]>
Commit | Line | Data |
---|---|---|
878ddf1f | 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 | |
c0b162a2 | 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 | |
a537f148 | 7 | it contains DXE enum extensions for EFI event services.\r |
878ddf1f | 8 | \r |
c0b162a2 | 9 | Copyright (c) 2006 - 2007, Intel Corporation<BR>\r |
878ddf1f | 10 | All rights reserved. This program and the accompanying materials\r |
11 | are licensed and made available under the terms and conditions of the BSD License\r | |
12 | which accompanies this distribution. The full text of the license may be found at\r | |
13 | http://opensource.org/licenses/bsd-license.php\r | |
14 | \r | |
15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
17 | \r | |
18 | **/\r | |
19 | \r | |
a537f148 | 20 | \r |
9a462b41 | 21 | /**\r |
c0b162a2 | 22 | An empty function to pass error checking of CreateEventEx ().\r |
23 | \r | |
511710d6 | 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 | |
c0b162a2 | 26 | \r |
9a462b41 | 27 | **/\r |
58251024 | 28 | STATIC\r |
511710d6 | 29 | VOID\r |
30 | EFIAPI\r | |
31 | InternalEmptyFuntion (\r | |
32 | IN EFI_EVENT Event,\r | |
33 | IN VOID *Context\r | |
34 | )\r | |
35 | {\r | |
36 | return;\r | |
9a462b41 | 37 | }\r |
878ddf1f | 38 | \r |
39 | /**\r | |
c0b162a2 | 40 | Create a Legacy Boot Event.\r |
41 | \r | |
42 | Tiano extended the CreateEvent Type enum to add a legacy boot event type.\r | |
878ddf1f | 43 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r |
c0b162a2 | 44 | added and now it's possible to not voilate the UEFI specification by\r |
878ddf1f | 45 | declaring a GUID for the legacy boot event class. This library supports\r |
c0b162a2 | 46 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r |
878ddf1f | 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 | |
55 | EFI_STATUS\r | |
56 | EFIAPI\r | |
57 | EfiCreateEventLegacyBoot (\r | |
abea19db | 58 | OUT EFI_EVENT *LegacyBootEvent\r |
878ddf1f | 59 | )\r |
9a462b41 | 60 | {\r |
61 | return EfiCreateEventLegacyBootEx (\r | |
93b0fbc8 | 62 | TPL_CALLBACK,\r |
9a462b41 | 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 | |
c0b162a2 | 71 | the caller to specify a notification function.\r |
72 | \r | |
9a462b41 | 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 | |
88 | EFI_STATUS\r | |
89 | EFIAPI\r | |
90 | EfiCreateEventLegacyBootEx (\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 | |
878ddf1f | 96 | {\r |
97 | EFI_STATUS Status;\r | |
98 | \r | |
99 | ASSERT (LegacyBootEvent != NULL);\r | |
100 | \r | |
c0b162a2 | 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 | |
0f6b6f75 | 112 | } else {\r |
c0b162a2 | 113 | //\r |
114 | // For UEFI 2.0 and the future use an Event Group\r | |
115 | //\r | |
116 | Status = gBS->CreateEventEx (\r | |
93b0fbc8 | 117 | EVT_NOTIFY_SIGNAL,\r |
c0b162a2 | 118 | NotifyTpl,\r |
119 | NotifyFunction,\r | |
120 | NotifyContext,\r | |
121 | &gEfiEventLegacyBootGuid,\r | |
122 | LegacyBootEvent\r | |
123 | );\r | |
c0b162a2 | 124 | }\r |
9a462b41 | 125 | \r |
878ddf1f | 126 | return Status;\r |
127 | }\r | |
128 | \r | |
878ddf1f | 129 | /**\r |
c0b162a2 | 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 | |
878ddf1f | 133 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r |
c0b162a2 | 134 | added and now it's possible to not voilate the UEFI specification and use\r |
878ddf1f | 135 | the ready to boot event class defined in UEFI 2.0. This library supports\r |
c0b162a2 | 136 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r |
878ddf1f | 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 | |
145 | EFI_STATUS\r | |
146 | EFIAPI\r | |
147 | EfiCreateEventReadyToBoot (\r | |
abea19db | 148 | OUT EFI_EVENT *ReadyToBootEvent\r |
878ddf1f | 149 | )\r |
9a462b41 | 150 | {\r |
151 | return EfiCreateEventReadyToBootEx (\r | |
93b0fbc8 | 152 | TPL_CALLBACK,\r |
9a462b41 | 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 | |
c0b162a2 | 161 | the caller to specify a notification function.\r |
162 | \r | |
9a462b41 | 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 | |
178 | EFI_STATUS\r | |
179 | EFIAPI\r | |
180 | EfiCreateEventReadyToBootEx (\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 | |
878ddf1f | 186 | {\r |
187 | EFI_STATUS Status;\r | |
188 | \r | |
189 | ASSERT (ReadyToBootEvent != NULL);\r | |
190 | \r | |
c0b162a2 | 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 | |
0f6b6f75 | 202 | } else {\r |
c0b162a2 | 203 | //\r |
204 | // For UEFI 2.0 and the future use an Event Group\r | |
205 | //\r | |
206 | Status = gBS->CreateEventEx (\r | |
93b0fbc8 | 207 | EVT_NOTIFY_SIGNAL,\r |
c0b162a2 | 208 | NotifyTpl,\r |
209 | NotifyFunction,\r | |
210 | NotifyContext,\r | |
211 | &gEfiEventReadyToBootGuid,\r | |
212 | ReadyToBootEvent\r | |
213 | );\r | |
c0b162a2 | 214 | }\r |
878ddf1f | 215 | \r |
216 | return Status;\r | |
217 | }\r | |
218 | \r | |
219 | \r | |
220 | /**\r | |
c0b162a2 | 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 | |
878ddf1f | 225 | \r |
226 | **/\r | |
227 | VOID\r | |
228 | EFIAPI\r | |
229 | EfiSignalEventReadyToBoot (\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 | |
c0b162a2 | 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 | |
878ddf1f | 248 | \r |
249 | **/\r | |
250 | VOID\r | |
251 | EFIAPI\r | |
252 | EfiSignalEventLegacyBoot (\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 | |
c0b162a2 | 268 | Check to see if the Firmware Volume (FV) Media Device Path is valid\r |
269 | \r | |
878ddf1f | 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 | |
c0b162a2 | 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 | |
878ddf1f | 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 | |
285 | EFI_GUID *\r | |
286 | EFIAPI\r | |
287 | EfiGetNameGuidFromFwVolDevicePathNode (\r | |
abea19db | 288 | IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r |
878ddf1f | 289 | )\r |
290 | {\r | |
291 | ASSERT (FvDevicePathNode != NULL);\r | |
292 | \r | |
878ddf1f | 293 | //\r |
294 | // Use the new Device path that does not conflict with the UEFI\r | |
295 | //\r | |
a537f148 | 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 | |
abea19db | 300 | return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r |
878ddf1f | 301 | }\r |
302 | }\r | |
303 | }\r | |
c0b162a2 | 304 | \r |
878ddf1f | 305 | return NULL;\r |
306 | }\r | |
307 | \r | |
308 | \r | |
309 | /**\r | |
310 | Initialize a Firmware Volume (FV) Media Device Path node.\r | |
c0b162a2 | 311 | \r |
878ddf1f | 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 | |
c0b162a2 | 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 | |
878ddf1f | 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 | |
abea19db | 319 | @param FvDevicePathNode Pointer to a FV device path node to initialize\r |
320 | @param NameGuid FV file name to use in FvDevicePathNode\r | |
878ddf1f | 321 | \r |
322 | **/\r | |
323 | VOID\r | |
324 | EFIAPI\r | |
325 | EfiInitializeFwVolDevicepathNode (\r | |
abea19db | 326 | IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r |
327 | IN CONST EFI_GUID *NameGuid\r | |
878ddf1f | 328 | )\r |
329 | {\r | |
330 | ASSERT (FvDevicePathNode != NULL);\r | |
331 | ASSERT (NameGuid != NULL);\r | |
332 | \r | |
878ddf1f | 333 | //\r |
334 | // Use the new Device path that does not conflict with the UEFI\r | |
335 | //\r | |
a537f148 | 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 | |
878ddf1f | 339 | \r |
340 | //\r | |
a537f148 | 341 | // Add the GUID for generic Tiano device paths\r |
878ddf1f | 342 | //\r |
a537f148 | 343 | CopyGuid (&FvDevicePathNode->Tiano.TianoSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r |
878ddf1f | 344 | \r |
345 | //\r | |
a537f148 | 346 | // Add in the FW Vol File Path Tiano defined information\r |
878ddf1f | 347 | //\r |
a537f148 | 348 | FvDevicePathNode->Tiano.Type = TIANO_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r |
878ddf1f | 349 | \r |
878ddf1f | 350 | CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r |
878ddf1f | 351 | }\r |
352 | \r |