Skip to content

Commit 5a2f1d5

Browse files
committed
x86_64: use ACPI address from bootloader
1 parent a07822a commit 5a2f1d5

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

kernel/src/arch/x86_64/acpi.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use crate::arch::consts::PHYSICAL_MEMORY_OFFSET;
21
use crate::memory::phys_to_virt;
3-
use acpi::{search_for_rsdp_bios, AcpiHandler, PhysicalMapping};
2+
use acpi::{parse_rsdp, AcpiHandler, PhysicalMapping};
43
use core::ptr::NonNull;
5-
use core::slice;
64

75
struct Handler;
86

@@ -14,7 +12,7 @@ impl AcpiHandler for Handler {
1412
) -> PhysicalMapping<T> {
1513
PhysicalMapping {
1614
physical_start: physical_address,
17-
virtual_start: NonNull::new((physical_address + PHYSICAL_MEMORY_OFFSET) as *mut T)
15+
virtual_start: NonNull::new(phys_to_virt(physical_address) as *mut T)
1816
.unwrap(),
1917
region_length: size,
2018
mapped_length: size,
@@ -26,9 +24,8 @@ impl AcpiHandler for Handler {
2624
}
2725
}
2826

29-
pub fn init() {
30-
let mut handler = Handler {};
31-
let res = unsafe { search_for_rsdp_bios(&mut handler) };
27+
pub fn init(rsdp_addr: usize) {
28+
let res = parse_rsdp(&mut Handler, rsdp_addr);
3229
if let Ok(acpi) = res {
3330
debug!("ACPI {:#x?}", acpi);
3431
}

kernel/src/arch/x86_64/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub extern "C" fn _start(boot_info: &'static BootInfo) -> ! {
7070
// init cpu scheduler and process manager, and add user shell app in process manager
7171
crate::process::init();
7272
// load acpi
73-
acpi::init();
73+
acpi::init(boot_info.acpi2_rsdp_addr as usize);
7474

7575
// wake up other CPUs
7676
AP_CAN_INIT.store(true, Ordering::Relaxed);

rboot

0 commit comments

Comments
 (0)