Page 1 of 1
OSDev Floppy vs CD-ROM
Posted: Fri May 13, 2016 9:04 am
by BrightLight
If you notice, most, if not all OSDev tutorials boot from a floppy disk because "it's simple." Actually, CD-ROMs are also very simple. In real mode, INT 0x13 function 0x42 is easy to use, ATA PIO mode is also easy, and ISO9660 is simpler than FAT12/16. Other than that, no PC sold today has a floppy drive.
So my question is: why do so many people still stick to floppy disks?
Re: OSDev Floppy vs CD-ROM
Posted: Fri May 13, 2016 9:16 am
by Kazinsal
Perceived simplicity.
People write floppy drivers because they think the old technology is going to be incredibly simple, and then their drivers work fine in emulators but completely fail on real hardware due to floppies becoming unreliable with age. They don't get the disconnect between a floppy drive that exists only in memory and one that has physical motors and magnetic fields to manipulate.
Floppies are pretty close to the top of the pile of unreliable crap. But it works in an emulator, and that's what matters.
Re: OSDev Floppy vs CD-ROM
Posted: Fri May 13, 2016 9:36 am
by Kevin
The one reason that would actually make sense is that floppies are writable and CD-ROMs aren't.
Re: OSDev Floppy vs CD-ROM
Posted: Fri May 13, 2016 10:02 am
by Brendan
Hi,
omarrx024 wrote:If you notice, most, if not all OSDev tutorials boot from a floppy disk because "it's simple." Actually, CD-ROMs are also very simple. In real mode, INT 0x13 function 0x42 is easy to use, ATA PIO mode is also easy, and ISO9660 is simpler than FAT12/16. Other than that, no PC sold today has a floppy drive.
So my question is: why do so many people still stick to floppy disks?
For floppy, I don't use any file system at all and just store "boot files" (e.g. compressed initial RAM disk thing, etc) in contiguous sectors (and use a few "LBA sector number for start of file" fields at a known location in my boot loader to find them). This is much simpler than bothering with any file system including ISO9660 (and is faster and more space efficient).
Note that (with El Torito and common tools) it's fairly easy to get CD to emulate floppy, so a boot loader for floppy is good enough to cover both device types in the early stages of an OS. The reverse (getting floppy to support El Torito and/or emulate a CD) is a little harder.
Also; it doesn't really matter what you start with. Eventually you're going to want to be able to boot from all kinds of devices (MBR partitioned disk/USB flash, GPT partitioned disk/USB flash, CD-ROM, floppy, network; then UEFI). The differences between boot loaders designed for different BIOS devices is relatively minor (it only effects the "loading from ..." and doesn't effect the code to get memory map, setup a video mode, initialise paging ready for kernel, etc); so once you've got (e.g.) a floppy boot loader it's easy to create a boot loader for the other device types because you've already done the majority of the code.
Finally; a lot of beginners simply don't have many real test machines, so what real hardware currently supports isn't as important as what emulators support.
Note: for people that do have multiple real test machines, my advice is to setup PXE/network boot if you can (it makes a significant difference to the hassle and time testing takes).
Kazinsal wrote:People write floppy drivers because they think the old technology is going to be incredibly simple, and then their drivers work fine in emulators but completely fail on real hardware due to floppies becoming unreliable with age.
Drivers have nothing to do with booting, and booting from floppy has nothing to do with writing a floppy driver.
Cheers,
Brendan
Re: OSDev Floppy vs CD-ROM
Posted: Fri May 13, 2016 11:01 am
by DavidCooper
I now work mostly on machines which have neither floppy nor CD/DVD drives, so using either of those involves having a box plugged in on a cable, making the machine less easy to pick up and move around. If you want to work on real hardware, the most sane place to start these days is therefore a USB flash drive, and it's safest to use one of the very small ones that only sticks out 5mm so that you'll never risk leaning on it by mistake, but you must do it properly using an MBR and at least one partition instead of treating it as a floppy disk.
However, there's still no harm in working with floppy disk images in an emulator to begin with, just so long as you're thinking ahead to the time when you'll want to boot from a USB flash drive instead (or from the internal hard drive): you just need to avoid creating a tangled mess where your OS is mixed into your loader, and any decent tutorial should make that clear. My own boot code can load from a floppy disk or from a partition on a flash drive without any modification (though that code isn't in the ancient version that's available online), so perhaps a tutorial setting out how to do that would be useful.