core: (struct frame_zone).addr now represent address without the header

This commit is contained in:
Starnakin 2024-11-20 00:49:31 +01:00
parent 3315d85e0c
commit b7dd7761d5
2 changed files with 12 additions and 12 deletions

View File

@ -33,8 +33,7 @@ int free_frame(void *frame_ptr)
while (it && (frame_ptr < it->addr || frame_ptr >= it->addr + it->len))
it = it->next;
uint32_t index =
(frame_ptr + (it->len - it->size) - it->addr) / PAGE_SIZE;
uint32_t index = ((frame_ptr - it->addr) / PAGE_SIZE);
SET_FRAME(it->frame_table, index, 0);
if (it->first_free_frame > index)
it->first_free_frame = index;

View File

@ -58,24 +58,25 @@ static void add_frame_node(multiboot_memory_map_t *mmmt)
struct frame_zone *current =
(struct frame_zone *)GET_PAGE_ADDR(1022, index++);
memset(current, 0, sizeof(struct frame_zone));
current->addr = (void *)mmmt->addr;
current->frame_table = (uint32_t *)current + sizeof(struct frame_zone);
const size_t frame_table_size =
CEIL(current->size - sizeof(struct frame_zone), PAGE_SIZE * 32);
for (uint32_t i = index; index - i < CEIL(frame_table_size, PAGE_SIZE);
index++)
frame_zones_page_table[index] =
((uint32_t)zone + PAGE_SIZE & PAGE_MASK) | INIT_FLAGS;
// glhf reading this bozo
current->frame_table = (uint32_t *)current + sizeof(struct frame_zone);
current->len = mmmt->len;
// 32 is cause we are using uint32_t
current->size = (mmmt->len - (sizeof(struct frame_zone) +
(mmmt->len / PAGE_SIZE) / 32));
current->remaining_frames = current->size / PAGE_SIZE;
current->first_free_frame = 0;
current->next = NULL;
const size_t frame_table_size = current->size / (PAGE_SIZE * 32);
memset(current->frame_table, 0, frame_table_size * 4);
uint32_t i = index;
for (; index - i < CEIL(frame_table_size, PAGE_SIZE); index++)
frame_zones_page_table[index] =
((uint32_t)zone + PAGE_SIZE & PAGE_MASK) | INIT_FLAGS;
current->addr = (void *)mmmt->addr + index * PAGE_SIZE;
if (!head) {
head = current;
return;