fixed paging problem

This commit is contained in:
rami 2024-07-03 22:44:44 -04:00
parent faa6ce0757
commit bd20049519
2 changed files with 13 additions and 18 deletions

View File

@ -80,18 +80,6 @@ flush_tss:
ltr [esp+4]
ret
global enable_paging
enable_paging:
push eax
mov eax, [esp+4]
mov cr3, eax
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
pop eax
ret
extern exception_handler
%macro isr_err_stub 1
isr_stub_%+%1:

View File

@ -17,7 +17,6 @@ extern void pit_isr(void);
extern void jmp_user_mode(uint32_t esp, uint32_t eip);
extern void flush_tss(uint32_t segment_selector);
extern gdt_t gdt[6];
extern void enable_paging(uint32_t *page_directory);
void exception_handler(int_stack_frame_t r) {
LOG("Exception 0x%X (0x%X) has occurred\nEAX: 0x%08X\nECX: 0x%08X\nEDX: 0x%08X\nEBX: 0x%08X\nESI: 0x%08X\nEDI: 0x%08X\nEBP: 0x%08X\nESP: 0x%08X\n",
@ -94,17 +93,25 @@ void kernel(multiboot_info_t *info) {
#define PAGE_TAB_INDEX(x) (((x) >> 12) & 0x3FF)
#define PAGE_OFFSET(x) ((x) & 0xFFF)
LOG("Page directory: %08X -- Page table: %08X\n", page_dir, page_tab);
for (int i = 0; i < 1024; i++) {
page_tab[i] = (i * 0x1000) | PAGE_PRESENT | PAGE_RW | PAGE_USER;
page_tab[i] = (i * 0x1000) | PAGE_PRESENT | PAGE_RW | PAGE_USER;
}
for (int i = 0; i < 1024; i++) {
page_dir[i] = ((uint32_t)page_tab) | PAGE_PRESENT | PAGE_RW | PAGE_USER;
page_dir[i] = ((uint32_t)page_tab) | PAGE_PRESENT | PAGE_RW | PAGE_USER;
}
enable_paging(page_dir);
//enable_paging(page_dir);
asm volatile("mov %0, %%cr3" :: "r" (page_dir));
asm volatile(
"mov %%cr0, %%eax;"
"or $0x80000000, %%eax;"
"mov %%eax, %%cr0;"
:
:
: "%eax"
);
uint32_t stack = (uint32_t)mmap_find_first_free_block();
multi_mod_t *init = (multi_mod_t *)info->moduleaddress;