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