PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
PMM Stack

A generic free stack page allocator. More...

Collaboration diagram for PMM Stack:

Detailed Description

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.

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.
 

Macro Definition Documentation

◆ PMM_BUFFER_MAX

#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.

Function Documentation

◆ pmm_stack_init()

void pmm_stack_init ( pmm_stack_t stack)

Initializes a PMM stack.

Parameters
stackThe stack to initialize.

Definition at line 5 of file pmm_stack.c.

Here is the caller graph for this function:

◆ pmm_stack_alloc()

void * pmm_stack_alloc ( pmm_stack_t stack)

Allocates a single page from the stack.

Parameters
stackThe stack to allocate from.
Returns
On success, a pointer to the allocated page. On failure NULL and errno is set.

Definition at line 12 of file pmm_stack.c.

Here is the caller graph for this function:

◆ pmm_stack_free()

void pmm_stack_free ( pmm_stack_t stack,
void *  address 
)

Frees a single page, returning it to the stack.

Parameters
stackThe stack to free to.
addressThe address of the page to free.

Definition at line 36 of file pmm_stack.c.

Here is the caller graph for this function: