Create my first bootloader

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
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

Create my first bootloader

Post by kendfrey »

My first OS has expanded beyond the size of the boot sector, so I need to create a bootloader. Now there are many ready-made bootloaders to be found, however I want to understand everything that goes on in my bootloader. I couldn't find any tutorials on creating bootloaders. I want to simply load a file containing code, and then jump to it. Does anyone know of a complete tutorial on how to do this? My floppy disk is currently formatted as FAT12. And I do want to know how to do everything without BIOS interrupts, if that is feasible.
xleelz
Posts: 8
Joined: Mon Aug 01, 2011 7:59 pm

Re: Create my first bootloader

Post by xleelz »

ask and ye shall recieve: http://brokenthorn.com/Resources/OSDev5.html

This is number 5 of Broken Thorn's OS tutorial... 5 and 6 teach how to load the kernel using FAT12 file system
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

Re: Create my first bootloader

Post by kendfrey »

This looks like something useful. I will try to use it, even though it is littered with errors (floppy disks have 63 tracks total?). I would still be glad if I could do this without BIOS interrupts.
xleelz
Posts: 8
Joined: Mon Aug 01, 2011 7:59 pm

Re: Create my first bootloader

Post by xleelz »

The tutorial works, that's all I know. I'm not sure you could create a floppy disk driver AND load a kernel using FAT12 file system in 512 bytes. BIOS is your friend in real mode
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

Re: Create my first bootloader

Post by kendfrey »

I take it it's pretty complicated to read a floppy. I should probably stick to BIOS then. I have another question: Is it possible to copy a multi-stage bootloader to a CD and have it work the same as a floppy? What about using a USB stick? I don't have real floppies, but I would like to sometime run my OS on something besides an emulator.
xleelz
Posts: 8
Joined: Mon Aug 01, 2011 7:59 pm

Re: Create my first bootloader

Post by xleelz »

I think you can. I usually use mkisofs to turn a .ima or .img floppy image into a cd image and burn it to a cd. It usually has the same effect on my computer that a floppy image does in an emulator.
As far as making a floppy driver, number 19 in that OSDev series talks about making a DMA floppy driver. Judging by what it says, I'd say the driver would be just under 512 bytes but it plus the code required to load the kernel would probably exceed the limit.
rdos
Member
Member
Posts: 3310
Joined: Wed Oct 01, 2008 1:55 pm

Re: Create my first bootloader

Post by rdos »

kendfrey wrote:This looks like something useful. I will try to use it, even though it is littered with errors (floppy disks have 63 tracks total?). I would still be glad if I could do this without BIOS interrupts.
You shouldn't do a bootloader that doesn't use BIOS interrupts. Installing drivers for different disc-hardware should not be done in the bootloader, but in the OS. By using BIOS you make sure that your bootloader works regardless of disc-hardware, and if you have an OS driver for the disc or not.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Create my first bootloader

Post by Combuster »

kendfrey wrote:I have another question: Is it possible to copy a multi-stage bootloader to a CD and have it work the same as a floppy?
Yes, using emulation as mentioned. However a CD has much larger native bootloader sizes supported and you don't need the two-stage setup with native CD boot (besides the fact that not all computers supporting CD boot support El-Torito emulation)
What about using a USB stick?
An USB is usually treated like a harddisk (and they usually have partitions and the whole shebang), and might need other BIOS calls to actually read the data from the far end of the (USB) drive.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply