Ignore:
Timestamp:
Feb 22, 2011, 2:25:44 AM (14 years ago)
Author:
chris
Message:
  • Further fixes to automatic ATAPI sense handling, now supporting sense buffers larger than 64 bytes if requested by initiator (cdrecord wanted 96 bytes)
  • Separate, and internally handled, spinlock for libc malloc/free calls to reduce chances of memory corruption if somebody forgets to get the driver-level spinlock before calling malloc/free. There was no real problem with that, just some awkward code fragments which look much better now.
  • Link power management implemented
  • More generic support for adapter/port options so all of them can now have a global, adapter or port scope
  • Generic support for inverting driver options (i.e. turn them off with '!')
  • Thorough PCI scan is now the default; the reason it wasn't so far was a delay in Virtualbox but that was never a problem on real hardware
  • SCSI emulation for ATAPI devices; this can be enabled on global, adapter or port scope
File:
1 edited

Legend:

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

    r76 r77  
    201201  u8 cdb[ATAPI_MIN_CDB_LEN];
    202202  ATAPI_CDB_6 _far *pcdb = (ATAPI_CDB_6 _far *) cdb;
     203  size_t sense_buf_len = ATAPI_SENSE_LEN;
    203204
    204205  if ((iorb->RequestControl & IORB_REQ_STATUSBLOCK) &&
     
    211212                                       (u16) iorb->pStatusBlock);
    212213    if (ssb->Flags & 0x0008U) {
    213       /* set a generic error code and skip automatic sense code handling */
    214214      iorb_seterr(iorb, IOERR_DEVICE_NONSPECIFIC);
    215215      return(-1);
    216216    }
     217
     218    /* if the sense buffer requested is larger than our default, adjust
     219     * the length accordingly to satisfy the caller's requirements. */
     220    if (ssb->SenseData != NULL && ssb->ReqSenseLen > sense_buf_len) {
     221      sense_buf_len = ssb->ReqSenseLen;
     222    }
    217223  }
    218224
    219225  /* allocate sense buffer in ADD workspace */
    220   if ((aws->buf = malloc(ATAPI_SENSE_LEN)) == NULL) {
     226  if ((aws->buf = malloc(sense_buf_len)) == NULL) {
    221227    iorb_seterr(iorb, IOERR_CMD_SW_RESOURCE);
    222228    return(-1);
    223229  }
    224   memset(aws->buf, 0x00, ATAPI_SENSE_LEN);
     230  memset(aws->buf, 0x00, sense_buf_len);
    225231
    226232  /* prepare request sense command */
    227233  memset(cdb, 0x00, sizeof(cdb));
    228234  pcdb->cmd = ATAPI_CMD_REQUEST_SENSE;
    229   pcdb->trans_len = (u8) ATAPI_SENSE_LEN;
     235  pcdb->trans_len = (u8) sense_buf_len;
    230236 
    231237  aws->ppfunc = atapi_req_sense_pp;
     
    236242               ATA_CMD_PACKET,
    237243               AP_ATAPI_CMD, (void _far*) cdb, sizeof(cdb),
    238                AP_VADDR, (void _far *) aws->buf, ATAPI_SENSE_LEN,
     244               AP_VADDR, (void _far *) aws->buf, sense_buf_len,
    239245               AP_FEATURES,  ATAPI_FEAT_DMA,
    240246               AP_END);
     
    277283
    278284    if (ssb->SenseData != NULL) {
    279       memcpy(ssb->SenseData, psd, max(ssb->ReqSenseLen, ATAPI_SENSE_LEN));
     285      memcpy(ssb->SenseData, psd, ssb->ReqSenseLen);
    280286      ssb->Flags |= STATUS_SENSEDATA_VALID;
    281287    }
Note: See TracChangeset for help on using the changeset viewer.