Double Fault if i run an infinite loop

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
SeeSoftware
Posts: 13
Joined: Tue Apr 18, 2017 6:02 pm

Double Fault if i run an infinite loop

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Double Fault if i run an infinite loop

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
SeeSoftware
Posts: 13
Joined: Tue Apr 18, 2017 6:02 pm

Re: Double Fault if i run an infinite loop

Post 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)
SeeSoftware
Posts: 13
Joined: Tue Apr 18, 2017 6:02 pm

Re: Double Fault if i run an infinite loop

Post by SeeSoftware »

Setting the PIC fixed my problem thank you Brendan
Post Reply