]>
Commit | Line | Data |
---|---|---|
5c08e117 | 1 | /** @file\r |
128efbbc | 2 | This module produce main entry for BDS phase - BdsEntry.\r |
5c08e117 | 3 | When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed\r |
4 | which contains interface of BdsEntry.\r | |
5 | After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked\r | |
6 | to enter BDS phase.\r | |
7 | \r | |
46433d44 | 8 | Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r |
180a5a35 | 9 | This program and the accompanying materials\r |
5c08e117 | 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 | #include "Bds.h"\r | |
20 | #include "Language.h"\r | |
21 | #include "FrontPage.h"\r | |
22 | #include "Hotkey.h"\r | |
23 | #include "HwErrRecSupport.h"\r | |
24 | \r | |
25 | ///\r | |
26 | /// BDS arch protocol instance initial value.\r | |
27 | ///\r | |
28 | /// Note: Current BDS not directly get the BootMode, DefaultBoot,\r | |
29 | /// TimeoutDefault, MemoryTestLevel value from the BDS arch protocol.\r | |
128efbbc | 30 | /// Please refer to the library useage of BdsLibGetBootMode, BdsLibGetTimeout\r |
5c08e117 | 31 | /// and PlatformBdsDiagnostics in BdsPlatform.c\r |
32 | ///\r | |
f7cdf5cd | 33 | EFI_HANDLE gBdsHandle = NULL;\r |
34 | \r | |
35 | EFI_BDS_ARCH_PROTOCOL gBds = {\r | |
36 | BdsEntry\r | |
5c08e117 | 37 | };\r |
38 | \r | |
39 | UINT16 *mBootNext = NULL;\r | |
40 | \r | |
ff843847 RN |
41 | ///\r |
42 | /// The read-only variables defined in UEFI Spec.\r | |
43 | ///\r | |
44 | CHAR16 *mReadOnlyVariables[] = {\r | |
45 | L"PlatformLangCodes",\r | |
46 | L"LangCodes",\r | |
47 | L"BootOptionSupport",\r | |
48 | L"HwErrRecSupport",\r | |
49 | L"OsIndicationsSupported"\r | |
50 | };\r | |
51 | \r | |
5c08e117 | 52 | /**\r |
53 | \r | |
54 | Install Boot Device Selection Protocol\r | |
55 | \r | |
56 | @param ImageHandle The image handle.\r | |
57 | @param SystemTable The system table.\r | |
58 | \r | |
59 | @retval EFI_SUCEESS BDS has finished initializing.\r | |
60 | Return the dispatcher and recall BDS.Entry\r | |
61 | @retval Other Return status from AllocatePool() or gBS->InstallProtocolInterface\r | |
62 | \r | |
63 | **/\r | |
64 | EFI_STATUS\r | |
65 | EFIAPI\r | |
66 | BdsInitialize (\r | |
67 | IN EFI_HANDLE ImageHandle,\r | |
68 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
69 | )\r | |
70 | {\r | |
71 | EFI_STATUS Status;\r | |
72 | \r | |
5c08e117 | 73 | //\r |
74 | // Install protocol interface\r | |
75 | //\r | |
f7cdf5cd | 76 | Status = gBS->InstallMultipleProtocolInterfaces (\r |
77 | &gBdsHandle,\r | |
78 | &gEfiBdsArchProtocolGuid, &gBds,\r | |
79 | NULL\r | |
5c08e117 | 80 | );\r |
81 | ASSERT_EFI_ERROR (Status);\r | |
82 | \r | |
83 | return Status;\r | |
84 | }\r | |
85 | \r | |
86 | /**\r | |
87 | \r | |
88 | This function attempts to boot for the boot order specified\r | |
89 | by platform policy.\r | |
90 | \r | |
91 | **/\r | |
92 | VOID\r | |
93 | BdsBootDeviceSelect (\r | |
94 | VOID\r | |
95 | )\r | |
96 | {\r | |
97 | EFI_STATUS Status;\r | |
98 | LIST_ENTRY *Link;\r | |
99 | BDS_COMMON_OPTION *BootOption;\r | |
100 | UINTN ExitDataSize;\r | |
101 | CHAR16 *ExitData;\r | |
102 | UINT16 Timeout;\r | |
103 | LIST_ENTRY BootLists;\r | |
104 | CHAR16 Buffer[20];\r | |
105 | BOOLEAN BootNextExist;\r | |
106 | LIST_ENTRY *LinkBootNext;\r | |
5676ccca | 107 | EFI_EVENT ConnectConInEvent;\r |
5c08e117 | 108 | \r |
109 | //\r | |
110 | // Got the latest boot option\r | |
111 | //\r | |
112 | BootNextExist = FALSE;\r | |
113 | LinkBootNext = NULL;\r | |
5676ccca | 114 | ConnectConInEvent = NULL;\r |
5c08e117 | 115 | InitializeListHead (&BootLists);\r |
116 | \r | |
117 | //\r | |
118 | // First check the boot next option\r | |
119 | //\r | |
120 | ZeroMem (Buffer, sizeof (Buffer));\r | |
121 | \r | |
5676ccca | 122 | //\r |
123 | // Create Event to signal ConIn connection request\r | |
124 | //\r | |
125 | if (PcdGetBool (PcdConInConnectOnDemand)) {\r | |
126 | Status = gBS->CreateEventEx (\r | |
127 | EVT_NOTIFY_SIGNAL,\r | |
128 | TPL_CALLBACK,\r | |
fe813348 | 129 | EfiEventEmptyFunction,\r |
5676ccca | 130 | NULL,\r |
131 | &gConnectConInEventGuid,\r | |
132 | &ConnectConInEvent\r | |
133 | );\r | |
134 | if (EFI_ERROR(Status)) {\r | |
135 | ConnectConInEvent = NULL;\r | |
136 | }\r | |
137 | }\r | |
138 | \r | |
5c08e117 | 139 | if (mBootNext != NULL) {\r |
140 | //\r | |
141 | // Indicate we have the boot next variable, so this time\r | |
142 | // boot will always have this boot option\r | |
143 | //\r | |
144 | BootNextExist = TRUE;\r | |
145 | \r | |
146 | //\r | |
147 | // Clear the this variable so it's only exist in this time boot\r | |
148 | //\r | |
69fc8f08 RN |
149 | Status = gRT->SetVariable (\r |
150 | L"BootNext",\r | |
151 | &gEfiGlobalVariableGuid,\r | |
152 | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r | |
153 | 0,\r | |
154 | NULL\r | |
155 | );\r | |
156 | //\r | |
157 | // Deleting variable with current variable implementation shouldn't fail.\r | |
158 | //\r | |
159 | ASSERT_EFI_ERROR (Status);\r | |
5c08e117 | 160 | \r |
161 | //\r | |
162 | // Add the boot next boot option\r | |
163 | //\r | |
164 | UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *mBootNext);\r | |
165 | BootOption = BdsLibVariableToOption (&BootLists, Buffer);\r | |
128efbbc | 166 | \r |
5c08e117 | 167 | //\r |
168 | // If fail to get boot option from variable, just return and do nothing.\r | |
169 | //\r | |
170 | if (BootOption == NULL) {\r | |
171 | return;\r | |
172 | }\r | |
128efbbc | 173 | \r |
5c08e117 | 174 | BootOption->BootCurrent = *mBootNext;\r |
175 | }\r | |
176 | //\r | |
177 | // Parse the boot order to get boot option\r | |
178 | //\r | |
179 | BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r | |
d8600108 RN |
180 | \r |
181 | //\r | |
182 | // When we didn't have chance to build boot option variables in the first \r | |
183 | // full configuration boot (e.g.: Reset in the first page or in Device Manager),\r | |
184 | // we have no boot options in the following mini configuration boot.\r | |
185 | // Give the last chance to enumerate the boot options.\r | |
186 | //\r | |
187 | if (IsListEmpty (&BootLists)) {\r | |
188 | BdsLibEnumerateAllBootOption (&BootLists);\r | |
189 | }\r | |
190 | \r | |
5c08e117 | 191 | Link = BootLists.ForwardLink;\r |
192 | \r | |
193 | //\r | |
194 | // Parameter check, make sure the loop will be valid\r | |
195 | //\r | |
196 | if (Link == NULL) {\r | |
197 | return ;\r | |
198 | }\r | |
199 | //\r | |
200 | // Here we make the boot in a loop, every boot success will\r | |
201 | // return to the front page\r | |
202 | //\r | |
203 | for (;;) {\r | |
204 | //\r | |
205 | // Check the boot option list first\r | |
206 | //\r | |
207 | if (Link == &BootLists) {\r | |
5676ccca | 208 | //\r |
209 | // When LazyConIn enabled, signal connect ConIn event before enter UI\r | |
210 | //\r | |
211 | if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r | |
212 | gBS->SignalEvent (ConnectConInEvent);\r | |
213 | }\r | |
214 | \r | |
5c08e117 | 215 | //\r |
216 | // There are two ways to enter here:\r | |
217 | // 1. There is no active boot option, give user chance to\r | |
218 | // add new boot option\r | |
219 | // 2. All the active boot option processed, and there is no\r | |
220 | // one is success to boot, then we back here to allow user\r | |
221 | // add new active boot option\r | |
222 | //\r | |
223 | Timeout = 0xffff;\r | |
224 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
225 | InitializeListHead (&BootLists);\r | |
226 | BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r | |
227 | Link = BootLists.ForwardLink;\r | |
228 | continue;\r | |
229 | }\r | |
230 | //\r | |
231 | // Get the boot option from the link list\r | |
232 | //\r | |
233 | BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r | |
234 | \r | |
235 | //\r | |
236 | // According to EFI Specification, if a load option is not marked\r | |
237 | // as LOAD_OPTION_ACTIVE, the boot manager will not automatically\r | |
238 | // load the option.\r | |
239 | //\r | |
240 | if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r | |
241 | //\r | |
baf46e70 | 242 | // skip the header of the link list, because it has no boot option\r |
5c08e117 | 243 | //\r |
244 | Link = Link->ForwardLink;\r | |
245 | continue;\r | |
246 | }\r | |
247 | //\r | |
248 | // Make sure the boot option device path connected,\r | |
249 | // but ignore the BBS device path\r | |
250 | //\r | |
251 | if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r | |
252 | //\r | |
253 | // Notes: the internal shell can not been connected with device path\r | |
254 | // so we do not check the status here\r | |
255 | //\r | |
256 | BdsLibConnectDevicePath (BootOption->DevicePath);\r | |
257 | }\r | |
2df686c6 | 258 | \r |
259 | //\r | |
260 | // Restore to original mode before launching boot option.\r | |
261 | //\r | |
262 | BdsSetConsoleMode (FALSE);\r | |
263 | \r | |
5c08e117 | 264 | //\r |
265 | // All the driver options should have been processed since\r | |
266 | // now boot will be performed.\r | |
267 | //\r | |
268 | Status = BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r | |
59b9d73e | 269 | if (Status != EFI_SUCCESS) {\r |
5c08e117 | 270 | //\r |
271 | // Call platform action to indicate the boot fail\r | |
272 | //\r | |
273 | BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r | |
274 | PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);\r | |
275 | \r | |
276 | //\r | |
277 | // Check the next boot option\r | |
278 | //\r | |
279 | Link = Link->ForwardLink;\r | |
280 | \r | |
281 | } else {\r | |
282 | //\r | |
283 | // Call platform action to indicate the boot success\r | |
284 | //\r | |
128efbbc | 285 | BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r |
5c08e117 | 286 | PlatformBdsBootSuccess (BootOption);\r |
287 | \r | |
288 | //\r | |
289 | // Boot success, then stop process the boot order, and\r | |
290 | // present the boot manager menu, front page\r | |
291 | //\r | |
5676ccca | 292 | \r |
293 | //\r | |
294 | // When LazyConIn enabled, signal connect ConIn Event before enter UI\r | |
295 | //\r | |
296 | if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r | |
297 | gBS->SignalEvent (ConnectConInEvent);\r | |
298 | }\r | |
299 | \r | |
5c08e117 | 300 | Timeout = 0xffff;\r |
301 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
302 | \r | |
303 | //\r | |
baf46e70 | 304 | // Rescan the boot option list, avoid potential risk of the boot\r |
5c08e117 | 305 | // option change in front page\r |
306 | //\r | |
307 | if (BootNextExist) {\r | |
308 | LinkBootNext = BootLists.ForwardLink;\r | |
309 | }\r | |
310 | \r | |
311 | InitializeListHead (&BootLists);\r | |
312 | if (LinkBootNext != NULL) {\r | |
313 | //\r | |
314 | // Reserve the boot next option\r | |
315 | //\r | |
316 | InsertTailList (&BootLists, LinkBootNext);\r | |
317 | }\r | |
318 | \r | |
319 | BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r | |
320 | Link = BootLists.ForwardLink;\r | |
321 | }\r | |
322 | }\r | |
323 | \r | |
324 | }\r | |
325 | \r | |
7ea22852 ED |
326 | /**\r |
327 | \r | |
328 | Validate input console variable data. \r | |
329 | \r | |
330 | If found the device path is not a valid device path, remove the variable.\r | |
331 | \r | |
332 | @param VariableName Input console variable name.\r | |
333 | \r | |
334 | **/\r | |
7ea22852 ED |
335 | VOID\r |
336 | BdsFormalizeConsoleVariable (\r | |
337 | IN CHAR16 *VariableName\r | |
338 | )\r | |
339 | {\r | |
340 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
341 | UINTN VariableSize;\r | |
342 | EFI_STATUS Status;\r | |
343 | \r | |
344 | DevicePath = BdsLibGetVariableAndSize (\r | |
345 | VariableName,\r | |
346 | &gEfiGlobalVariableGuid,\r | |
347 | &VariableSize\r | |
348 | );\r | |
98b241d6 | 349 | if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) { \r |
7ea22852 ED |
350 | Status = gRT->SetVariable (\r |
351 | VariableName,\r | |
352 | &gEfiGlobalVariableGuid,\r | |
353 | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r | |
354 | 0,\r | |
355 | NULL\r | |
356 | );\r | |
69fc8f08 RN |
357 | //\r |
358 | // Deleting variable with current variable implementation shouldn't fail.\r | |
359 | //\r | |
7ea22852 ED |
360 | ASSERT_EFI_ERROR (Status);\r |
361 | }\r | |
362 | }\r | |
363 | \r | |
364 | /**\r | |
365 | \r | |
18cf3950 | 366 | Formalize Bds global variables. \r |
7ea22852 | 367 | \r |
18cf3950 | 368 | 1. For ConIn/ConOut/ConErr, if found the device path is not a valid device path, remove the variable.\r |
369 | 2. For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps \r | |
370 | 3. Delete OsIndications variable if it is not NV/BS/RT UINT64\r | |
371 | Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.\r | |
372 | \r | |
7ea22852 ED |
373 | **/\r |
374 | VOID \r | |
375 | BdsFormalizeEfiGlobalVariable (\r | |
376 | VOID\r | |
377 | )\r | |
378 | {\r | |
18cf3950 | 379 | EFI_STATUS Status;\r |
380 | UINT64 OsIndicationSupport;\r | |
381 | UINT64 OsIndication;\r | |
382 | UINTN DataSize;\r | |
383 | UINT32 Attributes;\r | |
384 | \r | |
7ea22852 ED |
385 | //\r |
386 | // Validate Console variable.\r | |
387 | //\r | |
388 | BdsFormalizeConsoleVariable (L"ConIn");\r | |
389 | BdsFormalizeConsoleVariable (L"ConOut");\r | |
390 | BdsFormalizeConsoleVariable (L"ErrOut");\r | |
18cf3950 | 391 | \r |
392 | //\r | |
393 | // OS indicater support variable\r | |
394 | //\r | |
566771b0 | 395 | OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI \\r |
396 | | EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;\r | |
397 | \r | |
69fc8f08 RN |
398 | BdsDxeSetVariableAndReportStatusCodeOnError (\r |
399 | L"OsIndicationsSupported",\r | |
400 | &gEfiGlobalVariableGuid,\r | |
401 | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
402 | sizeof(UINT64),\r | |
403 | &OsIndicationSupport\r | |
404 | );\r | |
18cf3950 | 405 | \r |
406 | //\r | |
407 | // If OsIndications is invalid, remove it.\r | |
408 | // Invalid case\r | |
409 | // 1. Data size != UINT64\r | |
410 | // 2. OsIndication value inconsistence\r | |
411 | // 3. OsIndication attribute inconsistence\r | |
412 | //\r | |
413 | OsIndication = 0;\r | |
414 | Attributes = 0;\r | |
415 | DataSize = sizeof(UINT64);\r | |
416 | Status = gRT->GetVariable (\r | |
417 | L"OsIndications",\r | |
418 | &gEfiGlobalVariableGuid,\r | |
419 | &Attributes,\r | |
420 | &DataSize,\r | |
421 | &OsIndication\r | |
422 | );\r | |
423 | \r | |
424 | if (!EFI_ERROR(Status)) {\r | |
425 | if (DataSize != sizeof(UINT64) ||\r | |
426 | (OsIndication & ~OsIndicationSupport) != 0 ||\r | |
427 | Attributes != (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE)){\r | |
428 | \r | |
429 | DEBUG ((EFI_D_ERROR, "Unformalized OsIndications variable exists. Delete it\n"));\r | |
430 | Status = gRT->SetVariable (\r | |
431 | L"OsIndications",\r | |
432 | &gEfiGlobalVariableGuid,\r | |
18cf3950 | 433 | 0,\r |
69fc8f08 RN |
434 | 0,\r |
435 | NULL\r | |
18cf3950 | 436 | );\r |
69fc8f08 RN |
437 | //\r |
438 | // Deleting variable with current variable implementation shouldn't fail.\r | |
439 | //\r | |
18cf3950 | 440 | ASSERT_EFI_ERROR (Status);\r |
441 | }\r | |
442 | }\r | |
443 | \r | |
7ea22852 ED |
444 | }\r |
445 | \r | |
5c08e117 | 446 | /**\r |
447 | \r | |
448 | Service routine for BdsInstance->Entry(). Devices are connected, the\r | |
449 | consoles are initialized, and the boot options are tried.\r | |
450 | \r | |
451 | @param This Protocol Instance structure.\r | |
452 | \r | |
453 | **/\r | |
454 | VOID\r | |
455 | EFIAPI\r | |
456 | BdsEntry (\r | |
457 | IN EFI_BDS_ARCH_PROTOCOL *This\r | |
458 | )\r | |
459 | {\r | |
5c08e117 | 460 | LIST_ENTRY DriverOptionList;\r |
461 | LIST_ENTRY BootOptionList;\r | |
462 | UINTN BootNextSize;\r | |
9a6b4de2 | 463 | CHAR16 *FirmwareVendor;\r |
e1e91b73 SZ |
464 | EFI_STATUS Status;\r |
465 | UINT16 BootTimeOut;\r | |
ff843847 RN |
466 | UINTN Index;\r |
467 | EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;\r | |
5c08e117 | 468 | \r |
469 | //\r | |
470 | // Insert the performance probe\r | |
471 | //\r | |
128efbbc | 472 | PERF_END (NULL, "DXE", NULL, 0);\r |
473 | PERF_START (NULL, "BDS", NULL, 0);\r | |
5c08e117 | 474 | \r |
475 | //\r | |
476 | // Initialize the global system boot option and driver option\r | |
477 | //\r | |
478 | InitializeListHead (&DriverOptionList);\r | |
479 | InitializeListHead (&BootOptionList);\r | |
480 | \r | |
481 | //\r | |
482 | // Initialize hotkey service\r | |
483 | //\r | |
484 | InitializeHotkeyService ();\r | |
485 | \r | |
9a6b4de2 | 486 | //\r |
487 | // Fill in FirmwareVendor and FirmwareRevision from PCDs\r | |
488 | //\r | |
489 | FirmwareVendor = (CHAR16 *)PcdGetPtr (PcdFirmwareVendor);\r | |
490 | gST->FirmwareVendor = AllocateRuntimeCopyPool (StrSize (FirmwareVendor), FirmwareVendor);\r | |
491 | ASSERT (gST->FirmwareVendor != NULL);\r | |
492 | gST->FirmwareRevision = PcdGet32 (PcdFirmwareRevision);\r | |
493 | \r | |
494 | //\r | |
495 | // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r | |
496 | //\r | |
d2b9b337 | 497 | gST->Hdr.CRC32 = 0;\r |
9a6b4de2 | 498 | gBS->CalculateCrc32 ((VOID *)gST, sizeof(EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r |
499 | \r | |
7ea22852 ED |
500 | //\r |
501 | // Validate Variable.\r | |
502 | //\r | |
503 | BdsFormalizeEfiGlobalVariable();\r | |
504 | \r | |
ff843847 RN |
505 | //\r |
506 | // Mark the read-only variables if the Variable Lock protocol exists\r | |
507 | //\r | |
508 | Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r | |
509 | DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));\r | |
510 | if (!EFI_ERROR (Status)) {\r | |
bdb898a5 | 511 | for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {\r |
ff843847 RN |
512 | Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);\r |
513 | ASSERT_EFI_ERROR (Status);\r | |
514 | }\r | |
515 | }\r | |
516 | \r | |
cb38c322 | 517 | //\r |
518 | // Report Status Code to indicate connecting drivers will happen\r | |
519 | //\r | |
520 | REPORT_STATUS_CODE (\r | |
521 | EFI_PROGRESS_CODE,\r | |
522 | (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)\r | |
523 | );\r | |
524 | \r | |
a2b35995 | 525 | InitializeHwErrRecSupport();\r |
128efbbc | 526 | \r |
e1e91b73 SZ |
527 | //\r |
528 | // Initialize L"Timeout" EFI global variable.\r | |
529 | //\r | |
530 | BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);\r | |
531 | if (BootTimeOut != 0xFFFF) {\r | |
532 | //\r | |
533 | // If time out value equal 0xFFFF, no need set to 0xFFFF to variable area because UEFI specification\r | |
534 | // define same behavior between no value or 0xFFFF value for L"Timeout".\r | |
535 | //\r | |
69fc8f08 | 536 | BdsDxeSetVariableAndReportStatusCodeOnError (\r |
e1e91b73 SZ |
537 | L"Timeout",\r |
538 | &gEfiGlobalVariableGuid,\r | |
539 | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r | |
540 | sizeof (UINT16),\r | |
541 | &BootTimeOut\r | |
542 | );\r | |
e1e91b73 SZ |
543 | }\r |
544 | \r | |
5c08e117 | 545 | //\r |
546 | // bugbug: platform specific code\r | |
547 | // Initialize the platform specific string and language\r | |
548 | //\r | |
549 | InitializeStringSupport ();\r | |
550 | InitializeLanguage (TRUE);\r | |
551 | InitializeFrontPage (TRUE);\r | |
552 | \r | |
ff843847 RN |
553 | //\r |
554 | // Do the platform init, can be customized by OEM/IBV\r | |
555 | //\r | |
556 | PERF_START (NULL, "PlatformBds", "BDS", 0);\r | |
557 | PlatformBdsInit ();\r | |
558 | \r | |
5c08e117 | 559 | //\r |
560 | // Set up the device list based on EFI 1.1 variables\r | |
561 | // process Driver#### and Load the driver's in the\r | |
562 | // driver option list\r | |
563 | //\r | |
564 | BdsLibBuildOptionFromVar (&DriverOptionList, L"DriverOrder");\r | |
565 | if (!IsListEmpty (&DriverOptionList)) {\r | |
566 | BdsLibLoadDrivers (&DriverOptionList);\r | |
567 | }\r | |
568 | //\r | |
569 | // Check if we have the boot next option\r | |
570 | //\r | |
571 | mBootNext = BdsLibGetVariableAndSize (\r | |
572 | L"BootNext",\r | |
573 | &gEfiGlobalVariableGuid,\r | |
574 | &BootNextSize\r | |
575 | );\r | |
576 | \r | |
577 | //\r | |
578 | // Setup some platform policy here\r | |
579 | //\r | |
19bf20e1 | 580 | PlatformBdsPolicyBehavior (&DriverOptionList, &BootOptionList, BdsProcessCapsules, BdsMemoryTest);\r |
128efbbc | 581 | PERF_END (NULL, "PlatformBds", "BDS", 0);\r |
5c08e117 | 582 | \r |
583 | //\r | |
584 | // BDS select the boot device to load OS\r | |
585 | //\r | |
586 | BdsBootDeviceSelect ();\r | |
587 | \r | |
588 | //\r | |
589 | // Only assert here since this is the right behavior, we should never\r | |
590 | // return back to DxeCore.\r | |
591 | //\r | |
592 | ASSERT (FALSE);\r | |
593 | \r | |
594 | return ;\r | |
595 | }\r | |
69fc8f08 RN |
596 | \r |
597 | \r | |
598 | /**\r | |
599 | Set the variable and report the error through status code upon failure.\r | |
600 | \r | |
601 | @param VariableName A Null-terminated string that is the name of the vendor's variable.\r | |
602 | Each VariableName is unique for each VendorGuid. VariableName must\r | |
603 | contain 1 or more characters. If VariableName is an empty string,\r | |
604 | then EFI_INVALID_PARAMETER is returned.\r | |
605 | @param VendorGuid A unique identifier for the vendor.\r | |
606 | @param Attributes Attributes bitmask to set for the variable.\r | |
607 | @param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE, \r | |
608 | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or \r | |
609 | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero \r | |
610 | causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is \r | |
611 | set, then a SetVariable() call with a DataSize of zero will not cause any change to \r | |
612 | the variable value (the timestamp associated with the variable may be updated however \r | |
613 | even if no new data value is provided,see the description of the \r | |
614 | EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not \r | |
615 | be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated). \r | |
616 | @param Data The contents for the variable.\r | |
617 | \r | |
618 | @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r | |
619 | defined by the Attributes.\r | |
620 | @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the\r | |
621 | DataSize exceeds the maximum allowed.\r | |
622 | @retval EFI_INVALID_PARAMETER VariableName is an empty string.\r | |
623 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r | |
624 | @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r | |
625 | @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r | |
626 | @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r | |
627 | @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS \r | |
628 | or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo \r | |
629 | does NOT pass the validation check carried out by the firmware.\r | |
630 | \r | |
631 | @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r | |
632 | **/\r | |
633 | EFI_STATUS\r | |
634 | BdsDxeSetVariableAndReportStatusCodeOnError (\r | |
635 | IN CHAR16 *VariableName,\r | |
636 | IN EFI_GUID *VendorGuid,\r | |
637 | IN UINT32 Attributes,\r | |
638 | IN UINTN DataSize,\r | |
639 | IN VOID *Data\r | |
640 | )\r | |
641 | {\r | |
642 | EFI_STATUS Status;\r | |
643 | EDKII_SET_VARIABLE_STATUS *SetVariableStatus;\r | |
644 | UINTN NameSize;\r | |
645 | \r | |
646 | Status = gRT->SetVariable (\r | |
647 | VariableName,\r | |
648 | VendorGuid,\r | |
649 | Attributes,\r | |
650 | DataSize,\r | |
651 | Data\r | |
652 | );\r | |
653 | if (EFI_ERROR (Status)) {\r | |
654 | NameSize = StrSize (VariableName);\r | |
655 | SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);\r | |
656 | if (SetVariableStatus != NULL) {\r | |
657 | CopyGuid (&SetVariableStatus->Guid, VendorGuid);\r | |
658 | SetVariableStatus->NameSize = NameSize;\r | |
659 | SetVariableStatus->DataSize = DataSize;\r | |
660 | SetVariableStatus->SetStatus = Status;\r | |
661 | SetVariableStatus->Attributes = Attributes;\r | |
662 | CopyMem (SetVariableStatus + 1, VariableName, NameSize);\r | |
663 | CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data, DataSize);\r | |
664 | \r | |
665 | REPORT_STATUS_CODE_EX (\r | |
666 | EFI_ERROR_CODE,\r | |
667 | PcdGet32 (PcdErrorCodeSetVariable),\r | |
668 | 0,\r | |
669 | NULL,\r | |
670 | &gEdkiiStatusCodeDataTypeVariableGuid,\r | |
671 | SetVariableStatus,\r | |
672 | sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize\r | |
673 | );\r | |
674 | \r | |
675 | FreePool (SetVariableStatus);\r | |
676 | }\r | |
677 | }\r | |
678 | \r | |
679 | return Status;\r | |
680 | }\r | |
681 | \r |