]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiLib/UefiNotTiano.c
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiNotTiano.c
... / ...
CommitLineData
1/** @file\r
2 Library functions that abstract areas of conflict between framework and UEFI 2.0.\r
3\r
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
7 it contains DXE enum extensions for EFI event services.\r
8\r
9Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
10This 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#include "UefiLibInternal.h"\r
23\r
24/**\r
25 Creates an EFI event in the Legacy Boot Event Group.\r
26\r
27 Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library\r
28 abstracts the implementation mechanism of this event from the caller. This function\r
29 abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary\r
30 to UEFI 2.0 based mechanism. This library abstracts the caller from how this event\r
31 is created to prevent to code form having to change with the version of the\r
32 specification supported.\r
33 If LegacyBootEvent is NULL, then ASSERT().\r
34\r
35 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
36\r
37 @retval EFI_SUCCESS Event was created.\r
38 @retval Other Event was not created.\r
39\r
40**/\r
41EFI_STATUS\r
42EFIAPI\r
43EfiCreateEventLegacyBoot (\r
44 OUT EFI_EVENT *LegacyBootEvent\r
45 )\r
46{\r
47 return EfiCreateEventLegacyBootEx (\r
48 TPL_CALLBACK,\r
49 EfiEventEmptyFunction,\r
50 NULL,\r
51 LegacyBootEvent\r
52 );\r
53}\r
54\r
55/**\r
56 Create an EFI event in the Legacy Boot Event Group and allows\r
57 the caller to specify a notification function.\r
58\r
59 This function abstracts the creation of the Legacy Boot Event.\r
60 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
61 This library abstracts the caller from how this event is created to prevent\r
62 to code form having to change with the version of the specification supported.\r
63 If LegacyBootEvent is NULL, then ASSERT().\r
64\r
65 @param NotifyTpl The task priority level of the event.\r
66 @param NotifyFunction The notification function to call when the event is signaled.\r
67 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
68 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
69\r
70 @retval EFI_SUCCESS Event was created.\r
71 @retval Other Event was not created.\r
72\r
73**/\r
74EFI_STATUS\r
75EFIAPI\r
76EfiCreateEventLegacyBootEx (\r
77 IN EFI_TPL NotifyTpl,\r
78 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
79 IN VOID *NotifyContext, OPTIONAL\r
80 OUT EFI_EVENT *LegacyBootEvent\r
81 )\r
82{\r
83 EFI_STATUS Status;\r
84 EFI_EVENT_NOTIFY WorkerNotifyFunction;\r
85\r
86 ASSERT (LegacyBootEvent != NULL);\r
87\r
88 if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
89 DEBUG ((EFI_D_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r
90 ASSERT (FALSE);\r
91\r
92 return EFI_UNSUPPORTED;\r
93 } else {\r
94 //\r
95 // For UEFI 2.0 and the future use an Event Group\r
96 //\r
97 if (NotifyFunction == NULL) {\r
98 //\r
99 // CreateEventEx will check NotifyFunction is NULL or not and return error.\r
100 // Use dummy routine for the case NotifyFunction is NULL.\r
101 //\r
102 WorkerNotifyFunction = EfiEventEmptyFunction;\r
103 } else {\r
104 WorkerNotifyFunction = NotifyFunction;\r
105 }\r
106 Status = gBS->CreateEventEx (\r
107 EVT_NOTIFY_SIGNAL,\r
108 NotifyTpl,\r
109 WorkerNotifyFunction,\r
110 NotifyContext,\r
111 &gEfiEventLegacyBootGuid,\r
112 LegacyBootEvent\r
113 );\r
114 }\r
115\r
116 return Status;\r
117}\r
118\r
119/**\r
120 Create an EFI event in the Ready To Boot Event Group.\r
121\r
122 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library\r
123 abstracts the implementation mechanism of this event from the caller.\r
124 This function abstracts the creation of the Ready to Boot Event. The Framework\r
125 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts\r
126 the caller from how this event is created to prevent the code form having to\r
127 change with the version of the specification supported.\r
128 If ReadyToBootEvent is NULL, then ASSERT().\r
129\r
130 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
131\r
132 @retval EFI_SUCCESS Event was created.\r
133 @retval Other Event was not created.\r
134\r
135**/\r
136EFI_STATUS\r
137EFIAPI\r
138EfiCreateEventReadyToBoot (\r
139 OUT EFI_EVENT *ReadyToBootEvent\r
140 )\r
141{\r
142 return EfiCreateEventReadyToBootEx (\r
143 TPL_CALLBACK,\r
144 EfiEventEmptyFunction,\r
145 NULL,\r
146 ReadyToBootEvent\r
147 );\r
148}\r
149\r
150/**\r
151 Create an EFI event in the Ready To Boot Event Group and allows\r
152 the caller to specify a notification function.\r
153\r
154 This function abstracts the creation of the Ready to Boot Event.\r
155 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
156 This library abstracts the caller from how this event is created to prevent\r
157 to code form having to change with the version of the specification supported.\r
158 If ReadyToBootEvent is NULL, then ASSERT().\r
159\r
160 @param NotifyTpl The task priority level of the event.\r
161 @param NotifyFunction The notification function to call when the event is signaled.\r
162 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
163 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
164\r
165 @retval EFI_SUCCESS Event was created.\r
166 @retval Other Event was not created.\r
167\r
168**/\r
169EFI_STATUS\r
170EFIAPI\r
171EfiCreateEventReadyToBootEx (\r
172 IN EFI_TPL NotifyTpl,\r
173 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
174 IN VOID *NotifyContext, OPTIONAL\r
175 OUT EFI_EVENT *ReadyToBootEvent\r
176 )\r
177{\r
178 EFI_STATUS Status;\r
179 EFI_EVENT_NOTIFY WorkerNotifyFunction;\r
180\r
181 ASSERT (ReadyToBootEvent != NULL);\r
182\r
183 if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
184 DEBUG ((EFI_D_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r
185 ASSERT (FALSE);\r
186\r
187 return EFI_UNSUPPORTED;\r
188 } else {\r
189 //\r
190 // For UEFI 2.0 and the future use an Event Group\r
191 //\r
192 if (NotifyFunction == NULL) {\r
193 //\r
194 // CreateEventEx will check NotifyFunction is NULL or not and return error.\r
195 // Use dummy routine for the case NotifyFunction is NULL.\r
196 //\r
197 WorkerNotifyFunction = EfiEventEmptyFunction;\r
198 } else {\r
199 WorkerNotifyFunction = NotifyFunction;\r
200 }\r
201 Status = gBS->CreateEventEx (\r
202 EVT_NOTIFY_SIGNAL,\r
203 NotifyTpl,\r
204 WorkerNotifyFunction,\r
205 NotifyContext,\r
206 &gEfiEventReadyToBootGuid,\r
207 ReadyToBootEvent\r
208 );\r
209 }\r
210\r
211 return Status;\r
212}\r
213\r
214\r
215/**\r
216 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().\r
217\r
218 This function abstracts the signaling of the Ready to Boot Event. The Framework moved\r
219 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller\r
220 from how this event is created to prevent to code form having to change with the\r
221 version of the specification supported.\r
222\r
223**/\r
224VOID\r
225EFIAPI\r
226EfiSignalEventReadyToBoot (\r
227 VOID\r
228 )\r
229{\r
230 EFI_STATUS Status;\r
231 EFI_EVENT ReadyToBootEvent;\r
232\r
233 Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
234 if (!EFI_ERROR (Status)) {\r
235 gBS->SignalEvent (ReadyToBootEvent);\r
236 gBS->CloseEvent (ReadyToBootEvent);\r
237 }\r
238}\r
239\r
240/**\r
241 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().\r
242\r
243 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from\r
244 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how\r
245 this event is created to prevent to code form having to change with the version of the\r
246 specification supported.\r
247\r
248**/\r
249VOID\r
250EFIAPI\r
251EfiSignalEventLegacyBoot (\r
252 VOID\r
253 )\r
254{\r
255 EFI_STATUS Status;\r
256 EFI_EVENT LegacyBootEvent;\r
257\r
258 Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r
259 if (!EFI_ERROR (Status)) {\r
260 gBS->SignalEvent (LegacyBootEvent);\r
261 gBS->CloseEvent (LegacyBootEvent);\r
262 }\r
263}\r
264\r
265\r
266/**\r
267 Check to see if the Firmware Volume (FV) Media Device Path is valid\r
268\r
269 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.\r
270 This library function abstracts validating a device path node.\r
271 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid.\r
272 If it is valid, then return the GUID file name from the device path node. Otherwise,\r
273 return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward\r
274 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts\r
275 the differences from the caller.\r
276 If FvDevicePathNode is NULL, then ASSERT().\r
277\r
278 @param FvDevicePathNode The pointer to FV device path to check.\r
279\r
280 @retval NULL FvDevicePathNode is not valid.\r
281 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r
282\r
283**/\r
284EFI_GUID *\r
285EFIAPI\r
286EfiGetNameGuidFromFwVolDevicePathNode (\r
287 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r
288 )\r
289{\r
290 ASSERT (FvDevicePathNode != NULL);\r
291\r
292 if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
293 DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r
294 return (EFI_GUID *) &FvDevicePathNode->FvFileName;\r
295 }\r
296\r
297 return NULL;\r
298}\r
299\r
300\r
301/**\r
302 Initialize a Firmware Volume (FV) Media Device Path node.\r
303\r
304 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification.\r
305 This library function abstracts initializing a device path node.\r
306 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device\r
307 path changed in the DXE CIS version 0.92 in a non back ward compatible way to\r
308 not conflict with the UEFI 2.0 specification. This function abstracts the\r
309 differences from the caller.\r
310 If FvDevicePathNode is NULL, then ASSERT().\r
311 If NameGuid is NULL, then ASSERT().\r
312\r
313 @param FvDevicePathNode The pointer to a FV device path node to initialize\r
314 @param NameGuid FV file name to use in FvDevicePathNode\r
315\r
316**/\r
317VOID\r
318EFIAPI\r
319EfiInitializeFwVolDevicepathNode (\r
320 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r
321 IN CONST EFI_GUID *NameGuid\r
322 )\r
323{\r
324 ASSERT (FvDevicePathNode != NULL);\r
325 ASSERT (NameGuid != NULL);\r
326\r
327 //\r
328 // Use the new Device path that does not conflict with the UEFI\r
329 //\r
330 FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r
331 FvDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r
332 SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
333\r
334 CopyGuid (&FvDevicePathNode->FvFileName, NameGuid);\r
335}\r
336\r