2 Support functions for managing protocol.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
16 /// IHANDLE - contains a list of protocol handles
20 /// All handles list of IHANDLE
21 LIST_ENTRY AllHandles
;
22 /// List of PROTOCOL_INTERFACE's for this handle
25 /// The Handle Database Key value when this handle was last created or modified
29 #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
31 #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
34 /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
35 /// database. Each handler that supports this protocol is listed, along
36 /// with a list of registered notifies.
40 /// Link Entry inserted to mProtocolDatabase
41 LIST_ENTRY AllEntries
;
42 /// ID of the protocol
44 /// All protocol interfaces
46 /// Registerd notification handlers
51 #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
54 /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
55 /// with a protocol interface structure
59 /// Link on IHANDLE.Protocols
63 /// Link on PROTOCOL_ENTRY.Protocols
64 LIST_ENTRY ByProtocol
;
66 PROTOCOL_ENTRY
*Protocol
;
67 /// The interface value
69 /// OPEN_PROTOCOL_DATA list
75 #define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')
79 ///Link on PROTOCOL_INTERFACE.OpenList
82 EFI_HANDLE AgentHandle
;
83 EFI_HANDLE ControllerHandle
;
89 #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
92 /// PROTOCOL_NOTIFY - used for each register notification for a protocol
96 PROTOCOL_ENTRY
*Protocol
;
97 /// All notifications for this protocol
101 /// Last position notified
102 LIST_ENTRY
*Position
;
108 Finds the protocol entry for the requested protocol.
109 The gProtocolDatabaseLock must be owned
111 @param Protocol The ID of the protocol
112 @param Create Create a new entry if not found
114 @return Protocol entry
118 CoreFindProtocolEntry (
119 IN EFI_GUID
*Protocol
,
125 Signal event for every protocol in protocol entry.
127 @param ProtEntry Protocol entry
131 CoreNotifyProtocolEntry (
132 IN PROTOCOL_ENTRY
*ProtEntry
137 Finds the protocol instance for the requested handle and protocol.
138 Note: This function doesn't do parameters checking, it's caller's responsibility
139 to pass in valid parameters.
141 @param Handle The handle to search the protocol on
142 @param Protocol GUID of the protocol
143 @param Interface The interface for the protocol being searched
145 @return Protocol instance (NULL: Not found)
149 CoreFindProtocolInterface (
151 IN EFI_GUID
*Protocol
,
157 Removes Protocol from the protocol list (but not the handle list).
159 @param Handle The handle to remove protocol on.
160 @param Protocol GUID of the protocol to be moved
161 @param Interface The interface of the protocol
163 @return Protocol Entry
167 CoreRemoveInterfaceFromProtocol (
169 IN EFI_GUID
*Protocol
,
175 Connects a controller to a driver.
177 @param ControllerHandle Handle of the controller to be
179 @param ContextDriverImageHandles DriverImageHandle A pointer to an
180 ordered list of driver image
182 @param RemainingDevicePath RemainingDevicePath A pointer to
183 the device path that specifies a
184 child of the controller
185 specified by ControllerHandle.
187 @retval EFI_SUCCESS One or more drivers were
188 connected to ControllerHandle.
189 @retval EFI_OUT_OF_RESOURCES No enough system resources to
190 complete the request.
191 @retval EFI_NOT_FOUND No drivers were connected to
196 CoreConnectSingleController (
197 IN EFI_HANDLE ControllerHandle
,
198 IN EFI_HANDLE
*ContextDriverImageHandles OPTIONAL
,
199 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
203 Attempts to disconnect all drivers that are using the protocol interface being queried.
204 If failed, reconnect all drivers disconnected.
205 Note: This function doesn't do parameters checking, it's caller's responsibility
206 to pass in valid parameters.
208 @param UserHandle The handle on which the protocol is installed
209 @param Prot The protocol to disconnect drivers from
211 @retval EFI_SUCCESS Drivers using the protocol interface are all
213 @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers
217 CoreDisconnectControllersUsingProtocolInterface (
218 IN EFI_HANDLE UserHandle
,
219 IN PROTOCOL_INTERFACE
*Prot
224 Acquire lock on gProtocolDatabaseLock.
228 CoreAcquireProtocolLock (
234 Release lock on gProtocolDatabaseLock.
238 CoreReleaseProtocolLock (
244 Check whether a handle is a valid EFI_HANDLE
246 @param UserHandle The handle to check
248 @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.
249 @retval EFI_SUCCESS The handle is valid EFI_HANDLE.
254 IN EFI_HANDLE UserHandle
260 extern EFI_LOCK gProtocolDatabaseLock
;
261 extern LIST_ENTRY gHandleList
;
262 extern UINT64 gHandleDatabaseKey
;