]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Dxe/Hand/Handle.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Hand / Handle.h
... / ...
CommitLineData
1/** @file\r
2 Support functions for managing protocol.\r
3\r
4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#ifndef _HAND_H_\r
10#define _HAND_H_\r
11\r
12\r
13#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\r
14\r
15///\r
16/// IHANDLE - contains a list of protocol handles\r
17///\r
18typedef struct {\r
19 UINTN Signature;\r
20 /// All handles list of IHANDLE\r
21 LIST_ENTRY AllHandles;\r
22 /// List of PROTOCOL_INTERFACE's for this handle\r
23 LIST_ENTRY Protocols;\r
24 UINTN LocateRequest;\r
25 /// The Handle Database Key value when this handle was last created or modified\r
26 UINT64 Key;\r
27} IHANDLE;\r
28\r
29#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r
30\r
31#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')\r
32\r
33///\r
34/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol\r
35/// database. Each handler that supports this protocol is listed, along\r
36/// with a list of registered notifies.\r
37///\r
38typedef struct {\r
39 UINTN Signature;\r
40 /// Link Entry inserted to mProtocolDatabase\r
41 LIST_ENTRY AllEntries;\r
42 /// ID of the protocol\r
43 EFI_GUID ProtocolID;\r
44 /// All protocol interfaces\r
45 LIST_ENTRY Protocols;\r
46 /// Registerd notification handlers\r
47 LIST_ENTRY Notify;\r
48} PROTOCOL_ENTRY;\r
49\r
50\r
51#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')\r
52\r
53///\r
54/// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r
55/// with a protocol interface structure\r
56///\r
57typedef struct {\r
58 UINTN Signature;\r
59 /// Link on IHANDLE.Protocols\r
60 LIST_ENTRY Link;\r
61 /// Back pointer\r
62 IHANDLE *Handle;\r
63 /// Link on PROTOCOL_ENTRY.Protocols\r
64 LIST_ENTRY ByProtocol;\r
65 /// The protocol ID\r
66 PROTOCOL_ENTRY *Protocol;\r
67 /// The interface value\r
68 VOID *Interface;\r
69 /// OPEN_PROTOCOL_DATA list\r
70 LIST_ENTRY OpenList;\r
71 UINTN OpenListCount;\r
72\r
73} PROTOCOL_INTERFACE;\r
74\r
75#define OPEN_PROTOCOL_DATA_SIGNATURE SIGNATURE_32('p','o','d','l')\r
76\r
77typedef struct {\r
78 UINTN Signature;\r
79 ///Link on PROTOCOL_INTERFACE.OpenList\r
80 LIST_ENTRY Link;\r
81\r
82 EFI_HANDLE AgentHandle;\r
83 EFI_HANDLE ControllerHandle;\r
84 UINT32 Attributes;\r
85 UINT32 OpenCount;\r
86} OPEN_PROTOCOL_DATA;\r
87\r
88\r
89#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')\r
90\r
91///\r
92/// PROTOCOL_NOTIFY - used for each register notification for a protocol\r
93///\r
94typedef struct {\r
95 UINTN Signature;\r
96 PROTOCOL_ENTRY *Protocol;\r
97 /// All notifications for this protocol\r
98 LIST_ENTRY Link;\r
99 /// Event to notify\r
100 EFI_EVENT Event;\r
101 /// Last position notified\r
102 LIST_ENTRY *Position;\r
103} PROTOCOL_NOTIFY;\r
104\r
105\r
106\r
107/**\r
108 Finds the protocol entry for the requested protocol.\r
109 The gProtocolDatabaseLock must be owned\r
110\r
111 @param Protocol The ID of the protocol\r
112 @param Create Create a new entry if not found\r
113\r
114 @return Protocol entry\r
115\r
116**/\r
117PROTOCOL_ENTRY *\r
118CoreFindProtocolEntry (\r
119 IN EFI_GUID *Protocol,\r
120 IN BOOLEAN Create\r
121 );\r
122\r
123\r
124/**\r
125 Signal event for every protocol in protocol entry.\r
126\r
127 @param ProtEntry Protocol entry\r
128\r
129**/\r
130VOID\r
131CoreNotifyProtocolEntry (\r
132 IN PROTOCOL_ENTRY *ProtEntry\r
133 );\r
134\r
135\r
136/**\r
137 Finds the protocol instance for the requested handle and protocol.\r
138 Note: This function doesn't do parameters checking, it's caller's responsibility\r
139 to pass in valid parameters.\r
140\r
141 @param Handle The handle to search the protocol on\r
142 @param Protocol GUID of the protocol\r
143 @param Interface The interface for the protocol being searched\r
144\r
145 @return Protocol instance (NULL: Not found)\r
146\r
147**/\r
148PROTOCOL_INTERFACE *\r
149CoreFindProtocolInterface (\r
150 IN IHANDLE *Handle,\r
151 IN EFI_GUID *Protocol,\r
152 IN VOID *Interface\r
153 );\r
154\r
155\r
156/**\r
157 Removes Protocol from the protocol list (but not the handle list).\r
158\r
159 @param Handle The handle to remove protocol on.\r
160 @param Protocol GUID of the protocol to be moved\r
161 @param Interface The interface of the protocol\r
162\r
163 @return Protocol Entry\r
164\r
165**/\r
166PROTOCOL_INTERFACE *\r
167CoreRemoveInterfaceFromProtocol (\r
168 IN IHANDLE *Handle,\r
169 IN EFI_GUID *Protocol,\r
170 IN VOID *Interface\r
171 );\r
172\r
173\r
174/**\r
175 Connects a controller to a driver.\r
176\r
177 @param ControllerHandle Handle of the controller to be\r
178 connected.\r
179 @param ContextDriverImageHandles DriverImageHandle A pointer to an\r
180 ordered list of driver image\r
181 handles.\r
182 @param RemainingDevicePath RemainingDevicePath A pointer to\r
183 the device path that specifies a\r
184 child of the controller\r
185 specified by ControllerHandle.\r
186\r
187 @retval EFI_SUCCESS One or more drivers were\r
188 connected to ControllerHandle.\r
189 @retval EFI_OUT_OF_RESOURCES No enough system resources to\r
190 complete the request.\r
191 @retval EFI_NOT_FOUND No drivers were connected to\r
192 ControllerHandle.\r
193\r
194**/\r
195EFI_STATUS\r
196CoreConnectSingleController (\r
197 IN EFI_HANDLE ControllerHandle,\r
198 IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,\r
199 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
200 );\r
201\r
202/**\r
203 Attempts to disconnect all drivers that are using the protocol interface being queried.\r
204 If failed, reconnect all drivers disconnected.\r
205 Note: This function doesn't do parameters checking, it's caller's responsibility\r
206 to pass in valid parameters.\r
207\r
208 @param UserHandle The handle on which the protocol is installed\r
209 @param Prot The protocol to disconnect drivers from\r
210\r
211 @retval EFI_SUCCESS Drivers using the protocol interface are all\r
212 disconnected\r
213 @retval EFI_ACCESS_DENIED Failed to disconnect one or all of the drivers\r
214\r
215**/\r
216EFI_STATUS\r
217CoreDisconnectControllersUsingProtocolInterface (\r
218 IN EFI_HANDLE UserHandle,\r
219 IN PROTOCOL_INTERFACE *Prot\r
220 );\r
221\r
222\r
223/**\r
224 Acquire lock on gProtocolDatabaseLock.\r
225\r
226**/\r
227VOID\r
228CoreAcquireProtocolLock (\r
229 VOID\r
230 );\r
231\r
232\r
233/**\r
234 Release lock on gProtocolDatabaseLock.\r
235\r
236**/\r
237VOID\r
238CoreReleaseProtocolLock (\r
239 VOID\r
240 );\r
241\r
242\r
243/**\r
244 Check whether a handle is a valid EFI_HANDLE\r
245\r
246 @param UserHandle The handle to check\r
247\r
248 @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid EFI_HANDLE.\r
249 @retval EFI_SUCCESS The handle is valid EFI_HANDLE.\r
250\r
251**/\r
252EFI_STATUS\r
253CoreValidateHandle (\r
254 IN EFI_HANDLE UserHandle\r
255 );\r
256\r
257//\r
258// Externs\r
259//\r
260extern EFI_LOCK gProtocolDatabaseLock;\r
261extern LIST_ENTRY gHandleList;\r
262extern UINT64 gHandleDatabaseKey;\r
263\r
264#endif\r