Ignore:
Timestamp:
Jun 21, 2011, 2:39:30 PM (14 years ago)
Author:
Markus Thielen
Message:

contains CMs changes for unaligned buffers; removed unused stack var; let driver continue boot on unknown command line switch

File:
1 edited

Legend:

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

    r87 r110  
    8080  int rc;
    8181
     82  if (io->BlockCount == 0) {
     83    /* NOP; return -1 without error in IORB to indicate success */
     84    return(-1);
     85  }
     86
     87  if (add_workspace(iorb)->unaligned) {
     88    /* unaligned S/G addresses present; need to use double buffers */
     89    return(atapi_read_unaligned(iorb, slot));
     90  }
     91
    8292  /* translate read command to SCSI/ATAPI READ12 command.
    8393   * READ12 seems to be the most supported READ variant - according to MMC,
     
    112122  if (rc == 0) {
    113123    add_workspace(iorb)->blocks = count;
     124    add_workspace(iorb)->ppfunc = ata_read_pp;
     125
     126  } else if (rc > 0) {
     127    iorb_seterr(iorb, IOERR_CMD_SGLIST_BAD);
     128
     129  } else if (rc == ATA_CMD_UNALIGNED_ADDR) {
     130    /* unaligned S/G addresses detected; need to use double buffers */
     131    add_workspace(iorb)->unaligned = 1;
     132    return(atapi_read_unaligned(iorb, slot));
     133
     134  } else {
     135    iorb_seterr(iorb, IOERR_CMD_ADD_SOFTWARE_FAILURE);
     136  }
     137
     138  return(rc);
     139}
     140
     141/******************************************************************************
     142 * Read sectors from AHCI device with unaligned S/G element addresses. AHCI
     143 * only allows aligned S/G addresses while OS/2 doesn't have these kind of
     144 * restrictions. This doesn't happen very often but when it does, we need to
     145 * use a transfer buffer and copy the data manually.
     146 */
     147int atapi_read_unaligned(IORBH _far *iorb, int slot)
     148{
     149  IORB_EXECUTEIO _far *io = (IORB_EXECUTEIO _far *) iorb;
     150  ADD_WORKSPACE _far *aws = add_workspace(iorb);
     151  ATAPI_CDB_12 cdb;
     152  AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb);
     153  int p = iorb_unit_port(iorb);
     154  int d = iorb_unit_device(iorb);
     155  int rc;
     156
     157  /* translate read command to SCSI/ATAPI READ12 command.
     158   * READ12 seems to be the most supported READ variant - according to MMC,
     159   * and it's enough even for BluRay.
     160   */
     161  memset(&cdb, 0x00, sizeof(cdb));
     162  cdb.cmd = ATAPI_CMD_READ_12;
     163  SET_CDB_32(cdb.lba, io->RBA + io->BlocksXferred);
     164  SET_CDB_32(cdb.trans_len, 1);
     165
     166  /* allocate transfer buffer */
     167  if ((aws->buf = malloc(io->BlockSize)) == NULL) {
     168    iorb_seterr(iorb, IOERR_CMD_SW_RESOURCE);
     169    return(-1);
     170  }
     171
     172  rc = ata_cmd(ai, p, d, slot, ATA_CMD_PACKET,
     173               AP_ATAPI_CMD, (void _far *) &cdb, sizeof(cdb),
     174               AP_VADDR,     (void _far *) aws->buf, (u16) io->BlockSize,
     175               AP_DEVICE,    0x40,
     176               AP_FEATURES,  ATAPI_FEAT_DMA | ATAPI_FEAT_DMA_TO_HOST,
     177               AP_END);
     178
     179  if (rc == 0) {
     180    add_workspace(iorb)->blocks = 1;
    114181    add_workspace(iorb)->ppfunc = ata_read_pp;
    115182
Note: See TracChangeset for help on using the changeset viewer.