]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseSimulateTouchPadDxe/CommPs2.h
change "Ps2MouseSimulateTouchPad" to "Ps2MouseAbsolutePointer" for more clearing...
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2MouseSimulateTouchPadDxe / CommPs2.h
1 /**@file
2 PS2 Mouse Communication Interface
3
4
5 Copyright (c) 2006 - 2007, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _COMMPS2_H_
17 #define _COMMPS2_H_
18
19 #define PS2_PACKET_LENGTH 3
20 #define PS2_SYNC_MASK 0xc
21 #define PS2_SYNC_BYTE 0x8
22
23 #define IS_PS2_SYNC_BYTE(byte) ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)
24
25 #define PS2_READ_BYTE_ONE 0
26 #define PS2_READ_DATA_BYTE 1
27 #define PS2_PROCESS_PACKET 2
28
29 #define TIMEOUT 50000
30 #define BAT_TIMEOUT 500000
31
32 //
33 // 8042 I/O Port
34 //
35 #define KBC_DATA_PORT 0x60
36 #define KBC_CMD_STS_PORT 0x64
37
38 //
39 // 8042 Command
40 //
41 #define READ_CMD_BYTE 0x20
42 #define WRITE_CMD_BYTE 0x60
43 #define DISABLE_AUX 0xa7
44 #define ENABLE_AUX 0xa8
45 #define SELF_TEST 0xaa
46 #define DISABLE_KB 0xad
47 #define ENABLE_KB 0xae
48 #define WRITE_AUX_DEV 0xd4
49
50 #define CMD_SYS_FLAG 0x04
51 #define CMD_KB_STS 0x10
52 #define CMD_KB_DIS 0x10
53 #define CMD_KB_EN 0x0
54
55 //
56 // 8042 Auxiliary Device Command
57 //
58 #define SETSF1_CMD 0xe6
59 #define SETSF2_CMD 0xe7
60 #define SETRE_CMD 0xe8
61 #define READ_CMD 0xeb
62 #define SETRM_CMD 0xf0
63 #define SETSR_CMD 0xf3
64 #define ENABLE_CMD 0xf4
65 #define DISABLE_CMD 0xf5
66 #define RESET_CMD 0xff
67
68 //
69 // return code
70 //
71 #define PS2_ACK 0xfa
72 #define PS2_RESEND 0xfe
73 #define PS2MOUSE_BAT1 0xaa
74 #define PS2MOUSE_BAT2 0x0
75
76 //
77 // Keyboard Controller Status
78 //
79 #define KBC_PARE 0x80 // Parity Error
80 #define KBC_TIM 0x40 // General Time Out
81 #define KBC_AUXB 0x20 // Output buffer for auxiliary device (PS/2):
82 // 0 - Holds keyboard data
83 // 1 - Holds data for auxiliary device
84 //
85 #define KBC_KEYL 0x10 // Keyboard lock status:
86 // 0 - keyboard locked
87 // 1 - keyboard free
88 //
89 #define KBC_CD 0x08 // Command/Data:
90 // 0 - data byte written via port 60h
91 // 1 - command byte written via port 64h
92 //
93 #define KBC_SYSF 0x04 // System Flag:
94 // 0 - power-on reset
95 // 1 - self-test successful
96 //
97 #define KBC_INPB 0x02 // Input Buffer Status :
98 // 0 - input buffer empty
99 // 1 - CPU data in input buffer
100 //
101 #define KBC_OUTB 0x01 // Output Buffer Status :
102 // 0 - output buffer empty
103 // 1 - keyboard controller data in output buffer
104 //
105 EFI_STATUS
106 KbcSelfTest (
107 IN EFI_ISA_IO_PROTOCOL *IsaIo
108 )
109 /*++
110
111 Routine Description:
112
113 GC_TODO: Add function description
114
115 Arguments:
116
117 IsaIo - GC_TODO: add argument description
118
119 Returns:
120
121 GC_TODO: add return values
122
123 --*/
124 ;
125
126 EFI_STATUS
127 KbcEnableAux (
128 IN EFI_ISA_IO_PROTOCOL *IsaIo
129 )
130 /*++
131
132 Routine Description:
133
134 GC_TODO: Add function description
135
136 Arguments:
137
138 IsaIo - GC_TODO: add argument description
139
140 Returns:
141
142 GC_TODO: add return values
143
144 --*/
145 ;
146
147 EFI_STATUS
148 KbcDisableAux (
149 IN EFI_ISA_IO_PROTOCOL *IsaIo
150 )
151 /*++
152
153 Routine Description:
154
155 GC_TODO: Add function description
156
157 Arguments:
158
159 IsaIo - GC_TODO: add argument description
160
161 Returns:
162
163 GC_TODO: add return values
164
165 --*/
166 ;
167
168 EFI_STATUS
169 KbcEnableKb (
170 IN EFI_ISA_IO_PROTOCOL *IsaIo
171 )
172 /*++
173
174 Routine Description:
175
176 GC_TODO: Add function description
177
178 Arguments:
179
180 IsaIo - GC_TODO: add argument description
181
182 Returns:
183
184 GC_TODO: add return values
185
186 --*/
187 ;
188
189 EFI_STATUS
190 KbcDisableKb (
191 IN EFI_ISA_IO_PROTOCOL *IsaIo
192 )
193 /*++
194
195 Routine Description:
196
197 GC_TODO: Add function description
198
199 Arguments:
200
201 IsaIo - GC_TODO: add argument description
202
203 Returns:
204
205 GC_TODO: add return values
206
207 --*/
208 ;
209
210 EFI_STATUS
211 CheckKbStatus (
212 IN EFI_ISA_IO_PROTOCOL *IsaIo,
213 OUT BOOLEAN *KeyboardEnable
214 )
215 /*++
216
217 Routine Description:
218
219 GC_TODO: Add function description
220
221 Arguments:
222
223 IsaIo - GC_TODO: add argument description
224 KeyboardEnable - GC_TODO: add argument description
225
226 Returns:
227
228 GC_TODO: add return values
229
230 --*/
231 ;
232
233 EFI_STATUS
234 PS2MouseReset (
235 IN EFI_ISA_IO_PROTOCOL *IsaIo
236 )
237 /*++
238
239 Routine Description:
240
241 GC_TODO: Add function description
242
243 Arguments:
244
245 IsaIo - GC_TODO: add argument description
246
247 Returns:
248
249 GC_TODO: add return values
250
251 --*/
252 ;
253
254 EFI_STATUS
255 PS2MouseSetSampleRate (
256 IN EFI_ISA_IO_PROTOCOL *IsaIo,
257 IN MOUSE_SR SampleRate
258 )
259 /*++
260
261 Routine Description:
262
263 GC_TODO: Add function description
264
265 Arguments:
266
267 IsaIo - GC_TODO: add argument description
268 SampleRate - GC_TODO: add argument description
269
270 Returns:
271
272 GC_TODO: add return values
273
274 --*/
275 ;
276
277 EFI_STATUS
278 PS2MouseSetResolution (
279 IN EFI_ISA_IO_PROTOCOL *IsaIo,
280 IN MOUSE_RE Resolution
281 )
282 /*++
283
284 Routine Description:
285
286 GC_TODO: Add function description
287
288 Arguments:
289
290 IsaIo - GC_TODO: add argument description
291 Resolution - GC_TODO: add argument description
292
293 Returns:
294
295 GC_TODO: add return values
296
297 --*/
298 ;
299
300 EFI_STATUS
301 PS2MouseSetScaling (
302 IN EFI_ISA_IO_PROTOCOL *IsaIo,
303 IN MOUSE_SF Scaling
304 )
305 /*++
306
307 Routine Description:
308
309 GC_TODO: Add function description
310
311 Arguments:
312
313 IsaIo - GC_TODO: add argument description
314 Scaling - GC_TODO: add argument description
315
316 Returns:
317
318 GC_TODO: add return values
319
320 --*/
321 ;
322
323 EFI_STATUS
324 PS2MouseEnable (
325 IN EFI_ISA_IO_PROTOCOL *IsaIo
326 )
327 /*++
328
329 Routine Description:
330
331 GC_TODO: Add function description
332
333 Arguments:
334
335 IsaIo - GC_TODO: add argument description
336
337 Returns:
338
339 GC_TODO: add return values
340
341 --*/
342 ;
343
344 EFI_STATUS
345 PS2MouseGetPacket (
346 PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev
347 )
348 /*++
349
350 Routine Description:
351
352 GC_TODO: Add function description
353
354 Arguments:
355
356 MouseDev - GC_TODO: add argument description
357
358 Returns:
359
360 GC_TODO: add return values
361
362 --*/
363 ;
364
365 EFI_STATUS
366 PS2MouseRead (
367 IN EFI_ISA_IO_PROTOCOL *IsaIo,
368 OUT VOID *Buffer,
369 IN OUT UINTN *BufSize,
370 IN UINTN State
371 );
372
373 //
374 // 8042 I/O function
375 //
376 EFI_STATUS
377 Out8042Command (
378 IN EFI_ISA_IO_PROTOCOL *IsaIo,
379 IN UINT8 Command
380 );
381
382 EFI_STATUS
383 In8042Data (
384 IN EFI_ISA_IO_PROTOCOL *IsaIo,
385 IN OUT UINT8 *Data
386 );
387
388 EFI_STATUS
389 Out8042Data (
390 IN EFI_ISA_IO_PROTOCOL *IsaIo,
391 IN UINT8 Data
392 );
393
394 EFI_STATUS
395 Out8042AuxCommand (
396 IN EFI_ISA_IO_PROTOCOL *IsaIo,
397 IN UINT8 Command,
398 IN BOOLEAN Resend
399 );
400
401 EFI_STATUS
402 In8042AuxData (
403 IN EFI_ISA_IO_PROTOCOL *IsaIo,
404 IN OUT UINT8 *Data
405 );
406
407 EFI_STATUS
408 Out8042AuxData (
409 IN EFI_ISA_IO_PROTOCOL *IsaIo,
410 IN UINT8 Data
411 );
412
413 EFI_STATUS
414 CheckForInput (
415 IN EFI_ISA_IO_PROTOCOL *IsaIo
416 );
417
418 EFI_STATUS
419 WaitInputEmpty (
420 IN EFI_ISA_IO_PROTOCOL *IsaIo,
421 IN UINTN Timeout
422 );
423
424 EFI_STATUS
425 WaitOutputFull (
426 IN EFI_ISA_IO_PROTOCOL *IsaIo,
427 IN UINTN Timeout
428 );
429
430 #endif // _COMMPS2_H_