]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
Clean up the private GUID definition in module Level.
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / GenericBdsLib / BdsBoot.c
index 1ac2946360d700abba6e73a9c067fdc7623602a9..372cab59721d1dedbc94f454b6531ef2ec2585ff 100644 (file)
@@ -18,23 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 BOOLEAN mEnumBootDevice = FALSE;\r
 EFI_HII_HANDLE gBdsLibStringPackHandle = NULL;\r
 \r
-///\r
-/// This GUID is used for an EFI Variable that stores the front device pathes\r
-/// for a partial device path that starts with the HD node.\r
-///\r
-EFI_GUID  mHdBootVariablePrivateGuid = { 0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x8, 0xe2, 0xe, 0x90, 0x6c, 0xb6, 0xde } };\r
-\r
-///\r
-/// This GUID is used for register UNI string.\r
-///\r
-EFI_GUID mBdsLibStringPackGuid = {  0x3b4d9b23, 0x95ac, 0x44f6, { 0x9f, 0xcd, 0xe, 0x95, 0x94, 0x58, 0x6c, 0x72 } };\r
-\r
-///\r
-/// This GUID is used for Set/Get platform language into/from variable at last time enumeration to ensure the enumeration will\r
-/// only execute once.\r
-///\r
-EFI_GUID mBdsLibLastLangGuid = { 0xe8c545b, 0xa2ee, 0x470d, { 0x8e, 0x26, 0xbd, 0xa1, 0xa1, 0x3c, 0xa, 0xa3 } };\r
-\r
 /**\r
   The constructor function register UNI strings into imageHandle.\r
   \r
@@ -56,7 +39,7 @@ GenericBdsLibConstructor (
 {\r
 \r
   gBdsLibStringPackHandle = HiiAddPackages (\r
-                              &mBdsLibStringPackGuid,\r
+                              &gBdsLibStringPackageGuid,\r
                               &ImageHandle,\r
                               GenericBdsLibStrings,\r
                               NULL\r
@@ -450,6 +433,7 @@ BdsFindUsbDevice (
         // could be installed for this USB device.\r
         //\r
         BdsLibConnectDevicePath (FullDevicePath);\r
+        REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
         Status = gBS->LoadImage (\r
                        TRUE,\r
                        gImageHandle,\r
@@ -483,6 +467,7 @@ BdsFindUsbDevice (
         //\r
         FullDevicePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
         if (FullDevicePath != NULL) {\r
+          REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
           Status = gBS->LoadImage (\r
                           TRUE,\r
                           gImageHandle,\r
@@ -753,6 +738,10 @@ BdsLibBootViaBootOption (
         \r
     DEBUG_CODE_END();\r
   \r
+    //\r
+    // Report status code for OS Loader LoadImage.\r
+    //\r
+    REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
     Status = gBS->LoadImage (\r
                     TRUE,\r
                     gImageHandle,\r
@@ -781,6 +770,7 @@ BdsLibBootViaBootOption (
       //\r
       FilePath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
       if (FilePath != NULL) {\r
+        REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderLoad));\r
         Status = gBS->LoadImage (\r
                         TRUE,\r
                         gImageHandle,\r
@@ -832,6 +822,11 @@ BdsLibBootViaBootOption (
     WriteBootToOsPerformanceData ();\r
   );\r
 \r
+  //\r
+  // Report status code for OS Loader StartImage.\r
+  //\r
+  REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderStart));\r
+\r
   Status = gBS->StartImage (ImageHandle, ExitDataSize, ExitData);\r
   DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status = %r\n", Status));\r
 \r
@@ -894,13 +889,13 @@ BdsExpandPartitionPartialDevicePathToFull (
 \r
   FullDevicePath = NULL;\r
   //\r
-  // Check if there is prestore 'HDDP' variable.\r
+  // Check if there is prestore HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable.\r
   // If exist, search the front path which point to partition node in the variable instants.\r
-  // If fail to find or 'HDDP' not exist, reconnect all and search in all system\r
+  // If fail to find or HD_BOOT_DEVICE_PATH_VARIABLE_NAME not exist, reconnect all and search in all system\r
   //\r
   CachedDevicePath = BdsLibGetVariableAndSize (\r
-                      L"HDDP",\r
-                      &mHdBootVariablePrivateGuid,\r
+                      HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
+                      &gHdBootDevicePathVariablGuid,\r
                       &CachedDevicePathSize\r
                       );\r
 \r
@@ -942,7 +937,7 @@ BdsExpandPartitionPartialDevicePathToFull (
       FullDevicePath = AppendDevicePath (Instance, DevicePath);\r
 \r
       //\r
-      // Adjust the 'HDDP' instances sequence if the matched one is not first one.\r
+      // Adjust the HD_BOOT_DEVICE_PATH_VARIABLE_NAME instances sequence if the matched one is not first one.\r
       //\r
       if (NeedAdjust) {\r
         //\r
@@ -962,8 +957,8 @@ BdsExpandPartitionPartialDevicePathToFull (
         // Save the matching Device Path so we don't need to do a connect all next time\r
         //\r
         Status = gRT->SetVariable (\r
-                        L"HDDP",\r
-                        &mHdBootVariablePrivateGuid,\r
+                        HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
+                        &gHdBootDevicePathVariablGuid,\r
                         EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
                         GetDevicePathSize (CachedDevicePath),\r
                         CachedDevicePath\r
@@ -977,7 +972,7 @@ BdsExpandPartitionPartialDevicePathToFull (
   }\r
 \r
   //\r
-  // If we get here we fail to find or 'HDDP' not exist, and now we need\r
+  // If we get here we fail to find or HD_BOOT_DEVICE_PATH_VARIABLE_NAME not exist, and now we need\r
   // to search all devices in the system for a matched partition\r
   //\r
   BdsLibConnectAllDriversToAllControllers ();\r
@@ -1007,11 +1002,11 @@ BdsExpandPartitionPartialDevicePathToFull (
       FullDevicePath = AppendDevicePath (BlockIoDevicePath, DevicePath);\r
 \r
       //\r
-      // Save the matched partition device path in 'HDDP' variable\r
+      // Save the matched partition device path in HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable\r
       //\r
       if (CachedDevicePath != NULL) {\r
         //\r
-        // Save the matched partition device path as first instance of 'HDDP' variable\r
+        // Save the matched partition device path as first instance of HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable\r
         //\r
         if (BdsLibMatchDevicePaths (CachedDevicePath, BlockIoDevicePath)) {\r
           TempNewDevicePath = CachedDevicePath;\r
@@ -1030,7 +1025,8 @@ 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, the 'HDDP' variable maybe become larger and larger.\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
         ASSERT (CachedDevicePath != NULL);\r
@@ -1060,8 +1056,8 @@ BdsExpandPartitionPartialDevicePathToFull (
       // Save the matching Device Path so we don't need to do a connect all next time\r
       //\r
       Status = gRT->SetVariable (\r
-                      L"HDDP",\r
-                      &mHdBootVariablePrivateGuid,\r
+                      HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
+                      &gHdBootDevicePathVariablGuid,\r
                       EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
                       GetDevicePathSize (CachedDevicePath),\r
                       CachedDevicePath\r
@@ -1483,7 +1479,7 @@ BdsLibEnumerateAllBootOption (
   // device from the boot order variable\r
   //\r
   if (mEnumBootDevice) {\r
-    LastLang = GetVariable (L"LastEnumLang", &mBdsLibLastLangGuid);\r
+    LastLang = GetVariable (LAST_ENUM_LANGUAGE_VARIABLE_NAME, &gLastEnumLangGuid);\r
     PlatLang = GetEfiGlobalVariable (L"PlatformLang");\r
     ASSERT (PlatLang != NULL);\r
     if ((LastLang != NULL) && (AsciiStrCmp (LastLang, PlatLang) == 0)) {\r
@@ -1493,8 +1489,8 @@ BdsLibEnumerateAllBootOption (
       return Status;\r
     } else {\r
       Status = gRT->SetVariable (\r
-        L"LastEnumLang",\r
-        &mBdsLibLastLangGuid,\r
+        LAST_ENUM_LANGUAGE_VARIABLE_NAME,\r
+        &gLastEnumLangGuid,\r
         EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
         AsciiStrSize (PlatLang),\r
         PlatLang\r
@@ -1904,6 +1900,7 @@ BdsLibGetBootableHandle (
   )\r
 {\r
   EFI_STATUS                      Status;\r
+  EFI_TPL                         OldTpl;\r
   EFI_DEVICE_PATH_PROTOCOL        *UpdatedDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL        *DupDevicePath;\r
   EFI_HANDLE                      Handle;\r
@@ -1923,6 +1920,12 @@ BdsLibGetBootableHandle (
 \r
   UpdatedDevicePath = DevicePath;\r
 \r
+  //\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
+\r
   //\r
   // Check whether the device is connected\r
   //\r
@@ -1950,6 +1953,8 @@ BdsLibGetBootableHandle (
     // Get BlockIo protocol and check removable attribute\r
     //\r
     Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
     //\r
     // Issue a dummy read to the device to check for media change.\r
     // When the removable media is changed, any Block IO read/write will\r
@@ -2046,6 +2051,8 @@ BdsLibGetBootableHandle (
     FreePool(SimpleFileSystemHandles);\r
   }\r
 \r
+  gBS->RestoreTPL (OldTpl);\r
+\r
   return ReturnHandle;\r
 }\r
 \r