3 Copyright (c) 2006 - 2009, 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
83 PlatformBdsConnectConsole (
84 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
90 Connect the predefined platform default console device. Always try to find
91 and enable the vga device if have.
95 PlatformConsole - Predfined platform default console device array.
99 EFI_SUCCESS - Success connect at least one ConIn and ConOut
100 device, there must have one ConOut device is
103 EFI_STATUS - Return the status of
104 BdsLibConnectAllDefaultConsoles ()
112 Status
= EFI_SUCCESS
;
115 // Have chance to connect the platform default console,
116 // the platform default console is the minimue device group
117 // the platform should support
119 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
121 // Update the console variable with the connect type
123 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
124 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
127 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
128 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
131 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
132 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
138 // Connect the all the default console with current cosole variable
140 Status
= BdsLibConnectAllDefaultConsoles ();
145 PlatformBdsConnectSequence (
152 Connect with predeined platform connect sequence,
153 the OEM/IBV can customize with their own connect sequence.
170 // Here we can get the customized platform connect sequence
171 // Notes: we can connect with new variable which record the
172 // last time boots connect device path sequence
174 while (gPlatformConnectSequence
[Index
] != NULL
) {
176 // Build the platform boot option
178 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
183 // Just use the simple policy to connect all devices
189 PlatformBdsGetDriverOption (
190 IN OUT LIST_ENTRY
*BdsDriverLists
196 Load the predefined driver option, OEM/IBV can customize this
197 to load their own drivers
201 BdsDriverLists - The header of the driver option link list.
214 // Here we can get the customized platform driver option
216 while (gPlatformDriverOption
[Index
] != NULL
) {
218 // Build the platform boot option
220 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
227 PlatformBdsDiagnostics (
228 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
229 IN BOOLEAN QuietBoot
,
230 IN BASEM_MEMORY_TEST BaseMemoryTest
236 Perform the platform diagnostic, such like test memory. OEM/IBV also
237 can customize this fuction to support specific platform diagnostic.
241 MemoryTestLevel - The memory test intensive level
243 QuietBoot - Indicate if need to enable the quiet boot
245 BaseMemoryTest - A pointer to BdsMemoryTest()
256 // Here we can decide if we need to show
257 // the diagnostics screen
258 // Notes: this quiet boot code should be remove
259 // from the graphic lib
262 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
264 // Perform system diagnostic
266 Status
= BaseMemoryTest (MemoryTestLevel
);
267 if (EFI_ERROR (Status
)) {
274 // Perform system diagnostic
276 Status
= BaseMemoryTest (MemoryTestLevel
);
281 PlatformBdsPolicyBehavior (
282 IN OUT LIST_ENTRY
*DriverOptionList
,
283 IN OUT LIST_ENTRY
*BootOptionList
,
284 IN PROCESS_CAPSULES ProcessCapsules
,
285 IN BASEM_MEMORY_TEST BaseMemoryTest
291 The function will excute with as the platform policy, current policy
292 is driven by boot mode. IBV/OEM can customize this code for their specific
297 DriverOptionList - The header of the driver option link list
299 BootOptionList - The header of the boot option link list
301 ProcessCapsules - A pointer to ProcessCapsules()
303 BaseMemoryTest - A pointer to BaseMemoryTest()
313 EFI_BOOT_MODE BootMode
;
316 // Init the time out value
318 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
321 // Load the driver option as the driver option list
323 PlatformBdsGetDriverOption (DriverOptionList
);
326 // Get current Boot Mode
328 Status
= BdsLibGetBootMode (&BootMode
);
331 // Go the different platform policy with different boot mode
332 // Notes: this part code can be change with the table policy
336 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
337 case BOOT_WITH_MINIMAL_CONFIGURATION
:
339 // In no-configuration boot mode, we can connect the
342 BdsLibConnectAllDefaultConsoles ();
343 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
346 // Perform some platform specific connect sequence
348 PlatformBdsConnectSequence ();
351 // Notes: current time out = 0 can not enter the
354 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
357 // Check the boot option with the boot option list
359 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
362 case BOOT_ON_FLASH_UPDATE
:
364 // Boot with the specific configuration
366 PlatformBdsConnectConsole (gPlatformConsole
);
367 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
369 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
372 case BOOT_IN_RECOVERY_MODE
:
374 // In recovery mode, just connect platform console
375 // and show up the front page
377 PlatformBdsConnectConsole (gPlatformConsole
);
378 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
381 // In recovery boot mode, we still enter to the
384 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
387 case BOOT_WITH_FULL_CONFIGURATION
:
388 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
389 case BOOT_WITH_DEFAULT_SETTINGS
:
392 // Connect platform console
394 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
395 if (EFI_ERROR (Status
)) {
397 // Here OEM/IBV can customize with defined action
399 PlatformBdsNoConsoleAction ();
402 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
405 // Perform some platform specific connect sequence
407 PlatformBdsConnectSequence ();
410 // Give one chance to enter the setup if we
413 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
416 // Here we have enough time to do the enumeration of boot device
418 BdsLibEnumerateAllBootOption (BootOptionList
);
428 PlatformBdsBootSuccess (
429 IN BDS_COMMON_OPTION
*Option
435 Hook point after a boot attempt succeeds. We don't expect a boot option to
436 return, so the EFI 1.0 specification defines that you will default to an
437 interactive mode and stop processing the BootOrder list in this case. This
438 is alos a platform implementation and can be customized by IBV/OEM.
442 Option - Pointer to Boot Option that succeeded to boot.
453 // If Boot returned with EFI_SUCCESS and there is not in the boot device
454 // select loop then we need to pop up a UI and wait for user input.
456 TmpStr
= Option
->StatusString
;
457 if (TmpStr
!= NULL
) {
458 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
465 PlatformBdsBootFail (
466 IN BDS_COMMON_OPTION
*Option
,
467 IN EFI_STATUS Status
,
469 IN UINTN ExitDataSize
475 Hook point after a boot attempt fails.
479 Option - Pointer to Boot Option that failed to boot.
481 Status - Status returned from failed boot.
483 ExitData - Exit data returned from failed boot.
485 ExitDataSize - Exit data size returned from failed boot.
496 // If Boot returned with failed status then we need to pop up a UI and wait
499 TmpStr
= Option
->StatusString
;
500 if (TmpStr
!= NULL
) {
501 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
507 PlatformBdsNoConsoleAction (
514 This function is remained for IBV/OEM to do some platform action,
515 if there no console device can be connected.
523 EFI_SUCCESS - Direct return success now.
532 PlatformBdsLockNonUpdatableFlash (
540 Lock the ConsoleIn device in system table. All key
541 presses will be ignored until the Password is typed in. The only way to
542 disable the password is to type it in to a ConIn device.
544 @param Password Password used to lock ConIn device.
546 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
547 @retval EFI_UNSUPPORTED Password not found
556 return EFI_UNSUPPORTED
;