Ignore:
Timestamp:
Dec 12, 2017, 11:08:37 PM (8 years ago)
Author:
David Azarewicz
Message:

Fixed IOCtl pass-thru interface.
Cosmetic changes to user interface.
Removed old IBM smartctl exe from distribution.

File:
1 edited

Legend:

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

    r191 r193  
    5555  SCATGATENTRY        sg_lst[AHCI_MAX_SG / 2]; /* scatter/gather list */
    5656  ULONG               sg_cnt;                  /* number of S/G elements */
    57   struct _KernVMLock_t *lh;                  /* lock handle for VMLock() */
     57  struct _KernVMLock_t lh;                     /* lock handle for KernVMLock() */
    5858} IOCTL_CONTEXT;
    5959
    6060/* -------------------------- function prototypes -------------------------- */
    6161
    62 static USHORT do_smart  (BYTE unit, BYTE sub_func, BYTE cnt, BYTE lba_l,
    63                          void *buf);
    64 static int    map_unit  (BYTE unit, USHORT *a, USHORT *p,
    65                          USHORT *d);
     62static USHORT do_smart(BYTE unit, BYTE sub_func, BYTE cnt, BYTE lba_l, void *buf);
     63static int map_unit(BYTE unit, USHORT *a, USHORT *p, USHORT *d);
    6664
    6765extern IORBH FAR16DATA * (__far16 *Far16AdrOfIoctlWakeup16)(IORBH FAR16DATA*);
     
    168166  memset(ic, 0x00, sizeof(*ic));
    169167
     168  /* lock DMA transfer buffer into memory and construct S/G list */
     169  if (req->buflen > 0)
     170  {
     171    if (KernVMLock(VMDHL_LONG | !((req->flags & PT_WRITE) ? VMDHL_WRITE : 0),
     172                       req->buf, req->buflen, &ic->lh, (KernPageList_t*)&ic->sg_lst, &ic->sg_cnt) != 0)
     173    {
     174      /* couldn't lock buffer and/or produce a S/G list */
     175      MemFree(ic);
     176      return(RPDONE | RPERR_PARAMETER);
     177    }
     178  }
     179
    170180  /* fill in adapter passthrough fields */
    171181  ic->iorb.iorbh.Length           = sizeof(ic->iorb);
     
    200210
    201211  /* Wait for IORB completion. */
    202   spin_lock(drv_lock);
     212
     213  //DAZ 20171206 spin_lock(drv_lock);
    203214  while (!(ic->iorb.iorbh.Status & IORB_DONE))
    204215  {
    205     KernBlock((ULONG)&ic->iorb.iorbh, 30000, 0, NULL, NULL);
    206   }
    207   spin_unlock(drv_lock);
     216    KernBlock(CastFar16ToULONG(MemFar16Adr(&ic->iorb.iorbh)), 30000, 0, NULL, NULL);
     217  }
     218  //DAZ 20171206 spin_unlock(drv_lock);
    208219
    209220  ret = RPDONE;
     
    270281      memcpy(sense_buf, ic->sense, min(ic->ssb.ReqSenseLen, req->sense_len));
    271282    }
    272 
    273283  }
    274284  else if ((req->flags & PT_ATAPI) == 0)
     
    282292
    283293  MemFree(ic);
     294  if (req->buflen > 0) KernVMUnlock(&ic->lh);
    284295  return(ret);
    285296}
     
    393404{
    394405  DSKSP_CommandParameters *cp = (DSKSP_CommandParameters *)Far16ToFlat(ioctl->ioctl.pvParm);
    395   USHORT size = 0;
    396406  USHORT ret;
    397407  UCHAR unit;
    398   UCHAR parm;
     408  UCHAR parm = 0;
     409  void *pData = NULL;
    399410
    400411  unit = cp->byPhysicalUnit;
    401412
    402   /* verify addressability of data buffer (depends on SMART function) */
    403   switch (ioctl->ioctl.bFunction)
    404   {
    405 
    406   case DSKSP_SMART_GETSTATUS:
    407     size = sizeof(ULONG);
    408     break;
    409 
    410   case DSKSP_SMART_GET_ATTRIBUTES:
    411   case DSKSP_SMART_GET_THRESHOLDS:
    412   case DSKSP_SMART_GET_LOG:
    413     size = 512;
    414     break;
    415   }
    416 
    417   if (size > 0)
    418   {
    419     parm = *(UCHAR*)Far16ToFlat(ioctl->ioctl.pvData);
     413  if (ioctl->ioctl.pvData)
     414  {
     415    pData = (void*)Far16ToFlat(ioctl->ioctl.pvData);
     416    parm = *(UCHAR*)pData;
    420417  }
    421418
     
    444441
    445442  case DSKSP_SMART_GETSTATUS:
    446     ret = do_smart(unit, ATA_SMART_STATUS, 0, 0, Far16ToFlat(ioctl->ioctl.pvData));
     443    ret = do_smart(unit, ATA_SMART_STATUS, 0, 0, pData);
    447444    break;
    448445
    449446  case DSKSP_SMART_GET_ATTRIBUTES:
    450     ret = do_smart(unit, ATA_SMART_READ_VALUES, 0, 0, Far16ToFlat(ioctl->ioctl.pvData));
     447    ret = do_smart(unit, ATA_SMART_READ_VALUES, 0, 0, pData);
    451448    break;
    452449
    453450  case DSKSP_SMART_GET_THRESHOLDS:
    454     ret = do_smart(unit, ATA_SMART_READ_THRESHOLDS, 0, 0, Far16ToFlat(ioctl->ioctl.pvData));
     451    ret = do_smart(unit, ATA_SMART_READ_THRESHOLDS, 0, 0, pData);
    455452    break;
    456453
    457454  case DSKSP_SMART_GET_LOG:
    458     ret = do_smart(unit, ATA_SMART_READ_LOG, 1, parm, Far16ToFlat(ioctl->ioctl.pvData));
     455    ret = do_smart(unit, ATA_SMART_READ_LOG, 1, parm, pData);
    459456    break;
    460457
Note: See TracChangeset for help on using the changeset viewer.