feat(adapter): higher-half kernel (linked at PHYS_OFFSET, boot trampoline, no low mappings), fix SBI ecall clobbers
This commit is contained in:
@@ -6,3 +6,20 @@ pub use page_table::{
|
||||
PAGE_SIZE, PageTable, Sv39Flags, USER_VA_END, USER_VA_START, activate, active_root, check_wx,
|
||||
create_user_root, init_kernel_page_table, map_user_page, unmap_user_page,
|
||||
};
|
||||
|
||||
/// The kernel lives in the upper half of the address space: all of RAM and
|
||||
/// the MMIO windows appear at their physical address plus this offset (the
|
||||
/// start of Sv39's upper half), and the kernel image is linked there too,
|
||||
/// so one offset converts any kernel address. Must match linker.ld.
|
||||
pub const PHYS_OFFSET: usize = 0xFFFF_FFC0_0000_0000;
|
||||
|
||||
/// Where the kernel sees physical address `pa`.
|
||||
pub const fn phys_to_virt(pa: usize) -> usize {
|
||||
pa + PHYS_OFFSET
|
||||
}
|
||||
|
||||
/// The physical address behind kernel address `va` (a static, the boot
|
||||
/// heap, a page table). Only valid for addresses in the direct map.
|
||||
pub const fn virt_to_phys(va: usize) -> usize {
|
||||
va - PHYS_OFFSET
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user