Problem with the 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
User avatar
darkinsanity
Member
Member
Posts: 45
Joined: Wed Sep 17, 2008 3:59 am
Location: Germany

Problem with the IDT

Post 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
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: Problem with the IDT

Post by yemista »

I bet you loaded the wrong address into the idtr. Whats the code that actually loads it?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Problem with the IDT

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: Problem with the IDT

Post 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
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: Problem with the IDT

Post 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
"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 ]
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Problem with the IDT

Post by Love4Boobies »

Combuster wrote:(WTF is code doing in HEADER files)
This reminds me of good ol' Pascal :?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
darkinsanity
Member
Member
Posts: 45
Joined: Wed Sep 17, 2008 3:59 am
Location: Germany

Re: Problem with the IDT

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