wip: frame_allocator working pretty good (?)

core: remove physical allocatory
This commit is contained in:
2024-11-19 16:57:19 +01:00
parent e8fd6c55eb
commit 3315d85e0c
14 changed files with 61 additions and 471 deletions

View File

@ -46,11 +46,10 @@ void *alloc_pages(size_t size)
return NULL;
}
for (size_t i = index; i - (size_t)index < nb_pages; i++) {
void *frame = alloc_frames(PAGE_SIZE);
void *frame = alloc_frame();
if (!frame) {
for (size_t j = index; j < i; j++)
free_frames((void *)(page_table[j] >> 12),
PAGE_SIZE);
free_frame((void *)(page_table[j] >> 12));
return NULL;
}
page_table[i] = ((uint32_t)frame & PAGE_MASK) | INIT_FLAGS;
@ -83,7 +82,7 @@ int free_pages(void *page_ptr, size_t size)
kprintf(KERN_WARNING "Page already free\n");
return -2;
}
free_frames((void *)(page_table[i] & PAGE_MASK), PAGE_SIZE);
free_frame((void *)(page_table[i] & PAGE_MASK));
page_table[i] = i << 12;
}