|
PatchworkOS
|
Bitmap. More...
Data Structures | |
| struct | bitmap_t |
| Bitmap structure. More... | |
Macros | |
| #define | BITMAP_BITS_TO_QWORDS(bits) (((bits) + 63) / 64) |
| Convert number of bits to number of qwords. | |
| #define | BITMAP_BITS_TO_BYTES(bits) (BITMAP_BITS_TO_QWORDS(bits) * sizeof(uint64_t)) |
| Convert number of bits to number of bytes. | |
| #define | BITMAP_QWORDS_TO_BITS(qwords) ((qwords) * 64) |
| Convert number of qwords to number of bits. | |
| #define | BITMAP_FOR_EACH_SET(idx, map) |
| Iterate over each set bit in the bitmap. | |
Functions | |
| static void | bitmap_init (bitmap_t *map, void *buffer, uint64_t length) |
| Initialize a bitmap. | |
| static bool | bitmap_is_set (bitmap_t *map, uint64_t idx) |
| Check if a bit is set in the bitmap. | |
| static void | bitmap_set (bitmap_t *map, uint64_t index) |
| Set a bit in the bitmap. | |
| static void | bitmap_set_range (bitmap_t *map, uint64_t low, uint64_t high) |
| Set a range of bits in the bitmap. | |
| static uint64_t | bitmap_find_clear_region_and_set (bitmap_t *map, uint64_t length, uintptr_t maxIdx, uint64_t align) |
| Find a clear region of specified length and alignment, and set it. | |
| static void | bitmap_clear (bitmap_t *map, uint64_t index) |
| Clear a bit in the bitmap. | |
| static void | bitmap_clear_range (bitmap_t *map, uint64_t low, uint64_t high) |
| Clear a range of bits in the bitmap. | |
| static uint64_t | bitmap_sum (bitmap_t *map, uint64_t low, uint64_t high) |
| Sum the number of set bits in a range. | |
| static uint64_t | bitmap_find_first_clear (bitmap_t *map) |
| Find the first clear bit in the bitmap. | |
| static uint64_t | bitmap_find_first_set (bitmap_t *map, uint64_t startIdx) |
| Find the first set bit in the bitmap. | |
Bitmap.
| #define BITMAP_BITS_TO_BYTES | ( | bits | ) | (BITMAP_BITS_TO_QWORDS(bits) * sizeof(uint64_t)) |
| #define BITMAP_BITS_TO_QWORDS | ( | bits | ) | (((bits) + 63) / 64) |
| #define BITMAP_FOR_EACH_SET | ( | idx, | |
| map | |||
| ) |
Iterate over each set bit in the bitmap.
| idx | Pointer to store the current index. |
| map | The bitmap. |
| #define BITMAP_QWORDS_TO_BITS | ( | qwords | ) | ((qwords) * 64) |
Clear a bit in the bitmap.
| map | Pointer to the bitmap. |
| index | Index of the bit to clear. |
Definition at line 186 of file bitmap.h.
References boot_memory_map_t::length, map, and MIN.
Referenced by _heap_alloc(), _heap_remove_from_free_list(), space_free_callback(), and vfs_ctx_free_fd().
Clear a range of bits in the bitmap.
| map | Pointer to the bitmap. |
| low | Low index of the range (inclusive). |
| high | High index of the range (exclusive). |
Definition at line 206 of file bitmap.h.
References boot_memory_map_t::length, map, and MIN.
Referenced by pmm_bitmap_free().
|
inlinestatic |
Find a clear region of specified length and alignment, and set it.
| map | Pointer to the bitmap. |
| length | Length of the region to find. |
| maxIdx | Maximum index to search up to. |
| align | Alignment of the region. |
map->length if not found. Definition at line 147 of file bitmap.h.
References bitmap_is_set(), bitmap_set_range(), boot_memory_map_t::length, map, MAX, and ROUND_UP.
Referenced by pmm_bitmap_alloc().
Find the first clear bit in the bitmap.
| map | The bitmap. |
map->length if none found. Definition at line 283 of file bitmap.h.
References BITMAP_BITS_TO_QWORDS, boot_memory_map_t::length, and map.
Referenced by space_alloc_callback(), vfs_ctx_alloc_fd(), and vfs_ctx_dup().
Find the first set bit in the bitmap.
| map | The bitmap. |
| startIdx | Index to start searching from. |
map->length if none found. Definition at line 323 of file bitmap.h.
References BITMAP_BITS_TO_QWORDS, boot_memory_map_t::length, and map.
Referenced by _heap_alloc().
Initialize a bitmap.
| map | The bitmap. |
| buffer | Pointer to the buffer, must be a multiple of 8 bytes. |
| length | Length of the bitmap in bits. |
Definition at line 74 of file bitmap.h.
References buffer, boot_memory_map_t::length, and map.
Referenced by _heap_init(), pmm_bitmap_init(), space_init(), and vfs_ctx_init().
Check if a bit is set in the bitmap.
| map | The bitmap. |
| idx | Index of the bit to check. |
Definition at line 88 of file bitmap.h.
References boot_memory_map_t::length, and map.
Referenced by bitmap_find_clear_region_and_set().
Set a bit in the bitmap.
| map | Pointer to the bitmap. |
| index | Index of the bit to set. |
Definition at line 106 of file bitmap.h.
References boot_memory_map_t::length, and map.
Referenced by _heap_add_to_free_list(), bitmap_set_range(), space_alloc_callback(), vfs_ctx_alloc_fd(), vfs_ctx_dup(), vfs_ctx_dup2(), and vfs_ctx_set_fd().
Set a range of bits in the bitmap.
| map | Pointer to the bitmap. |
| low | Low index of the range (inclusive). |
| high | High index of the range (exclusive). |
Definition at line 125 of file bitmap.h.
References bitmap_set(), boot_memory_map_t::length, and map.
Referenced by bitmap_find_clear_region_and_set().
Sum the number of set bits in a range.
| map | Pointer to the bitmap. |
| low | Low index of the range (inclusive). |
| high | High index of the range (exclusive). |
Definition at line 230 of file bitmap.h.
References boot_memory_map_t::length, and map.