PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
bitmap_set_range.c
Go to the documentation of this file.
1#include <sys/bitmap.h>
2
4{
5 if (low >= high || high > map->length)
6 {
7 return;
8 }
9
10 uint64_t firstQwordIdx = low / 64;
11 uint64_t firstBitInQword = low % 64;
12 uint64_t lastQwordIdx = (high - 1) / 64;
13 uint64_t lastBitInQword = (high - 1) % 64;
14
15 if (firstQwordIdx == lastQwordIdx)
16 {
17 uint64_t mask = (~0ULL << firstBitInQword) & (~0ULL >> (63 - lastBitInQword));
18 map->buffer[firstQwordIdx] |= mask;
19 return;
20 }
21
22 map->buffer[firstQwordIdx] |= (~0ULL << firstBitInQword);
23
24 for (uint64_t i = firstQwordIdx + 1; i < lastQwordIdx; i++)
25 {
26 map->buffer[i] = ~0ULL;
27 }
28
29 map->buffer[lastQwordIdx] |= (~0ULL >> (63 - lastBitInQword));
30}
void bitmap_set_range(bitmap_t *map, uint64_t low, uint64_t high)
Set a range of bits in the bitmap.
boot_memory_map_t * map
Definition mem.c:19
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Bitmap structure.
Definition bitmap.h:22
uint64_t length
Definition boot_info.h:58