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 <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Ruiyu Ni
2016-07-22 10:14:05 +08:00
parent 1b0319535b
commit fc41b97f12

View File

@ -26,7 +26,6 @@
@retval EFI_ABORTED The abort mechanism was received. @retval EFI_ABORTED The abort mechanism was received.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI
LoadPciRomConnectAllDriversToAllControllers ( LoadPciRomConnectAllDriversToAllControllers (
VOID VOID
); );
@ -377,98 +376,36 @@ LoadEfiDriversFromRomImage (
@retval EFI_ABORTED The abort mechanism was received. @retval EFI_ABORTED The abort mechanism was received.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI
LoadPciRomConnectAllDriversToAllControllers ( LoadPciRomConnectAllDriversToAllControllers (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN AllHandleCount;
EFI_HANDLE *AllHandleBuffer;
UINTN Index;
UINTN HandleCount; UINTN HandleCount;
EFI_HANDLE *HandleBuffer; EFI_HANDLE *HandleBuffer;
UINTN *HandleType; UINTN Index;
UINTN HandleIndex;
BOOLEAN Parent;
BOOLEAN Device;
Status = gBS->LocateHandleBuffer( Status = gBS->LocateHandleBuffer (
AllHandles, AllHandles,
NULL, NULL,
NULL, NULL,
&AllHandleCount, &HandleCount,
&AllHandleBuffer &HandleBuffer
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
for (Index = 0; Index < AllHandleCount; Index++) { for (Index = 0; Index < HandleCount; Index++) {
if (ShellGetExecutionBreakFlag ()) { if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED; Status = EFI_ABORTED;
goto Done; break;
} }
// gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
// 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
);
}
}
}
FreePool (HandleBuffer);
FreePool (HandleType);
} }
Done: if (HandleBuffer != NULL) {
FreePool (AllHandleBuffer); FreePool (HandleBuffer);
}
return Status; return Status;
} }