]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c
Update for IntelFrameworkModulePkg.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMngr / BootManager.c
index 817b2e0e0b1e768a7340a2399e8c548de76c94d2..f86d55594b90437f63cd85304fb03aea9f776c27 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   The platform boot manager reference implementation\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\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
 http://opensource.org/licenses/bsd-license.php\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
+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
@@ -56,7 +63,7 @@ BOOT_MANAGER_CALLBACK_DATA  gBootManagerPrivate = {
 };\r
 \r
 /**\r
-  This call back funtion is registered with Boot Manager formset.\r
+  This call back function is registered with Boot Manager formset.\r
   When user selects a boot option, this call back function will\r
   be triggered. The boot option is saved for later processing.\r
 \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 = mBootOptionsList->ForwardLink; Link != mBootOptionsList; Link = Link->ForwardLink) {\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
@@ -172,7 +186,7 @@ InitializeBootManager (
 }\r
 \r
 /**\r
-  This funtion invokees Boot Manager. If all devices have not a chance to be connected,\r
+  This function invokes Boot Manager. If all devices have not a chance to be connected,\r
   the connect all will be triggered. It then enumerate all boot options. If \r
   a boot option from the Boot Manager page is selected, Boot Manager will boot\r
   from this boot option.\r
@@ -190,7 +204,6 @@ CallBootManager (
   UINTN                       ExitDataSize;\r
   EFI_STRING_ID               Token;\r
   EFI_INPUT_KEY               Key;\r
-  LIST_ENTRY                  BdsBootOptionList;\r
   CHAR16                      *HelpString;\r
   EFI_STRING_ID               HelpToken;\r
   UINT16                      *TempStr;\r
@@ -201,13 +214,13 @@ CallBootManager (
   VOID                        *EndOpCodeHandle;\r
   EFI_IFR_GUID_LABEL          *StartLabel;\r
   EFI_IFR_GUID_LABEL          *EndLabel;\r
-  CHAR16                      *HiiString;\r
-  CHAR16                      *BootStringNumber;\r
-  UINTN                       DevicePathType;\r
-  UINTN                       BufferSize;\r
+  UINT16                      DeviceType;\r
+  BOOLEAN                     IsLegacyOption;\r
+  BOOLEAN                     NeedEndOp;\r
 \r
-  gOption = NULL;\r
-  InitializeListHead (&BdsBootOptionList);\r
+  DeviceType = (UINT16) -1;\r
+  gOption    = NULL;\r
+  InitializeListHead (&mBootOptionsList);\r
 \r
   //\r
   // Connect all prior to entering the platform setup menu.\r
@@ -216,14 +229,8 @@ CallBootManager (
     BdsLibConnectAllDriversToAllControllers ();\r
     gConnectAllHappened = TRUE;\r
   }\r
-  //\r
-  // BugBug: Here we can not remove the legacy refresh macro, so we need\r
-  // get the boot order every time from "BootOrder" variable.\r
-  // Recreate the boot option list base on the BootOrder variable\r
-  //\r
-  BdsLibEnumerateAllBootOption (&BdsBootOptionList);\r
 \r
-  mBootOptionsList  = &BdsBootOptionList;\r
+  BdsLibEnumerateAllBootOption (&mBootOptionsList);\r
 \r
   HiiHandle = gBootManagerPrivate.HiiHandle;\r
 \r
@@ -251,8 +258,8 @@ CallBootManager (
   EndLabel->Number       = LABEL_BOOT_OPTION_END;\r
 \r
   mKeyInput = 0;\r
-\r
-  for (Link = BdsBootOptionList.ForwardLink; Link != &BdsBootOptionList; Link = Link->ForwardLink) {\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
     //\r
@@ -266,66 +273,38 @@ CallBootManager (
     if ((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) {\r
       continue;\r
     }\r
-    \r
-    //\r
-    // Replace description string with UNI file string.\r
-    //\r
-    BootStringNumber = NULL;\r
-    \r
-    DevicePathType = BdsGetBootTypeFromDevicePath (Option->DevicePath);\r
 \r
     //\r
-    // store number string of boot option temporary.\r
+    // Group the legacy boot option in the sub title created dynamically\r
     //\r
-    HiiString = NULL;\r
-    switch (DevicePathType) {\r
-    case BDS_EFI_ACPI_FLOPPY_BOOT:\r
-      HiiString = GetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY));\r
-      break;\r
-    case BDS_EFI_MEDIA_CDROM_BOOT:\r
-    case BDS_EFI_MESSAGE_SATA_BOOT:\r
-    case BDS_EFI_MESSAGE_ATAPI_BOOT:\r
-      HiiString = GetStringById (STRING_TOKEN (STR_DESCRIPTION_DVD));\r
-      break;\r
-    case BDS_EFI_MESSAGE_USB_DEVICE_BOOT:\r
-      HiiString = GetStringById (STRING_TOKEN (STR_DESCRIPTION_USB));\r
-      break;\r
-    case BDS_EFI_MESSAGE_SCSI_BOOT:\r
-      HiiString = GetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI));\r
-      break;\r
-    case BDS_EFI_MESSAGE_MISC_BOOT:\r
-      HiiString = GetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC));\r
-      break;\r
-    case BDS_EFI_MESSAGE_MAC_BOOT:\r
-      HiiString = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK));\r
-      break;\r
-    case BBS_DEVICE_PATH:\r
-      //\r
-      // Do nothing for legacy boot option.\r
-      //\r
-      break;\r
-    default:\r
-      DEBUG((EFI_D_INFO, "Can not find HiiString for given device path type 0x%x\n", DevicePathType));\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
-    //\r
-    // If found Hii description string then cat Hii string with original description.\r
-    //\r
-    if (HiiString != NULL) {\r
-      BootStringNumber = Option->Description;\r
-      BufferSize = StrSize(BootStringNumber);\r
-      BufferSize += StrSize(HiiString);\r
-      Option->Description = AllocateZeroPool(BufferSize);\r
-      StrCpy (Option->Description, HiiString);\r
-      if (StrnCmp (BootStringNumber, L"0", 1) != 0) {\r
-        StrCat (Option->Description, L" ");\r
-        StrCat (Option->Description, BootStringNumber);\r
-      } \r
-      \r
-      FreePool (HiiString);\r
-      FreePool (BootStringNumber);\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
+\r
     ASSERT (Option->Description != NULL);\r
     \r
     Token = HiiSetString (HiiHandle, 0, Option->Description, NULL);\r
@@ -349,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
@@ -365,7 +348,7 @@ CallBootManager (
                            gFormBrowser2,\r
                            &HiiHandle,\r
                            1,\r
-                           &mBootManagerGuid,\r
+                           &gBootManagerFormSetGuid,\r
                            0,\r
                            NULL,\r
                            &ActionRequest\r
@@ -379,7 +362,7 @@ CallBootManager (
   }\r
 \r
   //\r
-  //Will leave browser, check any reset required change is applied? if yes, reset system\r
+  // Will leave browser, check any reset required change is applied? if yes, reset system\r
   //\r
   SetupResetReminder ();\r
 \r