From fc41b97f128a0c7f28a9cc250e629a0ad2262ac8 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Fri, 22 Jul 2016 10:14:05 +0800 Subject: ShellPkg/LoadPciRom: Fix the ConnectAll() implementation 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 Reviewed-by: Jaben Carsey Reviewed-by: Hao A Wu --- .../UefiShellDebug1CommandsLib/LoadPciRom.c | 91 ++++------------------ 1 file changed, 14 insertions(+), 77 deletions(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c index 1b284c2d87..c9078f7614 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c @@ -26,7 +26,6 @@ @retval EFI_ABORTED The abort mechanism was received. **/ EFI_STATUS -EFIAPI LoadPciRomConnectAllDriversToAllControllers ( VOID ); @@ -377,98 +376,36 @@ LoadEfiDriversFromRomImage ( @retval EFI_ABORTED The abort mechanism was received. **/ EFI_STATUS -EFIAPI LoadPciRomConnectAllDriversToAllControllers ( VOID ) - { EFI_STATUS Status; - UINTN AllHandleCount; - EFI_HANDLE *AllHandleBuffer; - UINTN Index; UINTN HandleCount; EFI_HANDLE *HandleBuffer; - UINTN *HandleType; - UINTN HandleIndex; - BOOLEAN Parent; - BOOLEAN Device; - - Status = gBS->LocateHandleBuffer( - AllHandles, - NULL, - NULL, - &AllHandleCount, - &AllHandleBuffer - ); + UINTN Index; + + Status = gBS->LocateHandleBuffer ( + AllHandles, + NULL, + NULL, + &HandleCount, + &HandleBuffer + ); if (EFI_ERROR (Status)) { return Status; } - for (Index = 0; Index < AllHandleCount; Index++) { + for (Index = 0; Index < HandleCount; Index++) { if (ShellGetExecutionBreakFlag ()) { Status = EFI_ABORTED; - goto Done; - } - // - // Scan the handle database - // - Status = ParseHandleDatabaseByRelationshipWithType( - NULL, - AllHandleBuffer[Index], - &HandleCount, - &HandleBuffer, - &HandleType - ); -/* - Status = LibScanHandleDatabase ( - NULL, - NULL, - AllHandleBuffer[Index], - NULL, - &HandleCount, - &HandleBuffer, - &HandleType - ); -*/ - if (EFI_ERROR (Status)) { - goto Done; - } - - Device = TRUE; - if ((HandleType[Index] & HR_DRIVER_BINDING_HANDLE) != 0) { - Device = FALSE; - } - - if ((HandleType[Index] & HR_IMAGE_HANDLE) != 0) { - Device = FALSE; - } - - if (Device) { - Parent = FALSE; - for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { - if ((HandleType[HandleIndex] & HR_PARENT_HANDLE) != 0) { - Parent = TRUE; - } - } - - if (!Parent) { - if ((HandleType[Index] & HR_DEVICE_HANDLE) != 0) { - Status = gBS->ConnectController ( - AllHandleBuffer[Index], - NULL, - NULL, - TRUE - ); - } - } + break; } + gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE); + } + if (HandleBuffer != NULL) { FreePool (HandleBuffer); - FreePool (HandleType); } - -Done: - FreePool (AllHandleBuffer); return Status; } -- cgit v1.2.3