[SOLVED] Fault Occures on Key Press

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.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Fault Occures on Key Press

Post 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.
rdos
Member
Member
Posts: 3296
Joined: Wed Oct 01, 2008 1:55 pm

Re: Fault Occures on Key Press

Post 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.
FunnyGuy9796
Member
Member
Posts: 61
Joined: Tue Sep 13, 2022 9:29 pm
Libera.chat IRC: FunnyGuy9796

Re: Fault Occures on Key Press

Post by FunnyGuy9796 »

Ok, everything now works as intended after remapping the PIC. Thank you guys for your help! I very much appreciated it.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Fault Occures on Key Press

Post 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.
FunnyGuy9796
Member
Member
Posts: 61
Joined: Tue Sep 13, 2022 9:29 pm
Libera.chat IRC: FunnyGuy9796

Re: Fault Occures on Key Press

Post 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!
Post Reply