d4ilyrun/kernel

Switch to a higher-half kernel design

Closed this issue · 0 comments

What

A higher-half kernel is a kernel whose code resides at the beginning of the RAM (e.g. physical address == 0x00100000), but which appears to be linked in the higher half of the address space (i.e. virtual address > 3GiB). This can be done through the use of linker script.

Why

Higher-half kernel have many benefits:

  • Reserving the lower half of the address space for userland programs
  • Easily linking user applications regardless of the kernel code's total current size
  • Being compatible with hexadecimal mnemonic constants (e.g. 0xdeadbeef)

How

From what I gathered:

  1. Modify the linkerscript using the AT directive
  2. Use a temporary static PD and PT to map the kernel before booting
  3. Run as usual until the C code sets up paging completely (overriding the temporary paging structure in the process)
  4. Benefit

References