3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 Portions copyright (c) 2011, Apple Inc. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "BdsPlatform.h"
17 EMU_SYSTEM_CONFIGURATION mSystemConfigData
;
27 Size
= sizeof (mSystemConfigData
);
28 Status
= gRT
->GetVariable (
30 &gEmuSystemConfigGuid
,
33 (VOID
*) &mSystemConfigData
36 if (EFI_ERROR (Status
)) {
38 // SetupVariable is corrupt
40 mSystemConfigData
.ConOutRow
= PcdGet32 (PcdConOutColumn
);
41 mSystemConfigData
.ConOutColumn
= PcdGet32 (PcdConOutRow
);
43 Status
= gRT
->SetVariable (
45 &gEmuSystemConfigGuid
,
46 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
47 sizeof (mSystemConfigData
),
48 (VOID
*) &mSystemConfigData
50 if (EFI_ERROR (Status
)) {
51 DEBUG ((EFI_D_ERROR
, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status
));
57 // BDS Platform Functions
68 Platform Bds init. Include the platform firmware vendor, revision
81 EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid
);
85 PlatformBdsConnectConsole (
86 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
92 Connect the predefined platform default console device. Always try to find
93 and enable the vga device if have.
97 PlatformConsole - Predefined platform default console device array.
101 EFI_SUCCESS - Success connect at least one ConIn and ConOut
102 device, there must have one ConOut device is
105 EFI_STATUS - Return the status of
106 BdsLibConnectAllDefaultConsoles ()
114 Status
= EFI_SUCCESS
;
117 // Have chance to connect the platform default console,
118 // the platform default console is the minimum device group
119 // the platform should support
121 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
123 // Update the console variable with the connect type
125 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
126 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
129 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
130 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
133 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
134 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
140 // Connect the all the default console with current cosole variable
142 Status
= BdsLibConnectAllDefaultConsoles ();
147 PlatformBdsConnectSequence (
154 Connect with predefined platform connect sequence,
155 the OEM/IBV can customize with their own connect sequence.
172 // Here we can get the customized platform connect sequence
173 // Notes: we can connect with new variable which record the
174 // last time boots connect device path sequence
176 while (gPlatformConnectSequence
[Index
] != NULL
) {
178 // Build the platform boot option
180 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
185 // Just use the simple policy to connect all devices
191 PlatformBdsGetDriverOption (
192 IN OUT LIST_ENTRY
*BdsDriverLists
198 Load the predefined driver option, OEM/IBV can customize this
199 to load their own drivers
203 BdsDriverLists - The header of the driver option link list.
216 // Here we can get the customized platform driver option
218 while (gPlatformDriverOption
[Index
] != NULL
) {
220 // Build the platform boot option
222 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
229 PlatformBdsDiagnostics (
230 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
231 IN BOOLEAN QuietBoot
,
232 IN BASEM_MEMORY_TEST BaseMemoryTest
238 Perform the platform diagnostic, such like test memory. OEM/IBV also
239 can customize this fuction to support specific platform diagnostic.
243 MemoryTestLevel - The memory test intensive level
245 QuietBoot - Indicate if need to enable the quiet boot
247 BaseMemoryTest - A pointer to BdsMemoryTest()
258 // Here we can decide if we need to show
259 // the diagnostics screen
260 // Notes: this quiet boot code should be remove
261 // from the graphic lib
264 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
266 // Perform system diagnostic
268 Status
= BaseMemoryTest (MemoryTestLevel
);
269 if (EFI_ERROR (Status
)) {
276 // Perform system diagnostic
278 Status
= BaseMemoryTest (MemoryTestLevel
);
283 PlatformBdsPolicyBehavior (
284 IN OUT LIST_ENTRY
*DriverOptionList
,
285 IN OUT LIST_ENTRY
*BootOptionList
,
286 IN PROCESS_CAPSULES ProcessCapsules
,
287 IN BASEM_MEMORY_TEST BaseMemoryTest
293 The function will execute with as the platform policy, current policy
294 is driven by boot mode. IBV/OEM can customize this code for their specific
299 DriverOptionList - The header of the driver option link list
301 BootOptionList - The header of the boot option link list
303 ProcessCapsules - A pointer to ProcessCapsules()
305 BaseMemoryTest - A pointer to BaseMemoryTest()
315 EFI_BOOT_MODE BootMode
;
318 // Init the time out value
320 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
323 // Load the driver option as the driver option list
325 PlatformBdsGetDriverOption (DriverOptionList
);
328 // Get current Boot Mode
330 Status
= BdsLibGetBootMode (&BootMode
);
333 // Go the different platform policy with different boot mode
334 // Notes: this part code can be change with the table policy
338 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
339 case BOOT_WITH_MINIMAL_CONFIGURATION
:
341 // In no-configuration boot mode, we can connect the
344 BdsLibConnectAllDefaultConsoles ();
345 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
348 // Perform some platform specific connect sequence
350 PlatformBdsConnectSequence ();
353 // Notes: current time out = 0 can not enter the
356 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
359 // Check the boot option with the boot option list
361 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
364 case BOOT_ON_FLASH_UPDATE
:
366 // Boot with the specific configuration
368 PlatformBdsConnectConsole (gPlatformConsole
);
369 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
371 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
374 case BOOT_IN_RECOVERY_MODE
:
376 // In recovery mode, just connect platform console
377 // and show up the front page
379 PlatformBdsConnectConsole (gPlatformConsole
);
380 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
383 // In recovery boot mode, we still enter to the
386 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
389 case BOOT_WITH_FULL_CONFIGURATION
:
390 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
391 case BOOT_WITH_DEFAULT_SETTINGS
:
394 // Connect platform console
396 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
397 if (EFI_ERROR (Status
)) {
399 // Here OEM/IBV can customize with defined action
401 PlatformBdsNoConsoleAction ();
404 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
407 // Perform some platform specific connect sequence
409 PlatformBdsConnectSequence ();
412 // Give one chance to enter the setup if we
415 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
418 // Here we have enough time to do the enumeration of boot device
420 BdsLibEnumerateAllBootOption (BootOptionList
);
430 PlatformBdsBootSuccess (
431 IN BDS_COMMON_OPTION
*Option
437 Hook point after a boot attempt succeeds. We don't expect a boot option to
438 return, so the EFI 1.0 specification defines that you will default to an
439 interactive mode and stop processing the BootOrder list in this case. This
440 is alos a platform implementation and can be customized by IBV/OEM.
444 Option - Pointer to Boot Option that succeeded to boot.
455 // If Boot returned with EFI_SUCCESS and there is not in the boot device
456 // select loop then we need to pop up a UI and wait for user input.
458 TmpStr
= Option
->StatusString
;
459 if (TmpStr
!= NULL
) {
460 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
467 PlatformBdsBootFail (
468 IN BDS_COMMON_OPTION
*Option
,
469 IN EFI_STATUS Status
,
471 IN UINTN ExitDataSize
477 Hook point after a boot attempt fails.
481 Option - Pointer to Boot Option that failed to boot.
483 Status - Status returned from failed boot.
485 ExitData - Exit data returned from failed boot.
487 ExitDataSize - Exit data size returned from failed boot.
498 // If Boot returned with failed status then we need to pop up a UI and wait
501 TmpStr
= Option
->StatusString
;
502 if (TmpStr
!= NULL
) {
503 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
509 PlatformBdsNoConsoleAction (
516 This function is remained for IBV/OEM to do some platform action,
517 if there no console device can be connected.
525 EFI_SUCCESS - Direct return success now.
534 PlatformBdsLockNonUpdatableFlash (
542 Lock the ConsoleIn device in system table. All key
543 presses will be ignored until the Password is typed in. The only way to
544 disable the password is to type it in to a ConIn device.
546 @param Password Password used to lock ConIn device.
548 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
549 @retval EFI_UNSUPPORTED Password not found
558 return EFI_UNSUPPORTED
;