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