hil_intio.c revision 1.3.6.2 1 1.3.6.2 jruoho /* $NetBSD: hil_intio.c,v 1.3.6.2 2011/06/06 09:05:36 jruoho Exp $ */
2 1.3.6.2 jruoho /* $OpenBSD: hil_intio.c,v 1.8 2007/01/06 20:10:57 miod Exp $ */
3 1.3.6.2 jruoho
4 1.3.6.2 jruoho /*
5 1.3.6.2 jruoho * Copyright (c) 2005, Miodrag Vallat.
6 1.3.6.2 jruoho * All rights reserved.
7 1.3.6.2 jruoho *
8 1.3.6.2 jruoho * Redistribution and use in source and binary forms, with or without
9 1.3.6.2 jruoho * modification, are permitted provided that the following conditions
10 1.3.6.2 jruoho * are met:
11 1.3.6.2 jruoho * 1. Redistributions of source code must retain the above copyright
12 1.3.6.2 jruoho * notice, this list of conditions and the following disclaimer.
13 1.3.6.2 jruoho * 2. Redistributions in binary form must reproduce the above copyright
14 1.3.6.2 jruoho * notice, this list of conditions and the following disclaimer in the
15 1.3.6.2 jruoho * documentation and/or other materials provided with the distribution.
16 1.3.6.2 jruoho *
17 1.3.6.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 1.3.6.2 jruoho * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 1.3.6.2 jruoho * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 1.3.6.2 jruoho * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21 1.3.6.2 jruoho * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 1.3.6.2 jruoho * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 1.3.6.2 jruoho * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.3.6.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 1.3.6.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 1.3.6.2 jruoho * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.3.6.2 jruoho * POSSIBILITY OF SUCH DAMAGE.
28 1.3.6.2 jruoho *
29 1.3.6.2 jruoho */
30 1.3.6.2 jruoho
31 1.3.6.2 jruoho #include <sys/param.h>
32 1.3.6.2 jruoho #include <sys/systm.h>
33 1.3.6.2 jruoho #include <sys/device.h>
34 1.3.6.2 jruoho #include <sys/conf.h>
35 1.3.6.2 jruoho #include <sys/bus.h>
36 1.3.6.2 jruoho #include <sys/cpu.h>
37 1.3.6.2 jruoho
38 1.3.6.2 jruoho #include <machine/intr.h>
39 1.3.6.2 jruoho
40 1.3.6.2 jruoho #include <dev/cons.h>
41 1.3.6.2 jruoho
42 1.3.6.2 jruoho #include <hp300/dev/intiovar.h>
43 1.3.6.2 jruoho
44 1.3.6.2 jruoho #include <machine/hil_machdep.h>
45 1.3.6.2 jruoho #include <dev/hil/hilvar.h>
46 1.3.6.2 jruoho
47 1.3.6.2 jruoho static int hil_intio_match(device_t, cfdata_t, void *);
48 1.3.6.2 jruoho static void hil_intio_attach(device_t, device_t, void *);
49 1.3.6.2 jruoho
50 1.3.6.2 jruoho CFATTACH_DECL_NEW(hil_intio, sizeof(struct hil_softc),
51 1.3.6.2 jruoho hil_intio_match, hil_intio_attach, NULL, NULL);
52 1.3.6.2 jruoho
53 1.3.6.2 jruoho int
54 1.3.6.2 jruoho hil_intio_match(device_t parent, cfdata_t cf, void *aux)
55 1.3.6.2 jruoho {
56 1.3.6.2 jruoho struct intio_attach_args *ia = aux;
57 1.3.6.2 jruoho static int hil_matched = 0;
58 1.3.6.2 jruoho
59 1.3.6.2 jruoho if (strcmp("hil", ia->ia_modname) != 0)
60 1.3.6.2 jruoho return 0;
61 1.3.6.2 jruoho
62 1.3.6.2 jruoho /* Allow only one instance. */
63 1.3.6.2 jruoho if (hil_matched != 0)
64 1.3.6.2 jruoho return 0;
65 1.3.6.2 jruoho
66 1.3.6.2 jruoho if (badaddr((void *)ia->ia_addr)) /* should not happen! */
67 1.3.6.2 jruoho return 0;
68 1.3.6.2 jruoho
69 1.3.6.2 jruoho return 1;
70 1.3.6.2 jruoho }
71 1.3.6.2 jruoho
72 1.3.6.2 jruoho int hil_is_console = -1; /* undecided */
73 1.3.6.2 jruoho
74 1.3.6.2 jruoho void
75 1.3.6.2 jruoho hil_intio_attach(device_t parent, device_t self, void *aux)
76 1.3.6.2 jruoho {
77 1.3.6.2 jruoho struct hil_softc *sc = device_private(self);
78 1.3.6.2 jruoho struct intio_attach_args *ia = aux;
79 1.3.6.2 jruoho
80 1.3.6.2 jruoho sc->sc_dev = self;
81 1.3.6.2 jruoho sc->sc_bst = ia->ia_bst;
82 1.3.6.2 jruoho if (bus_space_map(sc->sc_bst, ia->ia_iobase,
83 1.3.6.2 jruoho HILMAPSIZE, 0, &sc->sc_bsh) != 0) {
84 1.3.6.2 jruoho aprint_error(": couldn't map hil controller\n");
85 1.3.6.2 jruoho return;
86 1.3.6.2 jruoho }
87 1.3.6.2 jruoho
88 1.3.6.2 jruoho /*
89 1.3.6.2 jruoho * Check that the configured console device is a wsdisplay.
90 1.3.6.2 jruoho */
91 1.3.6.2 jruoho if (major(cn_tab->cn_dev) != devsw_name2chr("wsdisplay", NULL, 0))
92 1.3.6.2 jruoho hil_is_console = 0;
93 1.3.6.2 jruoho
94 1.3.6.2 jruoho hil_attach(sc, &hil_is_console);
95 1.3.6.2 jruoho intr_establish(hil_intr, sc, ia->ia_ipl, IPL_TTY);
96 1.3.6.2 jruoho
97 1.3.6.2 jruoho config_interrupts(self, hil_attach_deferred);
98 1.3.6.2 jruoho }
99