]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update to support EFI_SIMPLE_INPUT_EX protocol
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Oct 2007 02:35:55 +0000 (02:35 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Oct 2007 02:35:55 +0000 (02:35 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4179 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf

index c4f1ee1780ee54a4d03896f80e2943b031d84d89..26e40d6bea9c9f53c36f092e01e213e824e93086 100644 (file)
@@ -85,16 +85,6 @@ KeyboardWaitForValue (
   IN UINT8                   Value\r
   );\r
 \r
-STATIC\r
-EFI_STATUS\r
-UpdateStatusLights (\r
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
-  );\r
-\r
-//\r
-// Global variables\r
-//\r
-\r
 STATIC struct {\r
   UINT8  ScanCode;\r
   UINT16  EfiScanCode;\r
@@ -613,6 +603,24 @@ ConvertKeyboardScanCodeToEfiKey[] = {
     0x00,\r
     0x00\r
   },\r
+  {\r
+    0x5B,  //Left LOGO\r
+    SCAN_NULL,\r
+    0x00,\r
+    0x00\r
+  },  \r
+  {\r
+    0x5C,  //Right LOGO\r
+    SCAN_NULL,\r
+    0x00,\r
+    0x00\r
+  },  \r
+  {\r
+    0x5D,  //Menu key\r
+    SCAN_NULL,\r
+    0x00,\r
+    0x00\r
+  },    \r
   {\r
     TABLE_END,\r
     TABLE_END,\r
@@ -1316,7 +1324,6 @@ Returns:
 \r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 UpdateStatusLights (\r
   IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
@@ -1550,19 +1557,55 @@ Returns:
       break;\r
 \r
     case SCANCODE_LEFT_SHIFT_MAKE:\r
+      if (!Extended) {\r
+        ConsoleIn->Shift     = TRUE;\r
+        ConsoleIn->LeftShift = TRUE;\r
+      }      \r
+      break;\r
     case SCANCODE_RIGHT_SHIFT_MAKE:\r
       if (!Extended) {\r
         ConsoleIn->Shift = TRUE;\r
+        ConsoleIn->RightShift = TRUE;\r
       }\r
       break;\r
 \r
     case SCANCODE_LEFT_SHIFT_BREAK:\r
+      if (!Extended) {\r
+        ConsoleIn->Shift     = FALSE;\r
+        ConsoleIn->LeftShift = FALSE;\r
+      } else {\r
+        ConsoleIn->SysReq    = FALSE;\r
+      }      \r
+      break;\r
     case SCANCODE_RIGHT_SHIFT_BREAK:\r
       if (!Extended) {\r
         ConsoleIn->Shift = FALSE;\r
+        ConsoleIn->RightShift = FALSE;\r
       }\r
       break;\r
 \r
+    case SCANCODE_LEFT_LOGO_MAKE:\r
+      ConsoleIn->LeftLogo = TRUE;\r
+      break;    \r
+    case SCANCODE_LEFT_LOGO_BREAK:\r
+      ConsoleIn->LeftLogo = FALSE;\r
+      break;          \r
+    case SCANCODE_RIGHT_LOGO_MAKE:\r
+      ConsoleIn->RightLogo = TRUE;\r
+      break;\r
+    case SCANCODE_RIGHT_LOGO_BREAK:\r
+      ConsoleIn->RightLogo = FALSE;\r
+      break;      \r
+    case SCANCODE_MENU_MAKE:\r
+      ConsoleIn->Menu = TRUE;\r
+      break;\r
+    case SCANCODE_MENU_BREAK:\r
+      ConsoleIn->Menu = FALSE;\r
+      break;      \r
+    case SCANCODE_SYS_REQ_MAKE:\r
+      if (Extended) {\r
+        ConsoleIn->SysReq = TRUE;\r
+      }\r
     case SCANCODE_CAPS_LOCK_MAKE:\r
       ConsoleIn->CapsLock = (BOOLEAN)!ConsoleIn->CapsLock;\r
       UpdateStatusLights (ConsoleIn);\r
@@ -1588,12 +1631,6 @@ Returns:
     }\r
   }\r
   //\r
-  // If this is the SysRq, ignore it\r
-  //\r
-  if (Extended && ScanCode == 0x37) {\r
-    return EFI_NOT_READY;\r
-  }\r
-  //\r
   // Treat Numeric Key Pad "/" specially\r
   //\r
   if (Extended && ScanCode == 0x35) {\r
@@ -1609,6 +1646,14 @@ Returns:
       ConsoleIn->Key.ScanCode = ConvertKeyboardScanCodeToEfiKey[Index].EfiScanCode;\r
       if (ConsoleIn->Shift) {\r
         ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar;\r
+        //\r
+        // Need not return associated shift state if a class of printable characters that\r
+        // are normally adjusted by shift modifiers. e.g. Shift Key + 'f' key = 'F'\r
+        //\r
+        if (ConsoleIn->Key.UnicodeChar >= 'A' && ConsoleIn->Key.UnicodeChar <= 'Z') {\r
+          ConsoleIn->LeftShift  = FALSE;\r
+          ConsoleIn->RightShift = FALSE;\r
+        }\r
       } else {\r
         ConsoleIn->Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar;\r
       }\r
@@ -1655,6 +1700,43 @@ Returns:
     return EFI_NOT_READY;\r
   }\r
 \r
+  //\r
+  // Save the Shift/Toggle state\r
+  //\r
+  if (ConsoleIn->Ctrl) {\r
+    ConsoleIn->KeyState.KeyShiftState  |= (Extended == TRUE) ? EFI_RIGHT_CONTROL_PRESSED : EFI_LEFT_CONTROL_PRESSED;\r
+  }                                    \r
+  if (ConsoleIn->Alt) {                \r
+    ConsoleIn->KeyState.KeyShiftState  |= (Extended == TRUE) ? EFI_RIGHT_ALT_PRESSED : EFI_LEFT_ALT_PRESSED;\r
+  }                                    \r
+  if (ConsoleIn->LeftShift) {          \r
+    ConsoleIn->KeyState.KeyShiftState  |= EFI_LEFT_SHIFT_PRESSED;\r
+  }                                    \r
+  if (ConsoleIn->RightShift) {         \r
+    ConsoleIn->KeyState.KeyShiftState  |= EFI_RIGHT_SHIFT_PRESSED;\r
+  }                                    \r
+  if (ConsoleIn->LeftLogo) {           \r
+    ConsoleIn->KeyState.KeyShiftState  |= EFI_LEFT_LOGO_PRESSED;\r
+  }                                    \r
+  if (ConsoleIn->RightLogo) {          \r
+    ConsoleIn->KeyState.KeyShiftState  |= EFI_RIGHT_LOGO_PRESSED;\r
+  }                                    \r
+  if (ConsoleIn->Menu) {               \r
+    ConsoleIn->KeyState.KeyShiftState  |= EFI_MENU_KEY_PRESSED;\r
+  }                                    \r
+  if (ConsoleIn->SysReq) {             \r
+    ConsoleIn->KeyState.KeyShiftState  |= EFI_SYS_REQ_PRESSED;\r
+  }  \r
+  if (ConsoleIn->CapsLock) {\r
+    ConsoleIn->KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;\r
+  }\r
+  if (ConsoleIn->NumLock) {\r
+    ConsoleIn->KeyState.KeyToggleState |= EFI_NUM_LOCK_ACTIVE;\r
+  }\r
+  if (ConsoleIn->ScrollLock) {\r
+    ConsoleIn->KeyState.KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1855,6 +1937,12 @@ Returns:
   ConsoleIn->CapsLock   = FALSE;\r
   ConsoleIn->NumLock    = FALSE;\r
   ConsoleIn->ScrollLock = FALSE;\r
+  ConsoleIn->LeftShift  = FALSE;\r
+  ConsoleIn->RightShift = FALSE;\r
+  ConsoleIn->LeftLogo   = FALSE;\r
+  ConsoleIn->RightLogo  = FALSE;\r
+  ConsoleIn->Menu       = FALSE;\r
+  ConsoleIn->SysReq     = FALSE;  \r
 \r
   //\r
   // For reseting keyboard is not mandatory before booting OS and sometimes keyboard responses very slow,\r
@@ -2040,8 +2128,8 @@ Returns:
 \r
   @param[in]  BiosKeyboardPrivate   Keyboard Private Data Structure\r
 \r
-  @retval              TRUE                                                            Keyboard in System.\r
-  @retval              FALSE                                                           Keyboard not in System.\r
+  @retval     TRUE                  Keyboard in System.\r
+  @retval     FALSE                 Keyboard not in System.\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
index ab4ced939d8ad7a55af754c5099a45d700a58a20..71cf8eed03bb8c27225d238a4c7a5b8a48efd935 100644 (file)
@@ -45,6 +45,122 @@ KeyboardCheckForKey (
   IN  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This\r
   );\r
 \r
+STATIC\r
+BOOLEAN\r
+IsKeyRegistered (\r
+  IN EFI_KEY_DATA  *RegsiteredData,\r
+  IN EFI_KEY_DATA  *InputData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+  RegsiteredData    - A pointer to a buffer that is filled in with the keystroke \r
+                      state data for the key that was registered.\r
+  InputData         - A pointer to a buffer that is filled in with the keystroke \r
+                      state data for the key that was pressed.\r
+\r
+Returns:\r
+  TRUE              - Key be pressed matches a registered key.\r
+  FLASE             - Match failed. \r
+  \r
+--*/\r
+;\r
+STATIC\r
+EFI_STATUS\r
+KeyboardReadKeyStrokeWorker (\r
+  IN  KEYBOARD_CONSOLE_IN_DEV           *ConsoleInDev,\r
+  OUT EFI_KEY_DATA                      *KeyData\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reads the next keystroke from the input device. The WaitForKey Event can \r
+    be used to test for existance of a keystroke via WaitForEvent () call.\r
+\r
+  Arguments:\r
+    ConsoleInDev          - Ps2 Keyboard private structure\r
+    KeyData               - A pointer to a buffer that is filled in with the keystroke \r
+                            state data for the key that was pressed.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The keystroke information was returned.\r
+    EFI_NOT_READY         - There was no keystroke data availiable.\r
+    EFI_DEVICE_ERROR      - The keystroke information was not returned due to \r
+                            hardware errors.\r
+    EFI_INVALID_PARAMETER - KeyData is NULL.                        \r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_TPL                               OldTpl;\r
+  LIST_ENTRY                            *Link;\r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY         *CurrentNotify;\r
+  EFI_KEY_DATA                          OriginalKeyData;\r
+  if (KeyData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  //\r
+  // Enter critical section\r
+  //\r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  if (ConsoleInDev->KeyboardErr) {\r
+    gBS->RestoreTPL (OldTpl);\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+  //\r
+  // If there's no key, just return\r
+  //\r
+  Status = KeyboardCheckForKey (&ConsoleInDev->ConIn);\r
+  if (EFI_ERROR (Status)) {\r
+    gBS->RestoreTPL (OldTpl);\r
+    return EFI_NOT_READY;\r
+  }\r
+  CopyMem (&KeyData->Key, &ConsoleInDev->Key, sizeof (EFI_INPUT_KEY));\r
+\r
+  ConsoleInDev->Key.ScanCode    = SCAN_NULL;          \r
+  ConsoleInDev->Key.UnicodeChar = 0x0000;     \r
+  CopyMem (&KeyData->KeyState, &ConsoleInDev->KeyState, sizeof (EFI_KEY_STATE));\r
+                                          \r
+  ConsoleInDev->KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;\r
+  ConsoleInDev->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;\r
+  gBS->RestoreTPL (OldTpl);\r
+  //\r
+  //Switch the control value to their original characters. In KeyGetchar() the  CTRL-Alpha characters have been switched to \r
+  // their corresponding control value (ctrl-a = 0x0001 through ctrl-Z = 0x001A), here switch them back for notification function.\r
+  //\r
+  CopyMem (&OriginalKeyData, KeyData, sizeof (EFI_KEY_DATA));\r
+  if (ConsoleInDev->Ctrled) {\r
+    if (OriginalKeyData.Key.UnicodeChar >= 0x01 && OriginalKeyData.Key.UnicodeChar <= 0x1A) {\r
+      if (ConsoleInDev->CapsLock) {\r
+        OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'A' - 1);\r
+      } else {\r
+        OriginalKeyData.Key.UnicodeChar = (CHAR16)(OriginalKeyData.Key.UnicodeChar + 'a' - 1);\r
+      } \r
+    }\r
+  }\r
+  //\r
+  // Invoke notification functions if exist\r
+  //\r
+  for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {\r
+    CurrentNotify = CR (\r
+                      Link, \r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
+                      NotifyEntry, \r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
+                      );\r
+    if (IsKeyRegistered (&CurrentNotify->KeyData, &OriginalKeyData)) { \r
+      CurrentNotify->KeyNotificationFn (&OriginalKeyData);\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 KeyboardEfiReset (\r
@@ -161,47 +277,17 @@ Returns:
 {\r
   EFI_STATUS              Status;\r
   KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;\r
-  EFI_TPL                 OldTpl;\r
+  EFI_KEY_DATA            KeyData;\r
 \r
   ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
-\r
-  //\r
-  // Enter critical section\r
-  //\r
-  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
-\r
-  if (ConsoleIn->KeyboardErr) {\r
-    //\r
-    // Leave critical section and return\r
-    //\r
-    gBS->RestoreTPL (OldTpl);\r
-\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  //\r
-  // If there's no key, just return\r
-  //\r
-  Status = KeyboardCheckForKey (This);\r
+  Status = KeyboardReadKeyStrokeWorker (ConsoleIn, &KeyData);\r
   if (EFI_ERROR (Status)) {\r
-    //\r
-    // Leave critical section and return\r
-    //\r
-    gBS->RestoreTPL (OldTpl);\r
-    return EFI_NOT_READY;\r
+    return Status;\r
   }\r
 \r
-  Key->ScanCode               = ConsoleIn->Key.ScanCode;\r
-  Key->UnicodeChar            = ConsoleIn->Key.UnicodeChar;\r
-\r
-  ConsoleIn->Key.ScanCode     = SCAN_NULL;\r
-  ConsoleIn->Key.UnicodeChar  = 0x0000;\r
-\r
-  //\r
-  // Leave critical section and return\r
-  //\r
-  gBS->RestoreTPL (OldTpl);\r
-\r
+  CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));\r
   return EFI_SUCCESS;\r
+  \r
 }\r
 \r
 VOID\r
@@ -290,3 +376,435 @@ Returns:
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
+STATIC\r
+BOOLEAN\r
+IsKeyRegistered (\r
+  IN EFI_KEY_DATA  *RegsiteredData,\r
+  IN EFI_KEY_DATA  *InputData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+  RegsiteredData    - A pointer to a buffer that is filled in with the keystroke \r
+                      state data for the key that was registered.\r
+  InputData         - A pointer to a buffer that is filled in with the keystroke \r
+                      state data for the key that was pressed.\r
+\r
+Returns:\r
+  TRUE              - Key be pressed matches a registered key.\r
+  FLASE             - Match failed. \r
+  \r
+--*/\r
+{\r
+  ASSERT (RegsiteredData != NULL && InputData != NULL);\r
+  \r
+  if ((RegsiteredData->Key.ScanCode    != InputData->Key.ScanCode) ||\r
+      (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r
+    return FALSE;  \r
+  }      \r
+  \r
+  //\r
+  // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r
+  //\r
+  if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r
+      RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r
+    return FALSE;    \r
+  }   \r
+  if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r
+      RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r
+    return FALSE;    \r
+  }     \r
+  \r
+  return TRUE;\r
+\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+KeyboardWaitForKeyEx (\r
+  IN  EFI_EVENT               Event,\r
+  IN  VOID                    *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
+  Signal the event if there is key available\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
+\r
+  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (Context); \r
+  KeyboardWaitForKey (Event, &ConsoleInDev->ConIn);\r
+  \r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardEfiResetEx (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN BOOLEAN                            ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the input device and optionaly run diagnostics\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+                            not be reset.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                            Status;\r
+  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
+  EFI_TPL                               OldTpl;\r
+\r
+  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This); \r
+  if (ConsoleInDev->KeyboardErr) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  Status = ConsoleInDev->ConIn.Reset (\r
+                                 &ConsoleInDev->ConIn, \r
+                                 ExtendedVerification\r
+                                 );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  ConsoleInDev->KeyState.KeyShiftState  = EFI_SHIFT_STATE_VALID;\r
+  ConsoleInDev->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;\r
+\r
+  gBS->RestoreTPL (OldTpl);  \r
+  \r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardReadKeyStrokeEx (\r
+  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
+  OUT EFI_KEY_DATA                      *KeyData\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reads the next keystroke from the input device. The WaitForKey Event can \r
+    be used to test for existance of a keystroke via WaitForEvent () call.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    KeyData    - A pointer to a buffer that is filled in with the keystroke \r
+                 state data for the key that was pressed.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The keystroke information was returned.\r
+    EFI_NOT_READY         - There was no keystroke data availiable.\r
+    EFI_DEVICE_ERROR      - The keystroke information was not returned due to \r
+                            hardware errors.\r
+    EFI_INVALID_PARAMETER - KeyData is NULL.                        \r
+\r
+--*/\r
+{\r
+  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
+\r
+  if (KeyData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
+  return KeyboardReadKeyStrokeWorker (ConsoleInDev, KeyData);\r
+  \r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardSetState (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set certain state for the input device.\r
+\r
+  Arguments:\r
+    This              - Protocol instance pointer.\r
+    KeyToggleState    - A pointer to the EFI_KEY_TOGGLE_STATE to set the \r
+                        state for the input device.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device state was set successfully.\r
+    EFI_DEVICE_ERROR      - The device is not functioning correctly and could \r
+                            not have the setting adjusted.\r
+    EFI_UNSUPPORTED       - The device does not have the ability to set its state.\r
+    EFI_INVALID_PARAMETER - KeyToggleState is NULL.                       \r
+\r
+--*/   \r
+{\r
+  EFI_STATUS                            Status;\r
+  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
+  EFI_TPL                               OldTpl;\r
+\r
+  if (KeyToggleState == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
+\r
+  //\r
+  // Enter critical section\r
+  //\r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  if (ConsoleInDev->KeyboardErr) {\r
+    Status = EFI_DEVICE_ERROR;\r
+    goto Exit;\r
+  }\r
+\r
+  if (((ConsoleInDev->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) ||\r
+      ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID)) {\r
+    Status = EFI_UNSUPPORTED;\r
+    goto Exit;\r
+  }\r
+  \r
+  //\r
+  // Update the status light\r
+  //\r
+  ConsoleInDev->ScrollLock = FALSE;\r
+  ConsoleInDev->NumLock    = FALSE;\r
+  ConsoleInDev->CapsLock   = FALSE;\r
+\r
+  if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {\r
+    ConsoleInDev->ScrollLock = TRUE;\r
+  } \r
+  if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {\r
+    ConsoleInDev->NumLock = TRUE;\r
+  }\r
+  if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {\r
+    ConsoleInDev->CapsLock = TRUE;\r
+  }\r
+\r
+  Status = UpdateStatusLights (ConsoleInDev);\r
+  if (EFI_ERROR (Status)) {\r
+    Status = EFI_DEVICE_ERROR;    \r
+  }\r
+\r
+  ConsoleInDev->KeyState.KeyToggleState = *KeyToggleState;\r
+  \r
+Exit:   \r
+  //\r
+  // Leave critical section and return\r
+  //\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
+  return Status;\r
+\r
+}\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardRegisterKeyNotify (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_KEY_DATA                       *KeyData,\r
+  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,\r
+  OUT EFI_HANDLE                        *NotifyHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a notification function for a particular keystroke for the input device.\r
+\r
+  Arguments:\r
+    This                    - Protocol instance pointer.\r
+    KeyData                 - A pointer to a buffer that is filled in with the keystroke \r
+                              information data for the key that was pressed.\r
+    KeyNotificationFunction - Points to the function to be called when the key \r
+                              sequence is typed specified by KeyData.                        \r
+    NotifyHandle            - Points to the unique handle assigned to the registered notification.                          \r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The notification function was registered successfully.\r
+    EFI_OUT_OF_RESOURCES    - Unable to allocate resources for necesssary data structures.\r
+    EFI_INVALID_PARAMETER   - KeyData or NotifyHandle is NULL.                       \r
+                              \r
+--*/   \r
+{\r
+  EFI_STATUS                            Status;\r
+  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
+  EFI_TPL                               OldTpl;\r
+  LIST_ENTRY                            *Link;\r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY         *CurrentNotify;  \r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY         *NewNotify;\r
+\r
+  if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
+\r
+  //\r
+  // Enter critical section\r
+  //\r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+  //\r
+  // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r
+  //\r
+  for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {\r
+    CurrentNotify = CR (\r
+                      Link, \r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
+                      NotifyEntry, \r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
+                      );\r
+    if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) { \r
+      if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {\r
+        *NotifyHandle = CurrentNotify->NotifyHandle;        \r
+        Status = EFI_SUCCESS;\r
+        goto Exit;\r
+      }\r
+    }\r
+  }    \r
+  \r
+  //\r
+  // Allocate resource to save the notification function\r
+  //  \r
+  NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));\r
+  if (NewNotify == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Exit;\r
+  }\r
+\r
+  NewNotify->Signature         = KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE;     \r
+  NewNotify->KeyNotificationFn = KeyNotificationFunction;\r
+  CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));\r
+  InsertTailList (&ConsoleInDev->NotifyList, &NewNotify->NotifyEntry);\r
+\r
+  //\r
+  // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE\r
+  //  \r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &NewNotify->NotifyHandle,\r
+                  &gSimpleTextInExNotifyGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  *NotifyHandle                = NewNotify->NotifyHandle;  \r
+  Status                       = EFI_SUCCESS;\r
+\r
+Exit:\r
+  //\r
+  // Leave critical section and return\r
+  //\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;  \r
+\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardUnregisterKeyNotify (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_HANDLE                         NotificationHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Remove a registered notification function from a particular keystroke.\r
+\r
+  Arguments:\r
+    This                    - Protocol instance pointer.    \r
+    NotificationHandle      - The handle of the notification function being unregistered.\r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The notification function was unregistered successfully.\r
+    EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.\r
+    EFI_NOT_FOUND           - Can not find the matching entry in database.  \r
+                              \r
+--*/   \r
+{\r
+  EFI_STATUS                            Status;\r
+  KEYBOARD_CONSOLE_IN_DEV               *ConsoleInDev;\r
+  EFI_TPL                               OldTpl;\r
+  LIST_ENTRY                            *Link;\r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY         *CurrentNotify;    \r
+\r
+  if (NotificationHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  } \r
+  \r
+  Status = gBS->OpenProtocol (\r
+                  NotificationHandle,\r
+                  &gSimpleTextInExNotifyGuid,\r
+                  NULL,\r
+                  NULL,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);\r
+  \r
+  //\r
+  // Enter critical section\r
+  //\r
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);  \r
+\r
+  for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {\r
+    CurrentNotify = CR (\r
+                      Link, \r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
+                      NotifyEntry, \r
+                      KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
+                      );       \r
+    if (CurrentNotify->NotifyHandle == NotificationHandle) {\r
+      //\r
+      // Remove the notification function from NotifyList and free resources\r
+      //\r
+      RemoveEntryList (&CurrentNotify->NotifyEntry);      \r
+      Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                      CurrentNotify->NotifyHandle,\r
+                      &gSimpleTextInExNotifyGuid,\r
+                      NULL,\r
+                      NULL\r
+                      );\r
+      ASSERT_EFI_ERROR (Status);\r
+      gBS->FreePool (CurrentNotify);            \r
+      Status = EFI_SUCCESS;\r
+      goto Exit;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Can not find the specified Notification Handle\r
+  //\r
+  Status = EFI_NOT_FOUND;\r
+Exit:\r
+  //\r
+  // Leave critical section and return\r
+  //\r
+  gBS->RestoreTPL (OldTpl);\r
+  return Status;\r
+}\r
+\r
index 4e39fa06d628d90de2e7885f6f8754abe2bb2cd0..359d031ad239a996b3f07c02cbf403ed966e9d19 100644 (file)
@@ -44,9 +44,12 @@ KbdControllerDriverStop (
   IN  EFI_HANDLE                     *ChildHandleBuffer\r
   );\r
 \r
-//\r
-// Global variables\r
-//\r
+STATIC\r
+EFI_STATUS\r
+KbdFreeNotifyList (\r
+  IN OUT LIST_ENTRY           *ListHead\r
+  );  \r
+\r
 //\r
 // DriverBinding Protocol Instance\r
 //\r
@@ -215,6 +218,13 @@ Returns:
   ConsoleIn->Alted                  = FALSE;\r
   ConsoleIn->DevicePath             = ParentDevicePath;\r
 \r
+  ConsoleIn->ConInEx.Reset               = KeyboardEfiResetEx;\r
+  ConsoleIn->ConInEx.ReadKeyStrokeEx     = KeyboardReadKeyStrokeEx;\r
+  ConsoleIn->ConInEx.SetState            = KeyboardSetState;\r
+  ConsoleIn->ConInEx.RegisterKeyNotify   = KeyboardRegisterKeyNotify;\r
+  ConsoleIn->ConInEx.UnregisterKeyNotify = KeyboardUnregisterKeyNotify;  \r
+  \r
+  InitializeListHead (&ConsoleIn->NotifyList);\r
   //\r
   // Setup the WaitForKey event\r
   //\r
@@ -231,6 +241,20 @@ Returns:
     goto ErrorExit;\r
   }\r
   //\r
+  // Setup the WaitForKeyEx event\r
+  //  \r
+  Status = gBS->CreateEvent (\r
+                  EVT_NOTIFY_WAIT,\r
+                  TPL_NOTIFY,\r
+                  KeyboardWaitForKeyEx,\r
+                  &(ConsoleIn->ConInEx),\r
+                  &(ConsoleIn->ConInEx.WaitForKeyEx)\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    Status      = EFI_OUT_OF_RESOURCES;\r
+    StatusCode  = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;\r
+    goto ErrorExit;\r
+  }\r
   // Setup a periodic timer, used for reading keystrokes at a fixed interval\r
   //\r
   Status = gBS->CreateEvent (\r
@@ -297,6 +321,8 @@ Returns:
                   &Controller,\r
                   &gEfiSimpleTextInProtocolGuid,\r
                   &ConsoleIn->ConIn,\r
+                  &gEfiSimpleTextInputExProtocolGuid,\r
+                  &ConsoleIn->ConInEx,\r
                   NULL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
@@ -325,7 +351,10 @@ ErrorExit:
   if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {\r
     gBS->CloseEvent (ConsoleIn->TimerEvent);\r
   }\r
-\r
+  if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {\r
+    gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
+  }\r
+  KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
   if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {\r
     FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
   }\r
@@ -401,7 +430,18 @@ KbdControllerDriverStop (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-\r
+  Status = gBS->OpenProtocol (\r
+                  Controller,\r
+                  &gEfiSimpleTextInputExProtocolGuid,\r
+                  NULL,\r
+                  This->DriverBindingHandle,\r
+                  Controller,\r
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  \r
   ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);\r
 \r
   //\r
@@ -431,12 +471,15 @@ KbdControllerDriverStop (
     Status = KeyboardRead (ConsoleIn, &Data);;\r
   }\r
   //\r
-  // Uninstall the Simple TextIn Protocol\r
+  // Uninstall the SimpleTextIn and SimpleTextInEx protocols\r
   //\r
-  Status = gBS->UninstallProtocolInterface (\r
+  Status = gBS->UninstallMultipleProtocolInterfaces (\r
                   Controller,\r
                   &gEfiSimpleTextInProtocolGuid,\r
-                  &ConsoleIn->ConIn\r
+                  &ConsoleIn->ConIn,\r
+                  &gEfiSimpleTextInputExProtocolGuid,\r
+                  &ConsoleIn->ConInEx,\r
+                  NULL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -463,13 +506,55 @@ KbdControllerDriverStop (
     gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);\r
     (ConsoleIn->ConIn).WaitForKey = NULL;\r
   }\r
-\r
+  if (ConsoleIn->ConInEx.WaitForKeyEx != NULL) {\r
+    gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);\r
+    ConsoleIn->ConInEx.WaitForKeyEx = NULL;\r
+  }\r
+  KbdFreeNotifyList (&ConsoleIn->NotifyList);\r
   FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);\r
   gBS->FreePool (ConsoleIn);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
+STATIC\r
+EFI_STATUS\r
+KbdFreeNotifyList (\r
+  IN OUT LIST_ENTRY           *ListHead\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+Arguments:\r
+\r
+  ListHead   - The list head\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - Free the notify list successfully\r
+  EFI_INVALID_PARAMETER - ListHead is invalid.\r
+\r
+--*/\r
+{\r
+  KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;\r
+\r
+  if (ListHead == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  while (!IsListEmpty (ListHead)) {\r
+    NotifyNode = CR (\r
+                   ListHead->ForwardLink, \r
+                   KEYBOARD_CONSOLE_IN_EX_NOTIFY, \r
+                   NotifyEntry, \r
+                   KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE\r
+                   );\r
+    RemoveEntryList (ListHead->ForwardLink);\r
+    gBS->FreePool (NotifyNode);\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
+}\r
 \r
 /**\r
   The user Entry Point for module Ps2Keyboard. The user code starts with this function.\r
index 4f1080fe1b11fa1845055c4c9fb1a4862cff6f21..1eb2c5491c6d0edadffef05a0fa769a3a4575411 100644 (file)
@@ -1,5 +1,5 @@
 /**@file\r
-       PS/2 keyboard driver header file\r
+  PS/2 keyboard driver header file\r
 \r
 Copyright (c) 2006 - 2007, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Framework/StatusCode.h>\r
 \r
 #include <Protocol/SimpleTextIn.h>\r
+#include <Protocol/SimpleTextInEx.h>\r
 #include <Protocol/IsaIo.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/Ps2Policy.h>\r
@@ -30,18 +31,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 \r
 //\r
 // Driver Private Data\r
 //\r
 #define KEYBOARD_BUFFER_MAX_COUNT         32\r
 #define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE EFI_SIGNATURE_32 ('k', 'k', 'e', 'y')\r
+#define KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('k', 'c', 'e', 'n')\r
+\r
+typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {\r
+  UINTN                                 Signature;\r
+  EFI_HANDLE                            NotifyHandle;\r
+  EFI_KEY_DATA                          KeyData;\r
+  EFI_KEY_NOTIFY_FUNCTION               KeyNotificationFn;\r
+  LIST_ENTRY                            NotifyEntry;\r
+} KEYBOARD_CONSOLE_IN_EX_NOTIFY;\r
+\r
 \r
 typedef struct {\r
   UINTN                               Signature;\r
 \r
   EFI_HANDLE                          Handle;\r
   EFI_SIMPLE_TEXT_INPUT_PROTOCOL      ConIn;\r
+  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL   ConInEx;\r
   EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
 \r
   EFI_EVENT                           TimerEvent;\r
@@ -51,6 +65,14 @@ typedef struct {
   UINT32                              CommandRegisterAddress;\r
 \r
   EFI_INPUT_KEY                       Key;\r
+  EFI_KEY_STATE                       KeyState;\r
+\r
+  BOOLEAN                             LeftShift;\r
+  BOOLEAN                             RightShift;  \r
+  BOOLEAN                             LeftLogo;\r
+  BOOLEAN                             RightLogo;\r
+  BOOLEAN                             Menu;\r
+  BOOLEAN                             SysReq;\r
 \r
   BOOLEAN                             Ctrl;\r
   BOOLEAN                             Alt;\r
@@ -81,9 +103,19 @@ typedef struct {
   EFI_UNICODE_STRING_TABLE            *ControllerNameTable;\r
 \r
   EFI_DEVICE_PATH_PROTOCOL            *DevicePath;\r
+  //\r
+  // Notification Function List\r
+  //\r
+  LIST_ENTRY                          NotifyList;\r
 } KEYBOARD_CONSOLE_IN_DEV;\r
 \r
 #define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a)  CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)\r
+#define TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) \\r
+  CR (a, \\r
+      KEYBOARD_CONSOLE_IN_DEV, \\r
+      ConInEx, \\r
+      KEYBOARD_CONSOLE_IN_DEV_SIGNATURE \\r
+      )\r
 \r
 #define TABLE_END 0x0\r
 \r
@@ -94,10 +126,13 @@ extern EFI_DRIVER_BINDING_PROTOCOL   gKeyboardControllerDriver;
 extern EFI_COMPONENT_NAME_PROTOCOL   gPs2KeyboardComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL  gPs2KeyboardComponentName2;\r
 \r
+extern EFI_GUID                      gSimpleTextInExNotifyGuid;\r
+\r
 //\r
 // Driver entry point\r
 //\r
 EFI_STATUS\r
+EFIAPI\r
 InstallPs2KeyboardDriver (\r
   IN EFI_HANDLE           ImageHandle,\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
@@ -144,11 +179,42 @@ Returns:
 #define SCANCODE_CAPS_LOCK_MAKE         0x3A\r
 #define SCANCODE_NUM_LOCK_MAKE          0x45\r
 #define SCANCODE_SCROLL_LOCK_MAKE       0x46\r
-#define SCANCODE_MAX_MAKE               0x59\r
+#define SCANCODE_LEFT_LOGO_MAKE         0x5B //GUI key defined in Keyboard scan code\r
+#define SCANCODE_LEFT_LOGO_BREAK        0xDB\r
+#define SCANCODE_RIGHT_LOGO_MAKE        0x5C\r
+#define SCANCODE_RIGHT_LOGO_BREAK       0xDC\r
+#define SCANCODE_MENU_MAKE              0x5D //APPS key defined in Keyboard scan code \r
+#define SCANCODE_MENU_BREAK             0xDD\r
+#define SCANCODE_SYS_REQ_MAKE           0x37\r
+#define SCANCODE_MAX_MAKE               0x60\r
 \r
 //\r
 // Other functions that are used among .c files\r
 //\r
+\r
+EFI_STATUS\r
+UpdateStatusLights (\r
+  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Show keyboard status light for ScrollLock, NumLock and CapsLock\r
+  according to indicators in ConsoleIn.\r
+\r
+Arguments:\r
+\r
+  ConsoleIn   - driver private structure\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - Show the status light successfully.\r
+  EFI_TIMEOUT - Timeout when operating read/write on registers.\r
+\r
+--*/  \r
+;\r
+\r
 EFI_STATUS\r
 KeyboardRead (\r
   IN KEYBOARD_CONSOLE_IN_DEV  *ConsoleIn,\r
@@ -361,8 +427,8 @@ Returns:
 \r
   @param[in]  BiosKeyboardPrivate   Keyboard Private Data Structure\r
 \r
-  @retval              TRUE                                                            Keyboard in System.\r
-  @retval              FALSE                                                           Keyboard not in System.\r
+  @retval     TRUE                  Keyboard in System.\r
+  @retval     FALSE                 Keyboard not in System.\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
@@ -370,4 +436,157 @@ CheckKeyboardConnect (
   IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn\r
   )\r
 ;\r
+\r
+VOID\r
+EFIAPI\r
+KeyboardWaitForKeyEx (\r
+  IN  EFI_EVENT               Event,\r
+  IN  VOID                    *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event\r
+  Signal the event if there is key available\r
+\r
+Arguments:\r
+\r
+Returns:\r
+\r
+--*/    \r
+;  \r
+\r
+//\r
+// Simple Text Input Ex protocol function prototypes\r
+//\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardEfiResetEx (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN BOOLEAN                            ExtendedVerification\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reset the input device and optionaly run diagnostics\r
+\r
+  Arguments:\r
+    This                 - Protocol instance pointer.\r
+    ExtendedVerification - Driver may perform diagnostics on reset.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The device was reset.\r
+    EFI_DEVICE_ERROR      - The device is not functioning properly and could \r
+                            not be reset.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardReadKeyStrokeEx (\r
+  IN  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r
+  OUT EFI_KEY_DATA                      *KeyData\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Reads the next keystroke from the input device. The WaitForKey Event can \r
+    be used to test for existance of a keystroke via WaitForEvent () call.\r
+\r
+  Arguments:\r
+    This       - Protocol instance pointer.\r
+    KeyData    - A pointer to a buffer that is filled in with the keystroke \r
+                 state data for the key that was pressed.\r
+\r
+  Returns:\r
+    EFI_SUCCESS           - The keystroke information was returned.\r
+    EFI_NOT_READY         - There was no keystroke data availiable.\r
+    EFI_DEVICE_ERROR      - The keystroke information was not returned due to \r
+                            hardware errors.\r
+    EFI_INVALID_PARAMETER - KeyData is NULL.                        \r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardSetState (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_KEY_TOGGLE_STATE               *KeyToggleState\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Set certain state for the input device.\r
+\r
+  Arguments:\r
+    This                  - Protocol instance pointer.\r
+    KeyToggleState        - A pointer to the EFI_KEY_TOGGLE_STATE to set the \r
+                            state for the input device.\r
+                          \r
+  Returns:                \r
+    EFI_SUCCESS           - The device state was set successfully.\r
+    EFI_DEVICE_ERROR      - The device is not functioning correctly and could \r
+                            not have the setting adjusted.\r
+    EFI_UNSUPPORTED       - The device does not have the ability to set its state.\r
+    EFI_INVALID_PARAMETER - KeyToggleState is NULL.                       \r
+\r
+--*/   \r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardRegisterKeyNotify (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_KEY_DATA                       *KeyData,\r
+  IN EFI_KEY_NOTIFY_FUNCTION            KeyNotificationFunction,\r
+  OUT EFI_HANDLE                        *NotifyHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Register a notification function for a particular keystroke for the input device.\r
+\r
+  Arguments:\r
+    This                    - Protocol instance pointer.\r
+    KeyData                 - A pointer to a buffer that is filled in with the keystroke \r
+                              information data for the key that was pressed.\r
+    KeyNotificationFunction - Points to the function to be called when the key \r
+                              sequence is typed specified by KeyData.                        \r
+    NotifyHandle            - Points to the unique handle assigned to the registered notification.                          \r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The notification function was registered successfully.\r
+    EFI_OUT_OF_RESOURCES    - Unable to allocate resources for necesssary data structures.\r
+    EFI_INVALID_PARAMETER   - KeyData or NotifyHandle is NULL.                       \r
+                              \r
+--*/   \r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+KeyboardUnregisterKeyNotify (\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL  *This,\r
+  IN EFI_HANDLE                         NotificationHandle\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    Remove a registered notification function from a particular keystroke.\r
+\r
+  Arguments:\r
+    This                    - Protocol instance pointer.    \r
+    NotificationHandle      - The handle of the notification function being unregistered.\r
+\r
+  Returns:\r
+    EFI_SUCCESS             - The notification function was unregistered successfully.\r
+    EFI_INVALID_PARAMETER   - The NotificationHandle is invalid.\r
+    EFI_NOT_FOUND           - Can not find the matching entry in database.  \r
+                              \r
+--*/   \r
+;\r
+\r
 #endif\r
index 6a8890613f874e2bedb5a8a76aadd3ba391efe89..4aa2dae009557260c8cd0e2fec7a2f5f658eac8c 100644 (file)
   UefiBootServicesTableLib\r
   UefiLib\r
   UefiDriverEntryPoint\r
+  BaseLib\r
+  BaseMemoryLib\r
 \r
 [Protocols]\r
   gEfiPs2PolicyProtocolGuid                     # PROTOCOL TO_START\r
   gEfiIsaIoProtocolGuid                         # PROTOCOL TO_START\r
   gEfiSimpleTextInProtocolGuid                  # PROTOCOL BY_START\r
+  gEfiSimpleTextInputExProtocolGuid             # PROTOCOL BY_START\r
   gEfiDevicePathProtocolGuid                    # PROTOCOL TO_START\r
 \r
+[Guids]\r
+  gSimpleTextInExNotifyGuid                     # SOMETIMES_CONSUMED\r
+\r