wip: frame_allocator working pretty good (?)
core: remove physical allocatory
This commit is contained in:
@ -21,9 +21,25 @@
|
||||
#define GET_PAGE_ADDR(pd_index, pt_index) \
|
||||
((((uint32_t)pd_index * 1024) + (uint32_t)pt_index) * 4096)
|
||||
|
||||
#define GET_FRAME(frame_table, i) (frame_table[i / 8] & (1 << (i % 8)))
|
||||
#define SET_FRAME(frame_table, i, used) \
|
||||
do { \
|
||||
if (used) \
|
||||
frame_table[i / 8] |= (1 << (i % 8)); \
|
||||
else \
|
||||
frame_table[i / 8] &= ~(1 << (i % 8)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* len is the total size of the zone (ratio starnakin)
|
||||
* size is the remaining usable size after allocating
|
||||
* the struct for the linked list
|
||||
*/
|
||||
struct frame_zone {
|
||||
void *addr;
|
||||
uint32_t first_free_frame;
|
||||
uint32_t *frame_table;
|
||||
uint32_t len;
|
||||
uint32_t size;
|
||||
uint32_t remaining_frames;
|
||||
struct frame_zone *next;
|
||||
@ -40,8 +56,8 @@ extern struct frame_zone *head;
|
||||
|
||||
uint32_t *virt_to_phys(uint32_t *virt_addr);
|
||||
void init_memory(multiboot_info_t *mbd, uint32_t magic);
|
||||
void *alloc_frames(size_t size);
|
||||
int free_frames(void *frame_ptr, size_t size);
|
||||
void *alloc_frame(void);
|
||||
int free_frame(void *frame_ptr);
|
||||
void *alloc_pages(size_t size);
|
||||
int free_pages(void *page_ptr, size_t size);
|
||||
void init_page_table(uint32_t page_table[1024], uint16_t start);
|
||||
|
Reference in New Issue
Block a user