Changeset 13 for trunk/src/os2ahci/ata.c
- Timestamp:
- Sep 14, 2010, 10:07:59 AM (15 years ago)
- Location:
- trunk/src/os2ahci
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/ata.c
r12 r13 99 99 100 100 case AP_WRITE: 101 ahci_flags |= AHCI_CMD_WRITE; 101 if (va_arg(va, u16) != 0) { 102 ahci_flags |= AHCI_CMD_WRITE; 103 } 102 104 break; 103 105 … … 126 128 ata_cmd.lba_h = va_arg(va, u16); 127 129 break; 128 130 129 131 case AP_DEVICE: 130 132 /* ATA device byte */ … … 147 149 148 150 case AP_ATAPI_CMD: 151 /* ATAPI command */ 149 152 atapi_cmd = va_arg(va, void _far *); 150 153 atapi_cmd_len = va_arg(va, u16); 151 154 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)); 152 160 break; 153 161 … … 236 244 return(i - 1); 237 245 } 238 ddprintf("s/g list element: addr = 0x%08lx, size = 0x%04lx\n", sg_addr, chunk);239 246 cmd_tbl->sg_list[n].addr = sg_addr; 240 247 cmd_tbl->sg_list[n].size = chunk - 1; … … 515 522 sg_cnt = io->cSGList - sg_indx; 516 523 517 if (sector >= (1UL << 28) || count > 256 ) {524 if (sector >= (1UL << 28) || count > 256 || add_workspace(iorb)->is_ncq) { 518 525 /* need LBA48 for this command */ 519 526 if (!ai->ports[p].devs[d].lba48) { … … 521 528 return(-1); 522 529 } 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 529 548 } else { 530 549 rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ, … … 630 649 sg_cnt = io->cSGList - sg_indx; 631 650 632 if (sector >= (1UL << 28) || count > 256 ) {651 if (sector >= (1UL << 28) || count > 256 || add_workspace(iorb)->is_ncq) { 633 652 /* need LBA48 for this command */ 634 653 if (!ai->ports[p].devs[d].lba48) { … … 636 655 return(-1); 637 656 } 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 645 677 } else { 646 678 rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE, … … 699 731 int ata_execute_ata(IORBH _far *iorb, int slot) 700 732 { 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); 703 751 } 704 752 … … 745 793 } 746 794 747 /* TBD: fill in SCSI sense buffer in IORB */748 749 795 /* Return an error to indicate there's no HW command to be submitted and 750 796 * that the IORB can be completed "as is" (the upstream code expects the
Note:
See TracChangeset
for help on using the changeset viewer.