CS vodoo  :o

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
TexHawk

CS vodoo  :o

Post by TexHawk »

I have been experimenting with my bootsector code (along with the help of some people from this forum!) and after failure after failure I've come up with a pseudo-failure i.e. perhaps a glimmer of hope....

I was wondering if anyone has ever experienced this problem.  After loading the gdtr and setting the pmode bit, I made a jmp to my pmode code and this is where everything crashes.  Well after reviewing the register dump I see that the CS register correctly indexes its selector and is in full 32 bit mode however it still hiccups on the jump and crashes before I can reset the segment registers.  Anyone know why this would occur??  

Thanks,
Matt
HOS

RE:CS vodoo  :o

Post by HOS »

i had a similar problem with my code and it was fixed by placing the bits 16 and bits 32 directives in the correct place. ie if you are jumping to a 32bit pmode code segment, make sure that the code there is under bits 32 but the code before the jump to pmode is in bits 16. this is what worked for me.
Xenos

RE:CS vodoo  :o

Post by Xenos »

Now I know what made my OS crash! After setting the PE bit, CS still contains a 16bit segment selector and I tried to use 32bit code...
TexHawk

RE:CS vodoo  :o

Post by TexHawk »

Well I thought the jump to the pmode code reloaded the cs register to 32 bits by indexing into the GDT (?)  I tried moving the 'BITS 32' statement before the jump to pmode but I got some runtime error like 'jump_protected cs==0'But if move the 'BITS 32' statement after the jump the cs reloads correctly but everything else crashes.

Best Regards,
Matt
Adek336

RE:CS vodoo  :o

Post by Adek336 »

do you fixup gdtr/gdt? the bootloader is loaded at linear adress 0x7c00, so the gdtr should be fixed by that value; also the gdts (at least the code segment) should be fixed by 0x7c000. You would probably only need to:

GDTR:
  dw GDT_end - GDT0 -1
  dd GDT + 0x7c00

...

GDT2: //code
  dw 0xffff
  dw 0x7c00
  db 0
  db 0x9a
  db 0xcf
  db 0

but I´m not sure.

Cheers,
Adrian
Post Reply