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

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator: Moderators

Post Reply
ATXcs1372
Posts: 5
Joined: Sat Feb 12, 2011 4:22 am

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

Post by ATXcs1372 » Sat Feb 12, 2011 5:11 am

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?

User avatar
Mike
Site Admin
Posts: 465
Joined: Sat Oct 20, 2007 7:58 pm
Contact:

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

Post by Mike » Sat Feb 12, 2011 6:12 pm

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.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

jackson
Posts: 14
Joined: Sat Aug 06, 2011 7:52 pm

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

Post by jackson » Wed Feb 15, 2012 1:23 am

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

Post Reply