]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / RuntimeDxe / EfiRuntimeLib / Event.c
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials\r
3eb9473e 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 Event.c\r
15\r
16Abstract:\r
17\r
18 Support for Event lib fucntions.\r
19\r
20--*/\r
21\r
22#include "Tiano.h"\r
23#include "EfiRuntimeLib.h"\r
24\r
25EFI_EVENT\r
26RtEfiLibCreateProtocolNotifyEvent (\r
27 IN EFI_GUID *ProtocolGuid,\r
28 IN EFI_TPL NotifyTpl,\r
29 IN EFI_EVENT_NOTIFY NotifyFunction,\r
30 IN VOID *NotifyContext,\r
31 OUT VOID **Registration\r
32 )\r
33/*++\r
34\r
35Routine Description:\r
36\r
37 Create a protocol notification event and return it.\r
38\r
39Arguments:\r
40\r
41 ProtocolGuid - Protocol to register notification event on.\r
42\r
43 NotifyTpl - Maximum TPL to single the NotifyFunction.\r
44\r
45 NotifyFunction - EFI notification routine.\r
46\r
47 NotifyContext - Context passed into Event when it is created.\r
48\r
49 Registration - Registration key returned from RegisterProtocolNotify().\r
50\r
51Returns:\r
52\r
53 The EFI_EVENT that has been registered to be signaled when a ProtocolGuid\r
54 is added to the system.\r
55\r
56--*/\r
57{\r
58 EFI_STATUS Status;\r
59 EFI_EVENT Event;\r
60\r
61 //\r
62 // Create the event\r
63 //\r
64 Status = gBS->CreateEvent (\r
65 EFI_EVENT_NOTIFY_SIGNAL,\r
66 NotifyTpl,\r
67 NotifyFunction,\r
68 NotifyContext,\r
69 &Event\r
70 );\r
71 ASSERT (!EFI_ERROR (Status));\r
72\r
73 //\r
74 // Register for protocol notifactions on this event\r
75 //\r
76 Status = gBS->RegisterProtocolNotify (\r
77 ProtocolGuid,\r
78 Event,\r
79 Registration\r
80 );\r
81\r
82 ASSERT (!EFI_ERROR (Status));\r
83\r
84 //\r
85 // Kick the event so we will perform an initial pass of\r
86 // current installed drivers\r
87 //\r
88 gBS->SignalEvent (Event);\r
89 return Event;\r
90}\r
91\r
92EFI_STATUS\r
93EfiLibGetSystemConfigurationTable (\r
94 IN EFI_GUID *TableGuid,\r
95 IN OUT VOID **Table\r
96 )\r
97/*++\r
98\r
99Routine Description:\r
100\r
101 Return the EFI 1.0 System Tabl entry with TableGuid\r
102\r
103Arguments:\r
104\r
105 TableGuid - Name of entry to return in the system table\r
106 Table - Pointer in EFI system table associated with TableGuid\r
107\r
108Returns:\r
109\r
110 EFI_SUCCESS - Table returned;\r
111 EFI_NOT_FOUND - TableGuid not in EFI system table\r
112\r
113--*/\r
114{\r
115 UINTN Index;\r
116\r
117 for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r
118 if (EfiCompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
119 *Table = gST->ConfigurationTable[Index].VendorTable;\r
120 return EFI_SUCCESS;\r
121 }\r
122 }\r
123\r
124 return EFI_NOT_FOUND;\r
125}\r
126\r
127EFI_STATUS\r
128EfiConvertList (\r
129 IN UINTN DebugDisposition,\r
130 IN OUT EFI_LIST_ENTRY *ListHead\r
131 )\r
132/*++\r
133\r
134Routine Description:\r
135\r
136 Conver the standard Lib double linked list to a virtual mapping.\r
137\r
138Arguments:\r
139\r
140 DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)\r
141\r
142 ListHead - Head of linked list to convert\r
143\r
144Returns:\r
145\r
146 EFI_SUCCESS\r
147\r
148--*/\r
149{\r
150 EFI_LIST_ENTRY *Link;\r
151 EFI_LIST_ENTRY *NextLink;\r
152\r
153 //\r
154 // Convert all the ForwardLink & BackLink pointers in the list\r
155 //\r
156 Link = ListHead;\r
157 do {\r
158 NextLink = Link->ForwardLink;\r
159\r
160 EfiConvertPointer (\r
161 Link->ForwardLink == ListHead ? DebugDisposition : 0,\r
162 (VOID **) &Link->ForwardLink\r
163 );\r
164\r
165 EfiConvertPointer (\r
166 Link->BackLink == ListHead ? DebugDisposition : 0,\r
167 (VOID **) &Link->BackLink\r
168 );\r
169\r
170 Link = NextLink;\r
171 } while (Link != ListHead);\r
172 return EFI_SUCCESS;\r
173}\r
174\r
175#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
176\r
177STATIC\r
178VOID\r
179EFIAPI\r
180EventNotifySignalAllNullEvent (\r
181 IN EFI_EVENT Event,\r
182 IN VOID *Context\r
183 )\r
184{\r
185 //\r
186 // This null event is a size efficent way to enusre that \r
187 // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.\r
188 // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into \r
189 // CreateEventEx() and this function is used to make the\r
190 // old error checking in CreateEvent() for Tiano extensions\r
191 // function.\r
192 //\r
193 return;\r
194}\r
195\r
196#endif\r
197\r
198EFI_STATUS\r
199EFIAPI\r
200RtEfiCreateEventLegacyBoot (\r
201 IN EFI_TPL NotifyTpl,\r
202 IN EFI_EVENT_NOTIFY NotifyFunction,\r
203 IN VOID *NotifyContext,\r
204 OUT EFI_EVENT *LegacyBootEvent\r
205 )\r
206/*++\r
207\r
208Routine Description:\r
209 Create a Legacy Boot Event. \r
210 Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
211 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
212 added and now it's possible to not voilate the UEFI specification by \r
213 declaring a GUID for the legacy boot event class. This library supports\r
214 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
215 work both ways.\r
216\r
217Arguments:\r
218 LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)\r
219\r
220Returns:\r
221 EFI_SUCCESS Event was created.\r
222 Other Event was not created.\r
223\r
224--*/\r
225{\r
226 EFI_STATUS Status;\r
227 UINT32 EventType;\r
228 EFI_EVENT_NOTIFY WorkerNotifyFunction;\r
229\r
230#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
231\r
232 if (NotifyFunction == NULL) {\r
233 EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
234 } else {\r
235 EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;\r
236 }\r
237 WorkerNotifyFunction = NotifyFunction;\r
238\r
239 //\r
240 // prior to UEFI 2.0 use Tiano extension to EFI\r
241 //\r
242 Status = gBS->CreateEvent (\r
243 EventType,\r
244 NotifyTpl,\r
245 WorkerNotifyFunction,\r
246 NotifyContext,\r
247 LegacyBootEvent\r
248 );\r
249#else\r
250\r
251 EventType = EFI_EVENT_NOTIFY_SIGNAL;\r
252 if (NotifyFunction == NULL) {\r
253 //\r
254 // CreatEventEx will check NotifyFunction is NULL or not\r
255 //\r
256 WorkerNotifyFunction = EventNotifySignalAllNullEvent;\r
257 } else {\r
258 WorkerNotifyFunction = NotifyFunction;\r
259 }\r
260\r
261 //\r
262 // For UEFI 2.0 and the future use an Event Group\r
263 //\r
264 Status = gBS->CreateEventEx (\r
265 EventType,\r
266 NotifyTpl,\r
267 WorkerNotifyFunction,\r
268 NotifyContext,\r
269 &gEfiEventLegacyBootGuid,\r
270 LegacyBootEvent\r
271 );\r
272#endif\r
273 return Status;\r
274}\r
275\r
276EFI_STATUS\r
277EFIAPI\r
278RtEfiCreateEventReadyToBoot (\r
279 IN EFI_TPL NotifyTpl,\r
280 IN EFI_EVENT_NOTIFY NotifyFunction,\r
281 IN VOID *NotifyContext,\r
282 OUT EFI_EVENT *ReadyToBootEvent\r
283 )\r
284/*++\r
285\r
286Routine Description:\r
287 Create a Read to Boot Event. \r
288 \r
289 Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
290 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
291 added and now it's possible to not voilate the UEFI specification and use \r
292 the ready to boot event class defined in UEFI 2.0. This library supports\r
293 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
294 work both ways.\r
295\r
296Arguments:\r
297 ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)\r
298\r
299Return:\r
300 EFI_SUCCESS - Event was created.\r
301 Other - Event was not created.\r
302\r
303--*/\r
304{\r
305 EFI_STATUS Status;\r
306 UINT32 EventType;\r
307 EFI_EVENT_NOTIFY WorkerNotifyFunction;\r
308\r
309#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
310\r
311 if (NotifyFunction == NULL) {\r
312 EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
313 } else {\r
314 EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;\r
315 }\r
316 WorkerNotifyFunction = NotifyFunction;\r
317\r
318 //\r
319 // prior to UEFI 2.0 use Tiano extension to EFI\r
320 //\r
321 Status = gBS->CreateEvent (\r
322 EventType,\r
323 NotifyTpl,\r
324 WorkerNotifyFunction,\r
325 NotifyContext,\r
326 ReadyToBootEvent\r
327 );\r
328#else\r
329\r
330 EventType = EFI_EVENT_NOTIFY_SIGNAL;\r
331 if (NotifyFunction == NULL) {\r
332 //\r
333 // CreatEventEx will check NotifyFunction is NULL or not\r
334 //\r
335 WorkerNotifyFunction = EventNotifySignalAllNullEvent;\r
336 } else {\r
337 WorkerNotifyFunction = NotifyFunction;\r
338 }\r
339\r
340 //\r
341 // For UEFI 2.0 and the future use an Event Group\r
342 //\r
343 Status = gBS->CreateEventEx (\r
344 EventType,\r
345 NotifyTpl,\r
346 WorkerNotifyFunction,\r
347 NotifyContext,\r
348 &gEfiEventReadyToBootGuid,\r
349 ReadyToBootEvent\r
350 );\r
351#endif\r
352 return Status;\r
7ccf38a3 353}\r