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