]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h
IntelFrameworkModulePkg: Fix typos in comments
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2MouseAbsolutePointerDxe / CommPs2.h
CommitLineData
18a73eb7 1/** @file\r
2 Using PS2 Mouse to simulation Absolution Pointer Device.\r
afd0fe22 3 \r
180a5a35
HT
4Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
afd0fe22 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
18a73eb7 15#ifndef __COMMPS2_H__\r
16#define __COMMPS2_H__\r
afd0fe22 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
cab302fd 78///\r
79/// Parity Error\r
80///\r
81#define KBC_PARE 0x80 \r
82///\r
83/// General Time Out\r
84///\r
85#define KBC_TIM 0x40 \r
86///\r
87/// Output buffer for auxiliary device (PS/2):\r
88/// 0 - Holds keyboard data\r
89/// 1 - Holds data for auxiliary device\r
90///\r
91#define KBC_AUXB 0x20 \r
92///\r
93/// Keyboard lock status:\r
94/// 0 - keyboard locked\r
95/// 1 - keyboard free\r
96///\r
97#define KBC_KEYL 0x10 \r
98///\r
99/// Command/Data:\r
100/// 0 - data byte written via port 60h\r
101/// 1 - command byte written via port 64h\r
102///\r
103#define KBC_CD 0x08\r
104///\r
105/// System Flag:\r
106/// 0 - power-on reset\r
107/// 1 - self-test successful\r
108///\r
109#define KBC_SYSF 0x04 \r
110///\r
111/// Input Buffer Status :\r
112/// 0 - input buffer empty\r
113/// 1 - CPU data in input buffer\r
114///\r
115#define KBC_INPB 0x02 \r
116///\r
117/// Output Buffer Status :\r
118/// 0 - output buffer empty\r
119/// 1 - keyboard controller data in output buffer\r
120///\r
121#define KBC_OUTB 0x01 \r
bcd70414 122\r
123/**\r
124 Issue self test command via IsaIo interface.\r
125 \r
126 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
127 \r
128 @return EFI_SUCCESS Success to do keyboard self testing.\r
129 @return others Fail to do keyboard self testing.\r
130**/\r
afd0fe22 131EFI_STATUS\r
132KbcSelfTest (\r
133 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
ed66e1bc 134 );\r
afd0fe22 135\r
bcd70414 136/**\r
137 Issue command to enable keyboard AUX functionality.\r
138 \r
139 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
140 \r
141 @return Status of command issuing.\r
142**/\r
afd0fe22 143EFI_STATUS\r
144KbcEnableAux (\r
145 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
ed66e1bc 146 );\r
afd0fe22 147\r
bcd70414 148/**\r
149 Issue command to disable keyboard AUX functionality.\r
150 \r
151 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
152 \r
153 @return Status of command issuing.\r
154**/\r
afd0fe22 155EFI_STATUS\r
156KbcDisableAux (\r
157 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
ed66e1bc 158 );\r
afd0fe22 159\r
bcd70414 160/**\r
161 Issue command to enable keyboard.\r
162 \r
163 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
164 \r
165 @return Status of command issuing.\r
166**/\r
afd0fe22 167EFI_STATUS\r
168KbcEnableKb (\r
169 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
ed66e1bc 170 );\r
afd0fe22 171\r
bcd70414 172/**\r
173 Issue command to disable keyboard.\r
174 \r
175 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
176 \r
177 @return Status of command issuing.\r
178**/\r
afd0fe22 179EFI_STATUS\r
180KbcDisableKb (\r
181 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
ed66e1bc 182 );\r
afd0fe22 183\r
bcd70414 184/**\r
185 Issue command to check keyboard status.\r
186 \r
187 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
188 @param KeyboardEnable return whether keyboard is enable.\r
189 \r
190 @return Status of command issuing.\r
191**/\r
afd0fe22 192EFI_STATUS\r
193CheckKbStatus (\r
194 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
195 OUT BOOLEAN *KeyboardEnable\r
ed66e1bc 196 );\r
afd0fe22 197\r
bcd70414 198/**\r
199 Issue command to reset keyboard.\r
200 \r
201 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
202 \r
203 @return Status of command issuing.\r
204**/\r
afd0fe22 205EFI_STATUS\r
206PS2MouseReset (\r
207 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
ed66e1bc 208 );\r
afd0fe22 209\r
bcd70414 210/**\r
211 Issue command to set mouse's sample rate\r
212 \r
213 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
214 @param SampleRate value of sample rate \r
215 \r
216 @return Status of command issuing.\r
217**/\r
afd0fe22 218EFI_STATUS\r
219PS2MouseSetSampleRate (\r
220 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
221 IN MOUSE_SR SampleRate\r
ed66e1bc 222 );\r
afd0fe22 223\r
bcd70414 224/**\r
225 Issue command to set mouse's resolution.\r
226 \r
227 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
228 @param Resolution value of resolution\r
229 \r
230 @return Status of command issuing.\r
231**/\r
afd0fe22 232EFI_STATUS\r
233PS2MouseSetResolution (\r
234 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
235 IN MOUSE_RE Resolution\r
ed66e1bc 236 );\r
afd0fe22 237\r
bcd70414 238/**\r
239 Issue command to set mouse's scaling.\r
240 \r
241 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
242 @param Scaling value of scaling\r
243 \r
244 @return Status of command issuing.\r
245**/\r
afd0fe22 246EFI_STATUS\r
247PS2MouseSetScaling (\r
248 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
249 IN MOUSE_SF Scaling\r
ed66e1bc 250 );\r
afd0fe22 251\r
bcd70414 252/**\r
253 Issue command to enable Ps2 mouse.\r
254 \r
255 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
256 \r
257 @return Status of command issuing.\r
258**/\r
afd0fe22 259EFI_STATUS\r
260PS2MouseEnable (\r
261 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
ed66e1bc 262 );\r
afd0fe22 263\r
bcd70414 264/**\r
265 Get mouse packet . Only care first 3 bytes\r
afd0fe22 266\r
18a73eb7 267 @param MouseAbsolutePointerDev Pointer to PS2 Absolute Pointer Simulation Device Private Data Structure\r
afd0fe22 268\r
bcd70414 269 @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet\r
270 @retval EFI_SUCCESS The data packet is gotten successfully.\r
afd0fe22 271\r
bcd70414 272**/\r
afd0fe22 273EFI_STATUS\r
274PS2MouseGetPacket (\r
275 PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev\r
ed66e1bc 276 );\r
afd0fe22 277\r
bcd70414 278/**\r
279 Read data via IsaIo protocol with given number.\r
280 \r
281 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
282 @param Buffer Buffer receive data of mouse\r
283 @param BufSize The size of buffer\r
284 @param State Check input or read data\r
285 \r
286 @return status of reading mouse data.\r
287**/\r
afd0fe22 288EFI_STATUS\r
289PS2MouseRead (\r
290 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
291 OUT VOID *Buffer,\r
292 IN OUT UINTN *BufSize,\r
293 IN UINTN State\r
294 );\r
295\r
296//\r
297// 8042 I/O function\r
298//\r
bcd70414 299/**\r
300 I/O work flow of outing 8042 command.\r
301 \r
302 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
303 @param Command I/O command.\r
304 \r
70d3fe9d 305 @retval EFI_SUCCESS Success to execute I/O work flow\r
bcd70414 306 @retval EFI_TIMEOUT Keyboard controller time out.\r
307**/\r
afd0fe22 308EFI_STATUS\r
309Out8042Command (\r
310 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
311 IN UINT8 Command\r
312 );\r
313\r
bcd70414 314/**\r
315 I/O work flow of in 8042 data.\r
316 \r
317 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
318 @param Data Data value\r
319 \r
70d3fe9d 320 @retval EFI_SUCCESS Success to execute I/O work flow\r
bcd70414 321 @retval EFI_TIMEOUT Keyboard controller time out.\r
322**/\r
afd0fe22 323EFI_STATUS\r
324In8042Data (\r
325 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
326 IN OUT UINT8 *Data\r
327 );\r
328\r
bcd70414 329/**\r
330 I/O work flow of outing 8042 data.\r
331 \r
332 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
333 @param Data Data value\r
334 \r
70d3fe9d 335 @retval EFI_SUCCESS Success to execute I/O work flow\r
bcd70414 336 @retval EFI_TIMEOUT Keyboard controller time out.\r
337**/\r
afd0fe22 338EFI_STATUS\r
339Out8042Data (\r
340 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
341 IN UINT8 Data\r
342 );\r
343\r
bcd70414 344/**\r
345 I/O work flow of outing 8042 Aux command.\r
346 \r
347 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
348 @param Command Aux I/O command\r
349 @param Resend Whether need resend the Aux command.\r
350 \r
70d3fe9d 351 @retval EFI_SUCCESS Success to execute I/O work flow\r
bcd70414 352 @retval EFI_TIMEOUT Keyboard controller time out.\r
353**/\r
afd0fe22 354EFI_STATUS\r
355Out8042AuxCommand (\r
356 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
357 IN UINT8 Command,\r
358 IN BOOLEAN Resend\r
359 );\r
360\r
bcd70414 361/**\r
362 I/O work flow of in 8042 Aux data.\r
363 \r
364 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
365 @param Data Buffer holding return value.\r
366 \r
70d3fe9d 367 @retval EFI_SUCCESS Success to execute I/O work flow\r
bcd70414 368 @retval EFI_TIMEOUT Keyboard controller time out.\r
369**/\r
afd0fe22 370EFI_STATUS\r
371In8042AuxData (\r
372 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
373 IN OUT UINT8 *Data\r
374 );\r
375\r
bcd70414 376/**\r
377 I/O work flow of outing 8042 Aux data.\r
378 \r
379 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
18a73eb7 380 @param Data Buffer holding return value.\r
bcd70414 381 \r
70d3fe9d 382 @retval EFI_SUCCESS Success to execute I/O work flow\r
bcd70414 383 @retval EFI_TIMEOUT Keyboard controller time out.\r
384**/\r
afd0fe22 385EFI_STATUS\r
386Out8042AuxData (\r
387 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
388 IN UINT8 Data\r
389 );\r
390\r
bcd70414 391/**\r
18a73eb7 392 Check keyboard controller status, if it is output buffer full and for auxiliary device.\r
bcd70414 393 \r
394 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
395 \r
396 @retval EFI_SUCCESS Keyboard controller is ready\r
397 @retval EFI_NOT_READY Keyboard controller is not ready\r
398**/\r
afd0fe22 399EFI_STATUS\r
400CheckForInput (\r
401 IN EFI_ISA_IO_PROTOCOL *IsaIo\r
402 );\r
403\r
bcd70414 404/**\r
405 I/O work flow to wait input buffer empty in given time.\r
406 \r
407 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
408 @param Timeout Wating time.\r
409 \r
410 @retval EFI_TIMEOUT if input is still not empty in given time.\r
411 @retval EFI_SUCCESS input is empty.\r
412**/\r
afd0fe22 413EFI_STATUS\r
414WaitInputEmpty (\r
415 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
416 IN UINTN Timeout\r
417 );\r
418\r
bcd70414 419/**\r
420 I/O work flow to wait output buffer full in given time.\r
421 \r
422 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
423 @param Timeout given time\r
424 \r
425 @retval EFI_TIMEOUT output is not full in given time\r
426 @retval EFI_SUCCESS output is full in given time.\r
427**/\r
afd0fe22 428EFI_STATUS\r
429WaitOutputFull (\r
430 IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
431 IN UINTN Timeout\r
432 );\r
433\r
cab302fd 434#endif\r
435\r