]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
2c7e5c2f HT |
3 | Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | UefiNotTiano.c\r | |
15 | \r | |
16 | Abstract: \r | |
17 | \r | |
18 | Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r | |
19 | \r | |
20 | Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the\r | |
21 | oldconflicts with library functions and supporting implementations of the old \r | |
22 | (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way.\r | |
23 | \r | |
24 | --*/\r | |
25 | \r | |
26 | #include "EdkIIGlueUefi.h"\r | |
27 | \r | |
28 | /**\r | |
29 | An empty function to pass error checking of CreateEventEx (). \r | |
30 | \r | |
31 | This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error\r | |
32 | checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.\r | |
33 | \r | |
34 | **/\r | |
35 | STATIC\r | |
36 | VOID\r | |
37 | EFIAPI\r | |
38 | InternalEmptyFuntion (\r | |
39 | IN EFI_EVENT Event,\r | |
40 | IN VOID *Context\r | |
41 | )\r | |
42 | {\r | |
43 | return;\r | |
44 | }\r | |
45 | \r | |
46 | /**\r | |
47 | Create a Legacy Boot Event. \r | |
48 | \r | |
49 | Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r | |
50 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
51 | added and now it's possible to not voilate the UEFI specification by \r | |
52 | declaring a GUID for the legacy boot event class. This library supports\r | |
53 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r | |
54 | work both ways.\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 | |
62 | EFI_STATUS\r | |
63 | EFIAPI\r | |
64 | GlueEfiCreateEventLegacyBoot (\r | |
65 | OUT EFI_EVENT *LegacyBootEvent\r | |
66 | )\r | |
67 | {\r | |
68 | return EfiCreateEventLegacyBootEx (\r | |
69 | EFI_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 | |
95 | EFI_STATUS\r | |
96 | EFIAPI\r | |
97 | EfiCreateEventLegacyBootEx (\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 (EFI_SPECIFICATION_VERSION < 0x00020000) \r | |
109 | //\r | |
110 | // prior to UEFI 2.0 use Tiano extension to EFI\r | |
111 | //\r | |
112 | Status = gBS->CreateEvent (\r | |
113 | EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r | |
114 | NotifyTpl,\r | |
115 | NotifyFunction,\r | |
116 | NotifyContext,\r | |
117 | LegacyBootEvent\r | |
118 | );\r | |
119 | #else\r | |
120 | //\r | |
121 | // For UEFI 2.0 and the future use an Event Group\r | |
122 | //\r | |
123 | Status = gBS->CreateEventEx (\r | |
124 | EVENT_NOTIFY_SIGNAL,\r | |
125 | NotifyTpl,\r | |
126 | NotifyFunction,\r | |
127 | NotifyContext,\r | |
128 | &gEfiEventLegacyBootGuid,\r | |
129 | LegacyBootEvent\r | |
130 | );\r | |
131 | #endif\r | |
132 | \r | |
133 | return Status;\r | |
134 | }\r | |
135 | \r | |
136 | /**\r | |
137 | Create a Read to Boot Event. \r | |
138 | \r | |
139 | Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r | |
140 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
141 | added and now it's possible to not voilate the UEFI specification and use \r | |
142 | the ready to boot event class defined in UEFI 2.0. This library supports\r | |
143 | the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to \r | |
144 | work both ways.\r | |
145 | \r | |
146 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
147 | \r | |
148 | @retval EFI_SUCCESS Event was created.\r | |
149 | @retval Other Event was not created.\r | |
150 | \r | |
151 | **/\r | |
152 | EFI_STATUS\r | |
153 | EFIAPI\r | |
154 | GlueEfiCreateEventReadyToBoot (\r | |
155 | OUT EFI_EVENT *ReadyToBootEvent\r | |
156 | )\r | |
157 | {\r | |
158 | return EfiCreateEventReadyToBootEx (\r | |
159 | EFI_TPL_CALLBACK,\r | |
160 | InternalEmptyFuntion,\r | |
161 | NULL,\r | |
162 | ReadyToBootEvent\r | |
163 | );\r | |
164 | }\r | |
165 | \r | |
166 | /**\r | |
167 | Create an EFI event in the Ready To Boot Event Group and allows\r | |
168 | the caller to specify a notification function. \r | |
169 | \r | |
170 | This function abstracts the creation of the Ready to Boot Event.\r | |
171 | The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r | |
172 | This library abstracts the caller from how this event is created to prevent\r | |
173 | to code form having to change with the version of the specification supported.\r | |
174 | If ReadyToBootEvent is NULL, then ASSERT().\r | |
175 | \r | |
176 | @param NotifyTpl The task priority level of the event.\r | |
177 | @param NotifyFunction The notification function to call when the event is signaled.\r | |
178 | @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r | |
179 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
180 | \r | |
181 | @retval EFI_SUCCESS Event was created.\r | |
182 | @retval Other Event was not created.\r | |
183 | \r | |
184 | **/\r | |
185 | EFI_STATUS\r | |
186 | EFIAPI\r | |
187 | EfiCreateEventReadyToBootEx (\r | |
188 | IN EFI_TPL NotifyTpl,\r | |
189 | IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r | |
190 | IN VOID *NotifyContext, OPTIONAL\r | |
191 | OUT EFI_EVENT *ReadyToBootEvent\r | |
192 | )\r | |
193 | {\r | |
194 | EFI_STATUS Status;\r | |
195 | \r | |
196 | ASSERT (ReadyToBootEvent != NULL);\r | |
197 | \r | |
198 | #if (EFI_SPECIFICATION_VERSION < 0x00020000) \r | |
199 | //\r | |
200 | // prior to UEFI 2.0 use Tiano extension to EFI\r | |
201 | //\r | |
202 | Status = gBS->CreateEvent (\r | |
203 | EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r | |
204 | NotifyTpl,\r | |
205 | NotifyFunction,\r | |
206 | NotifyContext,\r | |
207 | ReadyToBootEvent\r | |
208 | );\r | |
209 | #else\r | |
210 | //\r | |
211 | // For UEFI 2.0 and the future use an Event Group\r | |
212 | //\r | |
213 | Status = gBS->CreateEventEx (\r | |
214 | EVENT_NOTIFY_SIGNAL,\r | |
215 | NotifyTpl,\r | |
216 | NotifyFunction,\r | |
217 | NotifyContext,\r | |
218 | &gEfiEventReadyToBootGuid,\r | |
219 | ReadyToBootEvent\r | |
220 | );\r | |
221 | #endif\r | |
222 | \r | |
223 | return Status;\r | |
224 | }\r | |
225 | \r | |
226 | \r | |
227 | /**\r | |
228 | Signal a Ready to Boot Event. \r | |
229 | \r | |
230 | Create a Ready to Boot Event. Signal it and close it. This causes other \r | |
231 | events of the same event group to be signaled in other modules. \r | |
232 | \r | |
233 | **/\r | |
234 | VOID\r | |
235 | EFIAPI\r | |
236 | EfiSignalEventReadyToBoot (\r | |
237 | VOID\r | |
238 | )\r | |
239 | {\r | |
240 | EFI_STATUS Status;\r | |
241 | EFI_EVENT ReadyToBootEvent;\r | |
242 | \r | |
243 | Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r | |
244 | if (!EFI_ERROR (Status)) {\r | |
245 | gBS->SignalEvent (ReadyToBootEvent);\r | |
246 | gBS->CloseEvent (ReadyToBootEvent);\r | |
247 | }\r | |
248 | }\r | |
249 | \r | |
250 | /**\r | |
251 | Signal a Legacy Boot Event. \r | |
252 | \r | |
253 | Create a legacy Boot Event. Signal it and close it. This causes other \r | |
254 | events of the same event group to be signaled in other modules. \r | |
255 | \r | |
256 | **/\r | |
257 | VOID\r | |
258 | EFIAPI\r | |
259 | EfiSignalEventLegacyBoot (\r | |
260 | VOID\r | |
261 | )\r | |
262 | {\r | |
263 | EFI_STATUS Status;\r | |
264 | EFI_EVENT LegacyBootEvent;\r | |
265 | \r | |
266 | Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r | |
267 | if (!EFI_ERROR (Status)) {\r | |
268 | gBS->SignalEvent (LegacyBootEvent);\r | |
269 | gBS->CloseEvent (LegacyBootEvent);\r | |
270 | }\r | |
271 | }\r | |
272 | \r | |
273 | \r | |
274 | /**\r | |
275 | Check to see if the Firmware Volume (FV) Media Device Path is valid \r | |
276 | \r | |
277 | Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r | |
278 | so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r | |
279 | the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r | |
280 | device path is defined for PIWG extensions of device path. If the code \r | |
281 | is compiled to conform with the UEFI 2.0 specification use the new device path\r | |
282 | else use the old form for backwards compatability. The return value to this\r | |
283 | function points to a location in FvDevicePathNode and it does not allocate\r | |
284 | new memory for the GUID pointer that is returned.\r | |
285 | \r | |
286 | @param FvDevicePathNode Pointer to FV device path to check.\r | |
287 | \r | |
288 | @retval NULL FvDevicePathNode is not valid.\r | |
289 | @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r | |
290 | \r | |
291 | **/\r | |
292 | EFI_GUID *\r | |
293 | EFIAPI\r | |
294 | GlueEfiGetNameGuidFromFwVolDevicePathNode (\r | |
295 | IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r | |
296 | )\r | |
297 | {\r | |
298 | ASSERT (FvDevicePathNode != NULL);\r | |
299 | \r | |
3eb9473e | 300 | //\r |
6f4ee195 | 301 | // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r |
302 | // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r | |
303 | // EFI 1.10 and UEFI 2.10.\r | |
3eb9473e | 304 | //\r |
305 | if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r | |
306 | DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r | |
307 | return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r | |
308 | }\r | |
309 | \r | |
3eb9473e | 310 | return NULL;\r |
311 | }\r | |
312 | \r | |
313 | \r | |
314 | /**\r | |
315 | Initialize a Firmware Volume (FV) Media Device Path node.\r | |
316 | \r | |
317 | Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r | |
318 | so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r | |
319 | the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r | |
320 | device path is defined for PIWG extensions of device path. If the code \r | |
321 | is compiled to conform with the UEFI 2.0 specification use the new device path\r | |
322 | else use the old form for backwards compatability.\r | |
323 | \r | |
324 | @param FvDevicePathNode Pointer to a FV device path node to initialize\r | |
325 | @param NameGuid FV file name to use in FvDevicePathNode\r | |
326 | \r | |
327 | **/\r | |
328 | VOID\r | |
329 | EFIAPI\r | |
330 | GlueEfiInitializeFwVolDevicepathNode (\r | |
331 | IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r | |
332 | IN CONST EFI_GUID *NameGuid\r | |
333 | )\r | |
334 | {\r | |
335 | ASSERT (FvDevicePathNode != NULL);\r | |
336 | ASSERT (NameGuid != NULL);\r | |
337 | \r | |
3eb9473e | 338 | //\r |
6f4ee195 | 339 | // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r |
340 | // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r | |
341 | // EFI 1.10 and UEFI 2.10.\r | |
3eb9473e | 342 | //\r |
343 | FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r | |
344 | FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;\r | |
345 | SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r | |
346 | \r | |
3eb9473e | 347 | CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r |
348 | \r | |
349 | }\r | |
350 | \r |