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