1 /* $NetBSD: npx_isa.c,v 1.20 2009/04/02 00:09:32 dyoung Exp $ */
4 * Copyright (c) 1991 The Regents of the University of California.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * @(#)npx.c 7.2 (Berkeley) 5/12/91
35 * Copyright (c) 1994, 1995, 1998 Charles M. Hannum. All rights reserved.
36 * Copyright (c) 1990 William Jolitz.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * @(#)npx.c 7.2 (Berkeley) 5/12/91
69 #include <sys/cdefs.h>
70 __KERNEL_RCSID(0, "$NetBSD: npx_isa.c,v 1.20 2009/04/02 00:09:32 dyoung Exp $");
72 #include <sys/param.h>
73 #include <sys/systm.h>
74 #include <sys/device.h>
76 #include <machine/bus.h>
77 #include <machine/cpufunc.h>
78 #include <machine/intr.h>
79 #include <machine/specialreg.h>
81 #include <dev/isa/isareg.h>
82 #include <dev/isa/isavar.h>
84 #include <i386/isa/npxvar.h>
86 int npx_isa_probe(device_t
, cfdata_t
, void *);
87 void npx_isa_attach(device_t
, device_t
, void *);
89 CFATTACH_DECL3_NEW(npx_isa
, sizeof(struct npx_softc
),
90 npx_isa_probe
, npx_isa_attach
, npxdetach
, NULL
, NULL
, NULL
,
94 npx_isa_probe(device_t parent
, cfdata_t match
, void *aux
)
96 struct isa_attach_args
*ia
= aux
;
97 bus_space_handle_t ioh
;
105 if (ISA_DIRECT_CONFIG(ia
))
108 if (bus_space_map(ia
->ia_iot
, 0xf0, 16, 0, &ioh
) != 0)
111 result
= npxprobe1(ia
->ia_iot
, ioh
, ia
->ia_irq
[0].ir_irq
);
113 bus_space_unmap(ia
->ia_iot
, ioh
, 16);
115 if (result
!= NPX_NONE
) {
117 * Remember our result -- we don't want to have to npxprobe1()
118 * again (especially if we've zapped the IRQ).
120 ia
->ia_aux
= (void *)(intptr_t)result
;
123 ia
->ia_io
[0].ir_addr
= 0xf0;
124 ia
->ia_io
[0].ir_size
= 16;
126 if (result
!= NPX_INTERRUPT
)
127 ia
->ia_nirq
= 0; /* zap the interrupt */
140 npx_isa_attach(device_t parent
, device_t self
, void *aux
)
142 struct npx_softc
*sc
= device_private(self
);
143 struct isa_attach_args
*ia
= aux
;
149 sc
->sc_type
= (u_long
) ia
->ia_aux
;
151 switch (sc
->sc_type
) {
153 sc
->sc_iot
= ia
->ia_iot
;
154 if (bus_space_map(sc
->sc_iot
, 0xf0, 16, 0, &sc
->sc_ioh
))
155 panic("%s: unable to map I/O space", __func__
);
156 lcr0(rcr0() & ~CR0_NE
);
157 sc
->sc_ih
= isa_intr_establish(ia
->ia_ic
, ia
->ia_irq
[0].ir_irq
,
158 IST_EDGE
, IPL_NONE
, (int (*)(void *))npxintr
, 0);
163 aprint_verbose_dev(sc
->sc_dev
, "%s using exception 16\n",
164 sc
->sc_type
== NPX_CPUID
? "reported by CPUID;" : "");
165 sc
->sc_type
= NPX_EXCEPTION
;
168 aprint_error_dev(sc
->sc_dev
,
169 "error reporting broken; not using\n");
170 sc
->sc_type
= NPX_NONE
;