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