]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiLib/UefiNotTiano.c
Cleanup "Tiano" word.
[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 Creates an EFI event in the Legacy Boot Event Group. Prior to UEFI 2.0 this \r
47 was done via a non blessed UEFI extensions and this library abstracts the \r
48 implementation mechanism of this event from the caller.\r
49 \r
50 This function abstracts the creation of the Legacy Boot Event. The Framework \r
51 moved from a proprietary to UEFI 2.0 based mechanism. This library abstracts \r
52 the caller from how this event is created to prevent to code form having to \r
53 change with the version of the specification supported.\r
54 If LegacyBootEvent is NULL, then ASSERT().\r
55 \r
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
78 the caller to specify a notification function.\r
79\r
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
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
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
131 Create an EFI event in the Ready To Boot Event Group. Prior to UEFI 2.0 this \r
132 was done via a non-standard UEFI extension, and this library abstracts the \r
133 implementation mechanism of this event from the caller.\r
134 \r
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
140\r
141 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
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
154 TPL_CALLBACK,\r
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
174 @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
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
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
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 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r
265 This library function abstracts validating a device path node.\r
266\r
267 Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid. \r
268 If it is valid, then return the GUID file name from the device path node. \r
269 Otherwise, return NULL. This device path changed in the DXE CIS version 0.92 \r
270 in a non back ward compatible way to not conflict with the UEFI 2.0 specification. \r
271 This function abstracts the differences from the caller.\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 The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r
299 This library function abstracts initializing a device path node.\r
300\r
301 Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device \r
302 path changed in the DXE CIS version 0.92 in a non back ward compatible way to \r
303 not conflict with the UEFI 2.0 specification. This function abstracts the \r
304 differences from the caller.\r
305 If FvDevicePathNode is NULL, then ASSERT().\r
306 If NameGuid is NULL, then ASSERT().\r
307\r
308 @param FvFileDevicePathNode Pointer to a FV device path node to initialize\r
309 @param NameGuid FV file name to use in FvDevicePathNode\r
310\r
311**/\r
312VOID\r
313EFIAPI\r
314EfiInitializeFwVolDevicepathNode (\r
315 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode,\r
316 IN CONST EFI_GUID *NameGuid\r
317 )\r
318{\r
319 ASSERT (FvFileDevicePathNode != NULL);\r
320 ASSERT (NameGuid != NULL);\r
321\r
322 //\r
323 // Use the new Device path that does not conflict with the UEFI\r
324 //\r
325 FvFileDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r
326 FvFileDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r
327 SetDevicePathNodeLength (&FvFileDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
328\r
329 CopyGuid (&FvFileDevicePathNode->FvFileName, NameGuid);\r
330}\r
331\r