]>
Commit | Line | Data |
---|---|---|
e386b444 | 1 | /** @file\r |
2 | Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r | |
3 | \r | |
fd2537ef | 4 | Help Port Framework/Tiano code that has conflicts with UEFI 2.0 by hiding the\r |
e386b444 | 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 | |
9 | Copyright (c) 2006 - 2007, Intel Corporation<BR>\r | |
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 | |
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 | 37 | VOID\r |
38 | EFIAPI\r | |
39 | InternalEmptyFuntion (\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 | |
63 | EFI_STATUS\r | |
64 | EFIAPI\r | |
65 | EfiCreateEventLegacyBoot (\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 | |
96 | EFI_STATUS\r | |
97 | EFIAPI\r | |
98 | EfiCreateEventLegacyBootEx (\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 | |
132 | Create a Read to Boot Event.\r | |
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 | |
147 | EFI_STATUS\r | |
148 | EFIAPI\r | |
149 | EfiCreateEventReadyToBoot (\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 | |
180 | EFI_STATUS\r | |
181 | EFIAPI\r | |
182 | EfiCreateEventReadyToBootEx (\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 | |
223 | VOID\r | |
224 | EFIAPI\r | |
225 | EfiSignalEventReadyToBoot (\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 | |
246 | VOID\r | |
247 | EFIAPI\r | |
248 | EfiSignalEventLegacyBoot (\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 | |
274 | \r | |
42eedea9 | 275 | @param FvFileDevicePathNode Pointer to FV device path to check.\r |
e386b444 | 276 | \r |
277 | @retval NULL FvDevicePathNode is not valid.\r | |
278 | @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r | |
279 | \r | |
280 | **/\r | |
c7d265a9 | 281 | EFI_GUID*\r |
e386b444 | 282 | EFIAPI\r |
283 | EfiGetNameGuidFromFwVolDevicePathNode (\r | |
c7d265a9 | 284 | IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode\r |
e386b444 | 285 | )\r |
286 | {\r | |
c7d265a9 | 287 | ASSERT (FvFileDevicePathNode != NULL);\r |
288 | \r | |
3d6f81d7 | 289 | if (DevicePathType (&FvFileDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r |
290 | DevicePathSubType (&FvFileDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r | |
c7d265a9 | 291 | return (EFI_GUID *) &FvFileDevicePathNode->FvFileName;\r |
292 | }\r | |
293 | \r | |
e386b444 | 294 | return NULL;\r |
295 | }\r | |
296 | \r | |
297 | \r | |
298 | /**\r | |
299 | Initialize a Firmware Volume (FV) Media Device Path node.\r | |
300 | \r | |
301 | Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r | |
302 | so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r | |
303 | the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r | |
304 | device path is defined for Tiano extensions of device path. If the code\r | |
305 | is compiled to conform with the UEFI 2.0 specification use the new device path\r | |
306 | else use the old form for backwards compatability.\r | |
307 | \r | |
42eedea9 | 308 | @param FvFileDevicePathNode Pointer to a FV device path node to initialize\r |
e386b444 | 309 | @param NameGuid FV file name to use in FvDevicePathNode\r |
310 | \r | |
311 | **/\r | |
312 | VOID\r | |
313 | EFIAPI\r | |
314 | EfiInitializeFwVolDevicepathNode (\r | |
c7d265a9 | 315 | IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode,\r |
316 | IN CONST EFI_GUID *NameGuid\r | |
e386b444 | 317 | )\r |
318 | {\r | |
c7d265a9 | 319 | ASSERT (FvFileDevicePathNode != NULL);\r |
e386b444 | 320 | ASSERT (NameGuid != NULL);\r |
c7d265a9 | 321 | \r |
e386b444 | 322 | //\r |
c7d265a9 | 323 | // Use the new Device path that does not conflict with the UEFI\r |
e386b444 | 324 | //\r |
c7d265a9 | 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 | |
e386b444 | 330 | }\r |
331 | \r |