- if (CONFIG_THREADS) {
- // Add to idmap with assured drive order.
- struct drive_s **end = pos;
- for (;;) {
- struct drive_s **prev = pos - 1;
- if (prev < idmap)
- break;
- struct drive_s *prevdrive = *prev;
- if (prevdrive->type < drive_g->type
- || (prevdrive->type == drive_g->type
- && prevdrive->cntl_id < drive_g->cntl_id))
- break;
- pos--;
- }
- if (pos != end)
- memmove(pos+1, pos, (void*)end-(void*)pos);
- }
- *pos = drive_g;
+}
+
+// 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(IDMap[EXTTYPE_HD], &bda->hdcount, drive_g);
+
+ // Setup disk geometry translation.
+ setup_translation(drive_g);
+
+ // Fill "fdpt" structure.
+ fill_fdpt(drive_g, hdid);