Fri Jul 3 13:49:39 2009 UTC ()
Use more uint8_t, and constify.


(tsutsui)
diff -r1.37 -r1.38 src/sys/arch/atari/dev/kbd.c
diff -r1.6 -r1.7 src/sys/arch/atari/dev/kbdvar.h

cvs diff -r1.37 -r1.38 src/sys/arch/atari/dev/kbd.c (expand / switch to unified diff)

--- src/sys/arch/atari/dev/kbd.c 2009/07/03 13:36:09 1.37
+++ src/sys/arch/atari/dev/kbd.c 2009/07/03 13:49:39 1.38
@@ -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);
113dev_type_ioctl(kbdioctl); 113dev_type_ioctl(kbdioctl);
114dev_type_poll(kbdpoll); 114dev_type_poll(kbdpoll);
115dev_type_kqfilter(kbdkqfilter); 115dev_type_kqfilter(kbdkqfilter);
116 116
117/* Interrupt handler */ 117/* Interrupt handler */
118void kbdintr(int); 118void kbdintr(int);
119 119
120static void kbdsoft(void *, void *); 120static void kbdsoft(void *, void *);
121static void kbdattach(struct device *, struct device *, void *); 121static void kbdattach(struct device *, struct device *, void *);
122static int kbdmatch(struct device *, struct cfdata *, void *); 122static int kbdmatch(struct device *, struct cfdata *, void *);
123#if NITE>0 123#if NITE>0
124static int kbd_do_modifier(uint8_t); 124static int kbd_do_modifier(uint8_t);
125#endif 125#endif
126static int kbd_write_poll(uint8_t *, int); 126static int kbd_write_poll(const uint8_t *, int);
127static void kbd_pkg_start(struct kbd_softc *, uint8_t); 127static void kbd_pkg_start(struct kbd_softc *, uint8_t);
128 128
129CFATTACH_DECL(kbd, sizeof(struct device), 129CFATTACH_DECL(kbd, sizeof(struct device),
130 kbdmatch, kbdattach, NULL, NULL); 130 kbdmatch, kbdattach, NULL, NULL);
131 131
132const struct cdevsw kbd_cdevsw = { 132const 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 */
139static int kbd_enable(void *, int); 139static int kbd_enable(void *, int);
@@ -169,28 +169,28 @@ static int @@ -169,28 +169,28 @@ static int
169kbdmatch(struct device *pdp, struct cfdata *cfp, void *auxp) 169kbdmatch(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*/
178static void 178static void
179kbdattach(struct device *pdp, struct device *dp, void *auxp) 179kbdattach(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 */
651static int 651static int
652kbd_write_poll(uint8_t *cmd, int len) 652kbd_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 */
669void 669void
670kbd_write(uint8_t *cmd, int len) 670kbd_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)

cvs diff -r1.6 -r1.7 src/sys/arch/atari/dev/kbdvar.h (expand / switch to unified diff)

--- src/sys/arch/atari/dev/kbdvar.h 2009/03/14 14:45:56 1.6
+++ src/sys/arch/atari/dev/kbdvar.h 2009/07/03 13:49:39 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kbdvar.h,v 1.6 2009/03/14 14:45:56 dsl Exp $ */ 1/* $NetBSD: kbdvar.h,v 1.7 2009/07/03 13:49:39 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Leo Weppelman. 4 * Copyright (c) 1996 Leo Weppelman.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -34,49 +34,49 @@ @@ -34,49 +34,49 @@
34#define _KBDVAR_H 34#define _KBDVAR_H
35 35
36/* 36/*
37 * The ringbuffer is the interface between the hard and soft interrupt handler. 37 * The ringbuffer is the interface between the hard and soft interrupt handler.
38 * The hard interrupt runs straight from the MFP interrupt. 38 * The hard interrupt runs straight from the MFP interrupt.
39 */ 39 */
40#define KBD_RING_SIZE 256 /* Sz of input ring buffer, must be power of 2 */ 40#define KBD_RING_SIZE 256 /* Sz of input ring buffer, must be power of 2 */
41#define KBD_RING_MASK 255 /* Modulo mask for above */ 41#define KBD_RING_MASK 255 /* Modulo mask for above */
42 42
43struct kbd_softc { 43struct kbd_softc {
44 int k_event_mode; /* if 1, collect events, */ 44 int k_event_mode; /* if 1, collect events, */
45 /* else pass to ite */ 45 /* else pass to ite */
46 struct evvar k_events; /* event queue state */ 46 struct evvar k_events; /* event queue state */
47 u_char k_soft_cs; /* control-reg. copy */ 47 uint8_t k_soft_cs; /* control-reg. copy */
48 u_char k_package[20]; /* XXX package being build */ 48 uint8_t k_package[20]; /* XXX package being build */
49 u_char k_pkg_size; /* Size of the package */ 49 uint8_t k_pkg_size; /* Size of the package */
50 u_char k_pkg_idx; /* Running pkg assembly index */ 50 uint8_t k_pkg_idx; /* Running pkg assembly index */
51 u_char k_pkg_type; /* Type of package */ 51 uint8_t k_pkg_type; /* Type of package */
52 u_char *k_sendp; /* Output pointer */ 52 const uint8_t *k_sendp; /* Output pointer */
53 int k_send_cnt; /* Chars left for output */ 53 int k_send_cnt; /* Chars left for output */
54#if NWSKBD>0 54#if NWSKBD>0
55 struct device *k_wskbddev; /* pointer to wskbd for sending strokes */ 55 struct device *k_wskbddev; /* pointer to wskbd for sending strokes */
56 int k_pollingmode; /* polling mode on? whatever it isss... */ 56 int k_pollingmode; /* polling mode on? whatever it isss... */
57#endif 57#endif
58}; 58};
59 59
60/* 60/*
61 * Package types 61 * Package types
62 */ 62 */
63#define KBD_MEM_PKG 0 /* Memory read package */ 63#define KBD_MEM_PKG 0 /* Memory read package */
64#define KBD_AMS_PKG 1 /* Absolute mouse package */ 64#define KBD_AMS_PKG 1 /* Absolute mouse package */
65#define KBD_RMS_PKG 2 /* Relative mouse package */ 65#define KBD_RMS_PKG 2 /* Relative mouse package */
66#define KBD_CLK_PKG 3 /* Clock package */ 66#define KBD_CLK_PKG 3 /* Clock package */
67#define KBD_JOY0_PKG 4 /* Joystick-0 package */ 67#define KBD_JOY0_PKG 4 /* Joystick-0 package */
68#define KBD_JOY1_PKG 5 /* Joystick-1 package */ 68#define KBD_JOY1_PKG 5 /* Joystick-1 package */
69#define KBD_TIMEO_PKG 6 /* Timeout package */ 69#define KBD_TIMEO_PKG 6 /* Timeout package */
70 70
71#ifdef _KERNEL 71#ifdef _KERNEL
72extern u_char kbd_modifier; 72extern uint8_t kbd_modifier;
73 73
74void kbd_bell_gparms(u_int *, u_int *, u_int *); 74void kbd_bell_gparms(u_int *, u_int *, u_int *);
75void kbd_bell_sparms(u_int, u_int, u_int); 75void kbd_bell_sparms(u_int, u_int, u_int);
76void kbd_write(u_char *, int); 76void kbd_write(const uint8_t *, int);
77int kbdgetcn(void); 77int kbdgetcn(void);
78void kbdbell(void); 78void kbdbell(void);
79void kbdenable(void); 79void kbdenable(void);
80#endif /* _KERNEL */ 80#endif /* _KERNEL */
81 81
82#endif /* _KBDVAR_H */ 82#endif /* _KBDVAR_H */