Page 1 of 3
Anyone tried to code their own bootloader ?
Posted: Fri Apr 25, 2008 2:20 pm
by Coldberg
I see alot of people here just use GRUB , i'm curious though has anyone ever tried to write their own non-trivial bootloader ? I'm currently trying to do so.
Posted: Fri Apr 25, 2008 2:33 pm
by Combuster
Its not uncommon really. There's even a tutorial on it on the wiki (
Babystep)
My bootloader can be found on my homepage (see signature)
Re: Anyone tried to code their own bootloader ?
Posted: Fri Apr 25, 2008 2:43 pm
by octavio
Coldberg wrote:I see alot of people here just use GRUB , i'm curious though has anyone ever tried to write their own non-trivial bootloader ? I'm currently trying to do so.
I wrote many bootloaders and many other assembly programmers write their own bootloaders too.
Posted: Fri Apr 25, 2008 3:15 pm
by suthers
I wrote my own bootloader, but mine was pretty simple, it just enables A20, loads a gdt, reads all the floppy from which it booted and the jumps to it.
Nothing more than i needed for it to work at the begining.
The only reason I wrote though is because I hate using anybodies else's code or binaries and i also felt that long term it would be better because i would have a bit more control.
Jules
Posted: Fri Apr 25, 2008 4:04 pm
by Ready4Dis
Many write their own bootloaders, many want to just get on with programming their kernel. I chose to write my own, and I use what most would call 'unconventional' tools (like djgpp instead of cygwin and a cross compiler, I use coff rather than elf like most others use, etc). I also wrote my own MBR that allows me to boot different partitions without a bootsector being the wiser (easily allows me to multi-boot windows, dos, my os, linux, and I use the standard partition table format so it's recognized by windows, linux, etc) in the 510 bytes i'm alloted, without a fancy/large graphical boot loader. I have multiple version of my bootloader depending on the device and file system, i currently have them for fat12/16/32 for floppy/hd (including usb drives if the bios supports them properly). I also wrote my own fat formatting utilities, as well as partitioning software. I like writing stuff myself, I use very little pre-made utlities (outside of the compilers, I even wrote my own linker for coff files so I can relocate and link them in my kernel). I haven't written my own compiler or assembler though, I will probably just port those over

.
Posted: Fri Apr 25, 2008 4:08 pm
by bewing
There was a poll on here a while back -- asking how many people use GRUB vs. writing their own bootloader. It turned out that a slight majority wrote their own. It's mostly pretty easy -- just gathering all the useful info from the BIOS, before the BIOS stops running (when you enter pmode) -- and parsing your supported filesystem to find/load the kernel image. All the while dealing with the limitations of realmode segmentation.

Then storing all that nice info in temporary tables for your kernel to retrieve.
Just make sure you limit your memory usage to 0x500 - 0x7ffff in realmode. That is the one thing that really doesn't get explained clearly enough.
Posted: Fri Apr 25, 2008 6:55 pm
by neon
I too have written several bootloaders. My main system's bootloader is fairly complex as it has alot of support to both a) insure the operating system itself is hardware independent, and b) contains all boot-time information and mode to start in. The bootloader contains its own minidrivers that are used to parse and load the kernel from 32bit pmode--without the Bios.
I never used GRUB for portability and security purposes. The kernel itself is hardware independent as it relies on other drivers that were pre-loaded by the bootloader to load its own kernel mode drivers.
Posted: Fri Apr 25, 2008 7:56 pm
by Dex
Theres "bootprog" as a good example
http://alexfru.chat.ru/epm.html#bootprog
But there again, DexOS could be used as a bootloader for other OS's, as it as most of what's in GRUB, but is only 50k insize.
Posted: Fri Apr 25, 2008 10:32 pm
by edfed
i currentlly write a new version of my bootloader.
i is able to load a file from sector 2, and restart from an other drive.
i'll put an hidden menu ( press ctrl) to choose the drive.
it fits in only 160 bytes, i have approximatelly 200 others bvytes for the hidden menu. and bug fixes

Posted: Fri Apr 25, 2008 11:14 pm
by 01000101
I have written my own bootloader as well.
yep... that's all i have to say.
Posted: Sat Apr 26, 2008 2:19 am
by zerosum
I wrote a crap one. Now I use GRUB

Posted: Sat Apr 26, 2008 2:35 am
by AJ
I have gone the other way - I was using GRUB (with an intermediate stage for enabling VESA video, switching to long mode and it had a debug command line console and could jump straight to a main() function without an assembly stub), but I have now switched to writing my own (in early stages).
My aim is to write a boot loader which offers an OS selection (like GRUB), has the same debug console as my first version and will also supply the kernel with information on installed devices (PCI configuration space and so on....). The aim is to get a lot of this 'run once' stuff out of my kernel.
The main difference between my 'second stage loader' which used GRUB and the new version, is that the original just used v86 for VESA switching, whereas the current version returns to real mode for using BIOS ints (so it can use BIOS int 0x13).
Cheers,
Adam
Posted: Sat Apr 26, 2008 2:56 pm
by Coldberg
Wow awesome

anyone ever tried PXE ?
Posted: Sat Apr 26, 2008 3:09 pm
by Ready4Dis
Coldberg wrote:Wow awesome

anyone ever tried PXE ?
No, but I have been wanting to try it out, seems like a much simpler way to test, rather then rebooting the dev machine, or copying it to disk all the time

. Just setup a server on my local network, update my kernel, and reboot the test machine. It's great too, because you can test it out on however many computers you want by just booting them on the network and booting from network

. No need to worry about which computer has a floppy disk, etc.
Posted: Sun Apr 27, 2008 4:10 am
by Coldberg
I'm working on implementing a PXE bootloader atm , so far so good , all i really need is a test machine or a netcard with PXE enabled. so far i was only been able to test on VMWare