]>
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
120 Issue command to enable keyboard AUX functionality.
122 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
124 @return Status of command issuing.
128 IN EFI_ISA_IO_PROTOCOL
*IsaIo
132 Issue command to disable keyboard AUX functionality.
134 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
136 @return Status of command issuing.
140 IN EFI_ISA_IO_PROTOCOL
*IsaIo
144 Issue command to enable keyboard.
146 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
148 @return Status of command issuing.
152 IN EFI_ISA_IO_PROTOCOL
*IsaIo
156 Issue command to disable keyboard.
158 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
160 @return Status of command issuing.
164 IN EFI_ISA_IO_PROTOCOL
*IsaIo
168 Issue command to check keyboard status.
170 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
171 @param KeyboardEnable return whether keyboard is enable.
173 @return Status of command issuing.
177 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
178 OUT BOOLEAN
*KeyboardEnable
182 Issue command to reset keyboard.
184 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
186 @return Status of command issuing.
190 IN EFI_ISA_IO_PROTOCOL
*IsaIo
194 Issue command to set mouse's sample rate
196 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
197 @param SampleRate value of sample rate
199 @return Status of command issuing.
202 PS2MouseSetSampleRate (
203 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
204 IN MOUSE_SR SampleRate
208 Issue command to set mouse's resolution.
210 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
211 @param Resolution value of resolution
213 @return Status of command issuing.
216 PS2MouseSetResolution (
217 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
218 IN MOUSE_RE Resolution
222 Issue command to set mouse's scaling.
224 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
225 @param Scaling value of scaling
227 @return Status of command issuing.
231 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
236 Issue command to enable Ps2 mouse.
238 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
240 @return Status of command issuing.
244 IN EFI_ISA_IO_PROTOCOL
*IsaIo
248 Get mouse packet . Only care first 3 bytes
250 @param MouseDev Pointer of PS2 Mouse Private Data Structure
252 @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet
253 @retval EFI_SUCCESS The data packet is gotten successfully.
258 PS2_MOUSE_DEV
*MouseDev
262 Read data via IsaIo protocol with given number.
264 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
265 @param Buffer Buffer receive data of mouse
266 @param BufSize The size of buffer
267 @param State Check input or read data
269 @return status of reading mouse data.
273 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
275 IN OUT UINTN
*BufSize
,
283 I/O work flow of outing 8042 command.
285 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
286 @param Command I/O command.
288 @retval EFI_SUCCESS Success to excute I/O work flow
289 @retval EFI_TIMEOUT Keyboard controller time out.
293 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
298 I/O work flow of in 8042 data.
300 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
301 @param Data Data value
303 @retval EFI_SUCCESS Success to excute I/O work flow
304 @retval EFI_TIMEOUT Keyboard controller time out.
308 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
313 I/O work flow of outing 8042 data.
315 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
316 @param Data Data value
318 @retval EFI_SUCCESS Success to excute I/O work flow
319 @retval EFI_TIMEOUT Keyboard controller time out.
323 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
328 I/O work flow of outing 8042 Aux command.
330 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
331 @param Command Aux I/O command
332 @param Resend Whether need resend the Aux command.
334 @retval EFI_SUCCESS Success to excute I/O work flow
335 @retval EFI_TIMEOUT Keyboard controller time out.
339 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
345 I/O work flow of in 8042 Aux data.
347 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
348 @param Data Buffer holding return value.
350 @retval EFI_SUCCESS Success to excute I/O work flow
351 @retval EFI_TIMEOUT Keyboard controller time out.
355 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
360 I/O work flow of outing 8042 Aux data.
362 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
363 @param Command Aux I/O command
365 @retval EFI_SUCCESS Success to excute I/O work flow
366 @retval EFI_TIMEOUT Keyboard controller time out.
370 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
375 Check keyboard controller status, if it is output buffer full and for auxiliary device
377 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
379 @retval EFI_SUCCESS Keyboard controller is ready
380 @retval EFI_NOT_READY Keyboard controller is not ready
384 IN EFI_ISA_IO_PROTOCOL
*IsaIo
388 I/O work flow to wait input buffer empty in given time.
390 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
391 @param Timeout Wating time.
393 @retval EFI_TIMEOUT if input is still not empty in given time.
394 @retval EFI_SUCCESS input is empty.
398 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
403 I/O work flow to wait output buffer full in given time.
405 @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
406 @param Timeout given time
408 @retval EFI_TIMEOUT output is not full in given time
409 @retval EFI_SUCCESS output is full in given time.
413 IN EFI_ISA_IO_PROTOCOL
*IsaIo
,
417 #endif // _COMMPS2_H_