diff --git a/src/arch/x86_64/rmm.rs b/src/arch/x86_64/rmm.rs index 1e4b707..328a922 100644 --- a/src/arch/x86_64/rmm.rs +++ b/src/arch/x86_64/rmm.rs @@ -80,7 +80,7 @@ unsafe fn inner( kernel_base: usize, kernel_size_aligned: usize, stack_base: usize, stack_size_aligned: usize, env_base: usize, env_size_aligned: usize, - acpi_base: usize, acpi_size: usize + acpi_base: usize, acpi_size_aligned: usize ) -> BuddyAllocator { // First, calculate how much memory we have let mut size = 0; @@ -163,6 +163,19 @@ unsafe fn inner( flush.ignore(); // Not the active table } + // Map acpi with identity mapping + for i in 0..acpi_size_aligned / A::PAGE_SIZE { + let phys = PhysicalAddress::new(acpi_base + i * A::PAGE_SIZE); + let virt = A::phys_to_virt(phys); + let flags = page_flags::(virt); + let flush = mapper.map_phys( + virt, + phys, + flags + ).expect("failed to map frame"); + flush.ignore(); // Not the active table + } + println!("Table: {:X}", mapper.table().phys().data()); for i in 0..512 { if let Some(entry) = mapper.table().entry(i) { diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index 65993ea..508ad80 100644 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -172,7 +172,11 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! { // Read ACPI tables, starts APs #[cfg(feature = "acpi")] { - acpi::init(&mut active_table, if acpi_rsdps_base != 0 && acpi_rsdps_size > 0 { Some((acpi_rsdps_base, acpi_rsdps_size)) } else { None }); + acpi::init(&mut active_table, if acpi_rsdps_base != 0 && acpi_rsdps_size > 0 { + Some((acpi_rsdps_base + crate::PHYS_OFFSET as u64, acpi_rsdps_size)) + } else { + None + }); device::init_after_acpi(&mut active_table); }