fix: change the pte to use a bitmask operation (still crashes but later)
This commit is contained in:
parent
7128f2640a
commit
55037b75fa
@ -8,6 +8,7 @@
|
|||||||
#define ACCESSED (1 << 4)
|
#define ACCESSED (1 << 4)
|
||||||
#define INIT_FLAGS (PRESENT | RW | SUPERVISOR)
|
#define INIT_FLAGS (PRESENT | RW | SUPERVISOR)
|
||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
|
#define PAGE_MASK 0xFFFFF000
|
||||||
#define HEAP_END 0xC0000000
|
#define HEAP_END 0xC0000000
|
||||||
|
|
||||||
void init_memory(void);
|
void init_memory(void);
|
||||||
|
@ -22,7 +22,7 @@ void kpanic(const char *format, ...)
|
|||||||
kprintf("fault at address: %p\n", faulting_address);
|
kprintf("fault at address: %p\n", faulting_address);
|
||||||
/* for (int i = 16; i < 32; i++) */
|
/* for (int i = 16; i < 32; i++) */
|
||||||
/* kprintf("%p\n", page_table1[i]); */
|
/* kprintf("%p\n", page_table1[i]); */
|
||||||
show_valloc_mem();
|
/* show_valloc_mem(); */
|
||||||
/* kprintf("\n\n"); */
|
/* kprintf("\n\n"); */
|
||||||
/* print_stack(); */
|
/* print_stack(); */
|
||||||
/* kprintf("\n\n"); */
|
/* kprintf("\n\n"); */
|
||||||
|
@ -43,11 +43,11 @@ void *alloc_pages(size_t size)
|
|||||||
PAGE_SIZE);
|
PAGE_SIZE);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
assert(page_table1[i] >> 12 == i);
|
/* assert(page_table1[i] >> 12 == i); */
|
||||||
page_table1[i] = (uint32_t)frame << 12 | INIT_FLAGS;
|
page_table1[i] = ((uint32_t)frame & PAGE_MASK) | INIT_FLAGS;
|
||||||
}
|
}
|
||||||
PRINT_PTR(page_table1[index]);
|
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)
|
int free_pages(void *page_ptr, size_t size)
|
||||||
|
@ -41,11 +41,11 @@ static void new_block(Zone *zone, uint32_t zone_size)
|
|||||||
new_block->next = zone->free;
|
new_block->next = zone->free;
|
||||||
new_block->next_free = zone->free;
|
new_block->next_free = zone->free;
|
||||||
}
|
}
|
||||||
kprintf("before zone: %p zone->free: %p new_block: %p\n", zone,
|
/* kprintf("before zone: %p zone->free: %p new_block: %p\n", zone, */
|
||||||
zone->free, new_block);
|
/* zone->free, new_block); */
|
||||||
zone->free = new_block;
|
zone->free = new_block;
|
||||||
kprintf("after zone: %p zone->free: %p new_block: %p\n", zone,
|
/* kprintf("after zone: %p zone->free: %p new_block: %p\n", zone, */
|
||||||
zone->free, new_block);
|
/* zone->free, new_block); */
|
||||||
assert(zone->free == new_block);
|
assert(zone->free == new_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user