VirtualBox

Changeset 44692 in vbox


Ignore:
Timestamp:
Feb 14, 2013 3:44:30 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
83788
Message:

BIOS: Implemented ATAPI device reset.

Location:
trunk/src/VBox/Devices/PC/BIOS
Files:
3 edited

Legend:

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

    r44528 r44692  
    757757   
    758758    if (status & ATA_CB_STAT_ERR) {
    759         BX_DEBUG_ATA("%s: read error\n", __func__);
     759        BX_DEBUG_ATA("%s: write error\n", __func__);
    760760        // Enable interrupts
    761761        outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
     
    949949    }
    950950   
    951     if (status & ATA_CB_STAT_ERR) {
     951    if (status & ATA_CB_STAT_CHK) {
    952952        BX_DEBUG_ATA("%s: error, status is %02x\n", __func__, status);
    953953        // Enable interrupts
     
    988988                break;
    989989           
    990             if (status & ATA_CB_STAT_ERR) {
     990            if (status & ATA_CB_STAT_CHK) {
    991991                BX_DEBUG_ATA("%s: error (status %02x)\n", __func__, status);
    992992                // Enable interrupts
     
    996996           
    997997            // Device must be ready to send data
    998             if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
     998            if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ | ATA_CB_STAT_CHK) )
    999999              != (ATA_CB_STAT_RDY | ATA_CB_STAT_DRQ) ) {
    10001000                BX_DEBUG_ATA("%s: not ready (status %02x)\n", __func__, status);
     
    10941094   
    10951095    // Final check, device must be ready
    1096     if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_ERR) )
     1096    if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_CHK) )
    10971097      != ATA_CB_STAT_RDY ) {
    10981098        BX_DEBUG_ATA("%s: not ready (status %02x)\n", __func__, (unsigned) status);
     
    11071107}
    11081108
     1109// ---------------------------------------------------------------------------
     1110// ATA/ATAPI driver : reset device; intended for ATAPI devices
     1111// ---------------------------------------------------------------------------
     1112      // returns
     1113      // 0 : no error
     1114      // 1 : error
     1115uint16_t ata_soft_reset(uint16_t device)
     1116{
     1117    uint16_t        iobase1, iobase2;
     1118    uint8_t         channel, slave;
     1119    uint8_t         status;
     1120    bio_dsk_t __far *bios_dsk;
     1121
     1122    bios_dsk = read_word(0x0040, 0x000E) :> &EbdaData->bdisk;
     1123
     1124    channel = device / 2;
     1125    slave   = device % 2;
     1126
     1127    iobase1  = bios_dsk->channels[channel].iobase1;
     1128    iobase2  = bios_dsk->channels[channel].iobase2;
     1129
     1130    /* Send a reset command to the device. */
     1131    outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15 | ATA_CB_DC_NIEN);
     1132    outb(iobase1 + ATA_CB_DH, slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0);
     1133    outb(iobase1 + ATA_CB_CMD, ATA_CMD_DEVICE_RESET);
     1134   
     1135    /* Wait for the device to clear BSY. */
     1136    while (1) {
     1137        status = inb(iobase1 + ATA_CB_STAT);
     1138        if ( !(status & ATA_CB_STAT_BSY) ) break;
     1139    }
     1140   
     1141    /* Final check, device must be ready */
     1142    if ( (status & (ATA_CB_STAT_BSY | ATA_CB_STAT_RDY | ATA_CB_STAT_DF | ATA_CB_STAT_DRQ | ATA_CB_STAT_CHK) )
     1143      != ATA_CB_STAT_RDY ) {
     1144        BX_DEBUG_ATA("%s: not ready (status %02x)\n", __func__, (unsigned) status);
     1145        /* Enable interrupts */
     1146        outb(iobase2 + ATA_CB_DC, ATA_CB_DC_HD15);
     1147        return 1;
     1148    }
     1149   
     1150    /* Enable interrupts */
     1151    outb(iobase2+ATA_CB_DC, ATA_CB_DC_HD15);
     1152    return 0;
     1153}
     1154
    11091155
    11101156// ---------------------------------------------------------------------------
  • trunk/src/VBox/Devices/PC/BIOS/ebda.h

    r44528 r44692  
    222222                               uint16_t header, uint32_t length, uint8_t inout, char __far *buffer);
    223223
     224extern uint16_t ata_soft_reset(uint16_t device);
     225
    224226/* All BIOS disk information. Disk-related code in the BIOS should not need
    225227 * anything outside of this structure.
  • trunk/src/VBox/Devices/PC/BIOS/eltorito.c

    r44528 r44692  
    109109};
    110110
     111/* Generic reset routine signature. */
     112typedef uint16_t (* cd_rst_func)(uint16_t device_id);
     113
     114/* Pointers to HW specific CD-ROM reset routines. */
     115cd_rst_func     softrst[DSKTYP_CNT] = {
     116    [DSK_TYPE_ATAPI]  = { ata_soft_reset },
     117#ifdef VBOX_WITH_AHCI
     118    [DSK_TYPE_AHCI]   = NULL,
     119#endif
     120#ifdef VBOX_WITH_SCSI
     121    [DSK_TYPE_SCSI]   = NULL,
     122#endif
     123};
     124
     125
    111126// ---------------------------------------------------------------------------
    112127// Start of El-Torito boot functions
     
    474489    switch (GET_AH()) {
    475490
     491    case 0x00: /* disk controller reset */
     492        if (pktacc[bios_dsk->devices[device].type])
     493        {
     494            status = softrst[bios_dsk->devices[device].type](device);
     495        }
     496        goto int13_success;
     497        break;
    476498    // all those functions return SUCCESS
    477     case 0x00: /* disk controller reset */
    478499    case 0x09: /* initialize drive parameters */
    479500    case 0x0c: /* seek to specified cylinder */
Note: See TracChangeset for help on using the changeset viewer.

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