]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Library functions that abstract areas of conflict between Tiano an UEFI 2.0.\r | |
3 | \r | |
4 | Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the\r | |
5 | oldconflicts with library functions and supporting implementations of the old \r | |
6 | (R8.5/EFI 1.10) and new (R9/UEFI 2.0) way.\r | |
7 | \r | |
8 | Copyright (c) 2006, Intel Corporation<BR>\r | |
9 | All rights reserved. This program and the accompanying materials\r | |
10 | are licensed and made available under the terms and conditions of the BSD License\r | |
11 | which accompanies this distribution. The full text of the license may be found at\r | |
12 | http://opensource.org/licenses/bsd-license.php\r | |
13 | \r | |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
16 | \r | |
17 | **/\r | |
18 | \r | |
19 | \r | |
20 | \r | |
21 | /**\r | |
22 | Create a Legacy Boot Event. \r | |
23 | \r | |
24 | Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r | |
25 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
26 | added and now it's possible to not voilate the UEFI specification by \r | |
27 | declaring a GUID for the legacy boot event class. This library supports\r | |
28 | the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to \r | |
29 | work both ways.\r | |
30 | \r | |
31 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
32 | \r | |
33 | @retval EFI_SUCCESS Event was created.\r | |
34 | @retval Other Event was not created.\r | |
35 | \r | |
36 | **/\r | |
37 | EFI_STATUS\r | |
38 | EFIAPI\r | |
39 | EfiCreateEventLegacyBoot (\r | |
abea19db | 40 | OUT EFI_EVENT *LegacyBootEvent\r |
878ddf1f | 41 | )\r |
42 | {\r | |
43 | EFI_STATUS Status;\r | |
44 | \r | |
45 | ASSERT (LegacyBootEvent != NULL);\r | |
46 | \r | |
47 | #if (EFI_SPECIFICATION_VERSION < 0x00020000) \r | |
48 | //\r | |
49 | // prior to UEFI 2.0 use Tiano extension to EFI\r | |
50 | //\r | |
51 | Status = gBS->CreateEvent (\r | |
52 | EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r | |
53 | EFI_TPL_CALLBACK,\r | |
54 | NULL,\r | |
55 | NULL,\r | |
56 | LegacyBootEvent\r | |
57 | );\r | |
58 | #else\r | |
59 | //\r | |
60 | // For UEFI 2.0 and the future use an Event Group\r | |
61 | //\r | |
62 | Status = gBS->CreateEventEx (\r | |
63 | EVENT_NOTIFY_SIGNAL,\r | |
64 | EFI_TPL_CALLBACK,\r | |
65 | NULL,\r | |
66 | NULL,\r | |
67 | &gEfiEventLegacyBootGuid,\r | |
68 | LegacyBootEvent\r | |
69 | );\r | |
70 | #endif\r | |
71 | return Status;\r | |
72 | }\r | |
73 | \r | |
74 | \r | |
75 | \r | |
76 | /**\r | |
77 | Create a Read to Boot Event. \r | |
78 | \r | |
79 | Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r | |
80 | This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r | |
81 | added and now it's possible to not voilate the UEFI specification and use \r | |
82 | the ready to boot event class defined in UEFI 2.0. This library supports\r | |
83 | the R8.5/EFI 1.10 form and R9/UEFI 2.0 form and allows common code to \r | |
84 | work both ways.\r | |
85 | \r | |
86 | @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).\r | |
87 | \r | |
88 | @retval EFI_SUCCESS Event was created.\r | |
89 | @retval Other Event was not created.\r | |
90 | \r | |
91 | **/\r | |
92 | EFI_STATUS\r | |
93 | EFIAPI\r | |
94 | EfiCreateEventReadyToBoot (\r | |
abea19db | 95 | OUT EFI_EVENT *ReadyToBootEvent\r |
878ddf1f | 96 | )\r |
97 | {\r | |
98 | EFI_STATUS Status;\r | |
99 | \r | |
100 | ASSERT (ReadyToBootEvent != NULL);\r | |
101 | \r | |
102 | #if (EFI_SPECIFICATION_VERSION < 0x00020000) \r | |
103 | //\r | |
104 | // prior to UEFI 2.0 use Tiano extension to EFI\r | |
105 | //\r | |
106 | Status = gBS->CreateEvent (\r | |
107 | EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r | |
108 | EFI_TPL_CALLBACK,\r | |
109 | NULL,\r | |
110 | NULL,\r | |
111 | ReadyToBootEvent\r | |
112 | );\r | |
113 | #else\r | |
114 | //\r | |
115 | // For UEFI 2.0 and the future use an Event Group\r | |
116 | //\r | |
117 | Status = gBS->CreateEventEx (\r | |
118 | EVENT_NOTIFY_SIGNAL,\r | |
119 | EFI_TPL_CALLBACK,\r | |
120 | NULL,\r | |
121 | NULL,\r | |
122 | &gEfiEventReadyToBootGuid,\r | |
123 | ReadyToBootEvent\r | |
124 | );\r | |
125 | #endif\r | |
126 | \r | |
127 | return Status;\r | |
128 | }\r | |
129 | \r | |
130 | \r | |
131 | /**\r | |
132 | Signal a Ready to Boot Event. \r | |
133 | \r | |
134 | Create a Ready to Boot Event. Signal it and close it. This causes other \r | |
135 | events of the same event group to be signaled in other modules. \r | |
136 | \r | |
137 | **/\r | |
138 | VOID\r | |
139 | EFIAPI\r | |
140 | EfiSignalEventReadyToBoot (\r | |
141 | VOID\r | |
142 | )\r | |
143 | {\r | |
144 | EFI_STATUS Status;\r | |
145 | EFI_EVENT ReadyToBootEvent;\r | |
146 | \r | |
147 | Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);\r | |
148 | if (!EFI_ERROR (Status)) {\r | |
149 | gBS->SignalEvent (ReadyToBootEvent);\r | |
150 | gBS->CloseEvent (ReadyToBootEvent);\r | |
151 | }\r | |
152 | }\r | |
153 | \r | |
154 | /**\r | |
155 | Signal a Legacy Boot Event. \r | |
156 | \r | |
157 | Create a legacy Boot Event. Signal it and close it. This causes other \r | |
158 | events of the same event group to be signaled in other modules. \r | |
159 | \r | |
160 | **/\r | |
161 | VOID\r | |
162 | EFIAPI\r | |
163 | EfiSignalEventLegacyBoot (\r | |
164 | VOID\r | |
165 | )\r | |
166 | {\r | |
167 | EFI_STATUS Status;\r | |
168 | EFI_EVENT LegacyBootEvent;\r | |
169 | \r | |
170 | Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);\r | |
171 | if (!EFI_ERROR (Status)) {\r | |
172 | gBS->SignalEvent (LegacyBootEvent);\r | |
173 | gBS->CloseEvent (LegacyBootEvent);\r | |
174 | }\r | |
175 | }\r | |
176 | \r | |
177 | \r | |
178 | /**\r | |
179 | Check to see if the Firmware Volume (FV) Media Device Path is valid \r | |
180 | \r | |
181 | Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r | |
182 | so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r | |
183 | the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r | |
184 | device path is defined for PIWG extensions of device path. If the code \r | |
185 | is compiled to conform with the UEFI 2.0 specification use the new device path\r | |
186 | else use the old form for backwards compatability. The return value to this\r | |
187 | function points to a location in FvDevicePathNode and it does not allocate\r | |
188 | new memory for the GUID pointer that is returned.\r | |
189 | \r | |
190 | @param FvDevicePathNode Pointer to FV device path to check.\r | |
191 | \r | |
192 | @retval NULL FvDevicePathNode is not valid.\r | |
193 | @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.\r | |
194 | \r | |
195 | **/\r | |
196 | EFI_GUID *\r | |
197 | EFIAPI\r | |
198 | EfiGetNameGuidFromFwVolDevicePathNode (\r | |
abea19db | 199 | IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r |
878ddf1f | 200 | )\r |
201 | {\r | |
202 | ASSERT (FvDevicePathNode != NULL);\r | |
203 | \r | |
204 | #if (EFI_SPECIFICATION_VERSION < 0x00020000) \r | |
205 | //\r | |
206 | // Use old Device Path that conflicts with UEFI\r | |
207 | //\r | |
208 | if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH ||\r | |
209 | DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r | |
abea19db | 210 | return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r |
878ddf1f | 211 | }\r |
212 | \r | |
213 | #else\r | |
214 | //\r | |
215 | // Use the new Device path that does not conflict with the UEFI\r | |
216 | //\r | |
217 | if (FvDevicePathNode->Piwg.Header.Type == MEDIA_DEVICE_PATH ||\r | |
218 | FvDevicePathNode->Piwg.Header.SubType == MEDIA_VENDOR_DP) {\r | |
219 | if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {\r | |
220 | if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r | |
abea19db | 221 | return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r |
878ddf1f | 222 | }\r |
223 | }\r | |
224 | }\r | |
225 | #endif \r | |
226 | return NULL;\r | |
227 | }\r | |
228 | \r | |
229 | \r | |
230 | /**\r | |
231 | Initialize a Firmware Volume (FV) Media Device Path node.\r | |
232 | \r | |
233 | Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r | |
234 | so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r | |
235 | the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r | |
236 | device path is defined for PIWG extensions of device path. If the code \r | |
237 | is compiled to conform with the UEFI 2.0 specification use the new device path\r | |
238 | else use the old form for backwards compatability.\r | |
239 | \r | |
abea19db | 240 | @param FvDevicePathNode Pointer to a FV device path node to initialize\r |
241 | @param NameGuid FV file name to use in FvDevicePathNode\r | |
878ddf1f | 242 | \r |
243 | **/\r | |
244 | VOID\r | |
245 | EFIAPI\r | |
246 | EfiInitializeFwVolDevicepathNode (\r | |
abea19db | 247 | IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r |
248 | IN CONST EFI_GUID *NameGuid\r | |
878ddf1f | 249 | )\r |
250 | {\r | |
251 | ASSERT (FvDevicePathNode != NULL);\r | |
252 | ASSERT (NameGuid != NULL);\r | |
253 | \r | |
254 | #if (EFI_SPECIFICATION_VERSION < 0x00020000) \r | |
255 | //\r | |
256 | // Use old Device Path that conflicts with UEFI\r | |
257 | //\r | |
258 | FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;\r | |
259 | FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;\r | |
260 | SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r | |
261 | \r | |
262 | #else\r | |
263 | //\r | |
264 | // Use the new Device path that does not conflict with the UEFI\r | |
265 | //\r | |
266 | FvDevicePathNode->Piwg.Header.Type = MEDIA_DEVICE_PATH;\r | |
267 | FvDevicePathNode->Piwg.Header.SubType = MEDIA_VENDOR_DP;\r | |
268 | SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r | |
269 | \r | |
270 | //\r | |
271 | // Add the GUID for generic PIWG device paths\r | |
272 | //\r | |
273 | CopyGuid (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid);\r | |
274 | \r | |
275 | //\r | |
276 | // Add in the FW Vol File Path PIWG defined inforation\r | |
277 | //\r | |
278 | FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;\r | |
279 | \r | |
280 | #endif\r | |
281 | \r | |
282 | CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r | |
283 | \r | |
284 | }\r | |
285 | \r |