Changeset 193 for trunk/src/os2ahci/ioctl.c
- Timestamp:
- Dec 12, 2017, 11:08:37 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ioctl.c
r191 r193 55 55 SCATGATENTRY sg_lst[AHCI_MAX_SG / 2]; /* scatter/gather list */ 56 56 ULONG sg_cnt; /* number of S/G elements */ 57 struct _KernVMLock_t *lh; /* lock handle forVMLock() */57 struct _KernVMLock_t lh; /* lock handle for KernVMLock() */ 58 58 } IOCTL_CONTEXT; 59 59 60 60 /* -------------------------- function prototypes -------------------------- */ 61 61 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); 62 static USHORT do_smart(BYTE unit, BYTE sub_func, BYTE cnt, BYTE lba_l, void *buf); 63 static int map_unit(BYTE unit, USHORT *a, USHORT *p, USHORT *d); 66 64 67 65 extern IORBH FAR16DATA * (__far16 *Far16AdrOfIoctlWakeup16)(IORBH FAR16DATA*); … … 168 166 memset(ic, 0x00, sizeof(*ic)); 169 167 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 170 180 /* fill in adapter passthrough fields */ 171 181 ic->iorb.iorbh.Length = sizeof(ic->iorb); … … 200 210 201 211 /* Wait for IORB completion. */ 202 spin_lock(drv_lock); 212 213 //DAZ 20171206 spin_lock(drv_lock); 203 214 while (!(ic->iorb.iorbh.Status & IORB_DONE)) 204 215 { 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); 208 219 209 220 ret = RPDONE; … … 270 281 memcpy(sense_buf, ic->sense, min(ic->ssb.ReqSenseLen, req->sense_len)); 271 282 } 272 273 283 } 274 284 else if ((req->flags & PT_ATAPI) == 0) … … 282 292 283 293 MemFree(ic); 294 if (req->buflen > 0) KernVMUnlock(&ic->lh); 284 295 return(ret); 285 296 } … … 393 404 { 394 405 DSKSP_CommandParameters *cp = (DSKSP_CommandParameters *)Far16ToFlat(ioctl->ioctl.pvParm); 395 USHORT size = 0;396 406 USHORT ret; 397 407 UCHAR unit; 398 UCHAR parm; 408 UCHAR parm = 0; 409 void *pData = NULL; 399 410 400 411 unit = cp->byPhysicalUnit; 401 412 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; 420 417 } 421 418 … … 444 441 445 442 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); 447 444 break; 448 445 449 446 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); 451 448 break; 452 449 453 450 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); 455 452 break; 456 453 457 454 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); 459 456 break; 460 457
Note:
See TracChangeset
for help on using the changeset viewer.