Bitmap page allocator that scans the bitmap linearly looking for size
amount of pages. Everytime it founds a free page, it check if the next size
pages are also free, if yes it marks them as allocated and returns a pointer to the first page
uint64_t *bitmap;
#define setpage(p, x) bitmap[p / 64] = x << (p % 64) | bitmap[p / 64]
#define getpage(p) bitmap[p / 64] & ((1 << (p % 64)))
void *palloc(int size) {
struct limine_hhdm_response *hhdm_res = hhdm_req.response;
int page = PGSIZE, p = 0;
while (1) {
// if free
if ((getpage(page)) == 0) {
// check that there are 'size' amount of pages free
for (p = page; p < (size + page); ++p) {
if ((getpage(p)) == 1)
break;
}
// mark the pages as used
if (p == size + page) {
for (p = page; p < (size + page); ++p)
setpage(p, 1);
return (void*) hhdm_res + (page * PGSIZE);
}
};
page++;
};
}
```