]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/LoadPciRom: Fix the ConnectAll() implementation
authorRuiyu Ni <ruiyu.ni@intel.com>
Fri, 22 Jul 2016 02:14:05 +0000 (10:14 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Mon, 25 Jul 2016 02:20:14 +0000 (10:20 +0800)
Old implementation depends on UefiHandleParsingLib and uses
incorrect Index to get handle type.
The simplest ConnectAll() implementation can be just to
locate all handles and call BS.ConnectController() for each
of them recursively. BS.ConnectController() does nothing
to the image handle. Such implementation is borrowed from
BDS core implementation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c

index 1b284c2d8720d9dc6f4105c12483f96299543fed..c9078f7614df8cb630e93bcc8dd710b31ae1feda 100644 (file)
@@ -26,7 +26,6 @@
   @retval EFI_ABORTED     The abort mechanism was received.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 LoadPciRomConnectAllDriversToAllControllers (\r
   VOID\r
   );\r
@@ -377,98 +376,36 @@ LoadEfiDriversFromRomImage (
   @retval EFI_ABORTED     The abort mechanism was received.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 LoadPciRomConnectAllDriversToAllControllers (\r
   VOID\r
   )\r
-\r
 {\r
   EFI_STATUS  Status;\r
-  UINTN       AllHandleCount;\r
-  EFI_HANDLE  *AllHandleBuffer;\r
-  UINTN       Index;\r
   UINTN       HandleCount;\r
   EFI_HANDLE  *HandleBuffer;\r
-  UINTN       *HandleType;\r
-  UINTN       HandleIndex;\r
-  BOOLEAN     Parent;\r
-  BOOLEAN     Device;\r
-\r
-  Status = gBS->LocateHandleBuffer(\r
-            AllHandles,\r
-            NULL,\r
-            NULL,\r
-            &AllHandleCount,\r
-            &AllHandleBuffer\r
-           );\r
+  UINTN       Index;\r
+\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  for (Index = 0; Index < AllHandleCount; Index++) {\r
+  for (Index = 0; Index < HandleCount; Index++) {\r
     if (ShellGetExecutionBreakFlag ()) {\r
       Status = EFI_ABORTED;\r
-      goto Done;\r
-    }\r
-    //\r
-    // Scan the handle database\r
-    //\r
-    Status = ParseHandleDatabaseByRelationshipWithType(\r
-      NULL,\r
-      AllHandleBuffer[Index],\r
-      &HandleCount,\r
-      &HandleBuffer,\r
-      &HandleType\r
-     );\r
-/*\r
-    Status = LibScanHandleDatabase (\r
-              NULL,\r
-              NULL,\r
-              AllHandleBuffer[Index],\r
-              NULL,\r
-              &HandleCount,\r
-              &HandleBuffer,\r
-              &HandleType\r
-             );\r
-*/\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    Device = TRUE;\r
-    if ((HandleType[Index] & HR_DRIVER_BINDING_HANDLE) != 0) {\r
-      Device = FALSE;\r
-    }\r
-\r
-    if ((HandleType[Index] & HR_IMAGE_HANDLE) != 0) {\r
-      Device = FALSE;\r
-    }\r
-\r
-    if (Device) {\r
-      Parent = FALSE;\r
-      for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {\r
-        if ((HandleType[HandleIndex] & HR_PARENT_HANDLE) != 0) {\r
-          Parent = TRUE;\r
-        }\r
-      }\r
-\r
-      if (!Parent) {\r
-        if ((HandleType[Index] & HR_DEVICE_HANDLE) != 0) {\r
-          Status = gBS->ConnectController (\r
-                        AllHandleBuffer[Index],\r
-                        NULL,\r
-                        NULL,\r
-                        TRUE\r
-                       );\r
-        }\r
-      }\r
+      break;\r
     }\r
+    gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
+  }\r
 \r
+  if (HandleBuffer != NULL) {\r
     FreePool (HandleBuffer);\r
-    FreePool (HandleType);\r
   }\r
-\r
-Done:\r
-  FreePool (AllHandleBuffer);\r
   return Status;\r
 }\r