My Kernel v0.1.0
Collaboration diagram for Memory Constants:

Modules

 Memory Constants - x86
 Constants related to the kernel's memory layout on the x86 architecture.
 

Macros

#define KERNEL_STACK_SIZE   0x4000U
 
#define USER_STACK_SIZE   0x10000U
 
#define KERNEL_PHYSICAL_START   0x00100000UL
 Physical address our kernel is loaded at.
 
#define KERNEL_HIGHER_HALF_OFFSET   0xC0000000UL
 Offset used fo relocation when linking our kernel.
 
#define KERNEL_HIGHER_HALF_PHYSICAL(_virtual)    ((u32)(_virtual) - KERNEL_HIGHER_HALF_OFFSET)
 Compute the physical equivalent of a higher half relocated virtual address.
 
#define KERNEL_HIGHER_HALF_VIRTUAL(_physical)    ((u32)(_physical) + KERNEL_HIGHER_HALF_OFFSET)
 Compute the higher half virtual equivalent of a physical address.
 
#define VMM_RESERVED_END   0x100000UL
 Size of the area reserved for allocating memory management structures. More...
 
#define NULL_PAGE_SIZE   PAGE_SIZE
 A single page of memory reserved to detect NULL references.
 

Variables

u32 _kernel_code_start
 Address of the byte located just before the end of the kernel's code. More...
 
u32 _kernel_code_end
 Address of the byte located just after the end of the kernel's code. More...
 
#define KERNEL_VMM_RESERVED_END   (PAGE_TABLES_START)
 Location of the reserved range for the kernel's VMM structure kernel_vmm.
 
#define KERNEL_VMM_RESERVED_START   (KERNEL_VMM_RESERVED_END - VMM_RESERVED_SIZE)
 Location of the reserved range for the kernel's VMM structure kernel_vmm.
 

Detailed Description

Memory Constants

Constants related to the kernel's memory layout.

Virtual address space layout

 0xFFFF_FFFF --------------------
             |                  |
             |    Page Tables   |
 0xFFC0_0000 |------------------|
             |      Kernel      |
             |   VMM Reserved   |
 0xFFB0_0000 |------------------|
             |                  |
             |                  |
             |                  |
             |  Kernel Memory   |
             |                  |
             |                  |
             |                  |
 0xC000_0000 |------------------|
             |                  |
             |                  |
             |                  |
             |                  |
             |       ...        |
             |                  |
             |                  |
             |                  |
             |                  |
             |                  |
 0x0010_0000 |------------------|
             |   VMM Reserved   |
 0x0001_0000 --------------------
             |     NULL Page    |
 0x0000_0000 --------------------

Macro Definition Documentation

◆ KERNEL_STACK_SIZE

#define KERNEL_STACK_SIZE   0x4000U

Size of the kernel's stack

◆ USER_STACK_SIZE

#define USER_STACK_SIZE   0x10000U

Size of the user stack

◆ VMM_RESERVED_END

#define VMM_RESERVED_END   0x100000UL

~1MiB Virtual memory range reserved for allocating VMA structures.

See also
vmm

Variable Documentation

◆ _kernel_code_end

u32 _kernel_code_end
extern

Any byte written after this address will not overwrite our kernel's executable binary.

Note
this address is defined inside the kernel's linker scrpit.

◆ _kernel_code_start

u32 _kernel_code_start
extern

Any byte written after this address WILL overwrite our kernel's executable binary.

Note
this address is defined inside the kernel's linker scrpit.