2022-10-17 16:43:35 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
struct UserHeap
|
|
|
|
{
|
|
|
|
bool init();
|
|
|
|
|
|
|
|
uint64_t request_virtual_page();
|
|
|
|
uint64_t request_virtual_pages(uint64_t count);
|
|
|
|
|
|
|
|
void free_virtual_page(uint64_t address);
|
|
|
|
void free_virtual_pages(uint64_t address, uint64_t count);
|
|
|
|
|
|
|
|
void free();
|
|
|
|
|
|
|
|
bool inherit(UserHeap& other);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t* bitmap = nullptr;
|
|
|
|
uint64_t bitmap_size = 0;
|
|
|
|
uint64_t start_index = 0;
|
|
|
|
bool bitmap_read(uint64_t index);
|
|
|
|
void bitmap_set(uint64_t index, bool value);
|
|
|
|
|
|
|
|
bool try_expand();
|
2022-10-17 16:49:19 +00:00
|
|
|
bool try_expand_size(uint64_t size);
|
2022-10-17 16:43:35 +00:00
|
|
|
};
|