core: (struct frame_zone).addr now represent address without the header
This commit is contained in:
parent
3315d85e0c
commit
b7dd7761d5
@ -33,8 +33,7 @@ int free_frame(void *frame_ptr)
|
|||||||
while (it && (frame_ptr < it->addr || frame_ptr >= it->addr + it->len))
|
while (it && (frame_ptr < it->addr || frame_ptr >= it->addr + it->len))
|
||||||
it = it->next;
|
it = it->next;
|
||||||
|
|
||||||
uint32_t index =
|
uint32_t index = ((frame_ptr - it->addr) / PAGE_SIZE);
|
||||||
(frame_ptr + (it->len - it->size) - it->addr) / PAGE_SIZE;
|
|
||||||
SET_FRAME(it->frame_table, index, 0);
|
SET_FRAME(it->frame_table, index, 0);
|
||||||
if (it->first_free_frame > index)
|
if (it->first_free_frame > index)
|
||||||
it->first_free_frame = index;
|
it->first_free_frame = index;
|
||||||
|
@ -58,24 +58,25 @@ static void add_frame_node(multiboot_memory_map_t *mmmt)
|
|||||||
|
|
||||||
struct frame_zone *current =
|
struct frame_zone *current =
|
||||||
(struct frame_zone *)GET_PAGE_ADDR(1022, index++);
|
(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 =
|
current->frame_table = (uint32_t *)current + sizeof(struct frame_zone);
|
||||||
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->len = mmmt->len;
|
current->len = mmmt->len;
|
||||||
|
// 32 is cause we are using uint32_t
|
||||||
current->size = (mmmt->len - (sizeof(struct frame_zone) +
|
current->size = (mmmt->len - (sizeof(struct frame_zone) +
|
||||||
(mmmt->len / PAGE_SIZE) / 32));
|
(mmmt->len / PAGE_SIZE) / 32));
|
||||||
current->remaining_frames = current->size / PAGE_SIZE;
|
current->remaining_frames = current->size / PAGE_SIZE;
|
||||||
current->first_free_frame = 0;
|
current->first_free_frame = 0;
|
||||||
current->next = NULL;
|
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) {
|
if (!head) {
|
||||||
head = current;
|
head = current;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user