]>
git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h
2 PS2 Mouse Communication Interface
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
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.
19 #define PS2_PACKET_LENGTH 3
20 #define PS2_SYNC_MASK 0xc
21 #define PS2_SYNC_BYTE 0x8
23 #define IS_PS2_SYNC_BYTE(byte) ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)
25 #define PS2_READ_BYTE_ONE 0
26 #define PS2_READ_DATA_BYTE 1
27 #define PS2_PROCESS_PACKET 2
30 #define BAT_TIMEOUT 500000
35 #define KBC_DATA_PORT 0x60
36 #define KBC_CMD_STS_PORT 0x64
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
50 #define CMD_SYS_FLAG 0x04
51 #define CMD_KB_STS 0x10
52 #define CMD_KB_DIS 0x10
56 // 8042 Auxiliary Device Command
58 #define SETSF1_CMD 0xe6
59 #define SETSF2_CMD 0xe7
60 #define SETRE_CMD 0xe8
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
72 #define PS2_RESEND 0xfe
73 #define PS2MOUSE_BAT1 0xaa
74 #define PS2MOUSE_BAT2 0x0
77 // Keyboard Controller Status
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
85 #define KBC_KEYL 0x10 // Keyboard lock status:
86 // 0 - keyboard locked
89 #define KBC_CD 0x08 // Command/Data:
90 // 0 - data byte written via port 60h
91 // 1 - command byte written via port 64h
93 #define KBC_SYSF 0x04 // System Flag:
95 // 1 - self-test successful
97 #define KBC_INPB 0x02 // Input Buffer Status :
98 // 0 - input buffer empty
99 // 1 - CPU data in input buffer
101 #define KBC_OUTB 0x01 // Output Buffer Status :
102 // 0 - output buffer empty
103 // 1 - keyboard controller data in output buffer
107 Issue self test command via IsaIo interface.
109 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
111 @return EFI_SUCCESS Success to do keyboard self testing.
112 @return others Fail to do keyboard self testing.
116 IN EFI_ISA_IO_PROTOCOL
*IsaIo
121 Issue command to enable keyboard AUX functionality.
123 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
125 @return Status of command issuing.
129 IN EFI_ISA_IO_PROTOCOL
*IsaIo
134 Issue command to disable keyboard AUX functionality.
136 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
138 @return Status of command issuing.
142 IN EFI_ISA_IO_PROTOCOL
*IsaIo
147 Issue command to enable keyboard.
149 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
151 @return Status of command issuing.
155 IN EFI_ISA_IO_PROTOCOL
*IsaIo
160 Issue command to disable keyboard.
162 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
164 @return Status of command issuing.
168 IN EFI_ISA_IO_PROTOCOL
*IsaIo
173 Issue command to check keyboard status.
175 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
176 @param KeyboardEnable return whether keyboard is enable.
178 @return Status of command issuing.
182 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
183 OUT BOOLEAN
*KeyboardEnable
188 Issue command to reset keyboard.
190 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
192 @return Status of command issuing.
196 IN EFI_ISA_IO_PROTOCOL
*IsaIo
201 Issue command to set mouse's sample rate
203 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
204 @param SampleRate value of sample rate
206 @return Status of command issuing.
209 PS2MouseSetSampleRate (
210 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
211 IN MOUSE_SR SampleRate
216 Issue command to set mouse's resolution.
218 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
219 @param Resolution value of resolution
221 @return Status of command issuing.
224 PS2MouseSetResolution (
225 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
226 IN MOUSE_RE Resolution
231 Issue command to set mouse's scaling.
233 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
234 @param Scaling value of scaling
236 @return Status of command issuing.
240 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
246 Issue command to enable Ps2 mouse.
248 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
250 @return Status of command issuing.
254 IN EFI_ISA_IO_PROTOCOL
*IsaIo
259 Get mouse packet . Only care first 3 bytes
261 @param MouseDev Pointer of PS2 Mouse Private Data Structure
263 @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet
264 @retval EFI_SUCCESS The data packet is gotten successfully.
269 PS2_MOUSE_DEV
*MouseDev
274 Read data via IsaIo protocol with given number.
276 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
277 @param Buffer Buffer receive data of mouse
278 @param BufSize The size of buffer
279 @param State Check input or read data
281 @return status of reading mouse data.
285 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
287 IN OUT UINTN
*BufSize
,
295 I/O work flow of outing 8042 command.
297 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
298 @param Command I/O command.
300 @retval EFI_SUCCESS Success to excute I/O work flow
301 @retval EFI_TIMEOUT Keyboard controller time out.
305 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
310 I/O work flow of in 8042 data.
312 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
313 @param Data Data value
315 @retval EFI_SUCCESS Success to excute I/O work flow
316 @retval EFI_TIMEOUT Keyboard controller time out.
320 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
325 I/O work flow of outing 8042 data.
327 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
328 @param Data Data value
330 @retval EFI_SUCCESS Success to excute I/O work flow
331 @retval EFI_TIMEOUT Keyboard controller time out.
335 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
340 I/O work flow of outing 8042 Aux command.
342 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
343 @param Command Aux I/O command
344 @param Resend Whether need resend the Aux command.
346 @retval EFI_SUCCESS Success to excute I/O work flow
347 @retval EFI_TIMEOUT Keyboard controller time out.
351 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
357 I/O work flow of in 8042 Aux data.
359 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
360 @param Data Buffer holding return value.
362 @retval EFI_SUCCESS Success to excute I/O work flow
363 @retval EFI_TIMEOUT Keyboard controller time out.
367 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
372 I/O work flow of outing 8042 Aux data.
374 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
375 @param Command Aux I/O command
377 @retval EFI_SUCCESS Success to excute I/O work flow
378 @retval EFI_TIMEOUT Keyboard controller time out.
382 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
387 Check keyboard controller status, if it is output buffer full and for auxiliary device
389 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
391 @retval EFI_SUCCESS Keyboard controller is ready
392 @retval EFI_NOT_READY Keyboard controller is not ready
396 IN EFI_ISA_IO_PROTOCOL
*IsaIo
400 I/O work flow to wait input buffer empty in given time.
402 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
403 @param Timeout Wating time.
405 @retval EFI_TIMEOUT if input is still not empty in given time.
406 @retval EFI_SUCCESS input is empty.
410 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
415 I/O work flow to wait output buffer full in given time.
417 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
418 @param Timeout given time
420 @retval EFI_TIMEOUT output is not full in given time
421 @retval EFI_SUCCESS output is full in given time.
425 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
429 #endif // _COMMPS2_H_