Page 1 of 1
When and where to enable pmode and stuff?
Posted: Thu Oct 14, 2004 12:02 pm
by McZ
I have been planning my os and started with a simple bootsector and planning for my stage2 which will be different depending on the filesystem it is running on the stage2 will search for the kernel wich will be in the Drive:/MyOS/Kernel32.bin or something like that...
anyway, to my questions... when and where "should" I enter Pmode and stuff like that? and enable Paging, (and the A20 Line?) in the Bootsector or the stage2 or in the kernel? or maybe it doesn't matter where as long as I do it and write the rest depending on that.
Re:When and where to enable pmode and stuff?
Posted: Thu Oct 14, 2004 12:20 pm
by Candy
McZ wrote:
I have been planning my os and started with a simple bootsector and planning for my stage2 which will be different depending on the filesystem it is running on the stage2 will search for the kernel wich will be in the Drive:/MyOS/Kernel32.bin or something like that...
anyway, to my questions... when and where "should" I enter Pmode and stuff like that? and enable Paging, (and the A20 Line?) in the Bootsector or the stage2 or in the kernel? or maybe it doesn't matter where as long as I do it and write the rest depending on that.
You decide for yourself. There are examples of people activating pmode instantly (in the boot sector), doing it in a second/third(me)/fourth stage or even in the kernel somewhere. You can also switch instantly, then switch back when you want to.
The usual order is, bootsector loading just the 2nd stage, 2nd stage loading kernel and setting up pmode + stuff around that, and the kernel just activating all its devices and starting to run.
Re:When and where to enable pmode and stuff?
Posted: Fri Oct 15, 2004 2:35 am
by Pype.Clicker
If your stage 2 has to load the kernel, you'll probably prefer being in real mode for stage 2, as it will have to load stuff from disks (thus UsingBios)
btw, if your kernel is big or if you have to place it above 1MB for SomeReason(tm), you may like to be in *unreal* mode in stage 2 ...
Re:When and where to enable pmode and stuff?
Posted: Fri Oct 15, 2004 4:18 am
by McZ
Pype.Clicker wrote:
If your stage 2 has to load the kernel, you'll probably prefer being in real mode for stage 2, as it will have to load stuff from disks (thus UsingBios)
btw, if your kernel is big or if you have to place it above 1MB for SomeReason(tm), you may like to be in *unreal* mode in stage 2 ...
can't stage2 first load the kernel into memory then enter pmode then jump to the kernel code?
Re:When and where to enable pmode and stuff?
Posted: Fri Oct 15, 2004 4:38 am
by Candy
McZ wrote:
can't stage2 first load the kernel into memory then enter pmode then jump to the kernel code?
Of course it CAN, it doesn't HAVE TO in any case. But it is the most common way. Boot sector is too small, the kernel is too pure so they create a tube of glue (something like that) to fix them together, that is, some stuff that can be loaded by the boot sector, that sets up the environment for the kernel. The boot sector loads a program into real mode stuff, the kernel is full protected mode stuff with paging etc. The glue must thus load the kernel, go to pmode, stuff like that. You might want to enable A20 and start up paging etc. too.