Module kernel_map

Source
Expand description

This module contains constants that define how the kernel address space is laid out on RISC-V, using the Sv39 paging model. The Sv39 model provides us with a 512GiB address space, which is a little more compact than the layout we have on other architectures or with Sv48, but still more than sufficient for the vast majority of platforms.

For simplicity, we reserve the top half of the address space, from 0xffff_ffc0_0000_0000 to 0xffff_ffff_ffff_ffff, for the kernel - this makes it easy to distinguish kernel addresses from userspace ones (both visually, and in code by testing a single sign-extended bit).

All of physical memory is mapped at the base of kernel-space.

The top 1GiB is reserved for the kernel itself, starting at 0xffff_ffff_c000_0000.

Constants§

KERNEL_ADDRESS_SPACE_START
KERNEL_BASE
The kernel starts at -1GiB. The kernel image is loaded directly at this address, and the following space until the top of memory is managed dynamically and contains the boot info structures, memory map, and kernel heap.
PHYSICAL_MAP_BASE

Functions§

physical_to_virtual
Access a given physical address through the physical mapping. This cannot be used until the kernel page tables have been switched to.