summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core/Dxe
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-30 02:35:26 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-30 02:35:26 +0000
commitadc8840a2517db5d93fbdba93f5f51d94ee0fb39 (patch)
tree4ebdc8748056bad256ae23f7e06dc30e43465f86 /MdeModulePkg/Core/Dxe
parenta82da388bfd838ba141d3643689de68e6c48e900 (diff)
downloadedk2-adc8840a2517db5d93fbdba93f5f51d94ee0fb39.zip
edk2-adc8840a2517db5d93fbdba93f5f51d94ee0fb39.tar.gz
edk2-adc8840a2517db5d93fbdba93f5f51d94ee0fb39.tar.bz2
Update ConnectController() to convert an ImageHandle retrieved from the Platform Driver Override Protocol or the Bus Specific Driver Override Protocol into a set of Driver Binding Handles. This is required if the ImageHandle produces more than one Driver Binding Handle or produces a Driver Binding Protocol on a handle other than the ImageHandle for the driver.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4346 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core/Dxe')
-rw-r--r--MdeModulePkg/Core/Dxe/Hand/DriverSupport.c142
1 files changed, 48 insertions, 94 deletions
diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
index 511acff..29b4572 100644
--- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
+++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c
@@ -28,12 +28,6 @@ BOOLEAN mRepairLoadedImage = FALSE;
//
// Driver Support Function Prototypes
//
-EFI_STATUS
-GetHandleFromDriverBinding (
- IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindingNeed,
- OUT EFI_HANDLE *Handle
- );
-
EFI_STATUS
CoreConnectSingleController (
IN EFI_HANDLE ControllerHandle,
@@ -282,7 +276,8 @@ AddSortedDriverBindingProtocol (
IN OUT UINTN *NumberOfSortedDriverBindingProtocols,
IN OUT EFI_DRIVER_BINDING_PROTOCOL **SortedDriverBindingProtocols,
IN UINTN DriverBindingHandleCount,
- IN OUT EFI_HANDLE *DriverBindingHandleBuffer
+ IN OUT EFI_HANDLE *DriverBindingHandleBuffer,
+ IN BOOLEAN IsImageHandle
)
/*++
@@ -322,6 +317,41 @@ Returns:
}
//
+ // If IsImageHandle is TRUE, then DriverBindingHandle is an image handle
+ // Find all the DriverBindingHandles associated with that image handle and add them to the sorted list
+ //
+ if (IsImageHandle) {
+ //
+ // Loop through all the Driver Binding Handles
+ //
+ for (Index = 0; Index < DriverBindingHandleCount; Index++) {
+ //
+ // Retrieve the Driver Binding Protocol associated with each Driver Binding Handle
+ //
+ Status = CoreHandleProtocol (
+ DriverBindingHandleBuffer[Index],
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **)&DriverBinding
+ );
+ //
+ // If the ImageHandle associated with DriverBinding matches DriverBindingHandle,
+ // then add the DriverBindingProtocol[Index] to the sorted list
+ //
+ if (DriverBinding->ImageHandle == DriverBindingHandle) {
+ AddSortedDriverBindingProtocol (
+ DriverBindingHandleBuffer[Index],
+ NumberOfSortedDriverBindingProtocols,
+ SortedDriverBindingProtocols,
+ DriverBindingHandleCount,
+ DriverBindingHandleBuffer,
+ FALSE
+ );
+ }
+ }
+ return;
+ }
+
+ //
// Retrieve the Driver Binding Protocol from DriverBindingHandle
//
Status = CoreHandleProtocol(
@@ -405,13 +435,8 @@ Returns:
UINTN SortIndex;
BOOLEAN OneStarted;
BOOLEAN DriverFound;
- EFI_HANDLE DriverBindingHandle;
//
- // DriverBindingHandle is used for performance measurement, initialize it here just in case.
- //
- DriverBindingHandle = NULL;
- //
// Initialize local variables
//
DriverBindingHandleCount = 0;
@@ -452,7 +477,8 @@ Returns:
&NumberOfSortedDriverBindingProtocols,
SortedDriverBindingProtocols,
DriverBindingHandleCount,
- DriverBindingHandleBuffer
+ DriverBindingHandleBuffer,
+ FALSE
);
}
}
@@ -479,7 +505,8 @@ Returns:
&NumberOfSortedDriverBindingProtocols,
SortedDriverBindingProtocols,
DriverBindingHandleCount,
- DriverBindingHandleBuffer
+ DriverBindingHandleBuffer,
+ TRUE
);
}
} while (!EFI_ERROR (Status));
@@ -488,7 +515,7 @@ Returns:
//
// Get the Bus Specific Driver Override Protocol instance on the Controller Handle
//
- Status = CoreHandleProtocol(
+ Status = CoreHandleProtocol (
ControllerHandle,
&gEfiBusSpecificDriverOverrideProtocolGuid,
(VOID **)&BusSpecificDriverOverride
@@ -506,7 +533,8 @@ Returns:
&NumberOfSortedDriverBindingProtocols,
SortedDriverBindingProtocols,
DriverBindingHandleCount,
- DriverBindingHandleBuffer
+ DriverBindingHandleBuffer,
+ TRUE
);
}
} while (!EFI_ERROR (Status));
@@ -522,7 +550,8 @@ Returns:
&NumberOfSortedDriverBindingProtocols,
SortedDriverBindingProtocols,
DriverBindingHandleCount,
- DriverBindingHandleBuffer
+ DriverBindingHandleBuffer,
+ FALSE
);
}
@@ -593,17 +622,13 @@ Returns:
// A driver was found that supports ControllerHandle, so attempt to start the driver
// on ControllerHandle.
//
- PERF_CODE_BEGIN ();
- GetHandleFromDriverBinding (DriverBinding, &DriverBindingHandle);
- PERF_CODE_END ();
-
- PERF_START (DriverBindingHandle, DRIVERBINDING_START_TOK, NULL, 0);
+ PERF_START (DriverBinding->DriverBindingHandle, DRIVERBINDING_START_TOK, NULL, 0);
Status = DriverBinding->Start (
DriverBinding,
ControllerHandle,
RemainingDevicePath
);
- PERF_END (DriverBindingHandle, DRIVERBINDING_START_TOK, NULL, 0);
+ PERF_END (DriverBinding->DriverBindingHandle, DRIVERBINDING_START_TOK, NULL, 0);
if (!EFI_ERROR (Status)) {
//
@@ -955,74 +980,3 @@ Done:
return Status;
}
-
-EFI_STATUS
-GetHandleFromDriverBinding (
- IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindingNeed,
- OUT EFI_HANDLE *Handle
- )
-/*++
-
-Routine Description:
-
- Locate the driver binding handle which a specified driver binding protocol installed on.
-
-Arguments:
-
- DriverBindingNeed - The specified driver binding protocol.
-
- Handle - The driver binding handle which the protocol installed on.
-
-
-Returns:
-
- EFI_NOT_FOUND - Could not find the handle.
-
- EFI_SUCCESS - Successfully find the associated driver binding handle.
-
---*/
- {
- EFI_STATUS Status ;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- UINTN DriverBindingHandleCount;
- EFI_HANDLE *DriverBindingHandleBuffer;
- UINTN Index;
-
- DriverBindingHandleCount = 0;
- DriverBindingHandleBuffer = NULL;
- *Handle = NULL_HANDLE;
- Status = CoreLocateHandleBuffer (
- ByProtocol,
- &gEfiDriverBindingProtocolGuid,
- NULL,
- &DriverBindingHandleCount,
- &DriverBindingHandleBuffer
- );
- if (EFI_ERROR (Status) || DriverBindingHandleCount == 0) {
- return EFI_NOT_FOUND;
- }
-
- for (Index = 0 ; Index < DriverBindingHandleCount; Index++ ) {
- Status = CoreOpenProtocol(
- DriverBindingHandleBuffer[Index],
- &gEfiDriverBindingProtocolGuid,
- (VOID **)&DriverBinding,
- gDxeCoreImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (!EFI_ERROR (Status) && DriverBinding != NULL) {
-
- if ( DriverBinding == DriverBindingNeed ) {
- *Handle = DriverBindingHandleBuffer[Index];
- CoreFreePool (DriverBindingHandleBuffer);
- return EFI_SUCCESS ;
- }
- }
- }
-
- CoreFreePool (DriverBindingHandleBuffer);
- return EFI_NOT_FOUND ;
-}
-