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";
28 // BDS Platform Functions
32 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
38 Platform Bds init. Incude the platform firmware vendor, revision
43 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
52 // set firmwarevendor, here can be IBV/OEM customize
54 gST
->FirmwareVendor
= AllocateRuntimeCopyPool (
55 sizeof (mFirmwareVendor
),
58 ASSERT (gST
->FirmwareVendor
!= NULL
);
60 gST
->FirmwareRevision
= 0;
63 // Fixup Tasble CRC after we updated Firmware Vendor and Revision
65 gBS
->CalculateCrc32 ((VOID
*) gST
, sizeof (EFI_SYSTEM_TABLE
), &gST
->Hdr
.CRC32
);
70 PlatformBdsConnectConsole (
71 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
77 Connect the predefined platform default console device. Always try to find
78 and enable the vga device if have.
82 PlatformConsole - Predfined platform default console device array.
86 EFI_SUCCESS - Success connect at least one ConIn and ConOut
87 device, there must have one ConOut device is
90 EFI_STATUS - Return the status of
91 BdsLibConnectAllDefaultConsoles ()
102 // Have chance to connect the platform default console,
103 // the platform default console is the minimue device group
104 // the platform should support
106 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
108 // Update the console variable with the connect type
110 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
111 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
114 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
115 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
118 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
119 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
125 // Connect the all the default console with current cosole variable
127 Status
= BdsLibConnectAllDefaultConsoles ();
132 PlatformBdsConnectSequence (
139 Connect with predeined platform connect sequence,
140 the OEM/IBV can customize with their own connect sequence.
157 // Here we can get the customized platform connect sequence
158 // Notes: we can connect with new variable which record the
159 // last time boots connect device path sequence
161 while (gPlatformConnectSequence
[Index
] != NULL
) {
163 // Build the platform boot option
165 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
170 // Just use the simple policy to connect all devices
176 PlatformBdsGetDriverOption (
177 IN OUT LIST_ENTRY
*BdsDriverLists
183 Load the predefined driver option, OEM/IBV can customize this
184 to load their own drivers
188 BdsDriverLists - The header of the driver option link list.
201 // Here we can get the customized platform driver option
203 while (gPlatformDriverOption
[Index
] != NULL
) {
205 // Build the platform boot option
207 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
214 PlatformBdsDiagnostics (
215 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
222 Perform the platform diagnostic, such like test memory. OEM/IBV also
223 can customize this fuction to support specific platform diagnostic.
227 MemoryTestLevel - The memory test intensive level
229 QuietBoot - Indicate if need to enable the quiet boot
240 // Here we can decide if we need to show
241 // the diagnostics screen
242 // Notes: this quiet boot code should be remove
243 // from the graphic lib
246 EnableQuietBootEx (&gEfiDefaultBmpLogoGuid
, mBdsImageHandle
);
248 // Perform system diagnostic
250 Status
= BdsMemoryTest (MemoryTestLevel
);
251 if (EFI_ERROR (Status
)) {
258 // Perform system diagnostic
260 Status
= BdsMemoryTest (MemoryTestLevel
);
264 PlatformBdsPolicyBehavior (
265 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
,
266 IN OUT LIST_ENTRY
*DriverOptionList
,
267 IN OUT LIST_ENTRY
*BootOptionList
273 The function will excute with as the platform policy, current policy
274 is driven by boot mode. IBV/OEM can customize this code for their specific
279 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
281 DriverOptionList - The header of the driver option link list
283 BootOptionList - The header of the boot option link list
295 // Init the time out value
297 Timeout
= BdsLibGetTimeout ();
300 // Load the driver option as the driver option list
302 PlatformBdsGetDriverOption (DriverOptionList
);
305 // Get current Boot Mode
307 Status
= BdsLibGetBootMode (&PrivateData
->BootMode
);
310 // Go the different platform policy with different boot mode
311 // Notes: this part code can be change with the table policy
313 switch (PrivateData
->BootMode
) {
315 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
316 case BOOT_WITH_MINIMAL_CONFIGURATION
:
318 // In no-configuration boot mode, we can connect the
321 BdsLibConnectAllDefaultConsoles ();
322 PlatformBdsDiagnostics (IGNORE
, TRUE
);
325 // Perform some platform specific connect sequence
327 PlatformBdsConnectSequence ();
330 // Notes: current time out = 0 can not enter the
333 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
336 // Check the boot option with the boot option list
338 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
341 case BOOT_ON_FLASH_UPDATE
:
343 // Boot with the specific configuration
345 PlatformBdsConnectConsole (gPlatformConsole
);
346 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
348 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
351 case BOOT_IN_RECOVERY_MODE
:
353 // In recovery mode, just connect platform console
354 // and show up the front page
356 PlatformBdsConnectConsole (gPlatformConsole
);
357 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
360 // In recovery boot mode, we still enter to the
363 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
366 case BOOT_WITH_FULL_CONFIGURATION
:
367 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
368 case BOOT_WITH_DEFAULT_SETTINGS
:
371 // Connect platform console
373 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
374 if (EFI_ERROR (Status
)) {
376 // Here OEM/IBV can customize with defined action
378 PlatformBdsNoConsoleAction ();
381 PlatformBdsDiagnostics (IGNORE
, TRUE
);
384 // Perform some platform specific connect sequence
386 PlatformBdsConnectSequence ();
389 // Give one chance to enter the setup if we
392 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
395 // Here we have enough time to do the enumeration of boot device
397 BdsLibEnumerateAllBootOption (BootOptionList
);
406 PlatformBdsBootSuccess (
407 IN BDS_COMMON_OPTION
*Option
413 Hook point after a boot attempt succeeds. We don't expect a boot option to
414 return, so the EFI 1.0 specification defines that you will default to an
415 interactive mode and stop processing the BootOrder list in this case. This
416 is alos a platform implementation and can be customized by IBV/OEM.
420 Option - Pointer to Boot Option that succeeded to boot.
431 // If Boot returned with EFI_SUCCESS and there is not in the boot device
432 // select loop then we need to pop up a UI and wait for user input.
434 TmpStr
= Option
->StatusString
;
435 if (TmpStr
!= NULL
) {
436 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
442 PlatformBdsBootFail (
443 IN BDS_COMMON_OPTION
*Option
,
444 IN EFI_STATUS Status
,
446 IN UINTN ExitDataSize
452 Hook point after a boot attempt fails.
456 Option - Pointer to Boot Option that failed to boot.
458 Status - Status returned from failed boot.
460 ExitData - Exit data returned from failed boot.
462 ExitDataSize - Exit data size returned from failed boot.
473 // If Boot returned with failed status then we need to pop up a UI and wait
476 TmpStr
= Option
->StatusString
;
477 if (TmpStr
!= NULL
) {
478 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
484 PlatformBdsNoConsoleAction (
491 This function is remained for IBV/OEM to do some platform action,
492 if there no console device can be connected.
500 EFI_SUCCESS - Direct return success now.
509 PlatformBdsLockNonUpdatableFlash (