]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Application/UiApp/BootMngr/BootManager.c
MdeModulePkg:Create Boot Maintenance Manager Library
[mirror_edk2.git] / MdeModulePkg / Application / UiApp / BootMngr / BootManager.c
index 3612c581daeaaecb34a39ae353854a8d83c27e4d..4390deef2455931e512c6697630bea7f37f84980 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The platform boot manager reference implementation\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2015, 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
@@ -219,7 +219,9 @@ EnumerateBootOptions  (
   VOID\r
   )\r
 {\r
+  EFI_STATUS                    Status;\r
   UINTN                         Index;\r
+  EFI_DEVICE_PATH_PROTOCOL      *ImageDevicePath;\r
   EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption;\r
   UINTN                         BootOptionCount;\r
   EFI_STRING_ID                 Token;\r
@@ -236,9 +238,13 @@ EnumerateBootOptions  (
   BOOLEAN                       IsLegacyOption;\r
   BOOLEAN                       NeedEndOp;\r
   UINT16                        KeyInput;\r
+  UINTN                         DestMax;\r
 \r
   DeviceType = (UINT16) -1;\r
 \r
+  Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **) &ImageDevicePath);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   //\r
   // for better user experience\r
   // 1. User changes HD configuration (e.g.: unplug HDD), here we have a chance to remove the HDD boot option\r
@@ -288,6 +294,13 @@ EnumerateBootOptions  (
       continue;\r
     }\r
 \r
+    //\r
+    // Don't display myself\r
+    //\r
+    if (CompareMem (BootOption[Index].FilePath, ImageDevicePath, GetDevicePathSize (ImageDevicePath)) == 0) {\r
+      continue;\r
+    }\r
+\r
     //\r
     // Group the legacy boot option in the sub title created dynamically\r
     //\r
@@ -325,10 +338,11 @@ EnumerateBootOptions  (
 \r
     TempStr = UiDevicePathToStr (BootOption[Index].FilePath);\r
     TempSize = StrSize (TempStr);\r
+    DestMax = (TempSize + StrSize (L"Device Path : ")) / sizeof(CHAR16);\r
     HelpString = AllocateZeroPool (TempSize + StrSize (L"Device Path : "));\r
     ASSERT (HelpString != NULL);\r
-    StrCat (HelpString, L"Device Path : ");\r
-    StrCat (HelpString, TempStr);\r
+    StrCatS (HelpString, DestMax, L"Device Path : ");\r
+    StrCatS (HelpString, DestMax, TempStr);\r
 \r
     HelpToken = HiiSetString (HiiHandle, 0, HelpString, NULL);\r
 \r