| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kbd.c,v 1.37 2009/07/03 13:36:09 tsutsui Exp $ */ | | 1 | /* $NetBSD: kbd.c,v 1.38 2009/07/03 13:49:39 tsutsui Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1995 Leo Weppelman | | 4 | * Copyright (c) 1995 Leo Weppelman |
5 | * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. | | 5 | * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -21,27 +21,27 @@ | | | @@ -21,27 +21,27 @@ |
21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
30 | * SUCH DAMAGE. | | 30 | * SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.37 2009/07/03 13:36:09 tsutsui Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: kbd.c,v 1.38 2009/07/03 13:49:39 tsutsui Exp $"); |
35 | | | 35 | |
36 | #include "mouse.h" | | 36 | #include "mouse.h" |
37 | #include "ite.h" | | 37 | #include "ite.h" |
38 | #include "wskbd.h" | | 38 | #include "wskbd.h" |
39 | | | 39 | |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/systm.h> | | 41 | #include <sys/systm.h> |
42 | #include <sys/device.h> | | 42 | #include <sys/device.h> |
43 | #include <sys/ioctl.h> | | 43 | #include <sys/ioctl.h> |
44 | #include <sys/tty.h> | | 44 | #include <sys/tty.h> |
45 | #include <sys/proc.h> | | 45 | #include <sys/proc.h> |
46 | #include <sys/conf.h> | | 46 | #include <sys/conf.h> |
47 | #include <sys/file.h> | | 47 | #include <sys/file.h> |
| @@ -113,27 +113,27 @@ dev_type_read(kbdread); | | | @@ -113,27 +113,27 @@ dev_type_read(kbdread); |
113 | dev_type_ioctl(kbdioctl); | | 113 | dev_type_ioctl(kbdioctl); |
114 | dev_type_poll(kbdpoll); | | 114 | dev_type_poll(kbdpoll); |
115 | dev_type_kqfilter(kbdkqfilter); | | 115 | dev_type_kqfilter(kbdkqfilter); |
116 | | | 116 | |
117 | /* Interrupt handler */ | | 117 | /* Interrupt handler */ |
118 | void kbdintr(int); | | 118 | void kbdintr(int); |
119 | | | 119 | |
120 | static void kbdsoft(void *, void *); | | 120 | static void kbdsoft(void *, void *); |
121 | static void kbdattach(struct device *, struct device *, void *); | | 121 | static void kbdattach(struct device *, struct device *, void *); |
122 | static int kbdmatch(struct device *, struct cfdata *, void *); | | 122 | static int kbdmatch(struct device *, struct cfdata *, void *); |
123 | #if NITE>0 | | 123 | #if NITE>0 |
124 | static int kbd_do_modifier(uint8_t); | | 124 | static int kbd_do_modifier(uint8_t); |
125 | #endif | | 125 | #endif |
126 | static int kbd_write_poll(uint8_t *, int); | | 126 | static int kbd_write_poll(const uint8_t *, int); |
127 | static void kbd_pkg_start(struct kbd_softc *, uint8_t); | | 127 | static void kbd_pkg_start(struct kbd_softc *, uint8_t); |
128 | | | 128 | |
129 | CFATTACH_DECL(kbd, sizeof(struct device), | | 129 | CFATTACH_DECL(kbd, sizeof(struct device), |
130 | kbdmatch, kbdattach, NULL, NULL); | | 130 | kbdmatch, kbdattach, NULL, NULL); |
131 | | | 131 | |
132 | const struct cdevsw kbd_cdevsw = { | | 132 | const struct cdevsw kbd_cdevsw = { |
133 | kbdopen, kbdclose, kbdread, nowrite, kbdioctl, | | 133 | kbdopen, kbdclose, kbdread, nowrite, kbdioctl, |
134 | nostop, notty, kbdpoll, nommap, kbdkqfilter, | | 134 | nostop, notty, kbdpoll, nommap, kbdkqfilter, |
135 | }; | | 135 | }; |
136 | | | 136 | |
137 | #if NWSKBD>0 | | 137 | #if NWSKBD>0 |
138 | /* accessops */ | | 138 | /* accessops */ |
139 | static int kbd_enable(void *, int); | | 139 | static int kbd_enable(void *, int); |
| @@ -169,28 +169,28 @@ static int | | | @@ -169,28 +169,28 @@ static int |
169 | kbdmatch(struct device *pdp, struct cfdata *cfp, void *auxp) | | 169 | kbdmatch(struct device *pdp, struct cfdata *cfp, void *auxp) |
170 | { | | 170 | { |
171 | | | 171 | |
172 | if (!strcmp((char *)auxp, "kbd")) | | 172 | if (!strcmp((char *)auxp, "kbd")) |
173 | return 1; | | 173 | return 1; |
174 | return 0; | | 174 | return 0; |
175 | } | | 175 | } |
176 | | | 176 | |
177 | /*ARGSUSED*/ | | 177 | /*ARGSUSED*/ |
178 | static void | | 178 | static void |
179 | kbdattach(struct device *pdp, struct device *dp, void *auxp) | | 179 | kbdattach(struct device *pdp, struct device *dp, void *auxp) |
180 | { | | 180 | { |
181 | int timeout; | | 181 | int timeout; |
182 | uint8_t kbd_rst[] = { 0x80, 0x01 }; | | 182 | const uint8_t kbd_rst[] = { 0x80, 0x01 }; |
183 | uint8_t kbd_icmd[] = { 0x12, 0x15 }; | | 183 | const uint8_t kbd_icmd[] = { 0x12, 0x15 }; |
184 | | | 184 | |
185 | /* | | 185 | /* |
186 | * Disable keyboard interrupts from MFP | | 186 | * Disable keyboard interrupts from MFP |
187 | */ | | 187 | */ |
188 | MFP->mf_ierb &= ~IB_AINT; | | 188 | MFP->mf_ierb &= ~IB_AINT; |
189 | | | 189 | |
190 | /* | | 190 | /* |
191 | * Reset ACIA and intialize to: | | 191 | * Reset ACIA and intialize to: |
192 | * divide by 16, 8 data, 1 stop, no parity, enable RX interrupts | | 192 | * divide by 16, 8 data, 1 stop, no parity, enable RX interrupts |
193 | */ | | 193 | */ |
194 | KBD->ac_cs = A_RESET; | | 194 | KBD->ac_cs = A_RESET; |
195 | delay(100); /* XXX: enough? */ | | 195 | delay(100); /* XXX: enough? */ |
196 | KBD->ac_cs = kbd_softc.k_soft_cs = KBD_INIT | A_RXINT; | | 196 | KBD->ac_cs = kbd_softc.k_soft_cs = KBD_INIT | A_RXINT; |
| @@ -639,45 +639,45 @@ kbdgetcn(void) | | | @@ -639,45 +639,45 @@ kbdgetcn(void) |
639 | if (ints_active) { | | 639 | if (ints_active) { |
640 | MFP->mf_iprb = (uint8_t)~IB_AINT; | | 640 | MFP->mf_iprb = (uint8_t)~IB_AINT; |
641 | MFP->mf_imrb |= IB_AINT; | | 641 | MFP->mf_imrb |= IB_AINT; |
642 | } | | 642 | } |
643 | | | 643 | |
644 | splx(s); | | 644 | splx(s); |
645 | return code; | | 645 | return code; |
646 | } | | 646 | } |
647 | | | 647 | |
648 | /* | | 648 | /* |
649 | * Write a command to the keyboard in 'polled' mode. | | 649 | * Write a command to the keyboard in 'polled' mode. |
650 | */ | | 650 | */ |
651 | static int | | 651 | static int |
652 | kbd_write_poll(uint8_t *cmd, int len) | | 652 | kbd_write_poll(const uint8_t *cmd, int len) |
653 | { | | 653 | { |
654 | int timeout; | | 654 | int timeout; |
655 | | | 655 | |
656 | while (len-- > 0) { | | 656 | while (len-- > 0) { |
657 | KBD->ac_da = *cmd++; | | 657 | KBD->ac_da = *cmd++; |
658 | for (timeout = 100; !(KBD->ac_cs & A_TXRDY); timeout--) | | 658 | for (timeout = 100; !(KBD->ac_cs & A_TXRDY); timeout--) |
659 | delay(10); | | 659 | delay(10); |
660 | if ((KBD->ac_cs & A_TXRDY) == 0) | | 660 | if ((KBD->ac_cs & A_TXRDY) == 0) |
661 | return 0; | | 661 | return 0; |
662 | } | | 662 | } |
663 | return 1; | | 663 | return 1; |
664 | } | | 664 | } |
665 | | | 665 | |
666 | /* | | 666 | /* |
667 | * Write a command to the keyboard. Return when command is send. | | 667 | * Write a command to the keyboard. Return when command is send. |
668 | */ | | 668 | */ |
669 | void | | 669 | void |
670 | kbd_write(uint8_t *cmd, int len) | | 670 | kbd_write(const uint8_t *cmd, int len) |
671 | { | | 671 | { |
672 | struct kbd_softc *k = &kbd_softc; | | 672 | struct kbd_softc *k = &kbd_softc; |
673 | int sps; | | 673 | int sps; |
674 | | | 674 | |
675 | /* | | 675 | /* |
676 | * Get to splhigh, 'real' interrupts arrive at spl6! | | 676 | * Get to splhigh, 'real' interrupts arrive at spl6! |
677 | */ | | 677 | */ |
678 | sps = splhigh(); | | 678 | sps = splhigh(); |
679 | | | 679 | |
680 | /* | | 680 | /* |
681 | * Make sure any privious write has ended... | | 681 | * Make sure any privious write has ended... |
682 | */ | | 682 | */ |
683 | while (k->k_sendp != NULL) | | 683 | while (k->k_sendp != NULL) |