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