Page 1 of 1

Why does my PC reboot when I enable PAGE??

Posted: Fri Apr 25, 2003 7:57 pm
by cxsnew
hi,everybody:
I make a OS kernel image,when I load it(loaded at 0x100000 in the RAM) and execute it,an exception will occur:the PC will reboot when execute the following instructions:
...
movl ???$0x101000,%eax
/*Set the page directory table pointer.. */
??? movl ???%eax,%cr3???
movl ???%cr0,%eax
/*Set PG=1 */
??? orl ???$0x80000000,%eax
??? movl ???%eax,%cr0
??? /*Flush the prefetch-queue*/???
??? jmp ???1f?????????
1:
/*Make sure eip is relocated*/
??? movl ???$1f,%eax
??? jmp ???*%eax??????
1:???/*Display a char in the screen*/
??? movl???$0x0B8F96,%eax
??? movb???$67,%bl
??? movb???$0x07,%bh
??? movw???%bx,(%eax)
...
.org 0x1000
.globl page_dir
page_dir:
...
.org 0x2000
.globl page_tb0
page_tb0:
...
...
I am sure I have make the PE=1 in the CR0 register before enable PAGING,and map the 1st 4MB of RAM correctly in the page directory and page table 0.
But once executes the instructons above,the PC will reboot,why???pls help me,thanks very much!!!!
BTW:I make the kernel image whith the following Makefile:
kernel.img:kernel.o
ld $< -o $@ -s --oformat binary -Ttext 0x100000
kernel.o:kernel.S
as $< -o $@

Re:Why does my PC reboot when I enable PAGE??

Posted: Sat Apr 26, 2003 2:13 pm
by shad
Why did you put the cr3 into the cr0 ? "mov eax,cr3
mov cr0,eax" ?

Re:Why does my PC reboot when I enable PAGE??

Posted: Sat Apr 26, 2003 2:14 pm
by shad
disreguard that.. realized u are using at&t syntax... (im dumb.)

Re:Why does my PC reboot when I enable PAGE??

Posted: Sat Apr 26, 2003 2:15 pm
by shad
Anyway, i dont think you've mapped anything.. what is at 0x101000 ? If thats your page directory, does it have a mapping of where you are in memory?

Re:Why does my PC reboot when I enable PAGE??

Posted: Sat Apr 26, 2003 9:47 pm
by cxsnew
I am very sorry that I have a mistake when move the kernel which has been loaded priviously by bootloader in 0x10000 to its final RAM position 0x100000.Since the kernel was not loaded fully,so the data in .org 0x1000(page directory) and the data in .org 0x2000(page table 0) were not correct as expected!!
So an invalid instruction maybe fetched when I want to display a char in the screen,this result in the reboot.
Thanks!