]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiLib/UefiNotTiano.c
Fixed some naming issues and update to the EDK II name. I also fixed an issue with...
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiNotTiano.c
... / ...
CommitLineData
1/** @file\r
2 Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r
3\r
4 Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the\r
5 oldconflicts with library functions and supporting implementations of the old \r
6 (EDK/EFI 1.10) and new (EDK II/UEFI 2.0) way. This module is a DXE driver as \r
7 it contains DXE enum extensions for EFI event services.\r
8\r
9Copyright (c) 2006, Intel Corporation<BR>\r
10All rights reserved. This program and the accompanying materials\r
11are licensed and made available under the terms and conditions of the BSD License\r
12which accompanies this distribution. The full text of the license may be found at\r
13http://opensource.org/licenses/bsd-license.php\r
14\r
15THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
16WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
17\r
18**/\r
19\r
20\r
21/**\r
22 An empty function to pass error checking of CreateEventEx (). \r
23 \r
24 This empty function enusres that EFI_EVENT_NOTIFY_SIGNAL_ALL is error
25 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
26 \r
27**/\r
28VOID
29EFIAPI
30InternalEmptyFuntion (
31 IN EFI_EVENT Event,
32 IN VOID *Context
33 )
34{
35 return;
36}\r
37\r
38/**\r
39 Create a Legacy Boot Event. \r
40 \r
41 Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
42 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
43 added and now it's possible to not voilate the UEFI specification by \r
44 declaring a GUID for the legacy boot event class. This library supports\r
45 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
46 work both ways.\r
47\r
48 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
49\r
50 @retval EFI_SUCCESS Event was created.\r
51 @retval Other Event was not created.\r
52\r
53**/\r
54EFI_STATUS\r
55EFIAPI\r
56EfiCreateEventLegacyBoot (\r
57 OUT EFI_EVENT *LegacyBootEvent\r
58 )\r
59{\r
60 return EfiCreateEventLegacyBootEx (\r
61 EFI_TPL_CALLBACK,\r
62 InternalEmptyFuntion,\r
63 NULL,\r
64 LegacyBootEvent\r
65 );\r
66}\r
67\r
68/**\r
69 Create an EFI event in the Legacy Boot Event Group and allows\r
70 the caller to specify a notification function. \r
71 \r
72 This function abstracts the creation of the Legacy Boot Event.\r
73 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
74 This library abstracts the caller from how this event is created to prevent\r
75 to code form having to change with the version of the specification supported.\r
76 If LegacyBootEvent is NULL, then ASSERT().\r
77\r
78 @param NotifyTpl The task priority level of the event.\r
79 @param NotifyFunction The notification function to call when the event is signaled.\r
80 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
81 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
82\r
83 @retval EFI_SUCCESS Event was created.\r
84 @retval Other Event was not created.\r
85\r
86**/\r
87EFI_STATUS\r
88EFIAPI\r
89EfiCreateEventLegacyBootEx (\r
90 IN EFI_TPL NotifyTpl,\r
91 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
92 IN VOID *NotifyContext, OPTIONAL\r
93 OUT EFI_EVENT *LegacyBootEvent\r
94 )\r
95{\r
96 EFI_STATUS Status;\r
97\r
98 ASSERT (LegacyBootEvent != NULL);\r
99\r
100#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
101 //\r
102 // prior to UEFI 2.0 use Tiano extension to EFI\r
103 //\r
104 Status = gBS->CreateEvent (\r
105 EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
106 NotifyTpl,\r
107 NotifyFunction,\r
108 NotifyContext,\r
109 LegacyBootEvent\r
110 );\r
111#elif (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
112 //\r
113 // For UEFI 2.0 and the future use an Event Group\r
114 //\r
115 Status = gBS->CreateEventEx (\r
116 EVENT_NOTIFY_SIGNAL,\r
117 NotifyTpl,\r
118 NotifyFunction,\r
119 NotifyContext,\r
120 &gEfiEventLegacyBootGuid,\r
121 LegacyBootEvent\r
122 );\r
123#else\r
124 //\r
125 // For EFI 1.10 with no Tiano extensions return unsupported\r
126 //\r
127 Status = EFI_UNSUPORTED;\r
128#endif\r
129\r
130 return Status;\r
131}\r
132\r
133/**\r
134 Create a Read to Boot Event. \r
135 \r
136 Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
137 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
138 added and now it's possible to not voilate the UEFI specification and use \r
139 the ready to boot event class defined in UEFI 2.0. This library supports\r
140 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r
141 work both ways.\r
142\r
143 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
144\r
145 @retval EFI_SUCCESS Event was created.\r
146 @retval Other Event was not created.\r
147\r
148**/\r
149EFI_STATUS\r
150EFIAPI\r
151EfiCreateEventReadyToBoot (\r
152 OUT EFI_EVENT *ReadyToBootEvent\r
153 )\r
154{\r
155 return EfiCreateEventReadyToBootEx (\r
156 EFI_TPL_CALLBACK,\r
157 InternalEmptyFuntion,\r
158 NULL,\r
159 ReadyToBootEvent\r
160 );\r
161}\r
162\r
163/**\r
164 Create an EFI event in the Ready To Boot Event Group and allows\r
165 the caller to specify a notification function. \r
166 \r
167 This function abstracts the creation of the Ready to Boot Event.\r
168 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
169 This library abstracts the caller from how this event is created to prevent\r
170 to code form having to change with the version of the specification supported.\r
171 If ReadyToBootEvent is NULL, then ASSERT().\r
172\r
173 @param NotifyTpl The task priority level of the event.\r
174 @param NotifyFunction The notification function to call when the event is signaled.\r
175 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
176 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
177\r
178 @retval EFI_SUCCESS Event was created.\r
179 @retval Other Event was not created.\r
180\r
181**/\r
182EFI_STATUS\r
183EFIAPI\r
184EfiCreateEventReadyToBootEx (\r
185 IN EFI_TPL NotifyTpl,\r
186 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
187 IN VOID *NotifyContext, OPTIONAL\r
188 OUT EFI_EVENT *ReadyToBootEvent\r
189 )\r
190{\r
191 EFI_STATUS Status;\r
192\r
193 ASSERT (ReadyToBootEvent != NULL);\r
194\r
195#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
196 //\r
197 // prior to UEFI 2.0 use Tiano extension to EFI\r
198 //\r
199 Status = gBS->CreateEvent (\r
200 EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
201 NotifyTpl,\r
202 NotifyFunction,\r
203 NotifyContext,\r
204 ReadyToBootEvent\r
205 );\r
206#elif (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
207 //\r
208 // For UEFI 2.0 and the future use an Event Group\r
209 //\r
210 Status = gBS->CreateEventEx (\r
211 EVENT_NOTIFY_SIGNAL,\r
212 NotifyTpl,\r
213 NotifyFunction,\r
214 NotifyContext,\r
215 &gEfiEventReadyToBootGuid,\r
216 ReadyToBootEvent\r
217 );\r
218#else\r
219 //\r
220 // For EFI 1.10 with no Tiano extensions return unsupported\r
221 //\r
222 Status = EFI_UNSUPORTED;\r
223#endif\r
224\r
225 return Status;\r
226}\r
227\r
228\r
229/**\r
230 Signal a Ready to Boot Event. \r
231 \r
232 Create a Ready to Boot Event. Signal it and close it. This causes other \r
233 events of the same event group to be signaled in other modules. \r
234\r
235**/\r
236VOID\r
237EFIAPI\r
238EfiSignalEventReadyToBoot (\r
239 VOID\r
240 )\r
241{\r
242 EFI_STATUS Status;\r
243 EFI_EVENT ReadyToBootEvent;\r
244\r
245 Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
246 if (!EFI_ERROR (Status)) {\r
247 gBS->SignalEvent (ReadyToBootEvent);\r
248 gBS->CloseEvent (ReadyToBootEvent);\r
249 }\r
250}\r
251\r
252/**\r
253 Signal a Legacy Boot Event. \r
254 \r
255 Create a legacy Boot Event. Signal it and close it. This causes other \r
256 events of the same event group to be signaled in other modules. \r
257\r
258**/\r
259VOID\r
260EFIAPI\r
261EfiSignalEventLegacyBoot (\r
262 VOID\r
263 )\r
264{\r
265 EFI_STATUS Status;\r
266 EFI_EVENT LegacyBootEvent;\r
267\r
268 Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r
269 if (!EFI_ERROR (Status)) {\r
270 gBS->SignalEvent (LegacyBootEvent);\r
271 gBS->CloseEvent (LegacyBootEvent);\r
272 }\r
273}\r
274\r
275\r
276/**\r
277 Check to see if the Firmware Volume (FV) Media Device Path is valid \r
278 \r
279 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
280 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
281 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
282 device path is defined for Tiano extensions of device path. If the code \r
283 is compiled to conform with the UEFI 2.0 specification use the new device path\r
284 else use the old form for backwards compatability. The return value to this\r
285 function points to a location in FvDevicePathNode and it does not allocate\r
286 new memory for the GUID pointer that is returned.\r
287\r
288 @param FvDevicePathNode Pointer to FV device path to check.\r
289\r
290 @retval NULL FvDevicePathNode is not valid.\r
291 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r
292\r
293**/\r
294EFI_GUID *\r
295EFIAPI\r
296EfiGetNameGuidFromFwVolDevicePathNode (\r
297 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r
298 )\r
299{\r
300 ASSERT (FvDevicePathNode != NULL);\r
301\r
302#if ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))\r
303 //\r
304 // Use old Device Path that conflicts with UEFI\r
305 //\r
306 if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH ||\r
307 DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
308 return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
309 }\r
310\r
311#elif ((EDK_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION >= 0x00020000))\r
312 //\r
313 // Use the new Device path that does not conflict with the UEFI\r
314 //\r
315 if (FvDevicePathNode->Tiano.Header.Type == MEDIA_DEVICE_PATH ||\r
316 FvDevicePathNode->Tiano.Header.SubType == MEDIA_VENDOR_DP) {\r
317 if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Tiano.TianoSpecificDevicePath)) {\r
318 if (FvDevicePathNode->Tiano.Type == TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
319 return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
320 }\r
321 }\r
322 }\r
323#endif \r
324 return NULL;\r
325}\r
326\r
327\r
328/**\r
329 Initialize a Firmware Volume (FV) Media Device Path node.\r
330 \r
331 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
332 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
333 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
334 device path is defined for Tiano extensions of device path. If the code \r
335 is compiled to conform with the UEFI 2.0 specification use the new device path\r
336 else use the old form for backwards compatability.\r
337\r
338 @param FvDevicePathNode Pointer to a FV device path node to initialize\r
339 @param NameGuid FV file name to use in FvDevicePathNode\r
340\r
341**/\r
342VOID\r
343EFIAPI\r
344EfiInitializeFwVolDevicepathNode (\r
345 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r
346 IN CONST EFI_GUID *NameGuid\r
347 )\r
348{\r
349 ASSERT (FvDevicePathNode != NULL);\r
350 ASSERT (NameGuid != NULL);\r
351\r
352#if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
353 //\r
354 // Use old Device Path that conflicts with UEFI\r
355 //\r
356 FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r
357 FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;\r
358 SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
359 \r
360#else\r
361 //\r
362 // Use the new Device path that does not conflict with the UEFI\r
363 //\r
364 FvDevicePathNode->Tiano.Header.Type = MEDIA_DEVICE_PATH;\r
365 FvDevicePathNode->Tiano.Header.SubType = MEDIA_VENDOR_DP;\r
366 SetDevicePathNodeLength (&FvDevicePathNode->Tiano.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
367\r
368 //\r
369 // Add the GUID for generic Tiano device paths\r
370 //\r
371 CopyGuid (&FvDevicePathNode->Tiano.TianoSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r
372\r
373 //\r
374 // Add in the FW Vol File Path Tiano defined information\r
375 //\r
376 FvDevicePathNode->Tiano.Type = TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
377\r
378#endif\r
379\r
380 CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r
381\r
382}\r
383\r