From 82ad6e2fa78f739bf6e18d8ec0603271d754f39e Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 19 Aug 2022 21:01:10 -0600 Subject: [PATCH] Remove devmap region from aarch64, use physmap instead --- src/arch/aarch64/consts.rs | 5 +---- src/arch/aarch64/device/gic.rs | 8 ++++---- src/arch/aarch64/device/rtc.rs | 4 ++-- src/arch/aarch64/device/serial.rs | 2 +- src/arch/aarch64/rmm.rs | 2 +- src/arch/aarch64/start.rs | 6 +++--- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/arch/aarch64/consts.rs b/src/arch/aarch64/consts.rs index dc31f89..997cc93 100644 --- a/src/arch/aarch64/consts.rs +++ b/src/arch/aarch64/consts.rs @@ -28,11 +28,8 @@ /// Size of kernel heap pub const KERNEL_HEAP_SIZE: usize = 1 * 1024 * 1024; // 1 MB - /// Offset of device map region - pub const KERNEL_DEVMAP_OFFSET: usize = KERNEL_HEAP_OFFSET - PML4_SIZE; - /// Offset of environment region - pub const KERNEL_ENV_OFFSET: usize = KERNEL_DEVMAP_OFFSET - PML4_SIZE; + pub const KERNEL_ENV_OFFSET: usize = KERNEL_HEAP_OFFSET - PML4_SIZE; /// Offset of temporary mapping for misc kernel bring-up actions pub const KERNEL_TMP_MISC_OFFSET: usize = KERNEL_ENV_OFFSET - PML4_SIZE; diff --git a/src/arch/aarch64/device/gic.rs b/src/arch/aarch64/device/gic.rs index 18d367f..20a6f11 100644 --- a/src/arch/aarch64/device/gic.rs +++ b/src/arch/aarch64/device/gic.rs @@ -61,7 +61,7 @@ impl GicDistIf { let start_frame = Frame::containing_address(PhysicalAddress::new(0x08000000)); let end_frame = Frame::containing_address(PhysicalAddress::new(0x08000000 + 0x10000 - 1)); for frame in Frame::range_inclusive(start_frame, end_frame) { - let page = Page::containing_address(VirtualAddress::new(frame.start_address().data() + crate::KERNEL_DEVMAP_OFFSET)); + let page = Page::containing_address(VirtualAddress::new(frame.start_address().data() + crate::PHYS_OFFSET)); mapper .get_mut() .expect("failed to access KernelMapper for mapping GIC distributor") @@ -70,13 +70,13 @@ impl GicDistIf { .flush(); } - self.address = crate::KERNEL_DEVMAP_OFFSET + 0x08000000; + self.address = crate::PHYS_OFFSET + 0x08000000; // Map in CPU0's interface let start_frame = Frame::containing_address(PhysicalAddress::new(0x08010000)); let end_frame = Frame::containing_address(PhysicalAddress::new(0x08010000 + 0x10000 - 1)); for frame in Frame::range_inclusive(start_frame, end_frame) { - let page = Page::containing_address(VirtualAddress::new(frame.start_address().data() + crate::KERNEL_DEVMAP_OFFSET)); + let page = Page::containing_address(VirtualAddress::new(frame.start_address().data() + crate::PHYS_OFFSET)); mapper .get_mut() .expect("failed to access KernelMapper for mapping GIC interface") @@ -85,7 +85,7 @@ impl GicDistIf { .flush(); } - GIC_CPU_IF.address = crate::KERNEL_DEVMAP_OFFSET + 0x08010000; + GIC_CPU_IF.address = crate::PHYS_OFFSET + 0x08010000; // Disable IRQ Distribution self.write(GICD_CTLR, 0); diff --git a/src/arch/aarch64/device/rtc.rs b/src/arch/aarch64/device/rtc.rs index bf4ddc3..178afcf 100644 --- a/src/arch/aarch64/device/rtc.rs +++ b/src/arch/aarch64/device/rtc.rs @@ -34,7 +34,7 @@ impl Pl031rtc { let end_frame = Frame::containing_address(PhysicalAddress::new(0x09010000 + 0x1000 - 1)); for frame in Frame::range_inclusive(start_frame, end_frame) { - let page = Page::containing_address(VirtualAddress::new(frame.start_address().data() + crate::KERNEL_DEVMAP_OFFSET)); + let page = Page::containing_address(VirtualAddress::new(frame.start_address().data() + crate::PHYS_OFFSET)); mapper .get_mut() .expect("failed to access KernelMapper for mapping RTC") @@ -43,7 +43,7 @@ impl Pl031rtc { .flush(); } - self.address = crate::KERNEL_DEVMAP_OFFSET + 0x09010000; + self.address = crate::PHYS_OFFSET + 0x09010000; } unsafe fn read(&self, reg: u32) -> u32 { diff --git a/src/arch/aarch64/device/serial.rs b/src/arch/aarch64/device/serial.rs index 8ffd08b..0cac8ef 100644 --- a/src/arch/aarch64/device/serial.rs +++ b/src/arch/aarch64/device/serial.rs @@ -16,7 +16,7 @@ pub unsafe fn init_early(dtb_base: usize, dtb_size: usize) { } if let Some((phys, size)) = device_tree::diag_uart_range(dtb_base, dtb_size) { - let virt = crate::KERNEL_DEVMAP_OFFSET + phys; + let virt = crate::PHYS_OFFSET + phys; { let mut serial_port = SerialPort::new(virt); serial_port.init(false); diff --git a/src/arch/aarch64/rmm.rs b/src/arch/aarch64/rmm.rs index 522267a..e819410 100644 --- a/src/arch/aarch64/rmm.rs +++ b/src/arch/aarch64/rmm.rs @@ -164,7 +164,7 @@ unsafe fn inner( Some(serial_base) => { let flush = mapper.map_phys( VirtualAddress::new(serial_base), - PhysicalAddress::new(serial_base - crate::KERNEL_DEVMAP_OFFSET), + PhysicalAddress::new(serial_base - crate::PHYS_OFFSET), PageFlags::new().write(true) ).expect("failed to map frame"); flush.ignore(); // Not the active table diff --git a/src/arch/aarch64/start.rs b/src/arch/aarch64/start.rs index b02e179..2adb7a2 100644 --- a/src/arch/aarch64/start.rs +++ b/src/arch/aarch64/start.rs @@ -81,7 +81,7 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! { KERNEL_SIZE.store(kernel_size, Ordering::SeqCst); // Try to find serial port prior to logging - device::serial::init_early(crate::KERNEL_DEVMAP_OFFSET + dtb_base, dtb_size); + device::serial::init_early(crate::PHYS_OFFSET + dtb_base, dtb_size); // Convert env to slice let env = slice::from_raw_parts((args.env_base + crate::PHYS_OFFSET) as *const u8, args.env_size); @@ -112,11 +112,11 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! { info!("Bootstrap entry point: {:X}", args.bootstrap_entry); println!("FILL MEMORY MAP START"); - device_tree::fill_memory_map(crate::KERNEL_DEVMAP_OFFSET + dtb_base, dtb_size); + device_tree::fill_memory_map(crate::PHYS_OFFSET + dtb_base, dtb_size); println!("FILL MEMORY MAP COMPLETE"); println!("FILL ENV DATA START"); - let env_size = device_tree::fill_env_data(crate::KERNEL_DEVMAP_OFFSET + dtb_base, dtb_size, env_base); + let env_size = device_tree::fill_env_data(crate::PHYS_OFFSET + dtb_base, dtb_size, env_base); println!("FILL ENV DATA COMPLETE"); // Initialize RMM