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
24 // Include common header file for this module.
26 #include "CommonHeader.h"
28 #include "Generic/Bds.h"
29 #include "BdsPlatform.h"
30 #include "Generic/String.h"
31 #include "Generic/Language.h"
32 #include "Generic/FrontPage.h"
34 CHAR16 mFirmwareVendor
[] = L
"TianoCore.org";
37 // BDS Platform Functions
41 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
47 Platform Bds init. Incude the platform firmware vendor, revision
52 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
61 // set firmwarevendor, here can be IBV/OEM customize
63 gST
->FirmwareVendor
= AllocateRuntimeCopyPool (
64 sizeof (mFirmwareVendor
),
67 ASSERT (gST
->FirmwareVendor
!= NULL
);
69 gST
->FirmwareRevision
= EFI_FIRMWARE_REVISION
;
72 // Fixup Tasble CRC after we updated Firmware Vendor and Revision
74 gBS
->CalculateCrc32 ((VOID
*) gST
, sizeof (EFI_SYSTEM_TABLE
), &gST
->Hdr
.CRC32
);
77 // Initialize the platform specific string and language
79 InitializeStringSupport ();
80 InitializeLanguage (TRUE
);
81 InitializeFrontPage (FALSE
);
86 PlatformBdsConnectConsole (
87 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
93 Connect the predefined platform default console device. Always try to find
94 and enable the vga device if have.
98 PlatformConsole - Predfined platform default console device array.
102 EFI_SUCCESS - Success connect at least one ConIn and ConOut
103 device, there must have one ConOut device is
106 EFI_STATUS - Return the status of
107 BdsLibConnectAllDefaultConsoles ()
115 Status
= EFI_SUCCESS
;
118 // Have chance to connect the platform default console,
119 // the platform default console is the minimue device group
120 // the platform should support
122 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
124 // Update the console variable with the connect type
126 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
127 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
130 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
131 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
134 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
135 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
141 // Connect the all the default console with current cosole variable
143 Status
= BdsLibConnectAllDefaultConsoles ();
144 if (EFI_ERROR (Status
)) {
152 PlatformBdsConnectSequence (
159 Connect with predeined platform connect sequence,
160 the OEM/IBV can customize with their own connect sequence.
177 // Here we can get the customized platform connect sequence
178 // Notes: we can connect with new variable which record the
179 // last time boots connect device path sequence
181 while (gPlatformConnectSequence
[Index
] != NULL
) {
183 // Build the platform boot option
185 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
192 PlatformBdsGetDriverOption (
193 IN OUT LIST_ENTRY
*BdsDriverLists
199 Load the predefined driver option, OEM/IBV can customize this
200 to load their own drivers
204 BdsDriverLists - The header of the driver option link list.
217 // Here we can get the customized platform driver option
219 while (gPlatformDriverOption
[Index
] != NULL
) {
221 // Build the platform boot option
223 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
230 PlatformBdsDiagnostics (
231 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
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
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 (&gEfiDefaultBmpLogoGuid
);
264 // Perform system diagnostic
266 Status
= BdsMemoryTest (MemoryTestLevel
);
267 if (EFI_ERROR (Status
)) {
274 // Perform system diagnostic
276 Status
= BdsMemoryTest (MemoryTestLevel
);
280 PlatformBdsPolicyBehavior (
281 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
,
282 IN OUT LIST_ENTRY
*DriverOptionList
,
283 IN OUT LIST_ENTRY
*BootOptionList
289 The function will excute with as the platform policy, current policy
290 is driven by boot mode. IBV/OEM can customize this code for their specific
295 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
297 DriverOptionList - The header of the driver option link list
299 BootOptionList - The header of the boot option link list
311 // Init the time out value
313 Timeout
= BdsLibGetTimeout ();
316 // Load the driver option as the driver option list
318 PlatformBdsGetDriverOption (DriverOptionList
);
321 // Get current Boot Mode
323 PrivateData
->BootMode
= GetBootModeHob();
326 // Go the different platform policy with different boot mode
327 // Notes: this part code can be change with the table policy
329 switch (PrivateData
->BootMode
) {
331 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
332 case BOOT_WITH_MINIMAL_CONFIGURATION
:
334 // In no-configuration boot mode, we can connect the
337 BdsLibConnectAllDefaultConsoles ();
338 PlatformBdsDiagnostics (IGNORE
, TRUE
);
341 // Perform some platform specific connect sequence
343 PlatformBdsConnectSequence ();
346 // Notes: current time out = 0 can not enter the
349 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
352 // Check the boot option with the boot option list
354 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
357 case BOOT_ON_FLASH_UPDATE
:
359 // Boot with the specific configuration
361 PlatformBdsConnectConsole (gPlatformConsole
);
362 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
364 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
367 case BOOT_IN_RECOVERY_MODE
:
369 // In recovery mode, just connect platform console
370 // and show up the front page
372 PlatformBdsConnectConsole (gPlatformConsole
);
373 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
376 // In recovery boot mode, we still enter to the
379 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
382 case BOOT_WITH_FULL_CONFIGURATION
:
383 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
384 case BOOT_WITH_DEFAULT_SETTINGS
:
387 // Connect platform console
389 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
390 if (EFI_ERROR (Status
)) {
392 // Here OEM/IBV can customize with defined action
394 PlatformBdsNoConsoleAction ();
397 PlatformBdsDiagnostics (IGNORE
, TRUE
);
400 // Perform some platform specific connect sequence
402 PlatformBdsConnectSequence ();
405 // Give one chance to enter the setup if we
408 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
411 // Here we have enough time to do the enumeration of boot device
413 BdsLibEnumerateAllBootOption (BootOptionList
);
422 PlatformBdsBootSuccess (
423 IN BDS_COMMON_OPTION
*Option
429 Hook point after a boot attempt succeeds. We don't expect a boot option to
430 return, so the EFI 1.0 specification defines that you will default to an
431 interactive mode and stop processing the BootOrder list in this case. This
432 is alos a platform implementation and can be customized by IBV/OEM.
436 Option - Pointer to Boot Option that succeeded to boot.
447 // If Boot returned with EFI_SUCCESS and there is not in the boot device
448 // select loop then we need to pop up a UI and wait for user input.
450 TmpStr
= GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED
));
451 if (TmpStr
!= NULL
) {
452 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
458 PlatformBdsBootFail (
459 IN BDS_COMMON_OPTION
*Option
,
460 IN EFI_STATUS Status
,
462 IN UINTN ExitDataSize
468 Hook point after a boot attempt fails.
472 Option - Pointer to Boot Option that failed to boot.
474 Status - Status returned from failed boot.
476 ExitData - Exit data returned from failed boot.
478 ExitDataSize - Exit data size returned from failed boot.
489 // If Boot returned with failed status then we need to pop up a UI and wait
492 TmpStr
= GetStringById (STRING_TOKEN (STR_BOOT_FAILED
));
493 if (TmpStr
!= NULL
) {
494 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
501 PlatformBdsNoConsoleAction (
508 This function is remained for IBV/OEM to do some platform action,
509 if there no console device can be connected.
517 EFI_SUCCESS - Direct return success now.