]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Library/UefiLib/UefiNotTiano.c
1. Removed #ifndef to enable Capsule architecture protocol on IPF.
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiNotTiano.c
... / ...
CommitLineData
1/** @file\r
2 Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r
3\r
4 Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the\r
5 oldconflicts 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 An empty function to pass error checking of CreateEventEx ().\r
23\r
24 This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error\r
25 checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r
26\r
27**/\r
28STATIC\r
29VOID\r
30EFIAPI\r
31InternalEmptyFuntion (\r
32 IN EFI_EVENT Event,\r
33 IN VOID *Context\r
34 )\r
35{\r
36 return;\r
37}\r
38\r
39/**\r
40 Create a Legacy Boot Event.\r
41\r
42 Tiano extended the CreateEvent Type enum to add a legacy boot event type.\r
43 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
44 added and now it's possible to not voilate the UEFI specification by\r
45 declaring a GUID for the legacy boot event class. This library supports\r
46 the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r
47 work both ways.\r
48\r
49 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
50\r
51 @retval EFI_SUCCESS Event was created.\r
52 @retval Other Event was not created.\r
53\r
54**/\r
55EFI_STATUS\r
56EFIAPI\r
57EfiCreateEventLegacyBoot (\r
58 OUT EFI_EVENT *LegacyBootEvent\r
59 )\r
60{\r
61 return EfiCreateEventLegacyBootEx (\r
62 EFI_TPL_CALLBACK,\r
63 InternalEmptyFuntion,\r
64 NULL,\r
65 LegacyBootEvent\r
66 );\r
67}\r
68\r
69/**\r
70 Create an EFI event in the Legacy Boot Event Group and allows\r
71 the caller to specify a notification function.\r
72\r
73 This function abstracts the creation of the Legacy Boot Event.\r
74 The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r
75 This library abstracts the caller from how this event is created to prevent\r
76 to code form having to change with the version of the specification supported.\r
77 If LegacyBootEvent is NULL, then ASSERT().\r
78\r
79 @param NotifyTpl The task priority level of the event.\r
80 @param NotifyFunction The notification function to call when the event is signaled.\r
81 @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r
82 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r
83\r
84 @retval EFI_SUCCESS Event was created.\r
85 @retval Other Event was not created.\r
86\r
87**/\r
88EFI_STATUS\r
89EFIAPI\r
90EfiCreateEventLegacyBootEx (\r
91 IN EFI_TPL NotifyTpl,\r
92 IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r
93 IN VOID *NotifyContext, OPTIONAL\r
94 OUT EFI_EVENT *LegacyBootEvent\r
95 )\r
96{\r
97 EFI_STATUS Status;\r
98\r
99 ASSERT (LegacyBootEvent != NULL);\r
100\r
101 if (gST->Hdr.Revision < 0x00020000) {\r
102 //\r
103 // prior to UEFI 2.0 use Tiano extension to EFI\r
104 //\r
105 Status = gBS->CreateEvent (\r
106 EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
107 NotifyTpl,\r
108 NotifyFunction,\r
109 NotifyContext,\r
110 LegacyBootEvent\r
111 );\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 EVENT_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 Read 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 LegacyBootEvent 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 EFI_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 LegacyBootEvent 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 < 0x00020000) {\r
192 //\r
193 // prior to UEFI 2.0 use Tiano extension to EFI\r
194 //\r
195 Status = gBS->CreateEvent (\r
196 EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
197 NotifyTpl,\r
198 NotifyFunction,\r
199 NotifyContext,\r
200 ReadyToBootEvent\r
201 );\r
202 } else {\r
203 //\r
204 // For UEFI 2.0 and the future use an Event Group\r
205 //\r
206 Status = gBS->CreateEventEx (\r
207 EVENT_NOTIFY_SIGNAL,\r
208 NotifyTpl,\r
209 NotifyFunction,\r
210 NotifyContext,\r
211 &gEfiEventReadyToBootGuid,\r
212 ReadyToBootEvent\r
213 );\r
214 }\r
215\r
216 return Status;\r
217}\r
218\r
219\r
220/**\r
221 Signal a Ready to Boot Event.\r
222\r
223 Create a Ready to Boot Event. Signal it and close it. This causes other\r
224 events of the same event group to be signaled in other modules.\r
225\r
226**/\r
227VOID\r
228EFIAPI\r
229EfiSignalEventReadyToBoot (\r
230 VOID\r
231 )\r
232{\r
233 EFI_STATUS Status;\r
234 EFI_EVENT ReadyToBootEvent;\r
235\r
236 Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r
237 if (!EFI_ERROR (Status)) {\r
238 gBS->SignalEvent (ReadyToBootEvent);\r
239 gBS->CloseEvent (ReadyToBootEvent);\r
240 }\r
241}\r
242\r
243/**\r
244 Signal a Legacy Boot Event.\r
245\r
246 Create a legacy Boot Event. Signal it and close it. This causes other\r
247 events of the same event group to be signaled in other modules.\r
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
268 Check to see if the Firmware Volume (FV) Media Device Path is valid\r
269\r
270 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
271 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
272 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r
273 device path is defined for Tiano extensions of device path. If the code\r
274 is compiled to conform with the UEFI 2.0 specification use the new device path\r
275 else use the old form for backwards compatability. The return value to this\r
276 function points to a location in FvDevicePathNode and it does not allocate\r
277 new memory for the GUID pointer that is returned.\r
278\r
279 @param FvDevicePathNode Pointer to FV device path to check.\r
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
285EFI_GUID *\r
286EFIAPI\r
287EfiGetNameGuidFromFwVolDevicePathNode (\r
288 IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r
289 )\r
290{\r
291 ASSERT (FvDevicePathNode != NULL);\r
292\r
293 //\r
294 // Use the new Device path that does not conflict with the UEFI\r
295 //\r
296 if (FvDevicePathNode->Tiano.Header.Type == MEDIA_DEVICE_PATH ||\r
297 FvDevicePathNode->Tiano.Header.SubType == MEDIA_VENDOR_DP) {\r
298 if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Tiano.TianoSpecificDevicePath)) {\r
299 if (FvDevicePathNode->Tiano.Type == TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
300 return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
301 }\r
302 }\r
303 }\r
304\r
305 return NULL;\r
306}\r
307\r
308\r
309/**\r
310 Initialize a Firmware Volume (FV) Media Device Path node.\r
311\r
312 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
313 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
314 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r
315 device path is defined for Tiano extensions of device path. If the code\r
316 is compiled to conform with the UEFI 2.0 specification use the new device path\r
317 else use the old form for backwards compatability.\r
318\r
319 @param FvDevicePathNode Pointer to a FV device path node to initialize\r
320 @param NameGuid FV file name to use in FvDevicePathNode\r
321\r
322**/\r
323VOID\r
324EFIAPI\r
325EfiInitializeFwVolDevicepathNode (\r
326 IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r
327 IN CONST EFI_GUID *NameGuid\r
328 )\r
329{\r
330 ASSERT (FvDevicePathNode != NULL);\r
331 ASSERT (NameGuid != NULL);\r
332\r
333 //\r
334 // Use the new Device path that does not conflict with the UEFI\r
335 //\r
336 FvDevicePathNode->Tiano.Header.Type = MEDIA_DEVICE_PATH;\r
337 FvDevicePathNode->Tiano.Header.SubType = MEDIA_VENDOR_DP;\r
338 SetDevicePathNodeLength (&FvDevicePathNode->Tiano.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
339\r
340 //\r
341 // Add the GUID for generic Tiano device paths\r
342 //\r
343 CopyGuid (&FvDevicePathNode->Tiano.TianoSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r
344\r
345 //\r
346 // Add in the FW Vol File Path Tiano defined information\r
347 //\r
348 FvDevicePathNode->Tiano.Type = TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r
349\r
350 CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r
351}\r
352\r