Identity map ACPI

This commit is contained in:
Jeremy Soller
2022-03-01 12:52:06 -07:00
parent 47c3bbe13a
commit ae0d48d9ab
2 changed files with 19 additions and 2 deletions

View File

@@ -80,7 +80,7 @@ unsafe fn inner<A: Arch>(
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<A> {
// First, calculate how much memory we have
let mut size = 0;
@@ -163,6 +163,19 @@ unsafe fn inner<A: Arch>(
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::<A>(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) {

View File

@@ -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);
}