3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This file include all platform action which can be customized
23 #include "BdsPlatform.h"
25 CHAR16 mFirmwareVendor
[] = L
"TianoCore.org";
26 UNIX_SYSTEM_CONFIGURATION mSystemConfigData
;
36 Size
= sizeof (mSystemConfigData
);
37 Status
= gRT
->GetVariable (
39 &gEfiUnixSystemConfigGuid
,
42 (VOID
*) &mSystemConfigData
45 if (EFI_ERROR (Status
)) {
47 // SetupVariable is corrupt
49 mSystemConfigData
.ConOutRow
= PcdGet32 (PcdConOutColumn
);
50 mSystemConfigData
.ConOutColumn
= PcdGet32 (PcdConOutRow
);
52 Status
= gRT
->SetVariable (
54 &gEfiUnixSystemConfigGuid
,
55 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
56 sizeof (mSystemConfigData
),
57 (VOID
*) &mSystemConfigData
59 if (EFI_ERROR (Status
)) {
60 DEBUG ((EFI_D_ERROR
, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status
));
66 // BDS Platform Functions
70 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
76 Platform Bds init. Include the platform firmware vendor, revision
81 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
90 // set firmwarevendor, here can be IBV/OEM customize
92 gST
->FirmwareVendor
= AllocateRuntimeCopyPool (
93 sizeof (mFirmwareVendor
),
96 ASSERT (gST
->FirmwareVendor
!= NULL
);
98 gST
->FirmwareRevision
= 0;
101 // Fixup Tasble CRC after we updated Firmware Vendor and Revision
103 gBS
->CalculateCrc32 ((VOID
*) gST
, sizeof (EFI_SYSTEM_TABLE
), &gST
->Hdr
.CRC32
);
108 PlatformBdsConnectConsole (
109 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
115 Connect the predefined platform default console device. Always try to find
116 and enable the vga device if have.
120 PlatformConsole - Predfined platform default console device array.
124 EFI_SUCCESS - Success connect at least one ConIn and ConOut
125 device, there must have one ConOut device is
128 EFI_STATUS - Return the status of
129 BdsLibConnectAllDefaultConsoles ()
137 Status
= EFI_SUCCESS
;
140 // Have chance to connect the platform default console,
141 // the platform default console is the minimue device group
142 // the platform should support
144 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
146 // Update the console variable with the connect type
148 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
149 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
152 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
153 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
156 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
157 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
163 // Connect the all the default console with current cosole variable
165 Status
= BdsLibConnectAllDefaultConsoles ();
170 PlatformBdsConnectSequence (
177 Connect with predeined platform connect sequence,
178 the OEM/IBV can customize with their own connect sequence.
195 // Here we can get the customized platform connect sequence
196 // Notes: we can connect with new variable which record the
197 // last time boots connect device path sequence
199 while (gPlatformConnectSequence
[Index
] != NULL
) {
201 // Build the platform boot option
203 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
208 // Just use the simple policy to connect all devices
214 PlatformBdsGetDriverOption (
215 IN OUT LIST_ENTRY
*BdsDriverLists
221 Load the predefined driver option, OEM/IBV can customize this
222 to load their own drivers
226 BdsDriverLists - The header of the driver option link list.
239 // Here we can get the customized platform driver option
241 while (gPlatformDriverOption
[Index
] != NULL
) {
243 // Build the platform boot option
245 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
252 PlatformBdsDiagnostics (
253 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
260 Perform the platform diagnostic, such like test memory. OEM/IBV also
261 can customize this fuction to support specific platform diagnostic.
265 MemoryTestLevel - The memory test intensive level
267 QuietBoot - Indicate if need to enable the quiet boot
278 // Here we can decide if we need to show
279 // the diagnostics screen
280 // Notes: this quiet boot code should be remove
281 // from the graphic lib
284 EnableQuietBoot (&gEfiDefaultBmpLogoGuid
);
286 // Perform system diagnostic
288 Status
= BdsMemoryTest (MemoryTestLevel
);
289 if (EFI_ERROR (Status
)) {
296 // Perform system diagnostic
298 Status
= BdsMemoryTest (MemoryTestLevel
);
302 PlatformBdsPolicyBehavior (
303 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
,
304 IN OUT LIST_ENTRY
*DriverOptionList
,
305 IN OUT LIST_ENTRY
*BootOptionList
311 The function will excute with as the platform policy, current policy
312 is driven by boot mode. IBV/OEM can customize this code for their specific
317 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
319 DriverOptionList - The header of the driver option link list
321 BootOptionList - The header of the boot option link list
333 // Init the time out value
335 Timeout
= BdsLibGetTimeout ();
338 // Load the driver option as the driver option list
340 PlatformBdsGetDriverOption (DriverOptionList
);
343 // Get current Boot Mode
345 Status
= BdsLibGetBootMode (&PrivateData
->BootMode
);
348 // Go the different platform policy with different boot mode
349 // Notes: this part code can be change with the table policy
351 switch (PrivateData
->BootMode
) {
353 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
354 case BOOT_WITH_MINIMAL_CONFIGURATION
:
356 // In no-configuration boot mode, we can connect the
359 BdsLibConnectAllDefaultConsoles ();
360 PlatformBdsDiagnostics (IGNORE
, TRUE
);
363 // Perform some platform specific connect sequence
365 PlatformBdsConnectSequence ();
368 // Notes: current time out = 0 can not enter the
371 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
374 // Check the boot option with the boot option list
376 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
379 case BOOT_ON_FLASH_UPDATE
:
381 // Boot with the specific configuration
383 PlatformBdsConnectConsole (gPlatformConsole
);
384 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
386 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
389 case BOOT_IN_RECOVERY_MODE
:
391 // In recovery mode, just connect platform console
392 // and show up the front page
394 PlatformBdsConnectConsole (gPlatformConsole
);
395 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
398 // In recovery boot mode, we still enter to the
401 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
404 case BOOT_WITH_FULL_CONFIGURATION
:
405 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
406 case BOOT_WITH_DEFAULT_SETTINGS
:
409 // Connect platform console
411 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
412 if (EFI_ERROR (Status
)) {
414 // Here OEM/IBV can customize with defined action
416 PlatformBdsNoConsoleAction ();
419 PlatformBdsDiagnostics (IGNORE
, TRUE
);
422 // Perform some platform specific connect sequence
424 PlatformBdsConnectSequence ();
427 // Give one chance to enter the setup if we
430 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
433 // Here we have enough time to do the enumeration of boot device
435 BdsLibEnumerateAllBootOption (BootOptionList
);
444 PlatformBdsBootSuccess (
445 IN BDS_COMMON_OPTION
*Option
451 Hook point after a boot attempt succeeds. We don't expect a boot option to
452 return, so the EFI 1.0 specification defines that you will default to an
453 interactive mode and stop processing the BootOrder list in this case. This
454 is alos a platform implementation and can be customized by IBV/OEM.
458 Option - Pointer to Boot Option that succeeded to boot.
469 // If Boot returned with EFI_SUCCESS and there is not in the boot device
470 // select loop then we need to pop up a UI and wait for user input.
472 TmpStr
= Option
->StatusString
;
473 if (TmpStr
!= NULL
) {
474 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
480 PlatformBdsBootFail (
481 IN BDS_COMMON_OPTION
*Option
,
482 IN EFI_STATUS Status
,
484 IN UINTN ExitDataSize
490 Hook point after a boot attempt fails.
494 Option - Pointer to Boot Option that failed to boot.
496 Status - Status returned from failed boot.
498 ExitData - Exit data returned from failed boot.
500 ExitDataSize - Exit data size returned from failed boot.
511 // If Boot returned with failed status then we need to pop up a UI and wait
514 TmpStr
= Option
->StatusString
;
515 if (TmpStr
!= NULL
) {
516 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
522 PlatformBdsNoConsoleAction (
529 This function is remained for IBV/OEM to do some platform action,
530 if there no console device can be connected.
538 EFI_SUCCESS - Direct return success now.
547 PlatformBdsLockNonUpdatableFlash (