]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h
2 PS2 Mouse Communication Interface
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #define PS2_PACKET_LENGTH 3
15 #define PS2_SYNC_MASK 0xc
16 #define PS2_SYNC_BYTE 0x8
18 #define IS_PS2_SYNC_BYTE(byte) ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)
20 #define PS2_READ_BYTE_ONE 0
21 #define PS2_READ_DATA_BYTE 1
22 #define PS2_PROCESS_PACKET 2
25 #define BAT_TIMEOUT 500000
30 #define KBC_DATA_PORT 0x60
31 #define KBC_CMD_STS_PORT 0x64
36 #define READ_CMD_BYTE 0x20
37 #define WRITE_CMD_BYTE 0x60
38 #define DISABLE_AUX 0xa7
39 #define ENABLE_AUX 0xa8
40 #define SELF_TEST 0xaa
41 #define DISABLE_KB 0xad
42 #define ENABLE_KB 0xae
43 #define WRITE_AUX_DEV 0xd4
45 #define CMD_SYS_FLAG 0x04
46 #define CMD_KB_STS 0x10
47 #define CMD_KB_DIS 0x10
51 // 8042 Auxiliary Device Command
53 #define SETSF1_CMD 0xe6
54 #define SETSF2_CMD 0xe7
55 #define SETRE_CMD 0xe8
57 #define SETRM_CMD 0xf0
58 #define SETSR_CMD 0xf3
59 #define ENABLE_CMD 0xf4
60 #define DISABLE_CMD 0xf5
61 #define RESET_CMD 0xff
67 #define PS2_RESEND 0xfe
68 #define PS2MOUSE_BAT1 0xaa
69 #define PS2MOUSE_BAT2 0x0
72 // Keyboard Controller Status
83 /// Output buffer for auxiliary device (PS/2):
84 /// 0 - Holds keyboard data
85 /// 1 - Holds data for auxiliary device
89 /// Keyboard lock status:
90 /// 0 - keyboard locked
96 /// 0 - data byte written via port 60h
97 /// 1 - command byte written via port 64h
102 /// 0 - power-on reset
103 /// 1 - self-test successful
105 #define KBC_SYSF 0x04
107 /// Input Buffer Status :
108 /// 0 - input buffer empty
109 /// 1 - CPU data in input buffer
111 #define KBC_INPB 0x02
113 /// Output Buffer Status :
114 /// 0 - output buffer empty
115 /// 1 - keyboard controller data in output buffer
117 #define KBC_OUTB 0x01
120 Issue self test command via IsaIo interface.
122 @return EFI_SUCCESS Success to do keyboard self testing.
123 @return others Fail to do keyboard self testing.
131 Issue command to enable keyboard AUX functionality.
133 @return Status of command issuing.
141 Issue command to disable keyboard AUX functionality.
143 @return Status of command issuing.
151 Issue command to enable keyboard.
153 @return Status of command issuing.
161 Issue command to disable keyboard.
163 @return Status of command issuing.
171 Issue command to check keyboard status.
173 @param KeyboardEnable return whether keyboard is enable.
175 @return Status of command issuing.
179 OUT BOOLEAN
*KeyboardEnable
183 Issue command to reset keyboard.
185 @return Status of command issuing.
193 Issue command to set mouse's sample rate
195 @param SampleRate value of sample rate
197 @return Status of command issuing.
200 PS2MouseSetSampleRate (
201 IN MOUSE_SR SampleRate
205 Issue command to set mouse's resolution.
207 @param Resolution value of resolution
209 @return Status of command issuing.
212 PS2MouseSetResolution (
213 IN MOUSE_RE Resolution
217 Issue command to set mouse's scaling.
219 @param Scaling value of scaling
221 @return Status of command issuing.
229 Issue command to enable Ps2 mouse.
231 @return Status of command issuing.
239 Get mouse packet . Only care first 3 bytes
241 @param MouseDev Pointer of PS2 Mouse Private Data Structure
243 @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet
244 @retval EFI_SUCCESS The data packet is gotten successfully.
249 PS2_MOUSE_DEV
*MouseDev
253 Read data via IsaIo protocol with given number.
255 @param Buffer Buffer receive data of mouse
256 @param BufSize The size of buffer
257 @param State Check input or read data
259 @return status of reading mouse data.
264 IN OUT UINTN
*BufSize
,
272 I/O work flow of outing 8042 command.
274 @param Command I/O command.
276 @retval EFI_SUCCESS Success to execute I/O work flow
277 @retval EFI_TIMEOUT Keyboard controller time out.
285 I/O work flow of in 8042 data.
287 @param Data Data value
289 @retval EFI_SUCCESS Success to execute I/O work flow
290 @retval EFI_TIMEOUT Keyboard controller time out.
298 I/O work flow of outing 8042 data.
300 @param Data Data value
302 @retval EFI_SUCCESS Success to execute I/O work flow
303 @retval EFI_TIMEOUT Keyboard controller time out.
311 I/O work flow of outing 8042 Aux command.
313 @param Command Aux I/O command
314 @param Resend Whether need resend the Aux command.
316 @retval EFI_SUCCESS Success to execute I/O work flow
317 @retval EFI_TIMEOUT Keyboard controller time out.
326 I/O work flow of in 8042 Aux data.
328 @param Data Buffer holding return value.
330 @retval EFI_SUCCESS Success to execute I/O work flow
331 @retval EFI_TIMEOUT Keyboard controller time out.
339 I/O work flow of outing 8042 Aux data.
341 @param Data Buffer holding return value
343 @retval EFI_SUCCESS Success to execute I/O work flow
344 @retval EFI_TIMEOUT Keyboard controller time out.
352 Check keyboard controller status, if it is output buffer full and for auxiliary device.
354 @retval EFI_SUCCESS Keyboard controller is ready
355 @retval EFI_NOT_READY Keyboard controller is not ready
363 I/O work flow to wait input buffer empty in given time.
365 @param Timeout Wating time.
367 @retval EFI_TIMEOUT if input is still not empty in given time.
368 @retval EFI_SUCCESS input is empty.
376 I/O work flow to wait output buffer full in given time.
378 @param Timeout given time
380 @retval EFI_TIMEOUT output is not full in given time
381 @retval EFI_SUCCESS output is full in given time.