Bootloaders are difficult?

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
garethadams
Posts: 8
Joined: Tue Sep 15, 2009 4:09 am

Bootloaders are difficult?

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Bootloaders are difficult?

Post 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
garethadams
Posts: 8
Joined: Tue Sep 15, 2009 4:09 am

Re: Bootloaders are difficult?

Post 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
geppyfx
Member
Member
Posts: 87
Joined: Tue Apr 28, 2009 4:58 pm

Re: Bootloaders are difficult?

Post 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.
garethadams
Posts: 8
Joined: Tue Sep 15, 2009 4:09 am

Re: Bootloaders are difficult?

Post 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!
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Bootloaders are difficult?

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply