- Always validate the return value read from the outbound FIFO.
- Copy access method info into the softc so we don't double dereference. - Remove static on functions.
This commit is contained in:
parent
351db2d000
commit
49849b4d3a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cac_eisa.c,v 1.4 2001/11/15 09:48:03 lukem Exp $ */
|
||||
/* $NetBSD: cac_eisa.c,v 1.5 2002/01/25 16:10:37 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -68,7 +68,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac_eisa.c,v 1.4 2001/11/15 09:48:03 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac_eisa.c,v 1.5 2002/01/25 16:10:37 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -87,20 +87,20 @@ __KERNEL_RCSID(0, "$NetBSD: cac_eisa.c,v 1.4 2001/11/15 09:48:03 lukem Exp $");
|
||||
#define CAC_EISA_IOSIZE 0x0017
|
||||
#define CAC_EISA_IOCONF 0x38
|
||||
|
||||
static void cac_eisa_attach(struct device *, struct device *, void *);
|
||||
static int cac_eisa_match(struct device *, struct cfdata *, void *);
|
||||
void cac_eisa_attach(struct device *, struct device *, void *);
|
||||
int cac_eisa_match(struct device *, struct cfdata *, void *);
|
||||
|
||||
static struct cac_ccb *cac_eisa_l0_completed(struct cac_softc *);
|
||||
static int cac_eisa_l0_fifo_full(struct cac_softc *);
|
||||
static void cac_eisa_l0_intr_enable(struct cac_softc *, int);
|
||||
static int cac_eisa_l0_intr_pending(struct cac_softc *);
|
||||
static void cac_eisa_l0_submit(struct cac_softc *, struct cac_ccb *);
|
||||
struct cac_ccb *cac_eisa_l0_completed(struct cac_softc *);
|
||||
int cac_eisa_l0_fifo_full(struct cac_softc *);
|
||||
void cac_eisa_l0_intr_enable(struct cac_softc *, int);
|
||||
int cac_eisa_l0_intr_pending(struct cac_softc *);
|
||||
void cac_eisa_l0_submit(struct cac_softc *, struct cac_ccb *);
|
||||
|
||||
struct cfattach cac_eisa_ca = {
|
||||
sizeof(struct cac_softc), cac_eisa_match, cac_eisa_attach
|
||||
};
|
||||
|
||||
static struct cac_linkage cac_eisa_l0 = {
|
||||
static const struct cac_linkage cac_eisa_l0 = {
|
||||
cac_eisa_l0_completed,
|
||||
cac_eisa_l0_fifo_full,
|
||||
cac_eisa_l0_intr_enable,
|
||||
@ -111,7 +111,7 @@ static struct cac_linkage cac_eisa_l0 = {
|
||||
struct cac_eisa_type {
|
||||
const char *ct_prodstr;
|
||||
const char *ct_typestr;
|
||||
struct cac_linkage *ct_linkage;
|
||||
const struct cac_linkage *ct_linkage;
|
||||
} static cac_eisa_type[] = {
|
||||
{ "CPQ4001", "IDA", &cac_eisa_l0 },
|
||||
{ "CPQ4002", "IDA-2", &cac_eisa_l0 },
|
||||
@ -120,7 +120,7 @@ struct cac_eisa_type {
|
||||
{ "CPQ4030", "SMART-2/E", &cac_l0 },
|
||||
};
|
||||
|
||||
static int
|
||||
int
|
||||
cac_eisa_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct eisa_attach_args *ea;
|
||||
@ -135,7 +135,7 @@ cac_eisa_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_eisa_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct eisa_attach_args *ea;
|
||||
@ -206,7 +206,7 @@ cac_eisa_attach(struct device *parent, struct device *self, void *aux)
|
||||
break;
|
||||
|
||||
printf(": Compaq %s\n", cac_eisa_type[i].ct_typestr);
|
||||
sc->sc_cl = cac_eisa_type[i].ct_linkage;
|
||||
memcpy(&sc->sc_cl, cac_eisa_type[i].ct_linkage, sizeof(sc->sc_cl));
|
||||
cac_init(sc, intrstr, 0);
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ cac_eisa_attach(struct device *parent, struct device *self, void *aux)
|
||||
* Linkage specific to EISA boards.
|
||||
*/
|
||||
|
||||
static int
|
||||
int
|
||||
cac_eisa_l0_fifo_full(struct cac_softc *sc)
|
||||
{
|
||||
|
||||
@ -222,7 +222,7 @@ cac_eisa_l0_fifo_full(struct cac_softc *sc)
|
||||
CAC_EISA_CHANNEL_CLEAR) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_eisa_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
{
|
||||
u_int16_t size;
|
||||
@ -243,7 +243,7 @@ cac_eisa_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
cac_outb(sc, CAC_EISAREG_LOCAL_DOORBELL, CAC_EISA_CHANNEL_BUSY);
|
||||
}
|
||||
|
||||
static struct cac_ccb *
|
||||
struct cac_ccb *
|
||||
cac_eisa_l0_completed(struct cac_softc *sc)
|
||||
{
|
||||
struct cac_ccb *ccb;
|
||||
@ -272,7 +272,7 @@ cac_eisa_l0_completed(struct cac_softc *sc)
|
||||
return (ccb);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
cac_eisa_l0_intr_pending(struct cac_softc *sc)
|
||||
{
|
||||
|
||||
@ -280,7 +280,7 @@ cac_eisa_l0_intr_pending(struct cac_softc *sc)
|
||||
CAC_EISA_CHANNEL_BUSY);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_eisa_l0_intr_enable(struct cac_softc *sc, int state)
|
||||
{
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cac.c,v 1.19 2001/11/13 13:14:35 lukem Exp $ */
|
||||
/* $NetBSD: cac.c,v 1.20 2002/01/25 16:10:35 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.19 2001/11/13 13:14:35 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.20 2002/01/25 16:10:35 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -62,24 +62,24 @@ __KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.19 2001/11/13 13:14:35 lukem Exp $");
|
||||
#include <dev/ic/cacreg.h>
|
||||
#include <dev/ic/cacvar.h>
|
||||
|
||||
static struct cac_ccb *cac_ccb_alloc(struct cac_softc *, int);
|
||||
static void cac_ccb_done(struct cac_softc *, struct cac_ccb *);
|
||||
static void cac_ccb_free(struct cac_softc *, struct cac_ccb *);
|
||||
static int cac_ccb_poll(struct cac_softc *, struct cac_ccb *, int);
|
||||
static int cac_ccb_start(struct cac_softc *, struct cac_ccb *);
|
||||
static int cac_print(void *, const char *);
|
||||
static void cac_shutdown(void *);
|
||||
static int cac_submatch(struct device *, struct cfdata *, void *);
|
||||
struct cac_ccb *cac_ccb_alloc(struct cac_softc *, int);
|
||||
void cac_ccb_done(struct cac_softc *, struct cac_ccb *);
|
||||
void cac_ccb_free(struct cac_softc *, struct cac_ccb *);
|
||||
int cac_ccb_poll(struct cac_softc *, struct cac_ccb *, int);
|
||||
int cac_ccb_start(struct cac_softc *, struct cac_ccb *);
|
||||
int cac_print(void *, const char *);
|
||||
void cac_shutdown(void *);
|
||||
int cac_submatch(struct device *, struct cfdata *, void *);
|
||||
|
||||
static struct cac_ccb *cac_l0_completed(struct cac_softc *);
|
||||
static int cac_l0_fifo_full(struct cac_softc *);
|
||||
static void cac_l0_intr_enable(struct cac_softc *, int);
|
||||
static int cac_l0_intr_pending(struct cac_softc *);
|
||||
static void cac_l0_submit(struct cac_softc *, struct cac_ccb *);
|
||||
struct cac_ccb *cac_l0_completed(struct cac_softc *);
|
||||
int cac_l0_fifo_full(struct cac_softc *);
|
||||
void cac_l0_intr_enable(struct cac_softc *, int);
|
||||
int cac_l0_intr_pending(struct cac_softc *);
|
||||
void cac_l0_submit(struct cac_softc *, struct cac_ccb *);
|
||||
|
||||
static void *cac_sdh; /* shutdown hook */
|
||||
|
||||
struct cac_linkage cac_l0 = {
|
||||
const struct cac_linkage cac_l0 = {
|
||||
cac_l0_completed,
|
||||
cac_l0_fifo_full,
|
||||
cac_l0_intr_enable,
|
||||
@ -186,14 +186,14 @@ cac_init(struct cac_softc *sc, const char *intrstr, int startfw)
|
||||
if (cac_sdh == NULL)
|
||||
cac_sdh = shutdownhook_establish(cac_shutdown, NULL);
|
||||
|
||||
(*sc->sc_cl->cl_intr_enable)(sc, CAC_INTR_ENABLE);
|
||||
(*sc->sc_cl.cl_intr_enable)(sc, CAC_INTR_ENABLE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Shut down all `cac' controllers.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
cac_shutdown(void *cookie)
|
||||
{
|
||||
extern struct cfdriver cac_cd;
|
||||
@ -214,7 +214,7 @@ cac_shutdown(void *cookie)
|
||||
/*
|
||||
* Print autoconfiguration message for a sub-device.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
cac_print(void *aux, const char *pnp)
|
||||
{
|
||||
struct cac_attach_args *caca;
|
||||
@ -230,7 +230,7 @@ cac_print(void *aux, const char *pnp)
|
||||
/*
|
||||
* Match a sub-device.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
cac_submatch(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct cac_attach_args *caca;
|
||||
@ -256,14 +256,14 @@ cac_intr(void *cookie)
|
||||
|
||||
sc = (struct cac_softc *)cookie;
|
||||
|
||||
if (!(*sc->sc_cl->cl_intr_pending)(sc)) {
|
||||
if (!(*sc->sc_cl.cl_intr_pending)(sc)) {
|
||||
#ifdef DEBUG
|
||||
printf("%s: spurious intr\n", sc->sc_dv.dv_xname);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
while ((ccb = (*sc->sc_cl->cl_completed)(sc)) != NULL) {
|
||||
while ((ccb = (*sc->sc_cl.cl_completed)(sc)) != NULL) {
|
||||
cac_ccb_done(sc, ccb);
|
||||
cac_ccb_start(sc, NULL);
|
||||
}
|
||||
@ -331,14 +331,14 @@ cac_cmd(struct cac_softc *sc, int command, void *data, int datasize,
|
||||
s = splbio();
|
||||
|
||||
/* Synchronous commands musn't wait. */
|
||||
if ((*sc->sc_cl->cl_fifo_full)(sc)) {
|
||||
if ((*sc->sc_cl.cl_fifo_full)(sc)) {
|
||||
cac_ccb_free(sc, ccb);
|
||||
rv = -1;
|
||||
} else {
|
||||
#ifdef DIAGNOSTIC
|
||||
ccb->ccb_flags |= CAC_CCB_ACTIVE;
|
||||
#endif
|
||||
(*sc->sc_cl->cl_submit)(sc, ccb);
|
||||
(*sc->sc_cl.cl_submit)(sc, ccb);
|
||||
rv = cac_ccb_poll(sc, ccb, 2000);
|
||||
cac_ccb_free(sc, ccb);
|
||||
}
|
||||
@ -355,7 +355,7 @@ cac_cmd(struct cac_softc *sc, int command, void *data, int datasize,
|
||||
/*
|
||||
* Wait for the specified CCB to complete. Must be called at splbio.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
cac_ccb_poll(struct cac_softc *sc, struct cac_ccb *wantccb, int timo)
|
||||
{
|
||||
struct cac_ccb *ccb;
|
||||
@ -364,13 +364,14 @@ cac_ccb_poll(struct cac_softc *sc, struct cac_ccb *wantccb, int timo)
|
||||
|
||||
do {
|
||||
for (; timo != 0; timo--) {
|
||||
if ((ccb = (*sc->sc_cl->cl_completed)(sc)) != NULL)
|
||||
ccb = (*sc->sc_cl.cl_completed)(sc);
|
||||
if (ccb != NULL)
|
||||
break;
|
||||
DELAY(100);
|
||||
}
|
||||
|
||||
if (timo == 0) {
|
||||
printf("%s: timeout", sc->sc_dv.dv_xname);
|
||||
printf("%s: timeout\n", sc->sc_dv.dv_xname);
|
||||
return (EBUSY);
|
||||
}
|
||||
cac_ccb_done(sc, ccb);
|
||||
@ -383,7 +384,7 @@ cac_ccb_poll(struct cac_softc *sc, struct cac_ccb *wantccb, int timo)
|
||||
* Enqueue the specifed command (if any) and attempt to start all enqueued
|
||||
* commands. Must be called at splbio.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
cac_ccb_start(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
{
|
||||
|
||||
@ -391,13 +392,13 @@ cac_ccb_start(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
SIMPLEQ_INSERT_TAIL(&sc->sc_ccb_queue, ccb, ccb_chain);
|
||||
|
||||
while ((ccb = SIMPLEQ_FIRST(&sc->sc_ccb_queue)) != NULL) {
|
||||
if ((*sc->sc_cl->cl_fifo_full)(sc))
|
||||
if ((*sc->sc_cl.cl_fifo_full)(sc))
|
||||
return (EBUSY);
|
||||
SIMPLEQ_REMOVE_HEAD(&sc->sc_ccb_queue, ccb, ccb_chain);
|
||||
#ifdef DIAGNOSTIC
|
||||
ccb->ccb_flags |= CAC_CCB_ACTIVE;
|
||||
#endif
|
||||
(*sc->sc_cl->cl_submit)(sc, ccb);
|
||||
(*sc->sc_cl.cl_submit)(sc, ccb);
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -406,7 +407,7 @@ cac_ccb_start(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
/*
|
||||
* Process a finished CCB.
|
||||
*/
|
||||
static void
|
||||
void
|
||||
cac_ccb_done(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
{
|
||||
struct device *dv;
|
||||
@ -494,14 +495,14 @@ cac_ccb_free(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
* Board specific linkage shared between multiple bus types.
|
||||
*/
|
||||
|
||||
static int
|
||||
int
|
||||
cac_l0_fifo_full(struct cac_softc *sc)
|
||||
{
|
||||
|
||||
return (cac_inl(sc, CAC_REG_CMD_FIFO) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
{
|
||||
|
||||
@ -510,13 +511,20 @@ cac_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
cac_outl(sc, CAC_REG_CMD_FIFO, ccb->ccb_paddr);
|
||||
}
|
||||
|
||||
static struct cac_ccb *
|
||||
struct cac_ccb *
|
||||
cac_l0_completed(struct cac_softc *sc)
|
||||
{
|
||||
struct cac_ccb *ccb;
|
||||
paddr_t off;
|
||||
|
||||
off = (cac_inl(sc, CAC_REG_DONE_FIFO) & ~3) - sc->sc_ccbs_paddr;
|
||||
if ((off = cac_inl(sc, CAC_REG_DONE_FIFO)) == 0)
|
||||
return (NULL);
|
||||
|
||||
if ((off & 3) != 0)
|
||||
printf("%s: failed command list returned: %lx\n",
|
||||
sc->sc_dv.dv_xname, (long)off);
|
||||
|
||||
off = (off & ~3) - sc->sc_ccbs_paddr;
|
||||
ccb = (struct cac_ccb *)(sc->sc_ccbs + off);
|
||||
|
||||
bus_dmamap_sync(sc->sc_dmat, sc->sc_dmamap, off, sizeof(struct cac_ccb),
|
||||
@ -525,14 +533,14 @@ cac_l0_completed(struct cac_softc *sc)
|
||||
return (ccb);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
cac_l0_intr_pending(struct cac_softc *sc)
|
||||
{
|
||||
|
||||
return (cac_inl(sc, CAC_REG_INTR_PENDING));
|
||||
return (cac_inl(sc, CAC_REG_INTR_PENDING) & CAC_INTR_ENABLE);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_l0_intr_enable(struct cac_softc *sc, int state)
|
||||
{
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cacvar.h,v 1.8 2000/11/08 19:20:35 ad Exp $ */
|
||||
/* $NetBSD: cacvar.h,v 1.9 2002/01/25 16:10:36 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -114,11 +114,11 @@ struct cac_softc {
|
||||
bus_dmamap_t sc_dmamap;
|
||||
int sc_nunits;
|
||||
void *sc_ih;
|
||||
const struct cac_linkage *sc_cl;
|
||||
caddr_t sc_ccbs;
|
||||
paddr_t sc_ccbs_paddr;
|
||||
SIMPLEQ_HEAD(, cac_ccb) sc_ccb_free;
|
||||
SIMPLEQ_HEAD(, cac_ccb) sc_ccb_queue;
|
||||
struct cac_linkage sc_cl;
|
||||
};
|
||||
|
||||
struct cac_attach_args {
|
||||
@ -132,6 +132,6 @@ int cac_cmd(struct cac_softc *, int, void *, int, int, int, int,
|
||||
int cac_init(struct cac_softc *, const char *, int);
|
||||
int cac_intr(void *);
|
||||
|
||||
extern struct cac_linkage cac_l0;
|
||||
extern const struct cac_linkage cac_l0;
|
||||
|
||||
#endif /* !_IC_CACVAR_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ld_cac.c,v 1.4 2001/11/13 13:14:40 lukem Exp $ */
|
||||
/* $NetBSD: ld_cac.c,v 1.5 2002/01/25 16:10:36 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ld_cac.c,v 1.4 2001/11/13 13:14:40 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ld_cac.c,v 1.5 2002/01/25 16:10:36 ad Exp $");
|
||||
|
||||
#include "rnd.h"
|
||||
|
||||
@ -71,26 +71,26 @@ struct ld_cac_softc {
|
||||
int sc_serrcnt;
|
||||
};
|
||||
|
||||
static void ld_cac_attach(struct device *, struct device *, void *);
|
||||
static void ld_cac_done(struct device *, void *, int);
|
||||
static int ld_cac_dump(struct ld_softc *, void *, int, int);
|
||||
static int ld_cac_match(struct device *, struct cfdata *, void *);
|
||||
static int ld_cac_start(struct ld_softc *, struct buf *);
|
||||
void ld_cac_attach(struct device *, struct device *, void *);
|
||||
void ld_cac_done(struct device *, void *, int);
|
||||
int ld_cac_dump(struct ld_softc *, void *, int, int);
|
||||
int ld_cac_match(struct device *, struct cfdata *, void *);
|
||||
int ld_cac_start(struct ld_softc *, struct buf *);
|
||||
|
||||
static struct timeval ld_cac_serrintvl = { 60, 0 };
|
||||
static const struct timeval ld_cac_serrintvl = { 60, 0 };
|
||||
|
||||
struct cfattach ld_cac_ca = {
|
||||
sizeof(struct ld_cac_softc), ld_cac_match, ld_cac_attach
|
||||
};
|
||||
|
||||
static int
|
||||
int
|
||||
ld_cac_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ld_cac_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct cac_drive_info dinfo;
|
||||
@ -145,7 +145,7 @@ ld_cac_attach(struct device *parent, struct device *self, void *aux)
|
||||
ldattach(ld);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
ld_cac_start(struct ld_softc *ld, struct buf *bp)
|
||||
{
|
||||
int flags, cmd;
|
||||
@ -172,7 +172,7 @@ ld_cac_start(struct ld_softc *ld, struct buf *bp)
|
||||
bp->b_rawblkno, flags, &cc));
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
ld_cac_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt)
|
||||
{
|
||||
struct ld_cac_softc *sc;
|
||||
@ -184,7 +184,7 @@ ld_cac_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt)
|
||||
sc->sc_hwunit, blkno, CAC_CCB_DATA_OUT, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ld_cac_done(struct device *dv, void *context, int error)
|
||||
{
|
||||
struct buf *bp;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cac_pci.c,v 1.11 2001/11/13 07:48:41 lukem Exp $ */
|
||||
/* $NetBSD: cac_pci.c,v 1.12 2002/01/25 16:10:37 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac_pci.c,v 1.11 2001/11/13 07:48:41 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cac_pci.c,v 1.12 2002/01/25 16:10:37 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -58,21 +58,21 @@ __KERNEL_RCSID(0, "$NetBSD: cac_pci.c,v 1.11 2001/11/13 07:48:41 lukem Exp $");
|
||||
#include <dev/ic/cacreg.h>
|
||||
#include <dev/ic/cacvar.h>
|
||||
|
||||
static void cac_pci_attach(struct device *, struct device *, void *);
|
||||
static struct cac_pci_type *cac_pci_findtype(struct pci_attach_args *);
|
||||
static int cac_pci_match(struct device *, struct cfdata *, void *);
|
||||
void cac_pci_attach(struct device *, struct device *, void *);
|
||||
const struct cac_pci_type *cac_pci_findtype(struct pci_attach_args *);
|
||||
int cac_pci_match(struct device *, struct cfdata *, void *);
|
||||
|
||||
static struct cac_ccb *cac_pci_l0_completed(struct cac_softc *);
|
||||
static int cac_pci_l0_fifo_full(struct cac_softc *);
|
||||
static void cac_pci_l0_intr_enable(struct cac_softc *, int);
|
||||
static int cac_pci_l0_intr_pending(struct cac_softc *);
|
||||
static void cac_pci_l0_submit(struct cac_softc *, struct cac_ccb *);
|
||||
struct cac_ccb *cac_pci_l0_completed(struct cac_softc *);
|
||||
int cac_pci_l0_fifo_full(struct cac_softc *);
|
||||
void cac_pci_l0_intr_enable(struct cac_softc *, int);
|
||||
int cac_pci_l0_intr_pending(struct cac_softc *);
|
||||
void cac_pci_l0_submit(struct cac_softc *, struct cac_ccb *);
|
||||
|
||||
struct cfattach cac_pci_ca = {
|
||||
sizeof(struct cac_softc), cac_pci_match, cac_pci_attach
|
||||
};
|
||||
|
||||
static struct cac_linkage cac_pci_l0 = {
|
||||
static const struct cac_linkage cac_pci_l0 = {
|
||||
cac_pci_l0_completed,
|
||||
cac_pci_l0_fifo_full,
|
||||
cac_pci_l0_intr_enable,
|
||||
@ -85,9 +85,9 @@ static struct cac_linkage cac_pci_l0 = {
|
||||
struct cac_pci_type {
|
||||
int ct_subsysid;
|
||||
int ct_flags;
|
||||
struct cac_linkage *ct_linkage;
|
||||
char *ct_typestr;
|
||||
} static cac_pci_type[] = {
|
||||
const struct cac_linkage *ct_linkage;
|
||||
const char *ct_typestr;
|
||||
} static const cac_pci_type[] = {
|
||||
{ 0x40300e11, 0, &cac_l0, "SMART-2/P" },
|
||||
{ 0x40310e11, 0, &cac_l0, "SMART-2SL" },
|
||||
{ 0x40320e11, 0, &cac_l0, "Smart Array 3200" },
|
||||
@ -103,17 +103,17 @@ struct cac_pci_type {
|
||||
struct cac_pci_product {
|
||||
u_short cp_vendor;
|
||||
u_short cp_product;
|
||||
} static cac_pci_product[] = {
|
||||
} static const cac_pci_product[] = {
|
||||
{ PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_SMART2P },
|
||||
{ PCI_VENDOR_DEC, PCI_PRODUCT_DEC_CPQ42XX },
|
||||
{ PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_1510 },
|
||||
};
|
||||
|
||||
static struct cac_pci_type *
|
||||
const struct cac_pci_type *
|
||||
cac_pci_findtype(struct pci_attach_args *pa)
|
||||
{
|
||||
struct cac_pci_type *ct;
|
||||
struct cac_pci_product *cp;
|
||||
const struct cac_pci_type *ct;
|
||||
const struct cac_pci_product *cp;
|
||||
pcireg_t subsysid;
|
||||
int i;
|
||||
|
||||
@ -144,18 +144,18 @@ cac_pci_findtype(struct pci_attach_args *pa)
|
||||
return (ct);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
cac_pci_match(struct device *parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
|
||||
return (cac_pci_findtype(aux) != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa;
|
||||
struct cac_pci_type *ct;
|
||||
const struct cac_pci_type *ct;
|
||||
struct cac_softc *sc;
|
||||
pci_chipset_tag_t pc;
|
||||
pci_intr_handle_t ih;
|
||||
@ -227,11 +227,11 @@ cac_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
printf(": Compaq %s\n", ct->ct_typestr);
|
||||
|
||||
/* Now attach to the bus-independent code. */
|
||||
sc->sc_cl = ct->ct_linkage;
|
||||
memcpy(&sc->sc_cl, ct->ct_linkage, sizeof(sc->sc_cl));
|
||||
cac_init(sc, intrstr, (ct->ct_flags & CT_STARTFW) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_pci_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
{
|
||||
|
||||
@ -240,16 +240,21 @@ cac_pci_l0_submit(struct cac_softc *sc, struct cac_ccb *ccb)
|
||||
cac_outl(sc, CAC_42REG_CMD_FIFO, ccb->ccb_paddr);
|
||||
}
|
||||
|
||||
static struct cac_ccb *
|
||||
struct cac_ccb *
|
||||
cac_pci_l0_completed(struct cac_softc *sc)
|
||||
{
|
||||
struct cac_ccb *ccb;
|
||||
u_int32_t off;
|
||||
|
||||
if ((off = cac_inl(sc, CAC_42REG_DONE_FIFO)) == 0xffffffffU)
|
||||
return (0);
|
||||
return (NULL);
|
||||
|
||||
cac_outl(sc, CAC_42REG_DONE_FIFO, 0);
|
||||
|
||||
if ((off & 3) != 0)
|
||||
printf("%s: failed command list returned: %lx\n",
|
||||
sc->sc_dv.dv_xname, (long)off);
|
||||
|
||||
off = (off & ~3) - sc->sc_ccbs_paddr;
|
||||
ccb = (struct cac_ccb *)(sc->sc_ccbs + off);
|
||||
|
||||
@ -259,21 +264,21 @@ cac_pci_l0_completed(struct cac_softc *sc)
|
||||
return (ccb);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
cac_pci_l0_intr_pending(struct cac_softc *sc)
|
||||
{
|
||||
|
||||
return ((cac_inl(sc, CAC_42REG_STATUS) & CAC_42_EXTINT) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cac_pci_l0_intr_enable(struct cac_softc *sc, int state)
|
||||
{
|
||||
|
||||
cac_outl(sc, CAC_42REG_INTR_MASK, (state ? 0 : 8)); /* XXX */
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
cac_pci_l0_fifo_full(struct cac_softc *sc)
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user