878ddf1f |
1 | /*++\r |
2 | \r |
3 | Copyright (c) 2006, Intel Corporation \r |
4 | All rights reserved. This program and the accompanying materials \r |
5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r |
7 | http://opensource.org/licenses/bsd-license.php \r |
8 | \r |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r |
11 | \r |
12 | Module Name:\r |
13 | \r |
14 | hand.h\r |
15 | \r |
16 | Abstract:\r |
17 | \r |
18 | EFI internal protocol definitions\r |
19 | \r |
20 | \r |
21 | \r |
22 | Revision 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 |
35 | typedef 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 |
53 | typedef 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 |
67 | typedef 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 |
84 | typedef 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 |
100 | typedef 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 |
113 | PROTOCOL_ENTRY *\r |
114 | CoreFindProtocolEntry (\r |
115 | IN EFI_GUID *Protocol,\r |
116 | IN BOOLEAN Create\r |
117 | )\r |
118 | /*++\r |
119 | \r |
120 | Routine 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 |
126 | Arguments:\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 |
132 | Returns:\r |
133 | \r |
134 | Protocol entry\r |
135 | \r |
136 | --*/\r |
137 | ;\r |
138 | \r |
139 | VOID\r |
140 | CoreNotifyProtocolEntry (\r |
141 | IN PROTOCOL_ENTRY *ProtEntry\r |
142 | )\r |
143 | /*++\r |
144 | \r |
145 | Routine Description:\r |
146 | \r |
147 | Signal event for every protocol in protocol entry.\r |
148 | \r |
149 | Arguments:\r |
150 | \r |
151 | ProtEntry - Protocol entry\r |
152 | \r |
153 | Returns:\r |
154 | \r |
155 | --*/\r |
156 | ;\r |
157 | \r |
158 | PROTOCOL_INTERFACE *\r |
159 | CoreFindProtocolInterface (\r |
160 | IN IHANDLE *Handle,\r |
161 | IN EFI_GUID *Protocol,\r |
162 | IN VOID *Interface\r |
163 | )\r |
164 | /*++\r |
165 | \r |
166 | Routine 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 |
173 | Arguments:\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 |
181 | Returns:\r |
182 | \r |
183 | Protocol instance (NULL: Not found)\r |
184 | \r |
185 | --*/\r |
186 | ;\r |
187 | \r |
188 | PROTOCOL_INTERFACE *\r |
189 | CoreRemoveInterfaceFromProtocol (\r |
190 | IN IHANDLE *Handle,\r |
191 | IN EFI_GUID *Protocol,\r |
192 | IN VOID *Interface\r |
193 | )\r |
194 | /*++\r |
195 | \r |
196 | Routine Description:\r |
197 | \r |
198 | Removes Protocol from the protocol list (but not the handle list).\r |
199 | \r |
200 | Arguments:\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 |
208 | Returns:\r |
209 | \r |
210 | Protocol Entry\r |
211 | \r |
212 | --*/\r |
213 | ;\r |
214 | \r |
215 | EFI_STATUS\r |
216 | CoreUnregisterProtocolNotify (\r |
217 | IN EFI_EVENT Event\r |
218 | )\r |
219 | /*++\r |
220 | \r |
221 | Routine Description:\r |
222 | \r |
223 | Removes all the events in the protocol database that match Event.\r |
224 | \r |
225 | Arguments:\r |
226 | \r |
227 | Event - The event to search for in the protocol database.\r |
228 | \r |
229 | Returns:\r |
230 | \r |
231 | EFI_SUCCESS when done searching the entire database.\r |
232 | \r |
233 | --*/\r |
234 | ;\r |
235 | \r |
236 | EFI_STATUS\r |
237 | CoreDisconnectControllersUsingProtocolInterface (\r |
238 | IN EFI_HANDLE UserHandle,\r |
239 | IN PROTOCOL_INTERFACE *Prot\r |
240 | )\r |
241 | /*++\r |
242 | \r |
243 | Routine 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 |
251 | Arguments:\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 |
256 | Returns:\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 |
264 | VOID\r |
265 | CoreAcquireProtocolLock (\r |
266 | VOID\r |
267 | )\r |
268 | /*++\r |
269 | \r |
270 | Routine Description:\r |
271 | \r |
272 | Acquire lock on gProtocolDatabaseLock.\r |
273 | \r |
274 | Arguments:\r |
275 | \r |
276 | None\r |
277 | \r |
278 | Returns:\r |
279 | \r |
280 | None\r |
281 | \r |
282 | --*/\r |
283 | ;\r |
284 | \r |
285 | VOID\r |
286 | CoreReleaseProtocolLock (\r |
287 | VOID\r |
288 | )\r |
289 | /*++\r |
290 | \r |
291 | Routine Description:\r |
292 | \r |
293 | Release lock on gProtocolDatabaseLock.\r |
294 | \r |
295 | Arguments:\r |
296 | \r |
297 | None\r |
298 | \r |
299 | Returns:\r |
300 | \r |
301 | None\r |
302 | \r |
303 | --*/\r |
304 | ;\r |
305 | \r |
306 | EFI_STATUS\r |
307 | CoreValidateHandle (\r |
308 | IN EFI_HANDLE UserHandle\r |
309 | )\r |
310 | /*++\r |
311 | \r |
312 | Routine Description:\r |
313 | \r |
314 | Check whether a handle is a valid EFI_HANDLE\r |
315 | \r |
316 | Arguments:\r |
317 | \r |
318 | UserHandle - The handle to check\r |
319 | \r |
320 | Returns:\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 |
333 | extern EFI_LOCK gProtocolDatabaseLock;\r |
334 | extern LIST_ENTRY gHandleList;\r |
335 | extern UINT64 gHandleDatabaseKey;\r |
336 | \r |
337 | #endif\r |