PERFORCE change 167333 for review
Alexander Motin
mav at FreeBSD.org
Fri Aug 14 19:24:33 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=167333
Change 167333 by mav at mav_mavbook on 2009/08/14 19:23:42
Add some ATAPI support to ATA_CAM wrapper.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/dev/ata/ata-all.c#22 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/dev/ata/ata-all.c#22 (text+ko) ====
@@ -149,7 +149,9 @@
/* reset the controller HW, the channel and device(s) */
while (ATA_LOCKING(dev, ATA_LF_LOCK) != ch->unit)
pause("ataatch", 1);
+#ifndef ATA_CAM
ATA_RESET(dev);
+#endif
ATA_LOCKING(dev, ATA_LF_UNLOCK);
/* allocate DMA resources if DMA HW present*/
@@ -1188,11 +1190,6 @@
if (ccb->ccb_h.func_code == XPT_ATA_IO) {
request->data = ccb->ataio.data_ptr;
request->bytecount = ccb->ataio.dxfer_len;
- } else {
- request->data = ccb->csio.data_ptr;
- request->bytecount = ccb->csio.dxfer_len;
- }
- if (ccb->ccb_h.func_code == XPT_ATA_IO) {
request->u.ata.command = ccb->ataio.cmd.command;
request->u.ata.feature = ((uint16_t)ccb->ataio.cmd.features_exp << 8) |
(uint16_t)ccb->ataio.cmd.features;
@@ -1206,14 +1203,29 @@
(uint64_t)ccb->ataio.cmd.lba_low;
if (ccb->ataio.cmd.flags & CAM_ATAIO_48BIT)
request->flags |= ATA_R_48BIT;
- if (ccb->ataio.cmd.flags & CAM_ATAIO_DMA)
+ if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE &&
+ ccb->ataio.cmd.flags & CAM_ATAIO_DMA)
+ request->flags |= ATA_R_DMA;
+ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
+ request->flags |= ATA_R_READ;
+ if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
+ request->flags |= ATA_R_WRITE;
+ } else {
+ request->data = ccb->csio.data_ptr;
+ request->bytecount = ccb->csio.dxfer_len;
+ bcopy((ccb->ccb_h.flags & CAM_CDB_POINTER) ?
+ ccb->csio.cdb_io.cdb_ptr : ccb->csio.cdb_io.cdb_bytes,
+ request->u.atapi.ccb, ccb->csio.cdb_len);
+ request->flags |= ATA_R_ATAPI;
+ if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE /*&&
+ ccb->ataio.cmd.flags & CAM_ATAIO_DMA*/)
request->flags |= ATA_R_DMA;
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
request->flags |= ATA_R_READ;
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
request->flags |= ATA_R_WRITE;
}
- request->transfersize = min(request->bytecount, 512);
+ request->transfersize = min(request->bytecount, 16*512);
// request->callback = ad_done;
request->retries = 0;
request->timeout = ccb->ccb_h.timeout / 1000;
@@ -1223,7 +1235,6 @@
ch->running = request;
ch->state = ATA_ACTIVE;
if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
-device_printf(dev, "XXX: EARLY FINISH!\n");
ch->running = NULL;
ch->state = ATA_IDLE;
ata_cam_end_transaction(dev, request);
@@ -1241,7 +1252,10 @@
ccb->ccb_h.status &= ~CAM_STATUS_MASK;
if (request->result == 0)
ccb->ccb_h.status |= CAM_REQ_CMP;
- else
+ else if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
+ ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR;
+ ccb->csio.scsi_status = SCSI_STATUS_CHECK_COND;
+ } else
ccb->ccb_h.status |= CAM_REQ_CMP_ERR;
ata_free_request(request);
xpt_done(ccb);
More information about the p4-projects
mailing list