X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FGenericBdsLib%2FBdsBoot.c;h=f170daab95b96058b50331df8a5d69f6ddffcd0b;hb=e56187913724379012649c0411668f94ac2ffd9f;hp=c8b2c59f5244e08ebbeeb5bc07119447c1225c6a;hpb=676df92c2c0c5bdeb0f8e27349f5dd467928ce09;p=mirror_edk2.git diff --git a/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c b/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c index c8b2c59f52..f170daab95 100644 --- a/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -1,6 +1,5 @@ /** @file - BDS Lib functions which relate with create or process the boot - option. + BDS Lib functions which relate with create or process the boot option. Copyright (c) 2004 - 2008, Intel Corporation.
All rights reserved. This program and the accompanying materials @@ -51,7 +50,7 @@ BdsLibDoLegacyBoot ( return EFI_UNSUPPORTED; } // - // Notes: if we seperate the int 19, then we don't need to refresh BBS + // Notes: if we separate the int 19, then we don't need to refresh BBS // BdsRefreshBbsTableForBoot (Option); @@ -73,17 +72,17 @@ BdsLibDoLegacyBoot ( /** - Process the boot option follow the EFI 1.1 specification and + Process the boot option follow the UEFI specification and special treat the legacy boot option with BBS_DEVICE_PATH. @param Option The boot option need to be processed @param DevicePath The device path which describe where to load the - boot image or the legcy BBS device path to boot + boot image or the legacy BBS device path to boot the legacy OS - @param ExitDataSize Returned directly from gBS->StartImage () - @param ExitData Returned directly from gBS->StartImage () + @param ExitDataSize The size of exit data. + @param ExitData Data returned when Boot image failed. - @retval EFI_SUCCESS Status from gBS->StartImage () + @retval EFI_SUCCESS Boot from the input boot option successfully. @retval EFI_NOT_FOUND If the Device Path is not found in the system **/ @@ -176,6 +175,7 @@ BdsLibBootViaBootOption ( FreePool(Option->DevicePath); } Option->DevicePath = AllocateZeroPool (GetDevicePathSize (DevicePath)); + ASSERT(Option->DevicePath != NULL); CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath)); // // Update the shell boot option @@ -287,7 +287,7 @@ Done: /** Expand a device path that starts with a hard drive media device path node to be a full device path that includes the full hardware path to the device. We need - to do this so it can be booted. As an optimizaiton the front match (the part point + to do this so it can be booted. As an optimization the front match (the part point to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ) is saved in a variable so a connect all is not required on every boot. All successful history device path which point to partition node (the front part) will be saved. @@ -339,8 +339,8 @@ BdsExpandPartitionPartialDevicePathToFull ( do { // // Check every instance of the variable - // First, check wheather the instance contain the partition node, which is needed for distinguishing multi - // partial partition boot option. Second, check wheather the instance could be connected. + // First, check whether the instance contain the partition node, which is needed for distinguishing multi + // partial partition boot option. Second, check whether the instance could be connected. // Instance = GetNextDevicePathInstance (&TempNewDevicePath, &Size); if (MatchPartitionDevicePathNode (Instance, HardDriveDevicePath)) { @@ -364,13 +364,13 @@ BdsExpandPartitionPartialDevicePathToFull ( if (DeviceExist) { // // Find the matched device path. - // Append the file path infomration from the boot option and return the fully expanded device path. + // Append the file path information from the boot option and return the fully expanded device path. // DevicePath = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath); FullDevicePath = AppendDevicePath (Instance, DevicePath); // - // Adjust the 'HDDP' instances sequense if the matched one is not first one. + // Adjust the 'HDDP' instances sequence if the matched one is not first one. // if (NeedAdjust) { // @@ -381,7 +381,7 @@ BdsExpandPartitionPartialDevicePathToFull ( FreePool (TempNewDevicePath); // - // Second, append the remaining parth after the matched instance + // Second, append the remaining path after the matched instance // TempNewDevicePath = CachedDevicePath; CachedDevicePath = AppendDevicePathInstance (Instance, CachedDevicePath ); @@ -406,7 +406,7 @@ BdsExpandPartitionPartialDevicePathToFull ( // // If we get here we fail to find or 'HDDP' not exist, and now we need - // to seach all devices in the system for a matched partition + // to search all devices in the system for a matched partition // BdsLibConnectAllDriversToAllControllers (); Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer); @@ -435,11 +435,11 @@ BdsExpandPartitionPartialDevicePathToFull ( FullDevicePath = AppendDevicePath (BlockIoDevicePath, DevicePath); // - // Save the matched patition device path in 'HDDP' variable + // Save the matched partition device path in 'HDDP' variable // if (CachedDevicePath != NULL) { // - // Save the matched patition device path as first instance of 'HDDP' variable + // Save the matched partition device path as first instance of 'HDDP' variable // if (BdsLibMatchDevicePaths (CachedDevicePath, BlockIoDevicePath)) { TempNewDevicePath = CachedDevicePath; @@ -456,7 +456,7 @@ 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 theary, the 'HDDP' variable maybe become larger and larger. + // If the user try to boot many OS in different HDs or partitions, in theory, the 'HDDP' variable maybe become larger and larger. // InstanceNum = 0; TempNewDevicePath = CachedDevicePath; @@ -511,8 +511,8 @@ BdsExpandPartitionPartialDevicePathToFull ( @param HardDriveDevicePath A device path which starts with a hard drive media device path. - @retval TRUE There is a matched device path instance FALSE - @retval FALSE There is no matched device path instance + @retval TRUE There is a matched device path instance. + @retval FALSE There is no matched device path instance. **/ BOOLEAN @@ -523,7 +523,6 @@ MatchPartitionDevicePathNode ( ) { HARDDRIVE_DEVICE_PATH *TmpHdPath; - HARDDRIVE_DEVICE_PATH *TempPath; EFI_DEVICE_PATH_PROTOCOL *DevicePath; BOOLEAN Match; EFI_DEVICE_PATH_PROTOCOL *BlockIoHdDevicePathNode; @@ -559,20 +558,19 @@ MatchPartitionDevicePathNode ( // See if the harddrive device path in blockio matches the orig Hard Drive Node // TmpHdPath = (HARDDRIVE_DEVICE_PATH *) BlockIoHdDevicePathNode; - TempPath = (HARDDRIVE_DEVICE_PATH *) BdsLibUnpackDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath); Match = FALSE; // // Check for the match // - if ((TmpHdPath->MBRType == TempPath->MBRType) && - (TmpHdPath->SignatureType == TempPath->SignatureType)) { + if ((TmpHdPath->MBRType == HardDriveDevicePath->MBRType) && + (TmpHdPath->SignatureType == HardDriveDevicePath->SignatureType)) { switch (TmpHdPath->SignatureType) { case SIGNATURE_TYPE_GUID: - Match = CompareGuid ((EFI_GUID *)TmpHdPath->Signature, (EFI_GUID *)TempPath->Signature); + Match = CompareGuid ((EFI_GUID *)TmpHdPath->Signature, (EFI_GUID *)HardDriveDevicePath->Signature); break; case SIGNATURE_TYPE_MBR: - Match = (BOOLEAN)(*((UINT32 *)(&(TmpHdPath->Signature[0]))) == *(UINT32 *)(&(TempPath->Signature[0]))); + Match = (BOOLEAN)(*((UINT32 *)(&(TmpHdPath->Signature[0]))) == ReadUnaligned32((UINT32 *)(&(HardDriveDevicePath->Signature[0])))); break; default: Match = FALSE; @@ -809,7 +807,7 @@ BdsDeleteAllInvalidEfiBootOption ( /** This function will enumerate all possible boot device in the system, - it will only excute once of every boot. + it will only execute once of every boot. @param BdsBootOptionList The header of the link list which indexed all current boot options @@ -1117,13 +1115,13 @@ BdsLibEnumerateAllBootOption ( } /** - Build the boot option with the handle parsed in. + Build the boot option with the handle parsed in @param Handle The handle which present the device path to create boot option @param BdsBootOptionList The header of the link list which indexed all current boot options - @param String Boot option name. + @param String The description of the boot option. **/ VOID @@ -1181,7 +1179,7 @@ BdsLibBuildOptionFromShell ( } /** - Boot from the EFI1.1 spec defined "BootNext" variable + Boot from the UEFI spec defined "BootNext" variable. **/ VOID @@ -1241,7 +1239,6 @@ BdsLibBootNext ( @param DevicePath Device Path to a bootable device - @retval NULL The device path points to an EFI bootable Media @retval NULL The media on the DevicePath is not bootable **/ @@ -1290,7 +1287,7 @@ BdsLibGetBootableHandle ( } } else { // - // Get BlockIo protocal and check removable attribute + // Get BlockIo protocol and check removable attribute // Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo); // @@ -1319,7 +1316,7 @@ BdsLibGetBootableHandle ( // // If fail to get bootable handle specified by a USB boot option, the BDS should try to find other bootable device in the same USB bus - // Try to locate the USB node device path first, if fail then use its previour PCI node to search + // Try to locate the USB node device path first, if fail then use its previous PCI node to search // DupDevicePath = DuplicateDevicePath (DevicePath); ASSERT (DupDevicePath != NULL); @@ -1468,23 +1465,23 @@ BdsLibNetworkBootWithMediaPresent ( @param DevicePath The bootable device Path to check - @retval BDS_EFI_MEDIA_HD_BOOT If the device path contains any media deviec path node, it is media boot type + @retval BDS_EFI_MEDIA_HD_BOOT If the device path contains any media device path node, it is media boot type For the floppy node, handle it as media node - @retval BDS_EFI_MEDIA_CDROM_BOOT If the device path contains any media deviec path node, it is media boot type + @retval BDS_EFI_MEDIA_CDROM_BOOT If the device path contains any media device path node, it is media boot type For the floppy node, handle it as media node - @retval BDS_EFI_ACPI_FLOPPY_BOOT If the device path contains any media deviec path node, it is media boot type + @retval BDS_EFI_ACPI_FLOPPY_BOOT If the device path contains any media device path node, it is media boot type For the floppy node, handle it as media node - @retval BDS_EFI_MESSAGE_ATAPI_BOOT If the device path not contains any media deviec path node, and + @retval BDS_EFI_MESSAGE_ATAPI_BOOT If the device path not contains any media device path node, and its last device path node point to a message device path node, it is - @retval BDS_EFI_MESSAGE_SCSI_BOOT If the device path not contains any media deviec path node, and + @retval BDS_EFI_MESSAGE_SCSI_BOOT If the device path not contains any media device path node, and its last device path node point to a message device path node, it is - @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If the device path not contains any media deviec path node, and + @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If the device path not contains any media device path node, and its last device path node point to a message device path node, it is - @retval BDS_EFI_MESSAGE_MISC_BOOT If the device path not contains any media deviec path node, and + @retval BDS_EFI_MESSAGE_MISC_BOOT If the device path not contains any media device path node, and its last device path node point to a message device path node, it is @retval BDS_LEGACY_BBS_BOOT Legacy boot type - @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path not point to a media and message devie, + @retval BDS_EFI_UNSUPPORT An EFI Removable BlockIO device path not point to a media and message device, **/ UINT32 @@ -1558,14 +1555,14 @@ BdsGetBootTypeFromDevicePath ( } /** - Check whether the Device path in a boot option point to a valide bootable device, + Check whether the Device path in a boot option point to a valid bootable device, And if CheckMedia is true, check the device is ready to boot now. - @param DevPath the Device path in a boot option - @param CheckMedia if true, check the device is ready to boot now. + @param DevPath the Device path in a boot option + @param CheckMedia if true, check the device is ready to boot now. - @retval TRUE the Device path is valide - @retval FALSE the Device path is invalide . + @retval TRUE the Device path is valid + @retval FALSE the Device path is invalid . **/ BOOLEAN @@ -1624,9 +1621,9 @@ BdsLibIsValidEFIBootOptDevicePath ( // If the boot option point to a file, it is a valid EFI boot option, // and assume it is ready to boot now // - while (!EfiIsDevicePathEnd (TempDevicePath)) { + while (!IsDevicePathEnd (TempDevicePath)) { LastDeviceNode = TempDevicePath; - TempDevicePath = EfiNextDevicePathNode (TempDevicePath); + TempDevicePath = NextDevicePathNode (TempDevicePath); } if ((DevicePathType (LastDeviceNode) == MEDIA_DEVICE_PATH) && (DevicePathSubType (LastDeviceNode) == MEDIA_FILEPATH_DP)) { @@ -1711,7 +1708,7 @@ BdsLibIsValidEFIBootOptDevicePath ( /** According to a file guild, check a Fv file device path is valid. If it is invalid, try to return the valid device path. - FV address maybe changes for memory layout adjust from time to time, use this funciton + FV address maybe changes for memory layout adjust from time to time, use this function could promise the Fv file device path is right. @param DevicePath on input, the Fv file device path need to check on @@ -1732,7 +1729,7 @@ EFI_STATUS EFIAPI BdsLibUpdateFvFileDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath, - IN EFI_GUID *FileGuid + IN EFI_GUID *FileGuid ) { EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; @@ -1765,9 +1762,9 @@ BdsLibUpdateFvFileDevicePath ( // TempDevicePath = *DevicePath; LastDeviceNode = TempDevicePath; - while (!EfiIsDevicePathEnd (TempDevicePath)) { + while (!IsDevicePathEnd (TempDevicePath)) { LastDeviceNode = TempDevicePath; - TempDevicePath = EfiNextDevicePathNode (TempDevicePath); + TempDevicePath = NextDevicePathNode (TempDevicePath); } GuidPoint = EfiGetNameGuidFromFwVolDevicePathNode ( (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LastDeviceNode