TianoCore EDK2 master
Loading...
Searching...
No Matches
Ps2KbdCtrller.c File Reference
#include "Ps2Keyboard.h"

Go to the source code of this file.

Functions

UINTN GetScancodeBufCount (IN SCAN_CODE_QUEUE *Queue)
 
EFI_STATUS GetScancodeBufHead (IN SCAN_CODE_QUEUE *Queue, IN UINTN Count, OUT UINT8 *Buf)
 
EFI_STATUS PopScancodeBufHead (IN SCAN_CODE_QUEUE *Queue, IN UINTN Count, OUT UINT8 *Buf OPTIONAL)
 
VOID PushScancodeBufTail (IN SCAN_CODE_QUEUE *Queue, IN UINT8 Scancode)
 
UINT8 KeyReadDataRegister (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn)
 
VOID KeyWriteDataRegister (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN UINT8 Data)
 
UINT8 KeyReadStatusRegister (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn)
 
VOID KeyWriteCommandRegister (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN UINT8 Data)
 
VOID KeyboardError (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN CHAR16 *ErrMsg)
 
VOID EFIAPI KeyboardTimerHandler (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS KeyboardRead (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, OUT UINT8 *Data)
 
EFI_STATUS KeyboardWrite (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN UINT8 Data)
 
EFI_STATUS KeyboardCommand (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN UINT8 Data)
 
EFI_STATUS KeyboardWaitForValue (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN UINT8 Value)
 
EFI_STATUS UpdateStatusLights (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn)
 
VOID InitializeKeyState (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, OUT EFI_KEY_STATE *KeyState)
 
VOID KeyGetchar (IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn)
 
EFI_STATUS InitKeyboard (IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, IN BOOLEAN ExtendedVerification)
 
BOOLEAN EFIAPI CheckKeyboardConnect (IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn)
 

Variables

struct {
   UINT8   ScanCode
 follows value defined in Scan Code Set1 More...
 
   UINT16   EfiScanCode
 
   CHAR16   UnicodeChar
 
   CHAR16   ShiftUnicodeChar
 
ConvertKeyboardScanCodeToEfiKey []
 
UINTN mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT
 
BOOLEAN mEnableMouseInterface
 

Detailed Description

Routines that access 8042 keyboard controller

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

Definition in file Ps2KbdCtrller.c.

Function Documentation

◆ CheckKeyboardConnect()

BOOLEAN EFIAPI CheckKeyboardConnect ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn)

Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device should not be in system.

Parameters
[in]ConsoleInKeyboard Private Data Structure
Return values
TRUEKeyboard in System.
FALSEKeyboard not in System.

Definition at line 1840 of file Ps2KbdCtrller.c.

◆ GetScancodeBufCount()

UINTN GetScancodeBufCount ( IN SCAN_CODE_QUEUE Queue)

Return the count of scancode in the queue.

Parameters
QueuePointer to instance of SCAN_CODE_QUEUE.
Returns
Count of the scancode.

Definition at line 568 of file Ps2KbdCtrller.c.

◆ GetScancodeBufHead()

EFI_STATUS GetScancodeBufHead ( IN SCAN_CODE_QUEUE Queue,
IN UINTN  Count,
OUT UINT8 *  Buf 
)

Read several bytes from the scancode buffer without removing them. This function is called to see if there are enough bytes of scancode representing a single key.

Parameters
QueuePointer to instance of SCAN_CODE_QUEUE.
CountNumber of bytes to be read
BufStore the results
Return values
EFI_SUCCESSsuccess to scan the keyboard code
EFI_NOT_READYinvalid parameter

Definition at line 592 of file Ps2KbdCtrller.c.

◆ InitializeKeyState()

VOID InitializeKeyState ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
OUT EFI_KEY_STATE KeyState 
)

Initialize the key state.

Parameters
ConsoleInThe KEYBOARD_CONSOLE_IN_DEV instance.
KeyStateA pointer to receive the key state information.

Definition at line 1111 of file Ps2KbdCtrller.c.

◆ InitKeyboard()

EFI_STATUS InitKeyboard ( IN OUT KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
IN BOOLEAN  ExtendedVerification 
)

Perform 8042 controller and keyboard Initialization. If ExtendedVerification is TRUE, do additional test for the keyboard interface

Parameters
ConsoleIn- KEYBOARD_CONSOLE_IN_DEV instance pointer
ExtendedVerification- indicates a thorough initialization
Return values
EFI_DEVICE_ERRORFail to init keyboard
EFI_SUCCESSSuccess to init keyboard

Definition at line 1483 of file Ps2KbdCtrller.c.

◆ KeyboardCommand()

EFI_STATUS KeyboardCommand ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
IN UINT8  Data 
)

Issue keyboard command.

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
DataThe buff holding the command
Return values
EFI_TIMEOUTKeyboard is not ready to issuing
EFI_SUCCESSSuccess to issue keyboard command

Definition at line 924 of file Ps2KbdCtrller.c.

◆ KeyboardError()

VOID KeyboardError ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
IN CHAR16 *  ErrMsg 
)

Display error message.

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
ErrMsgUnicode string of error message

Definition at line 751 of file Ps2KbdCtrller.c.

◆ KeyboardRead()

EFI_STATUS KeyboardRead ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
OUT UINT8 *  Data 
)

Read key value .

Parameters
ConsoleIn- Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
Data- Pointer to outof buffer for keeping key value
Return values
EFI_TIMEOUTStatus register time out
EFI_SUCCESSSuccess to read keyboard

Definition at line 835 of file Ps2KbdCtrller.c.

◆ KeyboardTimerHandler()

VOID EFIAPI KeyboardTimerHandler ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Timer event handler: read a series of scancodes from 8042 and put them into memory scancode buffer. it read as much scancodes to either fill the memory buffer or empty the keyboard buffer. It is registered as running under TPL_NOTIFY

Parameters
EventThe timer event
ContextA KEYBOARD_CONSOLE_IN_DEV pointer

Definition at line 772 of file Ps2KbdCtrller.c.

◆ KeyboardWaitForValue()

EFI_STATUS KeyboardWaitForValue ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
IN UINT8  Value 
)

wait for a specific value to be presented on 8042 Data register by keyboard and then read it, used in keyboard commands ack

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
Valuethe value wanted to be waited.
Return values
EFI_TIMEOUTFail to get specific value in given time
EFI_SUCCESSSuccess to get specific value in given time.

Definition at line 989 of file Ps2KbdCtrller.c.

◆ KeyboardWrite()

EFI_STATUS KeyboardWrite ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
IN UINT8  Data 
)

write key to keyboard

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
Datavalue wanted to be written
Return values
EFI_TIMEOUTThe input buffer register is full for putting new value util timeout
EFI_SUCCESSThe new value is success put into input buffer register.

Definition at line 878 of file Ps2KbdCtrller.c.

◆ KeyGetchar()

VOID KeyGetchar ( IN OUT KEYBOARD_CONSOLE_IN_DEV ConsoleIn)

Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec.

The function is always called in TPL_NOTIFY.

Parameters
ConsoleInKEYBOARD_CONSOLE_IN_DEV instance pointer

Definition at line 1145 of file Ps2KbdCtrller.c.

◆ KeyReadDataRegister()

UINT8 KeyReadDataRegister ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn)

Read data register .

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
Returns
return the value

Definition at line 687 of file Ps2KbdCtrller.c.

◆ KeyReadStatusRegister()

UINT8 KeyReadStatusRegister ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn)

Read status register.

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
Returns
value in status register

Definition at line 720 of file Ps2KbdCtrller.c.

◆ KeyWriteCommandRegister()

VOID KeyWriteCommandRegister ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
IN UINT8  Data 
)

Write command register .

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
DataThe value wanted to be written

Definition at line 735 of file Ps2KbdCtrller.c.

◆ KeyWriteDataRegister()

VOID KeyWriteDataRegister ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn,
IN UINT8  Data 
)

Write data register.

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
Datavalue wanted to be written

Definition at line 703 of file Ps2KbdCtrller.c.

◆ PopScancodeBufHead()

EFI_STATUS PopScancodeBufHead ( IN SCAN_CODE_QUEUE Queue,
IN UINTN  Count,
OUT UINT8 *Buf  OPTIONAL 
)

Read & remove several bytes from the scancode buffer. This function is usually called after GetScancodeBufHead()

Parameters
QueuePointer to instance of SCAN_CODE_QUEUE.
CountNumber of bytes to be read
BufStore the results
Return values
EFI_SUCCESSsuccess to scan the keyboard code
EFI_NOT_READYinvalid parameter

Definition at line 631 of file Ps2KbdCtrller.c.

◆ PushScancodeBufTail()

VOID PushScancodeBufTail ( IN SCAN_CODE_QUEUE Queue,
IN UINT8  Scancode 
)

Push one byte to the scancode buffer.

Parameters
QueuePointer to instance of SCAN_CODE_QUEUE.
ScancodeThe byte to push.

Definition at line 665 of file Ps2KbdCtrller.c.

◆ UpdateStatusLights()

EFI_STATUS UpdateStatusLights ( IN KEYBOARD_CONSOLE_IN_DEV ConsoleIn)

Show keyboard status lights according to indicators in ConsoleIn.

Parameters
ConsoleInPointer to instance of KEYBOARD_CONSOLE_IN_DEV
Returns
status of updating keyboard register

Definition at line 1061 of file Ps2KbdCtrller.c.

Variable Documentation

◆ EfiScanCode

UINT16 EfiScanCode

Definition at line 13 of file Ps2KbdCtrller.c.

◆ mEnableMouseInterface

BOOLEAN mEnableMouseInterface

Definition at line 558 of file Ps2KbdCtrller.c.

◆ mWaitForValueTimeOut

UINTN mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT

Definition at line 556 of file Ps2KbdCtrller.c.

◆ ScanCode

UINT8 ScanCode

follows value defined in Scan Code Set1

Definition at line 12 of file Ps2KbdCtrller.c.

◆ ShiftUnicodeChar

CHAR16 ShiftUnicodeChar

Definition at line 15 of file Ps2KbdCtrller.c.

◆ UnicodeChar

CHAR16 UnicodeChar

Definition at line 14 of file Ps2KbdCtrller.c.