Hi,
I am trying to get heap management and paging going in my OS, and I am working from JamesM's tutorials (and porting it to C++). The problem I am having is that when I try to create my heap, I get a general protection fault - but only when I run in Bochs or on a real PC. In virtualbox or QEMU though, it runs perfectly. As far as I can tell, paging is working fine, but when I try to make an index to keep track of the allocated memory, it crashes. This happens after I try to clear the memory at the start of the heap (line 84 or paging.cc, called from create_heap at line 42, which is called after paging is enabled). In Bochs, I get a write beyond limit, but it works in every other emulator I've tried...
Here are the relevant source files:
kheap.cc
kheap.h
paging.cc
paging.h
Note that instead of making a general ordered array like in the tutorial, I just made it specific to the heap management because I'm going to implement a std::vector - which I would use for this, but it requires heap management to work!
Now, I'm probably just missing something really simple and obvious, but I've been trying to fix this for a while now and haven't made any progress...
Thanks for any help.
Steve
Heap management problems
- Steve the Pirate
- Member
- Posts: 152
- Joined: Fri Dec 15, 2006 7:01 am
- Location: Brisbane, Australia
- Contact:
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: Heap management problems
Could you try it with the basic general ordered array first to ensure it works, and then go from there? If it still doesn't work then you know the problem is somewhere elseNote that instead of making a general ordered array like in the tutorial, I just made it specific to the heap management because I'm going to implement a std::vector - which I would use for this, but it requires heap management to work!
- Steve the Pirate
- Member
- Posts: 152
- Joined: Fri Dec 15, 2006 7:01 am
- Location: Brisbane, Australia
- Contact:
Re: Heap management problems
I think I fixed it! I was just thinking that I could be having problems if my GDT segments weren't set up properly, so I checked and it seems that I wasn't setting the granularity right in the set_gate function.
It works in Bochs now, and I'm about to restart to test on my computer
Update: Well it works fine now, and fixing the GDT also fixed another GPF I was getting.
-Steve
It works in Bochs now, and I'm about to restart to test on my computer
Update: Well it works fine now, and fixing the GDT also fixed another GPF I was getting.
-Steve