|
PatchworkOS
|
A generic bitmap page allocator. More...
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. | |
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.
| 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.
| bitmap | The bitmap to allocate from. |
| count | The number of pages to allocate. |
| maxAddr | The maximum address for the allocation. |
| alignment | The required alignment for the allocation. |
NULL and errno is set. Definition at line 16 of file pmm_bitmap.c.
References pmm_bitmap_t::bitmap, bitmap, bitmap_find_clear_region_and_set(), count, pmm_bitmap_t::free, bitmap_t::length, MAX, pmm_bitmap_t::maxAddr, MIN, NULL, PAGE_SIZE, PML_HIGHER_HALF_START, and ROUND_UP.
Referenced by pmm_alloc_bitmap().
| void pmm_bitmap_free | ( | pmm_bitmap_t * | bitmap, |
| void * | address, | ||
| uint64_t | count | ||
| ) |
Frees a region of pages, returning them to the bitmap.
| bitmap | The bitmap to free to. |
| address | The address of the region to free. |
| count | The number of pages to free. |
Definition at line 32 of file pmm_bitmap.c.
References address, assert, pmm_bitmap_t::bitmap, bitmap, bitmap_clear_range(), count, pmm_bitmap_t::free, PAGE_SIZE, PML_HIGHER_TO_LOWER, and ROUND_DOWN.
Referenced by pmm_free_pages_unlocked(), and pmm_free_unlocked().
| void pmm_bitmap_init | ( | pmm_bitmap_t * | bitmap, |
| void * | buffer, | ||
| uint64_t | size, | ||
| uintptr_t | maxAddr | ||
| ) |
Initializes a PMM bitmap.
| bitmap | The bitmap to initialize. |
| buffer | The buffer to use for the bitmap data. |
| size | The number of pages to manage. |
| maxAddr | The maximum address to manage. |
Definition at line 7 of file pmm_bitmap.c.
References assert, pmm_bitmap_t::bitmap, bitmap, bitmap_init(), buffer, pmm_bitmap_t::free, pmm_bitmap_t::maxAddr, PAGE_SIZE, and pmm_bitmap_t::total.
Referenced by pmm_init().