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";
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 ();
133 PlatformBdsConnectSequence (
140 Connect with predeined platform connect sequence,
141 the OEM/IBV can customize with their own connect sequence.
158 // Here we can get the customized platform connect sequence
159 // Notes: we can connect with new variable which record the
160 // last time boots connect device path sequence
162 while (gPlatformConnectSequence
[Index
] != NULL
) {
164 // Build the platform boot option
166 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
171 // Jst use the simple policy to connect all devices
177 PlatformBdsGetDriverOption (
178 IN OUT LIST_ENTRY
*BdsDriverLists
184 Load the predefined driver option, OEM/IBV can customize this
185 to load their own drivers
189 BdsDriverLists - The header of the driver option link list.
202 // Here we can get the customized platform driver option
204 while (gPlatformDriverOption
[Index
] != NULL
) {
206 // Build the platform boot option
208 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
215 PlatformBdsDiagnostics (
216 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
223 Perform the platform diagnostic, such like test memory. OEM/IBV also
224 can customize this fuction to support specific platform diagnostic.
228 MemoryTestLevel - The memory test intensive level
230 QuietBoot - Indicate if need to enable the quiet boot
241 // Here we can decide if we need to show
242 // the diagnostics screen
243 // Notes: this quiet boot code should be remove
244 // from the graphic lib
247 EnableQuietBoot (&gEfiDefaultBmpLogoGuid
);
249 // Perform system diagnostic
251 Status
= BdsMemoryTest (MemoryTestLevel
);
252 if (EFI_ERROR (Status
)) {
259 // Perform system diagnostic
261 Status
= BdsMemoryTest (MemoryTestLevel
);
265 PlatformBdsPolicyBehavior (
266 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE
*PrivateData
,
267 IN OUT LIST_ENTRY
*DriverOptionList
,
268 IN OUT LIST_ENTRY
*BootOptionList
274 The function will excute with as the platform policy, current policy
275 is driven by boot mode. IBV/OEM can customize this code for their specific
280 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance
282 DriverOptionList - The header of the driver option link list
284 BootOptionList - The header of the boot option link list
296 // Init the time out value
298 Timeout
= BdsLibGetTimeout ();
301 // Load the driver option as the driver option list
303 PlatformBdsGetDriverOption (DriverOptionList
);
306 // Get current Boot Mode
308 Status
= BdsLibGetBootMode (&PrivateData
->BootMode
);
311 // Go the different platform policy with different boot mode
312 // Notes: this part code can be change with the table policy
314 switch (PrivateData
->BootMode
) {
316 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
317 case BOOT_WITH_MINIMAL_CONFIGURATION
:
319 // In no-configuration boot mode, we can connect the
322 BdsLibConnectAllDefaultConsoles ();
323 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
);
326 // Perform some platform specific connect sequence
328 PlatformBdsConnectSequence ();
331 // Notes: current time out = 0 can not enter the
334 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
337 // Check the boot option with the boot option list
339 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
342 case BOOT_ON_FLASH_UPDATE
:
344 // Boot with the specific configuration
346 PlatformBdsConnectConsole (gPlatformConsole
);
347 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
349 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
352 case BOOT_IN_RECOVERY_MODE
:
354 // In recovery mode, just connect platform console
355 // and show up the front page
357 PlatformBdsConnectConsole (gPlatformConsole
);
358 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
361 // In recovery boot mode, we still enter to the
364 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
367 case BOOT_WITH_FULL_CONFIGURATION
:
368 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
369 case BOOT_WITH_DEFAULT_SETTINGS
:
372 // Connect platform console
374 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
375 if (EFI_ERROR (Status
)) {
377 // Here OEM/IBV can customize with defined action
379 PlatformBdsNoConsoleAction ();
382 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
);
385 // Perform some platform specific connect sequence
387 PlatformBdsConnectSequence ();
390 // Give one chance to enter the setup if we
393 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
396 // Here we have enough time to do the enumeration of boot device
398 BdsLibEnumerateAllBootOption (BootOptionList
);
407 PlatformBdsBootSuccess (
408 IN BDS_COMMON_OPTION
*Option
414 Hook point after a boot attempt succeeds. We don't expect a boot option to
415 return, so the EFI 1.0 specification defines that you will default to an
416 interactive mode and stop processing the BootOrder list in this case. This
417 is alos a platform implementation and can be customized by IBV/OEM.
421 Option - Pointer to Boot Option that succeeded to boot.
432 // If Boot returned with EFI_SUCCESS and there is not in the boot device
433 // select loop then we need to pop up a UI and wait for user input.
435 TmpStr
= Option
->StatusString
;
436 if (TmpStr
!= NULL
) {
437 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
443 PlatformBdsBootFail (
444 IN BDS_COMMON_OPTION
*Option
,
445 IN EFI_STATUS Status
,
447 IN UINTN ExitDataSize
453 Hook point after a boot attempt fails.
457 Option - Pointer to Boot Option that failed to boot.
459 Status - Status returned from failed boot.
461 ExitData - Exit data returned from failed boot.
463 ExitDataSize - Exit data size returned from failed boot.
474 // If Boot returned with failed status then we need to pop up a UI and wait
477 TmpStr
= Option
->StatusString
;
478 if (TmpStr
!= NULL
) {
479 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
486 PlatformBdsNoConsoleAction (
493 This function is remained for IBV/OEM to do some platform action,
494 if there no console device can be connected.
502 EFI_SUCCESS - Direct return success now.
511 PlatformBdsLockNonUpdatableFlash (