diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-08-16 12:09:44 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-08-16 12:09:44 -0400 |
commit | 0a0e42e98538e959fece731be9262b1a8e874c7d (patch) | |
tree | f832825c7bfdccc0fd1e257c66396d292492e660 /src/disk.c | |
parent | 669e6449565018e72e3833ff39fcf677d5a5b824 (diff) | |
download | seabios-0a0e42e98538e959fece731be9262b1a8e874c7d.tar.gz |
Add floppy controllers to "drives" list also.
The Drives.drives list now contains floppies, harddrives, and cdroms.
Add mapping table for external/internal drive ids for floppies.
Rename CONFIG_FLOPPY_SUPPORT to CONFIG_FLOPPY (for consistency).
Be consistent with "driveid" and "floppyid" variable names.
Replace switch statements of drive parameters into a global array.
There are some externally visible changes with this patch:
- Some calls will now return EPARAM instead of ETIMEOUT (or ECHANGED)
- floppy_1301/1308 are now only available when regs->dl is valid
- floppy_1308/1315 return EPARAM on invalid drives
Diffstat (limited to 'src/disk.c')
-rw-r--r-- | src/disk.c | 38 |
1 files changed, 21 insertions, 17 deletions
@@ -681,22 +681,18 @@ disk_13(struct bregs *regs, u8 driveid) ****************************************************************/ static int -get_driveid(struct bregs *regs, u8 iscd, u8 drive) +get_driveid(struct bregs *regs, u8 exttype, u8 extdriveoffset) { // basic check : device has to be defined - if (drive >= ARRAY_SIZE(Drives.idmap[0])) { - disk_ret(regs, DISK_RET_EPARAM); + if (extdriveoffset >= ARRAY_SIZE(Drives.idmap[0])) return -1; - } // Get the ata channel - u8 driveid = GET_GLOBAL(Drives.idmap[iscd][drive]); + u8 driveid = GET_GLOBAL(Drives.idmap[exttype][extdriveoffset]); // basic check : device has to be valid - if (driveid >= ARRAY_SIZE(Drives.drives)) { - disk_ret(regs, DISK_RET_EPARAM); + if (driveid >= ARRAY_SIZE(Drives.drives)) return -1; - } return driveid; } @@ -704,29 +700,37 @@ get_driveid(struct bregs *regs, u8 iscd, u8 drive) static void handle_legacy_disk(struct bregs *regs, u8 extdrive) { - if (extdrive < 0x80) { - floppy_13(regs, extdrive); + if (! CONFIG_DRIVES) { + // XXX - support handle_1301 anyway? + disk_ret(regs, DISK_RET_EPARAM); return; } - if (! CONFIG_DRIVES) { - // XXX - old code had other disk access method. - disk_ret(regs, DISK_RET_EPARAM); + if (extdrive < 0x80) { + int driveid = get_driveid(regs, EXTTYPE_FLOPPY, extdrive); + if (driveid < 0) + goto fail; + floppy_13(regs, driveid); return; } if (extdrive >= 0xe0) { - int driveid = get_driveid(regs, 1, extdrive - 0xe0); + int driveid = get_driveid(regs, EXTTYPE_CD, extdrive - 0xe0); if (driveid < 0) - return; + goto fail; cdrom_13(regs, driveid); return; } - int driveid = get_driveid(regs, 0, extdrive - 0x80); + int driveid = get_driveid(regs, EXTTYPE_HD, extdrive - 0x80); if (driveid < 0) - return; + goto fail; disk_13(regs, driveid); + return; + +fail: + // XXX - support 1301/1308/1315 anyway? + disk_ret(regs, DISK_RET_EPARAM); } void VISIBLE16 |