Page 1 of 1

Problem with the IDT

Posted: Thu Jan 29, 2009 5:35 am
by darkinsanity
Hi @all,
I´m writing my kernel in FreeBASIC. Now I´m at the point where I should use interrupts. So I wrote some functions that create and load a IDT. I wrote a function and created an IDT-entry for it. Then I tried to call int 0 to test it, but instead of printing text to the screen, the kernel crashed.
I hope you can help me, I have no ideas what to do.

The version of my kernel with the problem is here: http://darkinsanity.freehoster.ch/FROST_debug.zip

The logfile of Bochs is here: http://darkinsanity.freehoster.ch/bochs.log

Re: Problem with the IDT

Posted: Thu Jan 29, 2009 2:28 pm
by yemista
I bet you loaded the wrong address into the idtr. Whats the code that actually loads it?

Re: Problem with the IDT

Posted: Thu Jan 29, 2009 7:38 pm
by thepowersgang
Try adding a break point in Bochs at the instruction where you invoke the error, then running 'info itd' in the debugger.
Then add restart and add a break point for the required error handler then run again. If the handler is called step through it until it errors itself.

I think that the fault is caused by calling 'IRET' from within a function's stack frame, normally you would use an assembler stub that saves the registers and then calls the C/BASIC handler.

Re: Problem with the IDT

Posted: Thu Jan 29, 2009 8:17 pm
by yemista
I looked at your code and I bet it crashes because the idt is loaded wrong. put a breakpoint right after the lidt instruction, then type info idt 0x00 and see what laddr of that entry is

Re: Problem with the IDT

Posted: Fri Jan 30, 2009 5:37 am
by Combuster
Ouchouchouch :shock:

No stack configured
Broken ISR stubs (mixing assembly with freebasic prologue/epilogue)
General language abuse (WTF is code doing in HEADER files)

the horror

Re: Problem with the IDT

Posted: Fri Jan 30, 2009 5:46 am
by Love4Boobies
Combuster wrote:(WTF is code doing in HEADER files)
This reminds me of good ol' Pascal :?

Re: Problem with the IDT

Posted: Mon Feb 16, 2009 5:54 am
by darkinsanity
ok, the problem is solved. it was because the structure of the IDT-entries were automaticaly aligned on the 4-byte boundaries.
and i´ll fix that broken isr stubs soon ^^
thx for your help