Prepare for higher half
This commit is contained in:
parent
59327eb1b2
commit
729c7fd004
|
@ -1,6 +1,7 @@
|
|||
ENTRY(kstart)
|
||||
OUTPUT_FORMAT(elf64-x86-64)
|
||||
|
||||
/* KERNEL_OFFSET = 0xfffffe8000100000; */
|
||||
KERNEL_OFFSET = 0x100000;
|
||||
|
||||
SECTIONS {
|
||||
|
|
|
@ -21,6 +21,9 @@ pub const ENTRY_COUNT: usize = 512;
|
|||
/// Size of pages
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
|
||||
/// Offset of kernel from physical
|
||||
pub const KERNEL_OFFSET: usize = 0xfffffe8000000000;
|
||||
|
||||
/// Initialize paging
|
||||
pub unsafe fn init(stack_start: usize, stack_end: usize) -> ActivePageTable {
|
||||
extern {
|
||||
|
@ -66,7 +69,10 @@ pub unsafe fn init(stack_start: usize, stack_end: usize) -> ActivePageTable {
|
|||
let start_frame = Frame::containing_address(PhysicalAddress::new(start));
|
||||
let end_frame = Frame::containing_address(PhysicalAddress::new(end - 1));
|
||||
for frame in Frame::range_inclusive(start_frame, end_frame) {
|
||||
mapper.identity_map(frame, flags);
|
||||
mapper.identity_map(frame.clone(), flags);
|
||||
|
||||
let page = Page::containing_address(VirtualAddress::new(frame.start_address().get() + KERNEL_OFFSET));
|
||||
mapper.map_to(page, frame, flags);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -58,8 +58,9 @@ startup_arch:
|
|||
rep stosd
|
||||
|
||||
xor edi, edi
|
||||
;Link first PML4 to PDP
|
||||
;Link first PML4 and third to last PML4 to PDP
|
||||
mov DWORD [es:edi], 0x71000 | 1 << 1 | 1
|
||||
mov DWORD [es:edi + 509*8], 0x71000 | 1 << 1 | 1
|
||||
add edi, 0x1000
|
||||
;Link last PML4 to PML4
|
||||
mov DWORD [es:edi - 8], 0x70000 | 1 << 1 | 1
|
||||
|
|
Loading…
Reference in a new issue