Rolling Your Own Bootloader: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Frank (talk | contribs)
No edit summary
Combuster (talk | contribs)
→‎Loading ... Please wait ...: merged parts from bootloader
Line 28: Line 28:
=== Where will you load your kernel ? ===
=== Where will you load your kernel ? ===


You will have to decide where in memory you are going to load your kernel. Your kernel generally depends on it.
That's one of the first questions you need to answer. Being in [[Real Mode]], the easiest is to stay below the 1MB barrier -- which means you practically have 512KB of memory to load things. You may wish the kernel to be loaded at a well-known position -- say 0x10000 physical (es=0x1000, bx=0 when calling INT13h).


; tip: If your kernel is bigger (or is expected to grow bigger) than this, you'll probably prefer to have the kernel above the 1MB barrier, which means you need to activate [[A20 Line|A20]] gate and switch to [[Unreal Mode]] to load the kernel (with A20 alone, you cannot have more than 64K above 1MB).
In RealMode, the easiest is to stay below the 1MB barrier, which means you practically have 512KB of memory to load things. You may wish the kernel to be loaded at a well-known position, say 0x10000 physical (es=0x1000, bx=0 when calling INT13h).

; caveat: Note that BIOS will still be unable to write to memory above 1MB, so you need to read stuff in a buffer below 1MB and ''then'' manually copy those stuff above 1MB.
If your kernel is bigger (or is expected to grow bigger) than this, you'll probably prefer to have the kernel above the 1MB barrier, which means you need to activate [[A20 Line|A20 gate]] and switch to [[Unreal Mode]] to load the kernel (with A20 alone, you cannot have more than 64K above 1MB).

Note that BIOS will still be unable to write to memory above 1MB, so you need to read stuff in a buffer below 1MB and then perform a rep movsd to place the data where they ultimately should go.


=== How will you find your kernel ? ===
=== How will you find your kernel ? ===