diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1997-12-25 09:22:45 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1997-12-25 09:22:45 +0000 |
commit | 9e81d6c1eea4f1773dec269833c89f508fe2f518 (patch) | |
tree | 3094d64a61e416a0184126b2dc65e7869eaf7630 | |
parent | f689d11be07bc401b15d1961cd17978e76111392 (diff) |
New ISA/ISA PnP configuration infrastructure:
isa_attach_args and isapnp_attach_args have been merged.
-rw-r--r-- | sys/dev/isa/files.isapnp | 5 | ||||
-rw-r--r-- | sys/dev/isa/isapnp.c | 71 | ||||
-rw-r--r-- | sys/dev/isa/isapnpdebug.c | 15 | ||||
-rw-r--r-- | sys/dev/isa/isapnpreg.h | 7 | ||||
-rw-r--r-- | sys/dev/isa/isapnpres.c | 69 | ||||
-rw-r--r-- | sys/dev/isa/isapnpvar.h | 203 | ||||
-rw-r--r-- | sys/dev/isa/isavar.h | 212 |
7 files changed, 293 insertions, 289 deletions
diff --git a/sys/dev/isa/files.isapnp b/sys/dev/isa/files.isapnp index 585ef752b12..73d384f1ddb 100644 --- a/sys/dev/isa/files.isapnp +++ b/sys/dev/isa/files.isapnp @@ -1,4 +1,4 @@ -# $OpenBSD: files.isapnp,v 1.1 1997/12/21 14:41:22 downsj Exp $ +# $OpenBSD: files.isapnp,v 1.2 1997/12/25 09:22:36 downsj Exp $ # $NetBSD: files.isapnp,v 1.7 1997/10/16 17:16:36 matt Exp $ # # Config file and device description for machine-independent ISAPnP code. @@ -7,8 +7,9 @@ device isapnp {[port = -1], [size = 0], [iomem = -1], [iosiz = 0], [irq = -1], [drq = -1]} + attach isapnp at isa -file dev/isa/isapnp.c isapnp +file dev/isa/isapnp.c isapnp needs-flag file dev/isa/isapnpdebug.c isapnp file dev/isa/isapnpres.c isapnp diff --git a/sys/dev/isa/isapnp.c b/sys/dev/isa/isapnp.c index 2b90da5cb38..5c888ce9f15 100644 --- a/sys/dev/isa/isapnp.c +++ b/sys/dev/isa/isapnp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isapnp.c,v 1.12 1997/12/21 14:41:24 downsj Exp $ */ +/* $OpenBSD: isapnp.c,v 1.13 1997/12/25 09:22:38 downsj Exp $ */ /* $NetBSD: isapnp.c,v 1.9.4.3 1997/10/29 00:40:43 thorpej Exp $ */ /* @@ -41,12 +41,11 @@ #include <machine/bus.h> +#include <dev/isa/isapnpreg.h> + #include <dev/isa/isavar.h> #include <dev/isa/isadmavar.h> -#include <dev/isa/isapnpreg.h> -#include <dev/isa/isapnpvar.h> - #include <dev/isa/pnpdevs.h> void isapnp_init __P((struct isapnp_softc *)); @@ -57,13 +56,13 @@ int isapnp_alloc_region __P((bus_space_tag_t, struct isapnp_region *)); int isapnp_alloc_irq __P((isa_chipset_tag_t, struct isapnp_pin *)); int isapnp_alloc_drq __P((struct device *, struct isapnp_pin *)); int isapnp_testconfig __P((bus_space_tag_t, bus_space_tag_t, - struct isapnp_attach_args *, int)); -struct isapnp_attach_args *isapnp_bestconfig __P((struct device *, - struct isapnp_softc *, struct isapnp_attach_args **)); + struct isa_attach_args *, int)); +struct isa_attach_args *isapnp_bestconfig __P((struct device *, + struct isapnp_softc *, struct isa_attach_args **)); void isapnp_print_region __P((const char *, struct isapnp_region *, size_t)); void isapnp_configure __P((struct isapnp_softc *, - const struct isapnp_attach_args *)); + const struct isa_attach_args *)); void isapnp_print_pin __P((const char *, struct isapnp_pin *, size_t)); int isapnp_print __P((void *, const char *)); #ifdef _KERNEL @@ -73,6 +72,12 @@ int isapnp_find __P((struct isapnp_softc *, int)); int isapnp_match __P((struct device *, void *, void *)); void isapnp_attach __P((struct device *, struct device *, void *)); +#ifdef DEBUG_ISAPNP +# define DPRINTF(a) printf a +#else +# define DPRINTF(a) +#endif + struct cfattach isapnp_ca = { sizeof(struct isapnp_softc), isapnp_match, isapnp_attach }; @@ -190,6 +195,9 @@ isapnp_free_region(t, r) bus_space_tag_t t; struct isapnp_region *r; { + if (r->length == 0) + return; + #ifdef _KERNEL bus_space_unmap(t, r->h, r->length); #endif @@ -206,6 +214,9 @@ isapnp_alloc_region(t, r) { int error = 0; + if (r->length == 0) + return 0; + for (r->base = r->minbase; r->base <= r->maxbase; r->base += r->align) { #ifdef _KERNEL @@ -273,7 +284,7 @@ isapnp_alloc_drq(isa, i) int isapnp_testconfig(iot, memt, ipa, alloc) bus_space_tag_t iot, memt; - struct isapnp_attach_args *ipa; + struct isa_attach_args *ipa; int alloc; { int nio = 0, nmem = 0, nmem32 = 0, nirq = 0, ndrq = 0; @@ -302,13 +313,13 @@ isapnp_testconfig(iot, memt, ipa, alloc) } for (; nirq < ipa->ipa_nirq; nirq++) { - error = isapnp_alloc_irq(ipa->ipa_ic, &ipa->ipa_irq[nirq]); + error = isapnp_alloc_irq(ipa->ia_ic, &ipa->ipa_irq[nirq]); if (error) goto bad; } for (; ndrq < ipa->ipa_ndrq; ndrq++) { - error = isapnp_alloc_drq(ipa->ipa_isa, &ipa->ipa_drq[ndrq]); + error = isapnp_alloc_drq(ipa->ia_isa, &ipa->ipa_drq[ndrq]); if (error) goto bad; } @@ -344,7 +355,7 @@ bad: int isapnp_config(iot, memt, ipa) bus_space_tag_t iot, memt; - struct isapnp_attach_args *ipa; + struct isa_attach_args *ipa; { return isapnp_testconfig(iot, memt, ipa, 1); } @@ -356,7 +367,7 @@ isapnp_config(iot, memt, ipa) void isapnp_unconfig(iot, memt, ipa) bus_space_tag_t iot, memt; - struct isapnp_attach_args *ipa; + struct isa_attach_args *ipa; { int i; @@ -383,13 +394,13 @@ isapnp_unconfig(iot, memt, ipa) * Return the best configuration for each logical device, remove and * free all other configurations. */ -struct isapnp_attach_args * +struct isa_attach_args * isapnp_bestconfig(isa, sc, ipa) struct device *isa; struct isapnp_softc *sc; - struct isapnp_attach_args **ipa; + struct isa_attach_args **ipa; { - struct isapnp_attach_args *c, *best, *f = *ipa; + struct isa_attach_args *c, *best, *f = *ipa; int error; for (;;) { @@ -406,7 +417,7 @@ isapnp_bestconfig(isa, sc, ipa) best = c; } - best->ipa_isa = isa; + best->ia_isa = isa; /* Test the best config */ error = isapnp_testconfig(sc->sc_iot, sc->sc_memt, best, 0); @@ -436,7 +447,7 @@ isapnp_bestconfig(isa, sc, ipa) } else { /* Remove all other configs for this device */ - struct isapnp_attach_args *l = NULL, *n = NULL, *d; + struct isa_attach_args *l = NULL, *n = NULL, *d; for (c = f; c; ) { if (c == best) @@ -543,7 +554,7 @@ isapnp_print(aux, str) void *aux; const char *str; { - struct isapnp_attach_args *ipa = aux; + struct isa_attach_args *ipa = aux; if (str != NULL) printf("%s: <%s, %s, %s, %s>", @@ -570,7 +581,7 @@ isapnp_submatch(parent, match, aux) void *match, *aux; { struct cfdata *cf = match; - struct isapnp_attach_args *ipa = aux; + struct isa_attach_args *ipa = aux; const char *dname; int i; @@ -587,7 +598,7 @@ isapnp_submatch(parent, match, aux) * We found a match. Configure the card and call the * ISA probe... */ - if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) { + if (isapnp_config(ipa->ia_iot, ipa->ia_memt, ipa)) { printf ("%s: error in region allocation\n", cf->cf_driver->cd_name); return (0); @@ -651,7 +662,7 @@ isapnp_find(sc, all) void isapnp_configure(sc, ipa) struct isapnp_softc *sc; - const struct isapnp_attach_args *ipa; + const struct isa_attach_args *ipa; { int i; static u_char isapnp_mem_range[] = ISAPNP_MEM_DESC; @@ -664,8 +675,8 @@ isapnp_configure(sc, ipa) struct isapnp_region rz; struct isapnp_pin pz; - memset(&pz, 0, sizeof(pz)); - memset(&rz, 0, sizeof(rz)); + bzero(&pz, sizeof(pz)); + bzero(&rz, sizeof(rz)); #define B0(a) ((a) & 0xff) #define B1(a) (((a) >> 8) & 0xff) @@ -839,7 +850,7 @@ isapnp_attach(parent, self, aux) printf(": read port 0x%x\n", sc->sc_read_port); for (c = 0; c < sc->sc_ncards; c++) { - struct isapnp_attach_args *ipa, *lpa; + struct isa_attach_args *ipa, *lpa; /* Good morning card c */ isapnp_write_reg(sc, ISAPNP_WAKE, c + 1); @@ -854,7 +865,7 @@ isapnp_attach(parent, self, aux) isapnp_configure(sc, lpa); #ifdef DEBUG_ISAPNP { - struct isapnp_attach_args pa; + struct isa_attach_args pa; isapnp_get_config(sc, &pa); isapnp_print_config(&pa); @@ -875,10 +886,10 @@ isapnp_attach(parent, self, aux) continue; } - lpa->ipa_ic = ia->ia_ic; - lpa->ipa_iot = ia->ia_iot; - lpa->ipa_memt = ia->ia_memt; - lpa->ipa_delaybah = ia->ia_delaybah; + lpa->ia_ic = ia->ia_ic; + lpa->ia_iot = ia->ia_iot; + lpa->ia_memt = ia->ia_memt; + lpa->ia_delaybah = ia->ia_delaybah; isapnp_write_reg(sc, ISAPNP_ACTIVATE, 1); #ifdef _KERNEL diff --git a/sys/dev/isa/isapnpdebug.c b/sys/dev/isa/isapnpdebug.c index f02f80a17a0..850b06231f0 100644 --- a/sys/dev/isa/isapnpdebug.c +++ b/sys/dev/isa/isapnpdebug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isapnpdebug.c,v 1.1 1997/12/21 14:41:25 downsj Exp $ */ +/* $OpenBSD: isapnpdebug.c,v 1.2 1997/12/25 09:22:40 downsj Exp $ */ /* $NetBSD: isapnpdebug.c,v 1.4 1997/08/03 08:12:23 mikel Exp $ */ /* @@ -38,10 +38,9 @@ #include <machine/bus.h> -#include <dev/isa/isavar.h> - #include <dev/isa/isapnpreg.h> -#include <dev/isa/isapnpvar.h> + +#include <dev/isa/isavar.h> /* isapnp_print_mem(): * Print a memory tag @@ -218,7 +217,7 @@ isapnp_print_dep_start(str, pref) void isapnp_print_attach(pa) - const struct isapnp_attach_args *pa; + const struct isa_attach_args *pa; { int i; @@ -249,7 +248,7 @@ isapnp_print_attach(pa) void isapnp_get_config(sc, pa) struct isapnp_softc *sc; - struct isapnp_attach_args *pa; + struct isa_attach_args *pa; { int i; u_char v0, v1, v2, v3; @@ -261,7 +260,7 @@ isapnp_get_config(sc, pa) struct isapnp_region *r; struct isapnp_pin *p; - memset(pa, 0, sizeof(*pa)); + bzero(pa, sizeof(*pa)); for (i = 0; i < sizeof(isapnp_io_range); i++) { r = &pa->ipa_io[i]; @@ -370,7 +369,7 @@ isapnp_get_config(sc, pa) */ void isapnp_print_config(pa) - const struct isapnp_attach_args *pa; + const struct isa_attach_args *pa; { int i; const struct isapnp_region *r; diff --git a/sys/dev/isa/isapnpreg.h b/sys/dev/isa/isapnpreg.h index d379dccc22d..c633408469e 100644 --- a/sys/dev/isa/isapnpreg.h +++ b/sys/dev/isa/isapnpreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: isapnpreg.h,v 1.3 1997/12/21 14:41:26 downsj Exp $ */ +/* $OpenBSD: isapnpreg.h,v 1.4 1997/12/25 09:22:41 downsj Exp $ */ /* $NetBSD: isapnpreg.h,v 1.5 1997/08/12 07:34:34 mikel Exp $ */ /* @@ -30,6 +30,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _DEV_ISA_ISAPNPREG_H_ +#define _DEV_ISA_ISAPNPREG_H_ + /* * ISA Plug and Play register definitions; * From Plug and Play ISA Specification V1.0a, May 5 1994 @@ -171,3 +174,5 @@ #define ISAPNP_TAG_VENDOR_DEFINED 0x84 #define ISAPNP_TAG_MEM32_RANGE_DESC 0x85 #define ISAPNP_TAG_FIXED_MEM32_RANGE_DESC 0x86 + +#endif /* _DEV_ISA_ISAPNPREG_H_ */ diff --git a/sys/dev/isa/isapnpres.c b/sys/dev/isa/isapnpres.c index 99044fabe83..879c9c39ed0 100644 --- a/sys/dev/isa/isapnpres.c +++ b/sys/dev/isa/isapnpres.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isapnpres.c,v 1.1 1997/12/21 14:41:26 downsj Exp $ */ +/* $OpenBSD: isapnpres.c,v 1.2 1997/12/25 09:22:42 downsj Exp $ */ /* $NetBSD: isapnpres.c,v 1.7.4.1 1997/11/20 07:46:13 mellon Exp $ */ /* @@ -41,25 +41,28 @@ #include <machine/bus.h> -#include <dev/isa/isavar.h> - #include <dev/isa/isapnpreg.h> -#include <dev/isa/isapnpvar.h> +#include <dev/isa/isavar.h> int isapnp_wait_status __P((struct isapnp_softc *)); -struct isapnp_attach_args * - isapnp_newdev __P((struct isapnp_attach_args *)); -struct isapnp_attach_args * - isapnp_newconf __P((struct isapnp_attach_args *)); -void isapnp_merge __P((struct isapnp_attach_args *, - const struct isapnp_attach_args *)); -struct isapnp_attach_args * - isapnp_flatten __P((struct isapnp_attach_args *)); +struct isa_attach_args * + isapnp_newdev __P((struct isa_attach_args *)); +struct isa_attach_args * + isapnp_newconf __P((struct isa_attach_args *)); +void isapnp_merge __P((struct isa_attach_args *, + const struct isa_attach_args *)); +struct isa_attach_args * + isapnp_flatten __P((struct isa_attach_args *)); int isapnp_process_tag __P((u_char, u_char, u_char *, - struct isapnp_attach_args **, struct isapnp_attach_args **, - struct isapnp_attach_args **)); + struct isa_attach_args **, struct isa_attach_args **, + struct isa_attach_args **)); +#ifdef DEBUG_ISAPNP +# define DPRINTF(a) printf a +#else +# define DPRINTF(a) +#endif /* isapnp_wait_status(): * Wait for the next byte of resource data to become available @@ -84,13 +87,13 @@ isapnp_wait_status(sc) * Add a new logical device to the current card; expand the configuration * resources of the current card if needed. */ -struct isapnp_attach_args * +struct isa_attach_args * isapnp_newdev(card) - struct isapnp_attach_args *card; + struct isa_attach_args *card; { - struct isapnp_attach_args *ipa, *dev = ISAPNP_MALLOC(sizeof(*dev)); + struct isa_attach_args *ipa, *dev = ISAPNP_MALLOC(sizeof(*dev)); - memset(dev, 0, sizeof(*dev)); + bzero(dev, sizeof(*dev)); dev->ipa_pref = ISAPNP_DEP_ACCEPTABLE; memcpy(dev->ipa_devident, card->ipa_devident, @@ -113,13 +116,13 @@ isapnp_newdev(card) /* isapnp_newconf(): * Add a new alternate configuration to a logical device */ -struct isapnp_attach_args * +struct isa_attach_args * isapnp_newconf(dev) - struct isapnp_attach_args *dev; + struct isa_attach_args *dev; { - struct isapnp_attach_args *ipa, *conf = ISAPNP_MALLOC(sizeof(*conf)); + struct isa_attach_args *ipa, *conf = ISAPNP_MALLOC(sizeof(*conf)); - memset(conf, 0, sizeof(*conf)); + bzero(conf, sizeof(*conf)); memcpy(conf->ipa_devident, dev->ipa_devident, sizeof(conf->ipa_devident)); @@ -148,8 +151,8 @@ isapnp_newconf(dev) */ void isapnp_merge(c, d) - struct isapnp_attach_args *c; - const struct isapnp_attach_args *d; + struct isa_attach_args *c; + const struct isa_attach_args *d; { int i; @@ -173,11 +176,11 @@ isapnp_merge(c, d) /* isapnp_flatten(): * Flatten the tree to a list of config entries. */ -struct isapnp_attach_args * +struct isa_attach_args * isapnp_flatten(card) - struct isapnp_attach_args *card; + struct isa_attach_args *card; { - struct isapnp_attach_args *dev, *conf, *d, *c, *pa; + struct isa_attach_args *dev, *conf, *d, *c, *pa; dev = card->ipa_child; ISAPNP_FREE(card); @@ -222,12 +225,12 @@ isapnp_flatten(card) int isapnp_process_tag(tag, len, buf, card, dev, conf) u_char tag, len, *buf; - struct isapnp_attach_args **card, **dev, **conf; + struct isa_attach_args **card, **dev, **conf; { char str[64]; struct isapnp_region *r; struct isapnp_pin *p; - struct isapnp_attach_args *pa; + struct isa_attach_args *pa; #define COPY(a, b) strncpy((a), (b), sizeof(a)), (a)[sizeof(a) - 1] = '\0' @@ -433,7 +436,7 @@ isapnp_process_tag(tag, len, buf, card, dev, conf) /* isapnp_get_resource(): * Read the resources for card c */ -struct isapnp_attach_args * +struct isa_attach_args * isapnp_get_resource(sc, c) struct isapnp_softc *sc; int c; @@ -442,13 +445,13 @@ isapnp_get_resource(sc, c) u_short len; int i; int warned = 0; - struct isapnp_attach_args *card, *dev = NULL, *conf = NULL; + struct isa_attach_args *card, *dev = NULL, *conf = NULL; u_char buf[ISAPNP_MAX_TAGSIZE], *p; - memset(buf, 0, sizeof(buf)); + bzero(buf, sizeof(buf)); card = ISAPNP_MALLOC(sizeof(*card)); - memset(card, 0, sizeof(*card)); + bzero(card, sizeof(*card)); #define NEXT_BYTE \ if (isapnp_wait_status(sc)) \ diff --git a/sys/dev/isa/isapnpvar.h b/sys/dev/isa/isapnpvar.h deleted file mode 100644 index 5feb9ea17a7..00000000000 --- a/sys/dev/isa/isapnpvar.h +++ /dev/null @@ -1,203 +0,0 @@ -/* $OpenBSD: isapnpvar.h,v 1.3 1997/12/21 14:41:27 downsj Exp $ */ -/* $NetBSD: isapnpvar.h,v 1.5.4.2 1997/10/29 00:40:49 thorpej Exp $ */ - -/* - * Copyright (c) 1996 Christos Zoulas. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christos Zoulas. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DEV_ISAPNP_ISAPNPVAR_H_ -#define _DEV_ISAPNP_ISAPNPVAR_H_ - -/* - * ISA Plug and Play register definitions; - * From Plug and Play ISA Specification V1.0a, May 5 1994 - */ - -/* - * Structures and definitions needed by the machine-dependent header. - */ -struct isapnp_softc; - -#if (i386 != 1) -ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE. -#endif -#if i386 -#include <i386/isa/isapnp_machdep.h> -#endif - -#ifndef _KERNEL - -# include <stdlib.h> -# include <string.h> -# include <unistd.h> - -# define ISAPNP_WRITE_ADDR(sc, v) outb(ISAPNP_ADDR, v) -# define ISAPNP_WRITE_DATA(sc, v) outb(ISAPNP_WRDATA, v) -# define ISAPNP_READ_DATA(sc) inb(sc->sc_read_port) - -# define DELAY(us) usleep(us) -# define ISAPNP_MALLOC(a) malloc(a) -# define ISAPNP_FREE(a) free(a) - -# define panic printf - -#else - -/* XXX */ -# define memset(a, b, c) bzero(a, c) - -# define ISAPNP_WRITE_ADDR(sc, v) \ - bus_space_write_1(sc->sc_iot, sc->sc_addr_ioh, 0, v) -# define ISAPNP_WRITE_DATA(sc, v) \ - bus_space_write_1(sc->sc_iot, sc->sc_wrdata_ioh, 0, v) -# define ISAPNP_READ_DATA(sc) \ - bus_space_read_1(sc->sc_iot, sc->sc_read_ioh, 0) - -# define ISAPNP_MALLOC(a) malloc(a, M_DEVBUF, M_WAITOK) -# define ISAPNP_FREE(a) free(a, M_DEVBUF) - -#endif - -#ifdef DEBUG_ISAPNP -# define DPRINTF(a) printf a -#else -# define DPRINTF(a) -#endif - -struct isapnp_softc { - struct device sc_dev; - int sc_read_port; - bus_space_tag_t sc_iot; - bus_space_tag_t sc_memt; - bus_space_handle_t sc_addr_ioh; - bus_space_handle_t sc_wrdata_ioh; - bus_space_handle_t sc_read_ioh; - bus_space_handle_t sc_memh; - u_int8_t sc_ncards; - u_int8_t sc_id[ISAPNP_MAX_CARDS][ISAPNP_SERIAL_SIZE]; -}; - -struct isapnp_region { - bus_space_handle_t h; - u_int32_t base; - - u_int32_t minbase; - u_int32_t maxbase; - u_int32_t length; - u_int32_t align; - u_int8_t flags; -}; - -struct isapnp_pin { - u_int8_t num; - u_int8_t flags:4; - u_int8_t type:4; - u_int16_t bits; -}; - -struct isapnp_attach_args { - struct device *ipa_isa; /* isa device */ - bus_space_tag_t ipa_iot; /* isa i/o space tag */ - bus_space_tag_t ipa_memt; /* isa mem space tag */ - - bus_space_handle_t ipa_delaybah; - - isa_chipset_tag_t ipa_ic; - - struct isapnp_attach_args *ipa_sibling; - struct isapnp_attach_args *ipa_child; - - char ipa_devident[ISAPNP_MAX_IDENT]; - char ipa_devlogic[ISAPNP_MAX_DEVCLASS]; - char ipa_devcompat[ISAPNP_MAX_DEVCLASS]; - char ipa_devclass[ISAPNP_MAX_DEVCLASS]; - - u_char ipa_pref; - u_char ipa_devnum; - - u_char ipa_nio; - u_char ipa_nirq; - u_char ipa_ndrq; - u_char ipa_nmem; - u_char ipa_nmem32; - - struct isapnp_region ipa_io[ISAPNP_NUM_IO]; - struct isapnp_region ipa_mem[ISAPNP_NUM_MEM]; - struct isapnp_region ipa_mem32[ISAPNP_NUM_MEM32]; - struct isapnp_pin ipa_irq[ISAPNP_NUM_IRQ]; - struct isapnp_pin ipa_drq[ISAPNP_NUM_DRQ]; -}; - -struct isapnp_knowndev { - const char *pnpid; - const char *driver; -}; - -static __inline void isapnp_write_reg __P((struct isapnp_softc *, int, u_char)); -static __inline u_char isapnp_read_reg __P((struct isapnp_softc *, int)); - -static __inline void -isapnp_write_reg(sc, r, v) - struct isapnp_softc *sc; - int r; - u_char v; -{ - ISAPNP_WRITE_ADDR(sc, r); - ISAPNP_WRITE_DATA(sc, v); -} - -static __inline u_char -isapnp_read_reg(sc, r) - struct isapnp_softc *sc; -{ - ISAPNP_WRITE_ADDR(sc, r); - return ISAPNP_READ_DATA(sc); -} - -struct isapnp_attach_args * - isapnp_get_resource __P((struct isapnp_softc *, int)); -char *isapnp_id_to_vendor __P((char *, const u_char *)); - -int isapnp_config __P((bus_space_tag_t, bus_space_tag_t, - struct isapnp_attach_args *)); -void isapnp_unconfig __P((bus_space_tag_t, bus_space_tag_t, - struct isapnp_attach_args *)); - -#ifdef DEBUG_ISAPNP -void isapnp_print_mem __P((const char *, const struct isapnp_region *)); -void isapnp_print_io __P((const char *, const struct isapnp_region *)); -void isapnp_print_irq __P((const char *, const struct isapnp_pin *)); -void isapnp_print_drq __P((const char *, const struct isapnp_pin *)); -void isapnp_print_dep_start __P((const char *, const u_char)); -void isapnp_print_attach __P((const struct isapnp_attach_args *)); -void isapnp_get_config __P((struct isapnp_softc *, - struct isapnp_attach_args *)); -void isapnp_print_config __P((const struct isapnp_attach_args *)); -#endif - -#endif /* ! _DEV_ISAPNP_ISAPNPVAR_H_ */ diff --git a/sys/dev/isa/isavar.h b/sys/dev/isa/isavar.h index b2e0a295f27..dfa2b092e9c 100644 --- a/sys/dev/isa/isavar.h +++ b/sys/dev/isa/isavar.h @@ -1,5 +1,35 @@ -/* $OpenBSD: isavar.h,v 1.23 1997/12/21 14:41:27 downsj Exp $ */ +/* $OpenBSD: isavar.h,v 1.24 1997/12/25 09:22:44 downsj Exp $ */ /* $NetBSD: isavar.h,v 1.24 1996/10/21 22:41:11 thorpej Exp $ */ +/* $NetBSD: isapnpvar.h,v 1.5.4.2 1997/10/29 00:40:49 thorpej Exp $ */ + +/* + * Copyright (c) 1996 Christos Zoulas. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ /* * Copyright (c) 1995 Chris G. Demetriou @@ -41,7 +71,7 @@ #define _DEV_ISA_ISAVAR_H_ /* - * Definitions for ISA autoconfiguration. + * Definitions for ISA and ISA PnP autoconfiguration. */ #include <sys/queue.h> @@ -53,7 +83,7 @@ struct isabus_attach_args; #if (alpha + amiga + i386 + arc + wgrisc + power4e != 1) -ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE. +ERROR: COMPILING ISA FOR UNSUPPORTED MACHINE, OR MORE THAN ONE. #endif #if alpha #include <alpha/isa/isa_machdep.h> @@ -74,6 +104,87 @@ ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE. #include <powerpc/isa/isa_machdep.h> #endif +#include "isapnp.h" + +#if NISAPNP > 0 +/* + * Structures and definitions needed by the machine-dependent header. + */ +struct isapnp_softc; + +#if (i386 != 1) +ERROR: COMPILING ISAPNP FOR UNSUPPORTED MACHINE, OR MORE THAN ONE. +#endif +#if i386 +#include <i386/isa/isapnp_machdep.h> +#endif +#endif /* NISAPNP */ + +# define ISAPNP_WRITE_ADDR(sc, v) \ + bus_space_write_1(sc->sc_iot, sc->sc_addr_ioh, 0, v) +# define ISAPNP_WRITE_DATA(sc, v) \ + bus_space_write_1(sc->sc_iot, sc->sc_wrdata_ioh, 0, v) +# define ISAPNP_READ_DATA(sc) \ + bus_space_read_1(sc->sc_iot, sc->sc_read_ioh, 0) + +# define ISAPNP_MALLOC(a) malloc(a, M_DEVBUF, M_WAITOK) +# define ISAPNP_FREE(a) free(a, M_DEVBUF) + +#ifndef _DEV_ISA_ISAPNPREG_H_ +/* + * `reg' defines needed only for these structures. + */ +#define ISAPNP_MAX_CARDS 8 +#define ISAPNP_MAX_IDENT 32 +#define ISAPNP_MAX_DEVCLASS 16 +#define ISAPNP_SERIAL_SIZE 9 + +#define ISAPNP_NUM_MEM 4 +#define ISAPNP_NUM_IO 8 +#define ISAPNP_NUM_IRQ 16 +#define ISAPNP_NUM_DRQ 8 +#define ISAPNP_NUM_MEM32 4 +#endif /* _DEV_ISA_ISAPNPREG_H_ */ + +/* + * ISA PnP-specific structures. + */ +struct isapnp_softc { + struct device sc_dev; + int sc_read_port; + bus_space_tag_t sc_iot; + bus_space_tag_t sc_memt; + bus_space_handle_t sc_addr_ioh; + bus_space_handle_t sc_wrdata_ioh; + bus_space_handle_t sc_read_ioh; + bus_space_handle_t sc_memh; + u_int8_t sc_ncards; + u_int8_t sc_id[ISAPNP_MAX_CARDS][ISAPNP_SERIAL_SIZE]; +}; + +struct isapnp_region { + bus_space_handle_t h; + u_int32_t base; + + u_int32_t minbase; + u_int32_t maxbase; + u_int32_t length; + u_int32_t align; + u_int8_t flags; +}; + +struct isapnp_pin { + int16_t num; + u_int8_t flags:4; + u_int8_t type:4; + u_int16_t bits; +}; + +struct isapnp_knowndev { + const char *pnpid; + const char *driver; +}; + /* * ISA bus attach arguments */ @@ -85,23 +196,56 @@ struct isabus_attach_args { }; /* - * ISA driver attach arguments + * ISA/ISA PnP shared driver attach arguments */ struct isa_attach_args { + struct device *ia_isa; /* isa device */ bus_space_tag_t ia_iot; /* isa i/o space tag */ bus_space_tag_t ia_memt; /* isa mem space tag */ + bus_space_handle_t ia_delaybah; /* i/o handle for `delay port' */ + isa_chipset_tag_t ia_ic; - int ia_iobase; /* base i/o address */ - int ia_iosize; /* span of ports used */ - int ia_irq; /* interrupt request */ - int ia_drq; /* DMA request */ - int ia_maddr; /* physical i/o mem addr */ - u_int ia_msize; /* size of i/o memory */ - void *ia_aux; /* driver specific */ + /* + * ISA PnP configuration support. `ipa_' prefixes are used to denote + * PnP specific members of this structure. + */ + struct isa_attach_args *ipa_sibling; + struct isa_attach_args *ipa_child; - bus_space_handle_t ia_delaybah; /* i/o handle for `delay port' */ + char ipa_devident[ISAPNP_MAX_IDENT]; + char ipa_devlogic[ISAPNP_MAX_DEVCLASS]; + char ipa_devcompat[ISAPNP_MAX_DEVCLASS]; + char ipa_devclass[ISAPNP_MAX_DEVCLASS]; + + u_char ipa_pref; + u_char ipa_devnum; + + u_char ipa_nio; + u_char ipa_nirq; + u_char ipa_ndrq; + u_char ipa_nmem; + u_char ipa_nmem32; + + struct isapnp_region ipa_io[ISAPNP_NUM_IO]; + struct isapnp_region ipa_mem[ISAPNP_NUM_MEM]; + struct isapnp_region ipa_mem32[ISAPNP_NUM_MEM32]; + struct isapnp_pin ipa_irq[ISAPNP_NUM_IRQ]; + struct isapnp_pin ipa_drq[ISAPNP_NUM_DRQ]; + + /* + * Compatibility defines for ISA drivers. + */ +#define ia_iobase ipa_io[0].base +#define ia_iosize ipa_io[0].length +#define ia_irq ipa_irq[0].num +#define ia_drq ipa_drq[0].num +#define ia_maddr ipa_mem[0].base +#define ia_msize ipa_mem[0].length +#define ia_ioh ipa_io[0].h + + void *ia_aux; /* driver specific */ }; #define IOBASEUNK -1 /* i/o address is unknown */ @@ -176,4 +320,48 @@ int isaprint __P((void *, const char *)); void isa_establish __P((struct isadev *, struct device *)); #endif +/* + * ISA PnP prototypes and support macros. + */ +static __inline void isapnp_write_reg __P((struct isapnp_softc *, int, u_char)); +static __inline u_char isapnp_read_reg __P((struct isapnp_softc *, int)); + +static __inline void +isapnp_write_reg(sc, r, v) + struct isapnp_softc *sc; + int r; + u_char v; +{ + ISAPNP_WRITE_ADDR(sc, r); + ISAPNP_WRITE_DATA(sc, v); +} + +static __inline u_char +isapnp_read_reg(sc, r) + struct isapnp_softc *sc; +{ + ISAPNP_WRITE_ADDR(sc, r); + return ISAPNP_READ_DATA(sc); +} + +struct isa_attach_args * + isapnp_get_resource __P((struct isapnp_softc *, int)); +char *isapnp_id_to_vendor __P((char *, const u_char *)); + +int isapnp_config __P((bus_space_tag_t, bus_space_tag_t, + struct isa_attach_args *)); +void isapnp_unconfig __P((bus_space_tag_t, bus_space_tag_t, + struct isa_attach_args *)); + +#ifdef DEBUG_ISAPNP +void isapnp_print_mem __P((const char *, const struct isapnp_region *)); +void isapnp_print_io __P((const char *, const struct isapnp_region *)); +void isapnp_print_irq __P((const char *, const struct isapnp_pin *)); +void isapnp_print_drq __P((const char *, const struct isapnp_pin *)); +void isapnp_print_dep_start __P((const char *, const u_char)); +void isapnp_print_attach __P((const struct isa_attach_args *)); +void isapnp_get_config __P((struct isapnp_softc *, + struct isa_attach_args *)); +void isapnp_print_config __P((const struct isa_attach_args *)); +#endif /* DEBUG_ISAPNP */ #endif /* _DEV_ISA_ISAVAR_H_ */ |