3 Support functions for managing protocol.
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // IHANDLE - contains a list of protocol handles
24 #define EFI_HANDLE_SIGNATURE EFI_SIGNATURE_32('h','n','d','l')
27 LIST_ENTRY AllHandles
; // All handles list of IHANDLE
28 LIST_ENTRY Protocols
; // List of PROTOCOL_INTERFACE's for this handle
29 UINTN LocateRequest
; //
30 UINT64 Key
; // The Handle Database Key value when this handle was last created or modified
33 #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
37 // PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
38 // database. Each handler that supports this protocol is listed, along
39 // with a list of registered notifies.
42 #define PROTOCOL_ENTRY_SIGNATURE EFI_SIGNATURE_32('p','r','t','e')
45 LIST_ENTRY AllEntries
; // All entries
46 EFI_GUID ProtocolID
; // ID of the protocol
47 LIST_ENTRY Protocols
; // All protocol interfaces
48 LIST_ENTRY Notify
; // Registerd notification handlers
52 // PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
53 // with a protocol interface structure
56 #define PROTOCOL_INTERFACE_SIGNATURE EFI_SIGNATURE_32('p','i','f','c')
59 EFI_HANDLE Handle
; // Back pointer
60 LIST_ENTRY Link
; // Link on IHANDLE.Protocols
61 LIST_ENTRY ByProtocol
; // Link on PROTOCOL_ENTRY.Protocols
62 PROTOCOL_ENTRY
*Protocol
; // The protocol ID
63 VOID
*Interface
; // The interface value
65 LIST_ENTRY OpenList
; // OPEN_PROTOCOL_DATA list.
68 EFI_HANDLE ControllerHandle
;
72 #define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l')
78 EFI_HANDLE AgentHandle
;
79 EFI_HANDLE ControllerHandle
;
86 // PROTOCOL_NOTIFY - used for each register notification for a protocol
89 #define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n')
92 PROTOCOL_ENTRY
*Protocol
;
93 LIST_ENTRY Link
; // All notifications for this protocol
94 EFI_EVENT Event
; // Event to notify
95 LIST_ENTRY
*Position
; // Last position notified
99 // Internal prototypes
104 CoreFindProtocolEntry (
105 IN EFI_GUID
*Protocol
,
112 Finds the protocol entry for the requested protocol.
114 The gProtocolDatabaseLock must be owned
118 Protocol - The ID of the protocol
120 Create - Create a new entry if not found
130 CoreNotifyProtocolEntry (
131 IN PROTOCOL_ENTRY
*ProtEntry
137 Signal event for every protocol in protocol entry.
141 ProtEntry - Protocol entry
149 CoreFindProtocolInterface (
151 IN EFI_GUID
*Protocol
,
158 Finds the protocol instance for the requested handle and protocol.
160 Note: This function doesn't do parameters checking, it's caller's responsibility
161 to pass in valid parameters.
165 Handle - The handle to search the protocol on
167 Protocol - GUID of the protocol
169 Interface - The interface for the protocol being searched
173 Protocol instance (NULL: Not found)
179 CoreRemoveInterfaceFromProtocol (
181 IN EFI_GUID
*Protocol
,
188 Removes Protocol from the protocol list (but not the handle list).
192 Handle - The handle to remove protocol on.
194 Protocol - GUID of the protocol to be moved
196 Interface - The interface of the protocol
206 CoreUnregisterProtocolNotify (
213 Removes all the events in the protocol database that match Event.
217 Event - The event to search for in the protocol database.
221 EFI_SUCCESS when done searching the entire database.
227 CoreDisconnectControllersUsingProtocolInterface (
228 IN EFI_HANDLE UserHandle
,
229 IN PROTOCOL_INTERFACE
*Prot
235 Attempts to disconnect all drivers that are using the protocol interface being queried.
236 If failed, reconnect all drivers disconnected.
238 Note: This function doesn't do parameters checking, it's caller's responsibility
239 to pass in valid parameters.
243 UserHandle - The handle on which the protocol is installed
244 Prot - The protocol to disconnect drivers from
248 EFI_SUCCESS - Drivers using the protocol interface are all disconnected
249 EFI_ACCESS_DENIED - Failed to disconnect one or all of the drivers
255 CoreAcquireProtocolLock (
262 Acquire lock on gProtocolDatabaseLock.
276 CoreReleaseProtocolLock (
283 Release lock on gProtocolDatabaseLock.
298 IN EFI_HANDLE UserHandle
304 Check whether a handle is a valid EFI_HANDLE
308 UserHandle - The handle to check
312 EFI_INVALID_PARAMETER - The handle is NULL or not a valid EFI_HANDLE.
314 EFI_SUCCESS - The handle is valid EFI_HANDLE.
323 extern EFI_LOCK gProtocolDatabaseLock
;
324 extern LIST_ENTRY gHandleList
;
325 extern UINT64 gHandleDatabaseKey
;