Anyone tried to code their own bootloader ?
Anyone tried to code their own bootloader ?
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.
Re: Anyone tried to code their own bootloader ?
I wrote many bootloaders and many other assembly programmers write their own bootloaders too.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 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
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
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
.
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.
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.
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.
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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
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.
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.
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
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
welcome in my dream.
I have written my own bootloader as well.
yep... that's all i have to say.
yep... that's all i have to say.
Website: https://joscor.com
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
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
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 timeColdberg wrote:Wow awesomeanyone ever tried PXE ?



