2 Support functions for managing protocol.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. 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.
20 // IHANDLE - contains a list of protocol handles
23 #define EFI_HANDLE_SIGNATURE EFI_SIGNATURE_32('h','n','d','l')
26 LIST_ENTRY AllHandles
; // All handles list of IHANDLE
27 LIST_ENTRY Protocols
; // List of PROTOCOL_INTERFACE's for this handle
28 UINTN LocateRequest
; //
29 UINT64 Key
; // The Handle Database Key value when this handle was last created or modified
32 #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
36 // PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
37 // database. Each handler that supports this protocol is listed, along
38 // with a list of registered notifies.
41 #define PROTOCOL_ENTRY_SIGNATURE EFI_SIGNATURE_32('p','r','t','e')
44 LIST_ENTRY AllEntries
; // Link Entry inserted to mProtocolDatabase
45 EFI_GUID ProtocolID
; // ID of the protocol
46 LIST_ENTRY Protocols
; // All protocol interfaces
47 LIST_ENTRY Notify
; // Registerd notification handlers
51 // PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
52 // with a protocol interface structure
55 #define PROTOCOL_INTERFACE_SIGNATURE EFI_SIGNATURE_32('p','i','f','c')
58 LIST_ENTRY Link
; // Link on IHANDLE.Protocols
59 IHANDLE
*Handle
; // Back pointer
60 LIST_ENTRY ByProtocol
; // Link on PROTOCOL_ENTRY.Protocols
61 PROTOCOL_ENTRY
*Protocol
; // The protocol ID
62 VOID
*Interface
; // The interface value
64 LIST_ENTRY OpenList
; // OPEN_PROTOCOL_DATA list.
69 #define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l')
73 LIST_ENTRY Link
; //Link on PROTOCOL_INTERFACE.OpenList
75 EFI_HANDLE AgentHandle
;
76 EFI_HANDLE ControllerHandle
;
83 // PROTOCOL_NOTIFY - used for each register notification for a protocol
86 #define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n')
89 PROTOCOL_ENTRY
*Protocol
;
90 LIST_ENTRY Link
; // All notifications for this protocol
91 EFI_EVENT Event
; // Event to notify
92 LIST_ENTRY
*Position
; // Last position notified
96 // Internal prototypes
102 Finds the protocol entry for the requested protocol.
103 The gProtocolDatabaseLock must be owned
105 @param Protocol The ID of the protocol
106 @param Create Create a new entry if not found
108 @return Protocol entry
112 CoreFindProtocolEntry (
113 IN EFI_GUID
*Protocol
,
119 Signal event for every protocol in protocol entry.
121 @param ProtEntry Protocol entry
125 CoreNotifyProtocolEntry (
126 IN PROTOCOL_ENTRY
*ProtEntry
131 Finds the protocol instance for the requested handle and protocol.
132 Note: This function doesn't do parameters checking, it's caller's responsibility
133 to pass in valid parameters.
135 @param Handle The handle to search the protocol on
136 @param Protocol GUID of the protocol
137 @param Interface The interface for the protocol being searched
139 @return Protocol instance (NULL: Not found)
143 CoreFindProtocolInterface (
145 IN EFI_GUID
*Protocol
,
151 Removes Protocol from the protocol list (but not the handle list).
153 @param Handle The handle to remove protocol on.
154 @param Protocol GUID of the protocol to be moved
155 @param Interface The interface of the protocol
157 @return Protocol Entry
161 CoreRemoveInterfaceFromProtocol (
163 IN EFI_GUID
*Protocol
,
169 Removes all the events in the protocol database that match Event.
171 @param Event The event to search for in the protocol
174 @return EFI_SUCCESS when done searching the entire database.
178 CoreUnregisterProtocolNotify (
183 Connects a controller to a driver.
185 @param ControllerHandle Handle of the controller to be
187 @param ContextDriverImageHandles DriverImageHandle A pointer to an
188 ordered list of driver image
190 @param RemainingDevicePath RemainingDevicePath A pointer to
191 the device path that specifies a
192 child of the controller
193 specified by ControllerHandle.
195 @retval EFI_SUCCESS One or more drivers were
196 connected to ControllerHandle.
197 @retval EFI_OUT_OF_RESOURCES No enough system resources to
198 complete the request.
199 @retval EFI_NOT_FOUND No drivers were connected to
204 CoreConnectSingleController (
205 IN EFI_HANDLE ControllerHandle
,
206 IN EFI_HANDLE
*ContextDriverImageHandles OPTIONAL
,
207 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
211 Attempts to disconnect all drivers that are using the protocol interface being queried.
212 If failed, reconnect all drivers disconnected.
213 Note: This function doesn't do parameters checking, it's caller's responsibility
214 to pass in valid parameters.
216 @param UserHandle The handle on which the protocol is installed
217 @param Prot The protocol to disconnect drivers from
219 @retval EFI_SUCCESS Drivers using the protocol interface are all
221 @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers
225 CoreDisconnectControllersUsingProtocolInterface (
226 IN EFI_HANDLE UserHandle
,
227 IN PROTOCOL_INTERFACE
*Prot
232 Acquire lock on gProtocolDatabaseLock.
236 CoreAcquireProtocolLock (
242 Release lock on gProtocolDatabaseLock.
246 CoreReleaseProtocolLock (
252 Check whether a handle is a valid EFI_HANDLE
254 @param UserHandle The handle to check
256 @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.
257 @retval EFI_SUCCESS The handle is valid EFI_HANDLE.
262 IN EFI_HANDLE UserHandle
269 extern EFI_LOCK gProtocolDatabaseLock
;
270 extern LIST_ENTRY gHandleList
;
271 extern UINT64 gHandleDatabaseKey
;