Hi,
Schol-R-LEA wrote:Brendan wrote:For floppy, your code is "reckless".
To be fair to the OP, it is safe to say that the drives in question are emulated, and thus not bound to the limitations imposed by mechanical engineering. I agree that it is a poor practice, but it is an understandable short-cut when starting off, where you know that you are never going to run outside of emulation.
Emulators are supposed to emulate real hardware (and emulate limitations imposed by mechanical engineering). If someone is taking short-cuts like this then they are relying on bugs in emulators.
Schol-R-LEA wrote:More to the point, since it is emulated, it is unlikely that these flaws are relevant to the problem at hand.
More to the point; with decent error handling the OP probably would've solved half the problems themselves without having to ask. The floppy controller provides useful information that (e.g.) makes it obvious what the problem is if you try to read a sector that doesn't exist. It's easier to figure out what the problem is with more information (e.g. where you get a time-out) instead of less information (e.g. "my floppy driver hangs (but I don't know where or why because there's no error handling)").
Schol-R-LEA wrote:Now, it may be that you have a specific reason to support floppy drives, in which case I will withdraw my objection. However, if it is simply because you see them as easier to work with, I think you will find that you are mistaken about that.
Floppy is easier to write a driver for - one common "floppy controller" standard, fixed resources (IO ports, IRQs, etc), easy to find/read documentation and example code, etc. For hard drives there's multiple controller types and modes ("legacy mode PATA", "native mode PATA", AHCI, the entire unexplored "RAID controller" territory), a few variations of DMA controller, about 9 different transfer modes; then about 7 variations of "ATA specs" (for the hard drives themselves) with various optional features (locking, secure erase, native command queuing), different sector sizes, etc. For USB you have to start with PCI (enumeration, BARs); then there's several controller types; then USB device enumeration - all before you can start the USB storage device driver.
Schol-R-LEA wrote:I was thinking in terms of writing a boot loader for a hard drive, actually. The emulators in question are all capable of emulating a hard disk using a file as the virtual drive. Writing one for CD-R is no wiser than writing one for a floppy, indeed I would say it is worse given that it is a write-once medium.
One of the nice things about floppy and CD is that you don't have to bother with partitions.
Schol-R-LEA wrote:In an emulated environment, there is no real advantage to targeting removable media, unless you expect to move immediately to live hardware - a very, very bad idea all around. Unless your goal is to support a specific, unique real-time platform, focusing on live hardware is more of a distraction at this stage of development.
Eventually everyone wants to try their OS on real hardware; and if you rely on emulators and nothing else what happens is that as soon as you try it on real hardware you get bombarded by a massive number of problems and get so overwhelmed by how much your OS sucks that you're forced to throw everything away and start again from scratch. It's far easier to test regularly on real hardware (on as many different machines as you can get your hands on) and find the problems while you're working on the code, and prevent the "flock of failures" later.
Schol-R-LEA wrote:While some would argue that it helps you avoid over-reliance on quirks of the emulators, this only shifts the problem; unless you are testing on several different systems with notably different hardware, you risk falling into the same kind of platform specificity.
If you test on no real computers and 4 emulators you'll find about 25% of problems. If you test on 1 real computer and 4 emulators you'll find 80% of problems; which is a massive improvement (mostly caused by emulators not emulating a lot of things properly; typically including things like device timing, caches, TLBs, SMP, CPU features like performance monitoring, power management, etc).
Cheers,
Brendan