VirtualBox

Changeset 36704 in vbox for trunk/src/VBox/Devices/PC/BIOS


Ignore:
Timestamp:
Apr 18, 2011 11:43:39 AM (14 years ago)
Author:
vboxsync
Message:

BIOS: Try to find the right floppy data rate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/rombios.c

    r36205 r36704  
    73477347
    73487348  bx_bool
     7349floppy_read_id(drive)
     7350  Bit16u drive;
     7351{
     7352  Bit8u  val8;
     7353  Bit8u  return_status[7];
     7354
     7355  floppy_prepare_controller(drive);
     7356
     7357  // send Read ID command (2 bytes) to controller
     7358  outb(0x03f5, 0x4a);  // 4a: Read ID (MFM)
     7359  outb(0x03f5, drive); // 0=drive0, 1=drive1, head always 0
     7360
     7361  // turn on interrupts
     7362ASM_START
     7363  sti
     7364ASM_END
     7365
     7366  // wait on 40:3e bit 7 to become 1
     7367  do {
     7368    val8 = (read_byte(0x0040, 0x003e) & 0x80);
     7369  } while ( val8 == 0 );
     7370
     7371  val8 = 0; // separate asm from while() loop
     7372  // turn off interrupts
     7373ASM_START
     7374  cli
     7375ASM_END
     7376
     7377  // read 7 return status bytes from controller
     7378  return_status[0] = inb(0x3f5);
     7379  return_status[1] = inb(0x3f5);
     7380  return_status[2] = inb(0x3f5);
     7381  return_status[3] = inb(0x3f5);
     7382  return_status[4] = inb(0x3f5);
     7383  return_status[5] = inb(0x3f5);
     7384  return_status[6] = inb(0x3f5);
     7385
     7386  if ( (return_status[0] & 0xc0) != 0 )
     7387    return(0);
     7388  else
     7389    return(1);
     7390}
     7391
     7392  bx_bool
    73497393floppy_media_sense(drive)
    73507394  Bit16u drive;
     
    73587402    }
    73597403
    7360   // for now cheat and get drive type from CMOS,
    7361   // assume media is same as drive type
     7404  // Try the diskette data rates in the following order:
     7405  // 1 Mbps -> 500 Kbps -> 300 Kbps -> 250 Kbps
     7406  // The 1 Mbps rate is only tried for 2.88M drives.
    73627407
    73637408  // ** config_data **
     
    74527497    }
    74537498
     7499  write_byte(0x0040, 0x008B, config_data);
     7500  while (!floppy_read_id(drive)) {
     7501    if ((config_data & 0xC0) == 0x80) {
     7502        // If even 250 Kbps failed, we can't do much
     7503        break;
     7504    }
     7505    switch (config_data & 0xC0) {
     7506    case 0xC0:  // 1 Mbps
     7507        config_data = config_data & 0x3F | 0x00;
     7508        break;
     7509    case 0x00:  // 500 Kbps
     7510        config_data = config_data & 0x3F | 0x40;
     7511        break;
     7512    case 0x40:  // 300 Kbps
     7513        config_data = config_data & 0x3F | 0x80;
     7514        break;
     7515    }
     7516    write_byte(0x0040, 0x008B, config_data);
     7517  }
     7518
    74547519  if (drive == 0)
    74557520    media_state_offset = 0x90;
     
    75647629        return;
    75657630      }
     7631
     7632      // force re-calibration etc.
     7633      write_byte(0x0040, 0x003e, 0);
     7634
    75667635      SET_AH(0);
    75677636      set_diskette_ret_status(0);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette