When and where to enable pmode and stuff?

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
McZ

When and where to enable pmode and stuff?

Post 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.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:When and where to enable pmode and stuff?

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:When and where to enable pmode and stuff?

Post 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 ...
McZ

Re:When and where to enable pmode and stuff?

Post 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?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:When and where to enable pmode and stuff?

Post 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.
Post Reply