Home | History | Annotate | Line # | Download | only in isa
isa.c revision 1.116.2.2
      1  1.116.2.2     skrll /*	$NetBSD: isa.c,v 1.116.2.2 2004/09/03 12:45:18 skrll Exp $	*/
      2       1.58       cgd 
      3        1.1       cgd /*-
      4      1.110   thorpej  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
      5      1.105   mycroft  * All rights reserved.
      6      1.105   mycroft  *
      7      1.105   mycroft  * This code is derived from software contributed to The NetBSD Foundation
      8      1.110   thorpej  * by Charles M. Hannum; by Jason R. Thorpe of Wasabi Systems, Inc.
      9        1.1       cgd  *
     10        1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11        1.1       cgd  * modification, are permitted provided that the following conditions
     12        1.1       cgd  * are met:
     13        1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14        1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15        1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17        1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18        1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     19        1.1       cgd  *    must display the following acknowledgement:
     20      1.105   mycroft  *        This product includes software developed by the NetBSD
     21      1.105   mycroft  *        Foundation, Inc. and its contributors.
     22      1.105   mycroft  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.105   mycroft  *    contributors may be used to endorse or promote products derived
     24      1.105   mycroft  *    from this software without specific prior written permission.
     25        1.1       cgd  *
     26      1.105   mycroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.105   mycroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.105   mycroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.105   mycroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.105   mycroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.105   mycroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.105   mycroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.105   mycroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.105   mycroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.105   mycroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.105   mycroft  * POSSIBILITY OF SUCH DAMAGE.
     37        1.1       cgd  */
     38      1.109     lukem 
     39      1.109     lukem #include <sys/cdefs.h>
     40  1.116.2.2     skrll __KERNEL_RCSID(0, "$NetBSD: isa.c,v 1.116.2.2 2004/09/03 12:45:18 skrll Exp $");
     41        1.1       cgd 
     42       1.31   mycroft #include <sys/param.h>
     43       1.31   mycroft #include <sys/systm.h>
     44       1.40   mycroft #include <sys/kernel.h>
     45       1.31   mycroft #include <sys/malloc.h>
     46       1.46   mycroft #include <sys/device.h>
     47       1.85   thorpej 
     48       1.85   thorpej #include <machine/intr.h>
     49       1.31   mycroft 
     50       1.72       cgd #include <dev/isa/isareg.h>
     51       1.72       cgd #include <dev/isa/isavar.h>
     52       1.95   thorpej #include <dev/isa/isadmareg.h>
     53       1.77       cgd 
     54      1.102       leo #include "isadma.h"
     55      1.102       leo 
     56      1.103  christos #include "isapnp.h"
     57      1.108      fvdl #if NISAPNP > 0
     58      1.103  christos #include <dev/isapnp/isapnpreg.h>
     59      1.103  christos #include <dev/isapnp/isapnpvar.h>
     60      1.103  christos #endif
     61      1.103  christos 
     62      1.110   thorpej int	isamatch(struct device *, struct cfdata *, void *);
     63      1.110   thorpej void	isaattach(struct device *, struct device *, void *);
     64  1.116.2.1     skrll int	isarescan(struct device *, const char *, const int *);
     65  1.116.2.1     skrll void	isachilddetached(struct device *, struct device *);
     66      1.110   thorpej int	isaprint(void *, const char *);
     67       1.77       cgd 
     68  1.116.2.1     skrll CFATTACH_DECL2(isa, sizeof(struct isa_softc),
     69  1.116.2.1     skrll     isamatch, isaattach, NULL, NULL, isarescan, isachilddetached);
     70       1.79   thorpej 
     71      1.110   thorpej void	isa_attach_knowndevs(struct isa_softc *);
     72      1.110   thorpej void	isa_free_knowndevs(struct isa_softc *);
     73      1.110   thorpej 
     74  1.116.2.1     skrll int	isasubmatch(struct device *, struct cfdata *, const locdesc_t *, void *);
     75  1.116.2.1     skrll int	isasearch(struct device *, struct cfdata *, const locdesc_t *, void *);
     76       1.91       cgd 
     77       1.77       cgd int
     78      1.110   thorpej isamatch(struct device *parent, struct cfdata *cf, void *aux)
     79       1.77       cgd {
     80       1.77       cgd 	/* XXX check other indicators */
     81       1.77       cgd 
     82       1.77       cgd         return (1);
     83       1.77       cgd }
     84       1.77       cgd 
     85       1.77       cgd void
     86      1.110   thorpej isaattach(struct device *parent, struct device *self, void *aux)
     87       1.77       cgd {
     88       1.77       cgd 	struct isa_softc *sc = (struct isa_softc *)self;
     89       1.77       cgd 	struct isabus_attach_args *iba = aux;
     90  1.116.2.1     skrll 	static const int wildcard[7] = {
     91  1.116.2.1     skrll 		ISACF_PORT_DEFAULT, ISACF_SIZE_DEFAULT,
     92  1.116.2.1     skrll 		ISACF_IOMEM_DEFAULT, ISACF_IOSIZ_DEFAULT,
     93  1.116.2.1     skrll 		ISACF_IRQ_DEFAULT, ISACF_DRQ_DEFAULT, ISACF_DRQ2_DEFAULT
     94  1.116.2.1     skrll 	};
     95       1.98   thorpej 
     96      1.110   thorpej 	TAILQ_INIT(&sc->sc_knowndevs);
     97      1.110   thorpej 	sc->sc_dynamicdevs = 0;
     98      1.110   thorpej 
     99       1.80       cgd 	isa_attach_hook(parent, self, iba);
    100       1.88  christos 	printf("\n");
    101       1.77       cgd 
    102      1.110   thorpej 	/* XXX Add code to fetch known-devices. */
    103      1.110   thorpej 
    104       1.89   thorpej 	sc->sc_iot = iba->iba_iot;
    105       1.89   thorpej 	sc->sc_memt = iba->iba_memt;
    106       1.95   thorpej 	sc->sc_dmat = iba->iba_dmat;
    107       1.80       cgd 	sc->sc_ic = iba->iba_ic;
    108      1.103  christos 
    109      1.103  christos #if NISAPNP > 0
    110      1.103  christos 	/*
    111      1.103  christos 	 * Reset isapnp cards that the bios configured for us
    112      1.103  christos 	 */
    113      1.103  christos 	isapnp_isa_attach_hook(sc);
    114      1.103  christos #endif
    115       1.78       cgd 
    116      1.102       leo #if NISADMA > 0
    117       1.82   thorpej 	/*
    118      1.101   thorpej 	 * Initialize our DMA state.
    119       1.95   thorpej 	 */
    120      1.101   thorpej 	isa_dmainit(sc->sc_ic, sc->sc_iot, sc->sc_dmat, self);
    121      1.102       leo #endif
    122      1.100  drochner 
    123      1.110   thorpej 	/* Attach all direct-config children. */
    124      1.110   thorpej 	isa_attach_knowndevs(sc);
    125      1.110   thorpej 
    126      1.110   thorpej 	/*
    127      1.110   thorpej 	 * If we don't support dynamic hello/goodbye of devices,
    128      1.110   thorpej 	 * then free the knowndevs info now.
    129      1.110   thorpej 	 */
    130      1.110   thorpej 	if (sc->sc_dynamicdevs == 0)
    131      1.110   thorpej 		isa_free_knowndevs(sc);
    132      1.110   thorpej 
    133      1.110   thorpej 	/* Attach all indrect-config children. */
    134  1.116.2.1     skrll 	isarescan(self, "isa", wildcard);
    135  1.116.2.1     skrll }
    136  1.116.2.1     skrll 
    137  1.116.2.1     skrll int
    138  1.116.2.1     skrll isarescan(struct device *self, const char *ifattr, const int *locators)
    139  1.116.2.1     skrll {
    140  1.116.2.1     skrll 	int help[8];
    141  1.116.2.1     skrll 	locdesc_t *ldesc = (void *)help; /* XXX */;
    142  1.116.2.1     skrll 
    143  1.116.2.1     skrll 	ldesc->len = 7;
    144  1.116.2.1     skrll 	memcpy(&ldesc->locs, locators, 7 * sizeof(int));
    145  1.116.2.1     skrll 
    146  1.116.2.1     skrll 	/*
    147  1.116.2.1     skrll 	 * XXX Bus independant code calling this function does not
    148  1.116.2.1     skrll 	 * know the locator default values. It assumes "-1" for now.
    149  1.116.2.1     skrll 	 * (should be made available by "config" one day)
    150  1.116.2.1     skrll 	 * So fixup where the "-1" is not correct.
    151  1.116.2.1     skrll 	 */
    152  1.116.2.1     skrll 	if (ldesc->locs[ISACF_SIZE] == -1)
    153  1.116.2.1     skrll 		ldesc->locs[ISACF_SIZE] = ISACF_SIZE_DEFAULT;
    154  1.116.2.1     skrll 	if (ldesc->locs[ISACF_IOSIZ] == -1)
    155  1.116.2.1     skrll 		ldesc->locs[ISACF_IOSIZ] = ISACF_IOSIZ_DEFAULT;
    156  1.116.2.1     skrll 
    157  1.116.2.1     skrll 	config_search_loc(isasearch, self, ifattr, ldesc, NULL);
    158  1.116.2.1     skrll 	return (0);
    159  1.116.2.1     skrll }
    160  1.116.2.1     skrll 
    161  1.116.2.1     skrll void
    162  1.116.2.1     skrll isachilddetached(struct device *self, struct device *child)
    163  1.116.2.1     skrll {
    164  1.116.2.1     skrll 	/* nothing to do */
    165       1.77       cgd }
    166        1.1       cgd 
    167      1.110   thorpej void
    168      1.110   thorpej isa_attach_knowndevs(struct isa_softc *sc)
    169      1.110   thorpej {
    170      1.110   thorpej 	struct isa_attach_args ia;
    171      1.110   thorpej 	struct isa_knowndev *ik;
    172      1.110   thorpej 
    173      1.110   thorpej 	if (TAILQ_EMPTY(&sc->sc_knowndevs))
    174      1.110   thorpej 		return;
    175      1.110   thorpej 
    176      1.110   thorpej 	TAILQ_FOREACH(ik, &sc->sc_knowndevs, ik_list) {
    177      1.110   thorpej 		if (ik->ik_claimed != NULL)
    178      1.110   thorpej 			continue;
    179      1.110   thorpej 
    180      1.110   thorpej 		ia.ia_iot = sc->sc_iot;
    181      1.110   thorpej 		ia.ia_memt = sc->sc_memt;
    182      1.110   thorpej 		ia.ia_dmat = sc->sc_dmat;
    183      1.110   thorpej 		ia.ia_ic = sc->sc_ic;
    184      1.110   thorpej 
    185      1.110   thorpej 		ia.ia_pnpname = ik->ik_pnpname;
    186      1.110   thorpej 		ia.ia_pnpcompatnames = ik->ik_pnpcompatnames;
    187      1.110   thorpej 
    188      1.110   thorpej 		ia.ia_io = ik->ik_io;
    189      1.110   thorpej 		ia.ia_nio = ik->ik_nio;
    190      1.110   thorpej 
    191      1.110   thorpej 		ia.ia_iomem = ik->ik_iomem;
    192      1.110   thorpej 		ia.ia_niomem = ik->ik_niomem;
    193      1.110   thorpej 
    194      1.110   thorpej 		ia.ia_irq = ik->ik_irq;
    195      1.110   thorpej 		ia.ia_nirq = ik->ik_nirq;
    196      1.110   thorpej 
    197      1.110   thorpej 		ia.ia_drq = ik->ik_drq;
    198      1.110   thorpej 		ia.ia_ndrq = ik->ik_ndrq;
    199      1.110   thorpej 
    200      1.110   thorpej 		ia.ia_aux = NULL;
    201      1.110   thorpej 
    202  1.116.2.1     skrll 		/* XXX should setup locator array */
    203  1.116.2.1     skrll 
    204  1.116.2.1     skrll 		ik->ik_claimed = config_found_sm_loc(&sc->sc_dev,
    205  1.116.2.1     skrll 		    "isa", 0, &ia, isaprint, isasubmatch);
    206      1.110   thorpej 	}
    207      1.110   thorpej }
    208      1.110   thorpej 
    209      1.110   thorpej void
    210      1.110   thorpej isa_free_knowndevs(struct isa_softc *sc)
    211      1.110   thorpej {
    212      1.110   thorpej 	struct isa_knowndev *ik;
    213      1.110   thorpej 	struct isa_pnpname *ipn;
    214      1.110   thorpej 
    215      1.110   thorpej #define	FREEIT(x)	if (x != NULL) free(x, M_DEVBUF)
    216      1.110   thorpej 
    217      1.110   thorpej 	while ((ik = TAILQ_FIRST(&sc->sc_knowndevs)) != NULL) {
    218      1.110   thorpej 		TAILQ_REMOVE(&sc->sc_knowndevs, ik, ik_list);
    219      1.110   thorpej 		FREEIT(ik->ik_pnpname);
    220      1.110   thorpej 		while ((ipn = ik->ik_pnpcompatnames) != NULL) {
    221      1.110   thorpej 			ik->ik_pnpcompatnames = ipn->ipn_next;
    222      1.110   thorpej 			free(ipn->ipn_name, M_DEVBUF);
    223      1.110   thorpej 			free(ipn, M_DEVBUF);
    224      1.110   thorpej 		}
    225      1.110   thorpej 		FREEIT(ik->ik_io);
    226      1.110   thorpej 		FREEIT(ik->ik_iomem);
    227      1.110   thorpej 		FREEIT(ik->ik_irq);
    228      1.110   thorpej 		FREEIT(ik->ik_drq);
    229      1.110   thorpej 		free(ik, M_DEVBUF);
    230      1.110   thorpej 	}
    231      1.110   thorpej 
    232      1.110   thorpej #undef FREEIT
    233      1.110   thorpej }
    234      1.110   thorpej 
    235  1.116.2.1     skrll static int
    236  1.116.2.1     skrll checkattachargs(struct isa_attach_args *ia, const int *loc)
    237      1.110   thorpej {
    238      1.110   thorpej 	int i;
    239      1.110   thorpej 
    240      1.110   thorpej 	if (ia->ia_nio == 0) {
    241  1.116.2.1     skrll 		if (loc[ISACF_PORT] != ISACF_PORT_DEFAULT)
    242      1.110   thorpej 			return (0);
    243      1.110   thorpej 	} else {
    244  1.116.2.1     skrll 		if (loc[ISACF_PORT] != ISACF_PORT_DEFAULT &&
    245  1.116.2.1     skrll 		    loc[ISACF_PORT] != ia->ia_io[0].ir_addr)
    246      1.110   thorpej 			return (0);
    247      1.110   thorpej 	}
    248      1.110   thorpej 
    249      1.110   thorpej 	if (ia->ia_niomem == 0) {
    250  1.116.2.1     skrll 		if (loc[ISACF_IOMEM] != ISACF_IOMEM_DEFAULT)
    251      1.110   thorpej 			return (0);
    252      1.110   thorpej 	} else {
    253  1.116.2.1     skrll 		if (loc[ISACF_IOMEM] != ISACF_IOMEM_DEFAULT &&
    254  1.116.2.1     skrll 		    loc[ISACF_IOMEM] != ia->ia_iomem[0].ir_addr)
    255      1.110   thorpej 			return (0);
    256      1.110   thorpej 	}
    257      1.110   thorpej 
    258      1.110   thorpej 	if (ia->ia_nirq == 0) {
    259  1.116.2.1     skrll 		if (loc[ISACF_IRQ] != ISACF_IRQ_DEFAULT)
    260      1.110   thorpej 			return (0);
    261      1.110   thorpej 	} else {
    262  1.116.2.1     skrll 		if (loc[ISACF_IRQ] != ISACF_IRQ_DEFAULT &&
    263  1.116.2.1     skrll 		    loc[ISACF_IRQ] != ia->ia_irq[0].ir_irq)
    264      1.110   thorpej 			return (0);
    265      1.110   thorpej 	}
    266      1.110   thorpej 
    267      1.110   thorpej 	if (ia->ia_ndrq == 0) {
    268  1.116.2.1     skrll 		if (loc[ISACF_DRQ] != ISACF_DRQ_DEFAULT)
    269      1.110   thorpej 			return (0);
    270  1.116.2.1     skrll 		if (loc[ISACF_DRQ2] != ISACF_DRQ2_DEFAULT)
    271      1.110   thorpej 			return (0);
    272      1.110   thorpej 	} else {
    273      1.110   thorpej 		for (i = 0; i < 2; i++) {
    274      1.110   thorpej 			if (i == ia->ia_ndrq)
    275      1.110   thorpej 				break;
    276  1.116.2.1     skrll 			if (loc[ISACF_DRQ + i] != ISACF_DRQ_DEFAULT &&
    277  1.116.2.1     skrll 			    loc[ISACF_DRQ + i] != ia->ia_drq[i].ir_drq)
    278      1.110   thorpej 				return (0);
    279      1.110   thorpej 		}
    280      1.110   thorpej 		for (; i < 2; i++) {
    281  1.116.2.1     skrll 			if (loc[ISACF_DRQ + i] != ISACF_DRQ_DEFAULT)
    282      1.110   thorpej 				return (0);
    283      1.110   thorpej 		}
    284      1.110   thorpej 	}
    285      1.110   thorpej 
    286  1.116.2.1     skrll 	return (1);
    287  1.116.2.1     skrll }
    288  1.116.2.1     skrll 
    289  1.116.2.1     skrll int
    290  1.116.2.1     skrll isasubmatch(struct device *parent, struct cfdata *cf,
    291  1.116.2.1     skrll 	    const locdesc_t *ldesc, void *aux)
    292  1.116.2.1     skrll {
    293  1.116.2.1     skrll 	struct isa_attach_args *ia = aux;
    294  1.116.2.1     skrll 
    295  1.116.2.1     skrll 	if (!checkattachargs(ia, cf->cf_loc))
    296  1.116.2.1     skrll 		return (0);
    297  1.116.2.1     skrll 
    298      1.112   thorpej 	return (config_match(parent, cf, aux));
    299      1.110   thorpej }
    300      1.110   thorpej 
    301       1.46   mycroft int
    302      1.110   thorpej isaprint(void *aux, const char *isa)
    303       1.46   mycroft {
    304       1.46   mycroft 	struct isa_attach_args *ia = aux;
    305      1.110   thorpej 	const char *sep;
    306      1.110   thorpej 	int i;
    307      1.110   thorpej 
    308      1.110   thorpej 	/*
    309      1.110   thorpej 	 * This block of code only fires if we have a direct-config'd
    310      1.110   thorpej 	 * device for which there is no driver match.
    311      1.110   thorpej 	 */
    312      1.110   thorpej 	if (isa != NULL) {
    313      1.110   thorpej 		struct isa_pnpname *ipn;
    314      1.110   thorpej 
    315      1.110   thorpej 		if (ia->ia_pnpname != NULL)
    316      1.116   thorpej 			aprint_normal("%s", ia->ia_pnpname);
    317      1.110   thorpej 		if ((ipn = ia->ia_pnpcompatnames) != NULL) {
    318      1.116   thorpej 			aprint_normal(" (");	/* ) */
    319      1.110   thorpej 			for (sep = ""; ipn != NULL;
    320      1.110   thorpej 			     ipn = ipn->ipn_next, sep = " ") {
    321      1.116   thorpej 				aprint_normal("%s%s", sep, ipn->ipn_name);
    322      1.110   thorpej 			}
    323      1.116   thorpej 	/* ( */		aprint_normal(")");
    324      1.110   thorpej 		}
    325      1.116   thorpej 		aprint_normal(" at %s", isa);
    326      1.110   thorpej 	}
    327      1.110   thorpej 
    328      1.110   thorpej 	if (ia->ia_nio) {
    329      1.110   thorpej 		sep = "";
    330      1.116   thorpej 		aprint_normal(" port ");
    331      1.110   thorpej 		for (i = 0; i < ia->ia_nio; i++) {
    332      1.110   thorpej 			if (ia->ia_io[i].ir_size == 0)
    333      1.110   thorpej 				continue;
    334      1.116   thorpej 			aprint_normal("%s0x%x", sep, ia->ia_io[i].ir_addr);
    335      1.110   thorpej 			if (ia->ia_io[i].ir_size > 1)
    336      1.116   thorpej 				aprint_normal("-0x%x", ia->ia_io[i].ir_addr +
    337      1.110   thorpej 				    ia->ia_io[i].ir_size - 1);
    338      1.110   thorpej 			sep = ",";
    339      1.110   thorpej 		}
    340      1.110   thorpej 	}
    341      1.110   thorpej 
    342      1.110   thorpej 	if (ia->ia_niomem) {
    343      1.110   thorpej 		sep = "";
    344      1.116   thorpej 		aprint_normal(" iomem ");
    345      1.110   thorpej 		for (i = 0; i < ia->ia_niomem; i++) {
    346      1.110   thorpej 			if (ia->ia_iomem[i].ir_size == 0)
    347      1.110   thorpej 				continue;
    348      1.116   thorpej 			aprint_normal("%s0x%x", sep, ia->ia_iomem[i].ir_addr);
    349      1.110   thorpej 			if (ia->ia_iomem[i].ir_size > 1)
    350      1.116   thorpej 				aprint_normal("-0x%x", ia->ia_iomem[i].ir_addr +
    351      1.110   thorpej 				    ia->ia_iomem[i].ir_size - 1);
    352      1.110   thorpej 			sep = ",";
    353      1.110   thorpej 		}
    354      1.110   thorpej 	}
    355      1.110   thorpej 
    356      1.110   thorpej 	if (ia->ia_nirq) {
    357      1.110   thorpej 		sep = "";
    358      1.116   thorpej 		aprint_normal(" irq ");
    359      1.110   thorpej 		for (i = 0; i < ia->ia_nirq; i++) {
    360      1.110   thorpej 			if (ia->ia_irq[i].ir_irq == ISACF_IRQ_DEFAULT)
    361      1.110   thorpej 				continue;
    362      1.116   thorpej 			aprint_normal("%s%d", sep, ia->ia_irq[i].ir_irq);
    363      1.110   thorpej 			sep = ",";
    364      1.110   thorpej 		}
    365      1.110   thorpej 	}
    366      1.110   thorpej 
    367      1.110   thorpej 	if (ia->ia_ndrq) {
    368      1.110   thorpej 		sep = "";
    369      1.116   thorpej 		aprint_normal(" drq ");
    370      1.110   thorpej 		for (i = 0; i < ia->ia_ndrq; i++) {
    371      1.110   thorpej 			if (ia->ia_drq[i].ir_drq == ISACF_DRQ_DEFAULT)
    372      1.110   thorpej 				continue;
    373      1.116   thorpej 			aprint_normal("%s%d", sep, ia->ia_drq[i].ir_drq);
    374      1.110   thorpej 			sep = ",";
    375      1.110   thorpej 		}
    376      1.110   thorpej 	}
    377       1.46   mycroft 
    378       1.71   mycroft 	return (UNCONF);
    379       1.46   mycroft }
    380       1.46   mycroft 
    381       1.94       cgd int
    382  1.116.2.1     skrll isasearch(struct device *parent, struct cfdata *cf,
    383  1.116.2.1     skrll 	  const locdesc_t *ldesc, void *aux)
    384       1.94       cgd {
    385      1.110   thorpej 	struct isa_io res_io[1];
    386      1.110   thorpej 	struct isa_iomem res_mem[1];
    387      1.110   thorpej 	struct isa_irq res_irq[1];
    388      1.110   thorpej 	struct isa_drq res_drq[2];
    389       1.94       cgd 	struct isa_softc *sc = (struct isa_softc *)parent;
    390       1.94       cgd 	struct isa_attach_args ia;
    391  1.116.2.1     skrll 	int help[8];
    392  1.116.2.1     skrll 	locdesc_t *locs = (void *)&help; /* XXX */
    393       1.94       cgd 	int tryagain;
    394       1.94       cgd 
    395       1.94       cgd 	do {
    396      1.110   thorpej 		ia.ia_pnpname = NULL;
    397      1.110   thorpej 		ia.ia_pnpcompatnames = NULL;
    398      1.110   thorpej 
    399      1.110   thorpej 		res_io[0].ir_addr = cf->cf_loc[ISACF_PORT];
    400      1.110   thorpej 		res_io[0].ir_size = 0;
    401      1.110   thorpej 
    402      1.110   thorpej 		res_mem[0].ir_addr = cf->cf_loc[ISACF_IOMEM];
    403      1.110   thorpej 		res_mem[0].ir_size = cf->cf_loc[ISACF_IOSIZ];
    404      1.110   thorpej 
    405      1.110   thorpej 		res_irq[0].ir_irq =
    406      1.110   thorpej 		    cf->cf_loc[ISACF_IRQ] == 2 ? 9 : cf->cf_loc[ISACF_IRQ];
    407      1.110   thorpej 
    408      1.110   thorpej 		res_drq[0].ir_drq = cf->cf_loc[ISACF_DRQ];
    409      1.110   thorpej 		res_drq[1].ir_drq = cf->cf_loc[ISACF_DRQ2];
    410      1.110   thorpej 
    411       1.94       cgd 		ia.ia_iot = sc->sc_iot;
    412       1.94       cgd 		ia.ia_memt = sc->sc_memt;
    413       1.95   thorpej 		ia.ia_dmat = sc->sc_dmat;
    414       1.94       cgd 		ia.ia_ic = sc->sc_ic;
    415      1.110   thorpej 
    416      1.110   thorpej 		ia.ia_io = res_io;
    417      1.110   thorpej 		ia.ia_nio = 1;
    418      1.110   thorpej 
    419      1.110   thorpej 		ia.ia_iomem = res_mem;
    420      1.110   thorpej 		ia.ia_niomem = 1;
    421      1.110   thorpej 
    422      1.110   thorpej 		ia.ia_irq = res_irq;
    423      1.110   thorpej 		ia.ia_nirq = 1;
    424      1.110   thorpej 
    425      1.110   thorpej 		ia.ia_drq = res_drq;
    426      1.110   thorpej 		ia.ia_ndrq = 2;
    427       1.94       cgd 
    428  1.116.2.1     skrll 		if (!checkattachargs(&ia, ldesc->locs))
    429  1.116.2.1     skrll 			return (0);
    430  1.116.2.1     skrll 
    431       1.94       cgd 		tryagain = 0;
    432      1.112   thorpej 		if (config_match(parent, cf, &ia) > 0) {
    433  1.116.2.1     skrll 			/*
    434  1.116.2.1     skrll 			 * This is not necessary for detach, but might
    435  1.116.2.1     skrll 			 * still be useful to collect device information.
    436  1.116.2.1     skrll 			 */
    437  1.116.2.1     skrll 			locs->len = 7;
    438  1.116.2.1     skrll 			locs->locs[ISACF_PORT] = ia.ia_io[0].ir_addr;
    439  1.116.2.1     skrll 			locs->locs[ISACF_SIZE] = ia.ia_io[0].ir_size;
    440  1.116.2.1     skrll 			locs->locs[ISACF_IOMEM] = ia.ia_iomem[0].ir_addr;
    441  1.116.2.1     skrll 			locs->locs[ISACF_IOSIZ] = ia.ia_iomem[0].ir_size;
    442  1.116.2.1     skrll 			locs->locs[ISACF_IRQ] = ia.ia_irq[0].ir_irq;
    443  1.116.2.1     skrll 			locs->locs[ISACF_DRQ] = ia.ia_drq[0].ir_drq;
    444  1.116.2.1     skrll 			locs->locs[ISACF_DRQ2] = ia.ia_drq[1].ir_drq;
    445  1.116.2.1     skrll 			config_attach_loc(parent, cf, locs, &ia, isaprint);
    446       1.94       cgd 			tryagain = (cf->cf_fstate == FSTATE_STAR);
    447       1.94       cgd 		}
    448       1.94       cgd 	} while (tryagain);
    449       1.94       cgd 
    450       1.91       cgd 	return (0);
    451       1.72       cgd }
    452       1.72       cgd 
    453       1.72       cgd char *
    454      1.110   thorpej isa_intr_typename(int type)
    455       1.72       cgd {
    456       1.72       cgd 
    457       1.72       cgd 	switch (type) {
    458       1.75   mycroft         case IST_NONE :
    459       1.72       cgd 		return ("none");
    460       1.75   mycroft         case IST_PULSE:
    461       1.72       cgd 		return ("pulsed");
    462       1.75   mycroft         case IST_EDGE:
    463       1.72       cgd 		return ("edge-triggered");
    464       1.75   mycroft         case IST_LEVEL:
    465       1.72       cgd 		return ("level-triggered");
    466       1.72       cgd 	default:
    467       1.72       cgd 		panic("isa_intr_typename: invalid type %d", type);
    468       1.72       cgd 	}
    469        1.1       cgd }
    470