Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 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.1.1 2002-03-29 14:12:49 pj Exp $
24
 
25
 File:        $File$
26
 Revision:    $Revision: 1.1.1.1 $
27
 Last update: $Date: 2002-03-29 14:12:49 $
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
#define C8042_KEYBOARDIRQ  1
67
#define C8042_PS2IRQ      12
68
 
69
/*
70
 * init, enable, disable, get data for the keyboard
71
 */
72
int C8042_keyboardinit(PID task);
73
int C8042_keyboarddisable(void);
74
int C8042_keyboardenable(void);
75
int C8042_keyboardget(BYTE *data,BYTE access);
76
 
77
/*
78
 * init, enable, disable, get data for the ps/2 mouse (auxiliary port)
79
 */
80
int C8042_auxinit(PID task);
81
int C8042_auxportdisable(void);
82
int C8042_auxportenable(void);
83
int C8042_auxget(BYTE *data,BYTE access);
84
int C8042_auxend(void);
85
 
86
/* test if there is a PS/2 mouse on the aux port */
87
int C8042_ps2mousepresent(void);
88
 
89
/*
90
 * keyboard led controll
91
 */
92
void C8042_keyboardleds(BYTE numlock, BYTE cps, BYTE scrolllock);
93
 
94
/*
95
 *
96
 * from Linux OS kernel 2.2.2
97
 * (see GPL license)
98
 * with some modification
99
 */
100
 
101
/*
102
 *      Keyboard Controller Registers
103
 */
104
 
105
#define KBD_STATUS_REG          0x64    /* Status register (R) */
106
#define KBD_CNTL_REG            0x64    /* Controller command register (W) */
107
#define KBD_DATA_REG            0x60    /* Keyboard data register (R/W) */
108
 
109
/*
110
 *      Keyboard Controller Commands
111
 */
112
 
113
#define KBD_CCMD_READ_MODE      0x20    /* Read mode bits */
114
#define KBD_CCMD_WRITE_MODE     0x60    /* Write mode bits */
115
#define KBD_CCMD_GET_VERSION    0xA1    /* Get controller version */
116
#define KBD_CCMD_MOUSE_DISABLE  0xA7    /* Disable mouse interface */
117
#define KBD_CCMD_MOUSE_ENABLE   0xA8    /* Enable mouse interface */
118
#define KBD_CCMD_TEST_MOUSE     0xA9    /* Mouse interface test */
119
#define KBD_CCMD_SELF_TEST      0xAA    /* Controller self test */
120
#define KBD_CCMD_KBD_TEST       0xAB    /* Keyboard interface test */
121
#define KBD_CCMD_KBD_DISABLE    0xAD    /* Keyboard interface disable */
122
#define KBD_CCMD_KBD_ENABLE     0xAE    /* Keyboard interface enable */
123
#define KBD_CCMD_WRITE_AUX_OBUF 0xD3    /* Write to output buffer as if
124
                                           initiated by the auxiliary device */
125
#define KBD_CCMD_WRITE_MOUSE    0xD4    /* Write the following byte to the mouse */
126
 
127
/* added by me (MG) */
128
 
129
#define KBD_CCMD_GET_MODE       0xCA    /* Get controller mode (AT or PS/2) */
130
 
131
#define KBD_CREPLY_PS2MODE      0x01    /* PS2 mode */
132
#define KBD_CREPLY_ATMODE       0x00    /* AT mode */
133
#define KBD_CREPLY_GETMODEMASK  0x01    /* mask value for CCMD_GET_MODE */
134
 
135
/*
136
 *      Keyboard Commands
137
 */
138
 
139
#define KBD_CMD_SET_LEDS        0xED    /* Set keyboard leds */
140
#define KBD_CMD_SET_RATE        0xF3    /* Set typematic rate */
141
#define KBD_CMD_ENABLE          0xF4    /* Enable scanning */
142
#define KBD_CMD_DISABLE         0xF5    /* Disable scanning */
143
#define KBD_CMD_RESET           0xFF    /* Reset */
144
 
145
/* added by me (MG) */
146
#define KBD_CMD_SET_ALL_TYPEMATIC 0xF7  /* Set all key typematic */
147
 
148
#define KBD_LED_NUMLOCK         0x02
149
#define KBD_LED_CAPSLOCK        0x04
150
#define KBD_LED_SCROLLLOCK      0x01
151
 
152
#define KBD_LED_MASK            0x07
153
 
154
/*
155
 *      Keyboard Replies
156
 */
157
 
158
#define KBD_REPLY_POR           0xAA    /* Power on reset */
159
#define KBD_REPLY_ACK           0xFA    /* Command ACK */
160
#define KBD_REPLY_RESEND        0xFE    /* Command NACK, send the cmd again */
161
 
162
/* added by me (MG) */
163
#define KBD_REPLY_KISTOK        0x00    /* Keyboard Interface Self Test OK */
164
#define KBD_REPLY_CSTOK         0x55    /* Controller self test OK */
165
#define KBD_REPLY_MISTOK        0x00    /* Mouse Interface Self Test OK */
166
 
167
/*
168
 *      Status Register Bits
169
 */
170
 
171
#define KBD_STAT_OBF            0x01    /* Keyboard output buffer full */
172
#define KBD_STAT_IBF            0x02    /* Keyboard input buffer full */
173
#define KBD_STAT_SELFTEST       0x04    /* Self test successful */
174
#define KBD_STAT_CMD            0x08    /* Last write was a command write (0=data) */
175
#define KBD_STAT_UNLOCKED       0x10    /* Zero if keyboard locked */
176
#define KBD_STAT_MOUSE_OBF      0x20    /* Mouse output buffer full */
177
#define KBD_STAT_GTO            0x40    /* General receive/xmit timeout */
178
#define KBD_STAT_PERR           0x80    /* Parity error */
179
 
180
#define AUX_STAT_OBF (KBD_STAT_OBF | KBD_STAT_MOUSE_OBF)
181
 
182
/*
183
 *      Controller Mode Register Bits
184
 */
185
 
186
#define KBD_MODE_KBD_INT        0x01    /* Keyboard data generate IRQ1 */
187
#define KBD_MODE_MOUSE_INT      0x02    /* Mouse data generate IRQ12 */
188
#define KBD_MODE_SYS            0x04    /* The system flag (?) */
189
#define KBD_MODE_NO_KEYLOCK     0x08    /* The keylock doesn't affect the keyboard if set */
190
#define KBD_MODE_DISABLE_KBD    0x10    /* Disable keyboard interface */
191
#define KBD_MODE_DISABLE_MOUSE  0x20    /* Disable mouse interface */
192
#define KBD_MODE_KCC            0x40    /* Scan code conversion to PC format */
193
#define KBD_MODE_RFU            0x80
194
 
195
/*
196
 *      Mouse Commands
197
 */
198
 
199
#define AUX_SET_RES             0xE8    /* Set resolution */
200
#define AUX_SET_SCALE11         0xE6    /* Set 1:1 scaling */
201
#define AUX_SET_SCALE21         0xE7    /* Set 2:1 scaling */
202
#define AUX_GET_SCALE           0xE9    /* Get scaling factor */
203
#define AUX_SET_STREAM          0xEA    /* Set stream mode */
204
#define AUX_SET_SAMPLE          0xF3    /* Set sample rate */
205
#define AUX_ENABLE_DEV          0xF4    /* Enable aux device */
206
#define AUX_DISABLE_DEV         0xF5    /* Disable aux device */
207
#define AUX_RESET               0xFF    /* Reset aux device */
208
#define AUX_ACK                 0xFA    /* Command byte ACK. */
209
 
210
#define AUX_BUF_SIZE            2048    /* This might be better divisible by
211
                                           three to make overruns stay in sync
212
                                           but then the read function would
213
                                           need
214
                                           */
215
 
216
#endif
217
 
218
 
219
 
220