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