Hullo all. I would like to first mention that the next time I'm at a computer with internet access I'll further address the problem with some code to show, unfortunately I forgot my source code before I left the house to the library (My house has no internet access.)
I'm having trouble with either my kernel's IDT or how it handles interrupts. At first when I went to enable interrupts my ISR/IRQ handler was working great. I knew because I was getting a double fault exception that I couldn't pinpoint. After several hours of programming and a night of reset (and more programming) I determined I would try to rewrite all of the GDT/IDT/ISR/IRQ portion of the OS. Now, I haven't gotten to the IRQ part specifically (I'm following bran's kernel development tutorial to ensure that I'm doing everything right.) Now I when I try to enable interrupts (at the part in the tutorial where Brandon says to try dividing by zero.) I've tried this with and without interrupts disabled (without it, it doesn't work (obviously.)) With interrupts enabled QEMU manages to crash without any useful information, and I'm unable to see any useful messages.
I'm developing my OS in Linux, and I'm not following the tutorial *exactly.* (GDTs are done in just assembly, for example, and the video doesn't need to be initialized (and it's working great.)) But none of what I did should really be an issue of the problem. I'm sure the problem would go away if I just copied all of the "bkerndev" code, but that would be cheating, and it wouldn't be my code (so what would the fun be in that?)
Anyways, I'm hoping someone can reveal some sort of technique I could use to effectively debug the problem, or inform me of the most likely problem from the description above (sort of like going to a doctor.)
Thanks in advance.
Cheers,
-naota
IDT/interrupt problems [FIXED]
- AaronMiller
- Member
- Posts: 81
- Joined: Thu Mar 06, 2008 1:26 pm
- Location: Roseville, California (USA)
- Contact:
Re: IDT/interrupt problems
Exceptions can happen whether interrpts are disabled or not. if you doAaronMiller wrote:
I'm having trouble with either my kernel's IDT or how it handles interrupts. At first when I went to enable interrupts my ISR/IRQ handler was working great. I knew because I was getting a double fault exception that I couldn't pinpoint. After several hours of programming and a night of reset (and more programming) I determined I would try to rewrite all of the GDT/IDT/ISR/IRQ portion of the OS. Now, I haven't gotten to the IRQ part specifically (I'm following bran's kernel development tutorial to ensure that I'm doing everything right.) Now I when I try to enable interrupts (at the part in the tutorial where Brandon says to try dividing by zero.) I've tried this with and without interrupts disabled (without it, it doesn't work (obviously.)) With interrupts enabled QEMU manages to crash without any useful information, and I'm unable to see any useful messages.
a/=0; You should ALWAYS get an exception(ie, an interrupt) if there is an exception calling the exception, then you get a double fault exception, if there is yet another exception, you get a triple fault and your computer resets.
what interrupts being enabled or disabled control are the IRQs. You know, timer interrupt, keyboard, harddrive, etc etc.
So I fail to see how you divided by zero without either triple faulting or getting into an exception handler.
Re: IDT/interrupt problems
Also have you remapped the PIC? By default it is mapped to interrupts that the processor has reserved for protected mode, so you need to remap it to different interrupts.
- AaronMiller
- Member
- Posts: 81
- Joined: Thu Mar 06, 2008 1:26 pm
- Location: Roseville, California (USA)
- Contact:
Re: IDT/interrupt problems
Thanks everyone, I fixed the problem.
I was simply forgetting a single opcode in my assembly routine. Basically what ended up happening was because of the optimization the "s32 a; a = a / 0;" got cut out of the final assembly, which is why QEMU wasn't crashing with optimization on. With the optimization off, the division by zero was in use, and the problem was revealing itself by calling a pointer to a function that doesn't exist (due to the missing opcode) hence why QEMU crashed like how it did. The problem is now fixed and I was able to expand my code further.
Cheers,
-naota
I was simply forgetting a single opcode in my assembly routine. Basically what ended up happening was because of the optimization the "s32 a; a = a / 0;" got cut out of the final assembly, which is why QEMU wasn't crashing with optimization on. With the optimization off, the division by zero was in use, and the problem was revealing itself by calling a pointer to a function that doesn't exist (due to the missing opcode) hence why QEMU crashed like how it did. The problem is now fixed and I was able to expand my code further.
Cheers,
-naota