TianoCore EDK2 master
Loading...
Searching...
No Matches
CommPs2.h File Reference
#include "Ps2Mouse.h"

Go to the source code of this file.

Macros

#define PS2_PACKET_LENGTH   3
 
#define PS2_SYNC_MASK   0xc
 
#define PS2_SYNC_BYTE   0x8
 
#define IS_PS2_SYNC_BYTE(byte)   ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)
 
#define PS2_READ_BYTE_ONE   0
 
#define PS2_READ_DATA_BYTE   1
 
#define PS2_PROCESS_PACKET   2
 
#define TIMEOUT   50000
 
#define BAT_TIMEOUT   500000
 
#define KBC_DATA_PORT   0x60
 
#define KBC_CMD_STS_PORT   0x64
 
#define READ_CMD_BYTE   0x20
 
#define WRITE_CMD_BYTE   0x60
 
#define DISABLE_AUX   0xa7
 
#define ENABLE_AUX   0xa8
 
#define SELF_TEST   0xaa
 
#define DISABLE_KB   0xad
 
#define ENABLE_KB   0xae
 
#define WRITE_AUX_DEV   0xd4
 
#define CMD_SYS_FLAG   0x04
 
#define CMD_KB_STS   0x10
 
#define CMD_KB_DIS   0x10
 
#define CMD_KB_EN   0x0
 
#define SETSF1_CMD   0xe6
 
#define SETSF2_CMD   0xe7
 
#define SETRE_CMD   0xe8
 
#define READ_CMD   0xeb
 
#define SETRM_CMD   0xf0
 
#define SETSR_CMD   0xf3
 
#define ENABLE_CMD   0xf4
 
#define DISABLE_CMD   0xf5
 
#define RESET_CMD   0xff
 
#define PS2_ACK   0xfa
 
#define PS2_RESEND   0xfe
 
#define PS2MOUSE_BAT1   0xaa
 
#define PS2MOUSE_BAT2   0x0
 
#define KBC_PARE   0x80
 
#define KBC_TIM   0x40
 
#define KBC_AUXB   0x20
 
#define KBC_KEYL   0x10
 
#define KBC_CD   0x08
 
#define KBC_SYSF   0x04
 
#define KBC_INPB   0x02
 
#define KBC_OUTB   0x01
 

Functions

EFI_STATUS KbcSelfTest (VOID)
 
EFI_STATUS KbcEnableAux (VOID)
 
EFI_STATUS KbcDisableAux (VOID)
 
EFI_STATUS KbcEnableKb (VOID)
 
EFI_STATUS KbcDisableKb (VOID)
 
EFI_STATUS CheckKbStatus (OUT BOOLEAN *KeyboardEnable)
 
EFI_STATUS PS2MouseReset (VOID)
 
EFI_STATUS PS2MouseSetSampleRate (IN MOUSE_SR SampleRate)
 
EFI_STATUS PS2MouseSetResolution (IN MOUSE_RE Resolution)
 
EFI_STATUS PS2MouseSetScaling (IN MOUSE_SF Scaling)
 
EFI_STATUS PS2MouseEnable (VOID)
 
EFI_STATUS PS2MouseGetPacket (PS2_MOUSE_DEV *MouseDev)
 
EFI_STATUS PS2MouseRead (OUT UINT8 *Buffer, IN OUT UINTN *BufSize, IN UINTN State)
 
EFI_STATUS Out8042Command (IN UINT8 Command)
 
EFI_STATUS In8042Data (IN OUT UINT8 *Data)
 
EFI_STATUS Out8042Data (IN UINT8 Data)
 
EFI_STATUS Out8042AuxCommand (IN UINT8 Command, IN BOOLEAN Resend)
 
EFI_STATUS In8042AuxData (IN OUT UINT8 *Data)
 
EFI_STATUS Out8042AuxData (IN UINT8 Data)
 
EFI_STATUS CheckForInput (VOID)
 
EFI_STATUS WaitInputEmpty (IN UINTN Timeout)
 
EFI_STATUS WaitOutputFull (IN UINTN Timeout)
 

Detailed Description

PS2 Mouse Communication Interface

Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file CommPs2.h.

Macro Definition Documentation

◆ BAT_TIMEOUT

#define BAT_TIMEOUT   500000

Definition at line 25 of file CommPs2.h.

◆ CMD_KB_DIS

#define CMD_KB_DIS   0x10

Definition at line 47 of file CommPs2.h.

◆ CMD_KB_EN

#define CMD_KB_EN   0x0

Definition at line 48 of file CommPs2.h.

◆ CMD_KB_STS

#define CMD_KB_STS   0x10

Definition at line 46 of file CommPs2.h.

◆ CMD_SYS_FLAG

#define CMD_SYS_FLAG   0x04

Definition at line 45 of file CommPs2.h.

◆ DISABLE_AUX

#define DISABLE_AUX   0xa7

Definition at line 38 of file CommPs2.h.

◆ DISABLE_CMD

#define DISABLE_CMD   0xf5

Definition at line 60 of file CommPs2.h.

◆ DISABLE_KB

#define DISABLE_KB   0xad

Definition at line 41 of file CommPs2.h.

◆ ENABLE_AUX

#define ENABLE_AUX   0xa8

Definition at line 39 of file CommPs2.h.

◆ ENABLE_CMD

#define ENABLE_CMD   0xf4

Definition at line 59 of file CommPs2.h.

◆ ENABLE_KB

#define ENABLE_KB   0xae

Definition at line 42 of file CommPs2.h.

◆ IS_PS2_SYNC_BYTE

#define IS_PS2_SYNC_BYTE (   byte)    ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)

Definition at line 18 of file CommPs2.h.

◆ KBC_AUXB

#define KBC_AUXB   0x20

Output buffer for auxiliary device (PS/2): 0 - Holds keyboard data 1 - Holds data for auxiliary device

Definition at line 87 of file CommPs2.h.

◆ KBC_CD

#define KBC_CD   0x08

Command/Data: 0 - data byte written via port 60h 1 - command byte written via port 64h

Definition at line 99 of file CommPs2.h.

◆ KBC_CMD_STS_PORT

#define KBC_CMD_STS_PORT   0x64

Definition at line 31 of file CommPs2.h.

◆ KBC_DATA_PORT

#define KBC_DATA_PORT   0x60

Definition at line 30 of file CommPs2.h.

◆ KBC_INPB

#define KBC_INPB   0x02

Input Buffer Status : 0 - input buffer empty 1 - CPU data in input buffer

Definition at line 111 of file CommPs2.h.

◆ KBC_KEYL

#define KBC_KEYL   0x10

Keyboard lock status: 0 - keyboard locked 1 - keyboard free

Definition at line 93 of file CommPs2.h.

◆ KBC_OUTB

#define KBC_OUTB   0x01

Output Buffer Status : 0 - output buffer empty 1 - keyboard controller data in output buffer

Definition at line 117 of file CommPs2.h.

◆ KBC_PARE

#define KBC_PARE   0x80

Parity Error

Definition at line 77 of file CommPs2.h.

◆ KBC_SYSF

#define KBC_SYSF   0x04

System Flag: 0 - power-on reset 1 - self-test successful

Definition at line 105 of file CommPs2.h.

◆ KBC_TIM

#define KBC_TIM   0x40

General Time Out

Definition at line 81 of file CommPs2.h.

◆ PS2_ACK

#define PS2_ACK   0xfa

Definition at line 66 of file CommPs2.h.

◆ PS2_PACKET_LENGTH

#define PS2_PACKET_LENGTH   3

Definition at line 14 of file CommPs2.h.

◆ PS2_PROCESS_PACKET

#define PS2_PROCESS_PACKET   2

Definition at line 22 of file CommPs2.h.

◆ PS2_READ_BYTE_ONE

#define PS2_READ_BYTE_ONE   0

Definition at line 20 of file CommPs2.h.

◆ PS2_READ_DATA_BYTE

#define PS2_READ_DATA_BYTE   1

Definition at line 21 of file CommPs2.h.

◆ PS2_RESEND

#define PS2_RESEND   0xfe

Definition at line 67 of file CommPs2.h.

◆ PS2_SYNC_BYTE

#define PS2_SYNC_BYTE   0x8

Definition at line 16 of file CommPs2.h.

◆ PS2_SYNC_MASK

#define PS2_SYNC_MASK   0xc

Definition at line 15 of file CommPs2.h.

◆ PS2MOUSE_BAT1

#define PS2MOUSE_BAT1   0xaa

Definition at line 68 of file CommPs2.h.

◆ PS2MOUSE_BAT2

#define PS2MOUSE_BAT2   0x0

Definition at line 69 of file CommPs2.h.

◆ READ_CMD

#define READ_CMD   0xeb

Definition at line 56 of file CommPs2.h.

◆ READ_CMD_BYTE

#define READ_CMD_BYTE   0x20

Definition at line 36 of file CommPs2.h.

◆ RESET_CMD

#define RESET_CMD   0xff

Definition at line 61 of file CommPs2.h.

◆ SELF_TEST

#define SELF_TEST   0xaa

Definition at line 40 of file CommPs2.h.

◆ SETRE_CMD

#define SETRE_CMD   0xe8

Definition at line 55 of file CommPs2.h.

◆ SETRM_CMD

#define SETRM_CMD   0xf0

Definition at line 57 of file CommPs2.h.

◆ SETSF1_CMD

#define SETSF1_CMD   0xe6

Definition at line 53 of file CommPs2.h.

◆ SETSF2_CMD

#define SETSF2_CMD   0xe7

Definition at line 54 of file CommPs2.h.

◆ SETSR_CMD

#define SETSR_CMD   0xf3

Definition at line 58 of file CommPs2.h.

◆ TIMEOUT

#define TIMEOUT   50000

Definition at line 24 of file CommPs2.h.

◆ WRITE_AUX_DEV

#define WRITE_AUX_DEV   0xd4

Definition at line 43 of file CommPs2.h.

◆ WRITE_CMD_BYTE

#define WRITE_CMD_BYTE   0x60

Definition at line 37 of file CommPs2.h.

Function Documentation

◆ CheckForInput()

EFI_STATUS CheckForInput ( VOID  )

Check keyboard controller status, if it is output buffer full and for auxiliary device.

Return values
EFI_SUCCESSKeyboard controller is ready
EFI_NOT_READYKeyboard controller is not ready

Definition at line 766 of file CommPs2.c.

◆ CheckKbStatus()

EFI_STATUS CheckKbStatus ( OUT BOOLEAN *  KeyboardEnable)

Issue command to check keyboard status.

Parameters
KeyboardEnablereturn whether keyboard is enable.
Returns
Status of command issuing.

Definition at line 153 of file CommPs2.c.

◆ In8042AuxData()

EFI_STATUS In8042AuxData ( IN OUT UINT8 *  Data)

I/O work flow of in 8042 Aux data.

Parameters
DataBuffer holding return value.
Return values
EFI_SUCCESSSuccess to execute I/O work flow
EFI_TIMEOUTKeyboard controller time out.

Definition at line 740 of file CommPs2.c.

◆ In8042Data()

EFI_STATUS In8042Data ( IN OUT UINT8 *  Data)

I/O work flow of in 8042 data.

Parameters
DataData value
Return values
EFI_SUCCESSSuccess to execute I/O work flow
EFI_TIMEOUTKeyboard controller time out.

Definition at line 582 of file CommPs2.c.

◆ KbcDisableAux()

EFI_STATUS KbcDisableAux ( VOID  )

Issue command to disable keyboard AUX functionality.

Returns
Status of command issuing.

Issue command to disable keyboard AUX functionality.

Parameters
IsaIoPointer to instance of EFI_ISA_IO_PROTOCOL
Returns
Status of command issuing.

Definition at line 101 of file CommPs2.c.

◆ KbcDisableKb()

EFI_STATUS KbcDisableKb ( VOID  )

Issue command to disable keyboard.

Returns
Status of command issuing.

Definition at line 135 of file CommPs2.c.

◆ KbcEnableAux()

EFI_STATUS KbcEnableAux ( VOID  )

Issue command to enable keyboard AUX functionality.

Returns
Status of command issuing.

Definition at line 83 of file CommPs2.c.

◆ KbcEnableKb()

EFI_STATUS KbcEnableKb ( VOID  )

Issue command to enable keyboard.

Returns
Status of command issuing.

Issue command to enable keyboard.

Parameters
IsaIoPointer to instance of EFI_ISA_IO_PROTOCOL
Returns
Status of command issuing.

Definition at line 119 of file CommPs2.c.

◆ KbcSelfTest()

EFI_STATUS KbcSelfTest ( VOID  )

Issue self test command via IsaIo interface.

Returns
EFI_SUCCESS Success to do keyboard self testing.
others Fail to do keyboard self testing.

Definition at line 23 of file CommPs2.c.

◆ Out8042AuxCommand()

EFI_STATUS Out8042AuxCommand ( IN UINT8  Command,
IN BOOLEAN  Resend 
)

I/O work flow of outing 8042 Aux command.

Parameters
CommandAux I/O command
ResendWhether need resend the Aux command.
Return values
EFI_SUCCESSSuccess to execute I/O work flow
EFI_TIMEOUTKeyboard controller time out.

Definition at line 621 of file CommPs2.c.

◆ Out8042AuxData()

EFI_STATUS Out8042AuxData ( IN UINT8  Data)

I/O work flow of outing 8042 Aux data.

Parameters
DataBuffer holding return value
Return values
EFI_SUCCESSSuccess to execute I/O work flow
EFI_TIMEOUTKeyboard controller time out.

I/O work flow of outing 8042 Aux data.

Parameters
DataBuffer holding return value
Return values
EFI_SUCCESSSuccess to execute I/O work flow.
EFI_TIMEOUTKeyboard controller time out.

Definition at line 697 of file CommPs2.c.

◆ Out8042Command()

EFI_STATUS Out8042Command ( IN UINT8  Command)

I/O work flow of outing 8042 command.

Parameters
CommandI/O command.
Return values
EFI_SUCCESSSuccess to execute I/O work flow
EFI_TIMEOUTKeyboard controller time out.

Definition at line 519 of file CommPs2.c.

◆ Out8042Data()

EFI_STATUS Out8042Data ( IN UINT8  Data)

I/O work flow of outing 8042 data.

Parameters
DataData value
Return values
EFI_SUCCESSSuccess to execute I/O work flow
EFI_TIMEOUTKeyboard controller time out.

Definition at line 555 of file CommPs2.c.

◆ PS2MouseEnable()

EFI_STATUS PS2MouseEnable ( VOID  )

Issue command to enable Ps2 mouse.

Returns
Status of command issuing.

Definition at line 308 of file CommPs2.c.

◆ PS2MouseGetPacket()

EFI_STATUS PS2MouseGetPacket ( PS2_MOUSE_DEV MouseDev)

Get mouse packet . Only care first 3 bytes

Parameters
MouseDevPointer of PS2 Mouse Private Data Structure
Return values
EFI_NOT_READYMouse Device not ready to input data packet, or some error happened during getting the packet
EFI_SUCCESSThe data packet is gotten successfully.

Definition at line 328 of file CommPs2.c.

◆ PS2MouseRead()

EFI_STATUS PS2MouseRead ( OUT UINT8 *  Buffer,
IN OUT UINTN BufSize,
IN UINTN  State 
)

Read data via IsaIo protocol with given number.

Parameters
BufferBuffer receive data of mouse
BufSizeThe size of buffer
StateCheck input or read data
Returns
status of reading mouse data.

Definition at line 464 of file CommPs2.c.

◆ PS2MouseReset()

EFI_STATUS PS2MouseReset ( VOID  )

Issue command to reset keyboard.

Returns
Status of command issuing.

Definition at line 191 of file CommPs2.c.

◆ PS2MouseSetResolution()

EFI_STATUS PS2MouseSetResolution ( IN MOUSE_RE  Resolution)

Issue command to set mouse's resolution.

Parameters
Resolutionvalue of resolution
Returns
Status of command issuing.

Definition at line 265 of file CommPs2.c.

◆ PS2MouseSetSampleRate()

EFI_STATUS PS2MouseSetSampleRate ( IN MOUSE_SR  SampleRate)

Issue command to set mouse's sample rate

Parameters
SampleRatevalue of sample rate
Returns
Status of command issuing.

Definition at line 238 of file CommPs2.c.

◆ PS2MouseSetScaling()

EFI_STATUS PS2MouseSetScaling ( IN MOUSE_SF  Scaling)

Issue command to set mouse's scaling.

Parameters
Scalingvalue of scaling
Returns
Status of command issuing.

Definition at line 292 of file CommPs2.c.

◆ WaitInputEmpty()

EFI_STATUS WaitInputEmpty ( IN UINTN  Timeout)

I/O work flow to wait input buffer empty in given time.

Parameters
TimeoutWaiting time.
Return values
EFI_TIMEOUTif input is still not empty in given time.
EFI_SUCCESSinput is empty.

Definition at line 793 of file CommPs2.c.

◆ WaitOutputFull()

EFI_STATUS WaitOutputFull ( IN UINTN  Timeout)

I/O work flow to wait output buffer full in given time.

Parameters
Timeoutgiven time
Return values
EFI_TIMEOUToutput is not full in given time
EFI_SUCCESSoutput is full in given time.

Definition at line 832 of file CommPs2.c.