3 Copyright (c) 2006 - 2009, 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 UNIX_SYSTEM_CONFIGURATION mSystemConfigData
;
35 Size
= sizeof (mSystemConfigData
);
36 Status
= gRT
->GetVariable (
38 &gEfiUnixSystemConfigGuid
,
41 (VOID
*) &mSystemConfigData
44 if (EFI_ERROR (Status
)) {
46 // SetupVariable is corrupt
48 mSystemConfigData
.ConOutRow
= PcdGet32 (PcdConOutColumn
);
49 mSystemConfigData
.ConOutColumn
= PcdGet32 (PcdConOutRow
);
51 Status
= gRT
->SetVariable (
53 &gEfiUnixSystemConfigGuid
,
54 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
55 sizeof (mSystemConfigData
),
56 (VOID
*) &mSystemConfigData
58 if (EFI_ERROR (Status
)) {
59 DEBUG ((EFI_D_ERROR
, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status
));
65 // BDS Platform Functions
76 Platform Bds init. Include the platform firmware vendor, revision
91 PlatformBdsConnectConsole (
92 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
98 Connect the predefined platform default console device. Always try to find
99 and enable the vga device if have.
103 PlatformConsole - Predfined platform default console device array.
107 EFI_SUCCESS - Success connect at least one ConIn and ConOut
108 device, there must have one ConOut device is
111 EFI_STATUS - Return the status of
112 BdsLibConnectAllDefaultConsoles ()
120 Status
= EFI_SUCCESS
;
123 // Have chance to connect the platform default console,
124 // the platform default console is the minimue device group
125 // the platform should support
127 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
129 // Update the console variable with the connect type
131 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
132 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
135 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
136 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
139 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
140 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
146 // Connect the all the default console with current cosole variable
148 Status
= BdsLibConnectAllDefaultConsoles ();
153 PlatformBdsConnectSequence (
160 Connect with predeined platform connect sequence,
161 the OEM/IBV can customize with their own connect sequence.
178 // Here we can get the customized platform connect sequence
179 // Notes: we can connect with new variable which record the
180 // last time boots connect device path sequence
182 while (gPlatformConnectSequence
[Index
] != NULL
) {
184 // Build the platform boot option
186 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
191 // Just use the simple policy to connect all devices
197 PlatformBdsGetDriverOption (
198 IN OUT LIST_ENTRY
*BdsDriverLists
204 Load the predefined driver option, OEM/IBV can customize this
205 to load their own drivers
209 BdsDriverLists - The header of the driver option link list.
222 // Here we can get the customized platform driver option
224 while (gPlatformDriverOption
[Index
] != NULL
) {
226 // Build the platform boot option
228 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
235 PlatformBdsDiagnostics (
236 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
243 Perform the platform diagnostic, such like test memory. OEM/IBV also
244 can customize this fuction to support specific platform diagnostic.
248 MemoryTestLevel - The memory test intensive level
250 QuietBoot - Indicate if need to enable the quiet boot
261 // Here we can decide if we need to show
262 // the diagnostics screen
263 // Notes: this quiet boot code should be remove
264 // from the graphic lib
267 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
269 // Perform system diagnostic
271 Status
= BdsMemoryTest (MemoryTestLevel
);
272 if (EFI_ERROR (Status
)) {
279 // Perform system diagnostic
281 Status
= BdsMemoryTest (MemoryTestLevel
);
286 PlatformBdsPolicyBehavior (
287 IN OUT LIST_ENTRY
*DriverOptionList
,
288 IN OUT LIST_ENTRY
*BootOptionList
294 The function will excute with as the platform policy, current policy
295 is driven by boot mode. IBV/OEM can customize this code for their specific
300 DriverOptionList - The header of the driver option link list
302 BootOptionList - The header of the boot option link list
312 EFI_BOOT_MODE BootMode
;
315 // Init the time out value
317 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
320 // Load the driver option as the driver option list
322 PlatformBdsGetDriverOption (DriverOptionList
);
325 // Get current Boot Mode
327 Status
= BdsLibGetBootMode (&BootMode
);
330 // Go the different platform policy with different boot mode
331 // Notes: this part code can be change with the table policy
335 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
336 case BOOT_WITH_MINIMAL_CONFIGURATION
:
338 // In no-configuration boot mode, we can connect the
341 BdsLibConnectAllDefaultConsoles ();
342 PlatformBdsDiagnostics (IGNORE
, TRUE
);
345 // Perform some platform specific connect sequence
347 PlatformBdsConnectSequence ();
350 // Notes: current time out = 0 can not enter the
353 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
356 // Check the boot option with the boot option list
358 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
361 case BOOT_ON_FLASH_UPDATE
:
363 // Boot with the specific configuration
365 PlatformBdsConnectConsole (gPlatformConsole
);
366 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
368 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
371 case BOOT_IN_RECOVERY_MODE
:
373 // In recovery mode, just connect platform console
374 // and show up the front page
376 PlatformBdsConnectConsole (gPlatformConsole
);
377 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
380 // In recovery boot mode, we still enter to the
383 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
386 case BOOT_WITH_FULL_CONFIGURATION
:
387 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
388 case BOOT_WITH_DEFAULT_SETTINGS
:
391 // Connect platform console
393 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
394 if (EFI_ERROR (Status
)) {
396 // Here OEM/IBV can customize with defined action
398 PlatformBdsNoConsoleAction ();
401 PlatformBdsDiagnostics (IGNORE
, TRUE
);
404 // Perform some platform specific connect sequence
406 PlatformBdsConnectSequence ();
409 // Give one chance to enter the setup if we
412 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
415 // Here we have enough time to do the enumeration of boot device
417 BdsLibEnumerateAllBootOption (BootOptionList
);
427 PlatformBdsBootSuccess (
428 IN BDS_COMMON_OPTION
*Option
434 Hook point after a boot attempt succeeds. We don't expect a boot option to
435 return, so the EFI 1.0 specification defines that you will default to an
436 interactive mode and stop processing the BootOrder list in this case. This
437 is alos a platform implementation and can be customized by IBV/OEM.
441 Option - Pointer to Boot Option that succeeded to boot.
452 // If Boot returned with EFI_SUCCESS and there is not in the boot device
453 // select loop then we need to pop up a UI and wait for user input.
455 TmpStr
= Option
->StatusString
;
456 if (TmpStr
!= NULL
) {
457 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
464 PlatformBdsBootFail (
465 IN BDS_COMMON_OPTION
*Option
,
466 IN EFI_STATUS Status
,
468 IN UINTN ExitDataSize
474 Hook point after a boot attempt fails.
478 Option - Pointer to Boot Option that failed to boot.
480 Status - Status returned from failed boot.
482 ExitData - Exit data returned from failed boot.
484 ExitDataSize - Exit data size returned from failed boot.
495 // If Boot returned with failed status then we need to pop up a UI and wait
498 TmpStr
= Option
->StatusString
;
499 if (TmpStr
!= NULL
) {
500 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
506 PlatformBdsNoConsoleAction (
513 This function is remained for IBV/OEM to do some platform action,
514 if there no console device can be connected.
522 EFI_SUCCESS - Direct return success now.
531 PlatformBdsLockNonUpdatableFlash (