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