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