triple fault when moving 0x3 to CR0

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.
Post Reply
earlz

triple fault when moving 0x3 to CR0

Post by earlz »

Well I got these trivial triple faults from moving anything into CR0 and bochs says like invalid opcode or something

this is my simple code which disabled paging and leaves everything else the same..

Code: Select all

mov eax,CR0
and eax,0x7FFFFFFF
mov CR0,eax
hlt
and bochs never gets to the hlt I really don't know how much simpler it could possibly be!
and the code in my bootloader is this and it works fine!

Code: Select all

   mov   eax, CR0      ;Turn on paging and protected mode
   or   eax, 0x80000001
   mov   CR0, eax
btw I have interrupts off in this whole thing
paulbarker

Re:triple fault when moving 0x3 to CR0

Post by paulbarker »

Are you sure you're in ring 0?
bluecode

Re:triple fault when moving 0x3 to CR0

Post by bluecode »

Are you sure that your code is identity mapped? If it is not then you have a huge problem, because after you disable paging you will be somewhere in ram, but certainly not where your "hlt" is.
earlz

Re:triple fault when moving 0x3 to CR0

Post by earlz »

well my code is mapped to 8FFF0000 but is actually at 0x100000

oh I got it, I have to jump to an 0x100000 piece of code and turn off cr0!


edit:
thank you so much I jmped to a piece of 0x100000 code and it is all good now(worked first time without me even changing around my memory manager!)
Post Reply