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.
Hi, I recently started working on the IDT and interrupts in my OS, but have been having some problems. I cannot seem to figure out why my code isn't working. Whenever I boot it it just restarts.
jka913 wrote:
Hi, I recently started working on the IDT and interrupts in my OS, but have been having some problems. I cannot seem to figure out why my code isn't working. Whenever I boot it it just restarts.
Here is the code:
This all looks correct, assuming that it's been cut & pasted to save space ("SELECTOR" may need to be defined before use, the IDT would be in the .bss section and the idt_pointer would be in the .data section).
Can you run it through Bochs and see what the CPU was doing when it crashes?
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.
resb 0x50*8 ;descriptor = 8 bytes, ints 0x00-0x4F; this is 0-79
In any case it shouldn't effect interrupt number 0x49...
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.
I found the problem, the tutorial I was using used 0x10 for the selector and I had no idea what this was, so I just used that. Apparently it is supposed to be 0x8, it now works. ;D
The reason it works is because in this particular case 0x10 is probably a data selector and 0x8 is a code selector. The actual value 0x8/0x10 is immaterial, it's just an offset to a selector in the GDT. The reboot is likely due to an unhandled exception leading to a triple fault because you are trying to load CS with a non-executable selector.
Work the whole problem solving process, don't just hack away until things work, try to understand why they failed in the first place. Otherwise things rapidly turn into some kind of voodoo.
Hopefully you already figured the problem before you made the change, but your last comment was unclear. Whether you did or not it's still good advice IMHO.
Apologies for preaching, especially if my analysis was wrong.