]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / Hotkey.c
index 1a3ec1ff844039f000213a09082225a4a68cf6f6..8e33062a546b9837dfda31ae3e08eddd60e1906b 100644 (file)
@@ -2,7 +2,7 @@
   Provides a way for 3rd party applications to register themselves for launch by the\r
   Boot Manager based on hot key\r
 \r
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -73,15 +73,15 @@ EFI_STATUS
 HotkeyBoot (\r
   VOID\r
   )\r
-{ \r
+{\r
   EFI_STATUS           Status;\r
   UINTN                ExitDataSize;\r
   CHAR16               *ExitData;\r
 \r
   if (mHotkeyBootOption == NULL) {\r
     return EFI_NOT_FOUND;\r
-  } \r
-  \r
+  }\r
+\r
   BdsLibConnectDevicePath (mHotkeyBootOption->DevicePath);\r
 \r
   //\r
@@ -162,7 +162,7 @@ HotkeyCallback (
     HotkeyData = &Hotkey->KeyData[Hotkey->WaitingKey];\r
     if ((KeyData->Key.ScanCode == HotkeyData->Key.ScanCode) &&\r
         (KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) &&\r
-        (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ? \r
+        (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ?\r
           (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE\r
         )\r
        ) {\r
@@ -315,6 +315,7 @@ HotkeyInsertList (
   BDS_HOTKEY_OPTION  *HotkeyLeft;\r
   BDS_HOTKEY_OPTION  *HotkeyRight;\r
   UINTN              Index;\r
+  EFI_BOOT_KEY_DATA  KeyOptions;\r
   UINT32             KeyShiftStateLeft;\r
   UINT32             KeyShiftStateRight;\r
   EFI_INPUT_KEY      *InputKey;\r
@@ -327,28 +328,31 @@ HotkeyInsertList (
 \r
   HotkeyLeft->Signature = BDS_HOTKEY_OPTION_SIGNATURE;\r
   HotkeyLeft->BootOptionNumber = KeyOption->BootOption;\r
-  HotkeyLeft->CodeCount = (UINT8) KEY_OPTION_INPUT_KEY_COUNT (KeyOption);\r
+\r
+  KeyOptions = KeyOption->KeyData;\r
+\r
+  HotkeyLeft->CodeCount = (UINT8) KeyOptions.Options.InputKeyCount;\r
 \r
   //\r
   // Map key shift state from KeyOptions to EFI_KEY_DATA.KeyState\r
   //\r
   KeyShiftStateRight = EFI_SHIFT_STATE_VALID;\r
-  if (KEY_OPTION_SHIFT_PRESSED (KeyOption)) {\r
+  if (KeyOptions.Options.ShiftPressed) {\r
     KeyShiftStateRight |= EFI_RIGHT_SHIFT_PRESSED;\r
   }\r
-  if (KEY_OPTION_CONTROL_PRESSED (KeyOption)) {\r
+  if (KeyOptions.Options.ControlPressed) {\r
     KeyShiftStateRight |= EFI_RIGHT_CONTROL_PRESSED;\r
   }\r
-  if (KEY_OPTION_ALT_PRESSED (KeyOption)) {\r
+  if (KeyOptions.Options.AltPressed) {\r
     KeyShiftStateRight |= EFI_RIGHT_ALT_PRESSED;\r
   }\r
-  if (KEY_OPTION_LOGO_PRESSED (KeyOption)) {\r
+  if (KeyOptions.Options.LogoPressed) {\r
     KeyShiftStateRight |= EFI_RIGHT_LOGO_PRESSED;\r
   }\r
-  if (KEY_OPTION_MENU_PRESSED (KeyOption)) {\r
+  if (KeyOptions.Options.MenuPressed) {\r
     KeyShiftStateRight |= EFI_MENU_KEY_PRESSED;\r
   }\r
-  if (KEY_OPTION_SYS_REQ_PRESSED (KeyOption)) {\r
+  if (KeyOptions.Options.SysReqPressed) {\r
     KeyShiftStateRight |= EFI_SYS_REQ_PRESSED;\r
   }\r
 \r
@@ -417,7 +421,7 @@ IsKeyOptionVariable (
   )\r
 {\r
   UINTN         Index;\r
-  \r
+\r
   if (!CompareGuid (Guid, &gEfiGlobalVariableGuid) ||\r
       (StrSize (Name) != sizeof (L"Key####")) ||\r
       (StrnCmp (Name, L"Key", 3) != 0)\r
@@ -428,9 +432,9 @@ IsKeyOptionVariable (
   *OptionNumber = 0;\r
   for (Index = 3; Index < 7; Index++) {\r
     if ((Name[Index] >= L'0') && (Name[Index] <= L'9')) {\r
-      *OptionNumber = *OptionNumber * 10 + Name[Index] - L'0';\r
+      *OptionNumber = *OptionNumber * 16 + Name[Index] - L'0';\r
     } else if ((Name[Index] >= L'A') && (Name[Index] <= L'F')) {\r
-      *OptionNumber = *OptionNumber * 10 + Name[Index] - L'A';\r
+      *OptionNumber = *OptionNumber * 16 + Name[Index] - L'A' + 10;\r
     } else {\r
       return FALSE;\r
     }\r
@@ -546,6 +550,9 @@ InitializeHotkeyService (
                   sizeof (UINT32),\r
                   &BootOptionSupport\r
                   );\r
+  //\r
+  // Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.\r
+  //\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   KeyOptionNumbers = HotkeyGetOptionNumbers (&KeyOptionCount);\r