VirtualBox

儲存庫 vbox 的更動 55206


忽略:
時間撮記:
2015-4-13 上午11:05:11 (10 年 以前)
作者:
vboxsync
訊息:

BIOS: Added error checks in AHCI driver.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/PC/BIOS/ahci.c

    r52812 r55206  
    4444    uint32_t    len;
    4545} ahci_prdt;
     46
     47/**
     48 * SATA D2H FIS (Device to Host Frame Information Structure).
     49 */
     50typedef struct {
     51    uint8_t     fis_type;   /* 34h */
     52    uint8_t     intr;       /* Bit 6 indicates interrupt status. */
     53    uint8_t     status;     /* Status register. */
     54    uint8_t     error;      /* Error register. */
     55    uint8_t     sec_no;     /* Sector number register. */
     56    uint8_t     cyl_lo;     /* Cylinder low register. */
     57    uint8_t     cyl_hi;     /* Cylinder high register. */
     58    uint8_t     dev_hd;     /* Device/head register. */
     59    uint8_t     sec_no_exp; /* Expanded sector number register. */
     60    uint8_t     cyl_lo_exp; /* Expanded cylinder low register. */
     61    uint8_t     cyl_hi_exp; /* Expanded cylinder high register. */
     62    uint8_t     resvd0;
     63    uint8_t     sec_cn;     /* Sector count register. */
     64    uint8_t     sec_cn_exp; /* Expanded sector count register. */
     65    uint16_t    resvd1;
     66    uint32_t    resvd2;
     67} fis_d2h;
     68
     69ct_assert(sizeof(fis_d2h) == 20);
    4670
    4771/**
     
    305329        ahci_ctrl_clear_bits(io_base, AHCI_PORT_REG(port, AHCI_REG_PORT_CMD),
    306330                             AHCI_REG_PORT_CMD_ST);
    307 
    308         /** @todo: Examine status. */
     331        /* Caller must examine status. */
    309332    }
    310333    else
     
    315338 * Issue command to device.
    316339 */
    317 static void ahci_cmd_data(bio_dsk_t __far *bios_dsk, uint8_t cmd)
     340static uint16_t ahci_cmd_data(bio_dsk_t __far *bios_dsk, uint8_t cmd)
    318341{
    319342    ahci_t __far    *ahci  = bios_dsk->ahci_seg :> 0;
     
    321344    uint16_t        sectsz = bios_dsk->drqp.sect_sz;
    322345    uint16_t        prdt_idx;
     346    fis_d2h __far   *d2h;
    323347
    324348    _fmemset(&ahci->abCmd[0], 0, sizeof(ahci->abCmd));
     
    384408    ahci_port_cmd_sync(ahci, cmd);
    385409
     410    /* Examine operation status. */
     411    d2h = (void __far *)&ahci->abFisRecv[0x40];
     412    DBG_AHCI("AHCI: ERR=%02x, STAT=%02x, SCNT=%02x\n", d2h->error, d2h->status, d2h->sec_cn);
     413
    386414    /* Unlock the buffer again. */
    387415    vds_free_sg_list(&ahci->edds);
     416    return d2h->error ? 4 : 0;
    388417}
    389418
     
    490519{
    491520    uint16_t        device_id;
     521    uint16_t        rc;
    492522
    493523    device_id = VBOX_GET_AHCI_DEVICE(bios_dsk->drqp.dev_id);
     
    501531    high_bits_save(bios_dsk->ahci_seg :> 0);
    502532    ahci_port_init(bios_dsk->ahci_seg :> 0, bios_dsk->ahcidev[device_id].port);
    503     ahci_cmd_data(bios_dsk, AHCI_CMD_READ_DMA_EXT);
     533    rc = ahci_cmd_data(bios_dsk, AHCI_CMD_READ_DMA_EXT);
    504534    DBG_AHCI("%s: transferred %lu bytes\n", __func__, ((ahci_t __far *)(bios_dsk->ahci_seg :> 0))->aCmdHdr[1]);
    505535    bios_dsk->drqp.trsfsectors = bios_dsk->drqp.nsect;
     
    508538#endif
    509539    high_bits_restore(bios_dsk->ahci_seg :> 0);
    510     return 0;   //@todo!!
     540    return rc;
    511541}
    512542
     
    521551{
    522552    uint16_t        device_id;
     553    uint16_t        rc;
    523554
    524555    device_id = VBOX_GET_AHCI_DEVICE(bios_dsk->drqp.dev_id);
     
    532563    high_bits_save(bios_dsk->ahci_seg :> 0);
    533564    ahci_port_init(bios_dsk->ahci_seg :> 0, bios_dsk->ahcidev[device_id].port);
    534     ahci_cmd_data(bios_dsk, AHCI_CMD_WRITE_DMA_EXT);
     565    rc = ahci_cmd_data(bios_dsk, AHCI_CMD_WRITE_DMA_EXT);
    535566    DBG_AHCI("%s: transferred %lu bytes\n", __func__, ((ahci_t __far *)(bios_dsk->ahci_seg :> 0))->aCmdHdr[1]);
    536567    bios_dsk->drqp.trsfsectors = bios_dsk->drqp.nsect;
    537568    high_bits_restore(bios_dsk->ahci_seg :> 0);
    538     return 0;   //@todo!!
     569    return rc;
    539570}
    540571
     
    605636
    606637    return ahci->aCmdHdr[1] == 0 ? 4 : 0;
    607 //    return 0;   //@todo!!
    608638}
    609639
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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