summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c')
-rw-r--r--MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c159
1 files changed, 85 insertions, 74 deletions
diff --git a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
index 835f33cfa8..b1ab17af37 100644
--- a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
+++ b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Ps2Keyboard.h"
/**
@@ -20,10 +19,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
BOOLEAN
IsEfikeyBufEmpty (
- IN EFI_KEY_QUEUE *Queue
+ IN EFI_KEY_QUEUE *Queue
)
{
- return (BOOLEAN) (Queue->Head == Queue->Tail);
+ return (BOOLEAN)(Queue->Head == Queue->Tail);
}
/**
@@ -37,19 +36,21 @@ IsEfikeyBufEmpty (
**/
EFI_STATUS
PopEfikeyBufHead (
- IN EFI_KEY_QUEUE *Queue,
- OUT EFI_KEY_DATA *KeyData OPTIONAL
+ IN EFI_KEY_QUEUE *Queue,
+ OUT EFI_KEY_DATA *KeyData OPTIONAL
)
{
if (IsEfikeyBufEmpty (Queue)) {
return EFI_NOT_READY;
}
+
//
// Retrieve and remove the values
//
if (KeyData != NULL) {
CopyMem (KeyData, &Queue->Buffer[Queue->Head], sizeof (EFI_KEY_DATA));
}
+
Queue->Head = (Queue->Head + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;
return EFI_SUCCESS;
}
@@ -62,8 +63,8 @@ PopEfikeyBufHead (
**/
VOID
PushEfikeyBufTail (
- IN EFI_KEY_QUEUE *Queue,
- IN EFI_KEY_DATA *KeyData
+ IN EFI_KEY_QUEUE *Queue,
+ IN EFI_KEY_DATA *KeyData
)
{
if ((Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT == Queue->Head) {
@@ -72,6 +73,7 @@ PushEfikeyBufTail (
//
PopEfikeyBufHead (Queue, NULL);
}
+
CopyMem (&Queue->Buffer[Queue->Tail], KeyData, sizeof (EFI_KEY_DATA));
Queue->Tail = (Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;
}
@@ -98,24 +100,27 @@ IsKeyRegistered (
ASSERT (RegsiteredData != NULL && InputData != NULL);
if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
- (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
+ (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
+ {
return FALSE;
}
//
// Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
//
- if (RegsiteredData->KeyState.KeyShiftState != 0 &&
- RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
+ if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
+ (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
+ {
return FALSE;
}
- if (RegsiteredData->KeyState.KeyToggleState != 0 &&
- RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
+
+ if ((RegsiteredData->KeyState.KeyToggleState != 0) &&
+ (RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState))
+ {
return FALSE;
}
return TRUE;
-
}
/**
@@ -136,13 +141,13 @@ IsKeyRegistered (
**/
EFI_STATUS
KeyboardReadKeyStrokeWorker (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev,
- OUT EFI_KEY_DATA *KeyData
+ IN KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev,
+ OUT EFI_KEY_DATA *KeyData
)
{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
@@ -185,9 +190,9 @@ KeyboardEfiReset (
IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_TPL OldTpl;
ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
if (ConsoleIn->KeyboardErr) {
@@ -232,6 +237,7 @@ KeyboardEfiReset (
ConsoleIn->DevicePath
);
}
+
//
// Report the status If keyboard is locked
//
@@ -261,9 +267,9 @@ KeyboardReadKeyStroke (
OUT EFI_INPUT_KEY *Key
)
{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_KEY_DATA KeyData;
ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
@@ -280,21 +286,23 @@ KeyboardReadKeyStroke (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// If it is partial keystroke, skip it.
//
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
+ if ((KeyData.Key.ScanCode == SCAN_NULL) && (KeyData.Key.UnicodeChar == CHAR_NULL)) {
continue;
}
+
//
// Translate the CTRL-Alpha characters to their corresponding control value
// (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
//
if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
- if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1);
- } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1);
+ if ((KeyData.Key.UnicodeChar >= L'a') && (KeyData.Key.UnicodeChar <= L'z')) {
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'a' + 1);
+ } else if ((KeyData.Key.UnicodeChar >= L'A') && (KeyData.Key.UnicodeChar <= L'Z')) {
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'A' + 1);
}
}
@@ -314,15 +322,15 @@ KeyboardReadKeyStroke (
VOID
EFIAPI
KeyboardWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_TPL OldTpl;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
+ EFI_TPL OldTpl;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_KEY_DATA KeyData;
- ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
+ ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *)Context;
//
// Enter critical section
@@ -344,10 +352,11 @@ KeyboardWaitForKey (
&(ConsoleIn->EfiKeyQueue.Buffer[ConsoleIn->EfiKeyQueue.Head]),
sizeof (EFI_KEY_DATA)
);
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
+ if ((KeyData.Key.ScanCode == SCAN_NULL) && (KeyData.Key.UnicodeChar == CHAR_NULL)) {
PopEfikeyBufHead (&ConsoleIn->EfiKeyQueue, &KeyData);
continue;
}
+
//
// if there is pending value key, signal the event.
//
@@ -355,6 +364,7 @@ KeyboardWaitForKey (
break;
}
}
+
//
// Leave critical section and return
//
@@ -372,8 +382,8 @@ KeyboardWaitForKey (
VOID
EFIAPI
KeyboardWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
@@ -399,7 +409,7 @@ KeyboardEfiResetEx (
)
{
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
@@ -428,12 +438,12 @@ KeyboardEfiResetEx (
EFI_STATUS
EFIAPI
KeyboardReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
)
{
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
@@ -465,9 +475,9 @@ KeyboardSetState (
)
{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
+ EFI_TPL OldTpl;
if (KeyToggleState == NULL) {
return EFI_INVALID_PARAMETER;
@@ -501,12 +511,15 @@ KeyboardSetState (
if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {
ConsoleInDev->ScrollLock = TRUE;
}
+
if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {
ConsoleInDev->NumLock = TRUE;
}
+
if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {
ConsoleInDev->CapsLock = TRUE;
}
+
if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {
ConsoleInDev->IsSupportPartialKey = TRUE;
}
@@ -523,7 +536,6 @@ Exit:
gBS->RestoreTPL (OldTpl);
return Status;
-
}
/**
@@ -553,14 +565,14 @@ KeyboardRegisterKeyNotify (
OUT VOID **NotifyHandle
)
{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
- LIST_ENTRY *Link;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
-
- if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
+ EFI_TPL OldTpl;
+ LIST_ENTRY *Link;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
+
+ if ((KeyData == NULL) || (NotifyHandle == NULL) || (KeyNotificationFunction == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -584,7 +596,7 @@ KeyboardRegisterKeyNotify (
if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
*NotifyHandle = CurrentNotify;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto Exit;
}
}
@@ -593,7 +605,7 @@ KeyboardRegisterKeyNotify (
//
// Allocate resource to save the notification function
//
- NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
+ NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *)AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
if (NewNotify == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
@@ -604,8 +616,8 @@ KeyboardRegisterKeyNotify (
CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));
InsertTailList (&ConsoleInDev->NotifyList, &NewNotify->NotifyEntry);
- *NotifyHandle = NewNotify;
- Status = EFI_SUCCESS;
+ *NotifyHandle = NewNotify;
+ Status = EFI_SUCCESS;
Exit:
//
@@ -613,7 +625,6 @@ Exit:
//
gBS->RestoreTPL (OldTpl);
return Status;
-
}
/**
@@ -634,11 +645,11 @@ KeyboardUnregisterKeyNotify (
IN VOID *NotificationHandle
)
{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
- LIST_ENTRY *Link;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
+ EFI_TPL OldTpl;
+ LIST_ENTRY *Link;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
@@ -691,19 +702,19 @@ Exit:
VOID
EFIAPI
KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
+ EFI_KEY_DATA KeyData;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_TPL OldTpl;
- ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
+ ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *)Context;
//
// Invoke notification functions.
@@ -722,6 +733,7 @@ KeyNotifyProcessHandler (
if (EFI_ERROR (Status)) {
break;
}
+
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
@@ -730,4 +742,3 @@ KeyNotifyProcessHandler (
}
}
}
-