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

A generic bitmap page allocator. More...

Collaboration diagram for PMM Bitmap:

Detailed Description

A generic bitmap page allocator.

The PMM bitmap provides a flexible allocator for more specific allocations, for example it can handle contiguous pages, specific alignments and allocating below some specified address. This flexibility comes at the cost of performance, so the bitmap should only be used when necessary.

Data Structures

struct  pmm_bitmap_t
 Represents a bitmap allocator's state. More...
 

Functions

void pmm_bitmap_init (pmm_bitmap_t *bitmap, void *buffer, uint64_t size, uintptr_t maxAddr)
 Initializes a PMM bitmap.
 
void * pmm_bitmap_alloc (pmm_bitmap_t *bitmap, uint64_t count, uintptr_t maxAddr, uint64_t alignment)
 Allocates a contiguous region of pages from the bitmap.
 
void pmm_bitmap_free (pmm_bitmap_t *bitmap, void *address, uint64_t count)
 Frees a region of pages, returning them to the bitmap.
 

Function Documentation

◆ pmm_bitmap_init()

void pmm_bitmap_init ( pmm_bitmap_t bitmap,
void *  buffer,
uint64_t  size,
uintptr_t  maxAddr 
)

Initializes a PMM bitmap.

Parameters
bitmapThe bitmap to initialize.
bufferThe buffer to use for the bitmap data.
sizeThe number of pages to manage.
maxAddrThe maximum address to manage.

Definition at line 7 of file pmm_bitmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmm_bitmap_alloc()

void * pmm_bitmap_alloc ( pmm_bitmap_t bitmap,
uint64_t  count,
uintptr_t  maxAddr,
uint64_t  alignment 
)

Allocates a contiguous region of pages from the bitmap.

Parameters
bitmapThe bitmap to allocate from.
countThe number of pages to allocate.
maxAddrThe maximum address for the allocation.
alignmentThe required alignment for the allocation.
Returns
On success, a pointer to the allocated region. On failure NULL and errno is set.

Definition at line 16 of file pmm_bitmap.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmm_bitmap_free()

void pmm_bitmap_free ( pmm_bitmap_t bitmap,
void *  address,
uint64_t  count 
)

Frees a region of pages, returning them to the bitmap.

Parameters
bitmapThe bitmap to free to.
addressThe address of the region to free.
countThe number of pages to free.

Definition at line 32 of file pmm_bitmap.c.

Here is the call graph for this function:
Here is the caller graph for this function: