]>
Commit | Line | Data |
---|---|---|
e386b444 | 1 | /** @file\r |
9edc73ad | 2 | Library functions that abstract areas of conflict between framework and UEFI 2.0.\r |
e386b444 | 3 | \r |
9edc73ad | 4 | Help Port Framework code that has conflicts with UEFI 2.0 by hiding the\r |
5 | old conflicts with library functions and supporting implementations of the old\r | |
e386b444 | 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 | |
19388d29 HT |
9 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
10 | This program and the accompanying materials\r | |
e386b444 | 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 | |
1efcc4ae | 21 | \r |
f734a10a | 22 | #include "UefiLibInternal.h"\r |
e386b444 | 23 | \r |
e386b444 | 24 | /**\r |
cf8ae2f6 | 25 | Creates an EFI event in the Legacy Boot Event Group.\r |
26 | \r | |
27 | Prior to UEFI 2.0 this was done via a non blessed UEFI extensions and this library\r | |
28 | abstracts the implementation mechanism of this event from the caller. This function\r | |
29 | abstracts the creation of the Legacy Boot Event. The Framework moved from a proprietary\r | |
30 | to UEFI 2.0 based mechanism. This library abstracts the caller from how this event\r | |
31 | is created to prevent to code form having to change with the version of the\r | |
32 | specification supported.\r | |
7f1eba7b | 33 | If LegacyBootEvent is NULL, then ASSERT().\r |
cf8ae2f6 | 34 | \r |
e386b444 | 35 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r |
36 | \r | |
37 | @retval EFI_SUCCESS Event was created.\r | |
38 | @retval Other Event was not created.\r | |
39 | \r | |
40 | **/\r | |
41 | EFI_STATUS\r | |
42 | EFIAPI\r | |
43 | EfiCreateEventLegacyBoot (\r | |
44 | OUT EFI_EVENT *LegacyBootEvent\r | |
45 | )\r | |
46 | {\r | |
47 | return EfiCreateEventLegacyBootEx (\r | |
48 | TPL_CALLBACK,\r | |
e8326a00 | 49 | InternalEmptyFunction,\r |
e386b444 | 50 | NULL,\r |
51 | LegacyBootEvent\r | |
52 | );\r | |
53 | }\r | |
54 | \r | |
55 | /**\r | |
56 | Create an EFI event in the Legacy Boot Event Group and allows\r | |
070a76b1 | 57 | the caller to specify a notification function. \r |
58 | \r | |
e386b444 | 59 | This function abstracts the creation of the Legacy Boot Event.\r |
60 | The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r | |
61 | This library abstracts the caller from how this event is created to prevent\r | |
62 | to code form having to change with the version of the specification supported.\r | |
63 | If LegacyBootEvent is NULL, then ASSERT().\r | |
64 | \r | |
65 | @param NotifyTpl The task priority level of the event.\r | |
66 | @param NotifyFunction The notification function to call when the event is signaled.\r | |
67 | @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r | |
68 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
69 | \r | |
70 | @retval EFI_SUCCESS Event was created.\r | |
71 | @retval Other Event was not created.\r | |
72 | \r | |
73 | **/\r | |
74 | EFI_STATUS\r | |
75 | EFIAPI\r | |
76 | EfiCreateEventLegacyBootEx (\r | |
77 | IN EFI_TPL NotifyTpl,\r | |
78 | IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r | |
79 | IN VOID *NotifyContext, OPTIONAL\r | |
80 | OUT EFI_EVENT *LegacyBootEvent\r | |
81 | )\r | |
82 | {\r | |
e8326a00 ML |
83 | EFI_STATUS Status;\r |
84 | EFI_EVENT_NOTIFY WorkerNotifyFunction;\r | |
e386b444 | 85 | \r |
86 | ASSERT (LegacyBootEvent != NULL);\r | |
87 | \r | |
c7d265a9 | 88 | if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r |
89 | DEBUG ((EFI_D_ERROR, "EFI1.1 can't support LegacyBootEvent!"));\r | |
90 | ASSERT (FALSE);\r | |
91 | \r | |
e386b444 | 92 | return EFI_UNSUPPORTED;\r |
93 | } else {\r | |
94 | //\r | |
95 | // For UEFI 2.0 and the future use an Event Group\r | |
96 | //\r | |
e8326a00 ML |
97 | if (NotifyFunction == NULL) {\r |
98 | //\r | |
99 | // CreateEventEx will check NotifyFunction is NULL or not and return error.\r | |
100 | // Use dummy routine for the case NotifyFunction is NULL.\r | |
101 | //\r | |
102 | WorkerNotifyFunction = InternalEmptyFunction;\r | |
103 | } else {\r | |
104 | WorkerNotifyFunction = NotifyFunction;\r | |
105 | }\r | |
e386b444 | 106 | Status = gBS->CreateEventEx (\r |
107 | EVT_NOTIFY_SIGNAL,\r | |
108 | NotifyTpl,\r | |
e8326a00 | 109 | WorkerNotifyFunction,\r |
e386b444 | 110 | NotifyContext,\r |
111 | &gEfiEventLegacyBootGuid,\r | |
112 | LegacyBootEvent\r | |
113 | );\r | |
114 | }\r | |
115 | \r | |
116 | return Status;\r | |
117 | }\r | |
118 | \r | |
119 | /**\r | |
cf8ae2f6 | 120 | Create an EFI event in the Ready To Boot Event Group.\r |
121 | \r | |
122 | Prior to UEFI 2.0 this was done via a non-standard UEFI extension, and this library\r | |
123 | abstracts the implementation mechanism of this event from the caller. \r | |
7f1eba7b | 124 | This function abstracts the creation of the Ready to Boot Event. The Framework \r |
125 | moved from a proprietary to UEFI 2.0-based mechanism. This library abstracts \r | |
126 | the caller from how this event is created to prevent the code form having to \r | |
127 | change with the version of the specification supported.\r | |
128 | If ReadyToBootEvent is NULL, then ASSERT().\r | |
e386b444 | 129 | \r |
58380e9c | 130 | @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r |
e386b444 | 131 | \r |
132 | @retval EFI_SUCCESS Event was created.\r | |
133 | @retval Other Event was not created.\r | |
134 | \r | |
135 | **/\r | |
136 | EFI_STATUS\r | |
137 | EFIAPI\r | |
138 | EfiCreateEventReadyToBoot (\r | |
139 | OUT EFI_EVENT *ReadyToBootEvent\r | |
140 | )\r | |
141 | {\r | |
142 | return EfiCreateEventReadyToBootEx (\r | |
c7d265a9 | 143 | TPL_CALLBACK,\r |
e8326a00 | 144 | InternalEmptyFunction,\r |
e386b444 | 145 | NULL,\r |
146 | ReadyToBootEvent\r | |
147 | );\r | |
148 | }\r | |
149 | \r | |
150 | /**\r | |
151 | Create an EFI event in the Ready To Boot Event Group and allows\r | |
070a76b1 | 152 | the caller to specify a notification function. \r |
153 | \r | |
e386b444 | 154 | This function abstracts the creation of the Ready to Boot Event.\r |
155 | The Framework moved from a proprietary to UEFI 2.0 based mechanism.\r | |
156 | This library abstracts the caller from how this event is created to prevent\r | |
157 | to code form having to change with the version of the specification supported.\r | |
158 | If ReadyToBootEvent is NULL, then ASSERT().\r | |
159 | \r | |
160 | @param NotifyTpl The task priority level of the event.\r | |
161 | @param NotifyFunction The notification function to call when the event is signaled.\r | |
162 | @param NotifyContext The content to pass to NotifyFunction when the event is signaled.\r | |
42eedea9 | 163 | @param ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r |
e386b444 | 164 | \r |
165 | @retval EFI_SUCCESS Event was created.\r | |
166 | @retval Other Event was not created.\r | |
167 | \r | |
168 | **/\r | |
169 | EFI_STATUS\r | |
170 | EFIAPI\r | |
171 | EfiCreateEventReadyToBootEx (\r | |
172 | IN EFI_TPL NotifyTpl,\r | |
173 | IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL\r | |
174 | IN VOID *NotifyContext, OPTIONAL\r | |
175 | OUT EFI_EVENT *ReadyToBootEvent\r | |
176 | )\r | |
177 | {\r | |
e8326a00 ML |
178 | EFI_STATUS Status;\r |
179 | EFI_EVENT_NOTIFY WorkerNotifyFunction;\r | |
e386b444 | 180 | \r |
181 | ASSERT (ReadyToBootEvent != NULL);\r | |
182 | \r | |
c7d265a9 | 183 | if (gST->Hdr.Revision < EFI_2_00_SYSTEM_TABLE_REVISION) {\r |
184 | DEBUG ((EFI_D_ERROR, "EFI1.1 can't support ReadyToBootEvent!"));\r | |
185 | ASSERT (FALSE);\r | |
186 | \r | |
e386b444 | 187 | return EFI_UNSUPPORTED;\r |
188 | } else {\r | |
189 | //\r | |
190 | // For UEFI 2.0 and the future use an Event Group\r | |
191 | //\r | |
e8326a00 ML |
192 | if (NotifyFunction == NULL) {\r |
193 | //\r | |
194 | // CreateEventEx will check NotifyFunction is NULL or not and return error.\r | |
195 | // Use dummy routine for the case NotifyFunction is NULL.\r | |
196 | //\r | |
197 | WorkerNotifyFunction = InternalEmptyFunction;\r | |
198 | } else {\r | |
199 | WorkerNotifyFunction = NotifyFunction;\r | |
200 | }\r | |
e386b444 | 201 | Status = gBS->CreateEventEx (\r |
202 | EVT_NOTIFY_SIGNAL,\r | |
203 | NotifyTpl,\r | |
e8326a00 | 204 | WorkerNotifyFunction,\r |
e386b444 | 205 | NotifyContext,\r |
206 | &gEfiEventReadyToBootGuid,\r | |
207 | ReadyToBootEvent\r | |
208 | );\r | |
209 | }\r | |
210 | \r | |
211 | return Status;\r | |
212 | }\r | |
213 | \r | |
214 | \r | |
215 | /**\r | |
1d37ab9f | 216 | Create, Signal, and Close the Ready to Boot event using EfiSignalEventReadyToBoot().\r |
217 | \r | |
218 | This function abstracts the signaling of the Ready to Boot Event. The Framework moved\r | |
cf8ae2f6 | 219 | from a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller\r |
220 | from how this event is created to prevent to code form having to change with the\r | |
221 | version of the specification supported.\r | |
e386b444 | 222 | \r |
223 | **/\r | |
224 | VOID\r | |
225 | EFIAPI\r | |
226 | EfiSignalEventReadyToBoot (\r | |
227 | VOID\r | |
228 | )\r | |
229 | {\r | |
230 | EFI_STATUS Status;\r | |
231 | EFI_EVENT ReadyToBootEvent;\r | |
232 | \r | |
233 | Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r | |
234 | if (!EFI_ERROR (Status)) {\r | |
235 | gBS->SignalEvent (ReadyToBootEvent);\r | |
236 | gBS->CloseEvent (ReadyToBootEvent);\r | |
237 | }\r | |
238 | }\r | |
239 | \r | |
240 | /**\r | |
1d37ab9f | 241 | Create, Signal, and Close the Ready to Boot event using EfiSignalEventLegacyBoot().\r |
e386b444 | 242 | \r |
1d37ab9f | 243 | This function abstracts the signaling of the Legacy Boot Event. The Framework moved from\r |
244 | a proprietary to UEFI 2.0 based mechanism. This library abstracts the caller from how\r | |
245 | this event is created to prevent to code form having to change with the version of the\r | |
246 | specification supported.\r | |
e386b444 | 247 | \r |
248 | **/\r | |
249 | VOID\r | |
250 | EFIAPI\r | |
251 | EfiSignalEventLegacyBoot (\r | |
252 | VOID\r | |
253 | )\r | |
254 | {\r | |
255 | EFI_STATUS Status;\r | |
256 | EFI_EVENT LegacyBootEvent;\r | |
257 | \r | |
258 | Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r | |
259 | if (!EFI_ERROR (Status)) {\r | |
260 | gBS->SignalEvent (LegacyBootEvent);\r | |
261 | gBS->CloseEvent (LegacyBootEvent);\r | |
262 | }\r | |
263 | }\r | |
264 | \r | |
265 | \r | |
266 | /**\r | |
1d37ab9f | 267 | Check to see if the Firmware Volume (FV) Media Device Path is valid \r |
268 | \r | |
7f1eba7b | 269 | The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r |
270 | This library function abstracts validating a device path node.\r | |
7f1eba7b | 271 | Check the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure to see if it's valid. \r |
1d37ab9f | 272 | If it is valid, then return the GUID file name from the device path node. Otherwise, \r |
273 | return NULL. This device path changed in the DXE CIS version 0.92 in a non back ward \r | |
274 | compatible way to not conflict with the UEFI 2.0 specification. This function abstracts \r | |
275 | the differences from the caller.\r | |
9edc73ad | 276 | If FvDevicePathNode is NULL, then ASSERT().\r |
1d37ab9f | 277 | \r |
2fc59a00 | 278 | @param FvDevicePathNode The pointer to FV device path to check.\r |
e386b444 | 279 | \r |
280 | @retval NULL FvDevicePathNode is not valid.\r | |
281 | @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r | |
282 | \r | |
283 | **/\r | |
070a76b1 | 284 | EFI_GUID *\r |
e386b444 | 285 | EFIAPI\r |
286 | EfiGetNameGuidFromFwVolDevicePathNode (\r | |
070a76b1 | 287 | IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r |
e386b444 | 288 | )\r |
289 | {\r | |
070a76b1 | 290 | ASSERT (FvDevicePathNode != NULL);\r |
c7d265a9 | 291 | \r |
070a76b1 | 292 | if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r |
293 | DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_PIWG_FW_FILE_DP) {\r | |
294 | return (EFI_GUID *) &FvDevicePathNode->FvFileName;\r | |
c7d265a9 | 295 | }\r |
296 | \r | |
e386b444 | 297 | return NULL;\r |
298 | }\r | |
299 | \r | |
300 | \r | |
301 | /**\r | |
1d37ab9f | 302 | Initialize a Firmware Volume (FV) Media Device Path node.\r |
303 | \r | |
7f1eba7b | 304 | The Framework FwVol Device Path changed to conform to the UEFI 2.0 specification. \r |
1d37ab9f | 305 | This library function abstracts initializing a device path node. \r |
7f1eba7b | 306 | Initialize the MEDIA_FW_VOL_FILEPATH_DEVICE_PATH data structure. This device \r |
307 | path changed in the DXE CIS version 0.92 in a non back ward compatible way to \r | |
308 | not conflict with the UEFI 2.0 specification. This function abstracts the \r | |
309 | differences from the caller.\r | |
9edc73ad | 310 | If FvDevicePathNode is NULL, then ASSERT().\r |
311 | If NameGuid is NULL, then ASSERT().\r | |
1d37ab9f | 312 | \r |
2fc59a00 | 313 | @param FvDevicePathNode The pointer to a FV device path node to initialize\r |
e386b444 | 314 | @param NameGuid FV file name to use in FvDevicePathNode\r |
315 | \r | |
316 | **/\r | |
317 | VOID\r | |
318 | EFIAPI\r | |
319 | EfiInitializeFwVolDevicepathNode (\r | |
070a76b1 | 320 | IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r |
321 | IN CONST EFI_GUID *NameGuid\r | |
e386b444 | 322 | )\r |
323 | {\r | |
070a76b1 | 324 | ASSERT (FvDevicePathNode != NULL);\r |
e386b444 | 325 | ASSERT (NameGuid != NULL);\r |
c7d265a9 | 326 | \r |
e386b444 | 327 | //\r |
c7d265a9 | 328 | // Use the new Device path that does not conflict with the UEFI\r |
e386b444 | 329 | //\r |
070a76b1 | 330 | FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r |
331 | FvDevicePathNode->Header.SubType = MEDIA_PIWG_FW_FILE_DP;\r | |
332 | SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r | |
c7d265a9 | 333 | \r |
070a76b1 | 334 | CopyGuid (&FvDevicePathNode->FvFileName, NameGuid);\r |
e386b444 | 335 | }\r |
336 | \r |