|
PatchworkOS
|
A generic free stack page allocator. More...
Data Structures | |
| struct | page_buffer_t |
| Structure for a page buffer in the PMM stack. More... | |
| struct | pmm_stack_t |
| PMM stack structure for managing higher physical memory. More... | |
Macros | |
| #define | PMM_BUFFER_MAX ((PAGE_SIZE - sizeof(page_buffer_t)) / sizeof(void*)) |
The maximum number of pages that can be stored in a page_buffer_t. | |
Functions | |
| void | pmm_stack_init (pmm_stack_t *stack) |
| Initializes a PMM stack. | |
| void * | pmm_stack_alloc (pmm_stack_t *stack) |
| Allocates a single page from the stack. | |
| void | pmm_stack_free (pmm_stack_t *stack, void *address) |
| Frees a single page, returning it to the stack. | |
A generic free stack page allocator.
The PMM stack provides a fast, O(1) allocator for single pages. It uses freed pages to store metadata about other free pages, forming a stack of page buffers.
| #define PMM_BUFFER_MAX ((PAGE_SIZE - sizeof(page_buffer_t)) / sizeof(void*)) |
The maximum number of pages that can be stored in a page_buffer_t.
Definition at line 36 of file pmm_stack.h.
| void * pmm_stack_alloc | ( | pmm_stack_t * | stack | ) |
Allocates a single page from the stack.
| stack | The stack to allocate from. |
NULL and errno is set. Definition at line 12 of file pmm_stack.c.
References address, pmm_stack_t::free, pmm_stack_t::index, pmm_stack_t::last, NULL, page_buffer_t::pages, PMM_BUFFER_MAX, page_buffer_t::prev, and stack.
Referenced by pmm_alloc(), and pmm_alloc_pages().
| void pmm_stack_free | ( | pmm_stack_t * | stack, |
| void * | address | ||
| ) |
Frees a single page, returning it to the stack.
| stack | The stack to free to. |
| address | The address of the page to free. |
Definition at line 36 of file pmm_stack.c.
References address, pmm_stack_t::free, pmm_stack_t::index, pmm_stack_t::last, next, NULL, PAGE_SIZE, page_buffer_t::pages, PMM_BUFFER_MAX, page_buffer_t::prev, ROUND_DOWN, and stack.
Referenced by pmm_alloc_pages(), pmm_free_pages_unlocked(), and pmm_free_unlocked().
| void pmm_stack_init | ( | pmm_stack_t * | stack | ) |
Initializes a PMM stack.
| stack | The stack to initialize. |
Definition at line 5 of file pmm_stack.c.
References pmm_stack_t::free, pmm_stack_t::index, pmm_stack_t::last, NULL, and stack.
Referenced by pmm_init().