]> git.proxmox.com Git - mirror_edk2.git/commitdiff
The hotkey callback in BDS module should defer loading the boot option until the...
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Apr 2011 08:51:18 +0000 (08:51 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Apr 2011 08:51:18 +0000 (08:51 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11573 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.c
IntelFrameworkModulePkg/Universal/BdsDxe/Hotkey.h

index be3409457a827a00ee3f7dcee139f6efebaf71c4..05aed2b5a256034b35c7c12ea6f0d0328b7f09e6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   FrontPage routines to handle the callbacks and browser calls\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Bds.h"\r
 #include "FrontPage.h"\r
 #include "Language.h"\r
+#include "Hotkey.h"\r
 \r
 EFI_GUID  mFrontPageGuid      = FRONT_PAGE_FORMSET_GUID;\r
 \r
@@ -971,8 +972,10 @@ PlatformBdsEnterFrontPage (
     gConnectAllHappened = TRUE;\r
   }\r
 \r
+  HotkeyBoot ();\r
   if (TimeoutDefault != 0xffff) {\r
     Status = ShowProgress (TimeoutDefault);\r
+    HotkeyBoot ();\r
 \r
     //\r
     // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
index da0a2eef5aa9ff6842acc457c473dacdfc9cb2be..d0d9bb077bfb2b6e14d999abb35ca86a7576388a 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 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2011, 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
@@ -16,10 +16,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Hotkey.h"\r
 \r
 \r
-LIST_ENTRY      mHotkeyList = INITIALIZE_LIST_HEAD_VARIABLE (mHotkeyList);\r
-BOOLEAN         mHotkeyCallbackPending = FALSE;\r
-EFI_EVENT       mHotkeyEvent;\r
-VOID            *mHotkeyRegistration;\r
+LIST_ENTRY        mHotkeyList = INITIALIZE_LIST_HEAD_VARIABLE (mHotkeyList);\r
+BDS_COMMON_OPTION *mHotkeyBootOption = NULL;\r
+EFI_EVENT         mHotkeyEvent;\r
+VOID              *mHotkeyRegistration;\r
 \r
 \r
 /**\r
@@ -300,6 +300,50 @@ UnregisterHotkey (
   return Status;\r
 }\r
 \r
+/**\r
+  Try to boot the boot option triggered by hotkey.\r
+**/\r
+VOID\r
+HotkeyBoot (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS           Status;\r
+  UINTN                ExitDataSize;\r
+  CHAR16               *ExitData;\r
+  \r
+  if (mHotkeyBootOption != NULL) {\r
+    BdsLibConnectDevicePath (mHotkeyBootOption->DevicePath);\r
+\r
+    //\r
+    // Clear the screen before launch this BootOption\r
+    //\r
+    gST->ConOut->Reset (gST->ConOut, FALSE);\r
+\r
+    Status = BdsLibBootViaBootOption (mHotkeyBootOption, mHotkeyBootOption->DevicePath, &ExitDataSize, &ExitData);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Call platform action to indicate the boot fail\r
+      //\r
+      mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
+      PlatformBdsBootFail (mHotkeyBootOption, Status, ExitData, ExitDataSize);\r
+    } else {\r
+      //\r
+      // Call platform action to indicate the boot success\r
+      //\r
+      mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
+      PlatformBdsBootSuccess (mHotkeyBootOption);\r
+    }\r
+    FreePool (mHotkeyBootOption->Description);\r
+    FreePool (mHotkeyBootOption->DevicePath);\r
+    FreePool (mHotkeyBootOption->LoadOptions);\r
+    FreePool (mHotkeyBootOption);\r
+\r
+    mHotkeyBootOption = NULL;\r
+  }\r
+}\r
+\r
 /**\r
 \r
   This is the common notification function for HotKeys, it will be registered\r
@@ -322,24 +366,22 @@ HotkeyCallback (
   LIST_ENTRY         *Link;\r
   BDS_HOTKEY_OPTION  *Hotkey;\r
   UINT16             Buffer[10];\r
-  BDS_COMMON_OPTION  *BootOption;\r
-  UINTN              ExitDataSize;\r
-  CHAR16             *ExitData;\r
   EFI_STATUS         Status;\r
   EFI_KEY_DATA       *HotkeyData;\r
 \r
-  if (mHotkeyCallbackPending) {\r
+  if (mHotkeyBootOption != NULL) {\r
     //\r
-    // When responsing to a Hotkey, ignore sequential hotkey stroke until\r
-    // the current Boot#### load option returned\r
+    // Do not process sequential hotkey stroke until the current boot option returns\r
     //\r
     return EFI_SUCCESS;\r
   }\r
 \r
-  Status = EFI_SUCCESS;\r
-  Link = GetFirstNode (&mHotkeyList);\r
+  Status                 = EFI_SUCCESS;\r
 \r
-  while (!IsNull (&mHotkeyList, Link)) {\r
+  for ( Link = GetFirstNode (&mHotkeyList)\r
+      ; !IsNull (&mHotkeyList, Link)\r
+      ; Link = GetNextNode (&mHotkeyList, Link)\r
+      ) {\r
     HotkeyCatched = FALSE;\r
     Hotkey = BDS_HOTKEY_OPTION_FROM_LINK (Link);\r
 \r
@@ -349,26 +391,19 @@ HotkeyCallback (
     ASSERT (Hotkey->WaitingKey < (sizeof (Hotkey->KeyData) / sizeof (Hotkey->KeyData[0])));\r
     HotkeyData = &Hotkey->KeyData[Hotkey->WaitingKey];\r
     if ((KeyData->Key.ScanCode == HotkeyData->Key.ScanCode) &&\r
-       (KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) &&\r
-       (((HotkeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ? (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE)) {\r
+        (KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) &&\r
+        (((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ? \r
+          (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE\r
+        )\r
+       ) {\r
       //\r
-      // Receive an expecting key stroke\r
+      // For hotkey of key combination, transit to next waiting state\r
       //\r
-      if (Hotkey->CodeCount > 1) {\r
-        //\r
-        // For hotkey of key combination, transit to next waiting state\r
-        //\r
-        Hotkey->WaitingKey++;\r
+      Hotkey->WaitingKey++;\r
 \r
-        if (Hotkey->WaitingKey == Hotkey->CodeCount) {\r
-          //\r
-          // Received the whole key stroke sequence\r
-          //\r
-          HotkeyCatched = TRUE;\r
-        }\r
-      } else {\r
+      if (Hotkey->WaitingKey == Hotkey->CodeCount) {\r
         //\r
-        // For hotkey of single key stroke\r
+        // Received the whole key stroke sequence\r
         //\r
         HotkeyCatched = TRUE;\r
       }\r
@@ -391,38 +426,8 @@ HotkeyCallback (
       InitializeListHead (&BootLists);\r
 \r
       UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", Hotkey->BootOptionNumber);\r
-      BootOption = BdsLibVariableToOption (&BootLists, Buffer);\r
-      if (BootOption == NULL) {\r
-        return EFI_NOT_FOUND;\r
-      }\r
-      BootOption->BootCurrent = Hotkey->BootOptionNumber;\r
-      BdsLibConnectDevicePath (BootOption->DevicePath);\r
-\r
-      //\r
-      // Clear the screen before launch this BootOption\r
-      //\r
-      gST->ConOut->Reset (gST->ConOut, FALSE);\r
-\r
-      mHotkeyCallbackPending = TRUE;\r
-      Status = BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
-      mHotkeyCallbackPending = FALSE;\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        //\r
-        // Call platform action to indicate the boot fail\r
-        //\r
-        BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
-        PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);\r
-      } else {\r
-        //\r
-        // Call platform action to indicate the boot success\r
-        //\r
-        BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
-        PlatformBdsBootSuccess (BootOption);\r
-      }\r
+      mHotkeyBootOption = BdsLibVariableToOption (&BootLists, Buffer);\r
     }\r
-\r
-    Link = GetNextNode (&mHotkeyList, Link);\r
   }\r
 \r
   return Status;\r
index 281026c850e9062b0d79314f32ea5814e6276669..3fd80443a5879cceabe0c52ae28f0661333c559b 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 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2011, 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
@@ -92,4 +92,12 @@ InitializeHotkeyService (
   VOID\r
   );\r
 \r
+/**\r
+  Try to boot the boot option triggered by hotkey.\r
+**/\r
+VOID\r
+HotkeyBoot (\r
+  VOID\r
+  );\r
+\r
 #endif\r