Changeset e1dbcbc in mainline for uspace/srv/bd/ata_bd/ata_bd.c


Ignore:
Timestamp:
2011-04-29T13:43:01Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a81a1d09
Parents:
380e0364 (diff), f19f1b7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge development/ changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/ata_bd/ata_bd.c

    r380e0364 re1dbcbc  
    372372        uint16_t w;
    373373        uint8_t c;
     374        uint16_t bc;
    374375        size_t pos, len;
    375376        int rc;
     
    387388        } else if (rc == EIO) {
    388389                /*
    389                  * There is something, but not a register device.
    390                  * It could be a packet device.
     390                 * There is something, but not a register device. Check to see
     391                 * whether the IDENTIFY command left the packet signature in
     392                 * the registers in case this is a packet device.
     393                 *
     394                 * According to the ATA specification, the LBA low and
     395                 * interrupt reason registers should be set to 0x01. However,
     396                 * there are many devices that do not follow this and only set
     397                 * the byte count registers. So, only check these.
    391398                 */
    392                 rc = identify_pkt_dev(disk_id, &idata);
    393                 if (rc == EOK) {
    394                         /* We have a packet device. */
    395                         d->dev_type = ata_pkt_dev;
     399                bc = ((uint16_t)pio_read_8(&cmd->cylinder_high) << 8) |
     400                    pio_read_8(&cmd->cylinder_low);
     401
     402                if (bc == PDEV_SIGNATURE_BC) {
     403                        rc = identify_pkt_dev(disk_id, &idata);
     404                        if (rc == EOK) {
     405                                /* We have a packet device. */
     406                                d->dev_type = ata_pkt_dev;
     407                        } else {
     408                                return EIO;
     409                        }
    396410                } else {
    397411                        /* Nope. Something's there, but not recognized. */
     
    403417        }
    404418
    405         printf("device caps: 0x%04x\n", idata.caps);
    406419        if (d->dev_type == ata_pkt_dev) {
    407420                /* Packet device */
     
    566579
    567580        /*
    568          * This is where we would most likely expect a non-existing device to
    569          * show up by not setting SR_DRDY.
     581         * Do not wait for DRDY to be set in case this is a packet device.
     582         * We determine whether the device is present by waiting for DRQ to be
     583         * set after issuing the command.
    570584         */
    571         if (wait_status(SR_DRDY, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)
     585        if (wait_status(0, ~SR_BSY, NULL, TIMEOUT_PROBE) != EOK)
    572586                return ETIMEOUT;
    573587
     
    577591                return ETIMEOUT;
    578592
     593        /*
     594         * If ERR is set, this may be a packet device, so return EIO to cause
     595         * the caller to check for one.
     596         */
     597        if ((status & SR_ERR) != 0) {
     598                return EIO;
     599        }
     600
     601        if (wait_status(SR_DRQ, ~SR_BSY, &status, TIMEOUT_PROBE) != EOK)
     602                return ETIMEOUT;
     603
    579604        /* Read data from the disk buffer. */
    580605
    581         if ((status & SR_DRQ) != 0) {
    582                 for (i = 0; i < identify_data_size / 2; i++) {
    583                         data = pio_read_16(&cmd->data_port);
    584                         ((uint16_t *) buf)[i] = data;
    585                 }
    586         }
    587 
    588         if ((status & SR_ERR) != 0) {
    589                 return EIO;
     606        for (i = 0; i < identify_data_size / 2; i++) {
     607                data = pio_read_16(&cmd->data_port);
     608                ((uint16_t *) buf)[i] = data;
    590609        }
    591610
Note: See TracChangeset for help on using the changeset viewer.