Changeset View
Changeset View
Standalone View
Standalone View
head/sys/riscv/include/vmparam.h
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
#ifndef VM_LEVEL_0_ORDER | #ifndef VM_LEVEL_0_ORDER | ||||
#define VM_LEVEL_0_ORDER 9 | #define VM_LEVEL_0_ORDER 9 | ||||
#endif | #endif | ||||
/** | /** | ||||
* Address space layout. | * Address space layout. | ||||
* | * | ||||
* RISC-V implements up to a 48 bit virtual address space. The address space is | * RISC-V implements multiple paging modes with different virtual address space | ||||
* split into 2 regions at each end of the 64 bit address space, with an | * sizes: SV32, SV39 and SV48. SV39 permits a virtual address space size of | ||||
* out of range "hole" in the middle. | * 512GB and uses a three-level page table. Since this is large enough for most | ||||
* purposes, we currently use SV39 for both userland and the kernel, avoiding | |||||
* the extra translation step required by SV48. | |||||
* | * | ||||
* We limit the size of the two spaces to 39 bits each. | * The address space is split into two regions at each end of the 64-bit address | ||||
* space: | |||||
* | * | ||||
* Upper region: 0xffffffffffffffff | * 0x0000000000000000 - 0x0000003fffffffff 256GB user map | ||||
* 0xffffff8000000000 | * 0x0000004000000000 - 0xffffffbfffffffff unmappable | ||||
* 0xffffffc000000000 - 0xffffffc7ffffffff 32GB kernel map | |||||
* 0xffffffc800000000 - 0xffffffcfffffffff 32GB unused | |||||
* 0xffffffd000000000 - 0xffffffefffffffff 128GB direct map | |||||
* 0xfffffff000000000 - 0xffffffffffffffff 64GB unused | |||||
* | * | ||||
* Hole: 0xffffff7fffffffff | * The kernel is loaded at the beginning of the kernel map. | ||||
* 0x0000008000000000 | |||||
* | * | ||||
* Lower region: 0x0000007fffffffff | |||||
* 0x0000000000000000 | |||||
* | |||||
* We use the upper region for the kernel, and the lower region for userland. | |||||
* | |||||
* We define some interesting address constants: | * We define some interesting address constants: | ||||
* | * | ||||
* VM_MIN_ADDRESS and VM_MAX_ADDRESS define the start and end of the entire | * VM_MIN_ADDRESS and VM_MAX_ADDRESS define the start and end of the entire | ||||
* 64 bit address space, mostly just for convenience. | * 64 bit address space, mostly just for convenience. | ||||
* | * | ||||
* VM_MIN_KERNEL_ADDRESS and VM_MAX_KERNEL_ADDRESS define the start and end of | * VM_MIN_KERNEL_ADDRESS and VM_MAX_KERNEL_ADDRESS define the start and end of | ||||
* mappable kernel virtual address space. | * mappable kernel virtual address space. | ||||
* | * | ||||
* VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the | * VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the | ||||
* user address space. | * user address space. | ||||
*/ | */ | ||||
#define VM_MIN_ADDRESS (0x0000000000000000UL) | #define VM_MIN_ADDRESS (0x0000000000000000UL) | ||||
#define VM_MAX_ADDRESS (0xffffffffffffffffUL) | #define VM_MAX_ADDRESS (0xffffffffffffffffUL) | ||||
/* 32 GiB of kernel addresses */ | |||||
#define VM_MIN_KERNEL_ADDRESS (0xffffffc000000000UL) | #define VM_MIN_KERNEL_ADDRESS (0xffffffc000000000UL) | ||||
#define VM_MAX_KERNEL_ADDRESS (0xffffffc800000000UL) | #define VM_MAX_KERNEL_ADDRESS (0xffffffc800000000UL) | ||||
/* 128 GiB maximum for the direct map region */ | |||||
#define DMAP_MIN_ADDRESS (0xffffffd000000000UL) | #define DMAP_MIN_ADDRESS (0xffffffd000000000UL) | ||||
#define DMAP_MAX_ADDRESS (0xfffffff000000000UL) | #define DMAP_MAX_ADDRESS (0xfffffff000000000UL) | ||||
#define DMAP_MIN_PHYSADDR (dmap_phys_base) | #define DMAP_MIN_PHYSADDR (dmap_phys_base) | ||||
#define DMAP_MAX_PHYSADDR (dmap_phys_max) | #define DMAP_MAX_PHYSADDR (dmap_phys_max) | ||||
/* True if pa is in the dmap range */ | /* True if pa is in the dmap range */ | ||||
#define PHYS_IN_DMAP(pa) ((pa) >= DMAP_MIN_PHYSADDR && \ | #define PHYS_IN_DMAP(pa) ((pa) >= DMAP_MIN_PHYSADDR && \ | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |