34#define BITMAP_BITS_TO_QWORDS(bits) (((bits) + 63) / 64)
42#define BITMAP_BITS_TO_BYTES(bits) (BITMAP_BITS_TO_QWORDS(bits) * sizeof(uint64_t))
50#define BITMAP_QWORDS_TO_BITS(qwords) ((qwords) * 64)
58#define BITMAP_FOR_EACH_SET(idx, map) \
59 for (uint64_t qwordIdx = 0; qwordIdx < BITMAP_BITS_TO_QWORDS((map)->length); qwordIdx++) \
60 for (uint64_t tempQword = (map)->buffer[qwordIdx]; tempQword != 0; tempQword &= (tempQword - 1)) \
62 uint64_t bit = __builtin_ctzll(tempQword); \
63 *(idx) = qwordIdx * 64 + bit; \
64 *(idx) < (map)->length; \
73#define BITMAP_CREATE(name, bits) \
74 uint64_t name##Buffer[BITMAP_BITS_TO_QWORDS(bits)]; \
75 bitmap_t name = {.firstZeroIdx = 0, .length = (bits), .buffer = name##Buffer}
83#define BITMAP_CREATE_ZERO(name, bits) \
84 uint64_t name##Buffer[BITMAP_BITS_TO_QWORDS(bits)] = {0}; \
85 bitmap_t name = {.firstZeroIdx = 0, .length = (bits), .buffer = name##Buffer}
97#define BITMAP_DEFINE(name, bits) \
98 uint64_t name##Buffer[BITMAP_BITS_TO_QWORDS(bits)]; \
107#define BITMAP_DEFINE_INIT(name, bits) bitmap_init(&(name), name##Buffer, bits);
void bitmap_clear_range(bitmap_t *map, uint64_t low, uint64_t high)
Clear a range of bits in the bitmap.
bool bitmap_is_set(bitmap_t *map, uint64_t idx)
Check if a bit is set in the bitmap.
uint64_t bitmap_find_first_set(bitmap_t *map, uint64_t startIdx, uint64_t endIdx)
Find the first set bit in the bitmap.
void bitmap_init(bitmap_t *map, void *buffer, uint64_t length)
Initialize a bitmap.
void bitmap_set_range(bitmap_t *map, uint64_t low, uint64_t high)
Set a range of bits in the bitmap.
void bitmap_clear(bitmap_t *map, uint64_t index)
Clear a bit in the bitmap.
void bitmap_set(bitmap_t *map, uint64_t index)
Set a bit in the bitmap.
uint64_t bitmap_find_first_clear(bitmap_t *map, uint64_t startIdx, uint64_t endIdx)
Find the first clear bit in the bitmap.
uint64_t bitmap_find_clear_region_and_set(bitmap_t *map, uint64_t minIdx, uintptr_t maxIdx, uint64_t length, uint64_t alignment)
Find a clear region of specified length and alignment, and set it.
EFI_PHYSICAL_ADDRESS buffer
__UINTPTR_TYPE__ uintptr_t