2008-05-21 03:40:12 +02:00
|
|
|
/** @file
|
2008-04-09 09:07:50 +02:00
|
|
|
Support functions to connect/disconnect UEFI Driver model Protocol
|
|
|
|
|
2008-05-21 03:40:12 +02:00
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation. <BR>
|
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-04-09 09:07:50 +02:00
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
|
2008-08-27 16:29:23 +02:00
|
|
|
#include "DxeMain.h"
|
2008-09-23 09:35:34 +02:00
|
|
|
#include "Handle.h"
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Driver Support Functions
|
|
|
|
//
|
2008-05-09 09:08:30 +02:00
|
|
|
/**
|
|
|
|
Connects one or more drivers to a controller.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param ControllerHandle Handle of the controller to be
|
|
|
|
connected.
|
|
|
|
@param DriverImageHandle DriverImageHandle A pointer to an
|
|
|
|
ordered list of driver image
|
|
|
|
handles.
|
|
|
|
@param RemainingDevicePath RemainingDevicePath A pointer to
|
|
|
|
the device path that specifies a
|
|
|
|
child of the controller specified
|
|
|
|
by ControllerHandle.
|
|
|
|
@param Recursive Whether the function would be
|
|
|
|
called recursively or not.
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
@return Status code.
|
|
|
|
|
|
|
|
**/
|
2008-07-24 04:54:45 +02:00
|
|
|
EFI_STATUS
|
2007-07-04 12:51:54 +02:00
|
|
|
EFIAPI
|
|
|
|
CoreConnectController (
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_HANDLE *DriverImageHandle OPTIONAL,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
|
|
|
|
IN BOOLEAN Recursive
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_STATUS ReturnStatus;
|
|
|
|
IHANDLE *Handle;
|
|
|
|
PROTOCOL_INTERFACE *Prot;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
LIST_ENTRY *ProtLink;
|
|
|
|
OPEN_PROTOCOL_DATA *OpenData;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *AlignedRemainingDevicePath;
|
2007-09-14 23:35:03 +02:00
|
|
|
EFI_HANDLE *ChildHandleBuffer;
|
|
|
|
UINTN ChildHandleCount;
|
|
|
|
UINTN Index;
|
2008-07-24 04:54:45 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Make sure ControllerHandle is valid
|
|
|
|
//
|
|
|
|
Status = CoreValidateHandle (ControllerHandle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle = ControllerHandle;
|
|
|
|
|
|
|
|
//
|
2007-09-14 23:35:03 +02:00
|
|
|
// Make a copy of RemainingDevicePath to guanatee it is aligned
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
AlignedRemainingDevicePath = NULL;
|
|
|
|
if (RemainingDevicePath != NULL) {
|
2008-08-27 16:29:23 +02:00
|
|
|
AlignedRemainingDevicePath = DuplicateDevicePath (RemainingDevicePath);
|
2008-09-09 04:39:44 +02:00
|
|
|
|
|
|
|
if (AlignedRemainingDevicePath == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2007-09-14 23:35:03 +02:00
|
|
|
// Connect all drivers to ControllerHandle
|
|
|
|
// If CoreConnectSingleController returns EFI_NOT_READY, then the number of
|
|
|
|
// Driver Binding Protocols in the handle database has increased during the call
|
|
|
|
// so the connect operation must be restarted
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
2007-09-14 23:35:03 +02:00
|
|
|
do {
|
|
|
|
ReturnStatus = CoreConnectSingleController (
|
2008-07-18 11:50:09 +02:00
|
|
|
ControllerHandle,
|
|
|
|
DriverImageHandle,
|
|
|
|
AlignedRemainingDevicePath
|
|
|
|
);
|
2007-09-14 23:35:03 +02:00
|
|
|
} while (ReturnStatus == EFI_NOT_READY);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free the aligned copy of RemainingDevicePath
|
|
|
|
//
|
|
|
|
if (AlignedRemainingDevicePath != NULL) {
|
|
|
|
CoreFreePool (AlignedRemainingDevicePath);
|
2007-07-04 12:51:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// If recursive, then connect all drivers to all of ControllerHandle's children
|
|
|
|
//
|
2007-09-14 23:35:03 +02:00
|
|
|
if (Recursive) {
|
|
|
|
//
|
|
|
|
// Acquire the protocol lock on the handle database so the child handles can be collected
|
|
|
|
//
|
|
|
|
CoreAcquireProtocolLock ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure the DriverBindingHandle is valid
|
|
|
|
//
|
|
|
|
Status = CoreValidateHandle (ControllerHandle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Release the protocol lock on the handle database
|
|
|
|
//
|
|
|
|
CoreReleaseProtocolLock ();
|
|
|
|
|
|
|
|
return ReturnStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Count ControllerHandle's children
|
|
|
|
//
|
|
|
|
for (Link = Handle->Protocols.ForwardLink, ChildHandleCount = 0; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
|
|
|
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
2008-07-24 04:54:45 +02:00
|
|
|
for (ProtLink = Prot->OpenList.ForwardLink;
|
|
|
|
ProtLink != &Prot->OpenList;
|
2007-09-14 23:35:03 +02:00
|
|
|
ProtLink = ProtLink->ForwardLink) {
|
|
|
|
OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
|
|
|
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
|
|
|
ChildHandleCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate a handle buffer for ControllerHandle's children
|
|
|
|
//
|
2008-08-27 16:29:23 +02:00
|
|
|
ChildHandleBuffer = AllocatePool (ChildHandleCount * sizeof(EFI_HANDLE));
|
2008-09-09 04:39:44 +02:00
|
|
|
if (ChildHandleBuffer == NULL) {
|
2008-09-10 08:30:40 +02:00
|
|
|
CoreReleaseProtocolLock ();
|
2008-09-09 04:39:44 +02:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
2007-09-14 23:35:03 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Fill in a handle buffer with ControllerHandle's children
|
|
|
|
//
|
|
|
|
for (Link = Handle->Protocols.ForwardLink, ChildHandleCount = 0; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
|
|
|
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
2008-07-24 04:54:45 +02:00
|
|
|
for (ProtLink = Prot->OpenList.ForwardLink;
|
|
|
|
ProtLink != &Prot->OpenList;
|
2007-09-14 23:35:03 +02:00
|
|
|
ProtLink = ProtLink->ForwardLink) {
|
2007-07-04 12:51:54 +02:00
|
|
|
OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
|
|
|
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
2007-09-14 23:35:03 +02:00
|
|
|
ChildHandleBuffer[ChildHandleCount] = OpenData->ControllerHandle;
|
|
|
|
ChildHandleCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Release the protocol lock on the handle database
|
|
|
|
//
|
|
|
|
CoreReleaseProtocolLock ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Recursively connect each child handle
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < ChildHandleCount; Index++) {
|
|
|
|
CoreConnectController (
|
|
|
|
ChildHandleBuffer[Index],
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
TRUE
|
2008-07-24 04:54:45 +02:00
|
|
|
);
|
2007-09-14 23:35:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free the handle buffer of ControllerHandle's children
|
|
|
|
//
|
|
|
|
CoreFreePool (ChildHandleBuffer);
|
|
|
|
}
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
return ReturnStatus;
|
|
|
|
}
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Add Driver Binding Protocols from Context Driver Image Handles to sorted
|
|
|
|
Driver Binding Protocol list.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param DriverBindingHandle Handle of the driver binding
|
|
|
|
protocol.
|
|
|
|
@param NumberOfSortedDriverBindingProtocols Number Of sorted driver binding
|
|
|
|
protocols
|
|
|
|
@param SortedDriverBindingProtocols The sorted protocol list.
|
|
|
|
@param DriverBindingHandleCount Driver Binding Handle Count.
|
|
|
|
@param DriverBindingHandleBuffer The buffer of driver binding
|
|
|
|
protocol to be modified.
|
|
|
|
@param IsImageHandle Indicate whether
|
|
|
|
DriverBindingHandle is an image
|
|
|
|
handle
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
@return None.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 12:51:54 +02:00
|
|
|
VOID
|
|
|
|
AddSortedDriverBindingProtocol (
|
|
|
|
IN EFI_HANDLE DriverBindingHandle,
|
2008-07-24 04:54:45 +02:00
|
|
|
IN OUT UINTN *NumberOfSortedDriverBindingProtocols,
|
2007-07-04 12:51:54 +02:00
|
|
|
IN OUT EFI_DRIVER_BINDING_PROTOCOL **SortedDriverBindingProtocols,
|
|
|
|
IN UINTN DriverBindingHandleCount,
|
2007-11-30 03:35:26 +01:00
|
|
|
IN OUT EFI_HANDLE *DriverBindingHandleBuffer,
|
|
|
|
IN BOOLEAN IsImageHandle
|
2007-07-04 12:51:54 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure the DriverBindingHandle is valid
|
|
|
|
//
|
|
|
|
Status = CoreValidateHandle (DriverBindingHandle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-30 03:35:26 +01:00
|
|
|
//
|
|
|
|
// 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,
|
2008-07-18 11:50:09 +02:00
|
|
|
(VOID **) &DriverBinding
|
2007-11-30 03:35:26 +01:00
|
|
|
);
|
2007-12-10 01:43:22 +01:00
|
|
|
if (EFI_ERROR (Status) || DriverBinding == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-11-30 03:35:26 +01:00
|
|
|
//
|
|
|
|
// If the ImageHandle associated with DriverBinding matches DriverBindingHandle,
|
|
|
|
// then add the DriverBindingProtocol[Index] to the sorted list
|
|
|
|
//
|
|
|
|
if (DriverBinding->ImageHandle == DriverBindingHandle) {
|
|
|
|
AddSortedDriverBindingProtocol (
|
|
|
|
DriverBindingHandleBuffer[Index],
|
2008-07-24 04:54:45 +02:00
|
|
|
NumberOfSortedDriverBindingProtocols,
|
2007-11-30 03:35:26 +01:00
|
|
|
SortedDriverBindingProtocols,
|
|
|
|
DriverBindingHandleCount,
|
|
|
|
DriverBindingHandleBuffer,
|
|
|
|
FALSE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Retrieve the Driver Binding Protocol from DriverBindingHandle
|
|
|
|
//
|
|
|
|
Status = CoreHandleProtocol(
|
|
|
|
DriverBindingHandle,
|
|
|
|
&gEfiDriverBindingProtocolGuid,
|
2008-07-18 11:50:09 +02:00
|
|
|
(VOID **) &DriverBinding
|
2007-07-04 12:51:54 +02:00
|
|
|
);
|
|
|
|
//
|
|
|
|
// If DriverBindingHandle does not support the Driver Binding Protocol then return
|
|
|
|
//
|
|
|
|
if (EFI_ERROR (Status) || DriverBinding == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// See if DriverBinding is already in the sorted list
|
|
|
|
//
|
2007-09-14 23:35:03 +02:00
|
|
|
for (Index = 0; Index < *NumberOfSortedDriverBindingProtocols && Index < DriverBindingHandleCount; Index++) {
|
2007-07-04 12:51:54 +02:00
|
|
|
if (DriverBinding == SortedDriverBindingProtocols[Index]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Add DriverBinding to the end of the list
|
|
|
|
//
|
2007-09-14 23:35:03 +02:00
|
|
|
if (*NumberOfSortedDriverBindingProtocols < DriverBindingHandleCount) {
|
|
|
|
SortedDriverBindingProtocols[*NumberOfSortedDriverBindingProtocols] = DriverBinding;
|
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
*NumberOfSortedDriverBindingProtocols = *NumberOfSortedDriverBindingProtocols + 1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Mark the cooresponding handle in DriverBindingHandleBuffer as used
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < DriverBindingHandleCount; Index++) {
|
|
|
|
if (DriverBindingHandleBuffer[Index] == DriverBindingHandle) {
|
|
|
|
DriverBindingHandleBuffer[Index] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-07-24 04:54:45 +02:00
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Connects a controller to a driver.
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param ControllerHandle Handle of the controller to be
|
|
|
|
connected.
|
|
|
|
@param ContextDriverImageHandles DriverImageHandle A pointer to an
|
|
|
|
ordered list of driver image
|
|
|
|
handles.
|
|
|
|
@param RemainingDevicePath RemainingDevicePath A pointer to
|
|
|
|
the device path that specifies a
|
|
|
|
child of the controller
|
|
|
|
specified by ControllerHandle.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS One or more drivers were
|
|
|
|
connected to ControllerHandle.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES No enough system resources to
|
|
|
|
complete the request.
|
|
|
|
@retval EFI_NOT_FOUND No drivers were connected to
|
2008-05-09 09:08:30 +02:00
|
|
|
ControllerHandle.
|
|
|
|
|
|
|
|
**/
|
2008-07-24 04:54:45 +02:00
|
|
|
EFI_STATUS
|
2007-07-04 12:51:54 +02:00
|
|
|
CoreConnectSingleController (
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,
|
2008-07-24 04:54:45 +02:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
2007-07-04 12:51:54 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_HANDLE DriverImageHandle;
|
|
|
|
EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *PlatformDriverOverride;
|
|
|
|
EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;
|
|
|
|
UINTN DriverBindingHandleCount;
|
|
|
|
EFI_HANDLE *DriverBindingHandleBuffer;
|
2007-12-10 01:43:22 +01:00
|
|
|
UINTN NewDriverBindingHandleCount;
|
|
|
|
EFI_HANDLE *NewDriverBindingHandleBuffer;
|
2007-07-04 12:51:54 +02:00
|
|
|
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
|
|
|
UINTN NumberOfSortedDriverBindingProtocols;
|
|
|
|
EFI_DRIVER_BINDING_PROTOCOL **SortedDriverBindingProtocols;
|
|
|
|
UINT32 HighestVersion;
|
|
|
|
UINTN HighestIndex;
|
|
|
|
UINTN SortIndex;
|
|
|
|
BOOLEAN OneStarted;
|
|
|
|
BOOLEAN DriverFound;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize local variables
|
|
|
|
//
|
|
|
|
DriverBindingHandleCount = 0;
|
|
|
|
DriverBindingHandleBuffer = NULL;
|
|
|
|
NumberOfSortedDriverBindingProtocols = 0;
|
|
|
|
SortedDriverBindingProtocols = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get list of all Driver Binding Protocol Instances
|
|
|
|
//
|
|
|
|
Status = CoreLocateHandleBuffer (
|
2008-07-24 04:54:45 +02:00
|
|
|
ByProtocol,
|
|
|
|
&gEfiDriverBindingProtocolGuid,
|
2007-07-04 12:51:54 +02:00
|
|
|
NULL,
|
2008-07-24 04:54:45 +02:00
|
|
|
&DriverBindingHandleCount,
|
2007-07-04 12:51:54 +02:00
|
|
|
&DriverBindingHandleBuffer
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status) || (DriverBindingHandleCount == 0)) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate a duplicate array for the sorted Driver Binding Protocol Instances
|
|
|
|
//
|
2008-08-27 16:29:23 +02:00
|
|
|
SortedDriverBindingProtocols = AllocatePool (sizeof (VOID *) * DriverBindingHandleCount);
|
2007-07-04 12:51:54 +02:00
|
|
|
if (SortedDriverBindingProtocols == NULL) {
|
|
|
|
CoreFreePool (DriverBindingHandleBuffer);
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Add Driver Binding Protocols from Context Driver Image Handles first
|
|
|
|
//
|
|
|
|
if (ContextDriverImageHandles != NULL) {
|
|
|
|
for (Index = 0; ContextDriverImageHandles[Index] != NULL; Index++) {
|
|
|
|
AddSortedDriverBindingProtocol (
|
|
|
|
ContextDriverImageHandles[Index],
|
2008-07-24 04:54:45 +02:00
|
|
|
&NumberOfSortedDriverBindingProtocols,
|
2007-07-04 12:51:54 +02:00
|
|
|
SortedDriverBindingProtocols,
|
|
|
|
DriverBindingHandleCount,
|
2007-11-30 03:35:26 +01:00
|
|
|
DriverBindingHandleBuffer,
|
|
|
|
FALSE
|
2007-07-04 12:51:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Add the Platform Driver Override Protocol drivers for ControllerHandle next
|
|
|
|
//
|
|
|
|
Status = CoreLocateProtocol (
|
2008-07-24 04:54:45 +02:00
|
|
|
&gEfiPlatformDriverOverrideProtocolGuid,
|
|
|
|
NULL,
|
2008-07-18 11:50:09 +02:00
|
|
|
(VOID **) &PlatformDriverOverride
|
2007-07-04 12:51:54 +02:00
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status) && (PlatformDriverOverride != NULL)) {
|
|
|
|
DriverImageHandle = NULL;
|
|
|
|
do {
|
|
|
|
Status = PlatformDriverOverride->GetDriver (
|
|
|
|
PlatformDriverOverride,
|
|
|
|
ControllerHandle,
|
|
|
|
&DriverImageHandle
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
AddSortedDriverBindingProtocol (
|
|
|
|
DriverImageHandle,
|
2008-07-24 04:54:45 +02:00
|
|
|
&NumberOfSortedDriverBindingProtocols,
|
2007-07-04 12:51:54 +02:00
|
|
|
SortedDriverBindingProtocols,
|
|
|
|
DriverBindingHandleCount,
|
2007-11-30 03:35:26 +01:00
|
|
|
DriverBindingHandleBuffer,
|
|
|
|
TRUE
|
2007-07-04 12:51:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} while (!EFI_ERROR (Status));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the Bus Specific Driver Override Protocol instance on the Controller Handle
|
|
|
|
//
|
2007-11-30 03:35:26 +01:00
|
|
|
Status = CoreHandleProtocol (
|
2008-07-24 04:54:45 +02:00
|
|
|
ControllerHandle,
|
|
|
|
&gEfiBusSpecificDriverOverrideProtocolGuid,
|
2008-07-18 11:50:09 +02:00
|
|
|
(VOID **) &BusSpecificDriverOverride
|
2007-07-04 12:51:54 +02:00
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status) && (BusSpecificDriverOverride != NULL)) {
|
|
|
|
DriverImageHandle = NULL;
|
|
|
|
do {
|
|
|
|
Status = BusSpecificDriverOverride->GetDriver (
|
|
|
|
BusSpecificDriverOverride,
|
|
|
|
&DriverImageHandle
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
AddSortedDriverBindingProtocol (
|
|
|
|
DriverImageHandle,
|
2008-07-24 04:54:45 +02:00
|
|
|
&NumberOfSortedDriverBindingProtocols,
|
2007-07-04 12:51:54 +02:00
|
|
|
SortedDriverBindingProtocols,
|
|
|
|
DriverBindingHandleCount,
|
2007-11-30 03:35:26 +01:00
|
|
|
DriverBindingHandleBuffer,
|
|
|
|
TRUE
|
2007-07-04 12:51:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} while (!EFI_ERROR (Status));
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Then add all the remaining Driver Binding Protocols
|
|
|
|
//
|
|
|
|
SortIndex = NumberOfSortedDriverBindingProtocols;
|
|
|
|
for (Index = 0; Index < DriverBindingHandleCount; Index++) {
|
|
|
|
AddSortedDriverBindingProtocol (
|
|
|
|
DriverBindingHandleBuffer[Index],
|
2008-07-24 04:54:45 +02:00
|
|
|
&NumberOfSortedDriverBindingProtocols,
|
2007-07-04 12:51:54 +02:00
|
|
|
SortedDriverBindingProtocols,
|
|
|
|
DriverBindingHandleCount,
|
2007-11-30 03:35:26 +01:00
|
|
|
DriverBindingHandleBuffer,
|
|
|
|
FALSE
|
2007-07-04 12:51:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free the Driver Binding Handle Buffer
|
|
|
|
//
|
|
|
|
CoreFreePool (DriverBindingHandleBuffer);
|
|
|
|
|
2007-09-14 23:35:03 +02:00
|
|
|
//
|
|
|
|
// If the number of Driver Binding Protocols has increased since this function started, then return
|
|
|
|
// EFI_NOT_READY, so it will be restarted
|
|
|
|
//
|
2007-12-10 01:43:22 +01:00
|
|
|
Status = CoreLocateHandleBuffer (
|
2008-07-24 04:54:45 +02:00
|
|
|
ByProtocol,
|
|
|
|
&gEfiDriverBindingProtocolGuid,
|
2007-12-10 01:43:22 +01:00
|
|
|
NULL,
|
2008-07-24 04:54:45 +02:00
|
|
|
&NewDriverBindingHandleCount,
|
2007-12-10 01:43:22 +01:00
|
|
|
&NewDriverBindingHandleBuffer
|
|
|
|
);
|
|
|
|
CoreFreePool (NewDriverBindingHandleBuffer);
|
|
|
|
if (NewDriverBindingHandleCount > DriverBindingHandleCount) {
|
2007-09-14 23:35:03 +02:00
|
|
|
//
|
|
|
|
// Free any buffers that were allocated with AllocatePool()
|
|
|
|
//
|
|
|
|
CoreFreePool (SortedDriverBindingProtocols);
|
|
|
|
|
|
|
|
return EFI_NOT_READY;
|
|
|
|
}
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// Sort the remaining DriverBinding Protocol based on their Version field from
|
|
|
|
// highest to lowest.
|
|
|
|
//
|
|
|
|
for ( ; SortIndex < NumberOfSortedDriverBindingProtocols; SortIndex++) {
|
|
|
|
HighestVersion = SortedDriverBindingProtocols[SortIndex]->Version;
|
|
|
|
HighestIndex = SortIndex;
|
|
|
|
for (Index = SortIndex + 1; Index < NumberOfSortedDriverBindingProtocols; Index++) {
|
|
|
|
if (SortedDriverBindingProtocols[Index]->Version > HighestVersion) {
|
|
|
|
HighestVersion = SortedDriverBindingProtocols[Index]->Version;
|
|
|
|
HighestIndex = Index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SortIndex != HighestIndex) {
|
|
|
|
DriverBinding = SortedDriverBindingProtocols[SortIndex];
|
|
|
|
SortedDriverBindingProtocols[SortIndex] = SortedDriverBindingProtocols[HighestIndex];
|
|
|
|
SortedDriverBindingProtocols[HighestIndex] = DriverBinding;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Loop until no more drivers can be started on ControllerHandle
|
|
|
|
//
|
|
|
|
OneStarted = FALSE;
|
|
|
|
do {
|
|
|
|
|
|
|
|
//
|
|
|
|
// Loop through the sorted Driver Binding Protocol Instances in order, and see if
|
2008-07-24 04:54:45 +02:00
|
|
|
// any of the Driver Binding Protocols support the controller specified by
|
2007-07-04 12:51:54 +02:00
|
|
|
// ControllerHandle.
|
|
|
|
//
|
|
|
|
DriverBinding = NULL;
|
|
|
|
DriverFound = FALSE;
|
|
|
|
for (Index = 0; (Index < NumberOfSortedDriverBindingProtocols) && !DriverFound; Index++) {
|
|
|
|
if (SortedDriverBindingProtocols[Index] != NULL) {
|
|
|
|
DriverBinding = SortedDriverBindingProtocols[Index];
|
2009-02-23 04:01:59 +01:00
|
|
|
PERF_START (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0);
|
2007-07-04 12:51:54 +02:00
|
|
|
Status = DriverBinding->Supported(
|
2008-07-24 04:54:45 +02:00
|
|
|
DriverBinding,
|
2007-07-04 12:51:54 +02:00
|
|
|
ControllerHandle,
|
|
|
|
RemainingDevicePath
|
|
|
|
);
|
2009-02-23 04:01:59 +01:00
|
|
|
PERF_END (DriverBinding->DriverBindingHandle, "DB:Support:", NULL, 0);
|
2007-07-04 12:51:54 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
SortedDriverBindingProtocols[Index] = NULL;
|
|
|
|
DriverFound = TRUE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// A driver was found that supports ControllerHandle, so attempt to start the driver
|
|
|
|
// on ControllerHandle.
|
|
|
|
//
|
2009-02-23 04:01:59 +01:00
|
|
|
PERF_START (DriverBinding->DriverBindingHandle, "DB:Start:", NULL, 0);
|
2007-07-04 12:51:54 +02:00
|
|
|
Status = DriverBinding->Start (
|
2008-07-24 04:54:45 +02:00
|
|
|
DriverBinding,
|
2007-07-04 12:51:54 +02:00
|
|
|
ControllerHandle,
|
|
|
|
RemainingDevicePath
|
|
|
|
);
|
2009-02-23 04:01:59 +01:00
|
|
|
PERF_END (DriverBinding->DriverBindingHandle, "DB:Start:", NULL, 0);
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// The driver was successfully started on ControllerHandle, so set a flag
|
|
|
|
//
|
|
|
|
OneStarted = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (DriverFound);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free any buffers that were allocated with AllocatePool()
|
|
|
|
//
|
|
|
|
CoreFreePool (SortedDriverBindingProtocols);
|
|
|
|
|
|
|
|
//
|
|
|
|
// If at least one driver was started on ControllerHandle, then return EFI_SUCCESS.
|
|
|
|
//
|
|
|
|
if (OneStarted) {
|
|
|
|
return EFI_SUCCESS;
|
2008-07-24 04:54:45 +02:00
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// If no drivers started and RemainingDevicePath is an End Device Path Node, then return EFI_SUCCESS
|
|
|
|
//
|
|
|
|
if (RemainingDevicePath != NULL) {
|
|
|
|
if (IsDevicePathEnd (RemainingDevicePath)) {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2008-07-24 04:54:45 +02:00
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Otherwise, no drivers were started on ControllerHandle, so return EFI_NOT_FOUND
|
|
|
|
//
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 09:08:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Disonnects a controller from a driver
|
|
|
|
|
2008-07-24 04:54:45 +02:00
|
|
|
@param ControllerHandle ControllerHandle The handle of
|
|
|
|
the controller from which
|
|
|
|
driver(s) are to be
|
|
|
|
disconnected.
|
|
|
|
@param DriverImageHandle DriverImageHandle The driver to
|
|
|
|
disconnect from ControllerHandle.
|
|
|
|
@param ChildHandle ChildHandle The handle of the
|
|
|
|
child to destroy.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS One or more drivers were
|
|
|
|
disconnected from the controller.
|
|
|
|
@retval EFI_SUCCESS On entry, no drivers are managing
|
|
|
|
ControllerHandle.
|
|
|
|
@retval EFI_SUCCESS DriverImageHandle is not NULL,
|
|
|
|
and on entry DriverImageHandle is
|
|
|
|
not managing ControllerHandle.
|
|
|
|
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid
|
|
|
|
EFI_HANDLE.
|
|
|
|
@retval EFI_INVALID_PARAMETER DriverImageHandle is not NULL,
|
|
|
|
and it is not a valid EFI_HANDLE.
|
|
|
|
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it
|
|
|
|
is not a valid EFI_HANDLE.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES There are not enough resources
|
|
|
|
available to disconnect any
|
|
|
|
drivers from ControllerHandle.
|
|
|
|
@retval EFI_DEVICE_ERROR The controller could not be
|
|
|
|
disconnected because of a device
|
2008-05-09 09:08:30 +02:00
|
|
|
error.
|
|
|
|
|
|
|
|
**/
|
2008-07-24 04:54:45 +02:00
|
|
|
EFI_STATUS
|
2007-07-04 12:51:54 +02:00
|
|
|
EFIAPI
|
|
|
|
CoreDisconnectController (
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_HANDLE DriverImageHandle OPTIONAL,
|
|
|
|
IN EFI_HANDLE ChildHandle OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
IHANDLE *Handle;
|
|
|
|
EFI_HANDLE *DriverImageHandleBuffer;
|
|
|
|
EFI_HANDLE *ChildBuffer;
|
|
|
|
UINTN Index;
|
|
|
|
UINTN HandleIndex;
|
|
|
|
UINTN DriverImageHandleCount;
|
|
|
|
UINTN ChildrenToStop;
|
|
|
|
UINTN ChildBufferCount;
|
|
|
|
UINTN StopCount;
|
|
|
|
BOOLEAN Duplicate;
|
|
|
|
BOOLEAN ChildHandleValid;
|
|
|
|
BOOLEAN DriverImageHandleValid;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
LIST_ENTRY *ProtLink;
|
|
|
|
OPEN_PROTOCOL_DATA *OpenData;
|
|
|
|
PROTOCOL_INTERFACE *Prot;
|
|
|
|
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure ControllerHandle is valid
|
|
|
|
//
|
|
|
|
Status = CoreValidateHandle (ControllerHandle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make sure ChildHandle is valid if it is not NULL
|
|
|
|
//
|
|
|
|
if (ChildHandle != NULL) {
|
|
|
|
Status = CoreValidateHandle (ChildHandle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle = ControllerHandle;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get list of drivers that are currently managing ControllerHandle
|
|
|
|
//
|
|
|
|
DriverImageHandleBuffer = NULL;
|
2008-07-24 04:54:45 +02:00
|
|
|
DriverImageHandleCount = 1;
|
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
if (DriverImageHandle == NULL) {
|
|
|
|
//
|
|
|
|
// Look at each protocol interface for a match
|
|
|
|
//
|
|
|
|
DriverImageHandleCount = 0;
|
|
|
|
|
|
|
|
CoreAcquireProtocolLock ();
|
|
|
|
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
|
|
|
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
2008-07-24 04:54:45 +02:00
|
|
|
for (ProtLink = Prot->OpenList.ForwardLink;
|
|
|
|
ProtLink != &Prot->OpenList;
|
2007-07-04 12:51:54 +02:00
|
|
|
ProtLink = ProtLink->ForwardLink) {
|
|
|
|
OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
|
|
|
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
|
|
|
|
DriverImageHandleCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CoreReleaseProtocolLock ();
|
2008-07-24 04:54:45 +02:00
|
|
|
|
2007-07-04 12:51:54 +02:00
|
|
|
//
|
|
|
|
// If there are no drivers managing this controller, then return EFI_SUCCESS
|
|
|
|
//
|
|
|
|
if (DriverImageHandleCount == 0) {
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
2008-08-27 16:29:23 +02:00
|
|
|
DriverImageHandleBuffer = AllocatePool (sizeof (EFI_HANDLE) * DriverImageHandleCount);
|
2007-07-04 12:51:54 +02:00
|
|
|
if (DriverImageHandleBuffer == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
DriverImageHandleCount = 0;
|
|
|
|
|
|
|
|
CoreAcquireProtocolLock ();
|
|
|
|
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
|
|
|
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
2008-07-24 04:54:45 +02:00
|
|
|
for (ProtLink = Prot->OpenList.ForwardLink;
|
|
|
|
ProtLink != &Prot->OpenList;
|
2007-07-04 12:51:54 +02:00
|
|
|
ProtLink = ProtLink->ForwardLink) {
|
|
|
|
OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
|
|
|
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
|
|
|
|
Duplicate = FALSE;
|
|
|
|
for (Index = 0; Index< DriverImageHandleCount; Index++) {
|
|
|
|
if (DriverImageHandleBuffer[Index] == OpenData->AgentHandle) {
|
|
|
|
Duplicate = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Duplicate) {
|
|
|
|
DriverImageHandleBuffer[DriverImageHandleCount] = OpenData->AgentHandle;
|
|
|
|
DriverImageHandleCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CoreReleaseProtocolLock ();
|
|
|
|
}
|
|
|
|
|
|
|
|
StopCount = 0;
|
|
|
|
for (HandleIndex = 0; HandleIndex < DriverImageHandleCount; HandleIndex++) {
|
|
|
|
|
|
|
|
if (DriverImageHandleBuffer != NULL) {
|
|
|
|
DriverImageHandle = DriverImageHandleBuffer[HandleIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the Driver Binding Protocol of the driver that is managing this controller
|
|
|
|
//
|
|
|
|
Status = CoreHandleProtocol (
|
2008-07-24 04:54:45 +02:00
|
|
|
DriverImageHandle,
|
|
|
|
&gEfiDriverBindingProtocolGuid,
|
2007-07-04 12:51:54 +02:00
|
|
|
(VOID **)&DriverBinding
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_INVALID_PARAMETER;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Look at each protocol interface for a match
|
|
|
|
//
|
|
|
|
DriverImageHandleValid = FALSE;
|
|
|
|
ChildBufferCount = 0;
|
|
|
|
|
|
|
|
CoreAcquireProtocolLock ();
|
|
|
|
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
|
|
|
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
2008-07-24 04:54:45 +02:00
|
|
|
for (ProtLink = Prot->OpenList.ForwardLink;
|
|
|
|
ProtLink != &Prot->OpenList;
|
2007-07-04 12:51:54 +02:00
|
|
|
ProtLink = ProtLink->ForwardLink) {
|
|
|
|
OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
|
|
|
if (OpenData->AgentHandle == DriverImageHandle) {
|
|
|
|
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
|
|
|
ChildBufferCount++;
|
2008-07-24 04:54:45 +02:00
|
|
|
}
|
2007-07-04 12:51:54 +02:00
|
|
|
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
|
|
|
|
DriverImageHandleValid = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CoreReleaseProtocolLock ();
|
|
|
|
|
|
|
|
if (DriverImageHandleValid) {
|
|
|
|
ChildHandleValid = FALSE;
|
|
|
|
ChildBuffer = NULL;
|
|
|
|
if (ChildBufferCount != 0) {
|
2008-08-27 16:29:23 +02:00
|
|
|
ChildBuffer = AllocatePool (sizeof (EFI_HANDLE) * ChildBufferCount);
|
2007-07-04 12:51:54 +02:00
|
|
|
if (ChildBuffer == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChildBufferCount = 0;
|
|
|
|
|
|
|
|
CoreAcquireProtocolLock ();
|
|
|
|
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
|
|
|
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
2008-07-24 04:54:45 +02:00
|
|
|
for (ProtLink = Prot->OpenList.ForwardLink;
|
|
|
|
ProtLink != &Prot->OpenList;
|
2007-07-04 12:51:54 +02:00
|
|
|
ProtLink = ProtLink->ForwardLink) {
|
|
|
|
OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
|
|
|
if ((OpenData->AgentHandle == DriverImageHandle) &&
|
|
|
|
((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0)) {
|
|
|
|
Duplicate = FALSE;
|
|
|
|
for (Index = 0; Index < ChildBufferCount; Index++) {
|
|
|
|
if (ChildBuffer[Index] == OpenData->ControllerHandle) {
|
|
|
|
Duplicate = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Duplicate) {
|
|
|
|
ChildBuffer[ChildBufferCount] = OpenData->ControllerHandle;
|
|
|
|
if (ChildHandle == ChildBuffer[ChildBufferCount]) {
|
|
|
|
ChildHandleValid = TRUE;
|
|
|
|
}
|
|
|
|
ChildBufferCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CoreReleaseProtocolLock ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ChildHandle == NULL || ChildHandleValid) {
|
|
|
|
ChildrenToStop = 0;
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
if (ChildBufferCount > 0) {
|
|
|
|
if (ChildHandle != NULL) {
|
|
|
|
ChildrenToStop = 1;
|
|
|
|
Status = DriverBinding->Stop (DriverBinding, ControllerHandle, ChildrenToStop, &ChildHandle);
|
|
|
|
} else {
|
|
|
|
ChildrenToStop = ChildBufferCount;
|
|
|
|
Status = DriverBinding->Stop (DriverBinding, ControllerHandle, ChildrenToStop, ChildBuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status) && ((ChildHandle == NULL) || (ChildBufferCount == ChildrenToStop))) {
|
|
|
|
Status = DriverBinding->Stop (DriverBinding, ControllerHandle, 0, NULL);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
StopCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ChildBuffer != NULL) {
|
|
|
|
CoreFreePool (ChildBuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StopCount > 0) {
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
} else {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
}
|
2008-07-24 04:54:45 +02:00
|
|
|
|
|
|
|
Done:
|
2007-07-04 12:51:54 +02:00
|
|
|
|
|
|
|
if (DriverImageHandleBuffer != NULL) {
|
|
|
|
CoreFreePool (DriverImageHandleBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|