Skip to main content

kernel/arch/x86_64/mm/
layout.rs

1// SPDX-License-Identifier: GPL-3.0-only
2//! All locations of where things like HHDM, kernel image and more are mapped in the
3//! processor's address space
4//!
5//! Authors: MarioS271
6
7use crate::lib::addr::VirtAddr;
8
9// TODO: ASLR
10
11// Higher Half (Kernel)
12pub const KERNEL_IMAGE_BASE: VirtAddr = VirtAddr::new(0xffff_ffff_8000_0000);
13pub const KERNEL_IMAGE_SIZE: u64 = 1 << 31;  // 2 GiB
14
15pub const KERNEL_MMIO_BASE: VirtAddr = VirtAddr::new(0xffff_f000_0000_0000);
16pub const KERNEL_MMIO_SIZE: u64 = 1 << 43;  // 8 TiB
17
18pub const KERNEL_PAGE_ARRAY_BASE: VirtAddr = VirtAddr::new(0xffff_e000_0000_0000);
19pub const KERNEL_PAGE_ARRAY_SIZE: u64 = 1 << 44;  // 16 TiB
20
21pub const KERNEL_VMAP_BASE: VirtAddr = VirtAddr::new(0xffff_d000_0000_0000);
22pub const KERNEL_VMAP_SIZE: u64 = 1 << 44;  // 16 TiB
23
24pub const KERNEL_STACKS_BASE: VirtAddr = VirtAddr::new(0xffff_c000_0000_0000);
25pub const KERNEL_STACKS_SIZE: u64 = 1 << 44;  // 16 TiB
26
27pub const KERNEL_HHDM_BASE: VirtAddr = VirtAddr::new(0xffff_8000_0000_0000);
28pub const KERNEL_HHDM_SIZE: u64 = 1 << 46;  // 64 TiB
29
30
31pub const KERNEL_STACK_SIZE: u64 = 16_384;  // 16 KiB
32pub const KERNEL_STACK_SLOT_SIZE: u64 = 1 << 20;  // 1 MiB
33
34
35// Lower Half (Userspace)
36pub const USER_MAX: u64 = 0x0000_8000_0000_0000;
37pub const USER_STACK_TOP: VirtAddr = VirtAddr::new(0x0000_7fff_ffff_f000);
38
39pub const USER_MMAP_BASE: VirtAddr = VirtAddr::new(0x0000_7000_0000_0000);
40
41pub const USER_MMAP_MIN: VirtAddr = VirtAddr::new(0x0000_0000_0001_0000); // 64 KiB