diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2010-12-27 08:37:38 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2010-12-27 21:05:59 -0500 |
commit | 3c5e0e176b1e71b225b409c5c053094a731c5f64 (patch) | |
tree | bd144ba1bbf0bcb97cfa97e9081e380f2a490785 | |
parent | 031ef55b50361adff3d1d2766543d2f9c6ce1998 (diff) | |
download | seabios-3c5e0e176b1e71b225b409c5c053094a731c5f64.tar.gz |
Rename add_ordered_drive() to add_drive() and use in map_hd_drive().
-rw-r--r-- | src/block.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/block.c b/src/block.c index 72b30813..6a3faa30 100644 --- a/src/block.c +++ b/src/block.c @@ -30,14 +30,13 @@ getDrive(u8 exttype, u8 extdriveoffset) int getDriveId(u8 exttype, struct drive_s *drive_g) { int i; - for (i = 0; i < ARRAY_SIZE(Drives.idmap[0]); i++) if (getDrive(exttype, i) == drive_g) return i; - return -1; } + /**************************************************************** * Disk geometry translation ****************************************************************/ @@ -200,27 +199,9 @@ fill_fdpt(struct drive_s *drive_g, int hdid) struct extended_bios_data_area_s, fdpt[1]))); } -// Map a drive (that was registered via add_bcv_hd) -void -map_hd_drive(struct drive_s *drive_g) -{ - // fill hdidmap - u8 hdcount = GET_BDA(hdcount); - if (hdcount >= ARRAY_SIZE(Drives.idmap[0])) { - warn_noalloc(); - return; - } - dprintf(3, "Mapping hd drive %p to %d\n", drive_g, hdcount); - Drives.idmap[EXTTYPE_HD][hdcount] = drive_g; - SET_BDA(hdcount, hdcount + 1); - - // Fill "fdpt" structure. - fill_fdpt(drive_g, hdcount); -} - // Find spot to add a drive static void -add_ordered_drive(struct drive_s **idmap, u8 *count, struct drive_s *drive_g) +add_drive(struct drive_s **idmap, u8 *count, struct drive_s *drive_g) { if (*count >= ARRAY_SIZE(Drives.idmap[0])) { warn_noalloc(); @@ -230,22 +211,34 @@ add_ordered_drive(struct drive_s **idmap, u8 *count, struct drive_s *drive_g) *count = *count + 1; } +// Map a hard drive +void +map_hd_drive(struct drive_s *drive_g) +{ + ASSERT32FLAT(); + struct bios_data_area_s *bda = MAKE_FLATPTR(SEG_BDA, 0); + int hdid = bda->hdcount; + dprintf(3, "Mapping hd drive %p to %d\n", drive_g, hdid); + add_drive(Drives.idmap[EXTTYPE_HD], &bda->hdcount, drive_g); + + // Fill "fdpt" structure. + fill_fdpt(drive_g, hdid); +} + // Map a cd void map_cd_drive(struct drive_s *drive_g) { dprintf(3, "Mapping cd drive %p\n", drive_g); - add_ordered_drive(Drives.idmap[EXTTYPE_CD], &Drives.cdcount, drive_g); + add_drive(Drives.idmap[EXTTYPE_CD], &Drives.cdcount, drive_g); } // Map a floppy void map_floppy_drive(struct drive_s *drive_g) { - // fill idmap dprintf(3, "Mapping floppy drive %p\n", drive_g); - add_ordered_drive(Drives.idmap[EXTTYPE_FLOPPY], &Drives.floppycount - , drive_g); + add_drive(Drives.idmap[EXTTYPE_FLOPPY], &Drives.floppycount, drive_g); // Update equipment word bits for floppy if (Drives.floppycount == 1) { |