This repository has been archived on 2023-09-28. You can view files and clone it, but cannot push or open issues or pull requests.
homepage/content/projects/noxos/docs/codebase/mm/region.h.md

37 lines
2.4 KiB
Markdown

---
title: "region.h"
summary: "virtual memory space layout"
---
The first 4 digits of an address can be ignored, they are also ignored by the MMU,
but for clarity / readability reasons they are `FFFF` in the kernel space.
See _General Concepts / Memory Layout_(todo: add reference) and _General Concepts / Process Memory Isolation_(todo: add reference) for more details.
| Name | Start | Description |
|----------------------------------|--------------------|---------------------------------------------------|
| `MEM_REGION_PROCESS` | 0x0000000000000000 | This is the start of the process space |
| `MEM_REGION_PROCESS_EXEC` | 0x0000010000000000 | Every processes' executable will be mapped here |
| `MEM_REGION_PROCESS_THREAD_BASE` | 0x0000010100000000 | The start of the _Thread Data_ regions |
| `MEM_REGION_KERNEL` | 0xFFFF800000000000 | This is the start of the kernel space |
| `MEM_REGION_KERNEL_STACK_DUMMY` | 0xFFFFF00000000000 | This area is used when preparing a threads' stack |
| `MEM_REGION_KERNEL_HEAP` | 0xFFFFF80000000000 | The kernels' heap begins here |
| `MEM_REGION_KERNEL_THREAD_BASE` | 0xFFFFFF0000000000 | The kernel processes' _Thread Data_ regions |
| `MEM_REGION_KERNELEXEC` | 0xFFFFFFFF80000000 | The kernel executable is mapped here |
# `MEM_REGION_THREAD_OFFSET` - macro
This time the threads id specifies its offset in its processes' _Thread Data_ region.
# `KERNEL_START_ADDRESS` - macro
Returns the address of [_kernel_start](https://nerdcult.net/projects/noxos/docs/codebase/mm/region.h/#_kernel_start---global-variable).
# `KERNEL_END_ADDRESS` - macro
Returns the address of [_kernel_end](https://nerdcult.net/projects/noxos/docs/codebase/mm/region.h/#_kernel_end---global-variable).
# `_kernel_start` - global variable
This symbol is inserted by the linker at the beginning of the kernel.
To access its value use [KERNEL_START_ADDRESS](https://nerdcult.net/projects/noxos/docs/codebase/mm/region.h/#kernel_start_address---macro).
# `_kernel_end` - global variable
This symbol is inserted by the linker at the end of the kernel.
To access its value use [KERNEL_END_ADDRESS](https://nerdcult.net/projects/noxos/docs/codebase/mm/region.h/#kernel_end_address---macro).