Page 1 of 1

software interrupts not getting called + bochs error

Posted: Mon Feb 11, 2013 8:49 am
by BenjiWiebe
GRUB2 is the bootloader.
I have the GDT set up.
I thought I had the IDT set up, but I am not sure if I did it right.
int i86_idt_initialize (uint16_t codeSel) {

// set up idtr for processor
_idtr.limit = sizeof (struct idt_descriptor) * I86_MAX_INTERRUPTS -1;
_idtr.base = (uint32_t)&_idt[0];

// null out the idt
memset((void*)&_idt[0], 0, sizeof(struct idt_descriptor) * I86_MAX_INTERRUPTS-1);

// register default handlers
int i;
for (i=0; i<I86_MAX_INTERRUPTS; i++)
i86_install_ir (i, I86_IDT_DESC_PRESENT | I86_IDT_DESC_BIT32,
codeSel, (I86_IRQ_HANDLER)i86_default_handler_asm);

// install our idt
idt_install ();

return 0;
}
I am calling the above function to load the IDT.

My i86_default_handler_asm just runs cli, hlt. In my kernel code, I divide by zero to trigger a software interrupt.

Another, possibly relevant, thing I noticed was in bochs's output:

Code: Select all

00132630827e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x00)
00132630827e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
It looks like something with the GDT. Could that be causing the problem?

Thanks.

Re: software interrupts not getting called + bochs error

Posted: Mon Feb 11, 2013 9:04 am
by xenos
BenjiWiebe wrote:It looks like something with the GDT. Could that be causing the problem?
No. It rather looks like a problem with your IDT. Are you sure that i86_install_ir and idt_install are working correctly?

Re: software interrupts not getting called + bochs error

Posted: Mon Feb 11, 2013 12:23 pm
by BenjiWiebe
XenOS wrote:
BenjiWiebe wrote:It looks like something with the GDT. Could that be causing the problem?
No. It rather looks like a problem with your IDT. Are you sure that i86_install_ir and idt_install are working correctly?
No. I am not sure at all. I **think** they are working correctly... I copied them from somewhere... Oh here it is: http://www.brokenthorn.com/Resources/Demos/Demo7.zip. I copied them from the IDT code in Demo7/SysCore/HAL I think.

Re: software interrupts not getting called + bochs error

Posted: Mon Feb 11, 2013 2:09 pm
by xenos
Don't copy code without understanding what it does. Only use code you understand.

Re: software interrupts not getting called + bochs error

Posted: Mon Feb 11, 2013 2:34 pm
by BenjiWiebe
XenOS wrote:Don't copy code without understanding what it does. Only use code you understand.
I read it through when I copied it, and it made sense, and I think I understand what it does. But I am not *positive*.