Page 1 of 1

Using a Hard Disk (or image) instead of floppy?

Posted: Sat Feb 12, 2011 5:11 am
by ATXcs1372
I could not find this question anywhere on the board, but is it possible to implement the two stage loader as well as the FAT12 filesystem on an image that boots as a hard drive instead of a floppy?
I ask because I don't even own a machine that has a floppy drive!
I could emulate one, but I'd rather not mess with floppies if I don't have to

If so, what changed will need to be made?
Do we need the floppy sector loading code in stage1 (I'd assume no)?
How do we jump to stage2? Just a jmp call? With segment:offset in place, how do yow know the offset to jump by?

Re: Using a Hard Disk (or image) instead of floppy?

Posted: Sat Feb 12, 2011 6:12 pm
by Mike
Hello,

You will need to write support for ATA (probably serial ATA) in order for the software to read and write from the hard disk. Serial ATA is fairly complicated however you can find some example code online including the specification.

Because most hard disks are not formatted with FAT12 (if any) you will most likely need to write a new filesystem minidriver for the kernel and rewriting all file system parsing code in the boot loader. If the hard disk (or partition) is formatted with FAT12, then you do not need to do this. Disk reading using BIOS INT 0x13 can still be used however.
I ask because I don't even own a machine that has a floppy drive!
A lot of us dont. However the software can be used on a CD or DVD without modifications to run on real hardware due to floppy emulation.

Do keep in mind that there are alternative boot loaders that you can use to skip that stage that do support hard disk booting. Of course, you will still need to add ATA and filesystem driver support.

Re: Using a Hard Disk (or image) instead of floppy?

Posted: Wed Feb 15, 2012 1:23 am
by jackson
Go to osdev and there is tutorials on ata there but, if you want the specifacations then go to t13
Oh, and by the way look at the mkiso cmd it can be VERY useful for booting from a cd