]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / GenericBdsLib / BdsBoot.c
index e02a71015edcbbd066447c1e4b92c2a284c33733..178679ffb8b688074b1d006b121e8ac4b48061e0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   BDS Lib functions which relate with create or process the boot option.\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, 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,14 +18,37 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 BOOLEAN mEnumBootDevice = FALSE;\r
 EFI_HII_HANDLE gBdsLibStringPackHandle = NULL;\r
 \r
+/**\r
+\r
+  End Perf entry of BDS\r
+\r
+  @param  Event                 The triggered event.\r
+  @param  Context               Context for this event.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+BmEndOfBdsPerfCode (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+{\r
+  //\r
+  // Record the performance data for End of BDS\r
+  //\r
+  PERF_END(NULL, "BDS", NULL, 0);\r
+\r
+  return ;\r
+}\r
+\r
 /**\r
   The constructor function register UNI strings into imageHandle.\r
-  \r
-  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
+\r
+  It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
 \r
   @param  ImageHandle   The firmware allocated handle for the EFI image.\r
   @param  SystemTable   A pointer to the EFI System Table.\r
-  \r
+\r
   @retval EFI_SUCCESS   The constructor successfully added string package.\r
   @retval Other value   The constructor can't add string package.\r
 \r
@@ -227,7 +250,7 @@ BdsBuildLegacyDevNameString (
   //\r
   // If current BBS entry has its description then use it.\r
   //\r
-  StringDesc = (UINT8 *) (UINTN) ((CurBBSEntry->DescStringSegment << 4) + CurBBSEntry->DescStringOffset);\r
+  StringDesc = (UINT8 *) (((UINTN) CurBBSEntry->DescStringSegment << 4) + CurBBSEntry->DescStringOffset);\r
   if (NULL != StringDesc) {\r
     //\r
     // Only get fisrt 32 characters, this is suggested by BBS spec\r
@@ -330,7 +353,7 @@ BdsCreateLegacyBootOption (
   //\r
   // Create new BBS device path node with description string\r
   //\r
-  UnicodeStrToAsciiStr (BootDesc, HelpString);\r
+  UnicodeStrToAsciiStrS (BootDesc, HelpString, sizeof (HelpString));\r
 \r
   StringLen = AsciiStrLen (HelpString);\r
   NewBbsDevPathNode = AllocateZeroPool (sizeof (BBS_BBS_DEVICE_PATH) + StringLen);\r
@@ -409,7 +432,7 @@ BdsCreateLegacyBootOption (
                   );\r
 \r
   FreePool (Buffer);\r
-  \r
+\r
   Buffer = NULL;\r
 \r
   NewBootOrderList = AllocateZeroPool (*BootOrderListSize + sizeof (UINT16));\r
@@ -570,10 +593,10 @@ BdsDeleteAllInvalidLegacyBootOptions (
         return EFI_OUT_OF_RESOURCES;\r
       }\r
     }\r
-  \r
+\r
     //\r
     // Skip Non-Legacy boot option\r
-    // \r
+    //\r
     if (!BdsIsLegacyBootOption (BootOptionVar, &BbsEntry, &BbsIndex)) {\r
       if (BootOptionVar!= NULL) {\r
         FreePool (BootOptionVar);\r
@@ -780,7 +803,7 @@ BdsCreateOneLegacyBootOption (
 /**\r
   Add the legacy boot options from BBS table if they do not exist.\r
 \r
-  @retval EFI_SUCCESS          The boot options are added successfully \r
+  @retval EFI_SUCCESS          The boot options are added successfully\r
                                or they are already in boot options.\r
   @retval EFI_NOT_FOUND        No legacy boot options is found.\r
   @retval EFI_OUT_OF_RESOURCE  No enough memory.\r
@@ -930,7 +953,7 @@ BdsFillDevOrderBuf (
   @param BbsTable        The BBS table.\r
   @param BbsCount        The BBS Count.\r
 \r
-  @retval EFI_SUCCES             The buffer is created and the EFI variable named \r
+  @retval EFI_SUCCES             The buffer is created and the EFI variable named\r
                                  VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid is\r
                                  set correctly.\r
   @retval EFI_OUT_OF_RESOURCES   Memmory or storage is not enough.\r
@@ -1021,11 +1044,11 @@ BdsCreateDevOrder (
   DevOrderPtr->BbsType = BBS_HARDDISK;\r
   DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));\r
   DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_HARDDISK, BbsCount, DevOrderPtr->Data);\r
-  \r
+\r
   DevOrderPtr->BbsType = BBS_CDROM;\r
   DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));\r
   DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_CDROM, BbsCount, DevOrderPtr->Data);\r
-  \r
+\r
   DevOrderPtr->BbsType = BBS_EMBED_NETWORK;\r
   DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));\r
   DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_EMBED_NETWORK, BbsCount, DevOrderPtr->Data);\r
@@ -1034,7 +1057,7 @@ BdsCreateDevOrder (
   DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));\r
   DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_BEV_DEVICE, BbsCount, DevOrderPtr->Data);\r
 \r
-  ASSERT (TotalSize == (UINTN) ((UINT8 *) DevOrderPtr - (UINT8 *) DevOrder));\r
+  ASSERT (TotalSize == ((UINTN) DevOrderPtr - (UINTN) DevOrder));\r
 \r
   //\r
   // Save device order for legacy boot device to variable.\r
@@ -1052,7 +1075,7 @@ BdsCreateDevOrder (
 }\r
 \r
 /**\r
-  Add the legacy boot devices from BBS table into \r
+  Add the legacy boot devices from BBS table into\r
   the legacy device boot order.\r
 \r
   @retval EFI_SUCCESS           The boot devices are added successfully.\r
@@ -1270,7 +1293,7 @@ BdsUpdateLegacyDevOrder (
     NETIndex++;\r
   }\r
   NewNETPtr = NewPtr->Data;\r
-  \r
+\r
   //\r
   // copy BEV\r
   //\r
@@ -1494,7 +1517,7 @@ PrintBbsTable (
   Set the boot priority for BBS entries based on boot option entry and boot order.\r
 \r
   @param  Entry             The boot option is to be checked for refresh BBS table.\r
-  \r
+\r
   @retval EFI_SUCCESS           The boot priority for BBS entries is refreshed successfully.\r
   @retval EFI_NOT_FOUND         BBS entries can't be found.\r
   @retval EFI_OUT_OF_RESOURCES  Failed to get the legacy device boot order.\r
@@ -1695,8 +1718,8 @@ BdsLibDoLegacyBoot (
     //\r
     Status = EfiCreateEventLegacyBootEx(\r
                TPL_NOTIFY,\r
-               WriteBootToOsPerformanceData,\r
-               NULL, \r
+               BmEndOfBdsPerfCode,\r
+               NULL,\r
                &LegacyBootEvent\r
                );\r
     ASSERT_EFI_ERROR (Status);\r
@@ -1953,7 +1976,7 @@ BdsMatchUsbWwid (
 \r
 /**\r
   Find a USB device path which match the specified short-form device path start\r
-  with USB Class or USB WWID device path and load the boot file then return the \r
+  with USB Class or USB WWID device path and load the boot file then return the\r
   image handle. If ParentDevicePath is NULL, this function will search in all USB\r
   devices of the platform. If ParentDevicePath is not NULL,this function will only\r
   search in its child devices.\r
@@ -2110,7 +2133,7 @@ BdsFindUsbDevice (
 \r
 /**\r
   Expand USB Class or USB WWID device path node to be full device path of a USB\r
-  device in platform then load the boot file on this full device path and return the \r
+  device in platform then load the boot file on this full device path and return the\r
   image handle.\r
 \r
   This function support following 4 cases:\r
@@ -2233,22 +2256,13 @@ BdsLibBootViaBootOption (
   EFI_DEVICE_PATH_PROTOCOL  *FilePath;\r
   EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;\r
   EFI_DEVICE_PATH_PROTOCOL  *WorkingDevicePath;\r
-  EFI_ACPI_S3_SAVE_PROTOCOL *AcpiS3Save;\r
   LIST_ENTRY                TempBootLists;\r
   EFI_BOOT_LOGO_PROTOCOL    *BootLogo;\r
 \r
+  Status        = EFI_SUCCESS;\r
   *ExitDataSize = 0;\r
   *ExitData     = NULL;\r
 \r
-  //\r
-  // Notes: this code can be remove after the s3 script table\r
-  // hook on the event EVT_SIGNAL_READY_TO_BOOT or\r
-  // EVT_SIGNAL_LEGACY_BOOT\r
-  //\r
-  Status = gBS->LocateProtocol (&gEfiAcpiS3SaveProtocolGuid, NULL, (VOID **) &AcpiS3Save);\r
-  if (!EFI_ERROR (Status)) {\r
-    AcpiS3Save->S3Save (AcpiS3Save, NULL);\r
-  }\r
   //\r
   // If it's Device Path that starts with a hard drive path, append it with the front part to compose a\r
   // full device path\r
@@ -2351,9 +2365,9 @@ BdsLibBootViaBootOption (
     } else {\r
       DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Booting %S\n", Option->Description));\r
     }\r
-        \r
+\r
     DEBUG_CODE_END();\r
-  \r
+\r
     //\r
     // Report status code for OS Loader LoadImage.\r
     //\r
@@ -2407,7 +2421,7 @@ BdsLibBootViaBootOption (
     REPORT_STATUS_CODE (\r
       EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
       (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)\r
-      );    \r
+      );\r
     goto Done;\r
   }\r
 \r
@@ -2434,7 +2448,7 @@ BdsLibBootViaBootOption (
   // Write boot to OS performance data for UEFI boot\r
   //\r
   PERF_CODE (\r
-    WriteBootToOsPerformanceData (NULL, NULL);\r
+    BmEndOfBdsPerfCode (NULL, NULL);\r
   );\r
 \r
   //\r
@@ -2676,7 +2690,7 @@ BdsExpandPartitionPartialDevicePathToFull (
 \r
         //\r
         // Here limit the device path instance number to 12, which is max number for a system support 3 IDE controller\r
-        // If the user try to boot many OS in different HDs or partitions, in theory, \r
+        // If the user try to boot many OS in different HDs or partitions, in theory,\r
         // the HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable maybe become larger and larger.\r
         //\r
         InstanceNum = 0;\r
@@ -3200,7 +3214,7 @@ BdsLibEnumerateAllBootOption (
 \r
   //\r
   // Parse removable media followed by fixed media.\r
-  // The Removable[] array is used by the for-loop below to create removable media boot options \r
+  // The Removable[] array is used by the for-loop below to create removable media boot options\r
   // at first, and then to create fixed media boot options.\r
   //\r
   Removable[0]  = FALSE;\r
@@ -3615,7 +3629,7 @@ BdsLibGetBootableHandle (
   UpdatedDevicePath = DevicePath;\r
 \r
   //\r
-  // Enter to critical section to protect the acquired BlockIo instance \r
+  // Enter to critical section to protect the acquired BlockIo instance\r
   // from getting released due to the USB mass storage hotplug event\r
   //\r
   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
@@ -3639,10 +3653,10 @@ BdsLibGetBootableHandle (
     }\r
   } else {\r
     //\r
-    // For removable device boot option, its contained device path only point to the removable device handle, \r
-    // should make sure all its children handles (its child partion or media handles) are created and connected. \r
+    // For removable device boot option, its contained device path only point to the removable device handle,\r
+    // should make sure all its children handles (its child partion or media handles) are created and connected.\r
     //\r
-    gBS->ConnectController (Handle, NULL, NULL, TRUE); \r
+    gBS->ConnectController (Handle, NULL, NULL, TRUE);\r
     //\r
     // Get BlockIo protocol and check removable attribute\r
     //\r
@@ -4016,7 +4030,7 @@ BdsLibIsValidEFIBootOptDevicePathExt (
 \r
   //\r
   // Check if it's a valid boot option for network boot device.\r
-  // Check if there is EfiLoadFileProtocol installed. \r
+  // Check if there is EfiLoadFileProtocol installed.\r
   // If yes, that means there is a boot option for network.\r
   //\r
   Status = gBS->LocateDevicePath (\r
@@ -4054,7 +4068,7 @@ BdsLibIsValidEFIBootOptDevicePathExt (
       }\r
     } else {\r
       return TRUE;\r
-    }    \r
+    }\r
   }\r
 \r
   //\r