wip: change memory to have access to page_tables and allocate these dynamically

This commit is contained in:
2024-10-25 15:11:11 +02:00
parent f5147e78f9
commit a9bfb49bb8
7 changed files with 52 additions and 35 deletions

View File

@ -14,7 +14,10 @@ static uint32_t remaining_frames = MAX_FRAMES;
static int32_t find_next_block(size_t nb_frames)
{
for (uint32_t i = 1024; i + nb_frames < MAX_FRAMES - 1; i++) {
PRINT_UINT(CEIL(HEAP_START, PAGE_SIZE));
for (uint32_t i = CEIL(HEAP_START, PAGE_SIZE);
i + nb_frames < MAX_FRAMES; i++) {
PRINT_UINT(i);
uint32_t j;
for (j = 0; frame_table[i + j] == 0 && j < nb_frames; j++)
;
@ -33,9 +36,8 @@ void *alloc_frames(size_t size)
return NULL;
}
int i = find_next_block(nb_frames);
if (i == -1) {
kprintf(KERN_WARNING "Not enough frames available\n",
MAX_FRAMES);
if (i < 0) {
kprintf(KERN_WARNING "Not enough frames available\n");
return NULL;
}
for (size_t j = 0; j < nb_frames; j++) {
@ -44,7 +46,7 @@ void *alloc_frames(size_t size)
}
assert(remaining_frames >= nb_frames);
remaining_frames -= nb_frames;
return (void *)(i * PAGE_SIZE); // WARNING: address translation cramptés
return (void *)(i * PAGE_SIZE);
}
int free_frames(void *frame_ptr, size_t size)