From 777b7ad5376b715f1c9f137f1b1cf6d7345dc634 Mon Sep 17 00:00:00 2001 From: Jason Wright Date: Wed, 11 Nov 1998 00:26:02 +0000 Subject: Detect cards that require dma that are in non-dma slots and don't allow them to be attach'd. --- sys/arch/sparc/dev/esp.c | 7 +++++-- sys/arch/sparc/dev/hme.c | 4 +++- sys/arch/sparc/dev/lebuffer.c | 26 ++++++++++++++++++++++++-- sys/arch/sparc/dev/qec.c | 26 ++++++++++++++++++++++++-- sys/arch/sparc/dev/sbus.c | 29 ++++++++++++++++++++++++++++- sys/arch/sparc/dev/sbusvar.h | 3 ++- 6 files changed, 86 insertions(+), 9 deletions(-) (limited to 'sys') diff --git a/sys/arch/sparc/dev/esp.c b/sys/arch/sparc/dev/esp.c index 438922eb1d6..59f8c6415b2 100644 --- a/sys/arch/sparc/dev/esp.c +++ b/sys/arch/sparc/dev/esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esp.c,v 1.13 1998/01/28 17:21:47 jason Exp $ */ +/* $OpenBSD: esp.c,v 1.14 1998/11/11 00:25:58 jason Exp $ */ /* $NetBSD: esp.c,v 1.69 1997/08/27 11:24:18 bouyer Exp $ */ /* @@ -192,8 +192,11 @@ espmatch(parent, vcf, aux) if (strcmp(cf->cf_driver->cd_name, ra->ra_name)) return (0); - if (ca->ca_bustype == BUS_SBUS) + if (ca->ca_bustype == BUS_SBUS) { + if (!sbus_testdma((struct sbus_softc *)parent, ca)) + return (0); return (1); + } ra->ra_len = NBPG; return (probeget(ra->ra_vaddr, 1) != -1); } diff --git a/sys/arch/sparc/dev/hme.c b/sys/arch/sparc/dev/hme.c index 59f93f793ae..d8d2e8eec93 100644 --- a/sys/arch/sparc/dev/hme.c +++ b/sys/arch/sparc/dev/hme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hme.c,v 1.12 1998/10/02 17:42:24 jason Exp $ */ +/* $OpenBSD: hme.c,v 1.13 1998/11/11 00:26:00 jason Exp $ */ /* * Copyright (c) 1998 Jason L. Wright (jason@thought.net) @@ -146,6 +146,8 @@ hmematch(parent, vcf, aux) strcmp("SUNW,hme", ra->ra_name)) { return (0); } + if (!sbus_testdma((struct sbus_softc *)parent, ca)) + return(0); return (1); } diff --git a/sys/arch/sparc/dev/lebuffer.c b/sys/arch/sparc/dev/lebuffer.c index d5ee34b32a4..9e99c092881 100644 --- a/sys/arch/sparc/dev/lebuffer.c +++ b/sys/arch/sparc/dev/lebuffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lebuffer.c,v 1.3 1998/07/05 09:24:23 deraadt Exp $ */ +/* $OpenBSD: lebuffer.c,v 1.4 1998/11/11 00:26:00 jason Exp $ */ /* $NetBSD: lebuffer.c,v 1.3 1997/05/24 20:16:28 pk Exp $ */ /* @@ -50,10 +50,11 @@ #include /*XXX*/ int lebufprint __P((void *, const char *)); +int lebufmatch __P((struct device *, void *, void *)); void lebufattach __P((struct device *, struct device *, void *)); struct cfattach lebuffer_ca = { - sizeof(struct lebuf_softc), matchbyname, lebufattach + sizeof(struct lebuf_softc), lebufmatch, lebufattach }; struct cfdriver lebuffer_cd = { @@ -73,6 +74,27 @@ lebufprint(aux, name) return (UNCONF); } +/* + * Match a lebuffer card in a slot capable of dma. + */ +int +lebufmatch(parent, vcf, aux) + struct device *parent; + void *vcf, *aux; +{ + struct cfdata *cf = vcf; + struct confargs *ca = aux; + register struct romaux *ra = &ca->ca_ra; + + if (strcmp(cf->cf_driver->cd_name, ra->ra_name)) + return(0); + + if (!sbus_testdma((struct sbus_softc *)parent, ca)) + return(0); + + return (1); +} + /* * Attach all the sub-devices we can find */ diff --git a/sys/arch/sparc/dev/qec.c b/sys/arch/sparc/dev/qec.c index f0a3abec994..f0573775853 100644 --- a/sys/arch/sparc/dev/qec.c +++ b/sys/arch/sparc/dev/qec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qec.c,v 1.8 1998/11/02 05:50:59 jason Exp $ */ +/* $OpenBSD: qec.c,v 1.9 1998/11/11 00:26:00 jason Exp $ */ /* * Copyright (c) 1998 Theo de Raadt and Jason L. Wright. @@ -48,12 +48,13 @@ #include int qecprint __P((void *, const char *)); +int qecmatch __P((struct device *, void *, void *)); void qecattach __P((struct device *, struct device *, void *)); void qec_fix_range __P((struct qec_softc *, struct sbus_softc *)); void qec_translate __P((struct qec_softc *, struct confargs *)); struct cfattach qec_ca = { - sizeof(struct qec_softc), matchbyname, qecattach + sizeof(struct qec_softc), qecmatch, qecattach }; struct cfdriver qec_cd = { @@ -73,6 +74,27 @@ qecprint(aux, name) return (UNCONF); } +/* + * match a QEC device in a slot capable of DMA + */ +int +qecmatch(parent, vcf, aux) + struct device *parent; + void *vcf, *aux; +{ + struct cfdata *cf = vcf; + struct confargs *ca = aux; + struct romaux *ra = &ca->ca_ra; + + if (strcmp(cf->cf_driver->cd_name, ra->ra_name)) + return (0); + + if (!sbus_testdma((struct sbus_softc *)parent, ca)) + return (0); + + return (1); +} + /* * Attach all the sub-devices we can find */ diff --git a/sys/arch/sparc/dev/sbus.c b/sys/arch/sparc/dev/sbus.c index aee7de7fbf8..d82e7da864f 100644 --- a/sys/arch/sparc/dev/sbus.c +++ b/sys/arch/sparc/dev/sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbus.c,v 1.5 1997/08/08 08:25:27 downsj Exp $ */ +/* $OpenBSD: sbus.c,v 1.6 1998/11/11 00:26:00 jason Exp $ */ /* $NetBSD: sbus.c,v 1.17 1997/06/01 22:10:39 pk Exp $ */ /* @@ -87,9 +87,13 @@ sbus_print(args, sbus) const char *sbus; { register struct confargs *ca = args; + static char *sl = "slave-only"; if (sbus) printf("%s at %s", ca->ca_ra.ra_name, sbus); + /* Check root node for 'slave-only' property */ + if (getpropint(0, sl, 0) & (1 << ca->ca_slot)) + printf(" %s", sl); printf(" slot %d offset 0x%x", ca->ca_slot, ca->ca_offset); return (UNCONF); } @@ -287,3 +291,26 @@ sbusreset(sbus) } } } + +/* + * Returns true if this sbus slot is capable of dma + */ +int +sbus_testdma(sc, ca) + struct sbus_softc *sc; + struct confargs *ca; +{ + struct romaux *ra = &ca->ca_ra; + + /* + * XXX how to handle more then one sbus? + */ + + if (getpropint(0, "slave-only", 0) & (1 << ca->ca_slot)) { + printf("%s: dma card found in non-dma sbus slot %d" + ": not supported\n", ra->ra_name, ca->ca_slot); + return (0); + } + + return (1); +} diff --git a/sys/arch/sparc/dev/sbusvar.h b/sys/arch/sparc/dev/sbusvar.h index 21fd61967c2..90abe2456fc 100644 --- a/sys/arch/sparc/dev/sbusvar.h +++ b/sys/arch/sparc/dev/sbusvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sbusvar.h,v 1.4 1997/08/08 08:25:28 downsj Exp $ */ +/* $OpenBSD: sbusvar.h,v 1.5 1998/11/11 00:26:01 jason Exp $ */ /* $NetBSD: sbusvar.h,v 1.4 1996/04/22 02:35:05 abrown Exp $ */ /* @@ -76,3 +76,4 @@ struct sbus_softc { int sbusdev_match __P((struct cfdata *, void *)); void sbus_establish __P((struct sbusdev *, struct device *)); void sbus_translate __P((struct device *, struct confargs *)); +int sbus_testdma __P((struct sbus_softc *, struct confargs *)); -- cgit v1.2.3