svn commit: r251463 - stable/8/sys/cam/scsi

Steven Hartland smh at FreeBSD.org
Thu Jun 6 10:09:21 UTC 2013


Author: smh
Date: Thu Jun  6 10:09:20 2013
New Revision: 251463
URL: http://svnweb.freebsd.org/changeset/base/251463

Log:
  MFC r248992:
  Added ATA Pass-Through support to CAM

Modified:
  stable/8/sys/cam/scsi/scsi_all.c
  stable/8/sys/cam/scsi/scsi_all.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/cam/   (props changed)

Modified: stable/8/sys/cam/scsi/scsi_all.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_all.c	Thu Jun  6 10:06:32 2013	(r251462)
+++ stable/8/sys/cam/scsi/scsi_all.c	Thu Jun  6 10:09:20 2013	(r251463)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include <cam/cam_queue.h>
 #include <cam/cam_xpt.h>
 #include <cam/scsi/scsi_all.h>
+#include <sys/ata.h>
 #include <sys/sbuf.h>
 #ifndef _KERNEL
 #include <camlib.h>
@@ -4390,6 +4391,50 @@ scsi_write_same(struct ccb_scsiio *csio,
 }
 
 void
+scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries,
+		 void (*cbfcnp)(struct cam_periph *, union ccb *),
+		 u_int32_t flags, u_int8_t tag_action,
+		 u_int8_t protocol, u_int8_t ata_flags, u_int16_t features,
+		 u_int16_t sector_count, uint64_t lba, u_int8_t command,
+		 u_int8_t control, u_int8_t *data_ptr, u_int16_t dxfer_len,
+		 u_int8_t sense_len, u_int32_t timeout)
+{
+	struct ata_pass_16 *ata_cmd;
+
+	ata_cmd = (struct ata_pass_16 *)&csio->cdb_io.cdb_bytes;
+	ata_cmd->opcode = ATA_PASS_16;
+	ata_cmd->protocol = protocol;
+	ata_cmd->flags = ata_flags;
+	ata_cmd->features_ext = features >> 8;
+	ata_cmd->features = features;
+	ata_cmd->sector_count_ext = sector_count >> 8;
+	ata_cmd->sector_count = sector_count;
+	ata_cmd->lba_low = lba;
+	ata_cmd->lba_mid = lba >> 8;
+	ata_cmd->lba_high = lba >> 16;
+	ata_cmd->device = ATA_DEV_LBA;
+	if (protocol & AP_EXTEND) {
+		ata_cmd->lba_low_ext = lba >> 24;
+		ata_cmd->lba_mid_ext = lba >> 32;
+		ata_cmd->lba_high_ext = lba >> 40;
+	} else
+		ata_cmd->device |= (lba >> 24) & 0x0f;
+	ata_cmd->command = command;
+	ata_cmd->control = control;
+
+	cam_fill_csio(csio,
+		      retries,
+		      cbfcnp,
+		      flags,
+		      tag_action,
+		      data_ptr,
+		      dxfer_len,
+		      sense_len,
+		      sizeof(*ata_cmd),
+		      timeout);
+}
+
+void
 scsi_unmap(struct ccb_scsiio *csio, u_int32_t retries,
 	   void (*cbfcnp)(struct cam_periph *, union ccb *),
 	   u_int8_t tag_action, u_int8_t byte2,

Modified: stable/8/sys/cam/scsi/scsi_all.h
==============================================================================
--- stable/8/sys/cam/scsi/scsi_all.h	Thu Jun  6 10:06:32 2013	(r251462)
+++ stable/8/sys/cam/scsi/scsi_all.h	Thu Jun  6 10:09:20 2013	(r251463)
@@ -562,6 +562,19 @@ struct scsi_start_stop_unit
 struct ata_pass_12 {
 	u_int8_t opcode;
 	u_int8_t protocol;
+#define	AP_PROTO_HARD_RESET	(0x00 << 1)
+#define	AP_PROTO_SRST		(0x01 << 1)
+#define	AP_PROTO_NON_DATA	(0x03 << 1)
+#define	AP_PROTO_PIO_IN		(0x04 << 1)
+#define	AP_PROTO_PIO_OUT	(0x05 << 1)
+#define	AP_PROTO_DMA		(0x06 << 1)
+#define	AP_PROTO_DMA_QUEUED	(0x07 << 1)
+#define	AP_PROTO_DEVICE_DIAG	(0x08 << 1)
+#define	AP_PROTO_DEVICE_RESET	(0x09 << 1)
+#define	AP_PROTO_UDMA_IN	(0x10 << 1)
+#define	AP_PROTO_UDMA_OUT	(0x11 << 1)
+#define	AP_PROTO_FPDMA		(0x12 << 1)
+#define	AP_PROTO_RESP_INFO	(0x15 << 1)
 #define	AP_MULTI	0xe0
 	u_int8_t flags;
 #define	AP_T_LEN	0x03
@@ -585,6 +598,15 @@ struct ata_pass_16 {
 	u_int8_t protocol;
 #define	AP_EXTEND	0x01
 	u_int8_t flags;
+#define	AP_FLAG_TLEN_NO_DATA	(0 << 0)
+#define	AP_FLAG_TLEN_FEAT	(1 << 0)
+#define	AP_FLAG_TLEN_SECT_CNT	(2 << 0)
+#define	AP_FLAG_TLEN_STPSIU	(3 << 0)
+#define	AP_FLAG_BYT_BLOK_BYTES	(0 << 2)  
+#define	AP_FLAG_BYT_BLOK_BLOCKS	(1 << 2)  
+#define	AP_FLAG_TDIR_TO_DEV	(0 << 3)  
+#define	AP_FLAG_TDIR_FROM_DEV	(1 << 3)  
+#define	AP_FLAG_CHK_COND	(1 << 5)  
 	u_int8_t features_ext;
 	u_int8_t features;
 	u_int8_t sector_count_ext;
@@ -697,7 +719,7 @@ struct ata_pass_16 {
 
 /*
  * This length is the initial inquiry length used by the probe code, as    
- * well as the legnth necessary for scsi_print_inquiry() to function 
+ * well as the length necessary for scsi_print_inquiry() to function 
  * correctly.  If either use requires a different length in the future, 
  * the two values should be de-coupled.
  */
@@ -1333,6 +1355,14 @@ void scsi_write_same(struct ccb_scsiio *
 		     u_int32_t dxfer_len, u_int8_t sense_len,
 		     u_int32_t timeout);
 
+void scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries,
+		      void (*cbfcnp)(struct cam_periph *, union ccb *),
+		      u_int32_t flags, u_int8_t tag_action,
+		      u_int8_t protocol, u_int8_t ata_flags, u_int16_t features,
+		      u_int16_t sector_count, uint64_t lba, u_int8_t command,
+		      u_int8_t control, u_int8_t *data_ptr, u_int16_t dxfer_len,
+		      u_int8_t sense_len, u_int32_t timeout);
+
 void scsi_unmap(struct ccb_scsiio *csio, u_int32_t retries,
 		void (*cbfcnp)(struct cam_periph *, union ccb *),
 		u_int8_t tag_action, u_int8_t byte2,


More information about the svn-src-stable-8 mailing list