]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiLib/UefiNotTiano.c
remove unnecessary comments introduced by tools from MdePkg. The regular express...
[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 - 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 "UefiLibInternal.h"\r
23\r
24/**\r
25 An empty function to pass error checking of CreateEventEx ().\r
26\r
27 This empty function ensures that EVT_NOTIFY_SIGNAL_ALL is error\r
28 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
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
33\r
34**/\r
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
46 Create a Legacy Boot Event.\r
47\r
48 Tiano extended the CreateEvent Type enum to add a legacy boot event type.\r
49 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
50 added and now it's possible to not voilate the UEFI specification by\r
51 declaring a GUID for the legacy boot event class. This library supports\r
52 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r
53 work both ways.\r
54\r
55 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
56\r
57 @retval EFI_SUCCESS Event was created.\r
58 @retval Other Event was not created.\r
59\r
60**/\r
61EFI_STATUS\r
62EFIAPI\r
63EfiCreateEventLegacyBoot (\r
64 OUT EFI_EVENT *LegacyBootEvent\r
65 )\r
66{\r
67 return EfiCreateEventLegacyBootEx (\r
68 TPL_CALLBACK,\r
69 InternalEmptyFuntion,\r
70 NULL,\r
71 LegacyBootEvent\r
72 );\r
73}\r
74\r
75/**\r
76 Create an EFI event in the Legacy Boot Event Group and allows\r
77 the caller to specify a notification function.\r
78\r
79 This function abstracts the creation of the Legacy Boot Event.\r
80 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
81 This library abstracts the caller from how this event is created to prevent\r
82 to code form having to change with the version of the specification supported.\r
83 If LegacyBootEvent is NULL, then ASSERT().\r
84\r
85 @param NotifyTpl The task priority level of the event.\r
86 @param NotifyFunction The notification function to call when the event is signaled.\r
87 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
88 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
89\r
90 @retval EFI_SUCCESS Event was created.\r
91 @retval Other Event was not created.\r
92\r
93**/\r
94EFI_STATUS\r
95EFIAPI\r
96EfiCreateEventLegacyBootEx (\r
97 IN EFI_TPL NotifyTpl,\r
98 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
99 IN VOID *NotifyContext, OPTIONAL\r
100 OUT EFI_EVENT *LegacyBootEvent\r
101 )\r
102{\r
103 EFI_STATUS Status;\r
104\r
105 ASSERT (LegacyBootEvent != NULL);\r
106\r
107 if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
108 DEBUG ((EFI_D_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r
109 ASSERT (FALSE);\r
110\r
111 return EFI_UNSUPPORTED;\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
117 EVT_NOTIFY_SIGNAL,\r
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 "Ready 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
139 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
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
152 TPL_CALLBACK,\r
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
172 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
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 < EFI_2_00_SYSTEM_TABLE_REVISION) {\r
192 DEBUG ((EFI_D_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r
193 ASSERT (FALSE);\r
194\r
195 return EFI_UNSUPPORTED;\r
196 } else {\r
197 //\r
198 // For UEFI 2.0 and the future use an Event Group\r
199 //\r
200 Status = gBS->CreateEventEx (\r
201 EVT_NOTIFY_SIGNAL,\r
202 NotifyTpl,\r
203 NotifyFunction,\r
204 NotifyContext,\r
205 &gEfiEventReadyToBootGuid,\r
206 ReadyToBootEvent\r
207 );\r
208 }\r
209\r
210 return Status;\r
211}\r
212\r
213\r
214/**\r
215 Signal a Ready to Boot Event.\r
216\r
217 Create a Ready to Boot Event. Signal it and close it. This causes other\r
218 events of the same event group to be signaled in other modules.\r
219\r
220**/\r
221VOID\r
222EFIAPI\r
223EfiSignalEventReadyToBoot (\r
224 VOID\r
225 )\r
226{\r
227 EFI_STATUS Status;\r
228 EFI_EVENT ReadyToBootEvent;\r
229\r
230 Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
231 if (!EFI_ERROR (Status)) {\r
232 gBS->SignalEvent (ReadyToBootEvent);\r
233 gBS->CloseEvent (ReadyToBootEvent);\r
234 }\r
235}\r
236\r
237/**\r
238 Signal a Legacy Boot Event.\r
239\r
240 Create a legacy Boot Event. Signal it and close it. This causes other\r
241 events of the same event group to be signaled in other modules.\r
242\r
243**/\r
244VOID\r
245EFIAPI\r
246EfiSignalEventLegacyBoot (\r
247 VOID\r
248 )\r
249{\r
250 EFI_STATUS Status;\r
251 EFI_EVENT LegacyBootEvent;\r
252\r
253 Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r
254 if (!EFI_ERROR (Status)) {\r
255 gBS->SignalEvent (LegacyBootEvent);\r
256 gBS->CloseEvent (LegacyBootEvent);\r
257 }\r
258}\r
259\r
260\r
261/**\r
262 Check to see if the Firmware Volume (FV) Media Device Path is valid\r
263\r
264 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
265 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
266 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r
267 device path is defined for Tiano extensions of device path. If the code\r
268 is compiled to conform with the UEFI 2.0 specification use the new device path\r
269 else use the old form for backwards compatability. The return value to this\r
270 function points to a location in FvDevicePathNode and it does not allocate\r
271 new memory for the GUID pointer that is returned.\r
272 If FvDevicePathNode is NULL, then ASSERT().\r
273 \r
274 @param FvFileDevicePathNode Pointer to FV device path to check.\r
275\r
276 @retval NULL FvDevicePathNode is not valid.\r
277 @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r
278\r
279**/\r
280EFI_GUID*\r
281EFIAPI\r
282EfiGetNameGuidFromFwVolDevicePathNode (\r
283 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode\r
284 )\r
285{\r
286 ASSERT (FvFileDevicePathNode != NULL);\r
287\r
288 if (DevicePathType (&FvFileDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
289 DevicePathSubType (&FvFileDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r
290 return (EFI_GUID *) &FvFileDevicePathNode->FvFileName;\r
291 }\r
292\r
293 return NULL;\r
294}\r
295\r
296\r
297/**\r
298 Initialize a Firmware Volume (FV) Media Device Path node.\r
299\r
300 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
301 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
302 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r
303 device path is defined for Tiano extensions of device path. If the code\r
304 is compiled to conform with the UEFI 2.0 specification use the new device path\r
305 else use the old form for backwards compatability.\r
306 If FvDevicePathNode is NULL, then ASSERT().\r
307 If NameGuid is NULL, then ASSERT().\r
308\r
309 @param FvFileDevicePathNode Pointer to a FV device path node to initialize\r
310 @param NameGuid FV file name to use in FvDevicePathNode\r
311\r
312**/\r
313VOID\r
314EFIAPI\r
315EfiInitializeFwVolDevicepathNode (\r
316 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode,\r
317 IN CONST EFI_GUID *NameGuid\r
318 )\r
319{\r
320 ASSERT (FvFileDevicePathNode != NULL);\r
321 ASSERT (NameGuid != NULL);\r
322\r
323 //\r
324 // Use the new Device path that does not conflict with the UEFI\r
325 //\r
326 FvFileDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r
327 FvFileDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r
328 SetDevicePathNodeLength (&FvFileDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
329\r
330 CopyGuid (&FvFileDevicePathNode->FvFileName, NameGuid);\r
331}\r
332\r