System hang at paging enable
Posted: Tue Apr 15, 2008 1:39 pm
Hey Guys,
I'm having a system hang when I enable paging and I'm not sure whats going on. I have checked to confirm that the physical memory manager is providing correctly aligned pages. Any ideas or tips would be great!
I am identity mapping up the the end of the kernel and its initial heap and I am mapping on page directory onto the last 4 MB of virtual memory for easy access.
Here is the code for the writeCRX etc
I'm having a system hang when I enable paging and I'm not sure whats going on. I have checked to confirm that the physical memory manager is providing correctly aligned pages. Any ideas or tips would be great!
I am identity mapping up the the end of the kernel and its initial heap and I am mapping on page directory onto the last 4 MB of virtual memory for easy access.
Code: Select all
VirtMemMgr::VirtMemMgr(void* nonIdentPagingStart)
{
system.console<<"Configuring Virtual/Physical Memory Managers... ";
phyMem = new PhyMemMgr(nonIdentPagingStart);
uint* pageDir = (uint*)phyMem->getPage();
uint* pageTable = (uint*)phyMem->getPage();
//map the first 4MB of memory to page table
uint i = 0;
//map exiting memory one to one
for(; i < (uint)nonIdentPagingStart; i += 4096)
pageTable[i] = i | GLBL_SUPER_RW_PRESENT;
kCurPTE = i >> 12;
//map remainder of PDE to address 0 and mark GLBL_SUPER_RO_NOTPRESENT
//which will for our purposes mean unbacked virtual memory
for(; i < 0x400000; i += 4096)
pageTable[i] = 0 | GLBL_SUPER_RO_NOTPRESENT;
pageDir[0] = (uint)pageTable | SUPER_RW_PRESENT;
for(uint j = 1; j < 1023; i++)
pageDir[i] = 0 | SUPER_RO_NOTPRESENT;
//Map TPE to last 4 MB of VM
mappedPTE = (uint*)0xFFC00000;
pageDir[1023] = (uint)pageDir;
//enable paging
writeCR3((uint)pageDir);
writeCR0(readCR0() | 0x80000000);
system.console<<"done"<<endl;
}
Code: Select all
readCR0:
mov eax, cr0
retn
writeCR0:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov cr0, eax
pop ebp
retn
readCR3:
mov eax, cr3
retn
writeCR3:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov cr3, eax
pop ebp
retn