]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiLib/UefiNotTiano.c
Update the copyright notice format
[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
31 @param Context Pointer to the notification function's context,\r
32 which is implementation-dependent.\r
e386b444 33\r
34**/\r
e386b444 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
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
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
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
104 EFI_STATUS Status;\r
105\r
106 ASSERT (LegacyBootEvent != NULL);\r
107\r
c7d265a9 108 if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
109 DEBUG ((EFI_D_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r
110 ASSERT (FALSE);\r
111\r
e386b444 112 return EFI_UNSUPPORTED;\r
113 } else {\r
114 //\r
115 // For UEFI 2.0 and the future use an Event Group\r
116 //\r
117 Status = gBS->CreateEventEx (\r
118 EVT_NOTIFY_SIGNAL,\r
119 NotifyTpl,\r
120 NotifyFunction,\r
121 NotifyContext,\r
122 &gEfiEventLegacyBootGuid,\r
123 LegacyBootEvent\r
124 );\r
125 }\r
126\r
127 return Status;\r
128}\r
129\r
130/**\r
cf8ae2f6 131 Create an EFI event in the Ready To Boot Event Group.\r
132\r
133 Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library\r
134 abstracts the implementation mechanism of this event from the caller. \r
7f1eba7b 135 This function abstracts the creation of the Ready to Boot Event. The Framework \r
136 moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts \r
137 the caller from how this event is created to prevent the code form having to \r
138 change with the version of the specification supported.\r
139 If ReadyToBootEvent is NULL, then ASSERT().\r
e386b444 140\r
cf8ae2f6 141 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
e386b444 142\r
143 @retval EFI_SUCCESS Event was created.\r
144 @retval Other Event was not created.\r
145\r
146**/\r
147EFI_STATUS\r
148EFIAPI\r
149EfiCreateEventReadyToBoot (\r
150 OUT EFI_EVENT *ReadyToBootEvent\r
151 )\r
152{\r
153 return EfiCreateEventReadyToBootEx (\r
c7d265a9 154 TPL_CALLBACK,\r
e386b444 155 InternalEmptyFuntion,\r
156 NULL,\r
157 ReadyToBootEvent\r
158 );\r
159}\r
160\r
161/**\r
162 Create an EFI event in the Ready To Boot Event Group and allows\r
070a76b1 163 the caller to specify a notification function. \r
164 \r
e386b444 165 This function abstracts the creation of the Ready to Boot Event.\r
166 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
167 This library abstracts the caller from how this event is created to prevent\r
168 to code form having to change with the version of the specification supported.\r
169 If ReadyToBootEvent is NULL, then ASSERT().\r
170\r
171 @param NotifyTpl The task priority level of the event.\r
172 @param NotifyFunction The notification function to call when the event is signaled.\r
173 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
42eedea9 174 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
e386b444 175\r
176 @retval EFI_SUCCESS Event was created.\r
177 @retval Other Event was not created.\r
178\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182EfiCreateEventReadyToBootEx (\r
183 IN EFI_TPL NotifyTpl,\r
184 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
185 IN VOID *NotifyContext, OPTIONAL\r
186 OUT EFI_EVENT *ReadyToBootEvent\r
187 )\r
188{\r
189 EFI_STATUS Status;\r
190\r
191 ASSERT (ReadyToBootEvent != NULL);\r
192\r
c7d265a9 193 if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
194 DEBUG ((EFI_D_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r
195 ASSERT (FALSE);\r
196\r
e386b444 197 return EFI_UNSUPPORTED;\r
198 } else {\r
199 //\r
200 // For UEFI 2.0 and the future use an Event Group\r
201 //\r
202 Status = gBS->CreateEventEx (\r
203 EVT_NOTIFY_SIGNAL,\r
204 NotifyTpl,\r
205 NotifyFunction,\r
206 NotifyContext,\r
207 &gEfiEventReadyToBootGuid,\r
208 ReadyToBootEvent\r
209 );\r
210 }\r
211\r
212 return Status;\r
213}\r
214\r
215\r
216/**\r
1d37ab9f 217 Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().\r
218 \r
219 This function abstracts the signaling of the Ready to Boot Event. The Framework moved\r
cf8ae2f6 220 from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller\r
221 from how this event is created to prevent to code form having to change with the\r
222 version of the specification supported.\r
e386b444 223\r
224**/\r
225VOID\r
226EFIAPI\r
227EfiSignalEventReadyToBoot (\r
228 VOID\r
229 )\r
230{\r
231 EFI_STATUS Status;\r
232 EFI_EVENT ReadyToBootEvent;\r
233\r
234 Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
235 if (!EFI_ERROR (Status)) {\r
236 gBS->SignalEvent (ReadyToBootEvent);\r
237 gBS->CloseEvent (ReadyToBootEvent);\r
238 }\r
239}\r
240\r
241/**\r
1d37ab9f 242 Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().\r
e386b444 243\r
1d37ab9f 244 This function abstracts the signaling of the Legacy Boot Event. The Framework moved from\r
245 a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how\r
246 this event is created to prevent to code form having to change with the version of the\r
247 specification supported.\r
e386b444 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
1d37ab9f 268 Check to see if the Firmware Volume (FV) Media Device Path is valid \r
269 \r
7f1eba7b 270 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r
271 This library function abstracts validating a device path node.\r
7f1eba7b 272 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid. \r
1d37ab9f 273 If it is valid, then return the GUID file name from the device path node. Otherwise, \r
274 return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward \r
275 compatible way to not conflict with the UEFI 2.0 specification. This function abstracts \r
276 the differences from the caller.\r
9edc73ad 277 If FvDevicePathNode is NULL, then ASSERT().\r
1d37ab9f 278\r
279 @param FvDevicePathNode Pointer to FV device path to check.\r
e386b444 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
070a76b1 285EFI_GUID *\r
e386b444 286EFIAPI\r
287EfiGetNameGuidFromFwVolDevicePathNode (\r
070a76b1 288 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r
e386b444 289 )\r
290{\r
070a76b1 291 ASSERT (FvDevicePathNode != NULL);\r
c7d265a9 292\r
070a76b1 293 if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
294 DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r
295 return (EFI_GUID *) &FvDevicePathNode->FvFileName;\r
c7d265a9 296 }\r
297\r
e386b444 298 return NULL;\r
299}\r
300\r
301\r
302/**\r
1d37ab9f 303 Initialize a Firmware Volume (FV) Media Device Path node.\r
304 \r
7f1eba7b 305 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r
1d37ab9f 306 This library function abstracts initializing a device path node. \r
7f1eba7b 307 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device \r
308 path changed in the DXE CIS version 0.92 in a non back ward compatible way to \r
309 not conflict with the UEFI 2.0 specification. This function abstracts the \r
310 differences from the caller.\r
9edc73ad 311 If FvDevicePathNode is NULL, then ASSERT().\r
312 If NameGuid is NULL, then ASSERT().\r
1d37ab9f 313 \r
314 @param FvDevicePathNode Pointer to a FV device path node to initialize\r
e386b444 315 @param NameGuid FV file name to use in FvDevicePathNode\r
316\r
317**/\r
318VOID\r
319EFIAPI\r
320EfiInitializeFwVolDevicepathNode (\r
070a76b1 321 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r
322 IN CONST EFI_GUID *NameGuid\r
e386b444 323 )\r
324{\r
070a76b1 325 ASSERT (FvDevicePathNode != NULL);\r
e386b444 326 ASSERT (NameGuid != NULL);\r
c7d265a9 327\r
e386b444 328 //\r
c7d265a9 329 // Use the new Device path that does not conflict with the UEFI\r
e386b444 330 //\r
070a76b1 331 FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r
332 FvDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r
333 SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
c7d265a9 334\r
070a76b1 335 CopyGuid (&FvDevicePathNode->FvFileName, NameGuid);\r
e386b444 336}\r
337\r