]>
Commit | Line | Data |
---|---|---|
e386b444 | 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 | |
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 | |
29 | This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error\r | |
30 | checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r | |
31 | \r | |
32 | **/\r | |
33 | STATIC\r | |
34 | VOID\r | |
35 | EFIAPI\r | |
36 | InternalEmptyFuntion (\r | |
37 | IN EFI_EVENT Event,\r | |
38 | IN VOID *Context\r | |
39 | )\r | |
40 | {\r | |
41 | return;\r | |
42 | }\r | |
43 | \r | |
44 | /**\r | |
45 | Create a Legacy Boot Event.\r | |
46 | \r | |
47 | Tiano extended the CreateEvent Type enum to add a legacy boot event type.\r | |
48 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
49 | added and now it's possible to not voilate the UEFI specification by\r | |
50 | declaring a GUID for the legacy boot event class. This library supports\r | |
51 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r | |
52 | work both ways.\r | |
53 | \r | |
54 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
55 | \r | |
56 | @retval EFI_SUCCESS Event was created.\r | |
57 | @retval Other Event was not created.\r | |
58 | \r | |
59 | **/\r | |
60 | EFI_STATUS\r | |
61 | EFIAPI\r | |
62 | EfiCreateEventLegacyBoot (\r | |
63 | OUT EFI_EVENT *LegacyBootEvent\r | |
64 | )\r | |
65 | {\r | |
66 | return EfiCreateEventLegacyBootEx (\r | |
67 | TPL_CALLBACK,\r | |
68 | InternalEmptyFuntion,\r | |
69 | NULL,\r | |
70 | LegacyBootEvent\r | |
71 | );\r | |
72 | }\r | |
73 | \r | |
74 | /**\r | |
75 | Create an EFI event in the Legacy Boot Event Group and allows\r | |
76 | the caller to specify a notification function.\r | |
77 | \r | |
78 | This function abstracts the creation of the Legacy Boot Event.\r | |
79 | The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r | |
80 | This library abstracts the caller from how this event is created to prevent\r | |
81 | to code form having to change with the version of the specification supported.\r | |
82 | If LegacyBootEvent is NULL, then ASSERT().\r | |
83 | \r | |
84 | @param NotifyTpl The task priority level of the event.\r | |
85 | @param NotifyFunction The notification function to call when the event is signaled.\r | |
86 | @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r | |
87 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
88 | \r | |
89 | @retval EFI_SUCCESS Event was created.\r | |
90 | @retval Other Event was not created.\r | |
91 | \r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | EfiCreateEventLegacyBootEx (\r | |
96 | IN EFI_TPL NotifyTpl,\r | |
97 | IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r | |
98 | IN VOID *NotifyContext, OPTIONAL\r | |
99 | OUT EFI_EVENT *LegacyBootEvent\r | |
100 | )\r | |
101 | {\r | |
102 | EFI_STATUS Status;\r | |
103 | \r | |
104 | ASSERT (LegacyBootEvent != NULL);\r | |
105 | \r | |
c7d265a9 | 106 | if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r |
107 | DEBUG ((EFI_D_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r | |
108 | ASSERT (FALSE);\r | |
109 | \r | |
e386b444 | 110 | return EFI_UNSUPPORTED;\r |
111 | } else {\r | |
112 | //\r | |
113 | // For UEFI 2.0 and the future use an Event Group\r | |
114 | //\r | |
115 | Status = gBS->CreateEventEx (\r | |
116 | EVT_NOTIFY_SIGNAL,\r | |
117 | NotifyTpl,\r | |
118 | NotifyFunction,\r | |
119 | NotifyContext,\r | |
120 | &gEfiEventLegacyBootGuid,\r | |
121 | LegacyBootEvent\r | |
122 | );\r | |
123 | }\r | |
124 | \r | |
125 | return Status;\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
129 | Create a Read to Boot Event.\r | |
130 | \r | |
131 | Tiano extended the CreateEvent Type enum to add a ready to boot event type.\r | |
132 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
133 | added and now it's possible to not voilate the UEFI specification and use\r | |
134 | the ready to boot event class defined in UEFI 2.0. This library supports\r | |
135 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to\r | |
136 | work both ways.\r | |
137 | \r | |
138 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
139 | \r | |
140 | @retval EFI_SUCCESS Event was created.\r | |
141 | @retval Other Event was not created.\r | |
142 | \r | |
143 | **/\r | |
144 | EFI_STATUS\r | |
145 | EFIAPI\r | |
146 | EfiCreateEventReadyToBoot (\r | |
147 | OUT EFI_EVENT *ReadyToBootEvent\r | |
148 | )\r | |
149 | {\r | |
150 | return EfiCreateEventReadyToBootEx (\r | |
c7d265a9 | 151 | TPL_CALLBACK,\r |
e386b444 | 152 | InternalEmptyFuntion,\r |
153 | NULL,\r | |
154 | ReadyToBootEvent\r | |
155 | );\r | |
156 | }\r | |
157 | \r | |
158 | /**\r | |
159 | Create an EFI event in the Ready To Boot Event Group and allows\r | |
160 | the caller to specify a notification function.\r | |
161 | \r | |
162 | This function abstracts the creation of the Ready to Boot Event.\r | |
163 | The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r | |
164 | This library abstracts the caller from how this event is created to prevent\r | |
165 | to code form having to change with the version of the specification supported.\r | |
166 | If ReadyToBootEvent is NULL, then ASSERT().\r | |
167 | \r | |
168 | @param NotifyTpl The task priority level of the event.\r | |
169 | @param NotifyFunction The notification function to call when the event is signaled.\r | |
170 | @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r | |
171 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
172 | \r | |
173 | @retval EFI_SUCCESS Event was created.\r | |
174 | @retval Other Event was not created.\r | |
175 | \r | |
176 | **/\r | |
177 | EFI_STATUS\r | |
178 | EFIAPI\r | |
179 | EfiCreateEventReadyToBootEx (\r | |
180 | IN EFI_TPL NotifyTpl,\r | |
181 | IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r | |
182 | IN VOID *NotifyContext, OPTIONAL\r | |
183 | OUT EFI_EVENT *ReadyToBootEvent\r | |
184 | )\r | |
185 | {\r | |
186 | EFI_STATUS Status;\r | |
187 | \r | |
188 | ASSERT (ReadyToBootEvent != NULL);\r | |
189 | \r | |
c7d265a9 | 190 | if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r |
191 | DEBUG ((EFI_D_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r | |
192 | ASSERT (FALSE);\r | |
193 | \r | |
e386b444 | 194 | return EFI_UNSUPPORTED;\r |
195 | } else {\r | |
196 | //\r | |
197 | // For UEFI 2.0 and the future use an Event Group\r | |
198 | //\r | |
199 | Status = gBS->CreateEventEx (\r | |
200 | EVT_NOTIFY_SIGNAL,\r | |
201 | NotifyTpl,\r | |
202 | NotifyFunction,\r | |
203 | NotifyContext,\r | |
204 | &gEfiEventReadyToBootGuid,\r | |
205 | ReadyToBootEvent\r | |
206 | );\r | |
207 | }\r | |
208 | \r | |
209 | return Status;\r | |
210 | }\r | |
211 | \r | |
212 | \r | |
213 | /**\r | |
214 | Signal a Ready to Boot Event.\r | |
215 | \r | |
216 | Create a Ready to Boot Event. Signal it and close it. This causes other\r | |
217 | events of the same event group to be signaled in other modules.\r | |
218 | \r | |
219 | **/\r | |
220 | VOID\r | |
221 | EFIAPI\r | |
222 | EfiSignalEventReadyToBoot (\r | |
223 | VOID\r | |
224 | )\r | |
225 | {\r | |
226 | EFI_STATUS Status;\r | |
227 | EFI_EVENT ReadyToBootEvent;\r | |
228 | \r | |
229 | Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r | |
230 | if (!EFI_ERROR (Status)) {\r | |
231 | gBS->SignalEvent (ReadyToBootEvent);\r | |
232 | gBS->CloseEvent (ReadyToBootEvent);\r | |
233 | }\r | |
234 | }\r | |
235 | \r | |
236 | /**\r | |
237 | Signal a Legacy Boot Event.\r | |
238 | \r | |
239 | Create a legacy Boot Event. Signal it and close it. This causes other\r | |
240 | events of the same event group to be signaled in other modules.\r | |
241 | \r | |
242 | **/\r | |
243 | VOID\r | |
244 | EFIAPI\r | |
245 | EfiSignalEventLegacyBoot (\r | |
246 | VOID\r | |
247 | )\r | |
248 | {\r | |
249 | EFI_STATUS Status;\r | |
250 | EFI_EVENT LegacyBootEvent;\r | |
251 | \r | |
252 | Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r | |
253 | if (!EFI_ERROR (Status)) {\r | |
254 | gBS->SignalEvent (LegacyBootEvent);\r | |
255 | gBS->CloseEvent (LegacyBootEvent);\r | |
256 | }\r | |
257 | }\r | |
258 | \r | |
259 | \r | |
260 | /**\r | |
261 | Check to see if the Firmware Volume (FV) Media Device Path is valid\r | |
262 | \r | |
263 | Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r | |
264 | so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r | |
265 | the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r | |
266 | device path is defined for Tiano extensions of device path. If the code\r | |
267 | is compiled to conform with the UEFI 2.0 specification use the new device path\r | |
268 | else use the old form for backwards compatability. The return value to this\r | |
269 | function points to a location in FvDevicePathNode and it does not allocate\r | |
270 | new memory for the GUID pointer that is returned.\r | |
271 | \r | |
272 | @param FvDevicePathNode Pointer to FV device path to check.\r | |
273 | \r | |
274 | @retval NULL FvDevicePathNode is not valid.\r | |
275 | @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r | |
276 | \r | |
277 | **/\r | |
c7d265a9 | 278 | EFI_GUID*\r |
e386b444 | 279 | EFIAPI\r |
280 | EfiGetNameGuidFromFwVolDevicePathNode (\r | |
c7d265a9 | 281 | IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode\r |
e386b444 | 282 | )\r |
283 | {\r | |
c7d265a9 | 284 | ASSERT (FvFileDevicePathNode != NULL);\r |
285 | \r | |
286 | if (FvFileDevicePathNode->Header.Type == MEDIA_DEVICE_PATH &&\r | |
287 | FvFileDevicePathNode->Header.SubType == MEDIA_PIWG_FW_FILE_DP\r | |
288 | ) {\r | |
289 | return (EFI_GUID *) &FvFileDevicePathNode->FvFileName;\r | |
290 | }\r | |
291 | \r | |
e386b444 | 292 | return NULL;\r |
293 | }\r | |
294 | \r | |
295 | \r | |
296 | /**\r | |
297 | Initialize a Firmware Volume (FV) Media Device Path node.\r | |
298 | \r | |
299 | Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r | |
300 | so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r | |
301 | the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed\r | |
302 | device path is defined for Tiano extensions of device path. If the code\r | |
303 | is compiled to conform with the UEFI 2.0 specification use the new device path\r | |
304 | else use the old form for backwards compatability.\r | |
305 | \r | |
306 | @param FvDevicePathNode Pointer to a FV device path node to initialize\r | |
307 | @param NameGuid FV file name to use in FvDevicePathNode\r | |
308 | \r | |
309 | **/\r | |
310 | VOID\r | |
311 | EFIAPI\r | |
312 | EfiInitializeFwVolDevicepathNode (\r | |
c7d265a9 | 313 | IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileDevicePathNode,\r |
314 | IN CONST EFI_GUID *NameGuid\r | |
e386b444 | 315 | )\r |
316 | {\r | |
c7d265a9 | 317 | ASSERT (FvFileDevicePathNode != NULL);\r |
e386b444 | 318 | ASSERT (NameGuid != NULL);\r |
c7d265a9 | 319 | \r |
e386b444 | 320 | //\r |
c7d265a9 | 321 | // Use the new Device path that does not conflict with the UEFI\r |
e386b444 | 322 | //\r |
c7d265a9 | 323 | FvFileDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r |
324 | FvFileDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r | |
325 | SetDevicePathNodeLength (&FvFileDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r | |
326 | \r | |
327 | CopyGuid (&FvFileDevicePathNode->FvFileName, NameGuid);\r | |
e386b444 | 328 | }\r |
329 | \r |