Memory Management code reboots my kernel
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
Memory Management code reboots my kernel
Hello, i am trying to implement the paging and heap on my kernel, with the help of jmolloy's tutorial, and when i link the page and heap code with the rest and run it, it flashes on the boot screen,(it finds the kernel but then it searches for it and goes), which i think is rebooting. If i remove the paging/heap files, everything works fine. So this made me believe that the problem is in those files. I use a simple custom bootloader, my kernel image is a binary file, and i run it with qemu. I tried to debug it using prints and gdb but i couldn't find what is the problem. Can you help me? If you want more info, tell me.
-
- Member
- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: Memory Management code reboots my kernel
Hi,
I suggest you don't use the James Molloy's tutorial (see http://wiki.osdev.org/James_Molloy's_Tu ... Known_Bugs).
As for the paging code, try inspecting your code in an emulator+debugger+objdump/disassembler. Possible causes may be:
Hope this helps.
Regards,
glauxosdever
I suggest you don't use the James Molloy's tutorial (see http://wiki.osdev.org/James_Molloy's_Tu ... Known_Bugs).
As for the paging code, try inspecting your code in an emulator+debugger+objdump/disassembler. Possible causes may be:
- Invalid cr3 value (not a pointer to the page directory). Note: It has to be aligned on page boundaries.
- Invalid contents of page directory. Note: Assuming 32-bit x86, the lower 12 bits don't contribute to the physical address and, instead, they are various flags. Make sure "present" and various permissions are set properly!
- Invalid contents of page tables. Note: The same mentality as with page directories applies here, although the flags are not entirely the same.
- Some code (even outside the paging/heap files) causes a page fault and the page fault handler is not set up correctly so it causes a double fault and the double fault handler is not set up correctly so a triple fault is triggered and the machine reboots.
- A combination of the above and/or something else.
Hope this helps.
Regards,
glauxosdever
-
- Posts: 17
- Joined: Sun Aug 21, 2016 10:18 am
- Libera.chat IRC: Chpetrou
- Location: Cyprus, Greece
- Contact:
Re: Memory Management code reboots my kernel
Hello, Thanks for the reply , the code is attached below. I am also trying to debug it and find the mistake but its a bit hard. As for the tutorial, i am just trying to create a basic version of my os that works, and then try to make it better, and change some of the code, or make a better implementation of something. Do you suggest me any other tutorial or something else?
- Attachments
-
- CPOS.zip
- (59.22 KiB) Downloaded 30 times
Re: Memory Management code reboots my kernel
You may want to use the bare bones or meaty skeleton from the wiki, remember to use a cross compiler if you aren't already. Those should always work.Chpetrou wrote:Hello, Thanks for the reply , the code is attached below. I am also trying to debug it and find the mistake but its a bit hard. As for the tutorial, i am just trying to create a basic version of my os that works, and then try to make it better, and change some of the code, or make a better implementation of something. Do you suggest me any other tutorial or something else?
Then read whatever tutorial you prefer, but don't copy the code, understand it and write what you want/need yourself. I don't think it will take much longer doing it this way and I think the results will be better.
Also there are books on the subject, but the reality is that there's no easy shortcuts that would work (or more precisely, it's _extremely_ unlikely you'll find anything you can copy/paste to a significant degree and that it would work the way you want). The reason is that you are creating your _own_ OS, which means nothing is going to match it perfectly and trying to copy/paste usually leads to more issues than it solves, so better do it "the right way" from the beginning.
But if you _must_ use tutorials, then I'd still start with the bare bones or meaty skeleton and add pieces from other tutorials and debug them as you add them.