Rev 105 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
105 | pj | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * Massimiliano Giorgi <massy@gandalf.sssup.it> |
||
11 | * Luca Abeni <luca@gandalf.sssup.it> |
||
12 | * (see the web pages for full authors list) |
||
13 | * |
||
14 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
15 | * |
||
16 | * http://www.sssup.it |
||
17 | * http://retis.sssup.it |
||
18 | * http://shark.sssup.it |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | ------------ |
||
23 | CVS : $Id: 8042.h,v 1.1 2003-03-24 10:54:16 pj Exp $ |
||
24 | |||
25 | File: $File$ |
||
26 | Revision: $Revision: 1.1 $ |
||
27 | Last update: $Date: 2003-03-24 10:54:16 $ |
||
28 | ------------ |
||
29 | |||
30 | 8042.h |
||
31 | |||
32 | Interface between high level drivers |
||
33 | and the 8042 keyboard and PS/2 mouse controller |
||
34 | |||
35 | Revision: 1.0 |
||
36 | Last update: 22/Mar/1999 |
||
37 | |||
38 | Created by Massimiliano Giorgi, modified by Paolo Gai to support the |
||
39 | kernel 4.0.0 |
||
40 | |||
41 | **/ |
||
42 | |||
43 | /* |
||
44 | * Copyright (C) 2000 Paolo Gai |
||
45 | * |
||
46 | * This program is free software; you can redistribute it and/or modify |
||
47 | * it under the terms of the GNU General Public License as published by |
||
48 | * the Free Software Foundation; either version 2 of the License, or |
||
49 | * (at your option) any later version. |
||
50 | * |
||
51 | * This program is distributed in the hope that it will be useful, |
||
52 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
53 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
54 | * GNU General Public License for more details. |
||
55 | * |
||
56 | * You should have received a copy of the GNU General Public License |
||
57 | * along with this program; if not, write to the Free Software |
||
58 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
59 | * |
||
60 | */ |
||
61 | |||
62 | |||
63 | #ifndef __8042_H__ |
||
64 | #define __8042_H__ |
||
65 | |||
66 | #include "ll/sys/cdefs.h" |
||
67 | |||
68 | __BEGIN_DECLS |
||
69 | |||
70 | #define C8042_KEYBOARDIRQ 1 |
||
71 | #define C8042_PS2IRQ 12 |
||
72 | |||
73 | /* |
||
74 | * init, enable, disable, get data for the keyboard |
||
75 | */ |
||
76 | int C8042_keyboardinit(PID task); |
||
77 | int C8042_keyboarddisable(void); |
||
78 | int C8042_keyboardenable(void); |
||
79 | int C8042_keyboardget(BYTE *data,BYTE access); |
||
80 | |||
81 | /* |
||
82 | * init, enable, disable, get data for the ps/2 mouse (auxiliary port) |
||
83 | */ |
||
84 | int C8042_auxinit(PID task); |
||
85 | int C8042_auxportdisable(void); |
||
86 | int C8042_auxportenable(void); |
||
87 | int C8042_auxget(BYTE *data,BYTE access); |
||
88 | int C8042_auxend(void); |
||
89 | |||
90 | /* test if there is a PS/2 mouse on the aux port */ |
||
91 | int C8042_ps2mousepresent(void); |
||
92 | |||
93 | /* |
||
94 | * keyboard led controll |
||
95 | */ |
||
96 | void C8042_keyboardleds(BYTE numlock, BYTE cps, BYTE scrolllock); |
||
97 | |||
98 | /* |
||
99 | * |
||
100 | * from Linux OS kernel 2.2.2 |
||
101 | * (see GPL license) |
||
102 | * with some modification |
||
103 | */ |
||
104 | |||
105 | /* |
||
106 | * Keyboard Controller Registers |
||
107 | */ |
||
108 | |||
109 | #define KBD_STATUS_REG 0x64 /* Status register (R) */ |
||
110 | #define KBD_CNTL_REG 0x64 /* Controller command register (W) */ |
||
111 | #define KBD_DATA_REG 0x60 /* Keyboard data register (R/W) */ |
||
112 | |||
113 | /* |
||
114 | * Keyboard Controller Commands |
||
115 | */ |
||
116 | |||
117 | #define KBD_CCMD_READ_MODE 0x20 /* Read mode bits */ |
||
118 | #define KBD_CCMD_WRITE_MODE 0x60 /* Write mode bits */ |
||
119 | #define KBD_CCMD_GET_VERSION 0xA1 /* Get controller version */ |
||
120 | #define KBD_CCMD_MOUSE_DISABLE 0xA7 /* Disable mouse interface */ |
||
121 | #define KBD_CCMD_MOUSE_ENABLE 0xA8 /* Enable mouse interface */ |
||
122 | #define KBD_CCMD_TEST_MOUSE 0xA9 /* Mouse interface test */ |
||
123 | #define KBD_CCMD_SELF_TEST 0xAA /* Controller self test */ |
||
124 | #define KBD_CCMD_KBD_TEST 0xAB /* Keyboard interface test */ |
||
125 | #define KBD_CCMD_KBD_DISABLE 0xAD /* Keyboard interface disable */ |
||
126 | #define KBD_CCMD_KBD_ENABLE 0xAE /* Keyboard interface enable */ |
||
127 | #define KBD_CCMD_WRITE_AUX_OBUF 0xD3 /* Write to output buffer as if |
||
128 | initiated by the auxiliary device */ |
||
129 | #define KBD_CCMD_WRITE_MOUSE 0xD4 /* Write the following byte to the mouse */ |
||
130 | |||
131 | /* added by me (MG) */ |
||
132 | |||
133 | #define KBD_CCMD_GET_MODE 0xCA /* Get controller mode (AT or PS/2) */ |
||
134 | |||
135 | #define KBD_CREPLY_PS2MODE 0x01 /* PS2 mode */ |
||
136 | #define KBD_CREPLY_ATMODE 0x00 /* AT mode */ |
||
137 | #define KBD_CREPLY_GETMODEMASK 0x01 /* mask value for CCMD_GET_MODE */ |
||
138 | |||
139 | /* |
||
140 | * Keyboard Commands |
||
141 | */ |
||
142 | |||
143 | #define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */ |
||
144 | #define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */ |
||
145 | #define KBD_CMD_ENABLE 0xF4 /* Enable scanning */ |
||
146 | #define KBD_CMD_DISABLE 0xF5 /* Disable scanning */ |
||
147 | #define KBD_CMD_RESET 0xFF /* Reset */ |
||
148 | |||
149 | /* added by me (MG) */ |
||
150 | #define KBD_CMD_SET_ALL_TYPEMATIC 0xF7 /* Set all key typematic */ |
||
151 | |||
152 | #define KBD_LED_NUMLOCK 0x02 |
||
153 | #define KBD_LED_CAPSLOCK 0x04 |
||
154 | #define KBD_LED_SCROLLLOCK 0x01 |
||
155 | |||
156 | #define KBD_LED_MASK 0x07 |
||
157 | |||
158 | /* |
||
159 | * Keyboard Replies |
||
160 | */ |
||
161 | |||
162 | #define KBD_REPLY_POR 0xAA /* Power on reset */ |
||
163 | #define KBD_REPLY_ACK 0xFA /* Command ACK */ |
||
164 | #define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */ |
||
165 | |||
166 | /* added by me (MG) */ |
||
167 | #define KBD_REPLY_KISTOK 0x00 /* Keyboard Interface Self Test OK */ |
||
168 | #define KBD_REPLY_CSTOK 0x55 /* Controller self test OK */ |
||
169 | #define KBD_REPLY_MISTOK 0x00 /* Mouse Interface Self Test OK */ |
||
170 | |||
171 | /* |
||
172 | * Status Register Bits |
||
173 | */ |
||
174 | |||
175 | #define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */ |
||
176 | #define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */ |
||
177 | #define KBD_STAT_SELFTEST 0x04 /* Self test successful */ |
||
178 | #define KBD_STAT_CMD 0x08 /* Last write was a command write (0=data) */ |
||
179 | #define KBD_STAT_UNLOCKED 0x10 /* Zero if keyboard locked */ |
||
180 | #define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */ |
||
181 | #define KBD_STAT_GTO 0x40 /* General receive/xmit timeout */ |
||
182 | #define KBD_STAT_PERR 0x80 /* Parity error */ |
||
183 | |||
184 | #define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF) |
||
185 | |||
186 | /* |
||
187 | * Controller Mode Register Bits |
||
188 | */ |
||
189 | |||
190 | #define KBD_MODE_KBD_INT 0x01 /* Keyboard data generate IRQ1 */ |
||
191 | #define KBD_MODE_MOUSE_INT 0x02 /* Mouse data generate IRQ12 */ |
||
192 | #define KBD_MODE_SYS 0x04 /* The system flag (?) */ |
||
193 | #define KBD_MODE_NO_KEYLOCK 0x08 /* The keylock doesn't affect the keyboard if set */ |
||
194 | #define KBD_MODE_DISABLE_KBD 0x10 /* Disable keyboard interface */ |
||
195 | #define KBD_MODE_DISABLE_MOUSE 0x20 /* Disable mouse interface */ |
||
196 | #define KBD_MODE_KCC 0x40 /* Scan code conversion to PC format */ |
||
197 | #define KBD_MODE_RFU 0x80 |
||
198 | |||
199 | /* |
||
200 | * Mouse Commands |
||
201 | */ |
||
202 | |||
203 | #define AUX_SET_RES 0xE8 /* Set resolution */ |
||
204 | #define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */ |
||
205 | #define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */ |
||
206 | #define AUX_GET_SCALE 0xE9 /* Get scaling factor */ |
||
207 | #define AUX_SET_STREAM 0xEA /* Set stream mode */ |
||
208 | #define AUX_SET_SAMPLE 0xF3 /* Set sample rate */ |
||
209 | #define AUX_ENABLE_DEV 0xF4 /* Enable aux device */ |
||
210 | #define AUX_DISABLE_DEV 0xF5 /* Disable aux device */ |
||
211 | #define AUX_RESET 0xFF /* Reset aux device */ |
||
212 | #define AUX_ACK 0xFA /* Command byte ACK. */ |
||
213 | |||
214 | #define AUX_BUF_SIZE 2048 /* This might be better divisible by |
||
215 | three to make overruns stay in sync |
||
216 | but then the read function would |
||
217 | need |
||
218 | */ |
||
219 | |||
220 | __END_DECLS |
||
221 | #endif |
||
222 | |||
223 | |||
224 | |||
225 |