diff options
Diffstat (limited to 'common/constants/memory')
| -rw-r--r-- | common/constants/memory/flags.zig | 25 | ||||
| -rw-r--r-- | common/constants/memory/layout.zig | 17 | ||||
| -rw-r--r-- | common/constants/memory/memory.zig | 5 | ||||
| -rw-r--r-- | common/constants/memory/sizes.zig | 21 |
4 files changed, 68 insertions, 0 deletions
diff --git a/common/constants/memory/flags.zig b/common/constants/memory/flags.zig new file mode 100644 index 0000000..a057cf9 --- /dev/null +++ b/common/constants/memory/flags.zig @@ -0,0 +1,25 @@ +//! Memory Flag Constants + +pub const protection_read: u8 = 0x01; +pub const protection_write: u8 = 0x02; +pub const protection_execute: u8 = 0x04; +pub const protection_user: u8 = 0x08; + +pub const protection_kernel_read_only: u8 = protection_read; +pub const protection_kernel_read_write: u8 = protection_read | protection_write; +pub const protection_kernel_execute: u8 = protection_read | protection_execute; +pub const protection_user_read_only: u8 = protection_read | protection_user; +pub const protection_user_read_write: u8 = protection_read | protection_write | protection_user; +pub const protection_user_execute: u8 = protection_read | protection_execute | protection_user; + +pub const allocation_wired: u32 = 0x00000001; +pub const allocation_contiguous: u32 = 0x00000002; +pub const allocation_zero_fill: u32 = 0x00000004; +pub const allocation_no_cache: u32 = 0x00000008; +pub const allocation_write_combine: u32 = 0x00000010; + +pub const region_anonymous: u32 = 0x00000001; +pub const region_shared: u32 = 0x00000002; +pub const region_copy_on_write: u32 = 0x00000004; +pub const region_stack: u32 = 0x00000008; +pub const region_guard: u32 = 0x00000010; diff --git a/common/constants/memory/layout.zig b/common/constants/memory/layout.zig new file mode 100644 index 0000000..0e3780f --- /dev/null +++ b/common/constants/memory/layout.zig @@ -0,0 +1,17 @@ +//! Memory Layout Constants + +pub const kernel_base: u64 = 0xFFFFFE0000000000; +pub const kernel_text: u64 = 0xFFFFFE0001000000; +pub const kernel_heap: u64 = 0xFFFFFE1000000000; +pub const physmap_base: u64 = 0xFFFFFF0000000000; +pub const mmio_base: u64 = 0xFFFFFF8000000000; + +pub const kernel_physical_base: u64 = 0x100000; + +pub const user_space_start: u64 = 0x0000000000000000; +pub const user_space_end: u64 = 0x00007FFFFFFFFFFF; + +pub const kernel_stack_size: u64 = 64 * 1024; +pub const kernel_stack_pages: u64 = kernel_stack_size / 4096; + +pub const physmap_max_size: u64 = 512 * 1024 * 1024 * 1024; diff --git a/common/constants/memory/memory.zig b/common/constants/memory/memory.zig new file mode 100644 index 0000000..9d82b78 --- /dev/null +++ b/common/constants/memory/memory.zig @@ -0,0 +1,5 @@ +//! Memory Constants + +pub const layout = @import("layout.zig"); +pub const sizes = @import("sizes.zig"); +pub const flags = @import("flags.zig"); diff --git a/common/constants/memory/sizes.zig b/common/constants/memory/sizes.zig new file mode 100644 index 0000000..049b087 --- /dev/null +++ b/common/constants/memory/sizes.zig @@ -0,0 +1,21 @@ +//! Memory Size Constants + +pub const page_size: u64 = 4096; +pub const page_shift: u6 = 12; +pub const page_mask: u64 = page_size - 1; + +pub const large_page_size: u64 = 2 * 1024 * 1024; +pub const large_page_shift: u6 = 21; +pub const large_page_mask: u64 = large_page_size - 1; + +pub const huge_page_size: u64 = 1024 * 1024 * 1024; +pub const huge_page_shift: u6 = 30; +pub const huge_page_mask: u64 = huge_page_size - 1; + +pub const kilobyte: u64 = 1024; +pub const megabyte: u64 = 1024 * kilobyte; +pub const gigabyte: u64 = 1024 * megabyte; +pub const terabyte: u64 = 1024 * gigabyte; + +pub const entries_per_page_table: u64 = 512; +pub const page_table_levels: u8 = 4; |
