]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
Add BootlogoOnly feature in BDS for BGRT
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMngr / BootManager.c
index da291000bc360fd4f2dd38fae5da761402fc1e95..a838c2ff7eca0b7d3fc70adc3d38efd28e557ff0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The platform boot manager reference implementation\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2012, 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,9 +15,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "BootManager.h"\r
 \r
 UINT16             mKeyInput;\r
-EFI_GUID           mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID;\r
 LIST_ENTRY         mBootOptionsList;\r
 BDS_COMMON_OPTION  *gOption;\r
+CHAR16             *mDeviceTypeStr[] = {\r
+  L"Legacy BEV",\r
+  L"Legacy Floppy",\r
+  L"Legacy Hard Drive",\r
+  L"Legacy CD ROM",\r
+  L"Legacy PCMCIA",\r
+  L"Legacy USB",\r
+  L"Legacy Embedded Network",\r
+  L"Legacy Unknown Device"\r
+};\r
+\r
 \r
 HII_VENDOR_DEVICE_PATH  mBootManagerHiiVendorDevicePath = {\r
   {\r
@@ -29,10 +39,7 @@ HII_VENDOR_DEVICE_PATH  mBootManagerHiiVendorDevicePath = {
         (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
       }\r
     },\r
-    //\r
-    // {1DDDBE15-481D-4d2b-8277-B191EAF66525}\r
-    //\r
-    { 0x1dddbe15, 0x481d, 0x4d2b, { 0x82, 0x77, 0xb1, 0x91, 0xea, 0xf6, 0x65, 0x25 } }\r
+    BOOT_MANAGER_FORMSET_GUID\r
   },\r
   {\r
     END_DEVICE_PATH_TYPE,\r
@@ -88,40 +95,47 @@ BootManagerCallback (
   LIST_ENTRY              *Link;\r
   UINT16                  KeyCount;\r
 \r
-  if ((Value == NULL) || (ActionRequest == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Initialize the key count\r
-  //\r
-  KeyCount = 0;\r
+  if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
+    if ((Value == NULL) || (ActionRequest == NULL)) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
 \r
-  for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) {\r
-    Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+    //\r
+    // Initialize the key count\r
+    //\r
+    KeyCount = 0;\r
 \r
-    KeyCount++;\r
+    for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) {\r
+      Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
 \r
-    gOption = Option;\r
+      KeyCount++;\r
 \r
-    //\r
-    // Is this device the one chosen?\r
-    //\r
-    if (KeyCount == QuestionId) {\r
-      //\r
-      // Assigning the returned Key to a global allows the original routine to know what was chosen\r
-      //\r
-      mKeyInput = QuestionId;\r
+      gOption = Option;\r
 \r
       //\r
-      // Request to exit SendForm(), so that we could boot the selected option\r
+      // Is this device the one chosen?\r
       //\r
-      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
-      break;\r
+      if (KeyCount == QuestionId) {\r
+        //\r
+        // Assigning the returned Key to a global allows the original routine to know what was chosen\r
+        //\r
+        mKeyInput = QuestionId;\r
+\r
+        //\r
+        // Request to exit SendForm(), so that we could boot the selected option\r
+        //\r
+        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
+        break;\r
+      }\r
     }\r
+\r
+    return EFI_SUCCESS;\r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  //\r
+  // All other action return unsupported.\r
+  //\r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 /**\r
@@ -157,7 +171,7 @@ InitializeBootManager (
   // Publish our HII data\r
   //\r
   gBootManagerPrivate.HiiHandle = HiiAddPackages (\r
-                                    &mBootManagerGuid,\r
+                                    &gBootManagerFormSetGuid,\r
                                     gBootManagerPrivate.DriverHandle,\r
                                     BootManagerVfrBin,\r
                                     BdsDxeStrings,\r
@@ -200,8 +214,12 @@ CallBootManager (
   VOID                        *EndOpCodeHandle;\r
   EFI_IFR_GUID_LABEL          *StartLabel;\r
   EFI_IFR_GUID_LABEL          *EndLabel;\r
+  UINT16                      DeviceType;\r
+  BOOLEAN                     IsLegacyOption;\r
+  BOOLEAN                     NeedEndOp;\r
 \r
-  gOption = NULL;\r
+  DeviceType = (UINT16) -1;\r
+  gOption    = NULL;\r
   InitializeListHead (&mBootOptionsList);\r
 \r
   //\r
@@ -240,7 +258,7 @@ CallBootManager (
   EndLabel->Number       = LABEL_BOOT_OPTION_END;\r
 \r
   mKeyInput = 0;\r
-\r
+  NeedEndOp = FALSE;\r
   for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) {\r
     Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
 \r
@@ -255,7 +273,38 @@ CallBootManager (
     if ((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) {\r
       continue;\r
     }\r
-      \r
+\r
+    //\r
+    // Group the legacy boot option in the sub title created dynamically\r
+    //\r
+    IsLegacyOption = (BOOLEAN) (\r
+                       (DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) &&\r
+                       (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP)\r
+                       );\r
+\r
+    if (!IsLegacyOption && NeedEndOp) {\r
+      NeedEndOp = FALSE;\r
+      HiiCreateEndOpCode (StartOpCodeHandle);\r
+    }\r
+    \r
+    if (IsLegacyOption && DeviceType != ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType) {\r
+      if (NeedEndOp) {\r
+        HiiCreateEndOpCode (StartOpCodeHandle);\r
+      }\r
+\r
+      DeviceType = ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType;\r
+      Token      = HiiSetString (\r
+                     HiiHandle,\r
+                     0,\r
+                     mDeviceTypeStr[\r
+                       MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1)\r
+                       ],\r
+                     NULL\r
+                     );\r
+      HiiCreateSubTitleOpCode (StartOpCodeHandle, Token, 0, 0, 1);\r
+      NeedEndOp = TRUE;\r
+    }\r
+\r
     ASSERT (Option->Description != NULL);\r
     \r
     Token = HiiSetString (HiiHandle, 0, Option->Description, NULL);\r
@@ -279,9 +328,13 @@ CallBootManager (
       );\r
   }\r
 \r
+  if (NeedEndOp) {\r
+    HiiCreateEndOpCode (StartOpCodeHandle);\r
+  }\r
+\r
   HiiUpdateForm (\r
     HiiHandle,\r
-    &mBootManagerGuid,\r
+    &gBootManagerFormSetGuid,\r
     BOOT_MANAGER_FORM_ID,\r
     StartOpCodeHandle,\r
     EndOpCodeHandle\r
@@ -295,7 +348,7 @@ CallBootManager (
                            gFormBrowser2,\r
                            &HiiHandle,\r
                            1,\r
-                           &mBootManagerGuid,\r
+                           &gBootManagerFormSetGuid,\r
                            0,\r
                            NULL,\r
                            &ActionRequest\r
@@ -313,6 +366,11 @@ CallBootManager (
   //\r
   SetupResetReminder ();\r
 \r
+  //\r
+  // Restore to original mode before launching boot option.\r
+  //\r
+  BdsSetConsoleMode (FALSE);\r
+\r
   //\r
   // parse the selected option\r
   //\r