Split softc/device_t for spc(4) and misc related cleanup.
This commit is contained in:
parent
149201cfa6
commit
73f476d471
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: spc.c,v 1.5 2005/12/11 12:17:14 christos Exp $ */
|
||||
/* $NetBSD: spc.c,v 1.6 2008/03/31 15:20:47 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Izumi Tsutsui.
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.5 2005/12/11 12:17:14 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.6 2008/03/31 15:20:47 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -58,8 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.5 2005/12/11 12:17:14 christos Exp $");
|
|||
#include <hp300/dev/dmareg.h>
|
||||
#include <hp300/dev/dmavar.h>
|
||||
|
||||
static int spc_dio_match(struct device *, struct cfdata *, void *);
|
||||
static void spc_dio_attach(struct device *, struct device *, void *);
|
||||
static int spc_dio_match(device_t, cfdata_t, void *);
|
||||
static void spc_dio_attach(device_t, device_t, void *);
|
||||
static void spc_dio_dmastart(struct spc_softc *, void *, size_t, int);
|
||||
static void spc_dio_dmadone(struct spc_softc *);
|
||||
static void spc_dio_dmago(void *);
|
||||
|
@ -78,11 +78,11 @@ struct spc_dio_softc {
|
|||
#define SCSI_DATAIN 0x04 /* DMA direction */
|
||||
};
|
||||
|
||||
CFATTACH_DECL(spc, sizeof(struct spc_dio_softc),
|
||||
CFATTACH_DECL_NEW(spc, sizeof(struct spc_dio_softc),
|
||||
spc_dio_match, spc_dio_attach, NULL, NULL);
|
||||
|
||||
static int
|
||||
spc_dio_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
spc_dio_match(device_t parent, cfdata_t cf, void *aux)
|
||||
{
|
||||
struct dio_attach_args *da = aux;
|
||||
|
||||
|
@ -98,39 +98,40 @@ spc_dio_match(struct device *parent, struct cfdata *cf, void *aux)
|
|||
}
|
||||
|
||||
static void
|
||||
spc_dio_attach(struct device *parent, struct device *self, void *aux)
|
||||
spc_dio_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct spc_dio_softc *dsc = (struct spc_dio_softc *)self;
|
||||
struct spc_dio_softc *dsc = device_private(self);
|
||||
struct spc_softc *sc = &dsc->sc_spc;
|
||||
struct dio_attach_args *da = aux;
|
||||
bus_space_tag_t iot = &dsc->sc_tag;
|
||||
bus_space_handle_t iohsc, iohspc;
|
||||
uint8_t id;
|
||||
|
||||
sc->sc_dev = self;
|
||||
memcpy(iot, da->da_bst, sizeof(struct bus_space_tag));
|
||||
dio_set_bus_space_oddbyte(iot);
|
||||
|
||||
if (bus_space_map(iot, da->da_addr, da->da_size, 0, &iohsc)) {
|
||||
printf(": can't map SCSI registers\n");
|
||||
aprint_error(": can't map SCSI registers\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bus_space_subregion(iot, iohsc, SPC_OFFSET, SPC_SIZE, &iohspc)) {
|
||||
printf(": can't map SPC registers\n");
|
||||
aprint_error(": can't map SPC registers\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf(": 98265A SCSI");
|
||||
aprint_normal(": 98265A SCSI");
|
||||
|
||||
bus_space_write_1(iot, iohsc, HPSCSI_ID, 0xff);
|
||||
DELAY(100);
|
||||
id = bus_space_read_1(iot, iohsc, HPSCSI_ID);
|
||||
if ((id & ID_WORD_DMA) == 0) {
|
||||
printf(", 32-bit DMA");
|
||||
aprint_normal(", 32-bit DMA");
|
||||
dsc->sc_dflags |= SCSI_DMA32;
|
||||
}
|
||||
id &= ID_MASK;
|
||||
printf(", SCSI ID %d\n", id);
|
||||
aprint_normal(", SCSI ID %d\n", id);
|
||||
|
||||
sc->sc_iot = iot;
|
||||
sc->sc_ioh = iohspc;
|
||||
|
@ -169,14 +170,14 @@ spc_dio_dmastart(struct spc_softc *sc, void *addr, size_t size, int datain)
|
|||
|
||||
if (dmareq(&dsc->sc_dq) != 0)
|
||||
/* DMA channel is available, so start DMA immediately */
|
||||
spc_dio_dmago((void *)dsc);
|
||||
spc_dio_dmago(dsc);
|
||||
/* else dma start function will be called later from dmafree(). */
|
||||
}
|
||||
|
||||
static void
|
||||
spc_dio_dmago(void *arg)
|
||||
{
|
||||
struct spc_dio_softc *dsc = (struct spc_dio_softc *)arg;
|
||||
struct spc_dio_softc *dsc = arg;
|
||||
struct spc_softc *sc = &dsc->sc_spc;
|
||||
bus_space_tag_t iot;
|
||||
bus_space_handle_t iohsc, iohspc;
|
||||
|
@ -250,7 +251,7 @@ spc_dio_dmadone(struct spc_softc *sc)
|
|||
while ((bus_space_read_1(iot, ioh, SSTS) & SSTS_BUSY) != 0) {
|
||||
if (--timeout < 0)
|
||||
printf("%s: DMA complete timeout\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
device_xname(sc->sc_dev));
|
||||
DELAY(1);
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +278,7 @@ spc_dio_dmadone(struct spc_softc *sc)
|
|||
static void
|
||||
spc_dio_dmastop(void *arg)
|
||||
{
|
||||
struct spc_dio_softc *dsc = (struct spc_dio_softc *)arg;
|
||||
struct spc_dio_softc *dsc = arg;
|
||||
struct spc_softc *sc = &dsc->sc_spc;
|
||||
uint8_t cmd;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: spc.c,v 1.6 2007/03/04 06:00:04 christos Exp $ */
|
||||
/* $NetBSD: spc.c,v 1.7 2008/03/31 15:20:47 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.6 2007/03/04 06:00:04 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.7 2008/03/31 15:20:47 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -58,18 +58,16 @@ __KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.6 2007/03/04 06:00:04 christos Exp $");
|
|||
|
||||
#include <luna68k/luna68k/isr.h>
|
||||
|
||||
static int spc_mainbus_match __P((struct device *, struct cfdata *, void *));
|
||||
static void spc_mainbus_attach __P((struct device *, struct device *, void *));
|
||||
#include "ioconf.h"
|
||||
|
||||
CFATTACH_DECL(spc, sizeof(struct spc_softc),
|
||||
static int spc_mainbus_match(device_t, cfdata_t, void *);
|
||||
static void spc_mainbus_attach(device_t, device_t, void *);
|
||||
|
||||
CFATTACH_DECL_NEW(spc, sizeof(struct spc_softc),
|
||||
spc_mainbus_match, spc_mainbus_attach, NULL, NULL);
|
||||
extern struct cfdriver spc_cd;
|
||||
|
||||
static int
|
||||
spc_mainbus_match(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
spc_mainbus_match(device_t parent, cfdata_t cf, void *aux)
|
||||
{
|
||||
struct mainbus_attach_args *ma = aux;
|
||||
|
||||
|
@ -84,14 +82,13 @@ spc_mainbus_match(parent, cf, aux)
|
|||
}
|
||||
|
||||
static void
|
||||
spc_mainbus_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
spc_mainbus_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct spc_softc *sc = (void *)self;
|
||||
struct spc_softc *sc = device_private(self);
|
||||
struct mainbus_attach_args *ma = aux;
|
||||
|
||||
printf ("\n");
|
||||
sc->sc_dev = self;
|
||||
aprint_normal ("\n");
|
||||
|
||||
sc->sc_iot = /* XXX */ 0;
|
||||
sc->sc_ioh = ma->ma_addr;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: spc.c,v 1.32 2007/03/11 08:09:25 isaki Exp $ */
|
||||
/* $NetBSD: spc.c,v 1.33 2008/03/31 15:20:47 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.32 2007/03/11 08:09:25 isaki Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.33 2008/03/31 15:20:47 tsutsui Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
|
@ -60,20 +60,20 @@ __KERNEL_RCSID(0, "$NetBSD: spc.c,v 1.32 2007/03/11 08:09:25 isaki Exp $");
|
|||
#include <dev/ic/mb89352var.h>
|
||||
#include <dev/ic/mb89352reg.h>
|
||||
|
||||
static int spc_intio_match(struct device *, struct cfdata *, void *);
|
||||
static void spc_intio_attach(struct device *, struct device *, void *);
|
||||
static int spc_intio_match(device_t, cfdata_t, void *);
|
||||
static void spc_intio_attach(device_t, device_t, void *);
|
||||
|
||||
CFATTACH_DECL(spc_intio, sizeof(struct spc_softc),
|
||||
CFATTACH_DECL_NEW(spc_intio, sizeof(struct spc_softc),
|
||||
spc_intio_match, spc_intio_attach, NULL, NULL);
|
||||
|
||||
static int
|
||||
spc_intio_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
spc_intio_match(device_t parent, cfdata_t cf, void *aux)
|
||||
{
|
||||
struct intio_attach_args *ia = aux;
|
||||
bus_space_tag_t iot = ia->ia_bst;
|
||||
bus_space_handle_t ioh;
|
||||
|
||||
ia->ia_size=0x20;
|
||||
ia->ia_size = 0x20;
|
||||
|
||||
if (intio_map_allocate_region(device_parent(parent), ia,
|
||||
INTIO_MAP_TESTONLY) < 0)
|
||||
|
@ -90,22 +90,23 @@ spc_intio_match(struct device *parent, struct cfdata *cf, void *aux)
|
|||
}
|
||||
|
||||
static void
|
||||
spc_intio_attach(struct device *parent, struct device *self, void *aux)
|
||||
spc_intio_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct spc_softc *sc = (struct spc_softc *)self;
|
||||
struct spc_softc *sc = device_private(self);
|
||||
struct intio_attach_args *ia = aux;
|
||||
bus_space_tag_t iot = ia->ia_bst;
|
||||
bus_space_handle_t ioh;
|
||||
|
||||
printf("\n");
|
||||
sc->sc_dev = self;
|
||||
|
||||
intio_map_allocate_region(device_parent(parent), ia,
|
||||
INTIO_MAP_ALLOCATE);
|
||||
if (bus_space_map(iot, ia->ia_addr, 0x20, BUS_SPACE_MAP_SHIFTED,
|
||||
&ioh)) {
|
||||
printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
|
||||
aprint_error(": can't map i/o space\n");
|
||||
return;
|
||||
}
|
||||
aprint_normal("\n");
|
||||
|
||||
sc->sc_iot = iot;
|
||||
sc->sc_ioh = ioh;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mb89352.c,v 1.46 2007/10/19 11:59:56 ad Exp $ */
|
||||
/* $NetBSD: mb89352.c,v 1.47 2008/03/31 15:20:47 tsutsui Exp $ */
|
||||
/* NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp */
|
||||
|
||||
/*-
|
||||
|
@ -70,7 +70,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.46 2007/10/19 11:59:56 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.47 2008/03/31 15:20:47 tsutsui Exp $");
|
||||
|
||||
#ifdef DDB
|
||||
#define integrate
|
||||
|
@ -168,7 +168,7 @@ void spc_dequeue(struct spc_softc *, struct spc_acb *);
|
|||
void spc_scsipi_request(struct scsipi_channel *, scsipi_adapter_req_t,
|
||||
void *);
|
||||
int spc_poll(struct spc_softc *, struct scsipi_xfer *, int);
|
||||
integrate void spc_sched_msgout(struct spc_softc *, u_char);
|
||||
integrate void spc_sched_msgout(struct spc_softc *, uint8_t);
|
||||
integrate void spc_setsync(struct spc_softc *, struct spc_tinfo *);
|
||||
void spc_select(struct spc_softc *, struct spc_acb *);
|
||||
void spc_timeout(void *);
|
||||
|
@ -180,8 +180,8 @@ int spc_reselect(struct spc_softc *, int);
|
|||
void spc_msgin(struct spc_softc *);
|
||||
void spc_abort(struct spc_softc *, struct spc_acb *);
|
||||
void spc_msgout(struct spc_softc *);
|
||||
int spc_dataout_pio(struct spc_softc *, u_char *, int);
|
||||
int spc_datain_pio(struct spc_softc *, u_char *, int);
|
||||
int spc_dataout_pio(struct spc_softc *, uint8_t *, int);
|
||||
int spc_datain_pio(struct spc_softc *, uint8_t *, int);
|
||||
#if SPC_DEBUG
|
||||
void spc_print_acb(struct spc_acb *);
|
||||
void spc_dump_driver(struct spc_softc *);
|
||||
|
@ -257,8 +257,8 @@ spc_attach(struct spc_softc *sc)
|
|||
* the chip's clock input and the size and offset of the sync period
|
||||
* register.
|
||||
*
|
||||
* For a 20MHz clock, this gives us 25, or 100nS, or 10MB/s, as a
|
||||
* maximum transfer rate, and 112.5, or 450nS, or 2.22MB/s, as a
|
||||
* For a 20MHz clock, this gives us 25, or 100ns, or 10MB/s, as a
|
||||
* maximum transfer rate, and 112.5, or 450ns, or 2.22MB/s, as a
|
||||
* minimum transfer rate.
|
||||
*/
|
||||
sc->sc_minsync = (2 * 250) / sc->sc_freq;
|
||||
|
@ -268,7 +268,7 @@ spc_attach(struct spc_softc *sc)
|
|||
/*
|
||||
* Fill in the adapter.
|
||||
*/
|
||||
adapt->adapt_dev = &sc->sc_dev;
|
||||
adapt->adapt_dev = sc->sc_dev;
|
||||
adapt->adapt_nchannels = 1;
|
||||
adapt->adapt_openings = 7;
|
||||
adapt->adapt_max_periph = 1;
|
||||
|
@ -287,8 +287,7 @@ spc_attach(struct spc_softc *sc)
|
|||
* config_found() to make sure the adatper is disabled.
|
||||
*/
|
||||
if (scsipi_adapter_addref(adapt) != 0) {
|
||||
printf("%s: unable to enable controller\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
aprint_error_dev(sc->sc_dev, "unable to enable controller\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -297,14 +296,14 @@ spc_attach(struct spc_softc *sc)
|
|||
/*
|
||||
* ask the adapter what subunits are present
|
||||
*/
|
||||
sc->sc_child = config_found(&sc->sc_dev, chan, scsiprint);
|
||||
sc->sc_child = config_found(sc->sc_dev, chan, scsiprint);
|
||||
scsipi_adapter_delref(adapt);
|
||||
}
|
||||
|
||||
int
|
||||
spc_activate(struct device *self, enum devact act)
|
||||
spc_activate(device_t self, enum devact act)
|
||||
{
|
||||
struct spc_softc *sc = (void *)self;
|
||||
struct spc_softc *sc = device_private(self);
|
||||
int s, rv = 0;
|
||||
|
||||
s = splhigh();
|
||||
|
@ -324,9 +323,9 @@ spc_activate(struct device *self, enum devact act)
|
|||
}
|
||||
|
||||
int
|
||||
spc_detach(struct device *self, int flags)
|
||||
spc_detach(device_t self, int flags)
|
||||
{
|
||||
struct spc_softc *sc = (void *)self;
|
||||
struct spc_softc *sc = device_private(self);
|
||||
int rv = 0;
|
||||
|
||||
if (sc->sc_child != NULL)
|
||||
|
@ -516,7 +515,7 @@ spc_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req,
|
|||
{
|
||||
struct scsipi_xfer *xs;
|
||||
struct scsipi_periph *periph;
|
||||
struct spc_softc *sc = (void *)chan->chan_adapter->adapt_dev;
|
||||
struct spc_softc *sc = device_private(chan->chan_adapter->adapt_dev);
|
||||
struct spc_acb *acb;
|
||||
int s, flags;
|
||||
|
||||
|
@ -635,7 +634,7 @@ spc_poll(struct spc_softc *sc, struct scsipi_xfer *xs, int count)
|
|||
*/
|
||||
|
||||
integrate void
|
||||
spc_sched_msgout(struct spc_softc *sc, u_char m)
|
||||
spc_sched_msgout(struct spc_softc *sc, uint8_t m)
|
||||
{
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
|
@ -711,7 +710,7 @@ spc_select(struct spc_softc *sc, struct spc_acb *acb)
|
|||
int
|
||||
spc_reselect(struct spc_softc *sc, int message)
|
||||
{
|
||||
u_char selid, target, lun;
|
||||
uint8_t selid, target, lun;
|
||||
struct spc_acb *acb;
|
||||
struct scsipi_periph *periph;
|
||||
struct spc_tinfo *ti;
|
||||
|
@ -725,7 +724,7 @@ spc_reselect(struct spc_softc *sc, int message)
|
|||
selid = sc->sc_selid & ~(1 << sc->sc_initiator);
|
||||
if (selid & (selid - 1)) {
|
||||
printf("%s: reselect with invalid selid %02x; "
|
||||
"sending DEVICE RESET\n", sc->sc_dev.dv_xname, selid);
|
||||
"sending DEVICE RESET\n", device_xname(sc->sc_dev), selid);
|
||||
SPC_BREAK();
|
||||
goto reset;
|
||||
}
|
||||
|
@ -746,7 +745,7 @@ spc_reselect(struct spc_softc *sc, int message)
|
|||
}
|
||||
if (acb == NULL) {
|
||||
printf("%s: reselect from target %d lun %d with no nexus; "
|
||||
"sending ABORT\n", sc->sc_dev.dv_xname, target, lun);
|
||||
"sending ABORT\n", device_xname(sc->sc_dev), target, lun);
|
||||
SPC_BREAK();
|
||||
goto abort;
|
||||
}
|
||||
|
@ -767,7 +766,7 @@ spc_reselect(struct spc_softc *sc, int message)
|
|||
/* Do an implicit RESTORE POINTERS. */
|
||||
sc->sc_dp = acb->data_addr;
|
||||
sc->sc_dleft = acb->data_length;
|
||||
sc->sc_cp = (u_char *)&acb->scsipi_cmd;
|
||||
sc->sc_cp = (uint8_t *)&acb->scsipi_cmd;
|
||||
sc->sc_cleft = acb->scsipi_cmd_length;
|
||||
|
||||
return (0);
|
||||
|
@ -853,7 +852,7 @@ spc_done(struct spc_softc *sc, struct spc_acb *acb)
|
|||
xs->error = XS_DRIVER_STUFFUP;
|
||||
#if SPC_DEBUG
|
||||
printf("%s: spc_done: bad stat 0x%x\n",
|
||||
sc->sc_dev.dv_xname, acb->target_stat);
|
||||
device_xname(sc->sc_dev), acb->target_stat);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -1050,7 +1049,8 @@ nextbyte:
|
|||
if (sc->sc_dleft < 0) {
|
||||
periph = acb->xs->xs_periph;
|
||||
printf("%s: %ld extra bytes from %d:%d\n",
|
||||
sc->sc_dev.dv_xname, (long)-sc->sc_dleft,
|
||||
device_xname(sc->sc_dev),
|
||||
(long)-sc->sc_dleft,
|
||||
periph->periph_target, periph->periph_lun);
|
||||
sc->sc_dleft = 0;
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ nextbyte:
|
|||
case MSG_RESTOREPOINTERS:
|
||||
sc->sc_dp = acb->data_addr;
|
||||
sc->sc_dleft = acb->data_length;
|
||||
sc->sc_cp = (u_char *)&acb->scsipi_cmd;
|
||||
sc->sc_cp = (uint8_t *)&acb->scsipi_cmd;
|
||||
sc->sc_cleft = acb->scsipi_cmd_length;
|
||||
break;
|
||||
|
||||
|
@ -1159,7 +1159,8 @@ nextbyte:
|
|||
|
||||
default:
|
||||
printf("%s: unrecognized MESSAGE EXTENDED; "
|
||||
"sending REJECT\n", sc->sc_dev.dv_xname);
|
||||
"sending REJECT\n",
|
||||
device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
goto reject;
|
||||
}
|
||||
|
@ -1167,7 +1168,7 @@ nextbyte:
|
|||
|
||||
default:
|
||||
printf("%s: unrecognized MESSAGE; sending REJECT\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
reject:
|
||||
spc_sched_msgout(sc, SEND_REJECT);
|
||||
|
@ -1178,7 +1179,7 @@ nextbyte:
|
|||
case SPC_RESELECTED:
|
||||
if (!MSG_ISIDENTIFY(sc->sc_imess[0])) {
|
||||
printf("%s: reselect without IDENTIFY; "
|
||||
"sending DEVICE RESET\n", sc->sc_dev.dv_xname);
|
||||
"sending DEVICE RESET\n", device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
goto reset;
|
||||
}
|
||||
|
@ -1188,7 +1189,7 @@ nextbyte:
|
|||
|
||||
default:
|
||||
printf("%s: unexpected MESSAGE IN; sending DEVICE RESET\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
reset:
|
||||
spc_sched_msgout(sc, SEND_DEV_RESET);
|
||||
|
@ -1336,7 +1337,7 @@ nextmsg:
|
|||
|
||||
default:
|
||||
printf("%s: unexpected MESSAGE OUT; sending NOOP\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
sc->sc_omess[0] = MSG_NOOP;
|
||||
n = 1;
|
||||
|
@ -1440,11 +1441,11 @@ out:
|
|||
* and the rarer cases (as a result) somewhat more comlex
|
||||
*/
|
||||
int
|
||||
spc_dataout_pio(struct spc_softc *sc, u_char *p, int n)
|
||||
spc_dataout_pio(struct spc_softc *sc, uint8_t *p, int n)
|
||||
{
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
u_char intstat = 0;
|
||||
uint8_t intstat = 0;
|
||||
int out = 0;
|
||||
#define DOUTAMOUNT 8 /* Full FIFO */
|
||||
|
||||
|
@ -1549,7 +1550,7 @@ phasechange:
|
|||
* targets which don't disconnect or for huge transfers.
|
||||
*/
|
||||
int
|
||||
spc_datain_pio(struct spc_softc *sc, u_char *p, int n)
|
||||
spc_datain_pio(struct spc_softc *sc, uint8_t *p, int n)
|
||||
{
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
|
@ -1636,7 +1637,7 @@ spc_intr(void *arg)
|
|||
struct spc_softc *sc = arg;
|
||||
bus_space_tag_t iot = sc->sc_iot;
|
||||
bus_space_handle_t ioh = sc->sc_ioh;
|
||||
u_char ints;
|
||||
uint8_t ints;
|
||||
struct spc_acb *acb;
|
||||
struct scsipi_periph *periph;
|
||||
struct spc_tinfo *ti;
|
||||
|
@ -1672,7 +1673,7 @@ loop:
|
|||
SPC_MISC(("ints = 0x%x ", ints));
|
||||
|
||||
if ((ints & INTS_RST) != 0) {
|
||||
printf("%s: SCSI bus reset\n", sc->sc_dev.dv_xname);
|
||||
printf("%s: SCSI bus reset\n", device_xname(sc->sc_dev));
|
||||
goto reset;
|
||||
}
|
||||
|
||||
|
@ -1681,7 +1682,7 @@ loop:
|
|||
*/
|
||||
if ((bus_space_read_1(iot, ioh, SERR) & (SERR_SCSI_PAR|SERR_SPC_PAR))
|
||||
!= 0) {
|
||||
printf("%s: SCSI bus parity error\n", sc->sc_dev.dv_xname);
|
||||
printf("%s: SCSI bus parity error\n", device_xname(sc->sc_dev));
|
||||
if (sc->sc_prevphase == PH_MSGIN) {
|
||||
sc->sc_flags |= SPC_DROP_MSGIN;
|
||||
spc_sched_msgout(sc, SEND_PARITY_ERROR);
|
||||
|
@ -1709,7 +1710,7 @@ loop:
|
|||
* We don't currently support target mode.
|
||||
*/
|
||||
printf("%s: target mode selected; going to BUS FREE\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
device_xname(sc->sc_dev));
|
||||
|
||||
goto sched;
|
||||
} else if ((ints & INTS_RESEL) != 0) {
|
||||
|
@ -1742,7 +1743,7 @@ loop:
|
|||
*/
|
||||
if (sc->sc_state != SPC_SELECTING) {
|
||||
printf("%s: selection out while idle; "
|
||||
"resetting\n", sc->sc_dev.dv_xname);
|
||||
"resetting\n", device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
goto reset;
|
||||
}
|
||||
|
@ -1773,7 +1774,7 @@ loop:
|
|||
/* Do an implicit RESTORE POINTERS. */
|
||||
sc->sc_dp = acb->data_addr;
|
||||
sc->sc_dleft = acb->data_length;
|
||||
sc->sc_cp = (u_char *)&acb->scsipi_cmd;
|
||||
sc->sc_cp = (uint8_t *)&acb->scsipi_cmd;
|
||||
sc->sc_cleft = acb->scsipi_cmd_length;
|
||||
|
||||
/* On our first connection, schedule a timeout. */
|
||||
|
@ -1787,7 +1788,7 @@ loop:
|
|||
|
||||
if (sc->sc_state != SPC_SELECTING) {
|
||||
printf("%s: selection timeout while idle; "
|
||||
"resetting\n", sc->sc_dev.dv_xname);
|
||||
"resetting\n", device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
goto reset;
|
||||
}
|
||||
|
@ -1802,7 +1803,7 @@ loop:
|
|||
if (sc->sc_state != SPC_IDLE) {
|
||||
printf("%s: BUS FREE while not idle; "
|
||||
"state=%d\n",
|
||||
sc->sc_dev.dv_xname, sc->sc_state);
|
||||
device_xname(sc->sc_dev), sc->sc_state);
|
||||
SPC_BREAK();
|
||||
goto out;
|
||||
}
|
||||
|
@ -1873,7 +1874,7 @@ loop:
|
|||
*/
|
||||
printf("%s: unexpected disconnect; "
|
||||
"sending REQUEST SENSE\n",
|
||||
sc->sc_dev.dv_xname);
|
||||
device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
acb->target_stat = SCSI_CHECK;
|
||||
acb->xs->error = XS_NOERROR;
|
||||
|
@ -2011,7 +2012,8 @@ dophase:
|
|||
goto loop;
|
||||
}
|
||||
|
||||
printf("%s: unexpected bus phase; resetting\n", sc->sc_dev.dv_xname);
|
||||
printf("%s: unexpected bus phase; resetting\n",
|
||||
device_xname(sc->sc_dev));
|
||||
SPC_BREAK();
|
||||
reset:
|
||||
spc_init(sc, 1);
|
||||
|
@ -2069,7 +2071,7 @@ spc_timeout(void *arg)
|
|||
struct spc_softc *sc;
|
||||
int s;
|
||||
|
||||
sc = (void *)periph->periph_channel->chan_adapter->adapt_dev;
|
||||
sc = device_private(periph->periph_channel->chan_adapter->adapt_dev);
|
||||
scsipi_printaddr(periph);
|
||||
printf("timed out");
|
||||
|
||||
|
@ -2098,7 +2100,7 @@ spc_timeout(void *arg)
|
|||
void
|
||||
spc_show_scsi_cmd(struct spc_acb *acb)
|
||||
{
|
||||
u_char *b = (u_char *)&acb->scsipi_cmd;
|
||||
uint8_t *b = (uint8_t *)&acb->scsipi_cmd;
|
||||
int i;
|
||||
|
||||
scsipi_printaddr(acb->xs->xs_periph);
|
||||
|
@ -2127,7 +2129,7 @@ void
|
|||
spc_print_active_acb(void)
|
||||
{
|
||||
struct spc_acb *acb;
|
||||
struct spc_softc *sc = spc_cd.cd_devs[0]; /* XXX */
|
||||
struct spc_softc *sc = device_private(spc_cd.cd_devs[0]); /* XXX */
|
||||
|
||||
printf("ready list:\n");
|
||||
TAILQ_FOREACH(acb, &sc->ready_list, chain)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mb89352var.h,v 1.10 2005/12/11 12:21:27 christos Exp $ */
|
||||
/* $NetBSD: mb89352var.h,v 1.11 2008/03/31 15:20:47 tsutsui Exp $ */
|
||||
/* NecBSD: mb89352var.h,v 1.4 1998/03/14 07:31:22 kmatsuda Exp */
|
||||
|
||||
/*-
|
||||
|
@ -69,10 +69,10 @@
|
|||
struct spc_acb {
|
||||
struct scsipi_generic scsipi_cmd;
|
||||
int scsipi_cmd_length;
|
||||
u_char *data_addr; /* Saved data pointer */
|
||||
uint8_t *data_addr; /* Saved data pointer */
|
||||
int data_length; /* Residue */
|
||||
|
||||
u_char target_stat; /* SCSI status byte */
|
||||
uint8_t target_stat; /* SCSI status byte */
|
||||
|
||||
#ifdef notdef
|
||||
struct spc_dma_seg dma[SPC_NSEG]; /* Physical addresses+len */
|
||||
|
@ -80,7 +80,7 @@ struct spc_acb {
|
|||
|
||||
TAILQ_ENTRY(spc_acb) chain;
|
||||
struct scsipi_xfer *xs; /* SCSI xfer ctrl block from above */
|
||||
int flags;
|
||||
u_int flags;
|
||||
#define ACB_ALLOC 0x01
|
||||
#define ACB_NEXUS 0x02
|
||||
#define ACB_SENSE 0x04
|
||||
|
@ -104,13 +104,13 @@ struct spc_tinfo {
|
|||
u_char flags;
|
||||
#define DO_SYNC 0x01 /* (Re)Negotiate synchronous options */
|
||||
#define DO_WIDE 0x02 /* (Re)Negotiate wide options */
|
||||
u_char period; /* Period suggestion */
|
||||
u_char offset; /* Offset suggestion */
|
||||
u_char width; /* Width suggestion */
|
||||
uint8_t period; /* Period suggestion */
|
||||
uint8_t offset; /* Offset suggestion */
|
||||
uint8_t width; /* Width suggestion */
|
||||
};
|
||||
|
||||
struct spc_softc {
|
||||
struct device sc_dev;
|
||||
device_t sc_dev;
|
||||
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
|
@ -124,15 +124,15 @@ struct spc_softc {
|
|||
struct spc_tinfo sc_tinfo[8];
|
||||
|
||||
/* Data about the current nexus (updated for every cmd switch) */
|
||||
u_char *sc_dp; /* Current data pointer */
|
||||
uint8_t *sc_dp; /* Current data pointer */
|
||||
size_t sc_dleft; /* Data bytes left to transfer */
|
||||
u_char *sc_cp; /* Current command pointer */
|
||||
uint8_t *sc_cp; /* Current command pointer */
|
||||
size_t sc_cleft; /* Command bytes left to transfer */
|
||||
|
||||
/* Adapter state */
|
||||
u_char sc_phase; /* Current bus phase */
|
||||
u_char sc_prevphase; /* Previous bus phase */
|
||||
u_char sc_state; /* State applicable to the adapter */
|
||||
uint8_t sc_phase; /* Current bus phase */
|
||||
uint8_t sc_prevphase; /* Previous bus phase */
|
||||
uint8_t sc_state; /* State applicable to the adapter */
|
||||
#define SPC_INIT 0
|
||||
#define SPC_IDLE 1
|
||||
#define SPC_SELECTING 2 /* SCSI command is arbiting */
|
||||
|
@ -141,19 +141,19 @@ struct spc_softc {
|
|||
#define SPC_DISCONNECT 5 /* MSG_DISCONNECT received */
|
||||
#define SPC_CMDCOMPLETE 6 /* MSG_CMDCOMPLETE received */
|
||||
#define SPC_CLEANING 7
|
||||
u_char sc_flags;
|
||||
uint8_t sc_flags;
|
||||
#define SPC_DROP_MSGIN 0x01 /* Discard all msgs (parity err detected) */
|
||||
#define SPC_ABORTING 0x02 /* Bailing out */
|
||||
#define SPC_DOINGDMA 0x04 /* doing DMA */
|
||||
#define SPC_INACTIVE 0x80 /* The FIFO data path is active! */
|
||||
u_char sc_selid; /* Reselection ID */
|
||||
uint8_t sc_selid; /* Reselection ID */
|
||||
struct device *sc_child;/* Our child */
|
||||
|
||||
/* Message stuff */
|
||||
u_char sc_msgpriq; /* Messages we want to send */
|
||||
u_char sc_msgoutq; /* Messages sent during last MESSAGE OUT */
|
||||
u_char sc_lastmsg; /* Message last transmitted */
|
||||
u_char sc_currmsg; /* Message currently ready to transmit */
|
||||
uint8_t sc_msgpriq; /* Messages we want to send */
|
||||
uint8_t sc_msgoutq; /* Messages sent during last MESSAGE OUT */
|
||||
uint8_t sc_lastmsg; /* Message last transmitted */
|
||||
uint8_t sc_currmsg; /* Message currently ready to transmit */
|
||||
#define SEND_DEV_RESET 0x01
|
||||
#define SEND_PARITY_ERROR 0x02
|
||||
#define SEND_INIT_DET_ERR 0x04
|
||||
|
@ -163,10 +163,10 @@ struct spc_softc {
|
|||
#define SEND_SDTR 0x40
|
||||
#define SEND_WDTR 0x80
|
||||
#define SPC_MAX_MSG_LEN 8
|
||||
u_char sc_omess[SPC_MAX_MSG_LEN];
|
||||
u_char *sc_omp; /* Outgoing message pointer */
|
||||
u_char sc_imess[SPC_MAX_MSG_LEN];
|
||||
u_char *sc_imp; /* Incoming message pointer */
|
||||
uint8_t sc_omess[SPC_MAX_MSG_LEN];
|
||||
uint8_t *sc_omp; /* Outgoing message pointer */
|
||||
uint8_t sc_imess[SPC_MAX_MSG_LEN];
|
||||
uint8_t *sc_imp; /* Incoming message pointer */
|
||||
|
||||
/* Hardware stuff */
|
||||
int sc_initiator; /* Our scsi id */
|
||||
|
@ -188,9 +188,26 @@ struct spc_softc {
|
|||
#define SPC_SHOWSTART 0x20
|
||||
#define SPC_DOBREAK 0x40
|
||||
extern int spc_debug; /* SPC_SHOWSTART|SPC_SHOWMISC|SPC_SHOWTRACE; */
|
||||
#define SPC_PRINT(b, s) do {if ((spc_debug & (b)) != 0) printf s;} while (0)
|
||||
#define SPC_BREAK() do {if ((spc_debug & SPC_DOBREAK) != 0) Debugger();} while (0)
|
||||
#define SPC_ASSERT(x) do {if (x) {} else {printf("%s at line %d: assertion failed\n", sc->sc_dev.dv_xname, __LINE__); Debugger();}} while (0)
|
||||
#define SPC_PRINT(b, s) \
|
||||
do { \
|
||||
if ((spc_debug & (b)) != 0) \
|
||||
printf s; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#define SPC_BREAK() \
|
||||
do { \
|
||||
if ((spc_debug & SPC_DOBREAK) != 0) \
|
||||
Debugger(); \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#define SPC_ASSERT(x) \
|
||||
do { \
|
||||
if (x) { \
|
||||
; \
|
||||
} else { \
|
||||
printf("%s at line %d: assertion failed\n", \
|
||||
device_xname(sc->sc_dev), __LINE__); \
|
||||
Debugger(); \
|
||||
} \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#else
|
||||
#define SPC_PRINT(b, s)
|
||||
#define SPC_BREAK()
|
||||
|
@ -205,8 +222,8 @@ extern int spc_debug; /* SPC_SHOWSTART|SPC_SHOWMISC|SPC_SHOWTRACE; */
|
|||
#define SPC_START(s) SPC_PRINT(SPC_SHOWSTART, s)
|
||||
|
||||
void spc_attach(struct spc_softc *);
|
||||
int spc_activate(struct device *, enum devact);
|
||||
int spc_detach(struct device *, int);
|
||||
int spc_activate(device_t, enum devact);
|
||||
int spc_detach(device_t, int);
|
||||
int spc_intr(void *);
|
||||
int spc_find(bus_space_tag_t, bus_space_handle_t, int);
|
||||
void spc_init(struct spc_softc *, int);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: spc_pcmcia.c,v 1.18 2007/10/19 12:01:06 ad Exp $ */
|
||||
/* $NetBSD: spc_pcmcia.c,v 1.19 2008/03/31 15:20:47 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc_pcmcia.c,v 1.18 2007/10/19 12:01:06 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spc_pcmcia.c,v 1.19 2008/03/31 15:20:47 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -68,62 +68,59 @@ struct spc_pcmcia_softc {
|
|||
#define SPC_PCMCIA_ATTACHED 3
|
||||
};
|
||||
|
||||
int spc_pcmcia_match(struct device *, struct cfdata *, void *);
|
||||
int spc_pcmcia_validate_config(struct pcmcia_config_entry *);
|
||||
void spc_pcmcia_attach(struct device *, struct device *, void *);
|
||||
int spc_pcmcia_detach(struct device *, int);
|
||||
int spc_pcmcia_enable(struct device *, int);
|
||||
static int spc_pcmcia_match(device_t, cfdata_t, void *);
|
||||
static int spc_pcmcia_validate_config(struct pcmcia_config_entry *);
|
||||
static void spc_pcmcia_attach(device_t, device_t, void *);
|
||||
static int spc_pcmcia_detach(device_t, int);
|
||||
static int spc_pcmcia_enable(device_t, int);
|
||||
|
||||
CFATTACH_DECL(spc_pcmcia, sizeof(struct spc_pcmcia_softc),
|
||||
CFATTACH_DECL_NEW(spc_pcmcia, sizeof(struct spc_pcmcia_softc),
|
||||
spc_pcmcia_match, spc_pcmcia_attach, spc_pcmcia_detach, spc_activate);
|
||||
|
||||
const struct pcmcia_product spc_pcmcia_products[] = {
|
||||
static const struct pcmcia_product spc_pcmcia_products[] = {
|
||||
{ PCMCIA_VENDOR_FUJITSU, PCMCIA_PRODUCT_FUJITSU_SCSI600,
|
||||
PCMCIA_CIS_FUJITSU_SCSI600 },
|
||||
};
|
||||
const size_t spc_pcmcia_nproducts =
|
||||
sizeof(spc_pcmcia_products) / sizeof(spc_pcmcia_products[0]);
|
||||
static const size_t spc_pcmcia_nproducts = __arraycount(spc_pcmcia_products);
|
||||
|
||||
int
|
||||
spc_pcmcia_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
spc_pcmcia_match(device_t parent, cfdata_t cf, void *aux)
|
||||
{
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
|
||||
if (pcmcia_product_lookup(pa, spc_pcmcia_products, spc_pcmcia_nproducts,
|
||||
sizeof(spc_pcmcia_products[0]), NULL))
|
||||
return (1);
|
||||
return (0);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spc_pcmcia_validate_config(cfe)
|
||||
struct pcmcia_config_entry *cfe;
|
||||
spc_pcmcia_validate_config(struct pcmcia_config_entry *cfe)
|
||||
{
|
||||
|
||||
if (cfe->iftype != PCMCIA_IFTYPE_IO ||
|
||||
cfe->num_memspace != 0 ||
|
||||
cfe->num_iospace != 1)
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
return EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
spc_pcmcia_attach(struct device *parent, struct device *self,
|
||||
void *aux)
|
||||
spc_pcmcia_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct spc_pcmcia_softc *sc = (void *)self;
|
||||
struct spc_softc *spc = (void *)self;
|
||||
struct spc_pcmcia_softc *sc = device_private(self);
|
||||
struct spc_softc *spc = &sc->sc_spc;
|
||||
struct pcmcia_attach_args *pa = aux;
|
||||
struct pcmcia_config_entry *cfe;
|
||||
struct pcmcia_function *pf = pa->pf;
|
||||
int error;
|
||||
|
||||
spc->sc_dev = self;
|
||||
sc->sc_pf = pf;
|
||||
|
||||
error = pcmcia_function_configure(pf, spc_pcmcia_validate_config);
|
||||
if (error) {
|
||||
aprint_error("%s: configure failed, error=%d\n", self->dv_xname,
|
||||
error);
|
||||
aprint_error_dev(self, "configure failed, error=%d\n", error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -147,36 +144,32 @@ spc_pcmcia_attach(struct device *parent, struct device *self,
|
|||
sc->sc_state = SPC_PCMCIA_ATTACHED;
|
||||
return;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
pcmcia_function_unconfigure(pf);
|
||||
}
|
||||
|
||||
int
|
||||
spc_pcmcia_detach(self, flags)
|
||||
struct device *self;
|
||||
int flags;
|
||||
spc_pcmcia_detach(device_t self, int flags)
|
||||
{
|
||||
struct spc_pcmcia_softc *sc = (void *)self;
|
||||
struct spc_pcmcia_softc *sc = device_private(self);
|
||||
int error;
|
||||
|
||||
if (sc->sc_state != SPC_PCMCIA_ATTACHED)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
error = spc_detach(self, flags);
|
||||
if (error)
|
||||
return (error);
|
||||
return error;
|
||||
|
||||
pcmcia_function_unconfigure(sc->sc_pf);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spc_pcmcia_enable(arg, onoff)
|
||||
struct device *arg;
|
||||
int onoff;
|
||||
spc_pcmcia_enable(device_t self, int onoff)
|
||||
{
|
||||
struct spc_pcmcia_softc *sc = (void *)arg;
|
||||
struct spc_pcmcia_softc *sc = device_private(self);
|
||||
int error;
|
||||
|
||||
if (onoff) {
|
||||
|
@ -184,13 +177,13 @@ spc_pcmcia_enable(arg, onoff)
|
|||
sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
|
||||
spc_intr, &sc->sc_spc);
|
||||
if (!sc->sc_ih)
|
||||
return (EIO);
|
||||
return EIO;
|
||||
|
||||
error = pcmcia_function_enable(sc->sc_pf);
|
||||
if (error) {
|
||||
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
|
||||
sc->sc_ih = 0;
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Initialize only chip. */
|
||||
|
@ -201,5 +194,5 @@ spc_pcmcia_enable(arg, onoff)
|
|||
sc->sc_ih = 0;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue