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 "Generic/Bds.h"
24 #include "BdsPlatform.h"
25 #include "Generic/BdsString.h"
26 #include "Generic/Language.h"
27 #include "Generic/FrontPage.h"
29 CHAR16 mFirmwareVendor
[] = L
"TianoCore.org";
32 // BDS Platform Functions
36 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
42 Platform Bds init. Incude the platform firmware vendor, revision
47 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
56 // set firmwarevendor, here can be IBV/OEM customize
58 gST
->FirmwareVendor
= AllocateRuntimeCopyPool (
59 sizeof (mFirmwareVendor
),
62 ASSERT (gST
->FirmwareVendor
!= NULL
);
64 gST
->FirmwareRevision
= FIRMWARE_REVISION
;
67 // Fixup Tasble CRC after we updated Firmware Vendor and Revision
69 gBS
->CalculateCrc32 ((VOID
*) gST
, sizeof (EFI_SYSTEM_TABLE
), &gST
->Hdr
.CRC32
);
72 // Initialize the platform specific string and language
74 InitializeStringSupport ();
75 InitializeLanguage (TRUE
);
76 InitializeFrontPage (FALSE
);
81 PlatformBdsConnectConsole (
82 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
88 Connect the predefined platform default console device. Always try to find
89 and enable the vga device if have.
93 PlatformConsole - Predfined platform default console device array.
97 EFI_SUCCESS - Success connect at least one ConIn and ConOut
98 device, there must have one ConOut device is
101 EFI_STATUS - Return the status of
102 BdsLibConnectAllDefaultConsoles ()
110 Status
= EFI_SUCCESS
;
113 // Have chance to connect the platform default console,
114 // the platform default console is the minimue device group
115 // the platform should support
117 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
119 // Update the console variable with the connect type
121 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
122 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
125 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
126 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
129 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
130 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
136 // Connect the all the default console with current cosole variable
138 Status
= BdsLibConnectAllDefaultConsoles ();
139 if (EFI_ERROR (Status
)) {
147 PlatformBdsConnectSequence (
154 Connect with predeined 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
]);
187 PlatformBdsGetDriverOption (
188 IN OUT LIST_ENTRY
*BdsDriverLists
194 Load the predefined driver option, OEM/IBV can customize this
195 to load their own drivers
199 BdsDriverLists - The header of the driver option link list.
212 // Here we can get the customized platform driver option
214 while (gPlatformDriverOption
[Index
] != NULL
) {
216 // Build the platform boot option
218 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
225 PlatformBdsDiagnostics (
226 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
233 Perform the platform diagnostic, such like test memory. OEM/IBV also
234 can customize this fuction to support specific platform diagnostic.
238 MemoryTestLevel - The memory test intensive level
240 QuietBoot - Indicate if need to enable the quiet boot
251 // Here we can decide if we need to show
252 // the diagnostics screen
253 // Notes: this quiet boot code should be remove
254 // from the graphic lib
257 EnableQuietBoot (&gEfiDefaultBmpLogoGuid
);
259 // Perform system diagnostic
261 Status
= BdsMemoryTest (MemoryTestLevel
);
262 if (EFI_ERROR (Status
)) {
269 // Perform system diagnostic
271 Status
= BdsMemoryTest (MemoryTestLevel
);
275 PlatformBdsPolicyBehavior (
276 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
,
277 IN OUT LIST_ENTRY
*DriverOptionList
,
278 IN OUT LIST_ENTRY
*BootOptionList
284 The function will excute with as the platform policy, current policy
285 is driven by boot mode. IBV/OEM can customize this code for their specific
290 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
292 DriverOptionList - The header of the driver option link list
294 BootOptionList - The header of the boot option link list
306 // Init the time out value
308 Timeout
= BdsLibGetTimeout ();
311 // Load the driver option as the driver option list
313 PlatformBdsGetDriverOption (DriverOptionList
);
316 // Get current Boot Mode
318 PrivateData
->BootMode
= GetBootModeHob();
321 // Go the different platform policy with different boot mode
322 // Notes: this part code can be change with the table policy
324 switch (PrivateData
->BootMode
) {
326 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
327 case BOOT_WITH_MINIMAL_CONFIGURATION
:
329 // In no-configuration boot mode, we can connect the
332 BdsLibConnectAllDefaultConsoles ();
333 PlatformBdsDiagnostics (IGNORE
, TRUE
);
336 // Perform some platform specific connect sequence
338 PlatformBdsConnectSequence ();
341 // Notes: current time out = 0 can not enter the
344 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
347 // Check the boot option with the boot option list
349 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
352 case BOOT_ON_FLASH_UPDATE
:
354 // Boot with the specific configuration
356 PlatformBdsConnectConsole (gPlatformConsole
);
357 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
359 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
362 case BOOT_IN_RECOVERY_MODE
:
364 // In recovery mode, just connect platform console
365 // and show up the front page
367 PlatformBdsConnectConsole (gPlatformConsole
);
368 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
371 // In recovery boot mode, we still enter to the
374 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
377 case BOOT_WITH_FULL_CONFIGURATION
:
378 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
379 case BOOT_WITH_DEFAULT_SETTINGS
:
382 // Connect platform console
384 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
385 if (EFI_ERROR (Status
)) {
387 // Here OEM/IBV can customize with defined action
389 PlatformBdsNoConsoleAction ();
392 PlatformBdsDiagnostics (IGNORE
, TRUE
);
395 // Perform some platform specific connect sequence
397 PlatformBdsConnectSequence ();
400 // Give one chance to enter the setup if we
403 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
406 // Here we have enough time to do the enumeration of boot device
408 BdsLibEnumerateAllBootOption (BootOptionList
);
417 PlatformBdsBootSuccess (
418 IN BDS_COMMON_OPTION
*Option
424 Hook point after a boot attempt succeeds. We don't expect a boot option to
425 return, so the EFI 1.0 specification defines that you will default to an
426 interactive mode and stop processing the BootOrder list in this case. This
427 is alos a platform implementation and can be customized by IBV/OEM.
431 Option - Pointer to Boot Option that succeeded to boot.
442 // If Boot returned with EFI_SUCCESS and there is not in the boot device
443 // select loop then we need to pop up a UI and wait for user input.
445 TmpStr
= GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED
));
446 if (TmpStr
!= NULL
) {
447 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
453 PlatformBdsBootFail (
454 IN BDS_COMMON_OPTION
*Option
,
455 IN EFI_STATUS Status
,
457 IN UINTN ExitDataSize
463 Hook point after a boot attempt fails.
467 Option - Pointer to Boot Option that failed to boot.
469 Status - Status returned from failed boot.
471 ExitData - Exit data returned from failed boot.
473 ExitDataSize - Exit data size returned from failed boot.
484 // If Boot returned with failed status then we need to pop up a UI and wait
487 TmpStr
= GetStringById (STRING_TOKEN (STR_BOOT_FAILED
));
488 if (TmpStr
!= NULL
) {
489 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
496 PlatformBdsNoConsoleAction (
503 This function is remained for IBV/OEM to do some platform action,
504 if there no console device can be connected.
512 EFI_SUCCESS - Direct return success now.