]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/GenericBdsLib/BdsBoot.c
Add some ASSERT()s.
[mirror_edk2.git] / MdeModulePkg / Library / GenericBdsLib / BdsBoot.c
index 8f9d92881a6263f257c99a6fbac195344a559a51..953086c7d3b337458d0d83bb2565f13a5a510719 100644 (file)
@@ -50,7 +50,7 @@ BdsLibDoLegacyBoot (
     return EFI_UNSUPPORTED;\r
   }\r
   //\r
-  // Notes: if we seperate the int 19, then we don't need to refresh BBS\r
+  // Notes: if we separate the int 19, then we don't need to refresh BBS\r
   //\r
   BdsRefreshBbsTableForBoot (Option);\r
 \r
@@ -77,7 +77,7 @@ BdsLibDoLegacyBoot (
 \r
   @param  Option                 The boot option need to be processed\r
   @param  DevicePath             The device path which describe where to load the\r
-                                 boot image or the legcy BBS device path to boot\r
+                                 boot image or the legacy BBS device path to boot\r
                                  the legacy OS\r
   @param  ExitDataSize           The size of exit data.\r
   @param  ExitData               Data returned when Boot image failed.\r
@@ -89,8 +89,8 @@ BdsLibDoLegacyBoot (
 EFI_STATUS\r
 EFIAPI\r
 BdsLibBootViaBootOption (\r
-  IN  BDS_COMMON_OPTION             * Option,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL      * DevicePath,\r
+  IN  BDS_COMMON_OPTION             *Option,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL      *DevicePath,\r
   OUT UINTN                         *ExitDataSize,\r
   OUT CHAR16                        **ExitData OPTIONAL\r
   )\r
@@ -157,6 +157,7 @@ BdsLibBootViaBootOption (
         &Option->BootCurrent\r
         );\r
 \r
+  ASSERT (Option->DevicePath != NULL);\r
   if ((DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) &&\r
       (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP)\r
     ) {\r
@@ -175,6 +176,7 @@ BdsLibBootViaBootOption (
       FreePool(Option->DevicePath);\r
     }\r
     Option->DevicePath  = AllocateZeroPool (GetDevicePathSize (DevicePath));\r
+    ASSERT(Option->DevicePath != NULL);\r
     CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));\r
     //\r
     // Update the shell boot option\r
@@ -286,7 +288,7 @@ Done:
 /**\r
   Expand a device path that starts with a hard drive media device path node to be a\r
   full device path that includes the full hardware path to the device. We need\r
-  to do this so it can be booted. As an optimizaiton the front match (the part point\r
+  to do this so it can be booted. As an optimization the front match (the part point\r
   to the partition node. E.g. ACPI() /PCI()/ATA()/Partition() ) is saved in a variable\r
   so a connect all is not required on every boot. All successful history device path\r
   which point to partition node (the front part) will be saved.\r
@@ -338,8 +340,8 @@ BdsExpandPartitionPartialDevicePathToFull (
     do {\r
       //\r
       // Check every instance of the variable\r
-      // First, check wheather the instance contain the partition node, which is needed for distinguishing  multi\r
-      // partial partition boot option. Second, check wheather the instance could be connected.\r
+      // First, check whether the instance contain the partition node, which is needed for distinguishing  multi\r
+      // partial partition boot option. Second, check whether the instance could be connected.\r
       //\r
       Instance  = GetNextDevicePathInstance (&TempNewDevicePath, &Size);\r
       if (MatchPartitionDevicePathNode (Instance, HardDriveDevicePath)) {\r
@@ -363,13 +365,13 @@ BdsExpandPartitionPartialDevicePathToFull (
     if (DeviceExist) {\r
       //\r
       // Find the matched device path.\r
-      // Append the file path infomration from the boot option and return the fully expanded device path.\r
+      // Append the file path information from the boot option and return the fully expanded device path.\r
       //\r
       DevicePath     = NextDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *) HardDriveDevicePath);\r
       FullDevicePath = AppendDevicePath (Instance, DevicePath);\r
 \r
       //\r
-      // Adjust the 'HDDP' instances sequense if the matched one is not first one.\r
+      // Adjust the 'HDDP' instances sequence if the matched one is not first one.\r
       //\r
       if (NeedAdjust) {\r
         //\r
@@ -380,7 +382,7 @@ BdsExpandPartitionPartialDevicePathToFull (
         FreePool (TempNewDevicePath);\r
         \r
         //\r
-        // Second, append the remaining parth after the matched instance\r
+        // Second, append the remaining path after the matched instance\r
         //\r
         TempNewDevicePath = CachedDevicePath;\r
         CachedDevicePath = AppendDevicePathInstance (Instance, CachedDevicePath );\r
@@ -405,7 +407,7 @@ BdsExpandPartitionPartialDevicePathToFull (
 \r
   //\r
   // If we get here we fail to find or 'HDDP' not exist, and now we need\r
-  // to seach all devices in the system for a matched partition\r
+  // to search all devices in the system for a matched partition\r
   //\r
   BdsLibConnectAllDriversToAllControllers ();\r
   Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer);\r
@@ -434,11 +436,11 @@ BdsExpandPartitionPartialDevicePathToFull (
       FullDevicePath = AppendDevicePath (BlockIoDevicePath, DevicePath);\r
 \r
       //\r
-      // Save the matched patition device path in 'HDDP' variable\r
+      // Save the matched partition device path in 'HDDP' variable\r
       //\r
       if (CachedDevicePath != NULL) {\r
         //\r
-        // Save the matched patition device path as first instance of 'HDDP' variable\r
+        // Save the matched partition device path as first instance of 'HDDP' variable\r
         //\r
         if (BdsLibMatchDevicePaths (CachedDevicePath, BlockIoDevicePath)) {\r
           TempNewDevicePath = CachedDevicePath;\r
@@ -455,9 +457,10 @@ 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 theary, the 'HDDP' variable maybe become larger and larger.\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
         //\r
         InstanceNum = 0;\r
+        ASSERT (CachedDevicePath != NULL);\r
         TempNewDevicePath = CachedDevicePath;\r
         while (!IsDevicePathEnd (TempNewDevicePath)) {\r
           TempNewDevicePath = NextDevicePathNode (TempNewDevicePath);\r
@@ -806,7 +809,7 @@ BdsDeleteAllInvalidEfiBootOption (
 \r
 /**\r
   This function will enumerate all possible boot device in the system,\r
-  it will only excute once of every boot.\r
+  it will only execute once of every boot.\r
 \r
   @param  BdsBootOptionList      The header of the link list which indexed all\r
                                  current boot options\r
@@ -1224,6 +1227,7 @@ BdsLibBootNext (
     //\r
     UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *BootNext);\r
     BootOption = BdsLibVariableToOption (&TempList, Buffer);\r
+    ASSERT (BootOption != NULL);\r
     BdsLibConnectDevicePath (BootOption->DevicePath);\r
     BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
   }\r
@@ -1286,7 +1290,7 @@ BdsLibGetBootableHandle (
     }\r
   } else {\r
     //\r
-    // Get BlockIo protocal and check removable attribute\r
+    // Get BlockIo protocol and check removable attribute\r
     //\r
     Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
     //\r
@@ -1315,7 +1319,7 @@ BdsLibGetBootableHandle (
 \r
   //\r
   // 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\r
-  // Try to locate the USB node device path first, if fail then use its previour PCI node to search\r
+  // Try to locate the USB node device path first, if fail then use its previous PCI node to search\r
   //\r
   DupDevicePath = DuplicateDevicePath (DevicePath);\r
   ASSERT (DupDevicePath != NULL);\r
@@ -1464,23 +1468,23 @@ BdsLibNetworkBootWithMediaPresent (
 \r
   @param  DevicePath                      The bootable device Path to check\r
 \r
-  @retval BDS_EFI_MEDIA_HD_BOOT           If the device path contains any media deviec path node, it is media boot type\r
+  @retval BDS_EFI_MEDIA_HD_BOOT           If the device path contains any media device path node, it is media boot type\r
                                           For the floppy node, handle it as media node\r
-  @retval BDS_EFI_MEDIA_CDROM_BOOT        If the device path contains any media deviec path node, it is media boot type\r
+  @retval BDS_EFI_MEDIA_CDROM_BOOT        If the device path contains any media device path node, it is media boot type\r
                                           For the floppy node, handle it as media node\r
-  @retval BDS_EFI_ACPI_FLOPPY_BOOT        If the device path contains any media deviec path node, it is media boot type\r
+  @retval BDS_EFI_ACPI_FLOPPY_BOOT        If the device path contains any media device path node, it is media boot type\r
                                           For the floppy node, handle it as media node\r
-  @retval BDS_EFI_MESSAGE_ATAPI_BOOT      If the device path not contains any media deviec path node,  and\r
+  @retval BDS_EFI_MESSAGE_ATAPI_BOOT      If the device path not contains any media device path node,  and\r
                                           its last device path node point to a message device path node, it is\r
   \r
-  @retval BDS_EFI_MESSAGE_SCSI_BOOT       If the device path not contains any media deviec path node,  and\r
+  @retval BDS_EFI_MESSAGE_SCSI_BOOT       If the device path not contains any media device path node,  and\r
                                           its last device path node point to a message device path node, it is\r
-  @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If the device path not contains any media deviec path node,  and\r
+  @retval BDS_EFI_MESSAGE_USB_DEVICE_BOOT If the device path not contains any media device path node,  and\r
                                           its last device path node point to a message device path node, it is\r
-  @retval BDS_EFI_MESSAGE_MISC_BOOT       If the device path not contains any media deviec path node,  and\r
+  @retval BDS_EFI_MESSAGE_MISC_BOOT       If the device path not contains any media device path node,  and\r
                                           its last device path node point to a message device path node, it is\r
   @retval BDS_LEGACY_BBS_BOOT             Legacy boot type\r
-  @retval BDS_EFI_UNSUPPORT               An EFI Removable BlockIO device path not point to a media and message devie,   \r
+  @retval BDS_EFI_UNSUPPORT               An EFI Removable BlockIO device path not point to a media and message device,   \r
 \r
 **/\r
 UINT32\r
@@ -1554,14 +1558,14 @@ BdsGetBootTypeFromDevicePath (
 }\r
 \r
 /**\r
-  Check whether the Device path in a boot option point to a valide bootable device,\r
+  Check whether the Device path in a boot option point to a valid bootable device,\r
   And if CheckMedia is true, check the device is ready to boot now.\r
 \r
   @param  DevPath     the Device path in a boot option\r
   @param  CheckMedia  if true, check the device is ready to boot now.\r
 \r
-  @retval TRUE        the Device path  is valide\r
-  @retval FALSE       the Device path  is invalide .\r
+  @retval TRUE        the Device path  is valid\r
+  @retval FALSE       the Device path  is invalid .\r
 \r
 **/\r
 BOOLEAN\r
@@ -1707,7 +1711,7 @@ BdsLibIsValidEFIBootOptDevicePath (
 /**\r
   According to a file guild, check a Fv file device path is valid. If it is invalid,\r
   try to return the valid device path.\r
-  FV address maybe changes for memory layout adjust from time to time, use this funciton\r
+  FV address maybe changes for memory layout adjust from time to time, use this function\r
   could promise the Fv file device path is right.\r
 \r
   @param  DevicePath             on input, the Fv file device path need to check on\r