Changeset 129 for trunk


Ignore:
Timestamp:
Oct 16, 2011, 9:06:02 PM (14 years ago)
Author:
cjm
Message:
  • Finishing touches to SMART support in the context of tests with smartctl. Needed to separate 'parm' into 'cnt' and 'lba_l' for do_smart() because the "read smart log" command expects the count to be the number of sectors; setting both count and lba_l to the same value may result in DMA transfer overruns or underruns in the AHCI controller.
Location:
trunk/src/os2ahci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/os2ahci/ioctl.c

    r128 r129  
    5959/* -------------------------- function prototypes -------------------------- */
    6060
    61 static USHORT do_smart  (BYTE unit, BYTE sub_func, BYTE parm, void _far *buf);
     61static USHORT do_smart  (BYTE unit, BYTE sub_func, BYTE cnt, BYTE lba_l,
     62                         void _far *buf);
    6263static int    map_unit  (BYTE unit, USHORT _far *a, USHORT _far *p,
    6364                         USHORT _far *d);
     
    498499
    499500  case DSKSP_SMART_ONOFF:
    500     ret = do_smart(unit,
    501                    (BYTE) ((parm) ? ATA_SMART_ENABLE
    502                                   : ATA_SMART_DISABLE),
    503                    0, NULL);
     501    ret = do_smart(unit, (BYTE) ((parm) ? ATA_SMART_ENABLE
     502                                        : ATA_SMART_DISABLE),
     503                   0, 0, NULL);
    504504    break;
    505505
    506506  case DSKSP_SMART_AUTOSAVE_ONOFF:
    507507    ret = do_smart(unit, ATA_SMART_AUTOSAVE,
    508                    (BYTE) ((parm) ? (BYTE) 0xf1 : 0),
    509                    NULL);
     508                   (BYTE) ((parm) ? (BYTE) 0xf1 : 0), 0, NULL);
    510509    break;
    511510
    512511  case DSKSP_SMART_AUTO_OFFLINE:
    513     ret = do_smart(unit, ATA_SMART_AUTO_OFFLINE, parm, NULL);
     512    ret = do_smart(unit, ATA_SMART_AUTO_OFFLINE, parm, 0, NULL);
    514513    break;
    515514
    516515  case DSKSP_SMART_EXEC_OFFLINE:
    517     ret = do_smart(unit, ATA_SMART_IMMEDIATE_OFFLINE, parm, NULL);
     516    ret = do_smart(unit, ATA_SMART_IMMEDIATE_OFFLINE, 0, parm, NULL);
    518517    break;
    519518
    520519  case DSKSP_SMART_SAVE:
    521     ret = do_smart(unit, ATA_SMART_SAVE, 0, NULL);
     520    ret = do_smart(unit, ATA_SMART_SAVE, 0, 0, NULL);
    522521    break;
    523522
    524523  case DSKSP_SMART_GETSTATUS:
    525     ret = do_smart(unit, ATA_SMART_STATUS, 0, ioctl->DataPacket);
     524    ret = do_smart(unit, ATA_SMART_STATUS, 0, 0, ioctl->DataPacket);
    526525    break;
    527526
    528527  case DSKSP_SMART_GET_ATTRIBUTES:
    529     ret = do_smart(unit, ATA_SMART_READ_VALUES, 0, ioctl->DataPacket);
     528    ret = do_smart(unit, ATA_SMART_READ_VALUES, 0, 0, ioctl->DataPacket);
    530529    break;
    531530
    532531  case DSKSP_SMART_GET_THRESHOLDS:
    533     ret = do_smart(unit, ATA_SMART_READ_THRESHOLDS, 0, ioctl->DataPacket);
     532    ret = do_smart(unit, ATA_SMART_READ_THRESHOLDS, 0, 0, ioctl->DataPacket);
    534533    break;
    535534
    536535  case DSKSP_SMART_GET_LOG:
    537     ret = do_smart(unit, ATA_SMART_READ_LOG, parm, ioctl->DataPacket);
     536    ret = do_smart(unit, ATA_SMART_READ_LOG, 1, parm, ioctl->DataPacket);
    538537    break;
    539538
     
    548547 * Perform SMART request. The code has been more or less copied from DANIS506.
    549548 */
    550 static USHORT do_smart(BYTE unit, BYTE sub_func, BYTE parm, void _far *buf)
     549static USHORT do_smart(BYTE unit, BYTE sub_func, BYTE cnt, BYTE lba_l,
     550                       void _far *buf)
    551551{
    552552  OS2AHCI_PASSTHROUGH pt;
     
    575575  pt.cmdlen           = sizeof(pt.cmd.ata);
    576576  pt.cmd.ata.features = sub_func;
    577   pt.cmd.ata.count    = parm;
    578   pt.cmd.ata.lba_l    = (0xc24fL << 8) | parm;
     577  pt.cmd.ata.count    = cnt;
     578  pt.cmd.ata.lba_l    = (0xc24fL << 8) | lba_l;
    579579  pt.cmd.ata.cmd      = ATA_CMD_SMART;
    580580
     
    623623      for (_d = 0; _d <= pi->dev_max; _d++) {
    624624        if (pi->devs[_d].present) {
    625           if (--unit == 0) {
     625          if (unit-- == 0) {
    626626            /* found the device */
    627627            *a = _a;
  • trunk/src/os2ahci/ioctl.h

    r125 r129  
    179179  USHORT      SeekErrors[2];
    180180  USHORT      SATAErrors;
    181 } DeviceCountersData, NEAR *NPDeviceCountersData, FAR *PDeviceCountersData;
     181} DeviceCountersData;
    182182
    183183/******************************************************************************
     
    200200  ULONG       UnitFlags1;
    201201  USHORT      UnitFlags2;
    202 } UnitInformationData, NEAR *NPUnitInformationData, FAR *PUnitInformationData;
     202} UnitInformationData;
    203203
    204204
Note: See TracChangeset for help on using the changeset viewer.