]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
BDS enhancement: enumerate & show all legacy boot options in Boot Manager so that...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMngr / BootManager.c
index b22d0982aebf8cef9580a45ac45ba2a5f0a9c8ae..bf65ea092b534035a5aaec068eb04643b7f83ccb 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 - 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
@@ -18,6 +18,17 @@ UINT16             mKeyInput;
 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
@@ -207,8 +218,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
@@ -247,7 +262,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
@@ -262,7 +277,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
@@ -286,6 +332,10 @@ CallBootManager (
       );\r
   }\r
 \r
+  if (NeedEndOp) {\r
+    HiiCreateEndOpCode (StartOpCodeHandle);\r
+  }\r
+\r
   HiiUpdateForm (\r
     HiiHandle,\r
     &mBootManagerGuid,\r