Page 1 of 1
[SOLVED]Zero IDT and Bochs
Posted: Mon Nov 25, 2013 10:25 am
by Vanzef
Hello, everybody!
I am trying to make my little boolader working. So, I am switching to Protected Mode, and trying to jump to my infinite cycle ("jmp .", it was loaded to 0x1000:0 address), but Bochs gives me a "3rd exeption with no resolution". I didn't load any IDT, cause I don't want to use any interrupts. So can I load zero idt (".quad 0x0") or I must to use real table?
Re: Zero IDT and Bochs
Posted: Mon Nov 25, 2013 10:34 am
by Combuster
It says "exception" for a reason. If you don't use interrupts, and your OS is 100% bug free, then you might not need an IDT. You probably have hardware interrupts disabled, you're not calling software interrupts, which only leaves bugs as the cause.
In other words, read the rest of the log first.
Re: Zero IDT and Bochs
Posted: Mon Nov 25, 2013 10:41 am
by Vanzef
OK, I make breakpoint before jumping, so:
"[CPU0 ]: exeption(): 3rd (13) exeption with no resloution, shutdown status is 00h, resseting"
After that Bochs goes to reboot.
Re: Zero IDT and Bochs
Posted: Mon Nov 25, 2013 10:51 am
by iansjack
Well, it's easy enough to set up an IDT with simple functions to handle exceptions. At the very minimum all they need to do is to put a character on the screen (different for each exception) and then halt the processor. At least that way you have some idea of what exception is being triggered, giving you a fighting chance of finding the cause. And if you set a breakpoint at the start of the exception handler you can inspect the state of the machine and find out exactly what is going wrong.
Why wouldn't you do that?
Re: Zero IDT and Bochs
Posted: Mon Nov 25, 2013 10:54 am
by Vanzef
There is one problem, set up normal IDT - too long, and I want to try my "protected jump" right now, but thanks anyway, I'l try it later)
Re: Zero IDT and Bochs
Posted: Mon Nov 25, 2013 11:55 am
by iansjack
It seems to me that maybe it's taking you longer feeling about in the dark than it would if you did things properly. But what do I know?
Laziness is seldom a good excuse.
Re: Zero IDT and Bochs
Posted: Tue Nov 26, 2013 9:56 am
by Vanzef
OK, I think that you are right, so I am trying to do this.
I use this structure for gdt and gdtr:
Code: Select all
flat:
117 .quad 0x0
118
119 //.quad 0x00cf9b000000ffff /*code*/
120 .word 0xFFFF //code limit_lo
121 .word 0x0000 //code base_lo
122 .byte 0x00 //code base_mid
123 .byte 0x9a //code exec|read|present
124 .byte 0xcf //limit_hi|(32bit|4KB granularity)<<4
125 .byte 0x00 //code base_lo
126
127 //.quad 0x00cf93000000ffff /*data*/
128 .word 0xFFFF //code limit_lo
129 .word 0x0000 //code base_lo
130 .byte 0x00 //code base_mid
131 .byte 0x92 //code r|w|present
132 .byte 0xcf //limit_hi|(32bit|4KB granularity)<<4
133 .byte 0x00 //code base_lo
flatr:
136 .word 3*8-1
137 .long (LOADSEG<<4)+flat
and this for idt and idt:
Code: Select all
139 idt:
140 .quad 0
141 .quad 0x0000220000080000
142 idtr:
143 .word 2*8-1
144 .long (LOADSEG<<4)+idt
I see no mistakes, but bochs doesn't like it. Here is registers state before ljmp:
Code: Select all
<bochs:3> sreg
es:0x1000, dh=0x00009301, dl=0x0000ffff, valid=1
Data segment, base=0x00010000, limit=0x0000ffff, Read/Write, Accessed cs:0x9000, dh=0x00009309, dl=0x0000ffff, valid=1
Data segment, base=0x00090000, limit=0x0000ffff, Read/Write, Accessed ss:0x9000, dh=0x00009309, dl=0x0000ffff, valid=7
Data segment, base=0x00090000, limit=0x0000ffff, Read/Write, Accessed ds:0x9000, dh=0x00009309, dl=0x0000ffff, valid=3
Data segment, base=0x00090000, limit=0x0000ffff, Read/Write, Accessed fs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1
tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1
gdtr:base=0x000900e0, limit=0x17
idtr:base=0x000900fe, limit=0xf
Could you help me?
Re: [SOLVED]Zero IDT and Bochs
Posted: Tue Nov 26, 2013 10:46 am
by Vanzef
Problem was with my ljmp code. It was in ".code 16" section and PM - 32-bit. I put ".code32" before my ljmp, so it works!
Thanks!