BareMetal-OS-legacy
BareMetal-OS-legacy copied to clipboard
Higher half
Move the kernel to the higher half of memory (0xFFFF800000000000).
Required adjustment of the PML4.
Why would we want to put the Kernel up there?
All the reasons I Saw for doing so are:
- 32-bit binaries can use the whole address space
- we don't have precompiled 32-bit binaries for BareMetal
- It's easier to set up VM86 processes
- currently there is no option to switch to VM86 mode and i don't think its planned
- The Applications don't have to know how much memory is required by the Kernel
- I think with such a tiny Kernel we're unlikely to hit 0x200000 soon so that should be ok too
If there are reasons to put the Kernel in the higher helf please let me know, otherwise it'd suggest to keep it just where it is
P.S. Am I right in my prediction that the whole memory just gets identity mapped?
The main reason was to have a linear range of memory without gaps. There are a lot of gaps in lower memory that can't be used by an application. The plan would be to map available memory starting at the higher half and run out of there without worrying about gaps.
ah ok this sounds reasonable isn't this a issue of th bootloader? especially this part
; Move the trailing binary to its final location mov rsi, 0x8000+6144 ; Memory offset to end of pure64.sys mov rdi, 0x100000 ; Destination address at the 1MiB mark mov rcx, 0x0D00 ; For up to 26KiB kernel (26624 / 8) rep movsq ; Copy 8 bytes at a time
and all the things calling the kernel syscalls (0x100010 - 0x1000C0 at the moment) must be adjusted EDIT: and the paging table