+++ /dev/null
-/** @file\r
- Using PS2 Mouse to simulation Absolution Pointer Device.\r
-\r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __COMMPS2_H__\r
-#define __COMMPS2_H__\r
-\r
-#define PS2_PACKET_LENGTH 3\r
-#define PS2_SYNC_MASK 0xc\r
-#define PS2_SYNC_BYTE 0x8\r
-\r
-#define IS_PS2_SYNC_BYTE(byte) ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)\r
-\r
-#define PS2_READ_BYTE_ONE 0\r
-#define PS2_READ_DATA_BYTE 1\r
-#define PS2_PROCESS_PACKET 2\r
-\r
-#define TIMEOUT 50000\r
-#define BAT_TIMEOUT 500000\r
-\r
-//\r
-// 8042 I/O Port\r
-//\r
-#define KBC_DATA_PORT 0x60\r
-#define KBC_CMD_STS_PORT 0x64\r
-\r
-//\r
-// 8042 Command\r
-//\r
-#define READ_CMD_BYTE 0x20\r
-#define WRITE_CMD_BYTE 0x60\r
-#define DISABLE_AUX 0xa7\r
-#define ENABLE_AUX 0xa8\r
-#define SELF_TEST 0xaa\r
-#define DISABLE_KB 0xad\r
-#define ENABLE_KB 0xae\r
-#define WRITE_AUX_DEV 0xd4\r
-\r
-#define CMD_SYS_FLAG 0x04\r
-#define CMD_KB_STS 0x10\r
-#define CMD_KB_DIS 0x10\r
-#define CMD_KB_EN 0x0\r
-\r
-//\r
-// 8042 Auxiliary Device Command\r
-//\r
-#define SETSF1_CMD 0xe6\r
-#define SETSF2_CMD 0xe7\r
-#define SETRE_CMD 0xe8\r
-#define READ_CMD 0xeb\r
-#define SETRM_CMD 0xf0\r
-#define SETSR_CMD 0xf3\r
-#define ENABLE_CMD 0xf4\r
-#define DISABLE_CMD 0xf5\r
-#define RESET_CMD 0xff\r
-\r
-//\r
-// return code\r
-//\r
-#define PS2_ACK 0xfa\r
-#define PS2_RESEND 0xfe\r
-#define PS2MOUSE_BAT1 0xaa\r
-#define PS2MOUSE_BAT2 0x0\r
-\r
-//\r
-// Keyboard Controller Status\r
-//\r
-///\r
-/// Parity Error\r
-///\r
-#define KBC_PARE 0x80\r
-///\r
-/// General Time Out\r
-///\r
-#define KBC_TIM 0x40\r
-///\r
-/// Output buffer for auxiliary device (PS/2):\r
-/// 0 - Holds keyboard data\r
-/// 1 - Holds data for auxiliary device\r
-///\r
-#define KBC_AUXB 0x20\r
-///\r
-/// Keyboard lock status:\r
-/// 0 - keyboard locked\r
-/// 1 - keyboard free\r
-///\r
-#define KBC_KEYL 0x10\r
-///\r
-/// Command/Data:\r
-/// 0 - data byte written via port 60h\r
-/// 1 - command byte written via port 64h\r
-///\r
-#define KBC_CD 0x08\r
-///\r
-/// System Flag:\r
-/// 0 - power-on reset\r
-/// 1 - self-test successful\r
-///\r
-#define KBC_SYSF 0x04\r
-///\r
-/// Input Buffer Status :\r
-/// 0 - input buffer empty\r
-/// 1 - CPU data in input buffer\r
-///\r
-#define KBC_INPB 0x02\r
-///\r
-/// Output Buffer Status :\r
-/// 0 - output buffer empty\r
-/// 1 - keyboard controller data in output buffer\r
-///\r
-#define KBC_OUTB 0x01\r
-\r
-/**\r
- Issue self test command via IsaIo interface.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @return EFI_SUCCESS Success to do keyboard self testing.\r
- @return others Fail to do keyboard self testing.\r
-**/\r
-EFI_STATUS\r
-KbcSelfTest (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- Issue command to enable keyboard AUX functionality.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableAux (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- Issue command to disable keyboard AUX functionality.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableAux (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- Issue command to enable keyboard.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcEnableKb (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- Issue command to disable keyboard.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-KbcDisableKb (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- Issue command to check keyboard status.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param KeyboardEnable return whether keyboard is enable.\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-CheckKbStatus (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- OUT BOOLEAN *KeyboardEnable\r
- );\r
-\r
-/**\r
- Issue command to reset keyboard.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseReset (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- Issue command to set mouse's sample rate\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param SampleRate value of sample rate\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetSampleRate (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN MOUSE_SR SampleRate\r
- );\r
-\r
-/**\r
- Issue command to set mouse's resolution.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Resolution value of resolution\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetResolution (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN MOUSE_RE Resolution\r
- );\r
-\r
-/**\r
- Issue command to set mouse's scaling.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Scaling value of scaling\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseSetScaling (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN MOUSE_SF Scaling\r
- );\r
-\r
-/**\r
- Issue command to enable Ps2 mouse.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @return Status of command issuing.\r
-**/\r
-EFI_STATUS\r
-PS2MouseEnable (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- Get mouse packet . Only care first 3 bytes\r
-\r
- @param MouseAbsolutePointerDev Pointer to PS2 Absolute Pointer Simulation Device Private Data Structure\r
-\r
- @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet\r
- @retval EFI_SUCCESS The data packet is gotten successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-PS2MouseGetPacket (\r
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev\r
- );\r
-\r
-/**\r
- Read data via IsaIo protocol with given number.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Buffer Buffer receive data of mouse\r
- @param BufSize The size of buffer\r
- @param State Check input or read data\r
-\r
- @return status of reading mouse data.\r
-**/\r
-EFI_STATUS\r
-PS2MouseRead (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- OUT VOID *Buffer,\r
- IN OUT UINTN *BufSize,\r
- IN UINTN State\r
- );\r
-\r
-//\r
-// 8042 I/O function\r
-//\r
-/**\r
- I/O work flow of outing 8042 command.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Command I/O command.\r
-\r
- @retval EFI_SUCCESS Success to execute I/O work flow\r
- @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Command (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN UINT8 Command\r
- );\r
-\r
-/**\r
- I/O work flow of in 8042 data.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Data Data value\r
-\r
- @retval EFI_SUCCESS Success to execute I/O work flow\r
- @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042Data (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN OUT UINT8 *Data\r
- );\r
-\r
-/**\r
- I/O work flow of outing 8042 data.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Data Data value\r
-\r
- @retval EFI_SUCCESS Success to execute I/O work flow\r
- @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042Data (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN UINT8 Data\r
- );\r
-\r
-/**\r
- I/O work flow of outing 8042 Aux command.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Command Aux I/O command\r
- @param Resend Whether need resend the Aux command.\r
-\r
- @retval EFI_SUCCESS Success to execute I/O work flow\r
- @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxCommand (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN UINT8 Command,\r
- IN BOOLEAN Resend\r
- );\r
-\r
-/**\r
- I/O work flow of in 8042 Aux data.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Data Buffer holding return value.\r
-\r
- @retval EFI_SUCCESS Success to execute I/O work flow\r
- @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-In8042AuxData (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN OUT UINT8 *Data\r
- );\r
-\r
-/**\r
- I/O work flow of outing 8042 Aux data.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Data Buffer holding return value.\r
-\r
- @retval EFI_SUCCESS Success to execute I/O work flow\r
- @retval EFI_TIMEOUT Keyboard controller time out.\r
-**/\r
-EFI_STATUS\r
-Out8042AuxData (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN UINT8 Data\r
- );\r
-\r
-/**\r
- Check keyboard controller status, if it is output buffer full and for auxiliary device.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
-\r
- @retval EFI_SUCCESS Keyboard controller is ready\r
- @retval EFI_NOT_READY Keyboard controller is not ready\r
-**/\r
-EFI_STATUS\r
-CheckForInput (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo\r
- );\r
-\r
-/**\r
- I/O work flow to wait input buffer empty in given time.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Timeout Wating time.\r
-\r
- @retval EFI_TIMEOUT if input is still not empty in given time.\r
- @retval EFI_SUCCESS input is empty.\r
-**/\r
-EFI_STATUS\r
-WaitInputEmpty (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN UINTN Timeout\r
- );\r
-\r
-/**\r
- I/O work flow to wait output buffer full in given time.\r
-\r
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL\r
- @param Timeout given time\r
-\r
- @retval EFI_TIMEOUT output is not full in given time\r
- @retval EFI_SUCCESS output is full in given time.\r
-**/\r
-EFI_STATUS\r
-WaitOutputFull (\r
- IN EFI_ISA_IO_PROTOCOL *IsaIo,\r
- IN UINTN Timeout\r
- );\r
-\r
-#endif\r
-\r