software interrupts not getting called + bochs error

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
BenjiWiebe
Posts: 20
Joined: Thu Feb 07, 2013 9:47 pm
Location: Durham, Kansas
Contact:

software interrupts not getting called + bochs error

Post 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.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: software interrupts not getting called + bochs error

Post 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?
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
BenjiWiebe
Posts: 20
Joined: Thu Feb 07, 2013 9:47 pm
Location: Durham, Kansas
Contact:

Re: software interrupts not getting called + bochs error

Post 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.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: software interrupts not getting called + bochs error

Post by xenos »

Don't copy code without understanding what it does. Only use code you understand.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
BenjiWiebe
Posts: 20
Joined: Thu Feb 07, 2013 9:47 pm
Location: Durham, Kansas
Contact:

Re: software interrupts not getting called + bochs error

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