Home | History | Annotate | Line # | Download | only in isa
isa.c revision 1.138.76.8
      1  1.138.76.8   thorpej /*	$NetBSD: isa.c,v 1.138.76.8 2021/04/05 01:01:48 thorpej Exp $	*/
      2        1.58       cgd 
      3         1.1       cgd /*-
      4       1.133        ad  * Copyright (c) 1998, 2001, 2008 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  *
     19       1.105   mycroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.105   mycroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.105   mycroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.105   mycroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.105   mycroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.105   mycroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.105   mycroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.105   mycroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.105   mycroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.105   mycroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.105   mycroft  * POSSIBILITY OF SUCH DAMAGE.
     30         1.1       cgd  */
     31       1.109     lukem 
     32       1.109     lukem #include <sys/cdefs.h>
     33  1.138.76.8   thorpej __KERNEL_RCSID(0, "$NetBSD: isa.c,v 1.138.76.8 2021/04/05 01:01:48 thorpej Exp $");
     34         1.1       cgd 
     35        1.31   mycroft #include <sys/param.h>
     36        1.31   mycroft #include <sys/systm.h>
     37        1.40   mycroft #include <sys/kernel.h>
     38        1.31   mycroft #include <sys/malloc.h>
     39        1.46   mycroft #include <sys/device.h>
     40        1.85   thorpej 
     41       1.129        ad #include <sys/intr.h>
     42        1.31   mycroft 
     43        1.72       cgd #include <dev/isa/isareg.h>
     44        1.72       cgd #include <dev/isa/isavar.h>
     45        1.95   thorpej #include <dev/isa/isadmareg.h>
     46        1.77       cgd 
     47       1.102       leo #include "isadma.h"
     48       1.102       leo 
     49       1.103  christos #include "isapnp.h"
     50       1.108      fvdl #if NISAPNP > 0
     51       1.103  christos #include <dev/isapnp/isapnpreg.h>
     52       1.103  christos #include <dev/isapnp/isapnpvar.h>
     53       1.103  christos #endif
     54       1.103  christos 
     55       1.119  drochner #include "locators.h"
     56       1.119  drochner 
     57       1.132      cube int	isamatch(device_t, cfdata_t, void *);
     58       1.132      cube void	isaattach(device_t, device_t, void *);
     59       1.136    dyoung int	isadetach(device_t, int);
     60       1.132      cube int	isarescan(device_t, const char *, const int *);
     61       1.132      cube void	isachilddetached(device_t, device_t);
     62       1.110   thorpej int	isaprint(void *, const char *);
     63        1.77       cgd 
     64       1.132      cube CFATTACH_DECL2_NEW(isa, sizeof(struct isa_softc),
     65       1.136    dyoung     isamatch, isaattach, isadetach, NULL, isarescan, isachilddetached);
     66        1.79   thorpej 
     67       1.110   thorpej void	isa_attach_knowndevs(struct isa_softc *);
     68       1.110   thorpej void	isa_free_knowndevs(struct isa_softc *);
     69       1.110   thorpej 
     70       1.132      cube int	isasubmatch(device_t, cfdata_t, const int *, void *);
     71       1.132      cube int	isasearch(device_t, cfdata_t, const int *, void *);
     72        1.91       cgd 
     73       1.133        ad static int	isa_slotcount = -1;	/* -1 == don't know how many */
     74       1.133        ad 
     75        1.77       cgd int
     76       1.132      cube isamatch(device_t parent, cfdata_t cf, void *aux)
     77        1.77       cgd {
     78        1.77       cgd 	/* XXX check other indicators */
     79        1.77       cgd 
     80       1.128     isaki 	return (1);
     81        1.77       cgd }
     82        1.77       cgd 
     83        1.77       cgd void
     84       1.132      cube isaattach(device_t parent, device_t self, void *aux)
     85        1.77       cgd {
     86       1.132      cube 	struct isa_softc *sc = device_private(self);
     87        1.77       cgd 	struct isabus_attach_args *iba = aux;
     88       1.122  drochner 	static const int wildcard[ISACF_NLOCS] = {
     89  1.138.76.4   thorpej 		[ISACF_PORT]  = ISACF_PORT_DEFAULT,
     90  1.138.76.4   thorpej 		[ISACF_SIZE]  = ISACF_SIZE_DEFAULT,
     91  1.138.76.4   thorpej 		[ISACF_IOMEM] = ISACF_IOMEM_DEFAULT,
     92  1.138.76.4   thorpej 		[ISACF_IOSIZ] = ISACF_IOSIZ_DEFAULT,
     93  1.138.76.4   thorpej 		[ISACF_IRQ]   = ISACF_IRQ_DEFAULT,
     94  1.138.76.4   thorpej 		[ISACF_DRQ]   = ISACF_DRQ_DEFAULT,
     95  1.138.76.4   thorpej 		[ISACF_DRQ2]  = ISACF_DRQ2_DEFAULT,
     96       1.117  drochner 	};
     97        1.98   thorpej 
     98       1.110   thorpej 	TAILQ_INIT(&sc->sc_knowndevs);
     99       1.110   thorpej 	sc->sc_dynamicdevs = 0;
    100       1.110   thorpej 
    101       1.132      cube 	sc->sc_dev = self;
    102       1.132      cube 
    103        1.80       cgd 	isa_attach_hook(parent, self, iba);
    104       1.130  jmcneill 	aprint_naive("\n");
    105       1.130  jmcneill 	aprint_normal("\n");
    106        1.77       cgd 
    107       1.110   thorpej 	/* XXX Add code to fetch known-devices. */
    108       1.110   thorpej 
    109        1.89   thorpej 	sc->sc_iot = iba->iba_iot;
    110        1.89   thorpej 	sc->sc_memt = iba->iba_memt;
    111        1.95   thorpej 	sc->sc_dmat = iba->iba_dmat;
    112        1.80       cgd 	sc->sc_ic = iba->iba_ic;
    113       1.103  christos 
    114       1.103  christos #if NISAPNP > 0
    115       1.103  christos 	/*
    116       1.103  christos 	 * Reset isapnp cards that the bios configured for us
    117       1.103  christos 	 */
    118       1.103  christos 	isapnp_isa_attach_hook(sc);
    119       1.103  christos #endif
    120        1.78       cgd 
    121       1.102       leo #if NISADMA > 0
    122        1.82   thorpej 	/*
    123       1.101   thorpej 	 * Initialize our DMA state.
    124        1.95   thorpej 	 */
    125       1.101   thorpej 	isa_dmainit(sc->sc_ic, sc->sc_iot, sc->sc_dmat, self);
    126       1.102       leo #endif
    127       1.100  drochner 
    128       1.110   thorpej 	/* Attach all direct-config children. */
    129       1.110   thorpej 	isa_attach_knowndevs(sc);
    130       1.110   thorpej 
    131       1.110   thorpej 	/*
    132       1.110   thorpej 	 * If we don't support dynamic hello/goodbye of devices,
    133       1.110   thorpej 	 * then free the knowndevs info now.
    134       1.110   thorpej 	 */
    135       1.110   thorpej 	if (sc->sc_dynamicdevs == 0)
    136       1.110   thorpej 		isa_free_knowndevs(sc);
    137       1.110   thorpej 
    138       1.135    dyoung 	/* Attach all indirect-config children. */
    139  1.138.76.4   thorpej 	isarescan(self, NULL, wildcard);
    140       1.131  jmcneill 
    141       1.131  jmcneill 	if (!pmf_device_register(self, NULL, NULL))
    142       1.131  jmcneill 		aprint_error_dev(self, "couldn't establish power handler\n");
    143       1.117  drochner }
    144       1.117  drochner 
    145       1.117  drochner int
    146       1.136    dyoung isadetach(device_t self, int flags)
    147       1.136    dyoung {
    148       1.136    dyoung 	struct isa_softc *sc = device_private(self);
    149       1.136    dyoung 	int rc;
    150       1.136    dyoung 
    151       1.136    dyoung 	if ((rc = config_detach_children(self, flags)) != 0)
    152       1.136    dyoung 		return rc;
    153       1.136    dyoung 
    154       1.136    dyoung 	pmf_device_deregister(self);
    155       1.136    dyoung 
    156       1.136    dyoung 	isa_free_knowndevs(sc);
    157       1.136    dyoung 
    158       1.136    dyoung #if NISADMA > 0
    159       1.136    dyoung 	isa_dmadestroy(sc->sc_ic);
    160       1.136    dyoung #endif
    161       1.137    cegger 	isa_detach_hook(sc->sc_ic, self);
    162       1.136    dyoung 
    163       1.136    dyoung 	return 0;
    164       1.136    dyoung }
    165       1.136    dyoung 
    166       1.136    dyoung int
    167       1.132      cube isarescan(device_t self, const char *ifattr, const int *locators)
    168       1.117  drochner {
    169       1.138  jmcneill 	prop_dictionary_t dict;
    170       1.121  drochner 	int locs[ISACF_NLOCS];
    171       1.138  jmcneill 	bool no_legacy_devices = false;
    172       1.138  jmcneill 
    173       1.138  jmcneill 	dict = device_properties(self);
    174       1.138  jmcneill 	if (prop_dictionary_get_bool(dict, "no-legacy-devices",
    175       1.138  jmcneill 	    &no_legacy_devices) == true) {
    176       1.138  jmcneill 		aprint_debug_dev(self, "platform reports no legacy devices\n");
    177       1.138  jmcneill 		return 0;
    178       1.138  jmcneill 	}
    179       1.117  drochner 
    180       1.121  drochner 	memcpy(locs, locators, sizeof(locs));
    181       1.117  drochner 
    182       1.117  drochner 	/*
    183       1.127       wiz 	 * XXX Bus independent code calling this function does not
    184       1.117  drochner 	 * know the locator default values. It assumes "-1" for now.
    185       1.117  drochner 	 * (should be made available by "config" one day)
    186       1.117  drochner 	 * So fixup where the "-1" is not correct.
    187       1.117  drochner 	 */
    188       1.121  drochner 	if (locs[ISACF_SIZE] == -1)
    189       1.121  drochner 		locs[ISACF_SIZE] = ISACF_SIZE_DEFAULT;
    190       1.121  drochner 	if (locs[ISACF_IOSIZ] == -1)
    191       1.121  drochner 		locs[ISACF_IOSIZ] = ISACF_IOSIZ_DEFAULT;
    192       1.117  drochner 
    193  1.138.76.1   thorpej 	config_search(self, NULL,
    194  1.138.76.6   thorpej 	    CFARG_SEARCH, isasearch,
    195  1.138.76.1   thorpej 	    CFARG_LOCATORS, locs,
    196  1.138.76.1   thorpej 	    CFARG_EOL);
    197       1.117  drochner 	return (0);
    198       1.117  drochner }
    199       1.117  drochner 
    200       1.117  drochner void
    201       1.132      cube isachilddetached(device_t self, device_t child)
    202       1.117  drochner {
    203       1.136    dyoung 	struct isa_knowndev *ik;
    204       1.136    dyoung 	struct isa_softc *sc = device_private(self);
    205       1.136    dyoung 
    206       1.136    dyoung 	TAILQ_FOREACH(ik, &sc->sc_knowndevs, ik_list) {
    207       1.136    dyoung 		if (ik->ik_claimed == child)
    208       1.136    dyoung 			ik->ik_claimed = NULL;
    209       1.136    dyoung 	}
    210        1.77       cgd }
    211         1.1       cgd 
    212       1.110   thorpej void
    213       1.110   thorpej isa_attach_knowndevs(struct isa_softc *sc)
    214       1.110   thorpej {
    215       1.110   thorpej 	struct isa_attach_args ia;
    216       1.110   thorpej 	struct isa_knowndev *ik;
    217       1.110   thorpej 
    218       1.110   thorpej 	if (TAILQ_EMPTY(&sc->sc_knowndevs))
    219       1.110   thorpej 		return;
    220       1.110   thorpej 
    221       1.110   thorpej 	TAILQ_FOREACH(ik, &sc->sc_knowndevs, ik_list) {
    222       1.110   thorpej 		if (ik->ik_claimed != NULL)
    223       1.110   thorpej 			continue;
    224       1.110   thorpej 
    225       1.110   thorpej 		ia.ia_iot = sc->sc_iot;
    226       1.110   thorpej 		ia.ia_memt = sc->sc_memt;
    227       1.110   thorpej 		ia.ia_dmat = sc->sc_dmat;
    228       1.110   thorpej 		ia.ia_ic = sc->sc_ic;
    229       1.110   thorpej 
    230       1.110   thorpej 		ia.ia_pnpname = ik->ik_pnpname;
    231       1.110   thorpej 		ia.ia_pnpcompatnames = ik->ik_pnpcompatnames;
    232       1.110   thorpej 
    233       1.110   thorpej 		ia.ia_io = ik->ik_io;
    234       1.110   thorpej 		ia.ia_nio = ik->ik_nio;
    235       1.110   thorpej 
    236       1.110   thorpej 		ia.ia_iomem = ik->ik_iomem;
    237       1.110   thorpej 		ia.ia_niomem = ik->ik_niomem;
    238       1.110   thorpej 
    239       1.110   thorpej 		ia.ia_irq = ik->ik_irq;
    240       1.110   thorpej 		ia.ia_nirq = ik->ik_nirq;
    241       1.110   thorpej 
    242       1.110   thorpej 		ia.ia_drq = ik->ik_drq;
    243       1.110   thorpej 		ia.ia_ndrq = ik->ik_ndrq;
    244       1.110   thorpej 
    245       1.110   thorpej 		ia.ia_aux = NULL;
    246       1.110   thorpej 
    247       1.117  drochner 		/* XXX should setup locator array */
    248       1.117  drochner 
    249  1.138.76.2   thorpej 		ik->ik_claimed = config_found(sc->sc_dev, &ia, isaprint,
    250  1.138.76.2   thorpej 		    CFARG_SUBMATCH, isasubmatch,
    251  1.138.76.2   thorpej 		    CFARG_EOL);
    252       1.110   thorpej 	}
    253       1.110   thorpej }
    254       1.110   thorpej 
    255       1.110   thorpej void
    256       1.110   thorpej isa_free_knowndevs(struct isa_softc *sc)
    257       1.110   thorpej {
    258       1.110   thorpej 	struct isa_knowndev *ik;
    259       1.110   thorpej 	struct isa_pnpname *ipn;
    260       1.110   thorpej 
    261       1.110   thorpej #define	FREEIT(x)	if (x != NULL) free(x, M_DEVBUF)
    262       1.110   thorpej 
    263       1.110   thorpej 	while ((ik = TAILQ_FIRST(&sc->sc_knowndevs)) != NULL) {
    264       1.110   thorpej 		TAILQ_REMOVE(&sc->sc_knowndevs, ik, ik_list);
    265       1.110   thorpej 		FREEIT(ik->ik_pnpname);
    266       1.110   thorpej 		while ((ipn = ik->ik_pnpcompatnames) != NULL) {
    267       1.110   thorpej 			ik->ik_pnpcompatnames = ipn->ipn_next;
    268       1.110   thorpej 			free(ipn->ipn_name, M_DEVBUF);
    269       1.110   thorpej 			free(ipn, M_DEVBUF);
    270       1.110   thorpej 		}
    271       1.110   thorpej 		FREEIT(ik->ik_io);
    272       1.110   thorpej 		FREEIT(ik->ik_iomem);
    273       1.110   thorpej 		FREEIT(ik->ik_irq);
    274       1.110   thorpej 		FREEIT(ik->ik_drq);
    275       1.110   thorpej 		free(ik, M_DEVBUF);
    276       1.110   thorpej 	}
    277       1.110   thorpej 
    278       1.110   thorpej #undef FREEIT
    279       1.110   thorpej }
    280       1.110   thorpej 
    281       1.117  drochner static int
    282       1.117  drochner checkattachargs(struct isa_attach_args *ia, const int *loc)
    283       1.110   thorpej {
    284       1.110   thorpej 	int i;
    285       1.110   thorpej 
    286       1.110   thorpej 	if (ia->ia_nio == 0) {
    287       1.117  drochner 		if (loc[ISACF_PORT] != ISACF_PORT_DEFAULT)
    288       1.110   thorpej 			return (0);
    289       1.110   thorpej 	} else {
    290       1.117  drochner 		if (loc[ISACF_PORT] != ISACF_PORT_DEFAULT &&
    291       1.117  drochner 		    loc[ISACF_PORT] != ia->ia_io[0].ir_addr)
    292       1.110   thorpej 			return (0);
    293       1.110   thorpej 	}
    294       1.110   thorpej 
    295       1.110   thorpej 	if (ia->ia_niomem == 0) {
    296       1.117  drochner 		if (loc[ISACF_IOMEM] != ISACF_IOMEM_DEFAULT)
    297       1.110   thorpej 			return (0);
    298       1.110   thorpej 	} else {
    299       1.117  drochner 		if (loc[ISACF_IOMEM] != ISACF_IOMEM_DEFAULT &&
    300       1.117  drochner 		    loc[ISACF_IOMEM] != ia->ia_iomem[0].ir_addr)
    301       1.110   thorpej 			return (0);
    302       1.110   thorpej 	}
    303       1.110   thorpej 
    304       1.110   thorpej 	if (ia->ia_nirq == 0) {
    305       1.117  drochner 		if (loc[ISACF_IRQ] != ISACF_IRQ_DEFAULT)
    306       1.110   thorpej 			return (0);
    307       1.110   thorpej 	} else {
    308       1.117  drochner 		if (loc[ISACF_IRQ] != ISACF_IRQ_DEFAULT &&
    309       1.117  drochner 		    loc[ISACF_IRQ] != ia->ia_irq[0].ir_irq)
    310       1.110   thorpej 			return (0);
    311       1.110   thorpej 	}
    312       1.110   thorpej 
    313       1.110   thorpej 	if (ia->ia_ndrq == 0) {
    314       1.117  drochner 		if (loc[ISACF_DRQ] != ISACF_DRQ_DEFAULT)
    315       1.110   thorpej 			return (0);
    316       1.117  drochner 		if (loc[ISACF_DRQ2] != ISACF_DRQ2_DEFAULT)
    317       1.110   thorpej 			return (0);
    318       1.110   thorpej 	} else {
    319       1.110   thorpej 		for (i = 0; i < 2; i++) {
    320       1.110   thorpej 			if (i == ia->ia_ndrq)
    321       1.110   thorpej 				break;
    322       1.117  drochner 			if (loc[ISACF_DRQ + i] != ISACF_DRQ_DEFAULT &&
    323       1.117  drochner 			    loc[ISACF_DRQ + i] != ia->ia_drq[i].ir_drq)
    324       1.110   thorpej 				return (0);
    325       1.110   thorpej 		}
    326       1.110   thorpej 		for (; i < 2; i++) {
    327       1.117  drochner 			if (loc[ISACF_DRQ + i] != ISACF_DRQ_DEFAULT)
    328       1.110   thorpej 				return (0);
    329       1.110   thorpej 		}
    330       1.110   thorpej 	}
    331       1.110   thorpej 
    332       1.117  drochner 	return (1);
    333       1.117  drochner }
    334       1.117  drochner 
    335       1.117  drochner int
    336       1.132      cube isasubmatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    337       1.117  drochner {
    338       1.117  drochner 	struct isa_attach_args *ia = aux;
    339       1.117  drochner 
    340       1.117  drochner 	if (!checkattachargs(ia, cf->cf_loc))
    341       1.117  drochner 		return (0);
    342       1.117  drochner 
    343       1.112   thorpej 	return (config_match(parent, cf, aux));
    344       1.110   thorpej }
    345       1.110   thorpej 
    346        1.46   mycroft int
    347       1.110   thorpej isaprint(void *aux, const char *isa)
    348        1.46   mycroft {
    349        1.46   mycroft 	struct isa_attach_args *ia = aux;
    350       1.110   thorpej 	const char *sep;
    351       1.110   thorpej 	int i;
    352       1.110   thorpej 
    353       1.110   thorpej 	/*
    354       1.110   thorpej 	 * This block of code only fires if we have a direct-config'd
    355       1.110   thorpej 	 * device for which there is no driver match.
    356       1.110   thorpej 	 */
    357       1.110   thorpej 	if (isa != NULL) {
    358       1.110   thorpej 		struct isa_pnpname *ipn;
    359       1.110   thorpej 
    360       1.110   thorpej 		if (ia->ia_pnpname != NULL)
    361       1.116   thorpej 			aprint_normal("%s", ia->ia_pnpname);
    362       1.110   thorpej 		if ((ipn = ia->ia_pnpcompatnames) != NULL) {
    363       1.116   thorpej 			aprint_normal(" (");	/* ) */
    364       1.110   thorpej 			for (sep = ""; ipn != NULL;
    365       1.110   thorpej 			     ipn = ipn->ipn_next, sep = " ") {
    366       1.116   thorpej 				aprint_normal("%s%s", sep, ipn->ipn_name);
    367       1.110   thorpej 			}
    368       1.116   thorpej 	/* ( */		aprint_normal(")");
    369       1.110   thorpej 		}
    370       1.116   thorpej 		aprint_normal(" at %s", isa);
    371       1.110   thorpej 	}
    372       1.110   thorpej 
    373       1.110   thorpej 	if (ia->ia_nio) {
    374       1.110   thorpej 		sep = "";
    375       1.116   thorpej 		aprint_normal(" port ");
    376       1.110   thorpej 		for (i = 0; i < ia->ia_nio; i++) {
    377       1.110   thorpej 			if (ia->ia_io[i].ir_size == 0)
    378       1.110   thorpej 				continue;
    379       1.116   thorpej 			aprint_normal("%s0x%x", sep, ia->ia_io[i].ir_addr);
    380       1.110   thorpej 			if (ia->ia_io[i].ir_size > 1)
    381       1.116   thorpej 				aprint_normal("-0x%x", ia->ia_io[i].ir_addr +
    382       1.110   thorpej 				    ia->ia_io[i].ir_size - 1);
    383       1.110   thorpej 			sep = ",";
    384       1.110   thorpej 		}
    385       1.110   thorpej 	}
    386       1.110   thorpej 
    387       1.110   thorpej 	if (ia->ia_niomem) {
    388       1.110   thorpej 		sep = "";
    389       1.116   thorpej 		aprint_normal(" iomem ");
    390       1.110   thorpej 		for (i = 0; i < ia->ia_niomem; i++) {
    391       1.110   thorpej 			if (ia->ia_iomem[i].ir_size == 0)
    392       1.110   thorpej 				continue;
    393       1.116   thorpej 			aprint_normal("%s0x%x", sep, ia->ia_iomem[i].ir_addr);
    394       1.110   thorpej 			if (ia->ia_iomem[i].ir_size > 1)
    395       1.116   thorpej 				aprint_normal("-0x%x", ia->ia_iomem[i].ir_addr +
    396       1.110   thorpej 				    ia->ia_iomem[i].ir_size - 1);
    397       1.110   thorpej 			sep = ",";
    398       1.110   thorpej 		}
    399       1.110   thorpej 	}
    400       1.110   thorpej 
    401       1.110   thorpej 	if (ia->ia_nirq) {
    402       1.110   thorpej 		sep = "";
    403       1.116   thorpej 		aprint_normal(" irq ");
    404       1.110   thorpej 		for (i = 0; i < ia->ia_nirq; i++) {
    405       1.110   thorpej 			if (ia->ia_irq[i].ir_irq == ISACF_IRQ_DEFAULT)
    406       1.110   thorpej 				continue;
    407       1.116   thorpej 			aprint_normal("%s%d", sep, ia->ia_irq[i].ir_irq);
    408       1.110   thorpej 			sep = ",";
    409       1.110   thorpej 		}
    410       1.110   thorpej 	}
    411       1.110   thorpej 
    412       1.110   thorpej 	if (ia->ia_ndrq) {
    413       1.110   thorpej 		sep = "";
    414       1.116   thorpej 		aprint_normal(" drq ");
    415       1.110   thorpej 		for (i = 0; i < ia->ia_ndrq; i++) {
    416       1.110   thorpej 			if (ia->ia_drq[i].ir_drq == ISACF_DRQ_DEFAULT)
    417       1.110   thorpej 				continue;
    418       1.116   thorpej 			aprint_normal("%s%d", sep, ia->ia_drq[i].ir_drq);
    419       1.110   thorpej 			sep = ",";
    420       1.110   thorpej 		}
    421       1.110   thorpej 	}
    422        1.46   mycroft 
    423        1.71   mycroft 	return (UNCONF);
    424        1.46   mycroft }
    425        1.46   mycroft 
    426        1.94       cgd int
    427       1.132      cube isasearch(device_t parent, cfdata_t cf, const int *slocs, void *aux)
    428        1.94       cgd {
    429       1.110   thorpej 	struct isa_io res_io[1];
    430       1.110   thorpej 	struct isa_iomem res_mem[1];
    431       1.110   thorpej 	struct isa_irq res_irq[1];
    432       1.110   thorpej 	struct isa_drq res_drq[2];
    433       1.132      cube 	struct isa_softc *sc = device_private(parent);
    434        1.94       cgd 	struct isa_attach_args ia;
    435       1.122  drochner 	int flocs[ISACF_NLOCS];
    436        1.94       cgd 	int tryagain;
    437        1.94       cgd 
    438        1.94       cgd 	do {
    439       1.110   thorpej 		ia.ia_pnpname = NULL;
    440       1.110   thorpej 		ia.ia_pnpcompatnames = NULL;
    441       1.110   thorpej 
    442       1.110   thorpej 		res_io[0].ir_addr = cf->cf_loc[ISACF_PORT];
    443       1.110   thorpej 		res_io[0].ir_size = 0;
    444       1.110   thorpej 
    445       1.110   thorpej 		res_mem[0].ir_addr = cf->cf_loc[ISACF_IOMEM];
    446       1.110   thorpej 		res_mem[0].ir_size = cf->cf_loc[ISACF_IOSIZ];
    447       1.110   thorpej 
    448       1.110   thorpej 		res_irq[0].ir_irq =
    449       1.110   thorpej 		    cf->cf_loc[ISACF_IRQ] == 2 ? 9 : cf->cf_loc[ISACF_IRQ];
    450       1.110   thorpej 
    451       1.110   thorpej 		res_drq[0].ir_drq = cf->cf_loc[ISACF_DRQ];
    452       1.110   thorpej 		res_drq[1].ir_drq = cf->cf_loc[ISACF_DRQ2];
    453       1.110   thorpej 
    454        1.94       cgd 		ia.ia_iot = sc->sc_iot;
    455        1.94       cgd 		ia.ia_memt = sc->sc_memt;
    456        1.95   thorpej 		ia.ia_dmat = sc->sc_dmat;
    457        1.94       cgd 		ia.ia_ic = sc->sc_ic;
    458       1.110   thorpej 
    459       1.110   thorpej 		ia.ia_io = res_io;
    460       1.110   thorpej 		ia.ia_nio = 1;
    461       1.110   thorpej 
    462       1.110   thorpej 		ia.ia_iomem = res_mem;
    463       1.110   thorpej 		ia.ia_niomem = 1;
    464       1.110   thorpej 
    465       1.110   thorpej 		ia.ia_irq = res_irq;
    466       1.110   thorpej 		ia.ia_nirq = 1;
    467       1.110   thorpej 
    468       1.110   thorpej 		ia.ia_drq = res_drq;
    469       1.110   thorpej 		ia.ia_ndrq = 2;
    470        1.94       cgd 
    471       1.122  drochner 		if (!checkattachargs(&ia, slocs))
    472       1.117  drochner 			return (0);
    473       1.117  drochner 
    474        1.94       cgd 		tryagain = 0;
    475  1.138.76.8   thorpej 		if (config_probe(parent, cf, &ia)) {
    476       1.117  drochner 			/*
    477       1.117  drochner 			 * This is not necessary for detach, but might
    478       1.117  drochner 			 * still be useful to collect device information.
    479       1.117  drochner 			 */
    480       1.122  drochner 			flocs[ISACF_PORT] = ia.ia_io[0].ir_addr;
    481       1.122  drochner 			flocs[ISACF_SIZE] = ia.ia_io[0].ir_size;
    482       1.122  drochner 			flocs[ISACF_IOMEM] = ia.ia_iomem[0].ir_addr;
    483       1.122  drochner 			flocs[ISACF_IOSIZ] = ia.ia_iomem[0].ir_size;
    484       1.122  drochner 			flocs[ISACF_IRQ] = ia.ia_irq[0].ir_irq;
    485       1.122  drochner 			flocs[ISACF_DRQ] = ia.ia_drq[0].ir_drq;
    486       1.122  drochner 			flocs[ISACF_DRQ2] = ia.ia_drq[1].ir_drq;
    487  1.138.76.5   thorpej 			config_attach(parent, cf, &ia, isaprint,
    488  1.138.76.5   thorpej 			    CFARG_LOCATORS, flocs,
    489  1.138.76.5   thorpej 			    CFARG_EOL);
    490        1.94       cgd 			tryagain = (cf->cf_fstate == FSTATE_STAR);
    491        1.94       cgd 		}
    492        1.94       cgd 	} while (tryagain);
    493        1.94       cgd 
    494        1.91       cgd 	return (0);
    495        1.72       cgd }
    496        1.72       cgd 
    497       1.120  christos const char *
    498       1.110   thorpej isa_intr_typename(int type)
    499        1.72       cgd {
    500        1.72       cgd 
    501        1.72       cgd 	switch (type) {
    502       1.128     isaki 	case IST_NONE:
    503        1.72       cgd 		return ("none");
    504       1.128     isaki 	case IST_PULSE:
    505        1.72       cgd 		return ("pulsed");
    506       1.128     isaki 	case IST_EDGE:
    507        1.72       cgd 		return ("edge-triggered");
    508       1.128     isaki 	case IST_LEVEL:
    509        1.72       cgd 		return ("level-triggered");
    510        1.72       cgd 	default:
    511        1.72       cgd 		panic("isa_intr_typename: invalid type %d", type);
    512        1.72       cgd 	}
    513         1.1       cgd }
    514       1.133        ad 
    515       1.133        ad int
    516       1.133        ad isa_get_slotcount(void)
    517       1.133        ad {
    518       1.133        ad 
    519       1.133        ad 	return isa_slotcount;
    520       1.133        ad }
    521       1.133        ad 
    522       1.133        ad void
    523       1.133        ad isa_set_slotcount(int arg)
    524       1.133        ad {
    525       1.133        ad 
    526       1.133        ad 	isa_slotcount = arg;
    527       1.133        ad }
    528