2 Support functions for managing protocol.
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
22 /// IHANDLE - contains a list of protocol handles
26 /// All handles list of IHANDLE
27 LIST_ENTRY AllHandles
;
28 /// List of PROTOCOL_INTERFACE's for this handle
31 /// The Handle Database Key value when this handle was last created or modified
35 #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
37 #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
40 /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
41 /// database. Each handler that supports this protocol is listed, along
42 /// with a list of registered notifies.
46 /// Link Entry inserted to mProtocolDatabase
47 LIST_ENTRY AllEntries
;
48 /// ID of the protocol
50 /// All protocol interfaces
52 /// Registerd notification handlers
57 #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
60 /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
61 /// with a protocol interface structure
65 /// Link on IHANDLE.Protocols
69 /// Link on PROTOCOL_ENTRY.Protocols
70 LIST_ENTRY ByProtocol
;
72 PROTOCOL_ENTRY
*Protocol
;
73 /// The interface value
75 /// OPEN_PROTOCOL_DATA list
81 #define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')
85 ///Link on PROTOCOL_INTERFACE.OpenList
88 EFI_HANDLE AgentHandle
;
89 EFI_HANDLE ControllerHandle
;
95 #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
98 /// PROTOCOL_NOTIFY - used for each register notification for a protocol
102 PROTOCOL_ENTRY
*Protocol
;
103 /// All notifications for this protocol
107 /// Last position notified
108 LIST_ENTRY
*Position
;
114 Finds the protocol entry for the requested protocol.
115 The gProtocolDatabaseLock must be owned
117 @param Protocol The ID of the protocol
118 @param Create Create a new entry if not found
120 @return Protocol entry
124 CoreFindProtocolEntry (
125 IN EFI_GUID
*Protocol
,
131 Signal event for every protocol in protocol entry.
133 @param ProtEntry Protocol entry
137 CoreNotifyProtocolEntry (
138 IN PROTOCOL_ENTRY
*ProtEntry
143 Finds the protocol instance for the requested handle and protocol.
144 Note: This function doesn't do parameters checking, it's caller's responsibility
145 to pass in valid parameters.
147 @param Handle The handle to search the protocol on
148 @param Protocol GUID of the protocol
149 @param Interface The interface for the protocol being searched
151 @return Protocol instance (NULL: Not found)
155 CoreFindProtocolInterface (
157 IN EFI_GUID
*Protocol
,
163 Removes Protocol from the protocol list (but not the handle list).
165 @param Handle The handle to remove protocol on.
166 @param Protocol GUID of the protocol to be moved
167 @param Interface The interface of the protocol
169 @return Protocol Entry
173 CoreRemoveInterfaceFromProtocol (
175 IN EFI_GUID
*Protocol
,
181 Connects a controller to a driver.
183 @param ControllerHandle Handle of the controller to be
185 @param ContextDriverImageHandles DriverImageHandle A pointer to an
186 ordered list of driver image
188 @param RemainingDevicePath RemainingDevicePath A pointer to
189 the device path that specifies a
190 child of the controller
191 specified by ControllerHandle.
193 @retval EFI_SUCCESS One or more drivers were
194 connected to ControllerHandle.
195 @retval EFI_OUT_OF_RESOURCES No enough system resources to
196 complete the request.
197 @retval EFI_NOT_FOUND No drivers were connected to
202 CoreConnectSingleController (
203 IN EFI_HANDLE ControllerHandle
,
204 IN EFI_HANDLE
*ContextDriverImageHandles OPTIONAL
,
205 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
209 Attempts to disconnect all drivers that are using the protocol interface being queried.
210 If failed, reconnect all drivers disconnected.
211 Note: This function doesn't do parameters checking, it's caller's responsibility
212 to pass in valid parameters.
214 @param UserHandle The handle on which the protocol is installed
215 @param Prot The protocol to disconnect drivers from
217 @retval EFI_SUCCESS Drivers using the protocol interface are all
219 @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers
223 CoreDisconnectControllersUsingProtocolInterface (
224 IN EFI_HANDLE UserHandle
,
225 IN PROTOCOL_INTERFACE
*Prot
230 Acquire lock on gProtocolDatabaseLock.
234 CoreAcquireProtocolLock (
240 Release lock on gProtocolDatabaseLock.
244 CoreReleaseProtocolLock (
250 Check whether a handle is a valid EFI_HANDLE
252 @param UserHandle The handle to check
254 @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.
255 @retval EFI_SUCCESS The handle is valid EFI_HANDLE.
260 IN EFI_HANDLE UserHandle
266 extern EFI_LOCK gProtocolDatabaseLock
;
267 extern LIST_ENTRY gHandleList
;
268 extern UINT64 gHandleDatabaseKey
;