OSDev.org https://forum.osdev.org/ |
|
Can't enable paging https://forum.osdev.org/viewtopic.php?f=1&t=56090 |
Page 1 of 1 |
Author: | Nasmare [ Wed Jan 12, 2022 7:32 am ] |
Post subject: | Can't enable paging |
Hello, i'm trying to create os in c++ and i stumbled upon 1 problem: setting the paging bit causes a Triple Fault. Code here: paging.asm: Code: [Bits 32] [Global PagingLoadDirectory] [Global PagingEnable] PagingLoadDirectory: push ebp mov ebp, esp mov eax, [esp+8] mov cr3, eax mov esp, ebp pop ebp ret PagingEnable: push ebp mov ebp, esp mov eax, cr0 or eax, 0x80000000 mov cr0, eax mov esp, ebp pop ebp ret kernel.cpp: Code: extern "C" void PagingLoadDirectory(psize_t directory); extern "C" void PagingEnable(); //... psize_t PageDirectory = (psize_t)0x1004000; psize_t PageTable = (psize_t)0x1005000; for (size_t i = 0; i < 1024; i++) PageDirectory[i] = 0x00000002; for (size_t i = 0x1000; i < 0x1400; i++) PageTable[i] = (i * 0x1000) | 3; PageDirectory[0] = (size_t)PageTable | 3; PagingLoadDirectory(PageDirectory); PagingEnable(); //Triple Fault What am I doing wrong? P.S. the value of the control registers after the error occurred: CR0=0x80000011 CR2=0x01002580 CR3=0x01004000 CR4=0x00000000 The kernel is placed after 16 MB (at address 0x1000000) |
Author: | Octocontrabass [ Thu Jan 13, 2022 9:53 pm ] |
Post subject: | Re: Can't enable paging |
Code: for (size_t i = 0x1000; i < 0x1400; i++) PageTable[i] = (i * 0x1000) | 3; I'm pretty sure this code isn't doing what you want. How big is the PageTable array supposed to be? Code: PageDirectory[0] = (size_t)PageTable | 3; Your kernel is loaded above 16MiB, but entry 0 of the page directory only covers virtual addresses between 0 and 4MiB. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |