IDT

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
slacker

IDT

Post by slacker »

anyone see a problem in this code?
when an int0 occurs the PC reboots..

;-----------------------constants-------------
IDTpntr:
IDTlim DW IDTend-IDT
IDTbase DD IDT
;------------------------idt--------------------
IDT:
;int0
offsetL DW ISR0
CODEsel DW 0x08
zeroes DB 0x00
settings DB 0x8E
IDTend:
offsetH DW 0x00

;--------------------------isr's--------------------
ISR0:
PUSHA
PUSH ES
PUSH FS
PUSH GS
PUSH SI
PUSH DI

[extern _isr00]
call _isr00

POP DI
POP SI
POP GS
POP FS
POP ES
POPA
iret
Ozguxxx

Re:IDT

Post by Ozguxxx »

Might be caused by pusha, you must push all 32 bit registers, so I think you might want to try with pushad and popad... Also why did you put IDTEnd before offsetH? I could not understand it... Another question how do you call int0? It is reserved interrupt I mean do you cause a divide by 0 error intentionally to call int0? Also are you sure you are enabling interrupts in a good time I mean are you programming pic and setting idt correctly by loading idtr? Also your isr routine might cause an error... Different advices... Hope one of them helps... Good luck.
slacker

Re:IDT

Post by slacker »

i didnt enable interrupts and i did
int c = 7/0;
to cause the divide error.
do i have to enable interrupts for it to work?
Curufir

Re:IDT

Post by Curufir »

Processor exceptions will get called independent of whether you have the IDT setup correctly, are handling them correctly, or have interrupts enabled. The processor has no means to automatically recover from something like a GPF, so exceptions are never masked.
slacker

Re:IDT

Post by slacker »

but is there something in my code that would make the PC reboot?
Tim

Re:IDT

Post by Tim »

If you don't have an exception handler then any exception will cause the PC to reboot.
slacker

Re:IDT

Post by slacker »

my ISR pushed all registers, called an external function, and popped registers..why would that reboot the pc?
slacker

Re:IDT

Post by slacker »

p.s. the external function that was called printed("divide by zero error") and i know my print function works....
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:IDT

Post by Pype.Clicker »

declaring only one entry for your IDT is not a good idea. Even if it's just in order to test it, you should declare the first 32 interrupts to be valid and have a handler ,even if it just prints "kernel panic" and hang the processor. Any exception caught for a invalid (out of the IDT limit) interrupt will raise a GPF. If the GPF isn't valid, it raises a "double fault". As this one isn't valid aswell, you got a tripple fault condition, which resets the computer ...
Post Reply