mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2025-10-13 21:25:07 -07:00
doing some memory work and gdt and timer and vga
This commit is contained in:
@@ -2,20 +2,18 @@
|
||||
#include "io.h"
|
||||
|
||||
page_directory_entry_t *page_directory = (page_directory_entry_t *)0x100000;
|
||||
page_table_entry_t *page_table = (page_table_entry_t *)0x101000; // Located right after the page directory
|
||||
page_table_entry_t *page_table = (page_table_entry_t *)0x101000;
|
||||
page_table_entry_t *heap_page_table = (page_table_entry_t *)0x102000; // Located right after the page directory
|
||||
|
||||
// Helper function to set up the page directory entry
|
||||
void set_page_directory(page_directory_entry_t *dir) {
|
||||
for (int i = 0; i < PAGE_DIRECTORY_SIZE; i++) {
|
||||
// Set up a page directory entry with identity mapping
|
||||
dir[i].present = 9;
|
||||
dir[i].rw = 0; // Read/Write
|
||||
dir[i].user = 0; // Kernel mode
|
||||
dir[i].write_through = 0;
|
||||
dir[i].cache_disabled = 0;
|
||||
dir[i].accessed = 0;
|
||||
dir[0].frame = (uint32_t)page_table >> 12;
|
||||
dir[i].present = 0;
|
||||
}
|
||||
dir[0].present = 1;
|
||||
dir[0].rw = 1;
|
||||
dir[0].user = 0;
|
||||
dir[0].frame = (uint32_t)page_table >> 12;
|
||||
}
|
||||
|
||||
// Helper function to set up the page table entry
|
||||
@@ -47,10 +45,26 @@ void enable_paging() {
|
||||
|
||||
// Initialize paging: set up the page directory and enable paging
|
||||
void paging_init() {
|
||||
// Set up the page directory and page tables
|
||||
// Set up identity-mapped page directory + table
|
||||
set_page_directory(page_directory);
|
||||
set_page_table(page_table);
|
||||
|
||||
// Enable paging
|
||||
// === Set up heap mapping at 0xC0100000 ===
|
||||
for (int i = 0; i < PAGE_TABLE_SIZE; i++) {
|
||||
heap_page_table[i].present = 1;
|
||||
heap_page_table[i].rw = 1;
|
||||
heap_page_table[i].user = 0;
|
||||
heap_page_table[i].write_through = 0;
|
||||
heap_page_table[i].cache_disabled = 0;
|
||||
heap_page_table[i].accessed = 0;
|
||||
heap_page_table[i].frame = (256 + i); // Start physical heap at 1MB (256*4KB = 1MB)
|
||||
}
|
||||
|
||||
// Index 772 = 0xC0100000 / 4MB
|
||||
page_directory[772].present = 1;
|
||||
page_directory[772].rw = 1;
|
||||
page_directory[772].user = 0;
|
||||
page_directory[772].frame = (uint32_t)heap_page_table >> 12;
|
||||
|
||||
enable_paging();
|
||||
}
|
||||
|
Reference in New Issue
Block a user