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