| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hpckbd.c,v 1.28 2009/05/12 14:22:39 cegger Exp $ */ | | 1 | /* $NetBSD: hpckbd.c,v 1.29 2011/06/11 16:34:36 nonaka Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999-2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1999-2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by UCHIYAMA Yasushi. | | 8 | * by UCHIYAMA Yasushi. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 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 | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 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 | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 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 | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.28 2009/05/12 14:22:39 cegger Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.29 2011/06/11 16:34:36 nonaka Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/device.h> | | 37 | #include <sys/device.h> |
38 | | | 38 | |
39 | #include <sys/tty.h> | | 39 | #include <sys/tty.h> |
40 | | | 40 | |
41 | #include <sys/bus.h> | | 41 | #include <sys/bus.h> |
42 | #include <sys/intr.h> | | 42 | #include <sys/intr.h> |
43 | | | 43 | |
44 | #include <machine/config_hook.h> | | 44 | #include <machine/config_hook.h> |
45 | #include <machine/platid.h> | | 45 | #include <machine/platid.h> |
46 | #include <machine/platid_mask.h> | | 46 | #include <machine/platid_mask.h> |
| @@ -77,44 +77,44 @@ struct hpckbd_core { | | | @@ -77,44 +77,44 @@ struct hpckbd_core { |
77 | #define NEVENTQ 32 | | 77 | #define NEVENTQ 32 |
78 | struct hpckbd_eventq hc_eventq[NEVENTQ]; | | 78 | struct hpckbd_eventq hc_eventq[NEVENTQ]; |
79 | struct hpckbd_eventq *hc_head, *hc_tail; | | 79 | struct hpckbd_eventq *hc_head, *hc_tail; |
80 | int hc_nevents; | | 80 | int hc_nevents; |
81 | int hc_enabled; | | 81 | int hc_enabled; |
82 | struct device *hc_wskbddev; | | 82 | struct device *hc_wskbddev; |
83 | struct hpckbd_softc* hc_sc; /* back link */ | | 83 | struct hpckbd_softc* hc_sc; /* back link */ |
84 | #ifdef WSDISPLAY_COMPAT_RAWKBD | | 84 | #ifdef WSDISPLAY_COMPAT_RAWKBD |
85 | int hc_rawkbd; | | 85 | int hc_rawkbd; |
86 | #endif | | 86 | #endif |
87 | }; | | 87 | }; |
88 | | | 88 | |
89 | struct hpckbd_softc { | | 89 | struct hpckbd_softc { |
90 | struct device sc_dev; | | 90 | device_t sc_dev; |
91 | struct hpckbd_core *sc_core; | | 91 | struct hpckbd_core *sc_core; |
92 | struct hpckbd_core sc_coredata; | | 92 | struct hpckbd_core sc_coredata; |
93 | }; | | 93 | }; |
94 | | | 94 | |
95 | int hpckbd_match(device_t, cfdata_t, void *); | | 95 | int hpckbd_match(device_t, cfdata_t, void *); |
96 | void hpckbd_attach(device_t, device_t, void *); | | 96 | void hpckbd_attach(device_t, device_t, void *); |
97 | | | 97 | |
98 | void hpckbd_initcore(struct hpckbd_core *, struct hpckbd_ic_if *, int); | | 98 | void hpckbd_initcore(struct hpckbd_core *, struct hpckbd_ic_if *, int); |
99 | void hpckbd_initif(struct hpckbd_core *); | | 99 | void hpckbd_initif(struct hpckbd_core *); |
100 | int hpckbd_getevent(struct hpckbd_core *, u_int *, int *); | | 100 | int hpckbd_getevent(struct hpckbd_core *, u_int *, int *); |
101 | int hpckbd_putevent(struct hpckbd_core *, u_int, int); | | 101 | int hpckbd_putevent(struct hpckbd_core *, u_int, int); |
102 | void hpckbd_keymap_lookup(struct hpckbd_core*); | | 102 | void hpckbd_keymap_lookup(struct hpckbd_core*); |
103 | void hpckbd_keymap_setup(struct hpckbd_core *, const keysym_t *, int); | | 103 | void hpckbd_keymap_setup(struct hpckbd_core *, const keysym_t *, int); |
104 | int __hpckbd_input(void *, int, int); | | 104 | int __hpckbd_input(void *, int, int); |
105 | void __hpckbd_input_hook(void *); | | 105 | void __hpckbd_input_hook(void *); |
106 | | | 106 | |
107 | CFATTACH_DECL(hpckbd, sizeof(struct hpckbd_softc), | | 107 | CFATTACH_DECL_NEW(hpckbd, sizeof(struct hpckbd_softc), |
108 | hpckbd_match, hpckbd_attach, NULL, NULL); | | 108 | hpckbd_match, hpckbd_attach, NULL, NULL); |
109 | | | 109 | |
110 | /* wskbd accessopts */ | | 110 | /* wskbd accessopts */ |
111 | int hpckbd_enable(void *, int); | | 111 | int hpckbd_enable(void *, int); |
112 | void hpckbd_set_leds(void *, int); | | 112 | void hpckbd_set_leds(void *, int); |
113 | int hpckbd_ioctl(void *, u_long, void *, int, struct lwp *); | | 113 | int hpckbd_ioctl(void *, u_long, void *, int, struct lwp *); |
114 | | | 114 | |
115 | /* consopts */ | | 115 | /* consopts */ |
116 | struct hpckbd_core hpckbd_consdata; | | 116 | struct hpckbd_core hpckbd_consdata; |
117 | void hpckbd_cngetc(void *, u_int *, int*); | | 117 | void hpckbd_cngetc(void *, u_int *, int*); |
118 | void hpckbd_cnpollc(void *, int); | | 118 | void hpckbd_cnpollc(void *, int); |
119 | | | 119 | |
120 | const struct wskbd_accessops hpckbd_accessops = { | | 120 | const struct wskbd_accessops hpckbd_accessops = { |
| @@ -129,40 +129,41 @@ const struct wskbd_consops hpckbd_consop | | | @@ -129,40 +129,41 @@ const struct wskbd_consops hpckbd_consop |
129 | NULL, | | 129 | NULL, |
130 | }; | | 130 | }; |
131 | | | 131 | |
132 | struct wskbd_mapdata hpckbd_keymapdata = { | | 132 | struct wskbd_mapdata hpckbd_keymapdata = { |
133 | pckbd_keydesctab, | | 133 | pckbd_keydesctab, |
134 | #ifdef PCKBD_LAYOUT | | 134 | #ifdef PCKBD_LAYOUT |
135 | PCKBD_LAYOUT | | 135 | PCKBD_LAYOUT |
136 | #else | | 136 | #else |
137 | KB_US | | 137 | KB_US |
138 | #endif | | 138 | #endif |
139 | }; | | 139 | }; |
140 | | | 140 | |
141 | int | | 141 | int |
142 | hpckbd_match(device_t parent, | | 142 | hpckbd_match(device_t parent, cfdata_t cf, void *aux) |
143 | cfdata_t cf, void *aux) | | | |
144 | { | | 143 | { |
145 | return (1); | | 144 | return (1); |
146 | } | | 145 | } |
147 | | | 146 | |
148 | void | | 147 | void |
149 | hpckbd_attach(device_t parent, device_t self, void *aux) | | 148 | hpckbd_attach(device_t parent, device_t self, void *aux) |
150 | { | | 149 | { |
151 | struct hpckbd_attach_args *haa = aux; | | 150 | struct hpckbd_attach_args *haa = aux; |
152 | struct hpckbd_softc *sc = device_private(self); | | 151 | struct hpckbd_softc *sc = device_private(self); |
153 | struct hpckbd_ic_if *ic = haa->haa_ic; | | 152 | struct hpckbd_ic_if *ic = haa->haa_ic; |
154 | struct wskbddev_attach_args wa; | | 153 | struct wskbddev_attach_args wa; |
155 | | | 154 | |
| | | 155 | sc->sc_dev = self; |
| | | 156 | |
156 | /* | | 157 | /* |
157 | * Initialize core if it isn't console | | 158 | * Initialize core if it isn't console |
158 | */ | | 159 | */ |
159 | if (hpckbd_consdata.hc_ic == ic) { | | 160 | if (hpckbd_consdata.hc_ic == ic) { |
160 | sc->sc_core = &hpckbd_consdata; | | 161 | sc->sc_core = &hpckbd_consdata; |
161 | /* The core has been initialized in hpckbd_cnattach. */ | | 162 | /* The core has been initialized in hpckbd_cnattach. */ |
162 | } else { | | 163 | } else { |
163 | sc->sc_core = &sc->sc_coredata; | | 164 | sc->sc_core = &sc->sc_coredata; |
164 | hpckbd_initcore(sc->sc_core, ic, 0 /* not console */); | | 165 | hpckbd_initcore(sc->sc_core, ic, 0 /* not console */); |
165 | } | | 166 | } |
166 | | | 167 | |
167 | if (sc->sc_core->hc_keymap == default_keymap) | | 168 | if (sc->sc_core->hc_keymap == default_keymap) |
168 | printf(": no keymap."); | | 169 | printf(": no keymap."); |