User:Nedbrek/bootl

From OSDev Wiki
Jump to navigation Jump to search

"The king said it was daft to build a castle in the swamp. So I built it all the same! Just to show him." - The Swamp King

History

2010

  • Jan 2 - FAT12 style, booting into 64 bit mode in 512 B
  • Jan 24 - Started investigation of El Torito
  • Jan 27 - Booting from CDROM
  • Jan 30 - Enable A20, query for system mem map
  • Jan 31 - Added Boot Output Block (BOB), saved boot disk id to BOB
  • Feb 14 - Query VBE modes, pick one, screen blank from kernel.bin

Motivation

Or "Why not Grub"

The purpose of Ned OS is for me to learn more about how computers work - rather than driving to a functional product or tool. The primary use is inside a virtual machine. (Bochs is great!)

Also, to examine the assumptions that go into most operating systems and programming environments.

Using Grub would force me to accept all the assumptions that go into Grub (multi-stage boot loading, mult-boot kernel image, and ELF being the main ones). That, or to rewrite Grub line by line (rewriting is how I learn best).

Once I am committed to ELF, I'd then feel compelled to write a linker (huge time sink).

Grub also encourages the use of "ordinary binaries" for the kernel. That means GCC cross-compiler, which means C, which means all the UNIX assumptions (also, I'd feel compelled to write a compiler - double time sink).

Technical Issues

The main goal is to avoid multi-stage boot. I wanted to see how much I could fit into 512 B, and how far I could get towards pure 64 bit mode.

Just getting into 64 bit mode is pretty easy, about 170 B.

The problem is, once in 64 bit mode, you've lost all the BIOS functions...

So, I need the boot loader to pull everything needed from the BIOS (no going back!)

This is where CD boot really shines. You have the whole 512 B, and can easily get more.

Hard drive booting is harder (maybe unnecessary, as I would likely multi-boot a hard drive, which means Grub is ok).

I do have a stripped down version of the boot loader that fits into 446 B, but it is not what I would like.

Results

If Grub is like a cushy limo that delivers your kernel in style; Bootl is an orbital parachute that leaves you in a smoking crater - alive, but barely.

  • The system is in 64 bit mode, with interrupts disabled.
  • There is no interrupt table (you'll need to see about that right away!).
  • You have one 2M page (identity mapped at 0..1F_FFFF).
  • The video card is in some sort of graphics mode, it shoots for <=1024 wide and 32 bpp. The exact details are in the BOB. Since you can't get back to the BIOS, you're stuck with that mode forever. Enjoy!
  • Again, no BIOS, so no disk until you set up your own disk driver.
  • You'll need to set up the task register.
  • Caches are disabled
  • The MTRRs are wherever the BIOS left them, possibly not in good shape.