Bootloader Paging design problem
Posted: Sat Oct 06, 2007 1:58 pm
Hey everyone,
I ran into a small design issue with the bootloader, and am looking for suggestions (Before anyone says it, no GRUB stuff, please )
You can skip to "The Problem" section below, if you want.
History
Anywhoo... I am going back to the bootloader to add more content to it, but have finally admitted it: It has horrific memory management. Actually, it has NO memory management.
This makes it harder for the bootloader to execute programs. I am trying to find a nice way for my bootloader to load and execute a 16bit hardware detection (binary/COM like) program.
However, without any memory management, I need to load and execute this program directly within memory--which I am trying to avoid.
So, I decided to add some form of virtual memory management in the bootloader, and load the Kernel and other programs in their own virtual address space. This, of course, requires some form of paging, which is where the problem is at.
The Problem
Okay, the problem is with paging. I can only enable paging inside of PMode, as in RMode, Bochs gives me an error about setting the paging bit in CR0, when the PMode bit is 0 (RMode). This is understandable, but I run into a problem, as Bochs refuses to do this in RMode. It does not triple fault, it just repediatevly gives me the same error (And a large 17KB+ log file at that :/)
How can I enable paging in PMode, go back into RMode (While still using paging), in order to execute the 16bit COM program? I cannot switch back to RMode without it crashing.
Do I have no choice, or am I forgetting, or not seeing something? Does anyone have any suggestions here at what they would do?
The 16bit COM like program needs to be 16bit, as it accesses BIOS services. Because of this, I need to load and execute it from RMode. But, without a virtual address space, I am limited to this to execute it, which is as ugly as it can get:
Thanks
I ran into a small design issue with the bootloader, and am looking for suggestions (Before anyone says it, no GRUB stuff, please )
You can skip to "The Problem" section below, if you want.
History
Anywhoo... I am going back to the bootloader to add more content to it, but have finally admitted it: It has horrific memory management. Actually, it has NO memory management.
This makes it harder for the bootloader to execute programs. I am trying to find a nice way for my bootloader to load and execute a 16bit hardware detection (binary/COM like) program.
However, without any memory management, I need to load and execute this program directly within memory--which I am trying to avoid.
So, I decided to add some form of virtual memory management in the bootloader, and load the Kernel and other programs in their own virtual address space. This, of course, requires some form of paging, which is where the problem is at.
The Problem
Okay, the problem is with paging. I can only enable paging inside of PMode, as in RMode, Bochs gives me an error about setting the paging bit in CR0, when the PMode bit is 0 (RMode). This is understandable, but I run into a problem, as Bochs refuses to do this in RMode. It does not triple fault, it just repediatevly gives me the same error (And a large 17KB+ log file at that :/)
How can I enable paging in PMode, go back into RMode (While still using paging), in order to execute the 16bit COM program? I cannot switch back to RMode without it crashing.
Do I have no choice, or am I forgetting, or not seeing something? Does anyone have any suggestions here at what they would do?
The 16bit COM like program needs to be 16bit, as it accesses BIOS services. Because of this, I need to load and execute it from RMode. But, without a virtual address space, I am limited to this to execute it, which is as ugly as it can get:
Code: Select all
; execute hardware detection utility. It is loaded at 0x4000
call 0x400:0