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