MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
committed by
mergify[bot]
parent
7c7184e201
commit
1436aea4d5
@@ -9,10 +9,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include "DxeMain.h"
|
||||
#include "Handle.h"
|
||||
|
||||
|
||||
//
|
||||
// Driver Support Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Connects one or more drivers to a controller.
|
||||
|
||||
@@ -48,22 +48,22 @@ CoreConnectController (
|
||||
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;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
UINTN ChildHandleCount;
|
||||
UINTN Index;
|
||||
UINTN HandleFilePathSize;
|
||||
UINTN RemainingDevicePathSize;
|
||||
EFI_DEVICE_PATH_PROTOCOL *HandleFilePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *FilePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *TempFilePath;
|
||||
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;
|
||||
EFI_HANDLE *ChildHandleBuffer;
|
||||
UINTN ChildHandleCount;
|
||||
UINTN Index;
|
||||
UINTN HandleFilePathSize;
|
||||
UINTN RemainingDevicePathSize;
|
||||
EFI_DEVICE_PATH_PROTOCOL *HandleFilePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *FilePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *TempFilePath;
|
||||
|
||||
//
|
||||
// Make sure ControllerHandle is valid
|
||||
@@ -87,25 +87,27 @@ CoreConnectController (
|
||||
ASSERT (HandleFilePath != NULL);
|
||||
FilePath = HandleFilePath;
|
||||
TempFilePath = NULL;
|
||||
if (RemainingDevicePath != NULL && !Recursive) {
|
||||
if ((RemainingDevicePath != NULL) && !Recursive) {
|
||||
HandleFilePathSize = GetDevicePathSize (HandleFilePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
RemainingDevicePathSize = GetDevicePathSize (RemainingDevicePath);
|
||||
TempFilePath = AllocateZeroPool (HandleFilePathSize + RemainingDevicePathSize);
|
||||
TempFilePath = AllocateZeroPool (HandleFilePathSize + RemainingDevicePathSize);
|
||||
ASSERT (TempFilePath != NULL);
|
||||
CopyMem (TempFilePath, HandleFilePath, HandleFilePathSize);
|
||||
CopyMem ((UINT8 *) TempFilePath + HandleFilePathSize, RemainingDevicePath, RemainingDevicePathSize);
|
||||
CopyMem ((UINT8 *)TempFilePath + HandleFilePathSize, RemainingDevicePath, RemainingDevicePathSize);
|
||||
FilePath = TempFilePath;
|
||||
}
|
||||
|
||||
Status = gSecurity2->FileAuthentication (
|
||||
gSecurity2,
|
||||
FilePath,
|
||||
NULL,
|
||||
0,
|
||||
FALSE
|
||||
);
|
||||
gSecurity2,
|
||||
FilePath,
|
||||
NULL,
|
||||
0,
|
||||
FALSE
|
||||
);
|
||||
if (TempFilePath != NULL) {
|
||||
FreePool (TempFilePath);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -169,15 +171,15 @@ CoreConnectController (
|
||||
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);
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
for (ProtLink = Prot->OpenList.ForwardLink;
|
||||
ProtLink != &Prot->OpenList;
|
||||
ProtLink = ProtLink->ForwardLink) {
|
||||
ProtLink != &Prot->OpenList;
|
||||
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++;
|
||||
@@ -188,7 +190,7 @@ CoreConnectController (
|
||||
//
|
||||
// Allocate a handle buffer for ControllerHandle's children
|
||||
//
|
||||
ChildHandleBuffer = AllocatePool (ChildHandleCount * sizeof(EFI_HANDLE));
|
||||
ChildHandleBuffer = AllocatePool (ChildHandleCount * sizeof (EFI_HANDLE));
|
||||
if (ChildHandleBuffer == NULL) {
|
||||
CoreReleaseProtocolLock ();
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@@ -198,10 +200,11 @@ CoreConnectController (
|
||||
// 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);
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
for (ProtLink = Prot->OpenList.ForwardLink;
|
||||
ProtLink != &Prot->OpenList;
|
||||
ProtLink = ProtLink->ForwardLink) {
|
||||
ProtLink != &Prot->OpenList;
|
||||
ProtLink = ProtLink->ForwardLink)
|
||||
{
|
||||
OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
|
||||
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
||||
ChildHandleBuffer[ChildHandleCount] = OpenData->ControllerHandle;
|
||||
@@ -236,7 +239,6 @@ CoreConnectController (
|
||||
return ReturnStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add Driver Binding Protocols from Context Driver Image Handles to sorted
|
||||
Driver Binding Protocol list.
|
||||
@@ -296,11 +298,11 @@ AddSortedDriverBindingProtocol (
|
||||
// Retrieve the Driver Binding Protocol associated with each Driver Binding Handle
|
||||
//
|
||||
Status = CoreHandleProtocol (
|
||||
DriverBindingHandleBuffer[Index],
|
||||
&gEfiDriverBindingProtocolGuid,
|
||||
(VOID **) &DriverBinding
|
||||
);
|
||||
if (EFI_ERROR (Status) || DriverBinding == NULL) {
|
||||
DriverBindingHandleBuffer[Index],
|
||||
&gEfiDriverBindingProtocolGuid,
|
||||
(VOID **)&DriverBinding
|
||||
);
|
||||
if (EFI_ERROR (Status) || (DriverBinding == NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -319,21 +321,22 @@ AddSortedDriverBindingProtocol (
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the Driver Binding Protocol from DriverBindingHandle
|
||||
//
|
||||
Status = CoreHandleProtocol(
|
||||
Status = CoreHandleProtocol (
|
||||
DriverBindingHandle,
|
||||
&gEfiDriverBindingProtocolGuid,
|
||||
(VOID **) &DriverBinding
|
||||
(VOID **)&DriverBinding
|
||||
);
|
||||
//
|
||||
// If DriverBindingHandle does not support the Driver Binding Protocol then return
|
||||
//
|
||||
if (EFI_ERROR (Status) || DriverBinding == NULL) {
|
||||
if (EFI_ERROR (Status) || (DriverBinding == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,6 +355,7 @@ AddSortedDriverBindingProtocol (
|
||||
if (*NumberOfSortedDriverBindingProtocols < DriverBindingHandleCount) {
|
||||
SortedDriverBindingProtocols[*NumberOfSortedDriverBindingProtocols] = DriverBinding;
|
||||
}
|
||||
|
||||
*NumberOfSortedDriverBindingProtocols = *NumberOfSortedDriverBindingProtocols + 1;
|
||||
|
||||
//
|
||||
@@ -364,7 +368,6 @@ AddSortedDriverBindingProtocol (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Connects a controller to a driver.
|
||||
|
||||
@@ -416,12 +419,12 @@ CoreConnectSingleController (
|
||||
//
|
||||
// Initialize local variables
|
||||
//
|
||||
DriverBindingHandleCount = 0;
|
||||
DriverBindingHandleBuffer = NULL;
|
||||
NumberOfSortedDriverBindingProtocols = 0;
|
||||
SortedDriverBindingProtocols = NULL;
|
||||
PlatformDriverOverride = NULL;
|
||||
NewDriverBindingHandleBuffer = NULL;
|
||||
DriverBindingHandleCount = 0;
|
||||
DriverBindingHandleBuffer = NULL;
|
||||
NumberOfSortedDriverBindingProtocols = 0;
|
||||
SortedDriverBindingProtocols = NULL;
|
||||
PlatformDriverOverride = NULL;
|
||||
NewDriverBindingHandleBuffer = NULL;
|
||||
|
||||
//
|
||||
// Get list of all Driver Binding Protocol Instances
|
||||
@@ -468,7 +471,7 @@ CoreConnectSingleController (
|
||||
Status = CoreLocateProtocol (
|
||||
&gEfiPlatformDriverOverrideProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &PlatformDriverOverride
|
||||
(VOID **)&PlatformDriverOverride
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (PlatformDriverOverride != NULL)) {
|
||||
DriverImageHandle = NULL;
|
||||
@@ -501,7 +504,7 @@ CoreConnectSingleController (
|
||||
Status = CoreHandleProtocol (
|
||||
DriverBindingHandleBuffer[Index],
|
||||
&gEfiDriverFamilyOverrideProtocolGuid,
|
||||
(VOID **) &DriverFamilyOverride
|
||||
(VOID **)&DriverFamilyOverride
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (DriverFamilyOverride != NULL)) {
|
||||
DriverFamilyOverrideVersion = DriverFamilyOverride->GetVersion (DriverFamilyOverride);
|
||||
@@ -532,7 +535,7 @@ CoreConnectSingleController (
|
||||
Status = CoreHandleProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiBusSpecificDriverOverrideProtocolGuid,
|
||||
(VOID **) &BusSpecificDriverOverride
|
||||
(VOID **)&BusSpecificDriverOverride
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (BusSpecificDriverOverride != NULL)) {
|
||||
DriverImageHandle = NULL;
|
||||
@@ -608,9 +611,10 @@ CoreConnectSingleController (
|
||||
HighestIndex = Index;
|
||||
}
|
||||
}
|
||||
|
||||
if (SortIndex != HighestIndex) {
|
||||
DriverBinding = SortedDriverBindingProtocols[SortIndex];
|
||||
SortedDriverBindingProtocols[SortIndex] = SortedDriverBindingProtocols[HighestIndex];
|
||||
DriverBinding = SortedDriverBindingProtocols[SortIndex];
|
||||
SortedDriverBindingProtocols[SortIndex] = SortedDriverBindingProtocols[HighestIndex];
|
||||
SortedDriverBindingProtocols[HighestIndex] = DriverBinding;
|
||||
}
|
||||
}
|
||||
@@ -620,19 +624,18 @@ CoreConnectSingleController (
|
||||
//
|
||||
OneStarted = FALSE;
|
||||
do {
|
||||
|
||||
//
|
||||
// Loop through the sorted Driver Binding Protocol Instances in order, and see if
|
||||
// any of the Driver Binding Protocols support the controller specified by
|
||||
// ControllerHandle.
|
||||
//
|
||||
DriverBinding = NULL;
|
||||
DriverFound = FALSE;
|
||||
DriverFound = FALSE;
|
||||
for (Index = 0; (Index < NumberOfSortedDriverBindingProtocols) && !DriverFound; Index++) {
|
||||
if (SortedDriverBindingProtocols[Index] != NULL) {
|
||||
DriverBinding = SortedDriverBindingProtocols[Index];
|
||||
PERF_DRIVER_BINDING_SUPPORT_BEGIN (DriverBinding->DriverBindingHandle, ControllerHandle);
|
||||
Status = DriverBinding->Supported(
|
||||
Status = DriverBinding->Supported (
|
||||
DriverBinding,
|
||||
ControllerHandle,
|
||||
RemainingDevicePath
|
||||
@@ -640,7 +643,7 @@ CoreConnectSingleController (
|
||||
PERF_DRIVER_BINDING_SUPPORT_END (DriverBinding->DriverBindingHandle, ControllerHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SortedDriverBindingProtocols[Index] = NULL;
|
||||
DriverFound = TRUE;
|
||||
DriverFound = TRUE;
|
||||
|
||||
//
|
||||
// A driver was found that supports ControllerHandle, so attempt to start the driver
|
||||
@@ -692,8 +695,6 @@ CoreConnectSingleController (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Disonnects a controller from a driver
|
||||
|
||||
@@ -734,24 +735,24 @@ CoreDisconnectController (
|
||||
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;
|
||||
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
|
||||
@@ -793,16 +794,18 @@ CoreDisconnectController (
|
||||
|
||||
CoreAcquireProtocolLock ();
|
||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
for (ProtLink = Prot->OpenList.ForwardLink;
|
||||
ProtLink != &Prot->OpenList;
|
||||
ProtLink = ProtLink->ForwardLink) {
|
||||
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 ();
|
||||
|
||||
//
|
||||
@@ -823,19 +826,21 @@ CoreDisconnectController (
|
||||
|
||||
CoreAcquireProtocolLock ();
|
||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
for (ProtLink = Prot->OpenList.ForwardLink;
|
||||
ProtLink != &Prot->OpenList;
|
||||
ProtLink = ProtLink->ForwardLink) {
|
||||
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++) {
|
||||
for (Index = 0; Index < DriverImageHandleCount; Index++) {
|
||||
if (DriverImageHandleBuffer[Index] == OpenData->AgentHandle) {
|
||||
Duplicate = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Duplicate) {
|
||||
DriverImageHandleBuffer[DriverImageHandleCount] = OpenData->AgentHandle;
|
||||
DriverImageHandleCount++;
|
||||
@@ -843,12 +848,12 @@ CoreDisconnectController (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
}
|
||||
|
||||
StopCount = 0;
|
||||
for (HandleIndex = 0; HandleIndex < DriverImageHandleCount; HandleIndex++) {
|
||||
|
||||
if (DriverImageHandleBuffer != NULL) {
|
||||
DriverImageHandle = DriverImageHandleBuffer[HandleIndex];
|
||||
}
|
||||
@@ -861,7 +866,7 @@ CoreDisconnectController (
|
||||
&gEfiDriverBindingProtocolGuid,
|
||||
(VOID **)&DriverBinding
|
||||
);
|
||||
if (EFI_ERROR (Status) || DriverBinding == NULL) {
|
||||
if (EFI_ERROR (Status) || (DriverBinding == NULL)) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
@@ -870,30 +875,33 @@ CoreDisconnectController (
|
||||
// Look at each protocol interface for a match
|
||||
//
|
||||
DriverImageHandleValid = FALSE;
|
||||
ChildBufferCount = 0;
|
||||
ChildBufferCount = 0;
|
||||
|
||||
CoreAcquireProtocolLock ();
|
||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
for (ProtLink = Prot->OpenList.ForwardLink;
|
||||
ProtLink != &Prot->OpenList;
|
||||
ProtLink = ProtLink->ForwardLink) {
|
||||
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++;
|
||||
}
|
||||
|
||||
if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
|
||||
DriverImageHandleValid = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
|
||||
if (DriverImageHandleValid) {
|
||||
ChildHandleValid = FALSE;
|
||||
ChildBuffer = NULL;
|
||||
ChildBuffer = NULL;
|
||||
if (ChildBufferCount != 0) {
|
||||
ChildBuffer = AllocatePool (sizeof (EFI_HANDLE) * ChildBufferCount);
|
||||
if (ChildBuffer == NULL) {
|
||||
@@ -905,13 +913,15 @@ CoreDisconnectController (
|
||||
|
||||
CoreAcquireProtocolLock ();
|
||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
for (ProtLink = Prot->OpenList.ForwardLink;
|
||||
ProtLink != &Prot->OpenList;
|
||||
ProtLink = ProtLink->ForwardLink) {
|
||||
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)) {
|
||||
((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0))
|
||||
{
|
||||
Duplicate = FALSE;
|
||||
for (Index = 0; Index < ChildBufferCount; Index++) {
|
||||
if (ChildBuffer[Index] == OpenData->ControllerHandle) {
|
||||
@@ -919,34 +929,39 @@ CoreDisconnectController (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Duplicate) {
|
||||
ChildBuffer[ChildBufferCount] = OpenData->ControllerHandle;
|
||||
if (ChildHandle == ChildBuffer[ChildBufferCount]) {
|
||||
ChildHandleValid = TRUE;
|
||||
}
|
||||
|
||||
ChildBufferCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
}
|
||||
|
||||
if (ChildHandle == NULL || ChildHandleValid) {
|
||||
if ((ChildHandle == NULL) || ChildHandleValid) {
|
||||
ChildrenToStop = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
if (ChildBufferCount > 0) {
|
||||
if (ChildHandle != NULL) {
|
||||
ChildrenToStop = 1;
|
||||
Status = DriverBinding->Stop (DriverBinding, ControllerHandle, ChildrenToStop, &ChildHandle);
|
||||
Status = DriverBinding->Stop (DriverBinding, ControllerHandle, ChildrenToStop, &ChildHandle);
|
||||
} else {
|
||||
ChildrenToStop = ChildBufferCount;
|
||||
Status = DriverBinding->Stop (DriverBinding, ControllerHandle, ChildrenToStop, ChildBuffer);
|
||||
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++;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -9,26 +9,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _HAND_H_
|
||||
#define _HAND_H_
|
||||
|
||||
|
||||
#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
|
||||
#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
|
||||
|
||||
///
|
||||
/// IHANDLE - contains a list of protocol handles
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
/// All handles list of IHANDLE
|
||||
LIST_ENTRY AllHandles;
|
||||
LIST_ENTRY AllHandles;
|
||||
/// List of PROTOCOL_INTERFACE's for this handle
|
||||
LIST_ENTRY Protocols;
|
||||
UINTN LocateRequest;
|
||||
LIST_ENTRY Protocols;
|
||||
UINTN LocateRequest;
|
||||
/// The Handle Database Key value when this handle was last created or modified
|
||||
UINT64 Key;
|
||||
UINT64 Key;
|
||||
} IHANDLE;
|
||||
|
||||
#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
|
||||
|
||||
#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
|
||||
#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
|
||||
|
||||
///
|
||||
/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
|
||||
@@ -36,18 +35,17 @@ typedef struct {
|
||||
/// with a list of registered notifies.
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
/// Link Entry inserted to mProtocolDatabase
|
||||
LIST_ENTRY AllEntries;
|
||||
LIST_ENTRY AllEntries;
|
||||
/// ID of the protocol
|
||||
EFI_GUID ProtocolID;
|
||||
EFI_GUID ProtocolID;
|
||||
/// All protocol interfaces
|
||||
LIST_ENTRY Protocols;
|
||||
LIST_ENTRY Protocols;
|
||||
/// Registerd notification handlers
|
||||
LIST_ENTRY Notify;
|
||||
LIST_ENTRY Notify;
|
||||
} PROTOCOL_ENTRY;
|
||||
|
||||
|
||||
#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
|
||||
|
||||
///
|
||||
@@ -55,55 +53,51 @@ typedef struct {
|
||||
/// with a protocol interface structure
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
UINTN Signature;
|
||||
/// Link on IHANDLE.Protocols
|
||||
LIST_ENTRY Link;
|
||||
LIST_ENTRY Link;
|
||||
/// Back pointer
|
||||
IHANDLE *Handle;
|
||||
IHANDLE *Handle;
|
||||
/// Link on PROTOCOL_ENTRY.Protocols
|
||||
LIST_ENTRY ByProtocol;
|
||||
LIST_ENTRY ByProtocol;
|
||||
/// The protocol ID
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
/// The interface value
|
||||
VOID *Interface;
|
||||
VOID *Interface;
|
||||
/// OPEN_PROTOCOL_DATA list
|
||||
LIST_ENTRY OpenList;
|
||||
UINTN OpenListCount;
|
||||
|
||||
LIST_ENTRY OpenList;
|
||||
UINTN OpenListCount;
|
||||
} PROTOCOL_INTERFACE;
|
||||
|
||||
#define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
///Link on PROTOCOL_INTERFACE.OpenList
|
||||
LIST_ENTRY Link;
|
||||
UINTN Signature;
|
||||
/// Link on PROTOCOL_INTERFACE.OpenList
|
||||
LIST_ENTRY Link;
|
||||
|
||||
EFI_HANDLE AgentHandle;
|
||||
EFI_HANDLE ControllerHandle;
|
||||
UINT32 Attributes;
|
||||
UINT32 OpenCount;
|
||||
EFI_HANDLE AgentHandle;
|
||||
EFI_HANDLE ControllerHandle;
|
||||
UINT32 Attributes;
|
||||
UINT32 OpenCount;
|
||||
} OPEN_PROTOCOL_DATA;
|
||||
|
||||
|
||||
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
|
||||
#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
|
||||
|
||||
///
|
||||
/// PROTOCOL_NOTIFY - used for each register notification for a protocol
|
||||
///
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
UINTN Signature;
|
||||
PROTOCOL_ENTRY *Protocol;
|
||||
/// All notifications for this protocol
|
||||
LIST_ENTRY Link;
|
||||
LIST_ENTRY Link;
|
||||
/// Event to notify
|
||||
EFI_EVENT Event;
|
||||
EFI_EVENT Event;
|
||||
/// Last position notified
|
||||
LIST_ENTRY *Position;
|
||||
LIST_ENTRY *Position;
|
||||
} PROTOCOL_NOTIFY;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Finds the protocol entry for the requested protocol.
|
||||
The gProtocolDatabaseLock must be owned
|
||||
@@ -116,11 +110,10 @@ typedef struct {
|
||||
**/
|
||||
PROTOCOL_ENTRY *
|
||||
CoreFindProtocolEntry (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN BOOLEAN Create
|
||||
IN EFI_GUID *Protocol,
|
||||
IN BOOLEAN Create
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Signal event for every protocol in protocol entry.
|
||||
|
||||
@@ -129,10 +122,9 @@ CoreFindProtocolEntry (
|
||||
**/
|
||||
VOID
|
||||
CoreNotifyProtocolEntry (
|
||||
IN PROTOCOL_ENTRY *ProtEntry
|
||||
IN PROTOCOL_ENTRY *ProtEntry
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Finds the protocol instance for the requested handle and protocol.
|
||||
Note: This function doesn't do parameters checking, it's caller's responsibility
|
||||
@@ -147,12 +139,11 @@ CoreNotifyProtocolEntry (
|
||||
**/
|
||||
PROTOCOL_INTERFACE *
|
||||
CoreFindProtocolInterface (
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Removes Protocol from the protocol list (but not the handle list).
|
||||
|
||||
@@ -165,12 +156,11 @@ CoreFindProtocolInterface (
|
||||
**/
|
||||
PROTOCOL_INTERFACE *
|
||||
CoreRemoveInterfaceFromProtocol (
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Connects a controller to a driver.
|
||||
|
||||
@@ -215,11 +205,10 @@ CoreConnectSingleController (
|
||||
**/
|
||||
EFI_STATUS
|
||||
CoreDisconnectControllersUsingProtocolInterface (
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN PROTOCOL_INTERFACE *Prot
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN PROTOCOL_INTERFACE *Prot
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Acquire lock on gProtocolDatabaseLock.
|
||||
|
||||
@@ -229,7 +218,6 @@ CoreAcquireProtocolLock (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Release lock on gProtocolDatabaseLock.
|
||||
|
||||
@@ -239,7 +227,6 @@ CoreReleaseProtocolLock (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Check whether a handle is a valid EFI_HANDLE
|
||||
The gProtocolDatabaseLock must be owned
|
||||
@@ -252,14 +239,14 @@ CoreReleaseProtocolLock (
|
||||
**/
|
||||
EFI_STATUS
|
||||
CoreValidateHandle (
|
||||
IN EFI_HANDLE UserHandle
|
||||
IN EFI_HANDLE UserHandle
|
||||
);
|
||||
|
||||
//
|
||||
// Externs
|
||||
//
|
||||
extern EFI_LOCK gProtocolDatabaseLock;
|
||||
extern LIST_ENTRY gHandleList;
|
||||
extern UINT64 gHandleDatabaseKey;
|
||||
extern EFI_LOCK gProtocolDatabaseLock;
|
||||
extern LIST_ENTRY gHandleList;
|
||||
extern UINT64 gHandleDatabaseKey;
|
||||
|
||||
#endif
|
||||
|
@@ -12,24 +12,24 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// ProtocolRequest - Last LocateHandle request ID
|
||||
//
|
||||
UINTN mEfiLocateHandleRequest = 0;
|
||||
UINTN mEfiLocateHandleRequest = 0;
|
||||
|
||||
//
|
||||
// Internal prototypes
|
||||
//
|
||||
|
||||
typedef struct {
|
||||
EFI_GUID *Protocol;
|
||||
VOID *SearchKey;
|
||||
LIST_ENTRY *Position;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
EFI_GUID *Protocol;
|
||||
VOID *SearchKey;
|
||||
LIST_ENTRY *Position;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
} LOCATE_POSITION;
|
||||
|
||||
typedef
|
||||
IHANDLE *
|
||||
(* CORE_GET_NEXT) (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
(*CORE_GET_NEXT) (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -45,8 +45,8 @@ IHANDLE *
|
||||
**/
|
||||
IHANDLE *
|
||||
CoreGetNextLocateAllHandles (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -63,8 +63,8 @@ CoreGetNextLocateAllHandles (
|
||||
**/
|
||||
IHANDLE *
|
||||
CoreGetNextLocateByRegisterNotify (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -80,11 +80,10 @@ CoreGetNextLocateByRegisterNotify (
|
||||
**/
|
||||
IHANDLE *
|
||||
CoreGetNextLocateByProtocol (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Internal function for locating the requested handle(s) and returns them in Buffer.
|
||||
The caller should already have acquired the ProtocolLock.
|
||||
@@ -106,21 +105,21 @@ CoreGetNextLocateByProtocol (
|
||||
**/
|
||||
EFI_STATUS
|
||||
InternalCoreLocateHandle (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_HANDLE *Buffer
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_HANDLE *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LOCATE_POSITION Position;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
CORE_GET_NEXT GetNext;
|
||||
UINTN ResultSize;
|
||||
IHANDLE *Handle;
|
||||
IHANDLE **ResultBuffer;
|
||||
VOID *Interface;
|
||||
EFI_STATUS Status;
|
||||
LOCATE_POSITION Position;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
CORE_GET_NEXT GetNext;
|
||||
UINTN ResultSize;
|
||||
IHANDLE *Handle;
|
||||
IHANDLE **ResultBuffer;
|
||||
VOID *Interface;
|
||||
|
||||
if (BufferSize == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -139,52 +138,55 @@ InternalCoreLocateHandle (
|
||||
Position.SearchKey = SearchKey;
|
||||
Position.Position = &gHandleList;
|
||||
|
||||
ResultSize = 0;
|
||||
ResultBuffer = (IHANDLE **) Buffer;
|
||||
Status = EFI_SUCCESS;
|
||||
ResultSize = 0;
|
||||
ResultBuffer = (IHANDLE **)Buffer;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// Get the search function based on type
|
||||
//
|
||||
switch (SearchType) {
|
||||
case AllHandles:
|
||||
GetNext = CoreGetNextLocateAllHandles;
|
||||
break;
|
||||
case AllHandles:
|
||||
GetNext = CoreGetNextLocateAllHandles;
|
||||
break;
|
||||
|
||||
case ByRegisterNotify:
|
||||
//
|
||||
// Must have SearchKey for locate ByRegisterNotify
|
||||
//
|
||||
if (SearchKey == NULL) {
|
||||
case ByRegisterNotify:
|
||||
//
|
||||
// Must have SearchKey for locate ByRegisterNotify
|
||||
//
|
||||
if (SearchKey == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
GetNext = CoreGetNextLocateByRegisterNotify;
|
||||
break;
|
||||
|
||||
case ByProtocol:
|
||||
GetNext = CoreGetNextLocateByProtocol;
|
||||
if (Protocol == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Look up the protocol entry and set the head pointer
|
||||
//
|
||||
Position.ProtEntry = CoreFindProtocolEntry (Protocol, FALSE);
|
||||
if (Position.ProtEntry == NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
Position.Position = &Position.ProtEntry->Protocols;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
GetNext = CoreGetNextLocateByRegisterNotify;
|
||||
break;
|
||||
|
||||
case ByProtocol:
|
||||
GetNext = CoreGetNextLocateByProtocol;
|
||||
if (Protocol == NULL) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Look up the protocol entry and set the head pointer
|
||||
//
|
||||
Position.ProtEntry = CoreFindProtocolEntry (Protocol, FALSE);
|
||||
if (Position.ProtEntry == NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
Position.Position = &Position.ProtEntry->Protocols;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -193,7 +195,7 @@ InternalCoreLocateHandle (
|
||||
// Enumerate out the matching handles
|
||||
//
|
||||
mEfiLocateHandleRequest += 1;
|
||||
for (; ;) {
|
||||
for ( ; ;) {
|
||||
//
|
||||
// Get the next handle. If no more handles, stop
|
||||
//
|
||||
@@ -206,10 +208,10 @@ InternalCoreLocateHandle (
|
||||
// Increase the resulting buffer size, and if this handle
|
||||
// fits return it
|
||||
//
|
||||
ResultSize += sizeof(Handle);
|
||||
ResultSize += sizeof (Handle);
|
||||
if (ResultSize <= *BufferSize) {
|
||||
*ResultBuffer = Handle;
|
||||
ResultBuffer += 1;
|
||||
*ResultBuffer = Handle;
|
||||
ResultBuffer += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,13 +232,13 @@ InternalCoreLocateHandle (
|
||||
|
||||
*BufferSize = ResultSize;
|
||||
|
||||
if (SearchType == ByRegisterNotify && !EFI_ERROR(Status)) {
|
||||
if ((SearchType == ByRegisterNotify) && !EFI_ERROR (Status)) {
|
||||
//
|
||||
// If this is a search by register notify and a handle was
|
||||
// returned, update the register notification position
|
||||
//
|
||||
ASSERT (SearchKey != NULL);
|
||||
ProtNotify = SearchKey;
|
||||
ProtNotify = SearchKey;
|
||||
ProtNotify->Position = ProtNotify->Position->ForwardLink;
|
||||
}
|
||||
}
|
||||
@@ -265,25 +267,24 @@ InternalCoreLocateHandle (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CoreLocateHandle (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_HANDLE *Buffer
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT EFI_HANDLE *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Lock the protocol database
|
||||
//
|
||||
CoreAcquireProtocolLock ();
|
||||
Status = InternalCoreLocateHandle(SearchType, Protocol, SearchKey, BufferSize, Buffer);
|
||||
Status = InternalCoreLocateHandle (SearchType, Protocol, SearchKey, BufferSize, Buffer);
|
||||
CoreReleaseProtocolLock ();
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Routine to get the next Handle, when you are searching for all handles.
|
||||
|
||||
@@ -297,11 +298,11 @@ CoreLocateHandle (
|
||||
**/
|
||||
IHANDLE *
|
||||
CoreGetNextLocateAllHandles (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
)
|
||||
{
|
||||
IHANDLE *Handle;
|
||||
IHANDLE *Handle;
|
||||
|
||||
//
|
||||
// Next handle
|
||||
@@ -311,8 +312,8 @@ CoreGetNextLocateAllHandles (
|
||||
//
|
||||
// If not at the end of the list, get the handle
|
||||
//
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
if (Position->Position != &gHandleList) {
|
||||
Handle = CR (Position->Position, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
|
||||
}
|
||||
@@ -320,8 +321,6 @@ CoreGetNextLocateAllHandles (
|
||||
return Handle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Routine to get the next Handle, when you are searching for register protocol
|
||||
notifies.
|
||||
@@ -336,8 +335,8 @@ CoreGetNextLocateAllHandles (
|
||||
**/
|
||||
IHANDLE *
|
||||
CoreGetNextLocateByRegisterNotify (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
)
|
||||
{
|
||||
IHANDLE *Handle;
|
||||
@@ -345,15 +344,15 @@ CoreGetNextLocateByRegisterNotify (
|
||||
PROTOCOL_INTERFACE *Prot;
|
||||
LIST_ENTRY *Link;
|
||||
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
ProtNotify = Position->SearchKey;
|
||||
|
||||
//
|
||||
// If this is the first request, get the next handle
|
||||
//
|
||||
if (ProtNotify != NULL) {
|
||||
ASSERT(ProtNotify->Signature == PROTOCOL_NOTIFY_SIGNATURE);
|
||||
ASSERT (ProtNotify->Signature == PROTOCOL_NOTIFY_SIGNATURE);
|
||||
Position->SearchKey = NULL;
|
||||
|
||||
//
|
||||
@@ -361,8 +360,8 @@ CoreGetNextLocateByRegisterNotify (
|
||||
//
|
||||
Link = ProtNotify->Position->ForwardLink;
|
||||
if (Link != &ProtNotify->Protocol->Protocols) {
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
*Interface = Prot->Interface;
|
||||
}
|
||||
}
|
||||
@@ -370,7 +369,6 @@ CoreGetNextLocateByRegisterNotify (
|
||||
return Handle;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Routine to get the next Handle, when you are searching for a given protocol.
|
||||
|
||||
@@ -384,21 +382,21 @@ CoreGetNextLocateByRegisterNotify (
|
||||
**/
|
||||
IHANDLE *
|
||||
CoreGetNextLocateByProtocol (
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
IN OUT LOCATE_POSITION *Position,
|
||||
OUT VOID **Interface
|
||||
)
|
||||
{
|
||||
IHANDLE *Handle;
|
||||
LIST_ENTRY *Link;
|
||||
PROTOCOL_INTERFACE *Prot;
|
||||
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
for (; ;) {
|
||||
Handle = NULL;
|
||||
*Interface = NULL;
|
||||
for ( ; ;) {
|
||||
//
|
||||
// Next entry
|
||||
//
|
||||
Link = Position->Position->ForwardLink;
|
||||
Link = Position->Position->ForwardLink;
|
||||
Position->Position = Link;
|
||||
|
||||
//
|
||||
@@ -412,8 +410,8 @@ CoreGetNextLocateByProtocol (
|
||||
//
|
||||
// Get the handle
|
||||
//
|
||||
Prot = CR(Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
|
||||
Handle = Prot->Handle;
|
||||
*Interface = Prot->Interface;
|
||||
|
||||
//
|
||||
@@ -429,7 +427,6 @@ CoreGetNextLocateByProtocol (
|
||||
return Handle;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Locates the handle to a device on the device path that supports the specified protocol.
|
||||
|
||||
@@ -449,22 +446,22 @@ CoreGetNextLocateByProtocol (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CoreLocateDevicePath (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
|
||||
OUT EFI_HANDLE *Device
|
||||
IN EFI_GUID *Protocol,
|
||||
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
|
||||
OUT EFI_HANDLE *Device
|
||||
)
|
||||
{
|
||||
INTN SourceSize;
|
||||
INTN Size;
|
||||
INTN BestMatch;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_HANDLE BestDevice;
|
||||
EFI_DEVICE_PATH_PROTOCOL *SourcePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
|
||||
INTN SourceSize;
|
||||
INTN Size;
|
||||
INTN BestMatch;
|
||||
UINTN HandleCount;
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_HANDLE BestDevice;
|
||||
EFI_DEVICE_PATH_PROTOCOL *SourcePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
|
||||
|
||||
if (Protocol == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -474,9 +471,9 @@ CoreLocateDevicePath (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Handles = NULL;
|
||||
BestDevice = NULL;
|
||||
SourcePath = *DevicePath;
|
||||
Handles = NULL;
|
||||
BestDevice = NULL;
|
||||
SourcePath = *DevicePath;
|
||||
TmpDevicePath = SourcePath;
|
||||
while (!IsDevicePathEnd (TmpDevicePath)) {
|
||||
if (IsDevicePathEndInstance (TmpDevicePath)) {
|
||||
@@ -486,21 +483,22 @@ CoreLocateDevicePath (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
TmpDevicePath = NextDevicePathNode (TmpDevicePath);
|
||||
}
|
||||
|
||||
SourceSize = (UINTN) TmpDevicePath - (UINTN) SourcePath;
|
||||
SourceSize = (UINTN)TmpDevicePath - (UINTN)SourcePath;
|
||||
|
||||
//
|
||||
// Get a list of all handles that support the requested protocol
|
||||
//
|
||||
Status = CoreLocateHandleBuffer (ByProtocol, Protocol, NULL, &HandleCount, &Handles);
|
||||
if (EFI_ERROR (Status) || HandleCount == 0) {
|
||||
if (EFI_ERROR (Status) || (HandleCount == 0)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
BestMatch = -1;
|
||||
for(Index = 0; Index < HandleCount; Index += 1) {
|
||||
for (Index = 0; Index < HandleCount; Index += 1) {
|
||||
Handle = Handles[Index];
|
||||
Status = CoreHandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&TmpDevicePath);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -513,9 +511,9 @@ CoreLocateDevicePath (
|
||||
//
|
||||
// Check if DevicePath is first part of SourcePath
|
||||
//
|
||||
Size = GetDevicePathSize (TmpDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
|
||||
Size = GetDevicePathSize (TmpDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
ASSERT (Size >= 0);
|
||||
if ((Size <= SourceSize) && CompareMem (SourcePath, TmpDevicePath, (UINTN) Size) == 0) {
|
||||
if ((Size <= SourceSize) && (CompareMem (SourcePath, TmpDevicePath, (UINTN)Size) == 0)) {
|
||||
//
|
||||
// If the size is equal to the best match, then we
|
||||
// have a duplicate device path for 2 different device
|
||||
@@ -527,7 +525,7 @@ CoreLocateDevicePath (
|
||||
// We've got a match, see if it's the best match so far
|
||||
//
|
||||
if (Size > BestMatch) {
|
||||
BestMatch = Size;
|
||||
BestMatch = Size;
|
||||
BestDevice = Handle;
|
||||
}
|
||||
}
|
||||
@@ -544,18 +542,18 @@ CoreLocateDevicePath (
|
||||
}
|
||||
|
||||
if (Device == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Device = BestDevice;
|
||||
|
||||
//
|
||||
// Return the remaining part of the device path
|
||||
//
|
||||
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) SourcePath) + BestMatch);
|
||||
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)(((UINT8 *)SourcePath) + BestMatch);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Return the first Protocol Interface that matches the Protocol GUID. If
|
||||
Registration is passed in, return a Protocol Instance that was just add
|
||||
@@ -580,17 +578,17 @@ CoreLocateProtocol (
|
||||
OUT VOID **Interface
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LOCATE_POSITION Position;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
IHANDLE *Handle;
|
||||
EFI_STATUS Status;
|
||||
LOCATE_POSITION Position;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
IHANDLE *Handle;
|
||||
|
||||
if ((Interface == NULL) || (Protocol == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Interface = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// Set initial position
|
||||
@@ -618,6 +616,7 @@ CoreLocateProtocol (
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Position.Position = &Position.ProtEntry->Protocols;
|
||||
|
||||
Handle = CoreGetNextLocateByProtocol (&Position, Interface);
|
||||
@@ -632,7 +631,7 @@ CoreLocateProtocol (
|
||||
// If this is a search by register notify and a handle was
|
||||
// returned, update the register notification position
|
||||
//
|
||||
ProtNotify = Registration;
|
||||
ProtNotify = Registration;
|
||||
ProtNotify->Position = ProtNotify->Position->ForwardLink;
|
||||
}
|
||||
|
||||
@@ -666,15 +665,15 @@ Done:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CoreLocateHandleBuffer (
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *NumberHandles,
|
||||
OUT EFI_HANDLE **Buffer
|
||||
IN EFI_LOCATE_SEARCH_TYPE SearchType,
|
||||
IN EFI_GUID *Protocol OPTIONAL,
|
||||
IN VOID *SearchKey OPTIONAL,
|
||||
IN OUT UINTN *NumberHandles,
|
||||
OUT EFI_HANDLE **Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
|
||||
if (NumberHandles == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -684,14 +683,14 @@ CoreLocateHandleBuffer (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
BufferSize = 0;
|
||||
BufferSize = 0;
|
||||
*NumberHandles = 0;
|
||||
*Buffer = NULL;
|
||||
*Buffer = NULL;
|
||||
|
||||
//
|
||||
// Lock the protocol database
|
||||
//
|
||||
CoreAcquireProtocolLock();
|
||||
CoreAcquireProtocolLock ();
|
||||
Status = InternalCoreLocateHandle (
|
||||
SearchType,
|
||||
Protocol,
|
||||
@@ -705,10 +704,11 @@ CoreLocateHandleBuffer (
|
||||
//
|
||||
// Add code to correctly handle expected errors from CoreLocateHandle().
|
||||
//
|
||||
if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) {
|
||||
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||
if (Status != EFI_INVALID_PARAMETER) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
return Status;
|
||||
}
|
||||
@@ -727,14 +727,11 @@ CoreLocateHandleBuffer (
|
||||
*Buffer
|
||||
);
|
||||
|
||||
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
|
||||
if (EFI_ERROR(Status)) {
|
||||
*NumberHandles = BufferSize / sizeof (EFI_HANDLE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
*NumberHandles = 0;
|
||||
}
|
||||
|
||||
CoreReleaseProtocolLock ();
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -19,22 +19,20 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
VOID
|
||||
CoreNotifyProtocolEntry (
|
||||
IN PROTOCOL_ENTRY *ProtEntry
|
||||
IN PROTOCOL_ENTRY *ProtEntry
|
||||
)
|
||||
{
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
LIST_ENTRY *Link;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
LIST_ENTRY *Link;
|
||||
|
||||
ASSERT_LOCKED (&gProtocolDatabaseLock);
|
||||
|
||||
for (Link=ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
|
||||
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
|
||||
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
CoreSignalEvent (ProtNotify->Event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Removes Protocol from the protocol list (but not the handle list).
|
||||
|
||||
@@ -47,9 +45,9 @@ CoreNotifyProtocolEntry (
|
||||
**/
|
||||
PROTOCOL_INTERFACE *
|
||||
CoreRemoveInterfaceFromProtocol (
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
IN IHANDLE *Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *Interface
|
||||
)
|
||||
{
|
||||
PROTOCOL_INTERFACE *Prot;
|
||||
@@ -61,14 +59,13 @@ CoreRemoveInterfaceFromProtocol (
|
||||
|
||||
Prot = CoreFindProtocolInterface (Handle, Protocol, Interface);
|
||||
if (Prot != NULL) {
|
||||
|
||||
ProtEntry = Prot->Protocol;
|
||||
|
||||
//
|
||||
// If there's a protocol notify location pointing to this entry, back it up one
|
||||
//
|
||||
for(Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
|
||||
ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
|
||||
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||
|
||||
if (ProtNotify->Position == &Prot->ByProtocol) {
|
||||
ProtNotify->Position = Prot->ByProtocol.BackLink;
|
||||
@@ -84,7 +81,6 @@ CoreRemoveInterfaceFromProtocol (
|
||||
return Prot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add a new protocol notification record for the request protocol.
|
||||
|
||||
@@ -101,16 +97,16 @@ CoreRemoveInterfaceFromProtocol (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CoreRegisterProtocolNotify (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_EVENT Event,
|
||||
OUT VOID **Registration
|
||||
IN EFI_GUID *Protocol,
|
||||
IN EFI_EVENT Event,
|
||||
OUT VOID **Registration
|
||||
)
|
||||
{
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
EFI_STATUS Status;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
PROTOCOL_NOTIFY *ProtNotify;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((Protocol == NULL) || (Event == NULL) || (Registration == NULL)) {
|
||||
if ((Protocol == NULL) || (Event == NULL) || (Registration == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -124,16 +120,15 @@ CoreRegisterProtocolNotify (
|
||||
|
||||
ProtEntry = CoreFindProtocolEntry (Protocol, TRUE);
|
||||
if (ProtEntry != NULL) {
|
||||
|
||||
//
|
||||
// Allocate a new notification record
|
||||
//
|
||||
ProtNotify = AllocatePool (sizeof(PROTOCOL_NOTIFY));
|
||||
ProtNotify = AllocatePool (sizeof (PROTOCOL_NOTIFY));
|
||||
if (ProtNotify != NULL) {
|
||||
((IEVENT *)Event)->ExFlag |= EVT_EXFLAG_EVENT_PROTOCOL_NOTIFICATION;
|
||||
ProtNotify->Signature = PROTOCOL_NOTIFY_SIGNATURE;
|
||||
ProtNotify->Protocol = ProtEntry;
|
||||
ProtNotify->Event = Event;
|
||||
ProtNotify->Signature = PROTOCOL_NOTIFY_SIGNATURE;
|
||||
ProtNotify->Protocol = ProtEntry;
|
||||
ProtNotify->Event = Event;
|
||||
//
|
||||
// start at the begining
|
||||
//
|
||||
@@ -153,13 +148,12 @@ CoreRegisterProtocolNotify (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
if (ProtNotify != NULL) {
|
||||
*Registration = ProtNotify;
|
||||
Status = EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
|
||||
|
||||
@@ -177,16 +171,16 @@ CoreRegisterProtocolNotify (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CoreReinstallProtocolInterface (
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *OldInterface,
|
||||
IN VOID *NewInterface
|
||||
IN EFI_HANDLE UserHandle,
|
||||
IN EFI_GUID *Protocol,
|
||||
IN VOID *OldInterface,
|
||||
IN VOID *NewInterface
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
IHANDLE *Handle;
|
||||
PROTOCOL_INTERFACE *Prot;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
EFI_STATUS Status;
|
||||
IHANDLE *Handle;
|
||||
PROTOCOL_INTERFACE *Prot;
|
||||
PROTOCOL_ENTRY *ProtEntry;
|
||||
|
||||
if (Protocol == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -202,7 +196,7 @@ CoreReinstallProtocolInterface (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Handle = (IHANDLE *) UserHandle;
|
||||
Handle = (IHANDLE *)UserHandle;
|
||||
//
|
||||
// Check that Protocol exists on UserHandle, and Interface matches the interface in the database
|
||||
//
|
||||
|
Reference in New Issue
Block a user