Changeset 13 for trunk/src/os2ahci/ata.c


Ignore:
Timestamp:
Sep 14, 2010, 10:07:59 AM (15 years ago)
Author:
root
Message:

latest NCQ changes from Christian

Location:
trunk/src/os2ahci
Files:
1 added
1 moved

Legend:

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

    r12 r13  
    9999
    100100    case AP_WRITE:
    101       ahci_flags |= AHCI_CMD_WRITE;
     101      if (va_arg(va, u16) != 0) {
     102        ahci_flags |= AHCI_CMD_WRITE;
     103      }
    102104      break;
    103105
     
    126128      ata_cmd.lba_h = va_arg(va, u16);
    127129      break;
    128 
     130   
    129131    case AP_DEVICE:
    130132      /* ATA device byte */
     
    147149
    148150    case AP_ATAPI_CMD:
     151      /* ATAPI command */
    149152      atapi_cmd = va_arg(va, void _far *);
    150153      atapi_cmd_len = va_arg(va, u16);
    151154      ahci_flags |= AHCI_CMD_ATAPI;
     155      break;
     156
     157    case AP_ATA_CMD:
     158      /* ATA command "pass-through" */
     159      memcpy(&ata_cmd, va_arg(va, void _far *), sizeof(ATA_CMD));
    152160      break;
    153161
     
    236244        return(i - 1);
    237245      }
    238       ddprintf("s/g list element: addr = 0x%08lx, size = 0x%04lx\n", sg_addr, chunk);
    239246      cmd_tbl->sg_list[n].addr = sg_addr;
    240247      cmd_tbl->sg_list[n].size = chunk - 1;
     
    515522    sg_cnt = io->cSGList - sg_indx;
    516523
    517     if (sector >= (1UL << 28) || count > 256) {
     524    if (sector >= (1UL << 28) || count > 256 || add_workspace(iorb)->is_ncq) {
    518525      /* need LBA48 for this command */
    519526      if (!ai->ports[p].devs[d].lba48) {
     
    521528        return(-1);
    522529      }
    523       rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ_EXT,
    524                    AP_SECTOR_48, (u32) sector, (u16) 0,
    525                    AP_COUNT,     (u16) count,
    526                    AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
    527                    AP_DEVICE,    0x4000,
    528                    AP_END);
     530      if (add_workspace(iorb)->is_ncq) {
     531        /* use NCQ read; count goes into feature register, tag into count! */
     532        rc = ata_cmd(ai, p, d, slot, ATA_CMD_FPDMA_READ,
     533                     AP_SECTOR_48, (u32) sector, (u16) 0,
     534                     AP_FEATURES,  (u16) count,
     535                     AP_COUNT,     (u16) slot, /* tag = slot */
     536                     AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
     537                     AP_DEVICE,    0x4000,
     538                     AP_END);
     539      } else {
     540        rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ_EXT,
     541                     AP_SECTOR_48, (u32) sector, (u16) 0,
     542                     AP_COUNT,     (u16) count,
     543                     AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
     544                     AP_DEVICE,    0x4000,
     545                     AP_END);
     546      }
     547
    529548    } else {
    530549      rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ,
     
    630649    sg_cnt = io->cSGList - sg_indx;
    631650
    632     if (sector >= (1UL << 28) || count > 256) {
     651    if (sector >= (1UL << 28) || count > 256 || add_workspace(iorb)->is_ncq) {
    633652      /* need LBA48 for this command */
    634653      if (!ai->ports[p].devs[d].lba48) {
     
    636655        return(-1);
    637656      }
    638       rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE_EXT,
    639                    AP_SECTOR_48, (u32) sector, (u16) 0,
    640                    AP_COUNT,     (u16) count,
    641                    AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
    642                    AP_DEVICE,    0x4000,
    643                    AP_WRITE,
    644                    AP_END);
     657      if (add_workspace(iorb)->is_ncq) {
     658        /* use NCQ write; count goes into feature register, tag into count! */
     659        rc = ata_cmd(ai, p, d, slot, ATA_CMD_FPDMA_WRITE,
     660                     AP_SECTOR_48, (u32) sector, (u16) 0,
     661                     AP_FEATURES,  (u16) count,
     662                     AP_COUNT,     (u16) slot, /* tag = slot */
     663                     AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
     664                     AP_DEVICE,    0xc000,   /* force unit access (FUA) */
     665                     AP_WRITE,     1,
     666                     AP_END);
     667      } else {
     668        rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE_EXT,
     669                     AP_SECTOR_48, (u32) sector, (u16) 0,
     670                     AP_COUNT,     (u16) count,
     671                     AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
     672                     AP_DEVICE,    0x4000,
     673                     AP_WRITE,     1,
     674                     AP_END);
     675      }
     676     
    645677    } else {
    646678      rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE,
     
    699731int ata_execute_ata(IORBH _far *iorb, int slot)
    700732{
    701   iorb_seterr(iorb, IOERR_CMD_NOT_SUPPORTED);
    702   return(-1);
     733  IORB_ADAPTER_PASSTHRU _far *apt = (IORB_ADAPTER_PASSTHRU _far *) iorb;
     734  AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb);
     735  int p = iorb_unit_port(iorb);
     736  int d = iorb_unit_device(iorb);
     737  int rc;
     738
     739  if (apt->ControllerCmdLen != sizeof(ATA_CMD)) {
     740    iorb_seterr(iorb, IOERR_CMD_SYNTAX);
     741    return(-1);
     742  }
     743
     744  rc = ata_cmd(ai, p, d, slot, 0,
     745               AP_SGLIST,   apt->pSGList, apt->ppSGLIST,
     746               AP_ATA_CMD,  apt->pControllerCmd,
     747               AP_WRITE,    !(apt->Flags & PT_DIRECTION_IN),
     748               AP_END);
     749
     750  return(rc);
    703751}
    704752
     
    745793  }
    746794
    747   /* TBD: fill in SCSI sense buffer in IORB */
    748 
    749795  /* Return an error to indicate there's no HW command to be submitted and
    750796   * that the IORB can be completed "as is" (the upstream code expects the
Note: See TracChangeset for help on using the changeset viewer.