Page 2 of 2
Re: Fault Occures on Key Press
Posted: Sat Mar 11, 2023 7:14 pm
by MichaelPetch
You were wondering where in virtual memory your kernel was, this answers that can be determined from 'IP=0028:ffffffff80000184' . Your kernel was loaded at ffffffff80000000. It also confirms that CS should be set to 0x28 in your interrupt handlers which is what the Limine documentation suggested.
On a side note: Division by zero can be caused by two things - division by zero and division overflow.
Re: Fault Occures on Key Press
Posted: Sun Mar 12, 2023 2:39 am
by rdos
FunnyGuy9796 wrote:Indeed I did not remap the PIC. I, being new to this, accidentally overlooked the fact that the PIC needs to be initialized before the APIC. Thanks guy again for the help! (I know my questions and lack of understanding can be annoying)
I think you need to know if your system runs with the legacy PIC or with APIC. If you use APIC, you will normally not use the PIC, and if there is legacy support, the legacy PIC is typically disabled.
It's mostly old systems that require the use of PIC.
Re: Fault Occures on Key Press
Posted: Sun Mar 12, 2023 8:14 am
by FunnyGuy9796
Ok, everything now works as intended after remapping the PIC. Thank you guys for your help! I very much appreciated it.
Re: Fault Occures on Key Press
Posted: Sun Mar 12, 2023 10:41 am
by MichaelPetch
I'm going to recommend at this point that using a debugger will come in very handy moving forward. Although I had you use QEMU to dump out the interrupts and exceptions to narrow down your problem(s) that is just one method of getting info. Since you are using QEMU I recommend you start building all your assembly code and C/C++ code etc with debug info. You can attach GDB to QEMU using its remote interface. This would allow you to step through the code. The ability to use a debugger will probably be the most valuable skill as you continue your OSdev journey.
Since you don't say how you build everything, I can't offer explicit instructions on building a kernel for debugging so that it can be debugged in a QEMU session with GDB.
Re: Fault Occures on Key Press
Posted: Sun Mar 12, 2023 10:43 am
by FunnyGuy9796
Thanks for the advice! I was already looking in to setting up a GDB with QEMU but haven’t gotten around to it yet. Definitely will do it though!