summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2013-04-06 15:02:06 +0000
committermarius <marius@FreeBSD.org>2013-04-06 15:02:06 +0000
commitc7ee72f2d4a37a864126c1362b8eb28d1a5b0aba (patch)
tree159d78b97e2c9ff76f6c657c7f0bd043c0e9806c /sys/dev/ata
parentebdd865675e631940a1476531762707924a149b7 (diff)
downloadFreeBSD-src-c7ee72f2d4a37a864126c1362b8eb28d1a5b0aba.zip
FreeBSD-src-c7ee72f2d4a37a864126c1362b8eb28d1a5b0aba.tar.gz
- 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 so we can get rid of the former. - Add some missing prototypes. MFC after: 3 days
Diffstat (limited to 'sys/dev/ata')
-rw-r--r--sys/dev/ata/ata-all.c154
-rw-r--r--sys/dev/ata/ata-all.h6
-rw-r--r--sys/dev/ata/ata-lowlevel.c2
-rw-r--r--sys/dev/ata/ata-queue.c186
4 files changed, 153 insertions, 195 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c
index 8ca1cc4..6367fff 100644
--- a/sys/dev/ata/ata-all.c
+++ b/sys/dev/ata/ata-all.c
@@ -60,9 +60,17 @@ __FBSDID("$FreeBSD$");
/* prototypes */
static void ataaction(struct cam_sim *sim, union ccb *ccb);
static void atapoll(struct cam_sim *sim);
-static void ata_conn_event(void *, int);
+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_conn_event(void *context, int dummy);
+static void ata_init(void);
static void ata_interrupt_locked(void *data);
+static int ata_module_event_handler(module_t mod, int what, void *arg);
static void ata_periodic_poll(void *data);
+static int ata_str2mode(const char *str);
+static void ata_uninit(void);
/* global vars */
MALLOC_DEFINE(M_ATA, "ata_generic", "ATA driver generic layer");
@@ -435,6 +443,120 @@ ata_udelay(int interval)
}
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) {
@@ -464,7 +586,7 @@ ata_mode2str(int mode)
}
}
-int
+static int
ata_str2mode(const char *str)
{
@@ -501,6 +623,32 @@ ata_atapi(device_t dev, int target)
return (ch->devices & (ATA_ATAPI_MASTER << target));
}
+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() 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;
+ ata_cam_end_transaction(ch->dev, request);
+ }
+ mtx_unlock(&ch->state_mtx);
+}
+
static void
ata_cam_begin_transaction(device_t dev, union ccb *ccb)
{
@@ -658,7 +806,7 @@ ata_cam_process_sense(device_t dev, struct ata_request *request)
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);
diff --git a/sys/dev/ata/ata-all.h b/sys/dev/ata/ata-all.h
index cb2ae2f..9f0d611 100644
--- a/sys/dev/ata/ata-all.h
+++ b/sys/dev/ata/ata-all.h
@@ -613,16 +613,12 @@ void ata_interrupt(void *data);
int ata_getparam(struct ata_device *atadev, int init);
void ata_default_registers(device_t dev);
void ata_udelay(int interval);
+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);
int ata_atapi(device_t dev, int target);
-void ata_cam_end_transaction(device_t dev, struct ata_request *request);
-
-/* ata-queue.c: */
void ata_timeout(struct ata_request *);
-const char *ata_cmd2str(struct ata_request *request);
/* ata-lowlevel.c: */
void ata_generic_hw(device_t dev);
diff --git a/sys/dev/ata/ata-lowlevel.c b/sys/dev/ata/ata-lowlevel.c
index 4d526ca..53506a0 100644
--- a/sys/dev/ata/ata-lowlevel.c
+++ b/sys/dev/ata/ata-lowlevel.c
@@ -604,7 +604,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);
diff --git a/sys/dev/ata/ata-queue.c b/sys/dev/ata/ata-queue.c
deleted file mode 100644
index 30a8b7c7..0000000
--- a/sys/dev/ata/ata-queue.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*-
- * Copyright (c) 1998 - 2008 Søren Schmidt <sos@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "opt_ata.h"
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/ata.h>
-#include <sys/kernel.h>
-#include <sys/bio.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/sema.h>
-#include <sys/taskqueue.h>
-#include <vm/uma.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <dev/ata/ata-all.h>
-#include <ata_if.h>
-
-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;
- ata_cam_end_transaction(ch->dev, request);
- mtx_unlock(&ch->state_mtx);
- }
- else {
- mtx_unlock(&ch->state_mtx);
- }
-}
-
-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;
-}
OpenPOWER on IntegriCloud