]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiLib/UefiNotTiano.c
Update the comments.
[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
9Copyright (c) 2006 - 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
20\r
21//\r
22// Include common header file for this module.\r
23//\r
f734a10a 24#include "UefiLibInternal.h"\r
e386b444 25\r
26/**\r
27 An empty function to pass error checking of CreateEventEx ().\r
28\r
9eb7382f 29 This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error\r
e386b444 30 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
42eedea9 31 \r
32 @param Event Event whose notification function is being invoked.\r
33 @param Context Pointer to the notification function's context,\r
34 which is implementation-dependent.\r
e386b444 35\r
36**/\r
e386b444 37VOID\r
38EFIAPI\r
39InternalEmptyFuntion (\r
40 IN EFI_EVENT Event,\r
41 IN VOID *Context\r
42 )\r
43{\r
44 return;\r
45}\r
46\r
47/**\r
48 Create a Legacy Boot Event.\r
49\r
50 Tiano extended the CreateEvent Type enum to add a legacy boot event type.\r
51 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
52 added and now it's possible to not voilate the UEFI specification by\r
53 declaring a GUID for the legacy boot event class. This library supports\r
54 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r
55 work both ways.\r
56\r
57 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
58\r
59 @retval EFI_SUCCESS Event was created.\r
60 @retval Other Event was not created.\r
61\r
62**/\r
63EFI_STATUS\r
64EFIAPI\r
65EfiCreateEventLegacyBoot (\r
66 OUT EFI_EVENT *LegacyBootEvent\r
67 )\r
68{\r
69 return EfiCreateEventLegacyBootEx (\r
70 TPL_CALLBACK,\r
71 InternalEmptyFuntion,\r
72 NULL,\r
73 LegacyBootEvent\r
74 );\r
75}\r
76\r
77/**\r
78 Create an EFI event in the Legacy Boot Event Group and allows\r
79 the caller to specify a notification function.\r
80\r
81 This function abstracts the creation of the Legacy Boot Event.\r
82 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
83 This library abstracts the caller from how this event is created to prevent\r
84 to code form having to change with the version of the specification supported.\r
85 If LegacyBootEvent is NULL, then ASSERT().\r
86\r
87 @param NotifyTpl The task priority level of the event.\r
88 @param NotifyFunction The notification function to call when the event is signaled.\r
89 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
90 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
91\r
92 @retval EFI_SUCCESS Event was created.\r
93 @retval Other Event was not created.\r
94\r
95**/\r
96EFI_STATUS\r
97EFIAPI\r
98EfiCreateEventLegacyBootEx (\r
99 IN EFI_TPL NotifyTpl,\r
100 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
101 IN VOID *NotifyContext, OPTIONAL\r
102 OUT EFI_EVENT *LegacyBootEvent\r
103 )\r
104{\r
105 EFI_STATUS Status;\r
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
118 Status = gBS->CreateEventEx (\r
119 EVT_NOTIFY_SIGNAL,\r
120 NotifyTpl,\r
121 NotifyFunction,\r
122 NotifyContext,\r
123 &gEfiEventLegacyBootGuid,\r
124 LegacyBootEvent\r
125 );\r
126 }\r
127\r
128 return Status;\r
129}\r
130\r
131/**\r
9edc73ad 132 Create a "Ready to Boot" Event.\r
e386b444 133\r
134 Tiano extended the CreateEvent Type enum to add a ready to boot event type.\r
135 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
136 added and now it's possible to not voilate the UEFI specification and use\r
137 the ready to boot event class defined in UEFI 2.0. This library supports\r
138 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r
139 work both ways.\r
140\r
42eedea9 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
163 the caller to specify a notification function.\r
164\r
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
217 Signal a Ready to Boot Event.\r
218\r
219 Create a Ready to Boot Event. Signal it and close it. This causes other\r
220 events of the same event group to be signaled in other modules.\r
221\r
222**/\r
223VOID\r
224EFIAPI\r
225EfiSignalEventReadyToBoot (\r
226 VOID\r
227 )\r
228{\r
229 EFI_STATUS Status;\r
230 EFI_EVENT ReadyToBootEvent;\r
231\r
232 Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
233 if (!EFI_ERROR (Status)) {\r
234 gBS->SignalEvent (ReadyToBootEvent);\r
235 gBS->CloseEvent (ReadyToBootEvent);\r
236 }\r
237}\r
238\r
239/**\r
240 Signal a Legacy Boot Event.\r
241\r
242 Create a legacy Boot Event. Signal it and close it. This causes other\r
243 events of the same event group to be signaled in other modules.\r
244\r
245**/\r
246VOID\r
247EFIAPI\r
248EfiSignalEventLegacyBoot (\r
249 VOID\r
250 )\r
251{\r
252 EFI_STATUS Status;\r
253 EFI_EVENT LegacyBootEvent;\r
254\r
255 Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r
256 if (!EFI_ERROR (Status)) {\r
257 gBS->SignalEvent (LegacyBootEvent);\r
258 gBS->CloseEvent (LegacyBootEvent);\r
259 }\r
260}\r
261\r
262\r
263/**\r
264 Check to see if the Firmware Volume (FV) Media Device Path is valid\r
265\r
266 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
267 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
268 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r
269 device path is defined for Tiano extensions of device path. If the code\r
270 is compiled to conform with the UEFI 2.0 specification use the new device path\r
271 else use the old form for backwards compatability. The return value to this\r
272 function points to a location in FvDevicePathNode and it does not allocate\r
273 new memory for the GUID pointer that is returned.\r
9edc73ad 274 If FvDevicePathNode is NULL, then ASSERT().\r
275 \r
42eedea9 276 @param FvFileDevicePathNode Pointer to FV device path to check.\r
e386b444 277\r
278 @retval NULL FvDevicePathNode is not valid.\r
279 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r
280\r
281**/\r
c7d265a9 282EFI_GUID*\r
e386b444 283EFIAPI\r
284EfiGetNameGuidFromFwVolDevicePathNode (\r
c7d265a9 285 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode\r
e386b444 286 )\r
287{\r
c7d265a9 288 ASSERT (FvFileDevicePathNode != NULL);\r
289\r
3d6f81d7 290 if (DevicePathType (&FvFileDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
291 DevicePathSubType (&FvFileDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r
c7d265a9 292 return (EFI_GUID *) &FvFileDevicePathNode->FvFileName;\r
293 }\r
294\r
e386b444 295 return NULL;\r
296}\r
297\r
298\r
299/**\r
300 Initialize a Firmware Volume (FV) Media Device Path node.\r
301\r
302 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
303 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
304 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r
305 device path is defined for Tiano extensions of device path. If the code\r
306 is compiled to conform with the UEFI 2.0 specification use the new device path\r
307 else use the old form for backwards compatability.\r
9edc73ad 308 If FvDevicePathNode is NULL, then ASSERT().\r
309 If NameGuid is NULL, then ASSERT().\r
e386b444 310\r
42eedea9 311 @param FvFileDevicePathNode Pointer to a FV device path node to initialize\r
e386b444 312 @param NameGuid FV file name to use in FvDevicePathNode\r
313\r
314**/\r
315VOID\r
316EFIAPI\r
317EfiInitializeFwVolDevicepathNode (\r
c7d265a9 318 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode,\r
319 IN CONST EFI_GUID *NameGuid\r
e386b444 320 )\r
321{\r
c7d265a9 322 ASSERT (FvFileDevicePathNode != NULL);\r
e386b444 323 ASSERT (NameGuid != NULL);\r
c7d265a9 324\r
e386b444 325 //\r
c7d265a9 326 // Use the new Device path that does not conflict with the UEFI\r
e386b444 327 //\r
c7d265a9 328 FvFileDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r
329 FvFileDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r
330 SetDevicePathNodeLength (&FvFileDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
331\r
332 CopyGuid (&FvFileDevicePathNode->FvFileName, NameGuid);\r
e386b444 333}\r
334\r