3 Copyright (c) 2004 - 2006, 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 WIN_NT_SYSTEM_CONFIGURATION mSystemConfigData
;
36 Size
= sizeof (mSystemConfigData
);
37 Status
= gRT
->GetVariable (
39 &gEfiWinNtSystemConfigGuid
,
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 &gEfiWinNtSystemConfigGuid
,
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
);
105 SetupVariableInit ();
109 PlatformBdsConnectConsole (
110 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
116 Connect the predefined platform default console device. Always try to find
117 and enable the vga device if have.
121 PlatformConsole - Predfined platform default console device array.
125 EFI_SUCCESS - Success connect at least one ConIn and ConOut
126 device, there must have one ConOut device is
129 EFI_STATUS - Return the status of
130 BdsLibConnectAllDefaultConsoles ()
138 Status
= EFI_SUCCESS
;
141 // Have chance to connect the platform default console,
142 // the platform default console is the minimue device group
143 // the platform should support
145 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
147 // Update the console variable with the connect type
149 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
150 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
153 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
154 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
157 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
158 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
164 // Connect the all the default console with current cosole variable
166 Status
= BdsLibConnectAllDefaultConsoles ();
172 PlatformBdsConnectSequence (
179 Connect with predeined platform connect sequence,
180 the OEM/IBV can customize with their own connect sequence.
197 // Here we can get the customized platform connect sequence
198 // Notes: we can connect with new variable which record the
199 // last time boots connect device path sequence
201 while (gPlatformConnectSequence
[Index
] != NULL
) {
203 // Build the platform boot option
205 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
210 // Jst use the simple policy to connect all devices
216 PlatformBdsGetDriverOption (
217 IN OUT LIST_ENTRY
*BdsDriverLists
223 Load the predefined driver option, OEM/IBV can customize this
224 to load their own drivers
228 BdsDriverLists - The header of the driver option link list.
241 // Here we can get the customized platform driver option
243 while (gPlatformDriverOption
[Index
] != NULL
) {
245 // Build the platform boot option
247 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
254 PlatformBdsDiagnostics (
255 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
262 Perform the platform diagnostic, such like test memory. OEM/IBV also
263 can customize this fuction to support specific platform diagnostic.
267 MemoryTestLevel - The memory test intensive level
269 QuietBoot - Indicate if need to enable the quiet boot
280 // Here we can decide if we need to show
281 // the diagnostics screen
282 // Notes: this quiet boot code should be remove
283 // from the graphic lib
286 EnableQuietBoot (&gEfiDefaultBmpLogoGuid
);
288 // Perform system diagnostic
290 Status
= BdsMemoryTest (MemoryTestLevel
);
291 if (EFI_ERROR (Status
)) {
298 // Perform system diagnostic
300 Status
= BdsMemoryTest (MemoryTestLevel
);
304 PlatformBdsPolicyBehavior (
305 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
,
306 IN OUT LIST_ENTRY
*DriverOptionList
,
307 IN OUT LIST_ENTRY
*BootOptionList
313 The function will excute with as the platform policy, current policy
314 is driven by boot mode. IBV/OEM can customize this code for their specific
319 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
321 DriverOptionList - The header of the driver option link list
323 BootOptionList - The header of the boot option link list
335 // Init the time out value
337 Timeout
= BdsLibGetTimeout ();
340 // Load the driver option as the driver option list
342 PlatformBdsGetDriverOption (DriverOptionList
);
345 // Get current Boot Mode
347 Status
= BdsLibGetBootMode (&PrivateData
->BootMode
);
350 // Go the different platform policy with different boot mode
351 // Notes: this part code can be change with the table policy
353 switch (PrivateData
->BootMode
) {
355 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
356 case BOOT_WITH_MINIMAL_CONFIGURATION
:
358 // In no-configuration boot mode, we can connect the
361 BdsLibConnectAllDefaultConsoles ();
362 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
);
365 // Perform some platform specific connect sequence
367 PlatformBdsConnectSequence ();
370 // Notes: current time out = 0 can not enter the
373 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
376 // Check the boot option with the boot option list
378 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
381 case BOOT_ON_FLASH_UPDATE
:
383 // Boot with the specific configuration
385 PlatformBdsConnectConsole (gPlatformConsole
);
386 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
388 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
391 case BOOT_IN_RECOVERY_MODE
:
393 // In recovery mode, just connect platform console
394 // and show up the front page
396 PlatformBdsConnectConsole (gPlatformConsole
);
397 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
400 // In recovery boot mode, we still enter to the
403 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
406 case BOOT_WITH_FULL_CONFIGURATION
:
407 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
408 case BOOT_WITH_DEFAULT_SETTINGS
:
411 // Connect platform console
413 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
414 if (EFI_ERROR (Status
)) {
416 // Here OEM/IBV can customize with defined action
418 PlatformBdsNoConsoleAction ();
421 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
);
424 // Perform some platform specific connect sequence
426 PlatformBdsConnectSequence ();
429 // Give one chance to enter the setup if we
432 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
435 // Here we have enough time to do the enumeration of boot device
437 BdsLibEnumerateAllBootOption (BootOptionList
);
446 PlatformBdsBootSuccess (
447 IN BDS_COMMON_OPTION
*Option
453 Hook point after a boot attempt succeeds. We don't expect a boot option to
454 return, so the EFI 1.0 specification defines that you will default to an
455 interactive mode and stop processing the BootOrder list in this case. This
456 is alos a platform implementation and can be customized by IBV/OEM.
460 Option - Pointer to Boot Option that succeeded to boot.
471 // If Boot returned with EFI_SUCCESS and there is not in the boot device
472 // select loop then we need to pop up a UI and wait for user input.
474 TmpStr
= Option
->StatusString
;
475 if (TmpStr
!= NULL
) {
476 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
482 PlatformBdsBootFail (
483 IN BDS_COMMON_OPTION
*Option
,
484 IN EFI_STATUS Status
,
486 IN UINTN ExitDataSize
492 Hook point after a boot attempt fails.
496 Option - Pointer to Boot Option that failed to boot.
498 Status - Status returned from failed boot.
500 ExitData - Exit data returned from failed boot.
502 ExitDataSize - Exit data size returned from failed boot.
513 // If Boot returned with failed status then we need to pop up a UI and wait
516 TmpStr
= Option
->StatusString
;
517 if (TmpStr
!= NULL
) {
518 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
525 PlatformBdsNoConsoleAction (
532 This function is remained for IBV/OEM to do some platform action,
533 if there no console device can be connected.
541 EFI_SUCCESS - Direct return success now.
550 PlatformBdsLockNonUpdatableFlash (