Page 1 of 1

Double Fault if i run an infinite loop

Posted: Tue Apr 18, 2017 6:17 pm
by SeeSoftware
im creating an os for fun and i allready jumped to the kernel and i am in protected mode.

I setup the GDT and IDT in the kernel and everything seems to work but if i try to run an infinite loop in C afterwards (anything eg. for(;;),while(1)...) it generates a double fault (i catched the double fault to display an error).

But if i remove the CPU_initGDT and CPU_initIDT (both set the IDT or GDT table to appropriate values and run lidt and lgdt) it works fine.
(im allready setting a default GDT in the second stage bootloader )

Did anyone had this problem and how did he/she fix it ?

thanks in advance

Re: Double Fault if i run an infinite loop

Posted: Tue Apr 18, 2017 7:25 pm
by Brendan
Hi,
SeeSoftware wrote:Did anyone had this problem and how did he/she fix it ?
I'd be tempted to guess that your "CPU_initIDT" enables IRQs and nothing has reconfigured the PIC chips; which means that when the PIT timer causes an IRQ0 it's mapped to interrupt 0x08 (and the "interrupt 0x08" you see is not actually a double fault).


Cheers,

Brendan

Re: Double Fault if i run an infinite loop

Posted: Tue Apr 18, 2017 7:34 pm
by SeeSoftware
Brendan wrote:Hi,
SeeSoftware wrote:Did anyone had this problem and how did he/she fix it ?
I'd be tempted to guess that your "CPU_initIDT" enables IRQs and nothing has reconfigured the PIC chips; which means that when the PIT timer causes an IRQ0 it's mapped to interrupt 0x08 (and the "interrupt 0x08" you see is not actually a double fault).


Cheers,

Brendan

ahh thank you it makes sense because if i clear the interrupt flag then it will run fine because the IRQs wont fire (or something)

Re: Double Fault if i run an infinite loop

Posted: Tue Apr 18, 2017 9:03 pm
by SeeSoftware
Setting the PIC fixed my problem thank you Brendan