Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / i386 / pnpbios / npx_pnpbios.c
blob4a04db7b1a035f64040594c3cc16df3599b0b24c
1 /* $NetBSD: npx_pnpbios.c,v 1.11 2008/03/04 14:53:38 cube Exp $ */
3 /*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: npx_pnpbios.c,v 1.11 2008/03/04 14:53:38 cube Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/device.h>
39 #include <machine/bus.h>
40 #include <machine/cpufunc.h>
41 #include <machine/intr.h>
42 #include <machine/specialreg.h>
44 #include <dev/isa/isareg.h>
45 #include <dev/isa/isavar.h>
47 #include <i386/pnpbios/pnpbiosvar.h>
49 #include <i386/isa/npxvar.h>
51 int npx_pnpbios_match(device_t, cfdata_t, void *);
52 void npx_pnpbios_attach(device_t, device_t, void *);
54 CFATTACH_DECL_NEW(npx_pnpbios, sizeof(struct npx_softc),
55 npx_pnpbios_match, npx_pnpbios_attach, NULL, NULL);
57 int
58 npx_pnpbios_match(device_t parent, cfdata_t match, void *aux)
60 struct pnpbiosdev_attach_args *aa = aux;
62 if (strcmp(aa->idstr, "PNP0C04"))
63 return (0);
65 return (1);
68 void
69 npx_pnpbios_attach(device_t parent, device_t self, void *aux)
71 struct npx_softc *sc = device_private(self);
72 struct pnpbiosdev_attach_args *aa = aux;
73 int irq, ist;
75 sc->sc_dev = self;
77 if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
78 aprint_error(": can't map i/o space\n");
79 return;
82 aprint_naive("\n");
83 aprint_normal("\n");
84 pnpbios_print_devres(self, aa);
86 if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &irq, &ist) != 0) {
87 aprint_error_dev(self, "unable to get IRQ number or type\n");
88 return;
91 sc->sc_type = npxprobe1(sc->sc_iot, sc->sc_ioh, irq);
93 switch (sc->sc_type) {
94 case NPX_INTERRUPT:
95 aprint_normal_dev(self, "interrupting at irq %d\n", irq);
96 lcr0(rcr0() & ~CR0_NE);
97 sc->sc_ih = isa_intr_establish(0/*XXX*/, irq, ist, IPL_NONE,
98 (int (*)(void *))npxintr, NULL);
99 break;
100 case NPX_EXCEPTION:
101 /*FALLTHROUGH*/
102 case NPX_CPUID:
103 aprint_verbose_dev(self, "%susing exception 16\n",
104 sc->sc_type == NPX_CPUID ? "reported by CPUID; " : "");
105 sc->sc_type = NPX_EXCEPTION;
106 break;
107 case NPX_BROKEN:
108 aprint_error_dev(self, "error reporting broken; not using\n");
109 sc->sc_type = NPX_NONE;
110 return;
111 case NPX_NONE:
112 panic("npx_pnpbios_attach");
115 npxattach(sc);