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
105 Finds the protocol entry for the requested protocol.
106 The gProtocolDatabaseLock must be owned
108 @param Protocol The ID of the protocol
109 @param Create Create a new entry if not found
111 @return Protocol entry
115 CoreFindProtocolEntry (
116 IN EFI_GUID
*Protocol
,
123 Signal event for every protocol in protocol entry.
125 @param ProtEntry Protocol entry
129 CoreNotifyProtocolEntry (
130 IN PROTOCOL_ENTRY
*ProtEntry
136 Finds the protocol instance for the requested handle and protocol.
137 Note: This function doesn't do parameters checking, it's caller's responsibility
138 to pass in valid parameters.
140 @param Handle The handle to search the protocol on
141 @param Protocol GUID of the protocol
142 @param Interface The interface for the protocol being searched
144 @return Protocol instance (NULL: Not found)
148 CoreFindProtocolInterface (
150 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
,
176 Removes all the events in the protocol database that match Event.
178 @param Event The event to search for in the protocol
181 @return EFI_SUCCESS when done searching the entire database.
185 CoreUnregisterProtocolNotify (
192 Attempts to disconnect all drivers that are using the protocol interface being queried.
193 If failed, reconnect all drivers disconnected.
194 Note: This function doesn't do parameters checking, it's caller's responsibility
195 to pass in valid parameters.
197 @param UserHandle The handle on which the protocol is installed
198 @param Prot The protocol to disconnect drivers from
200 @retval EFI_SUCCESS Drivers using the protocol interface are all
202 @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers
206 CoreDisconnectControllersUsingProtocolInterface (
207 IN EFI_HANDLE UserHandle
,
208 IN PROTOCOL_INTERFACE
*Prot
214 Acquire lock on gProtocolDatabaseLock.
218 CoreAcquireProtocolLock (
225 Release lock on gProtocolDatabaseLock.
229 CoreReleaseProtocolLock (
236 Check whether a handle is a valid EFI_HANDLE
238 @param UserHandle The handle to check
240 @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.
241 @retval EFI_SUCCESS The handle is valid EFI_HANDLE.
246 IN EFI_HANDLE UserHandle
254 extern EFI_LOCK gProtocolDatabaseLock
;
255 extern LIST_ENTRY gHandleList
;
256 extern UINT64 gHandleDatabaseKey
;