3 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
4 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
,
237 IN BOOLEAN QuietBoot
,
238 IN BASEM_MEMORY_TEST BaseMemoryTest
244 Perform the platform diagnostic, such like test memory. OEM/IBV also
245 can customize this fuction to support specific platform diagnostic.
249 MemoryTestLevel - The memory test intensive level
251 QuietBoot - Indicate if need to enable the quiet boot
253 BaseMemoryTest - A pointer to BdsMemoryTest()
264 // Here we can decide if we need to show
265 // the diagnostics screen
266 // Notes: this quiet boot code should be remove
267 // from the graphic lib
270 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
272 // Perform system diagnostic
274 Status
= BaseMemoryTest (MemoryTestLevel
);
275 if (EFI_ERROR (Status
)) {
282 // Perform system diagnostic
284 Status
= BaseMemoryTest (MemoryTestLevel
);
289 PlatformBdsPolicyBehavior (
290 IN OUT LIST_ENTRY
*DriverOptionList
,
291 IN OUT LIST_ENTRY
*BootOptionList
,
292 IN PROCESS_CAPSULES ProcessCapsules
,
293 IN BASEM_MEMORY_TEST BaseMemoryTest
299 The function will excute with as the platform policy, current policy
300 is driven by boot mode. IBV/OEM can customize this code for their specific
305 DriverOptionList - The header of the driver option link list
307 BootOptionList - The header of the boot option link list
309 ProcessCapsules - A pointer to ProcessCapsules()
311 BaseMemoryTest - A pointer to BaseMemoryTest()
321 EFI_BOOT_MODE BootMode
;
324 // Init the time out value
326 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
329 // Load the driver option as the driver option list
331 PlatformBdsGetDriverOption (DriverOptionList
);
334 // Get current Boot Mode
336 Status
= BdsLibGetBootMode (&BootMode
);
339 // Go the different platform policy with different boot mode
340 // Notes: this part code can be change with the table policy
344 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
345 case BOOT_WITH_MINIMAL_CONFIGURATION
:
347 // In no-configuration boot mode, we can connect the
350 BdsLibConnectAllDefaultConsoles ();
351 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
354 // Perform some platform specific connect sequence
356 PlatformBdsConnectSequence ();
359 // Notes: current time out = 0 can not enter the
362 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
365 // Check the boot option with the boot option list
367 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
370 case BOOT_ON_FLASH_UPDATE
:
372 // Boot with the specific configuration
374 PlatformBdsConnectConsole (gPlatformConsole
);
375 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
377 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
380 case BOOT_IN_RECOVERY_MODE
:
382 // In recovery mode, just connect platform console
383 // and show up the front page
385 PlatformBdsConnectConsole (gPlatformConsole
);
386 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
389 // In recovery boot mode, we still enter to the
392 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
395 case BOOT_WITH_FULL_CONFIGURATION
:
396 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
397 case BOOT_WITH_DEFAULT_SETTINGS
:
400 // Connect platform console
402 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
403 if (EFI_ERROR (Status
)) {
405 // Here OEM/IBV can customize with defined action
407 PlatformBdsNoConsoleAction ();
410 PlatformBdsDiagnostics (IGNORE
, TRUE
, BaseMemoryTest
);
413 // Perform some platform specific connect sequence
415 PlatformBdsConnectSequence ();
418 // Give one chance to enter the setup if we
421 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
424 // Here we have enough time to do the enumeration of boot device
426 BdsLibEnumerateAllBootOption (BootOptionList
);
436 PlatformBdsBootSuccess (
437 IN BDS_COMMON_OPTION
*Option
443 Hook point after a boot attempt succeeds. We don't expect a boot option to
444 return, so the EFI 1.0 specification defines that you will default to an
445 interactive mode and stop processing the BootOrder list in this case. This
446 is alos a platform implementation and can be customized by IBV/OEM.
450 Option - Pointer to Boot Option that succeeded to boot.
461 // If Boot returned with EFI_SUCCESS and there is not in the boot device
462 // select loop then we need to pop up a UI and wait for user input.
464 TmpStr
= Option
->StatusString
;
465 if (TmpStr
!= NULL
) {
466 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
473 PlatformBdsBootFail (
474 IN BDS_COMMON_OPTION
*Option
,
475 IN EFI_STATUS Status
,
477 IN UINTN ExitDataSize
483 Hook point after a boot attempt fails.
487 Option - Pointer to Boot Option that failed to boot.
489 Status - Status returned from failed boot.
491 ExitData - Exit data returned from failed boot.
493 ExitDataSize - Exit data size returned from failed boot.
504 // If Boot returned with failed status then we need to pop up a UI and wait
507 TmpStr
= Option
->StatusString
;
508 if (TmpStr
!= NULL
) {
509 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
515 PlatformBdsNoConsoleAction (
522 This function is remained for IBV/OEM to do some platform action,
523 if there no console device can be connected.
531 EFI_SUCCESS - Direct return success now.
540 PlatformBdsLockNonUpdatableFlash (
548 Lock the ConsoleIn device in system table. All key
549 presses will be ignored until the Password is typed in. The only way to
550 disable the password is to type it in to a ConIn device.
552 @param Password Password used to lock ConIn device.
554 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
555 @retval EFI_UNSUPPORTED Password not found
564 return EFI_UNSUPPORTED
;