Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Please can anyone help me, my kernel works fine until i try to initialize paging by setting the paging bit in the cr0 register.
My directory and page table are okay and the address of my page directory gets into the cr3 register fine(from BOCHS register info screen), but when i try to set the paging bit BOCHS resets and generates this message
add byte ptr ds:[eax],al:0000.
exception 13 (which is General Protection Fault)
__asm__ __volatile__ ( "movl %cr0, %eax \n"
"orl $0x80000000, %eax \n"
"movl %eax, %cr0 \n");
I even tried placing the page directory at 100000 and page table at 101000 to no avail
:(
Last edited by samuelagm on Thu Jan 13, 2011 10:43 am, edited 2 times in total.
And there shall be nothing impossible to those who believe
Do not use colours (red is indiscernable from the background in my theme) , fix your page tables as they point into nothingness, and browse the front page of this forum and look for the half dozen others that reported this exact error message.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Thanks alot Guys, moving the page directry and page table to 0x109c00 and 0x109d00 respectively and re-writing the code in pure assembly language (no more inline assembly) solved the problem , as for the colours in my post; forgive me I didn't bother to read the forum rules , it would'nt happen again.
And there shall be nothing impossible to those who believe
moving the page directry and page table to 0x109c00 and 0x109d00
Paging structures need to be aligned to 4K or the processor will either complain or silently align them for you (so they both end up at 0x109000)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:Paging structures need to be aligned to 4K or the processor will either complain or silently align them for you (so they both end up at 0x109000)
Yea, you're right, after a while I started getting "page not present exceptions" after enabling paging, after seeing your post I change both the page directory and page table addresses to 0x109000 and 0x10a000 respectively and it worked!
The cause of the initial problem I posted was because the page table address was 0x10100
instead of 0x101000, thats why I was getting the "eax" message. I'm loving OS deving its just like a soap opera
And there shall be nothing impossible to those who believe
samuelagm wrote:
and re-writing the code in pure assembly language (no more inline assembly)
Will that make your coding more efficient?
I wouldn't say yes, but I now prefer all my assembly codes in one or two asm files rather than being scattered in my c files, is there any drawback to this technique?
And there shall be nothing impossible to those who believe
samuelagm wrote:is there any drawback to this technique?
No...it's just that you have more work to do (assembling and linking), calling your asm code, more files...It's much more easier to just put asm snippet in your C code stream...and all is well...just make sure you know your tools.
That is especially true for very short streams of code like enabling paging, etc.