]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/hand.h
Add comments and DoxyGen format for these files.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / hand.h
CommitLineData
504214c4 1/** @file \r
28a00297 2\r
504214c4
LG
3 Support functions for managing protocol.\r
4\r
5Copyright (c) 2006 - 2008, Intel Corporation \r
28a00297 6All rights reserved. This program and the accompanying materials \r
7are licensed and made available under the terms and conditions of the BSD License \r
8which accompanies this distribution. The full text of the license may be found at \r
9http://opensource.org/licenses/bsd-license.php \r
10 \r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
13\r
504214c4 14**/\r
28a00297 15\r
16#ifndef _HAND_H_\r
17#define _HAND_H_\r
18\r
19\r
20//\r
21// IHANDLE - contains a list of protocol handles\r
22//\r
23\r
24#define EFI_HANDLE_SIGNATURE EFI_SIGNATURE_32('h','n','d','l')\r
25typedef struct {\r
26 UINTN Signature;\r
27 LIST_ENTRY AllHandles; // All handles list of IHANDLE\r
28 LIST_ENTRY Protocols; // List of PROTOCOL_INTERFACE's for this handle\r
29 UINTN LocateRequest; // \r
30 UINT64 Key; // The Handle Database Key value when this handle was last created or modified\r
31} IHANDLE;\r
32\r
33#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r
34\r
35\r
36//\r
37// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol \r
38// database. Each handler that supports this protocol is listed, along\r
39// with a list of registered notifies.\r
40//\r
41\r
42#define PROTOCOL_ENTRY_SIGNATURE EFI_SIGNATURE_32('p','r','t','e')\r
43typedef struct {\r
44 UINTN Signature;\r
45 LIST_ENTRY AllEntries; // All entries\r
46 EFI_GUID ProtocolID; // ID of the protocol\r
47 LIST_ENTRY Protocols; // All protocol interfaces\r
48 LIST_ENTRY Notify; // Registerd notification handlers\r
49} PROTOCOL_ENTRY;\r
50\r
51//\r
52// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r
53// with a protocol interface structure\r
54//\r
55\r
56#define PROTOCOL_INTERFACE_SIGNATURE EFI_SIGNATURE_32('p','i','f','c')\r
57typedef struct {\r
58 UINTN Signature;\r
59 EFI_HANDLE Handle; // Back pointer\r
60 LIST_ENTRY Link; // Link on IHANDLE.Protocols\r
61 LIST_ENTRY ByProtocol; // Link on PROTOCOL_ENTRY.Protocols\r
62 PROTOCOL_ENTRY *Protocol; // The protocol ID\r
63 VOID *Interface; // The interface value\r
64 \r
65 LIST_ENTRY OpenList; // OPEN_PROTOCOL_DATA list.\r
66 UINTN OpenListCount; \r
67 \r
68 EFI_HANDLE ControllerHandle;\r
69\r
70} PROTOCOL_INTERFACE;\r
71\r
72#define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l')\r
73\r
74typedef struct {\r
75 UINTN Signature;\r
76 LIST_ENTRY Link;\r
77\r
78 EFI_HANDLE AgentHandle;\r
79 EFI_HANDLE ControllerHandle;\r
80 UINT32 Attributes;\r
81 UINT32 OpenCount;\r
82} OPEN_PROTOCOL_DATA;\r
83\r
84\r
85//\r
86// PROTOCOL_NOTIFY - used for each register notification for a protocol\r
87//\r
88\r
89#define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n')\r
90typedef struct {\r
91 UINTN Signature;\r
92 PROTOCOL_ENTRY *Protocol;\r
93 LIST_ENTRY Link; // All notifications for this protocol\r
94 EFI_EVENT Event; // Event to notify\r
95 LIST_ENTRY *Position; // Last position notified\r
96} PROTOCOL_NOTIFY;\r
97\r
98//\r
99// Internal prototypes\r
100//\r
101\r
102\r
103PROTOCOL_ENTRY *\r
104CoreFindProtocolEntry (\r
105 IN EFI_GUID *Protocol,\r
106 IN BOOLEAN Create\r
107 )\r
108/*++\r
109\r
110Routine Description:\r
111\r
112 Finds the protocol entry for the requested protocol.\r
113 \r
114 The gProtocolDatabaseLock must be owned\r
115\r
116Arguments:\r
117 \r
118 Protocol - The ID of the protocol \r
119\r
120 Create - Create a new entry if not found\r
121\r
122Returns:\r
123\r
124 Protocol entry\r
125\r
126--*/\r
127;\r
128\r
129VOID\r
130CoreNotifyProtocolEntry (\r
131 IN PROTOCOL_ENTRY *ProtEntry\r
132 )\r
133/*++\r
134\r
135Routine Description:\r
136\r
137 Signal event for every protocol in protocol entry.\r
138\r
139Arguments:\r
140\r
141 ProtEntry - Protocol entry\r
142\r
143Returns:\r
144\r
145--*/\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
156Routine Description:\r
157\r
158 Finds the protocol instance for the requested handle and protocol.\r
159 \r
160 Note: This function doesn't do parameters checking, it's caller's responsibility \r
161 to pass in valid parameters.\r
162 \r
163Arguments:\r
164 \r
165 Handle - The handle to search the protocol on\r
166 \r
167 Protocol - GUID of the protocol\r
168\r
169 Interface - The interface for the protocol being searched\r
170\r
171Returns:\r
172\r
173 Protocol instance (NULL: Not found)\r
174\r
175--*/\r
176;\r
177\r
178PROTOCOL_INTERFACE *\r
179CoreRemoveInterfaceFromProtocol (\r
180 IN IHANDLE *Handle,\r
181 IN EFI_GUID *Protocol,\r
182 IN VOID *Interface\r
183 )\r
184/*++\r
185\r
186Routine Description:\r
187\r
188 Removes Protocol from the protocol list (but not the handle list).\r
189\r
190Arguments:\r
191\r
192 Handle - The handle to remove protocol on.\r
193\r
194 Protocol - GUID of the protocol to be moved\r
195\r
196 Interface - The interface of the protocol\r
197\r
198Returns:\r
199\r
200 Protocol Entry\r
201\r
202--*/\r
203;\r
204\r
205EFI_STATUS\r
206CoreUnregisterProtocolNotify (\r
207 IN EFI_EVENT Event\r
208 )\r
209/*++\r
210\r
211Routine Description:\r
212\r
213 Removes all the events in the protocol database that match Event.\r
214\r
215Arguments:\r
216 \r
217 Event - The event to search for in the protocol database.\r
218\r
219Returns:\r
220\r
221 EFI_SUCCESS when done searching the entire database.\r
222\r
223--*/\r
224;\r
225\r
226EFI_STATUS\r
227CoreDisconnectControllersUsingProtocolInterface (\r
228 IN EFI_HANDLE UserHandle,\r
229 IN PROTOCOL_INTERFACE *Prot\r
230 )\r
231/*++\r
232\r
233Routine Description:\r
234\r
235 Attempts to disconnect all drivers that are using the protocol interface being queried.\r
236 If failed, reconnect all drivers disconnected.\r
237 \r
238 Note: This function doesn't do parameters checking, it's caller's responsibility \r
239 to pass in valid parameters.\r
240\r
241Arguments:\r
242\r
243 UserHandle - The handle on which the protocol is installed \r
244 Prot - The protocol to disconnect drivers from\r
245\r
246Returns:\r
247\r
248 EFI_SUCCESS - Drivers using the protocol interface are all disconnected\r
249 EFI_ACCESS_DENIED - Failed to disconnect one or all of the drivers\r
250\r
251--*/\r
252;\r
253\r
254VOID\r
255CoreAcquireProtocolLock (\r
256 VOID\r
257 )\r
258/*++\r
259\r
260Routine Description:\r
261\r
262 Acquire lock on gProtocolDatabaseLock.\r
263 \r
264Arguments:\r
265\r
266 None\r
267 \r
268Returns:\r
269\r
270 None\r
271\r
272--*/\r
273;\r
274\r
275VOID\r
276CoreReleaseProtocolLock (\r
277 VOID\r
278 )\r
279/*++\r
280\r
281Routine Description:\r
282\r
283 Release lock on gProtocolDatabaseLock.\r
284 \r
285Arguments:\r
286\r
287 None\r
288 \r
289Returns:\r
290\r
291 None\r
292\r
293--*/\r
294;\r
295\r
296EFI_STATUS\r
297CoreValidateHandle (\r
298 IN EFI_HANDLE UserHandle\r
299 )\r
300/*++\r
301\r
302Routine Description:\r
303\r
304 Check whether a handle is a valid EFI_HANDLE\r
305 \r
306Arguments:\r
307\r
308 UserHandle - The handle to check\r
309 \r
310Returns:\r
311\r
312 EFI_INVALID_PARAMETER - The handle is NULL or not a valid EFI_HANDLE.\r
313 \r
314 EFI_SUCCESS - The handle is valid EFI_HANDLE.\r
315\r
316--*/\r
317;\r
318\r
319//\r
320// Externs\r
321//\r
322\r
323extern EFI_LOCK gProtocolDatabaseLock;\r
324extern LIST_ENTRY gHandleList;\r
325extern UINT64 gHandleDatabaseKey;\r
326\r
327#endif\r