Take newbusification one step further, ie use the device_t more consequently

all way through the code down the layers, instead of the mix'n'match that
resulted from the conversion done earlier.

Sponsored by:	pair.com
This commit is contained in:
Søren Schmidt 2005-04-30 16:22:07 +00:00
parent a4f4bae7f5
commit 0068f98f88
19 changed files with 592 additions and 574 deletions

View File

@ -231,7 +231,7 @@ ata_reinit(device_t dev)
}
/* catch request in ch->running if we havn't already */
ata_catch_inflight(ch);
ata_catch_inflight(dev);
/* we're done release the channel for new work */
mtx_lock(&ch->state_mtx);
@ -659,7 +659,7 @@ ata_getparam(device_t parent, struct ata_device *atadev)
ata_umode(&atadev->param) >= ATA_UDMA2)
atadev->mode = ATA_DMA_MAX;
}
else {
else {
if (ata_dma && ch->dma)
atadev->mode = ATA_DMA_MAX;
}
@ -680,21 +680,21 @@ ata_identify(device_t dev)
int master_unit = -1, slave_unit = -1;
if (ch->devices & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) {
if (!(master = malloc(sizeof(struct ata_device),
if (!(master = malloc(sizeof(struct ata_device),
M_ATA, M_NOWAIT | M_ZERO))) {
device_printf(dev, "out of memory\n");
return ENOMEM;
}
master->unit = ATA_MASTER;
}
master->unit = ATA_MASTER;
}
if (ch->devices & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) {
if (!(slave = malloc(sizeof(struct ata_device),
if (!(slave = malloc(sizeof(struct ata_device),
M_ATA, M_NOWAIT | M_ZERO))) {
free(master, M_ATA);
device_printf(dev, "out of memory\n");
return ENOMEM;
}
slave->unit = ATA_SLAVE;
}
slave->unit = ATA_SLAVE;
}
#ifdef ATA_STATIC_ID
@ -729,8 +729,10 @@ ata_identify(device_t dev)
}
void
ata_default_registers(struct ata_channel *ch)
ata_default_registers(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
/* fill in the defaults from whats setup already */
ch->r_io[ATA_ERROR].res = ch->r_io[ATA_FEATURE].res;
ch->r_io[ATA_ERROR].offset = ch->r_io[ATA_FEATURE].offset;
@ -839,8 +841,10 @@ ata_umode(struct ata_params *ap)
}
int
ata_limit_mode(struct ata_device *atadev, int mode, int maxmode)
ata_limit_mode(device_t dev, int mode, int maxmode)
{
struct ata_device *atadev = device_get_softc(dev);
if (maxmode && mode > maxmode)
mode = maxmode;
@ -950,8 +954,8 @@ ata_init(void)
ata_request_zone = uma_zcreate("ata_request", sizeof(struct ata_request),
NULL, NULL, NULL, NULL, 0, 0);
ata_composite_zone = uma_zcreate("ata_composite",
sizeof(struct ata_composite),
NULL, NULL, NULL, NULL, 0, 0);
sizeof(struct ata_composite),
NULL, NULL, NULL, NULL, 0, 0);
}
SYSINIT(ata_register, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_init, NULL);

View File

@ -104,64 +104,64 @@
#define ATA_A_HOB 0x80 /* High Order Byte enable */
/* SATA register defines */
#define ATA_SSTATUS 13
#define ATA_SS_DET_MASK 0x0000000f
#define ATA_SS_DET_NO_DEVICE 0x00000000
#define ATA_SS_DET_DEV_PRESENT 0x00000001
#define ATA_SS_DET_PHY_ONLINE 0x00000003
#define ATA_SS_DET_PHY_OFFLINE 0x00000004
#define ATA_SSTATUS 13
#define ATA_SS_DET_MASK 0x0000000f
#define ATA_SS_DET_NO_DEVICE 0x00000000
#define ATA_SS_DET_DEV_PRESENT 0x00000001
#define ATA_SS_DET_PHY_ONLINE 0x00000003
#define ATA_SS_DET_PHY_OFFLINE 0x00000004
#define ATA_SS_SPD_MASK 0x000000f0
#define ATA_SS_SPD_NO_SPEED 0x00000000
#define ATA_SS_SPD_GEN1 0x00000010
#define ATA_SS_SPD_GEN2 0x00000020
#define ATA_SS_SPD_MASK 0x000000f0
#define ATA_SS_SPD_NO_SPEED 0x00000000
#define ATA_SS_SPD_GEN1 0x00000010
#define ATA_SS_SPD_GEN2 0x00000020
#define ATA_SS_IPM_MASK 0x00000f00
#define ATA_SS_IPM_NO_DEVICE 0x00000000
#define ATA_SS_IPM_ACTIVE 0x00000100
#define ATA_SS_IPM_PARTIAL 0x00000200
#define ATA_SS_IPM_SLUMBER 0x00000600
#define ATA_SS_IPM_MASK 0x00000f00
#define ATA_SS_IPM_NO_DEVICE 0x00000000
#define ATA_SS_IPM_ACTIVE 0x00000100
#define ATA_SS_IPM_PARTIAL 0x00000200
#define ATA_SS_IPM_SLUMBER 0x00000600
#define ATA_SS_CONWELL_MASK \
#define ATA_SS_CONWELL_MASK \
(ATA_SS_DET_MASK|ATA_SS_SPD_MASK|ATA_SS_IPM_MASK)
#define ATA_SS_CONWELL_GEN1 \
#define ATA_SS_CONWELL_GEN1 \
(ATA_SS_DET_PHY_ONLINE|ATA_SS_SPD_GEN1|ATA_SS_IPM_ACTIVE)
#define ATA_SS_CONWELL_GEN2 \
#define ATA_SS_CONWELL_GEN2 \
(ATA_SS_DET_PHY_ONLINE|ATA_SS_SPD_GEN2|ATA_SS_IPM_ACTIVE)
#define ATA_SERROR 14
#define ATA_SE_DATA_CORRECTED 0x00000001
#define ATA_SE_COMM_CORRECTED 0x00000002
#define ATA_SE_DATA_ERR 0x00000100
#define ATA_SE_COMM_ERR 0x00000200
#define ATA_SE_PROT_ERR 0x00000400
#define ATA_SE_HOST_ERR 0x00000800
#define ATA_SE_PHY_CHANGED 0x00010000
#define ATA_SE_PHY_IERROR 0x00020000
#define ATA_SE_COMM_WAKE 0x00040000
#define ATA_SE_DECODE_ERR 0x00080000
#define ATA_SE_PARITY_ERR 0x00100000
#define ATA_SE_CRC_ERR 0x00200000
#define ATA_SE_HANDSHAKE_ERR 0x00400000
#define ATA_SE_LINKSEQ_ERR 0x00800000
#define ATA_SE_TRANSPORT_ERR 0x01000000
#define ATA_SE_UNKNOWN_FIS 0x02000000
#define ATA_SERROR 14
#define ATA_SE_DATA_CORRECTED 0x00000001
#define ATA_SE_COMM_CORRECTED 0x00000002
#define ATA_SE_DATA_ERR 0x00000100
#define ATA_SE_COMM_ERR 0x00000200
#define ATA_SE_PROT_ERR 0x00000400
#define ATA_SE_HOST_ERR 0x00000800
#define ATA_SE_PHY_CHANGED 0x00010000
#define ATA_SE_PHY_IERROR 0x00020000
#define ATA_SE_COMM_WAKE 0x00040000
#define ATA_SE_DECODE_ERR 0x00080000
#define ATA_SE_PARITY_ERR 0x00100000
#define ATA_SE_CRC_ERR 0x00200000
#define ATA_SE_HANDSHAKE_ERR 0x00400000
#define ATA_SE_LINKSEQ_ERR 0x00800000
#define ATA_SE_TRANSPORT_ERR 0x01000000
#define ATA_SE_UNKNOWN_FIS 0x02000000
#define ATA_SCONTROL 15
#define ATA_SC_DET_MASK 0x0000000f
#define ATA_SC_DET_IDLE 0x00000000
#define ATA_SC_DET_RESET 0x00000001
#define ATA_SC_DET_DISABLE 0x00000004
#define ATA_SCONTROL 15
#define ATA_SC_DET_MASK 0x0000000f
#define ATA_SC_DET_IDLE 0x00000000
#define ATA_SC_DET_RESET 0x00000001
#define ATA_SC_DET_DISABLE 0x00000004
#define ATA_SC_SPD_MASK 0x000000f0
#define ATA_SC_SPD_NO_SPEED 0x00000000
#define ATA_SC_SPD_SPEED_GEN1 0x00000010
#define ATA_SC_SPD_SPEED_GEN2 0x00000020
#define ATA_SC_SPD_MASK 0x000000f0
#define ATA_SC_SPD_NO_SPEED 0x00000000
#define ATA_SC_SPD_SPEED_GEN1 0x00000010
#define ATA_SC_SPD_SPEED_GEN2 0x00000020
#define ATA_SC_IPM_MASK 0x00000f00
#define ATA_SC_IPM_NONE 0x00000000
#define ATA_SC_IPM_DIS_PARTIAL 0x00000100
#define ATA_SC_IPM_DIS_SLUMBER 0x00000200
#define ATA_SC_IPM_MASK 0x00000f00
#define ATA_SC_IPM_NONE 0x00000000
#define ATA_SC_IPM_DIS_PARTIAL 0x00000100
#define ATA_SC_IPM_DIS_SLUMBER 0x00000200
/* DMA register defines */
#define ATA_DMA_ENTRIES 256
@ -204,7 +204,7 @@
#define ATA_PC98_BANKADDR_RID 9
#define ATA_IRQ_RID 0
#define ATA_DEV(device) ((device == ATA_MASTER) ? 0 : 1)
#define ATA_CFA_MAGIC 0x848A
#define ATA_CFA_MAGIC 0x848A
#define ATAPI_MAGIC_LSB 0x14
#define ATAPI_MAGIC_MSB 0xeb
#define ATAPI_P_READ (ATA_S_DRQ | ATA_I_IN)
@ -374,20 +374,20 @@ struct ata_dma {
#define ATA_DMA_LOADED 0x02 /* DMA tables etc loaded */
#define ATA_DMA_ACTIVE 0x04 /* DMA transfer in progress */
void (*alloc)(struct ata_channel *ch);
void (*free)(struct ata_channel *ch);
void (*alloc)(device_t);
void (*free)(device_t);
void (*setprd)(void *xsc, bus_dma_segment_t *segs, int nsegs, int error);
int (*load)(struct ata_device *atadev, caddr_t data, int32_t count,int dir);
int (*unload)(struct ata_channel *ch);
int (*start)(struct ata_channel *ch);
int (*stop)(struct ata_channel *ch);
int (*load)(device_t, caddr_t data, int32_t count,int dir);
int (*unload)(device_t);
int (*start)(device_t);
int (*stop)(device_t);
};
/* structure holding lowlevel functions */
struct ata_lowlevel {
int (*begin_transaction)(struct ata_request *request);
int (*end_transaction)(struct ata_request *request);
int (*command)(struct ata_device *atadev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
int (*command)(device_t dev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
};
/* structure holding resources for an ATA channel */
@ -451,29 +451,29 @@ int ata_reinit(device_t dev);
int ata_suspend(device_t dev);
int ata_resume(device_t dev);
int ata_identify(device_t dev);
void ata_default_registers(struct ata_channel *ch);
void ata_default_registers(device_t dev);
void ata_udelay(int interval);
char *ata_mode2str(int mode);
int ata_pmode(struct ata_params *ap);
int ata_wmode(struct ata_params *ap);
int ata_umode(struct ata_params *ap);
int ata_limit_mode(struct ata_device *atadev, int mode, int maxmode);
int ata_limit_mode(device_t dev, int mode, int maxmode);
/* ata-queue.c: */
int ata_controlcmd(struct ata_device *atadev, u_int8_t command, u_int16_t feature, u_int64_t lba, u_int16_t count);
int ata_atapicmd(struct ata_device *atadev, u_int8_t *ccb, caddr_t data, int count, int flags, int timeout);
int ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature, u_int64_t lba, u_int16_t count);
int ata_atapicmd(device_t dev, u_int8_t *ccb, caddr_t data, int count, int flags, int timeout);
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(struct ata_channel *ch);
void ata_fail_requests(struct ata_channel *ch, device_t dev);
void ata_catch_inflight(device_t dev);
void ata_fail_requests(device_t dev);
char *ata_cmd2str(struct ata_request *request);
/* ata-lowlevel.c: */
void ata_generic_hw(struct ata_channel *ch);
void ata_generic_reset(struct ata_channel *ch);
int ata_generic_command(struct ata_device *atadev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
void ata_generic_hw(device_t dev);
void ata_generic_reset(device_t dev);
int ata_generic_command(device_t dev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
/* macros for alloc/free of struct ata_request */
extern uma_zone_t ata_request_zone;

View File

@ -126,12 +126,12 @@ ata_pccard_probe(device_t dev)
ch->r_io[ATA_CONTROL].res = ctlio;
ch->r_io[ATA_CONTROL].offset = 0;
}
ata_default_registers(ch);
ata_default_registers(dev);
/* initialize softc for this channel */
ch->unit = 0;
ch->flags |= (ATA_USE_16BIT | ATA_NO_SLAVE);
ata_generic_hw(ch);
ata_generic_hw(dev);
return ata_probe(dev);
}

View File

@ -278,11 +278,11 @@ ata_cbuschannel_probe(device_t dev)
ch->r_io[ATA_CONTROL].res = ctlr->ctlio;
ch->r_io[ATA_CONTROL].offset = 0;
ch->r_io[ATA_IDX_ADDR].res = ctlr->io;
ata_default_registers(ch);
ata_default_registers(dev);
/* initialize softc for this channel */
ch->flags |= ATA_USE_16BIT;
ata_generic_hw(ch);
ata_generic_hw(dev);
return ata_probe(dev);
}

File diff suppressed because it is too large Load Diff

View File

@ -158,7 +158,6 @@ ad_attach(device_t dev)
static int
ad_detach(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct ad_softc *adp = device_get_ivars(dev);
device_t *children;
int nchildren, i;
@ -179,7 +178,7 @@ ad_detach(device_t dev)
disk_destroy(adp->disk);
/* fail requests on the queue and any thats "in flight" for this device */
ata_fail_requests(ch, dev);
ata_fail_requests(dev);
/* dont leave anything behind */
device_set_ivars(dev, NULL);
@ -193,7 +192,7 @@ ad_shutdown(device_t dev)
struct ata_device *atadev = device_get_softc(dev);
if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
ata_controlcmd(atadev, ATA_FLUSHCACHE, 0, 0, 0);
ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
}
static int
@ -335,19 +334,19 @@ ad_init(device_t dev)
ATA_SETMODE(device_get_parent(dev), dev);
/* enable read caching */
ata_controlcmd(atadev, ATA_SETFEATURES, ATA_SF_ENAB_RCACHE, 0, 0);
ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_ENAB_RCACHE, 0, 0);
/* enable write caching if enabled */
if (ata_wc)
ata_controlcmd(atadev, ATA_SETFEATURES, ATA_SF_ENAB_WCACHE, 0, 0);
ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_ENAB_WCACHE, 0, 0);
else
ata_controlcmd(atadev, ATA_SETFEATURES, ATA_SF_DIS_WCACHE, 0, 0);
ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_DIS_WCACHE, 0, 0);
/* use multiple sectors/interrupt if device supports it */
if (ad_version(atadev->param.version_major)) {
int secsperint = max(1, min(atadev->param.sectors_intr, 16));
if (!ata_controlcmd(atadev, ATA_SET_MULTI, 0, 0, secsperint))
if (!ata_controlcmd(dev, ATA_SET_MULTI, 0, 0, secsperint))
atadev->max_iosize = secsperint * DEV_BSIZE;
}
else

View File

@ -47,18 +47,18 @@ __FBSDID("$FreeBSD$");
#include <dev/ata/ata-pci.h>
/* prototypes */
static void ata_dmaalloc(struct ata_channel *);
static void ata_dmafree(struct ata_channel *);
static void ata_dmaalloc(device_t);
static void ata_dmafree(device_t);
static void ata_dmasetprd(void *, bus_dma_segment_t *, int, int);
static int ata_dmaload(struct ata_device *, caddr_t, int32_t, int);
static int ata_dmaunload(struct ata_channel *);
static int ata_dmaload(device_t, caddr_t, int32_t, int);
static int ata_dmaunload(device_t);
/* local vars */
static MALLOC_DEFINE(M_ATADMA, "ATA DMA", "ATA driver DMA");
/* misc defines */
#define MAXTABSZ PAGE_SIZE
#define MAXWSPCSZ PAGE_SIZE
#define MAXWSPCSZ PAGE_SIZE*2
struct ata_dc_cb_args {
bus_addr_t maddr;
@ -66,8 +66,10 @@ struct ata_dc_cb_args {
};
void
ata_dmainit(struct ata_channel *ch)
ata_dmainit(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
if ((ch->dma = malloc(sizeof(struct ata_dma), M_ATADMA, M_NOWAIT|M_ZERO))) {
ch->dma->alloc = ata_dmaalloc;
ch->dma->free = ata_dmafree;
@ -90,8 +92,9 @@ ata_dmasetupc_cb(void *xsc, bus_dma_segment_t *segs, int nsegs, int error)
}
static void
ata_dmaalloc(struct ata_channel *ch)
ata_dmaalloc(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
struct ata_dc_cb_args ccba;
if (bus_dma_tag_create(NULL, ch->dma->alignment, 0,
@ -128,7 +131,7 @@ ata_dmaalloc(struct ata_channel *ch)
if (bus_dmamap_create(ch->dma->data_tag, 0, &ch->dma->data_map))
goto error;
if (bus_dma_tag_create(ch->dma->dmatag, PAGE_SIZE, PAGE_SIZE,
if (bus_dma_tag_create(ch->dma->dmatag, PAGE_SIZE, 64 * 1024,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
NULL, NULL, MAXWSPCSZ, 1, MAXWSPCSZ,
0, NULL, NULL, &ch->dma->work_tag))
@ -148,15 +151,17 @@ ata_dmaalloc(struct ata_channel *ch)
return;
error:
device_printf(ch->dev, "WARNING - DMA allocation failed, disabling DMA\n");
ata_dmafree(ch);
device_printf(dev, "WARNING - DMA allocation failed, disabling DMA\n");
ata_dmafree(dev);
free(ch->dma, M_ATADMA);
ch->dma = NULL;
}
static void
ata_dmafree(struct ata_channel *ch)
ata_dmafree(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
if (ch->dma->work_bus) {
bus_dmamap_unload(ch->dma->work_tag, ch->dma->work_map);
bus_dmamem_free(ch->dma->work_tag, ch->dma->work, ch->dma->work_map);
@ -211,30 +216,26 @@ ata_dmasetprd(void *xsc, bus_dma_segment_t *segs, int nsegs, int error)
}
static int
ata_dmaload(struct ata_device *atadev, caddr_t data, int32_t count, int dir)
ata_dmaload(device_t dev, caddr_t data, int32_t count, int dir)
{
struct ata_channel *ch = device_get_softc(device_get_parent(atadev->dev));
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct ata_dmasetprd_args cba;
if (ch->dma->flags & ATA_DMA_LOADED) {
device_printf(atadev->dev,
"FAILURE - already active DMA on this device\n");
device_printf(dev, "FAILURE - already active DMA on this device\n");
return -1;
}
if (!count) {
device_printf(atadev->dev,
"FAILURE - zero length DMA transfer attempted\n");
device_printf(dev, "FAILURE - zero length DMA transfer attempted\n");
return -1;
}
if (((uintptr_t)data & (ch->dma->alignment - 1)) ||
(count & (ch->dma->alignment - 1))) {
device_printf(atadev->dev,
"FAILURE - non aligned DMA transfer attempted\n");
device_printf(dev, "FAILURE - non aligned DMA transfer attempted\n");
return -1;
}
if (count > ch->dma->max_iosize) {
device_printf(atadev->dev,
"FAILURE - oversized DMA transfer attempted %d > %d\n",
device_printf(dev, "FAILURE - oversized DMA transfer attempt %d > %d\n",
count, ch->dma->max_iosize);
return -1;
}
@ -256,8 +257,9 @@ ata_dmaload(struct ata_device *atadev, caddr_t data, int32_t count, int dir)
}
int
ata_dmaunload(struct ata_channel *ch)
ata_dmaunload(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
bus_dmamap_sync(ch->dma->sg_tag, ch->dma->sg_map, BUS_DMASYNC_POSTWRITE);
bus_dmamap_sync(ch->dma->data_tag, ch->dma->data_map,

View File

@ -99,12 +99,12 @@ ata_isa_probe(device_t dev)
ch->r_io[ATA_CONTROL].res = ctlio;
ch->r_io[ATA_CONTROL].offset = 0;
ch->r_io[ATA_IDX_ADDR].res = io;
ata_default_registers(ch);
ata_default_registers(dev);
/* initialize softc for this channel */
ch->unit = 0;
ch->flags |= ATA_USE_16BIT;
ata_generic_hw(ch);
ata_generic_hw(dev);
return ata_probe(dev);
}

View File

@ -59,8 +59,10 @@ static void ata_pio_write(struct ata_request *, int);
* low level ATA functions
*/
void
ata_generic_hw(struct ata_channel *ch)
ata_generic_hw(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
ch->hw.begin_transaction = ata_begin_transaction;
ch->hw.end_transaction = ata_end_transaction;
ch->hw.command = ata_generic_command;
@ -90,7 +92,7 @@ ata_begin_transaction(struct ata_request *request)
int write = (request->flags & ATA_R_WRITE);
/* issue command */
if (ch->hw.command(atadev, request->u.ata.command,
if (ch->hw.command(request->dev, request->u.ata.command,
request->u.ata.lba, request->u.ata.count,
request->u.ata.feature)) {
device_printf(request->dev, "error issueing %s command\n",
@ -127,7 +129,7 @@ ata_begin_transaction(struct ata_request *request)
/* ATA DMA data transfer commands */
case ATA_R_DMA:
/* check sanity, setup SG list and DMA engine */
if (ch->dma->load(atadev, request->data, request->bytecount,
if (ch->dma->load(request->dev, request->data, request->bytecount,
request->flags & ATA_R_READ)) {
device_printf(request->dev, "setting up DMA failed\n");
request->result = EIO;
@ -135,7 +137,7 @@ ata_begin_transaction(struct ata_request *request)
}
/* issue command */
if (ch->hw.command(atadev, request->u.ata.command,
if (ch->hw.command(request->dev, request->u.ata.command,
request->u.ata.lba, request->u.ata.count,
request->u.ata.feature)) {
device_printf(request->dev, "error issueing %s command\n",
@ -145,7 +147,7 @@ ata_begin_transaction(struct ata_request *request)
}
/* start DMA engine */
if (ch->dma->start(ch)) {
if (ch->dma->start(request->dev)) {
device_printf(request->dev, "error starting DMA\n");
request->result = EIO;
goto begin_finished;
@ -164,7 +166,7 @@ ata_begin_transaction(struct ata_request *request)
}
/* start ATAPI operation */
if (ch->hw.command(atadev, ATA_PACKET_CMD,
if (ch->hw.command(request->dev, ATA_PACKET_CMD,
request->transfersize << 8, 0, 0)) {
device_printf(request->dev, "error issuing ATA PACKET command\n");
request->result = EIO;
@ -204,6 +206,7 @@ ata_begin_transaction(struct ata_request *request)
ATA_PROTO_ATAPI_12 ? 6 : 8);
goto begin_continue;
/* ATAPI DMA commands */
case ATA_R_ATAPI|ATA_R_DMA:
/* is this just a POLL DSC command ? */
if (request->u.atapi.ccb[0] == ATAPI_POLL_DSC) {
@ -215,7 +218,7 @@ ata_begin_transaction(struct ata_request *request)
}
/* check sanity, setup SG list and DMA engine */
if (ch->dma->load(atadev, request->data, request->bytecount,
if (ch->dma->load(request->dev, request->data, request->bytecount,
request->flags & ATA_R_READ)) {
device_printf(request->dev, "setting up DMA failed\n");
request->result = EIO;
@ -223,7 +226,7 @@ ata_begin_transaction(struct ata_request *request)
}
/* start ATAPI operation */
if (ch->hw.command(atadev, ATA_PACKET_CMD, 0, 0, ATA_F_DMA)) {
if (ch->hw.command(request->dev, ATA_PACKET_CMD, 0, 0, ATA_F_DMA)) {
device_printf(request->dev, "error issuing ATAPI packet command\n");
request->result = EIO;
goto begin_finished;
@ -258,7 +261,7 @@ ata_begin_transaction(struct ata_request *request)
ATA_PROTO_ATAPI_12 ? 6 : 8);
/* start DMA engine */
if (ch->dma->start(ch)) {
if (ch->dma->start(request->dev)) {
request->result = EIO;
goto begin_finished;
}
@ -269,7 +272,7 @@ ata_begin_transaction(struct ata_request *request)
begin_finished:
if (ch->dma && ch->dma->flags & ATA_DMA_LOADED)
ch->dma->unload(ch);
ch->dma->unload(request->dev);
return ATA_OP_FINISHED;
begin_continue:
@ -318,8 +321,8 @@ ata_end_transaction(struct ata_request *request)
(ATA_IDX_INB(ch, ATA_CYL_MSB) << 16));
}
else {
request->u.ata.count = ATA_IDX_INB(ch, ATA_COUNT);
request->u.ata.lba = ATA_IDX_INB(ch, ATA_SECTOR) |
request->u.ata.count = ATA_IDX_INB(ch, ATA_COUNT);
request->u.ata.lba = ATA_IDX_INB(ch, ATA_SECTOR) |
(ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) |
(ATA_IDX_INB(ch, ATA_CYL_MSB) << 16) |
((ATA_IDX_INB(ch, ATA_DRIVE) & 0xf) << 24);
@ -387,7 +390,7 @@ ata_end_transaction(struct ata_request *request)
/* stop DMA engine and get status */
if (ch->dma->stop)
request->dmastat = ch->dma->stop(ch);
request->dmastat = ch->dma->stop(request->dev);
/* did we get error or data */
if (request->status & ATA_S_ERROR)
@ -398,7 +401,7 @@ ata_end_transaction(struct ata_request *request)
request->donecount = request->bytecount;
/* release SG list etc */
ch->dma->unload(ch);
ch->dma->unload(request->dev);
/* done with HW */
goto end_finished;
@ -499,7 +502,7 @@ ata_end_transaction(struct ata_request *request)
/* stop the engine and get engine status */
if (ch->dma->stop)
request->dmastat = ch->dma->stop(ch);
request->dmastat = ch->dma->stop(request->dev);
/* did we get error or data */
if (request->status & (ATA_S_ERROR | ATA_S_DWF))
@ -510,7 +513,7 @@ ata_end_transaction(struct ata_request *request)
request->donecount = request->bytecount;
/* release SG list etc */
ch->dma->unload(ch);
ch->dma->unload(request->dev);
/* done with HW */
goto end_finished;
@ -528,8 +531,10 @@ end_continue:
/* must be called with ATA channel locked */
void
ata_generic_reset(struct ata_channel *ch)
ata_generic_reset(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
u_int8_t ostat0 = 0, stat0 = 0, ostat1 = 0, stat1 = 0;
u_int8_t err = 0, lsb = 0, msb = 0;
int mask = 0, timeout;
@ -555,7 +560,7 @@ ata_generic_reset(struct ata_channel *ch)
}
if (bootverbose)
device_printf(ch->dev, "reset tp1 mask=%02x ostat0=%02x ostat1=%02x\n",
device_printf(dev, "reset tp1 mask=%02x ostat0=%02x ostat1=%02x\n",
mask, ostat0, ostat1);
/* if nothing showed up there is no need to get any further */
@ -583,7 +588,7 @@ ata_generic_reset(struct ata_channel *ch)
msb = ATA_IDX_INB(ch, ATA_CYL_MSB);
stat0 = ATA_IDX_INB(ch, ATA_STATUS);
if (bootverbose)
device_printf(ch->dev,
device_printf(dev,
"stat0=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",
stat0, err, lsb, msb);
if (stat0 == err && lsb == err && msb == err &&
@ -613,7 +618,7 @@ ata_generic_reset(struct ata_channel *ch)
msb = ATA_IDX_INB(ch, ATA_CYL_MSB);
stat1 = ATA_IDX_INB(ch, ATA_STATUS);
if (bootverbose)
device_printf(ch->dev,
device_printf(dev,
"stat1=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",
stat1, err, lsb, msb);
if (stat1 == err && lsb == err && msb == err &&
@ -654,7 +659,7 @@ ata_generic_reset(struct ata_channel *ch)
}
if (bootverbose)
device_printf(ch->dev, "reset tp2 stat0=%02x stat1=%02x devices=0x%b\n",
device_printf(dev, "reset tp2 stat0=%02x stat1=%02x devices=0x%b\n",
stat0, stat1, ch->devices,
"\20\4ATAPI_SLAVE\3ATAPI_MASTER\2ATA_SLAVE\1ATA_MASTER");
}
@ -711,17 +716,18 @@ ata_wait(struct ata_channel *ch, struct ata_device *atadev, u_int8_t mask)
}
int
ata_generic_command(struct ata_device *atadev, u_int8_t command,
ata_generic_command(device_t dev, u_int8_t command,
u_int64_t lba, u_int16_t count, u_int16_t feature)
{
struct ata_channel *ch = device_get_softc(device_get_parent(atadev->dev));
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct ata_device *atadev = device_get_softc(dev);
/* select device */
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | atadev->unit);
/* ready to issue command ? */
if (ata_wait(ch, atadev, 0) < 0) {
device_printf(atadev->dev, "timeout sending command=%02x\n", command);
device_printf(dev, "timeout sending command=%02x\n", command);
return -1;
}
@ -753,7 +759,7 @@ ata_generic_command(struct ata_device *atadev, u_int8_t command,
case ATA_FLUSHCACHE:
command = ATA_FLUSHCACHE48; break;
default:
device_printf(atadev->dev,"can't translate cmd to 48bit version\n");
device_printf(dev,"can't translate cmd to 48bit version\n");
return -1;
}
ATA_IDX_OUTB(ch, ATA_FEATURE, (feature>>8) & 0xff);

View File

@ -60,7 +60,7 @@ static MALLOC_DEFINE(M_ATAPCI, "ATA PCI", "ATA driver PCI");
#define IOMASK 0xfffffffc
/* prototypes */
static void ata_pci_dmainit(struct ata_channel *);
static void ata_pci_dmainit(device_t);
int
ata_legacy(device_t dev)
@ -404,7 +404,7 @@ ata_pci_allocate(device_t dev)
ch->r_io[ATA_CONTROL].res = ctlio;
ch->r_io[ATA_CONTROL].offset = ata_legacy(device_get_parent(dev)) ? 0 : 2;
ch->r_io[ATA_IDX_ADDR].res = io;
ata_default_registers(ch);
ata_default_registers(dev);
if (ctlr->r_res1) {
for (i = ATA_BMCMD_PORT; i <= ATA_BMDTP_PORT; i++) {
ch->r_io[i].res = ctlr->r_res1;
@ -412,13 +412,15 @@ ata_pci_allocate(device_t dev)
}
}
ata_generic_hw(ch);
ata_generic_hw(dev);
return 0;
}
static int
ata_pci_dmastart(struct ata_channel *ch)
ata_pci_dmastart(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
ATA_IDX_OUTB(ch, ATA_BMSTAT_PORT, (ATA_IDX_INB(ch, ATA_BMSTAT_PORT) |
(ATA_BMSTAT_INTERRUPT | ATA_BMSTAT_ERROR)));
ATA_IDX_OUTL(ch, ATA_BMDTP_PORT, ch->dma->sg_bus);
@ -431,8 +433,9 @@ ata_pci_dmastart(struct ata_channel *ch)
}
static int
ata_pci_dmastop(struct ata_channel *ch)
ata_pci_dmastop(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
int error;
ATA_IDX_OUTB(ch, ATA_BMCMD_PORT,
@ -444,9 +447,11 @@ ata_pci_dmastop(struct ata_channel *ch)
}
static void
ata_pci_dmainit(struct ata_channel *ch)
ata_pci_dmainit(device_t dev)
{
ata_dmainit(ch);
struct ata_channel *ch = device_get_softc(dev);
ata_dmainit(dev);
if (ch->dma) {
ch->dma->start = ata_pci_dmastart;
ch->dma->stop = ata_pci_dmastop;
@ -518,9 +523,9 @@ ata_pcichannel_attach(device_t dev)
int error;
if (ctlr->r_res1)
ctlr->dmainit(ch);
ctlr->dmainit(dev);
if (ch->dma)
ch->dma->alloc(ch);
ch->dma->alloc(dev);
if ((error = ctlr->allocate(dev)))
return error;
@ -538,7 +543,7 @@ ata_pcichannel_detach(device_t dev)
return error;
if (ch->dma)
ch->dma->free(ch);
ch->dma->free(dev);
/* free resources for io and ctlio XXX SOS */
@ -552,7 +557,7 @@ ata_pcichannel_locking(device_t dev, int mode)
struct ata_channel *ch = device_get_softc(dev);
if (ctlr->locking)
return ctlr->locking(ch, mode);
return ctlr->locking(dev, mode);
else
return ch->unit;
}
@ -565,17 +570,17 @@ ata_pcichannel_reset(device_t dev)
/* if DMA functionality present stop it */
if (ch->dma) {
if (ch->dma->stop)
ch->dma->stop(ch);
if (ch->dma->flags & ATA_DMA_LOADED)
ch->dma->unload(ch);
if (ch->dma->flags & ATA_DMA_ACTIVE)
ch->dma->stop(dev);
if (ch->dma->flags & ATA_DMA_LOADED)
ch->dma->unload(dev);
}
/* reset the controller HW */
if (ctlr->reset)
ctlr->reset(ch);
ctlr->reset(dev);
else
ata_generic_reset(ch);
ata_generic_reset(dev);
}
static void
@ -585,9 +590,9 @@ ata_pcichannel_setmode(device_t parent, device_t dev)
struct ata_device *atadev = device_get_softc(dev);
int mode = atadev->mode;
ctlr->setmode(atadev, ATA_PIO_MAX);
ctlr->setmode(dev, ATA_PIO_MAX);
if (mode >= ATA_DMA)
ctlr->setmode(atadev, mode);
ctlr->setmode(dev, mode);
}
static device_method_t ata_pcichannel_methods[] = {

View File

@ -53,10 +53,10 @@ struct ata_pci_controller {
int channels;
int (*chipinit)(device_t);
int (*allocate)(device_t);
int (*locking)(struct ata_channel *, int);
void (*reset)(struct ata_channel *);
void (*dmainit)(struct ata_channel *);
void (*setmode)(struct ata_device *, int);
int (*locking)(device_t, int);
void (*reset)(device_t);
void (*dmainit)(device_t);
void (*setmode)(device_t, int);
struct {
void (*function)(void *);
void *argument;
@ -91,9 +91,9 @@ struct ata_connect_task {
#define ATA_ACER_LABS_ID 0x10b9
#define ATA_ALI_5229 0x522910b9
#define ATA_ALI_5281 0x528110b9
#define ATA_ALI_5287 0x528710b9
#define ATA_ALI_5289 0x528910b9
#define ATA_ALI_5281 0x528110b9
#define ATA_ALI_5287 0x528710b9
#define ATA_ALI_5289 0x528910b9
#define ATA_CENATEK_ID 0x16ca
#define ATA_CENATEK_ROCKET 0x000116ca
@ -377,4 +377,4 @@ int ata_legacy(device_t);
struct ata_chip_id *ata_match_chip(device_t, struct ata_chip_id *);
/* global prototypes ata-dma.c */
void ata_dmainit(struct ata_channel *);
void ata_dmainit(device_t);

View File

@ -107,14 +107,14 @@ ata_queue_request(struct ata_request *request)
}
int
ata_controlcmd(struct ata_device *atadev, u_int8_t command, u_int16_t feature,
ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature,
u_int64_t lba, u_int16_t count)
{
struct ata_request *request = ata_alloc_request();
int error = ENOMEM;
if (request) {
request->dev = atadev->dev;
request->dev = dev;
request->u.ata.command = command;
request->u.ata.lba = lba;
request->u.ata.count = count;
@ -130,14 +130,15 @@ ata_controlcmd(struct ata_device *atadev, u_int8_t command, u_int16_t feature,
}
int
ata_atapicmd(struct ata_device *atadev, u_int8_t *ccb, caddr_t data,
ata_atapicmd(device_t dev, u_int8_t *ccb, caddr_t data,
int count, int flags, int timeout)
{
struct ata_request *request = ata_alloc_request();
struct ata_device *atadev = device_get_softc(dev);
int error = ENOMEM;
if (request) {
request->dev = atadev->dev;
request->dev = dev;
if ((atadev->param.config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12)
bcopy(ccb, request->u.atapi.ccb, 12);
else
@ -466,13 +467,14 @@ ata_timeout(struct ata_request *request)
}
void
ata_catch_inflight(struct ata_channel *ch)
ata_catch_inflight(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
struct ata_request *request;
mtx_lock(&ch->state_mtx);
if ((request = ch->running))
callout_stop(&request->callout);
callout_stop(&request->callout);
ch->running = NULL;
mtx_unlock(&ch->state_mtx);
if (request) {
@ -488,8 +490,9 @@ ata_catch_inflight(struct ata_channel *ch)
}
void
ata_fail_requests(struct ata_channel *ch, device_t dev)
ata_fail_requests(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct ata_request *request;
/* fail all requests queued on this channel for device dev if !NULL */

View File

@ -119,7 +119,7 @@ ata_raid_attach(struct ar_softc *rdp, int writeback)
/* sanitize arrays total_size % (width * interleave) == 0 */
if (rdp->type == AR_T_RAID0 || rdp->type == AR_T_RAID01 ||
rdp->type == AR_T_RAID5)
rdp->total_sectors = (rdp->total_sectors/(rdp->interleave*rdp->width))*
rdp->total_sectors = (rdp->total_sectors/(rdp->interleave*rdp->width))*
(rdp->interleave * rdp->width);
rdp->disk = disk_alloc();
rdp->disk->d_strategy = ata_raid_strategy;

View File

@ -283,7 +283,7 @@ struct hptv3_raid_conf {
struct intel_raid_conf {
u_int8_t intel_id[24];
#define INTEL_MAGIC "Intel Raid ISM Cfg Sig. "
#define INTEL_MAGIC "Intel Raid ISM Cfg Sig. "
u_int8_t version[6];
u_int8_t dummy_0[2];
@ -349,7 +349,7 @@ struct ite_raid_conf {
u_int32_t filler_2[5];
u_int16_t filler_3;
u_int8_t ite_id[40];
#define ITE_MAGIC "Integrated Technology Express Inc "
#define ITE_MAGIC "Integrated Technology Express Inc "
u_int16_t filler_4;
u_int32_t filler_5[6];
@ -397,7 +397,7 @@ struct ite_raid_conf {
struct lsiv2_raid_conf {
u_int8_t lsi_id[6];
#define LSIV2_MAGIC "$XIDE$"
#define LSIV2_MAGIC "$XIDE$"
u_int8_t dummy_0;
u_int8_t flags;
@ -470,7 +470,7 @@ struct lsiv3_raid_conf {
u_int8_t checksum_0;
u_int8_t filler_5[512*2];
u_int8_t lsi_id[6];
#define LSIV3_MAGIC "$_IDE$"
#define LSIV3_MAGIC "$_IDE$"
u_int16_t dummy_2; /* 0x33de for OK disk */
u_int16_t version; /* 0x0131 for this version */
@ -526,11 +526,11 @@ struct lsiv3_raid_conf {
struct promise_raid_conf {
char promise_id[24];
#define PR_MAGIC "Promise Technology, Inc."
#define PR_MAGIC "Promise Technology, Inc."
u_int32_t dummy_0;
u_int64_t magic_0;
#define PR_MAGIC0(x) (((u_int64_t)(x.channel) << 48) | \
#define PR_MAGIC0(x) (((u_int64_t)(x.channel) << 48) | \
((u_int64_t)(x.device != 0) << 56))
u_int16_t magic_1;
u_int32_t magic_2;
@ -644,25 +644,25 @@ struct sii_raid_conf {
( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
struct via_raid_conf {
u_int16_t magic;
#define VIA_MAGIC 0xaa55
u_int16_t magic;
#define VIA_MAGIC 0xaa55
u_int8_t dummy_0;
u_int8_t type;
#define VIA_T_MASK 0xfe
#define VIA_T_BOOTABLE 0x01
#define VIA_T_RAID0 0x04
#define VIA_T_RAID1 0x0c
#define VIA_T_SPAN 0x44
u_int8_t dummy_0;
u_int8_t type;
#define VIA_T_MASK 0xfe
#define VIA_T_BOOTABLE 0x01
#define VIA_T_RAID0 0x04
#define VIA_T_RAID1 0x0c
#define VIA_T_SPAN 0x44
u_int8_t disk_index;
u_int8_t stripe_layout;
#define VIA_L_MASK 0x07
#define VIA_L_SHIFT 4
u_int8_t disk_index;
u_int8_t stripe_layout;
#define VIA_L_MASK 0x07
#define VIA_L_SHIFT 4
u_int64_t total_sectors;
u_int32_t disk_id;
u_int32_t disks[8];
u_int8_t checksum;
u_int8_t filler_1[461];
u_int64_t total_sectors;
u_int32_t disk_id;
u_int32_t disks[8];
u_int8_t checksum;
u_int8_t filler_1[461];
} __packed;

View File

@ -63,7 +63,7 @@ CODE {
{
struct ata_device *atadev = device_get_softc(dev);
atadev->mode = ata_limit_mode(atadev, atadev->mode, ATA_PIO_MAX);
atadev->mode = ata_limit_mode(dev, atadev->mode, ATA_PIO_MAX);
}
};
METHOD void setmode {

View File

@ -56,34 +56,34 @@ __FBSDID("$FreeBSD$");
/* private data associated with an ATA bus */
struct atapi_xpt_softc {
struct ata_device atapi_cam_dev; /* must be first */
device_t dev;
device_t parent;
struct ata_channel *ata_ch;
struct cam_path *path;
struct cam_sim *sim;
int flags;
#define BUS_REGISTERED 0x01
#define RESOURCE_SHORTAGE 0x02
#define DETACHING 0x04
struct ata_device atapi_cam_dev; /* must be first */
device_t dev;
device_t parent;
struct ata_channel *ata_ch;
struct cam_path *path;
struct cam_sim *sim;
int flags;
#define BUS_REGISTERED 0x01
#define RESOURCE_SHORTAGE 0x02
#define DETACHING 0x04
TAILQ_HEAD(,atapi_hcb) pending_hcbs;
struct ata_device *atadev[2];
struct mtx state_lock;
struct mtx state_lock;
};
/* hardware command descriptor block */
struct atapi_hcb {
struct atapi_xpt_softc *softc;
int unit;
int bus;
int target;
int lun;
union ccb *ccb;
int flags;
#define QUEUED 0x0001
int unit;
int bus;
int target;
int lun;
union ccb *ccb;
int flags;
#define QUEUED 0x0001
#define AUTOSENSE 0x0002
char *dxfer_alloc;
char *dxfer_alloc;
TAILQ_ENTRY(atapi_hcb) chain;
};
@ -118,11 +118,11 @@ static void free_softc(struct atapi_xpt_softc *scp);
static MALLOC_DEFINE(M_ATACAM, "ATA CAM transport", "ATA driver CAM-XPT layer");
static device_method_t atapi_cam_methods[] = {
DEVMETHOD(device_identify, atapi_cam_identify),
DEVMETHOD(device_probe, atapi_cam_probe),
DEVMETHOD(device_attach, atapi_cam_attach),
DEVMETHOD(device_detach, atapi_cam_detach),
DEVMETHOD(ata_reinit, atapi_cam_reinit),
DEVMETHOD(device_identify, atapi_cam_identify),
DEVMETHOD(device_probe, atapi_cam_probe),
DEVMETHOD(device_attach, atapi_cam_attach),
DEVMETHOD(device_detach, atapi_cam_detach),
DEVMETHOD(ata_reinit, atapi_cam_reinit),
{0, 0}
};
@ -132,7 +132,7 @@ static driver_t atapi_cam_driver = {
sizeof(struct atapi_xpt_softc)
};
static devclass_t atapi_cam_devclass;
static devclass_t atapi_cam_devclass;
DRIVER_MODULE(atapicam, ata,
atapi_cam_driver,
atapi_cam_devclass,
@ -413,7 +413,7 @@ atapi_action(struct cam_sim *sim, union ccb *ccb)
int tid = ccb_h->target_id;
CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("dev reset\n"));
ata_controlcmd(softc->atadev[tid], ATA_ATAPI_RESET, 0, 0, 0);
ata_controlcmd(softc->atadev[tid]->dev, ATA_ATAPI_RESET, 0, 0, 0);
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);
return;
@ -472,7 +472,7 @@ atapi_action(struct cam_sim *sim, union ccb *ccb)
return;
}
if (softc->atadev[tid] == NULL) {
if (softc->atadev[tid] == NULL) {
ccb->ccb_h.status = CAM_DEV_NOT_THERE;
xpt_done(ccb);
mtx_unlock(&softc->state_lock);
@ -586,7 +586,7 @@ atapi_action(struct cam_sim *sim, union ccb *ccb)
if ((ccb_h->flags & CAM_DIR_MASK) == CAM_DIR_IN && (len & 1)) {
/* ATA always transfers an even number of bytes */
if ((buf = hcb->dxfer_alloc
= malloc(++len, M_ATACAM, M_NOWAIT | M_ZERO)) == NULL) {
= malloc(++len, M_ATACAM, M_NOWAIT | M_ZERO)) == NULL) {
printf("cannot allocate ATAPI/CAM buffer\n");
goto action_oom;
}

View File

@ -149,7 +149,7 @@ acd_shutdown(device_t dev)
struct ata_device *atadev = device_get_softc(dev);
if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
ata_controlcmd(atadev, ATA_FLUSHCACHE, 0, 0, 0);
ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
}
static int
@ -192,14 +192,13 @@ acd_geom_attach(void *arg, int flag)
static void
acd_geom_detach(void *arg, int flag)
{
struct ata_channel *ch = device_get_softc(device_get_parent(arg));
struct acd_softc *cdp = device_get_ivars(arg);
/* signal geom so we dont get any further requests */
g_wither_geom(cdp->gp, ENXIO);
/* fail requests on the queue and any thats "in flight" for this device */
ata_fail_requests(ch, arg);
ata_fail_requests(arg);
/* dont leave anything behind */
device_set_ivars(arg, NULL);
@ -425,7 +424,7 @@ acd_geom_ioctl(struct g_provider *pp, u_long cmd, void *addr, int fflag, struct
ccb[1] = args->address_format & CD_MSF_FORMAT;
if ((error = ata_atapicmd(atadev, ccb, (caddr_t)&cdp->subchan,
if ((error = ata_atapicmd(dev, ccb, (caddr_t)&cdp->subchan,
sizeof(cdp->subchan), ATA_R_READ, 10)))
break;
@ -439,7 +438,7 @@ acd_geom_ioctl(struct g_provider *pp, u_long cmd, void *addr, int fflag, struct
if (format == CD_TRACK_INFO)
ccb[6] = args->track;
if ((error = ata_atapicmd(atadev, ccb, (caddr_t)&cdp->subchan,
if ((error = ata_atapicmd(dev, ccb, (caddr_t)&cdp->subchan,
sizeof(cdp->subchan),ATA_R_READ,10))){
break;
}
@ -949,7 +948,7 @@ acd_read_toc(device_t dev)
ccb[0] = ATAPI_READ_TOC;
ccb[7] = len>>8;
ccb[8] = len;
if (ata_atapicmd(atadev, ccb, (caddr_t)&cdp->toc, len,
if (ata_atapicmd(dev, ccb, (caddr_t)&cdp->toc, len,
ATA_R_READ | ATA_R_QUIET, 30)) {
bzero(&cdp->toc, sizeof(cdp->toc));
return;
@ -965,7 +964,7 @@ acd_read_toc(device_t dev)
ccb[0] = ATAPI_READ_TOC;
ccb[7] = len>>8;
ccb[8] = len;
if (ata_atapicmd(atadev, ccb, (caddr_t)&cdp->toc, len,
if (ata_atapicmd(dev, ccb, (caddr_t)&cdp->toc, len,
ATA_R_READ | ATA_R_QUIET, 30)) {
bzero(&cdp->toc, sizeof(cdp->toc));
return;
@ -976,7 +975,7 @@ acd_read_toc(device_t dev)
acd_set_ioparm(dev);
bzero(ccb, sizeof(ccb));
ccb[0] = ATAPI_READ_CAPACITY;
if (ata_atapicmd(atadev, ccb, (caddr_t)sizes, sizeof(sizes),
if (ata_atapicmd(dev, ccb, (caddr_t)sizes, sizeof(sizes),
ATA_R_READ | ATA_R_QUIET, 30)) {
bzero(&cdp->toc, sizeof(cdp->toc));
return;
@ -1016,14 +1015,13 @@ acd_read_toc(device_t dev)
static int
acd_play(device_t dev, int start, int end)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16];
bzero(ccb, sizeof(ccb));
ccb[0] = ATAPI_PLAY_MSF;
lba2msf(start, &ccb[3], &ccb[4], &ccb[5]);
lba2msf(end, &ccb[6], &ccb[7], &ccb[8]);
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 10);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 10);
}
static int
@ -1048,22 +1046,20 @@ acd_setchan(device_t dev, u_int8_t c0, u_int8_t c1, u_int8_t c2, u_int8_t c3)
static int
acd_init_writer(device_t dev, int test_write)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16];
bzero(ccb, sizeof(ccb));
ccb[0] = ATAPI_REZERO;
ata_atapicmd(atadev, ccb, NULL, 0, ATA_R_QUIET, 60);
ata_atapicmd(dev, ccb, NULL, 0, ATA_R_QUIET, 60);
ccb[0] = ATAPI_SEND_OPC_INFO;
ccb[1] = 0x01;
ata_atapicmd(atadev, ccb, NULL, 0, ATA_R_QUIET, 30);
ata_atapicmd(dev, ccb, NULL, 0, ATA_R_QUIET, 30);
return 0;
}
static int
acd_fixate(device_t dev, int multisession)
{
struct ata_device *atadev = device_get_softc(dev);
struct acd_softc *cdp = device_get_ivars(dev);
int8_t ccb[16] = { ATAPI_CLOSE_TRACK, 0x01, 0x02, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
@ -1084,7 +1080,7 @@ acd_fixate(device_t dev, int multisession)
if ((error = acd_mode_select(dev, (caddr_t)&param, param.page_length + 10)))
return error;
error = ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
if (error)
return error;
@ -1189,24 +1185,22 @@ acd_init_track(device_t dev, struct cdr_track *track)
static int
acd_flush(device_t dev)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_SYNCHRONIZE_CACHE, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, ATA_R_QUIET, 60);
return ata_atapicmd(dev, ccb, NULL, 0, ATA_R_QUIET, 60);
}
static int
acd_read_track_info(device_t dev, int32_t lba, struct acd_track_info *info)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_READ_TRACK_INFO, 1,
lba>>24, lba>>16, lba>>8, lba, 0,
sizeof(*info)>>8, sizeof(*info),
0, 0, 0, 0, 0, 0, 0 };
int error;
if ((error = ata_atapicmd(atadev, ccb, (caddr_t)info, sizeof(*info),
if ((error = ata_atapicmd(dev, ccb, (caddr_t)info, sizeof(*info),
ATA_R_READ, 30)))
return error;
info->track_start_addr = ntohl(info->track_start_addr);
@ -1248,7 +1242,6 @@ acd_get_progress(device_t dev, int *finished)
static int
acd_send_cue(device_t dev, struct cdr_cuesheet *cuesheet)
{
struct ata_device *atadev = device_get_softc(dev);
struct acd_softc *cdp = device_get_ivars(dev);
struct write_param param;
int8_t ccb[16] = { ATAPI_SEND_CUE_SHEET, 0, 0, 0, 0, 0,
@ -1294,7 +1287,7 @@ acd_send_cue(device_t dev, struct cdr_cuesheet *cuesheet)
printf("\n%02x", buffer[i]);
printf("\n");
#endif
error = ata_atapicmd(atadev, ccb, buffer, cuesheet->len, 0, 30);
error = ata_atapicmd(dev, ccb, buffer, cuesheet->len, 0, 30);
}
free(buffer, M_ACD);
return error;
@ -1303,7 +1296,6 @@ acd_send_cue(device_t dev, struct cdr_cuesheet *cuesheet)
static int
acd_report_key(device_t dev, struct dvd_authinfo *ai)
{
struct ata_device *atadev = device_get_softc(dev);
struct dvd_miscauth *d = NULL;
u_int32_t lba = 0;
int16_t length;
@ -1349,7 +1341,7 @@ acd_report_key(device_t dev, struct dvd_authinfo *ai)
d->length = htons(length - 2);
}
error = ata_atapicmd(atadev, ccb, (caddr_t)d, length,
error = ata_atapicmd(dev, ccb, (caddr_t)d, length,
ai->format == DVD_INVALIDATE_AGID ? 0 : ATA_R_READ,10);
if (error) {
free(d, M_ACD);
@ -1401,7 +1393,6 @@ acd_report_key(device_t dev, struct dvd_authinfo *ai)
static int
acd_send_key(device_t dev, struct dvd_authinfo *ai)
{
struct ata_device *atadev = device_get_softc(dev);
struct dvd_miscauth *d;
int16_t length;
int8_t ccb[16];
@ -1439,7 +1430,7 @@ acd_send_key(device_t dev, struct dvd_authinfo *ai)
ccb[9] = length & 0xff;
ccb[10] = (ai->agid << 6) | ai->format;
d->length = htons(length - 2);
error = ata_atapicmd(atadev, ccb, (caddr_t)d, length, 0, 10);
error = ata_atapicmd(dev, ccb, (caddr_t)d, length, 0, 10);
free(d, M_ACD);
return error;
}
@ -1447,7 +1438,6 @@ acd_send_key(device_t dev, struct dvd_authinfo *ai)
static int
acd_read_structure(device_t dev, struct dvd_struct *s)
{
struct ata_device *atadev = device_get_softc(dev);
struct dvd_miscauth *d;
u_int16_t length;
int8_t ccb[16];
@ -1499,7 +1489,7 @@ acd_read_structure(device_t dev, struct dvd_struct *s)
ccb[8] = (length >> 8) & 0xff;
ccb[9] = length & 0xff;
ccb[10] = s->agid << 6;
error = ata_atapicmd(atadev, ccb, (caddr_t)d, length, ATA_R_READ, 30);
error = ata_atapicmd(dev, ccb, (caddr_t)d, length, ATA_R_READ, 30);
if (error) {
free(d, M_ACD);
return error;
@ -1585,48 +1575,44 @@ acd_blank(device_t dev, int blanktype)
0, 0, 0, 0, 0, 0, 0, 0 };
atadev->flags |= ATA_D_MEDIA_CHANGED;
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static int
acd_prevent_allow(device_t dev, int lock)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_PREVENT_ALLOW, 0, 0, 0, lock,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static int
acd_start_stop(device_t dev, int start)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_START_STOP, 0, 0, 0, start,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static int
acd_pause_resume(device_t dev, int pause)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_PAUSE, 0, 0, 0, 0, 0, 0, 0, pause,
0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static int
acd_mode_sense(device_t dev, int page, caddr_t pagebuf, int pagesize)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_MODE_SENSE_BIG, 0, page, 0, 0, 0, 0,
pagesize>>8, pagesize, 0, 0, 0, 0, 0, 0, 0 };
int error;
error = ata_atapicmd(atadev, ccb, pagebuf, pagesize, ATA_R_READ, 10);
error = ata_atapicmd(dev, ccb, pagebuf, pagesize, ATA_R_READ, 10);
#ifdef ACD_DEBUG
atapi_dump("acd: mode sense ", pagebuf, pagesize);
#endif
@ -1636,7 +1622,6 @@ acd_mode_sense(device_t dev, int page, caddr_t pagebuf, int pagesize)
static int
acd_mode_select(device_t dev, caddr_t pagebuf, int pagesize)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_MODE_SELECT_BIG, 0x10, 0, 0, 0, 0, 0,
pagesize>>8, pagesize, 0, 0, 0, 0, 0, 0, 0 };
@ -1644,18 +1629,17 @@ acd_mode_select(device_t dev, caddr_t pagebuf, int pagesize)
device_printf(dev, "modeselect pagesize=%d\n", pagesize);
atapi_dump("mode select ", pagebuf, pagesize);
#endif
return ata_atapicmd(atadev, ccb, pagebuf, pagesize, 0, 30);
return ata_atapicmd(dev, ccb, pagebuf, pagesize, 0, 30);
}
static int
acd_set_speed(device_t dev, int rdspeed, int wrspeed)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_SET_SPEED, 0, rdspeed >> 8, rdspeed,
wrspeed >> 8, wrspeed, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int error;
error = ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
if (!error)
acd_get_cap(dev);
return error;
@ -1685,25 +1669,23 @@ acd_get_cap(device_t dev)
static int
acd_read_format_caps(device_t dev, struct cdr_format_capacities *caps)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_READ_FORMAT_CAPACITIES, 0, 0, 0, 0, 0, 0,
(sizeof(struct cdr_format_capacities) >> 8) & 0xff,
sizeof(struct cdr_format_capacities) & 0xff,
0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, (caddr_t)caps,
return ata_atapicmd(dev, ccb, (caddr_t)caps,
sizeof(struct cdr_format_capacities), ATA_R_READ, 30);
}
static int
acd_format(device_t dev, struct cdr_format_params* params)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_FORMAT, 0x11, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0 };
int error;
error = ata_atapicmd(atadev, ccb, (u_int8_t *)params,
error = ata_atapicmd(dev, ccb, (u_int8_t *)params,
sizeof(struct cdr_format_params), 0, 30);
return error;
}
@ -1711,11 +1693,10 @@ acd_format(device_t dev, struct cdr_format_params* params)
static int
acd_test_ready(device_t dev)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_TEST_UNIT_READY, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static void

View File

@ -117,14 +117,13 @@ afd_attach(device_t dev)
static int
afd_detach(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct afd_softc *fdp = device_get_ivars(dev);
/* detroy disk from the system so we dont get any further requests */
disk_destroy(fdp->disk);
/* fail requests on the queue and any thats "in flight" for this device */
ata_fail_requests(ch, dev);
ata_fail_requests(dev);
/* dont leave anything behind */
device_set_ivars(dev, NULL);
@ -138,7 +137,7 @@ afd_shutdown(device_t dev)
struct ata_device *atadev = device_get_softc(dev);
if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
ata_controlcmd(atadev, ATA_FLUSHCACHE, 0, 0, 0);
ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
}
static int
@ -305,7 +304,7 @@ afd_sense(device_t dev)
/* get drive capabilities, some bugridden drives needs this repeated */
for (count = 0 ; count < 5 ; count++) {
if (!ata_atapicmd(atadev, ccb, (caddr_t)&fdp->cap,
if (!ata_atapicmd(dev, ccb, (caddr_t)&fdp->cap,
sizeof(struct afd_cappage), ATA_R_READ, 30) &&
fdp->cap.page_code == ATAPI_REWRITEABLE_CAP_PAGE) {
fdp->cap.cylinders = ntohs(fdp->cap.cylinders);
@ -326,17 +325,16 @@ afd_prevent_allow(device_t dev, int lock)
if (!strncmp(atadev->param.model, "IOMEGA Clik!", 12))
return 0;
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static int
afd_test_ready(device_t dev)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_TEST_UNIT_READY, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static void

View File

@ -167,7 +167,6 @@ ast_attach(device_t dev)
static int
ast_detach(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct ast_softc *stp = device_get_ivars(dev);
/* detroy devices from the system so we dont get any further requests */
@ -175,7 +174,7 @@ ast_detach(device_t dev)
destroy_dev(stp->dev2);
/* fail requests on the queue and any thats "in flight" for this device */
ata_fail_requests(ch, dev);
ata_fail_requests(dev);
/* dont leave anything behind */
devstat_remove_entry(stp->stats);
@ -190,7 +189,7 @@ ast_shutdown(device_t dev)
struct ata_device *atadev = device_get_softc(dev);
if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
ata_controlcmd(atadev, ATA_FLUSHCACHE, 0, 0, 0);
ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
}
static int
@ -515,29 +514,26 @@ ast_sense(device_t dev)
static int
ast_mode_sense(device_t dev, int page, void *pagebuf, int pagesize)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_MODE_SENSE, 0x08, page, pagesize>>8, pagesize,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int error;
error = ata_atapicmd(atadev, ccb, pagebuf, pagesize, ATA_R_READ, 10);
error = ata_atapicmd(dev, ccb, pagebuf, pagesize, ATA_R_READ, 10);
return error;
}
static int
ast_mode_select(device_t dev, void *pagebuf, int pagesize)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_MODE_SELECT, 0x10, 0, pagesize>>8, pagesize,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, pagebuf, pagesize, 0, 10);
return ata_atapicmd(dev, ccb, pagebuf, pagesize, 0, 10);
}
static int
ast_write_filemark(device_t dev, u_int8_t function)
{
struct ata_device *atadev = device_get_softc(dev);
struct ast_softc *stp = device_get_ivars(dev);
int8_t ccb[16] = { ATAPI_WEOF, 0x01, 0, 0, function, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
@ -553,7 +549,7 @@ ast_write_filemark(device_t dev, u_int8_t function)
stp->flags |= F_FM_WRITTEN;
}
}
error = ata_atapicmd(atadev, ccb, NULL, 0, 0, 10);
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 10);
if (error)
return error;
return ast_wait_dsc(dev, 10*60);
@ -562,12 +558,11 @@ ast_write_filemark(device_t dev, u_int8_t function)
static int
ast_read_position(device_t dev, int hard, struct ast_readposition *position)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_READ_POSITION, (hard ? 0x01 : 0), 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
int error;
error = ata_atapicmd(atadev, ccb, (caddr_t)position,
error = ata_atapicmd(dev, ccb, (caddr_t)position,
sizeof(struct ast_readposition), ATA_R_READ, 10);
position->tape = ntohl(position->tape);
position->host = ntohl(position->host);
@ -577,23 +572,21 @@ ast_read_position(device_t dev, int hard, struct ast_readposition *position)
static int
ast_space(device_t dev, u_int8_t function, int32_t count)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_SPACE, function, count>>16, count>>8, count,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 60*60);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 60*60);
}
static int
ast_locate(device_t dev, int hard, u_int32_t pos)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_LOCATE, 0x01 | (hard ? 0x4 : 0), 0,
pos>>24, pos>>16, pos>>8, pos,
0, 0, 0, 0, 0, 0, 0, 0, 0 };
int error;
error = ata_atapicmd(atadev, ccb, NULL, 0, 0, 10);
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 10);
if (error)
return error;
return ast_wait_dsc(dev, 60*60);
@ -602,17 +595,15 @@ ast_locate(device_t dev, int hard, u_int32_t pos)
static int
ast_prevent_allow(device_t dev, int lock)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_PREVENT_ALLOW, 0, 0, 0, lock,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static int
ast_load_unload(device_t dev, u_int8_t function)
{
struct ata_device *atadev = device_get_softc(dev);
struct ast_softc *stp = device_get_ivars(dev);
int8_t ccb[16] = { ATAPI_START_STOP, 0x01, 0, 0, function, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
@ -620,7 +611,7 @@ ast_load_unload(device_t dev, u_int8_t function)
if ((function & ATAPI_SS_EJECT) && !stp->cap.eject)
return 0;
error = ata_atapicmd(atadev, ccb, NULL, 0, 0, 10);
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 10);
if (error)
return error;
tsleep((caddr_t)&error, PRIBIO, "astlu", 1 * hz);
@ -632,12 +623,11 @@ ast_load_unload(device_t dev, u_int8_t function)
static int
ast_rewind(device_t dev)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_REZERO, 0x01, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
int error;
error = ata_atapicmd(atadev, ccb, NULL, 0, 0, 10);
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 10);
if (error)
return error;
return ast_wait_dsc(dev, 60*60);
@ -646,7 +636,6 @@ ast_rewind(device_t dev)
static int
ast_erase(device_t dev)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_ERASE, 3, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
int error;
@ -654,32 +643,28 @@ ast_erase(device_t dev)
if ((error = ast_rewind(dev)))
return error;
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 60*60);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 60*60);
}
static int
ast_test_ready(device_t dev)
{
struct ata_device *atadev = device_get_softc(dev);
int8_t ccb[16] = { ATAPI_TEST_UNIT_READY, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return ata_atapicmd(atadev, ccb, NULL, 0, 0, 30);
return ata_atapicmd(dev, ccb, NULL, 0, 0, 30);
}
static int
ast_wait_dsc(device_t dev, int timeout)
{
struct ata_device *atadev = device_get_softc(dev);
int error = 0;
int8_t ccb[16] = { ATAPI_POLL_DSC, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
timeout *= hz;
while (timeout > 0) {
error = ata_atapicmd(atadev, ccb, NULL, 0, 0, 0);
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 0);
if (error != EBUSY)
break;
tsleep(&error, PRIBIO, "atpwt", hz / 2);