Memory Management

To use the functions described in this page, the file <hal.h> should be included.

JSLK supports memory management by the use of a virtual memory manager and a heap. There is currently no physical memory manager available, although one will be implemented before the first release. The following functions can be used to interface with the memory manager throughout the kernel:

uint32_t kmalloc(uint32_t sz)

Used to allocate a block of memory.

Arguments

uint32_t sz: The size of the block to allocate.

Return value

The virtual memory address of the allocated block is returned as an uint32_t.

x86

Currently, only the first 16 MB of available memory are used by the kernel. To manage memory on the x86, a GDT is set-up as a security measure to protect memory until paging is enabled. After paging is enabled, Once the virtual memory manager functions become available, and later in the startup when the heap is initialized, the heap integrates with the VMM and overrides its functions. The structures for the page directories, tables and pages can be found in paging.h, the paging code in paging.c.

Last updated