wip: change memory to have access to page_tables and allocate these dynamically
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user