diff --git a/headers/memory.h b/headers/memory.h index 2d105a9..1344129 100644 --- a/headers/memory.h +++ b/headers/memory.h @@ -8,6 +8,7 @@ #define ACCESSED (1 << 4) #define INIT_FLAGS (PRESENT | RW | SUPERVISOR) #define PAGE_SIZE 4096 +#define PAGE_MASK 0xFFFFF000 #define HEAP_END 0xC0000000 void init_memory(void); diff --git a/src/kpanic.c b/src/kpanic.c index a75e0eb..8f72314 100644 --- a/src/kpanic.c +++ b/src/kpanic.c @@ -22,7 +22,7 @@ void kpanic(const char *format, ...) kprintf("fault at address: %p\n", faulting_address); /* for (int i = 16; i < 32; i++) */ /* kprintf("%p\n", page_table1[i]); */ - show_valloc_mem(); + /* show_valloc_mem(); */ /* kprintf("\n\n"); */ /* print_stack(); */ /* kprintf("\n\n"); */ diff --git a/src/memory/page.c b/src/memory/page.c index 5a9427c..947f894 100644 --- a/src/memory/page.c +++ b/src/memory/page.c @@ -43,11 +43,11 @@ void *alloc_pages(size_t size) PAGE_SIZE); return NULL; } - assert(page_table1[i] >> 12 == i); - page_table1[i] = (uint32_t)frame << 12 | INIT_FLAGS; + /* assert(page_table1[i] >> 12 == i); */ + page_table1[i] = ((uint32_t)frame & PAGE_MASK) | INIT_FLAGS; } PRINT_PTR(page_table1[index]); - return (void *)(page_table1[index] >> 12); + return (void *)(index * PAGE_SIZE); } int free_pages(void *page_ptr, size_t size) diff --git a/src/memory/virt/allocator.c b/src/memory/virt/allocator.c index 10592c8..2717068 100644 --- a/src/memory/virt/allocator.c +++ b/src/memory/virt/allocator.c @@ -41,11 +41,11 @@ static void new_block(Zone *zone, uint32_t zone_size) new_block->next = zone->free; new_block->next_free = zone->free; } - kprintf("before zone: %p zone->free: %p new_block: %p\n", zone, - zone->free, new_block); + /* kprintf("before zone: %p zone->free: %p new_block: %p\n", zone, */ + /* zone->free, new_block); */ zone->free = new_block; - kprintf("after zone: %p zone->free: %p new_block: %p\n", zone, - zone->free, new_block); + /* kprintf("after zone: %p zone->free: %p new_block: %p\n", zone, */ + /* zone->free, new_block); */ assert(zone->free == new_block); }