Page 1 of 1

Bootloaders are difficult?

Posted: Tue Sep 15, 2009 9:55 am
by garethadams
Hi,

This is probably going to get me flamed but...

what's so difficult about writing a bootloader (wait...read on!)?

I don't mean a bootloader that will boot windows, linux or (God forbid) OSX but a bootloader that will boot an OS <64k that just does basic FAT stuff. Surely that just involves copying the kernel code into a memory location? There's loads of those out there in the tutorials.

Most people who "write" an OS wil get as far as "Hello world" and a simple command line before they get bored/discouraged/out of their depth/married/kids or whatever else contributes the the millions of kernels that seem to exist in the interweb!

Using Grub to load a "Hello World" kernel just seems like overkill?

I've probably missed something obvious which will make me look like a complete twitter user (according to David Cameron) but if you don't ask you'll never know!

Thanks

Gareth

Re: Bootloaders are difficult?

Posted: Tue Sep 15, 2009 10:05 am
by AJ
Hi,

There's nothing difficult about it - if you only plan to write the Hello World kernel.

However, most people trying OS Dev aspire to greater things, for which they'll need something that can enable memory above 1MiB and can coexist with other OSes. For that, you need GRUB or something with a similar complexity level.
By using GRUB from the outset, you don't have to change your kernel entry interface later on.

Cheers,
Adam

Re: Bootloaders are difficult?

Posted: Tue Sep 15, 2009 12:42 pm
by garethadams
O.K., that makes sense. I can see how co-existing could introduce a level of complexity equal to writing an OS in the first place!

Thankfully my aims are much lower - I just want to have full control of the machine and see what I can accomplish in 64k!! (Jeff Minter would be proud of me...)

Thanks

Gareth

Re: Bootloaders are difficult?

Posted: Tue Sep 15, 2009 3:22 pm
by geppyfx
The only thing that makes bootloader difficult is that there is no 100% standardization of functions, OR most likely BIOSes have bugs. This also includes inability to read more that 1 sector from a disk.

Rest is really depends how qualified programmer to write a bootloader.

Re: Bootloaders are difficult?

Posted: Wed Sep 16, 2009 2:33 am
by garethadams
Ah, didn't realise that. So even if my simple bootloader worked on my home laptop it may not work on my eeepc, work PC etc. Interesting!! Beginning to realise what a minefield bootloaders are! I wonder if the author of Grub set out to write an OS and just got a bit sidetracked!

Re: Bootloaders are difficult?

Posted: Wed Sep 16, 2009 12:37 pm
by Brendan
Hi,
garethadams wrote:Ah, didn't realise that. So even if my simple bootloader worked on my home laptop it may not work on my eeepc, work PC etc. Interesting!!
Yes, but it's a little harder than that because (for PC BIOS) you need different boot loaders for different types of boot devices. For e.g. booting from network, booting from floppy (no "int 0x13 extensions"), booting from hard disk (with "int 0x13 extensions") and booting from CD-ROM (with "no emulation") are all different enough that it's better to write several separate boot loaders than to try to support all of these things in 512 bytes.


Cheers,

Brendan