This commit is contained in:
2026-06-14 18:53:54 -05:00
parent 53c5d7d40c
commit ac4b510221
6 changed files with 56 additions and 9 deletions

View File

@@ -13,6 +13,8 @@ static uint32_t max_address = 0;
static uint32_t total_available_memory = 0;
static uint8_t memory_bitmap[BITMAP_SIZE];
uint32_t* page_directory;
static void mark_free(uint32_t addr) {
uint32_t page_index = addr / PAGE_SIZE;
uint32_t byte_index = page_index / 8;
@@ -111,4 +113,20 @@ void* alloc_page() {
void free_page(void* addr) {
mark_free((uint32_t)addr);
}
void init_paging() {
page_directory = alloc_page();
for (int i = 0; i < 1024; i++) {
page_directory[i] = 0x0;
}
uint32_t* page_table = alloc_page();
page_directory[0] = (uint32_t)(page_table) | 0x3;
for (int i = 0; i < 1024; i++) {
page_table[i] = (i * PAGE_SIZE) | 0x3;
}
extern void load_page_directory(uint32_t* pd);
load_page_directory(page_directory);
}