svn commit: r251224 - stable/9/sys/dev/ata

Marius Strobl marius at FreeBSD.org
Sat Jun 1 13:10:26 UTC 2013


Author: marius
Date: Sat Jun  1 13:10:24 2013
New Revision: 251224
URL: http://svnweb.freebsd.org/changeset/base/251224

Log:
  MFC: r249203 (partial)
  
  - Make ata_str2mode() static, it's not used outside of ata-all.c.
  - Move ata_timeout() to ata-all.c so we don't need to expose both this
    function and ata_cam_end_transaction() but only the former.
  - Move ata_cmd2str() from ata-queue.c to ata-all.c.
  - Add some missing prototypes.

Modified:
  stable/9/sys/dev/ata/ata-all.c
  stable/9/sys/dev/ata/ata-all.h
  stable/9/sys/dev/ata/ata-lowlevel.c
  stable/9/sys/dev/ata/ata-queue.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/ata/ata-all.c
==============================================================================
--- stable/9/sys/dev/ata/ata-all.c	Sat Jun  1 12:27:48 2013	(r251223)
+++ stable/9/sys/dev/ata/ata-all.c	Sat Jun  1 13:10:24 2013	(r251224)
@@ -72,22 +72,26 @@ static struct cdevsw ata_cdevsw = {
 
 /* prototypes */
 #ifndef ATA_CAM
+static void bswap(int8_t *, int);
+static void btrim(int8_t *, int);
+static void bpack(int8_t *, int8_t *, int);
 static void ata_boot_attach(void);
 static device_t ata_add_child(device_t, struct ata_device *, int);
 #else
 static void ataaction(struct cam_sim *sim, union ccb *ccb);
 static void atapoll(struct cam_sim *sim);
+static void ata_cam_begin_transaction(device_t dev, union ccb *ccb);
+static void ata_cam_end_transaction(device_t dev, struct ata_request *request);
+static void ata_cam_request_sense(device_t dev, struct ata_request *request);
+static int ata_check_ids(device_t dev, union ccb *ccb);
+static void ata_periodic_poll(void *data);
 #endif
 static void ata_conn_event(void *, int);
-#ifndef ATA_CAM
-static void bswap(int8_t *, int);
-static void btrim(int8_t *, int);
-static void bpack(int8_t *, int8_t *, int);
-#endif
+static void ata_init(void);
 static void ata_interrupt_locked(void *data);
-#ifdef ATA_CAM
-static void ata_periodic_poll(void *data);
-#endif
+static int ata_module_event_handler(module_t mod, int what, void *arg);
+static int ata_str2mode(const char *str);
+static void ata_uninit(void);
 
 /* global vars */
 MALLOC_DEFINE(M_ATA, "ata_generic", "ATA driver generic layer");
@@ -1246,6 +1250,120 @@ ata_unit2str(struct ata_device *atadev)
 #endif
 
 const char *
+ata_cmd2str(struct ata_request *request)
+{
+	static char buffer[20];
+
+	if (request->flags & ATA_R_ATAPI) {
+		switch (request->u.atapi.sense.key ?
+		    request->u.atapi.saved_cmd : request->u.atapi.ccb[0]) {
+		case 0x00: return ("TEST_UNIT_READY");
+		case 0x01: return ("REZERO");
+		case 0x03: return ("REQUEST_SENSE");
+		case 0x04: return ("FORMAT");
+		case 0x08: return ("READ");
+		case 0x0a: return ("WRITE");
+		case 0x10: return ("WEOF");
+		case 0x11: return ("SPACE");
+		case 0x12: return ("INQUIRY");
+		case 0x15: return ("MODE_SELECT");
+		case 0x19: return ("ERASE");
+		case 0x1a: return ("MODE_SENSE");
+		case 0x1b: return ("START_STOP");
+		case 0x1e: return ("PREVENT_ALLOW");
+		case 0x23: return ("ATAPI_READ_FORMAT_CAPACITIES");
+		case 0x25: return ("READ_CAPACITY");
+		case 0x28: return ("READ_BIG");
+		case 0x2a: return ("WRITE_BIG");
+		case 0x2b: return ("LOCATE");
+		case 0x34: return ("READ_POSITION");
+		case 0x35: return ("SYNCHRONIZE_CACHE");
+		case 0x3b: return ("WRITE_BUFFER");
+		case 0x3c: return ("READ_BUFFER");
+		case 0x42: return ("READ_SUBCHANNEL");
+		case 0x43: return ("READ_TOC");
+		case 0x45: return ("PLAY_10");
+		case 0x47: return ("PLAY_MSF");
+		case 0x48: return ("PLAY_TRACK");
+		case 0x4b: return ("PAUSE");
+		case 0x51: return ("READ_DISK_INFO");
+		case 0x52: return ("READ_TRACK_INFO");
+		case 0x53: return ("RESERVE_TRACK");
+		case 0x54: return ("SEND_OPC_INFO");
+		case 0x55: return ("MODE_SELECT_BIG");
+		case 0x58: return ("REPAIR_TRACK");
+		case 0x59: return ("READ_MASTER_CUE");
+		case 0x5a: return ("MODE_SENSE_BIG");
+		case 0x5b: return ("CLOSE_TRACK/SESSION");
+		case 0x5c: return ("READ_BUFFER_CAPACITY");
+		case 0x5d: return ("SEND_CUE_SHEET");
+		case 0x96: return ("SERVICE_ACTION_IN");
+		case 0xa1: return ("BLANK_CMD");
+		case 0xa3: return ("SEND_KEY");
+		case 0xa4: return ("REPORT_KEY");
+		case 0xa5: return ("PLAY_12");
+		case 0xa6: return ("LOAD_UNLOAD");
+		case 0xad: return ("READ_DVD_STRUCTURE");
+		case 0xb4: return ("PLAY_CD");
+		case 0xbb: return ("SET_SPEED");
+		case 0xbd: return ("MECH_STATUS");
+		case 0xbe: return ("READ_CD");
+		case 0xff: return ("POLL_DSC");
+		}
+	} else {
+		switch (request->u.ata.command) {
+		case 0x00: return ("NOP");
+		case 0x08: return ("DEVICE_RESET");
+		case 0x20: return ("READ");
+		case 0x24: return ("READ48");
+		case 0x25: return ("READ_DMA48");
+		case 0x26: return ("READ_DMA_QUEUED48");
+		case 0x27: return ("READ_NATIVE_MAX_ADDRESS48");
+		case 0x29: return ("READ_MUL48");
+		case 0x30: return ("WRITE");
+		case 0x34: return ("WRITE48");
+		case 0x35: return ("WRITE_DMA48");
+		case 0x36: return ("WRITE_DMA_QUEUED48");
+		case 0x37: return ("SET_MAX_ADDRESS48");
+		case 0x39: return ("WRITE_MUL48");
+		case 0x70: return ("SEEK");
+		case 0xa0: return ("PACKET_CMD");
+		case 0xa1: return ("ATAPI_IDENTIFY");
+		case 0xa2: return ("SERVICE");
+		case 0xb0: return ("SMART");
+		case 0xc0: return ("CFA ERASE");
+		case 0xc4: return ("READ_MUL");
+		case 0xc5: return ("WRITE_MUL");
+		case 0xc6: return ("SET_MULTI");
+		case 0xc7: return ("READ_DMA_QUEUED");
+		case 0xc8: return ("READ_DMA");
+		case 0xca: return ("WRITE_DMA");
+		case 0xcc: return ("WRITE_DMA_QUEUED");
+		case 0xe6: return ("SLEEP");
+		case 0xe7: return ("FLUSHCACHE");
+		case 0xea: return ("FLUSHCACHE48");
+		case 0xec: return ("ATA_IDENTIFY");
+		case 0xef:
+			switch (request->u.ata.feature) {
+			case 0x03: return ("SETFEATURES SET TRANSFER MODE");
+			case 0x02: return ("SETFEATURES ENABLE WCACHE");
+			case 0x82: return ("SETFEATURES DISABLE WCACHE");
+			case 0xaa: return ("SETFEATURES ENABLE RCACHE");
+			case 0x55: return ("SETFEATURES DISABLE RCACHE");
+			}
+			sprintf(buffer, "SETFEATURES 0x%02x",
+			    request->u.ata.feature);
+			return (buffer);
+		case 0xf5: return ("SECURITY_FREE_LOCK");
+		case 0xf8: return ("READ_NATIVE_MAX_ADDRESS");
+		case 0xf9: return ("SET_MAX_ADDRESS");
+		}
+	}
+	sprintf(buffer, "unknown CMD (0x%02x)", request->u.ata.command);
+	return (buffer);
+}
+
+const char *
 ata_mode2str(int mode)
 {
     switch (mode) {
@@ -1275,7 +1393,7 @@ ata_mode2str(int mode)
     }
 }
 
-int
+static int
 ata_str2mode(const char *str)
 {
 
@@ -1463,6 +1581,40 @@ bpack(int8_t *src, int8_t *dst, int len)
 }
 #endif
 
+void
+ata_timeout(struct ata_request *request)
+{
+	struct ata_channel *ch;
+
+	ch = device_get_softc(request->parent);
+	//request->flags |= ATA_R_DEBUG;
+	ATA_DEBUG_RQ(request, "timeout");
+
+	/*
+	 * If we have an ATA_ACTIVE request running, we flag the request
+	 * ATA_R_TIMEOUT so ata_cam_end_transaction()/ata_finish() will handle
+	 * it correctly.
+	 * Also, NULL out the running request so we wont loose the race with
+	 * an eventual interrupt arriving late.
+	 */
+	if (ch->state == ATA_ACTIVE) {
+		request->flags |= ATA_R_TIMEOUT;
+		if (ch->dma.unload)
+			ch->dma.unload(request);
+		ch->running = NULL;
+		ch->state = ATA_IDLE;
+#ifdef ATA_CAM
+		ata_cam_end_transaction(ch->dev, request);
+#endif
+		mtx_unlock(&ch->state_mtx);
+#ifndef ATA_CAM
+		ATA_LOCKING(ch->dev, ATA_LF_UNLOCK);
+		ata_finish(request);
+#endif
+	} else
+		mtx_unlock(&ch->state_mtx);
+}
+
 #ifdef ATA_CAM
 static void
 ata_cam_begin_transaction(device_t dev, union ccb *ccb)
@@ -1620,7 +1772,7 @@ ata_cam_process_sense(device_t dev, stru
 		ata_reinit(dev);
 }
 
-void
+static void
 ata_cam_end_transaction(device_t dev, struct ata_request *request)
 {
 	struct ata_channel *ch = device_get_softc(dev);

Modified: stable/9/sys/dev/ata/ata-all.h
==============================================================================
--- stable/9/sys/dev/ata/ata-all.h	Sat Jun  1 12:27:48 2013	(r251223)
+++ stable/9/sys/dev/ata/ata-all.h	Sat Jun  1 13:10:24 2013	(r251224)
@@ -625,12 +625,13 @@ int ata_getparam(struct ata_device *atad
 void ata_default_registers(device_t dev);
 void ata_udelay(int interval);
 const char *ata_unit2str(struct ata_device *atadev);
+const char *ata_cmd2str(struct ata_request *request);
 const char *ata_mode2str(int mode);
 void ata_setmode(device_t dev);
 void ata_print_cable(device_t dev, u_int8_t *who);
-int ata_str2mode(const char *str);
 const char *ata_satarev2str(int rev);
 int ata_atapi(device_t dev, int target);
+void ata_timeout(struct ata_request *);
 #ifndef ATA_CAM
 int ata_identify(device_t dev);
 void ata_modify_if_48bit(struct ata_request *request);
@@ -639,8 +640,6 @@ int ata_wmode(struct ata_params *ap);
 int ata_umode(struct ata_params *ap);
 int ata_limit_mode(device_t dev, int mode, int maxmode);
 int ata_check_80pin(device_t dev, int mode);
-#else
-void ata_cam_end_transaction(device_t dev, struct ata_request *request);
 #endif
 
 /* ata-queue.c: */
@@ -649,11 +648,9 @@ int ata_atapicmd(device_t dev, u_int8_t 
 void ata_queue_request(struct ata_request *request);
 void ata_start(device_t dev);
 void ata_finish(struct ata_request *request);
-void ata_timeout(struct ata_request *);
 void ata_catch_inflight(device_t dev);
 void ata_fail_requests(device_t dev);
 void ata_drop_requests(device_t dev);
-const char *ata_cmd2str(struct ata_request *request);
 
 /* ata-lowlevel.c: */
 void ata_generic_hw(device_t dev);

Modified: stable/9/sys/dev/ata/ata-lowlevel.c
==============================================================================
--- stable/9/sys/dev/ata/ata-lowlevel.c	Sat Jun  1 12:27:48 2013	(r251223)
+++ stable/9/sys/dev/ata/ata-lowlevel.c	Sat Jun  1 13:10:24 2013	(r251224)
@@ -605,7 +605,7 @@ ata_generic_reset(device_t dev)
 }
 
 /* must be called with ATA channel locked and state_mtx held */
-int
+static int
 ata_generic_status(device_t dev)
 {
     struct ata_channel *ch = device_get_softc(dev);

Modified: stable/9/sys/dev/ata/ata-queue.c
==============================================================================
--- stable/9/sys/dev/ata/ata-queue.c	Sat Jun  1 12:27:48 2013	(r251223)
+++ stable/9/sys/dev/ata/ata-queue.c	Sat Jun  1 13:10:24 2013	(r251224)
@@ -510,40 +510,6 @@ ata_completed(void *context, int dummy)
 }
 #endif
 
-void
-ata_timeout(struct ata_request *request)
-{
-    struct ata_channel *ch = device_get_softc(request->parent);
-
-    //request->flags |= ATA_R_DEBUG;
-    ATA_DEBUG_RQ(request, "timeout");
-
-    /*
-     * if we have an ATA_ACTIVE request running, we flag the request 
-     * ATA_R_TIMEOUT so ata_finish will handle it correctly
-     * also NULL out the running request so we wont loose 
-     * the race with an eventual interrupt arriving late
-     */
-    if (ch->state == ATA_ACTIVE) {
-	request->flags |= ATA_R_TIMEOUT;
-	if (ch->dma.unload)
-	    ch->dma.unload(request);
-	ch->running = NULL;
-	ch->state = ATA_IDLE;
-#ifdef ATA_CAM
-	ata_cam_end_transaction(ch->dev, request);
-#endif
-	mtx_unlock(&ch->state_mtx);
-#ifndef ATA_CAM
-	ATA_LOCKING(ch->dev, ATA_LF_UNLOCK);
-	ata_finish(request);
-#endif
-    }
-    else {
-	mtx_unlock(&ch->state_mtx);
-    }
-}
-
 #ifndef ATA_CAM
 void
 ata_fail_requests(device_t dev)
@@ -684,120 +650,6 @@ ata_sort_queue(struct ata_channel *ch, s
 }
 #endif
 
-const char *
-ata_cmd2str(struct ata_request *request)
-{
-    static char buffer[20];
-
-    if (request->flags & ATA_R_ATAPI) {
-	switch (request->u.atapi.sense.key ?
-		request->u.atapi.saved_cmd : request->u.atapi.ccb[0]) {
-	case 0x00: return ("TEST_UNIT_READY");
-	case 0x01: return ("REZERO");
-	case 0x03: return ("REQUEST_SENSE");
-	case 0x04: return ("FORMAT");
-	case 0x08: return ("READ");
-	case 0x0a: return ("WRITE");
-	case 0x10: return ("WEOF");
-	case 0x11: return ("SPACE");
-	case 0x12: return ("INQUIRY");
-	case 0x15: return ("MODE_SELECT");
-	case 0x19: return ("ERASE");
-	case 0x1a: return ("MODE_SENSE");
-	case 0x1b: return ("START_STOP");
-	case 0x1e: return ("PREVENT_ALLOW");
-	case 0x23: return ("ATAPI_READ_FORMAT_CAPACITIES");
-	case 0x25: return ("READ_CAPACITY");
-	case 0x28: return ("READ_BIG");
-	case 0x2a: return ("WRITE_BIG");
-	case 0x2b: return ("LOCATE");
-	case 0x34: return ("READ_POSITION");
-	case 0x35: return ("SYNCHRONIZE_CACHE");
-	case 0x3b: return ("WRITE_BUFFER");
-	case 0x3c: return ("READ_BUFFER");
-	case 0x42: return ("READ_SUBCHANNEL");
-	case 0x43: return ("READ_TOC");
-	case 0x45: return ("PLAY_10");
-	case 0x47: return ("PLAY_MSF");
-	case 0x48: return ("PLAY_TRACK");
-	case 0x4b: return ("PAUSE");
-	case 0x51: return ("READ_DISK_INFO");
-	case 0x52: return ("READ_TRACK_INFO");
-	case 0x53: return ("RESERVE_TRACK");
-	case 0x54: return ("SEND_OPC_INFO");
-	case 0x55: return ("MODE_SELECT_BIG");
-	case 0x58: return ("REPAIR_TRACK");
-	case 0x59: return ("READ_MASTER_CUE");
-	case 0x5a: return ("MODE_SENSE_BIG");
-	case 0x5b: return ("CLOSE_TRACK/SESSION");
-	case 0x5c: return ("READ_BUFFER_CAPACITY");
-	case 0x5d: return ("SEND_CUE_SHEET");
-        case 0x96: return ("SERVICE_ACTION_IN");
-	case 0xa1: return ("BLANK_CMD");
-	case 0xa3: return ("SEND_KEY");
-	case 0xa4: return ("REPORT_KEY");
-	case 0xa5: return ("PLAY_12");
-	case 0xa6: return ("LOAD_UNLOAD");
-	case 0xad: return ("READ_DVD_STRUCTURE");
-	case 0xb4: return ("PLAY_CD");
-	case 0xbb: return ("SET_SPEED");
-	case 0xbd: return ("MECH_STATUS");
-	case 0xbe: return ("READ_CD");
-	case 0xff: return ("POLL_DSC");
-	}
-    }
-    else {
-	switch (request->u.ata.command) {
-	case 0x00: return ("NOP");
-	case 0x08: return ("DEVICE_RESET");
-	case 0x20: return ("READ");
-	case 0x24: return ("READ48");
-	case 0x25: return ("READ_DMA48");
-	case 0x26: return ("READ_DMA_QUEUED48");
-	case 0x27: return ("READ_NATIVE_MAX_ADDRESS48");
-	case 0x29: return ("READ_MUL48");
-	case 0x30: return ("WRITE");
-	case 0x34: return ("WRITE48");
-	case 0x35: return ("WRITE_DMA48");
-	case 0x36: return ("WRITE_DMA_QUEUED48");
-	case 0x37: return ("SET_MAX_ADDRESS48");
-	case 0x39: return ("WRITE_MUL48");
-	case 0x70: return ("SEEK");
-	case 0xa0: return ("PACKET_CMD");
-	case 0xa1: return ("ATAPI_IDENTIFY");
-	case 0xa2: return ("SERVICE");
-	case 0xb0: return ("SMART");
-	case 0xc0: return ("CFA ERASE");
-	case 0xc4: return ("READ_MUL");
-	case 0xc5: return ("WRITE_MUL");
-	case 0xc6: return ("SET_MULTI");
-	case 0xc7: return ("READ_DMA_QUEUED");
-	case 0xc8: return ("READ_DMA");
-	case 0xca: return ("WRITE_DMA");
-	case 0xcc: return ("WRITE_DMA_QUEUED");
-	case 0xe6: return ("SLEEP");
-	case 0xe7: return ("FLUSHCACHE");
-	case 0xea: return ("FLUSHCACHE48");
-	case 0xec: return ("ATA_IDENTIFY");
-	case 0xef:
-	    switch (request->u.ata.feature) {
-	    case 0x03: return ("SETFEATURES SET TRANSFER MODE");
-	    case 0x02: return ("SETFEATURES ENABLE WCACHE");
-	    case 0x82: return ("SETFEATURES DISABLE WCACHE");
-	    case 0xaa: return ("SETFEATURES ENABLE RCACHE");
-	    case 0x55: return ("SETFEATURES DISABLE RCACHE");
-	    }
-	    sprintf(buffer, "SETFEATURES 0x%02x", request->u.ata.feature);
-	    return buffer;
-	case 0xf5: return ("SECURITY_FREE_LOCK");
-	case 0xf8: return ("READ_NATIVE_MAX_ADDRESS");
-	case 0xf9: return ("SET_MAX_ADDRESS");
-	}
-    }
-    sprintf(buffer, "unknown CMD (0x%02x)", request->u.ata.command);
-    return buffer;
-}
-
 #ifndef ATA_CAM
 static const char *
 ata_skey2str(u_int8_t skey)


More information about the svn-src-all mailing list