[SOLVED]Zero IDT and Bochs

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
Vanzef
Posts: 9
Joined: Mon Jul 29, 2013 11:45 am

[SOLVED]Zero IDT and Bochs

Post 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?
Last edited by Vanzef on Tue Nov 26, 2013 10:44 am, edited 1 time in total.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Zero IDT and Bochs

Post 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.
"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 ]
Vanzef
Posts: 9
Joined: Mon Jul 29, 2013 11:45 am

Re: Zero IDT and Bochs

Post 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.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Zero IDT and Bochs

Post 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?
Vanzef
Posts: 9
Joined: Mon Jul 29, 2013 11:45 am

Re: Zero IDT and Bochs

Post 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)
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Zero IDT and Bochs

Post 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.
Vanzef
Posts: 9
Joined: Mon Jul 29, 2013 11:45 am

Re: Zero IDT and Bochs

Post 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?
Vanzef
Posts: 9
Joined: Mon Jul 29, 2013 11:45 am

Re: [SOLVED]Zero IDT and Bochs

Post 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!
Post Reply