A big problem with a crazy kernel

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
AdiLAN
Posts: 1
Joined: Fri Jul 17, 2020 4:16 pm

A big problem with a crazy kernel

Post by AdiLAN »

Hi, I have a big problem with my kernel, namely the kernel goes crazy keeps restarting qemu and I don't know why this is happening at all.
Here I leave a link to my project, inside is the latest compilation of the system along with a gif showing the crazy behavior of the kernel and source code.
https://mega.nz/folder/jhg1naiR#qH9oybvrGjYvIue2zho5jg
And one more problem underneath, I hope some of you help me fix these bugs.
Attachments
kernel code:<br />void main(void) {<br />clearScreen(0x99);<br /> printAt(&quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, 0, 0, 0);<br />}
kernel code:
void main(void) {
clearScreen(0x99);
printAt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 0, 0);
}
q0.png (7.82 KiB) Viewed 919 times
kernel code:<br />void main(void) {<br />clearScreen(0x99);<br />printAt(&quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, 0, 0, 0);<br />printAt(&quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, 0, 0, 0);<br />}
kernel code:
void main(void) {
clearScreen(0x99);
printAt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 0, 0);
printAt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 0, 0);
}
q1.png (8.45 KiB) Viewed 919 times
kernel code:<br />void main(void) {<br />clearScreen(0x99);<br />printAt(&quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, 0, 0, 0);<br />printAt(&quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, 0, 0, 0);<br />printAt(&quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;, 0, 0, 0);<br />}
kernel code:
void main(void) {
clearScreen(0x99);
printAt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 0, 0);
printAt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 0, 0);
printAt("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 0, 0);
}
q2.png (7.97 KiB) Viewed 919 times
Octocontrabass
Member
Member
Posts: 5885
Joined: Mon Mar 25, 2013 7:01 pm

Re: A big problem with a crazy kernel

Post by Octocontrabass »

AdiLAN wrote:Hi, I have a big problem with my kernel, namely the kernel goes crazy keeps restarting qemu and I don't know why this is happening at all.
Usually that means your kernel is causing a fault of some kind, and your exception handlers (if you have them) are not set up correctly, so the CPU faults three times in a row and reboots.

You can add "-no-reboot" to your QEMU command line to stop it from rebooting.

You can add "-d int" to your QEMU command line to log the fault (among many other things). The information in the log will tell you where to look to find the problem.

Once you fix the rebooting issue, you can use a debugger to step through your printAt() function to see why it's not printing the way it should be.
nullplan
Member
Member
Posts: 1917
Joined: Wed Aug 30, 2017 8:24 am

Re: A big problem with a crazy kernel

Post by nullplan »

In the code you posted, I see nothing to prevent the kernel from returning from its main function. Where does it return to? Is there anything to stop the CPU at that place? You can just add

Code: Select all

for (;;) asm("hlt");
as last line to prevent the kernel from returning.
Carpe diem!
Post Reply