wip: memory change
This commit is contained in:
@ -2,11 +2,12 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "kprintf.h"
|
||||
#include "memory.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define MAX_FRAMES (0xC0000000 / PAGE_SIZE)
|
||||
#define MAX_FRAMES (HEAP_END / PAGE_SIZE)
|
||||
|
||||
static uint8_t frame_table[MAX_FRAMES];
|
||||
static uint32_t remaining_frames = MAX_FRAMES;
|
||||
@ -37,16 +38,19 @@ void *alloc_frames(size_t size)
|
||||
MAX_FRAMES);
|
||||
return NULL;
|
||||
}
|
||||
for (size_t j = 0; j < nb_frames; j++)
|
||||
for (size_t j = 0; j < nb_frames; j++) {
|
||||
assert(j + i < MAX_FRAMES);
|
||||
frame_table[j + i] = 1;
|
||||
}
|
||||
assert(remaining_frames >= nb_frames);
|
||||
remaining_frames -= nb_frames;
|
||||
return (void *)(i * PAGE_SIZE);
|
||||
return (void *)(i * PAGE_SIZE); // WARNING: address translation cramptés
|
||||
}
|
||||
|
||||
int free_frames(void *frame_ptr, size_t size)
|
||||
{
|
||||
const uint32_t nb_frames = CEIL(size, PAGE_SIZE);
|
||||
const uint32_t start = (uint32_t)frame_ptr / PAGE_SIZE;
|
||||
const uint32_t start = (uint32_t)(frame_ptr + HEAP_END) / PAGE_SIZE;
|
||||
|
||||
if (start > MAX_FRAMES) {
|
||||
kprintf(KERN_WARNING "Address out of range\n");
|
||||
|
Reference in New Issue
Block a user