3 Copyright (c) 2004 - 2006, 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 WIN_NT_SYSTEM_CONFIGURATION mSystemConfigData
;
35 Size
= sizeof (mSystemConfigData
);
36 Status
= gRT
->GetVariable (
38 &gEfiWinNtSystemConfigGuid
,
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 &gEfiWinNtSystemConfigGuid
,
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
87 BdsLibSaveMemoryTypeInformation ();
92 PlatformBdsConnectConsole (
93 IN BDS_CONSOLE_CONNECT_ENTRY
*PlatformConsole
99 Connect the predefined platform default console device. Always try to find
100 and enable the vga device if have.
104 PlatformConsole - Predfined platform default console device array.
108 EFI_SUCCESS - Success connect at least one ConIn and ConOut
109 device, there must have one ConOut device is
112 EFI_STATUS - Return the status of
113 BdsLibConnectAllDefaultConsoles ()
121 Status
= EFI_SUCCESS
;
124 // Have chance to connect the platform default console,
125 // the platform default console is the minimue device group
126 // the platform should support
128 while (PlatformConsole
[Index
].DevicePath
!= NULL
) {
130 // Update the console variable with the connect type
132 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
133 BdsLibUpdateConsoleVariable (L
"ConIn", PlatformConsole
[Index
].DevicePath
, NULL
);
136 if ((PlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
137 BdsLibUpdateConsoleVariable (L
"ConOut", PlatformConsole
[Index
].DevicePath
, NULL
);
140 if ((PlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
141 BdsLibUpdateConsoleVariable (L
"ErrOut", PlatformConsole
[Index
].DevicePath
, NULL
);
147 // Connect the all the default console with current cosole variable
149 Status
= BdsLibConnectAllDefaultConsoles ();
155 PlatformBdsConnectSequence (
162 Connect with predeined platform connect sequence,
163 the OEM/IBV can customize with their own connect sequence.
180 // Here we can get the customized platform connect sequence
181 // Notes: we can connect with new variable which record the
182 // last time boots connect device path sequence
184 while (gPlatformConnectSequence
[Index
] != NULL
) {
186 // Build the platform boot option
188 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
193 // Jst use the simple policy to connect all devices
199 PlatformBdsGetDriverOption (
200 IN OUT LIST_ENTRY
*BdsDriverLists
206 Load the predefined driver option, OEM/IBV can customize this
207 to load their own drivers
211 BdsDriverLists - The header of the driver option link list.
224 // Here we can get the customized platform driver option
226 while (gPlatformDriverOption
[Index
] != NULL
) {
228 // Build the platform boot option
230 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
237 PlatformBdsDiagnostics (
238 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
239 IN BOOLEAN QuietBoot
,
240 IN BASEM_MEMORY_TEST BaseMemoryTest
246 Perform the platform diagnostic, such like test memory. OEM/IBV also
247 can customize this fuction to support specific platform diagnostic.
251 MemoryTestLevel - The memory test intensive level
253 QuietBoot - Indicate if need to enable the quiet boot
255 BaseMemoryTest - A pointer to BdsMemoryTest()
266 // Here we can decide if we need to show
267 // the diagnostics screen
268 // Notes: this quiet boot code should be remove
269 // from the graphic lib
272 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
274 // Perform system diagnostic
276 Status
= BaseMemoryTest (MemoryTestLevel
);
277 if (EFI_ERROR (Status
)) {
284 // Perform system diagnostic
286 Status
= BaseMemoryTest (MemoryTestLevel
);
290 The function will excute with as the platform policy, current policy
291 is driven by boot mode. IBV/OEM can customize this code for their specific
294 @param DriverOptionList The header of the driver option link list
295 @param BootOptionList The header of the boot option link list
296 @param ProcessCapsules A pointer to ProcessCapsules()
297 @param BaseMemoryTest A pointer to BaseMemoryTest()
302 PlatformBdsPolicyBehavior (
303 IN OUT LIST_ENTRY
*DriverOptionList
,
304 IN OUT LIST_ENTRY
*BootOptionList
,
305 IN PROCESS_CAPSULES ProcessCapsules
,
306 IN BASEM_MEMORY_TEST BaseMemoryTest
311 EFI_BOOT_MODE BootMode
;
314 // Init the time out value
316 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
319 // Load the driver option as the driver option list
321 PlatformBdsGetDriverOption (DriverOptionList
);
324 // Get current Boot Mode
326 Status
= BdsLibGetBootMode (&BootMode
);
329 // Go the different platform policy with different boot mode
330 // Notes: this part code can be change with the table policy
334 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
335 case BOOT_WITH_MINIMAL_CONFIGURATION
:
337 // In no-configuration boot mode, we can connect the
340 BdsLibConnectAllDefaultConsoles ();
341 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
, BaseMemoryTest
);
344 // Perform some platform specific connect sequence
346 PlatformBdsConnectSequence ();
349 // Notes: current time out = 0 can not enter the
352 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
355 // Check the boot option with the boot option list
357 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
360 case BOOT_ON_FLASH_UPDATE
:
362 // Boot with the specific configuration
364 PlatformBdsConnectConsole (gPlatformConsole
);
365 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
367 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
370 case BOOT_IN_RECOVERY_MODE
:
372 // In recovery mode, just connect platform console
373 // and show up the front page
375 PlatformBdsConnectConsole (gPlatformConsole
);
376 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
379 // In recovery boot mode, we still enter to the
382 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
385 case BOOT_WITH_FULL_CONFIGURATION
:
386 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
387 case BOOT_WITH_DEFAULT_SETTINGS
:
390 // Connect platform console
392 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
393 if (EFI_ERROR (Status
)) {
395 // Here OEM/IBV can customize with defined action
397 PlatformBdsNoConsoleAction ();
400 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
, BaseMemoryTest
);
403 // Perform some platform specific connect sequence
405 PlatformBdsConnectSequence ();
408 // Give one chance to enter the setup if we
411 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
414 // Here we have enough time to do the enumeration of boot device
416 BdsLibEnumerateAllBootOption (BootOptionList
);
426 PlatformBdsBootSuccess (
427 IN BDS_COMMON_OPTION
*Option
433 Hook point after a boot attempt succeeds. We don't expect a boot option to
434 return, so the EFI 1.0 specification defines that you will default to an
435 interactive mode and stop processing the BootOrder list in this case. This
436 is alos a platform implementation and can be customized by IBV/OEM.
440 Option - Pointer to Boot Option that succeeded to boot.
451 // If Boot returned with EFI_SUCCESS and there is not in the boot device
452 // select loop then we need to pop up a UI and wait for user input.
454 TmpStr
= Option
->StatusString
;
455 if (TmpStr
!= NULL
) {
456 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
463 PlatformBdsBootFail (
464 IN BDS_COMMON_OPTION
*Option
,
465 IN EFI_STATUS Status
,
467 IN UINTN ExitDataSize
473 Hook point after a boot attempt fails.
477 Option - Pointer to Boot Option that failed to boot.
479 Status - Status returned from failed boot.
481 ExitData - Exit data returned from failed boot.
483 ExitDataSize - Exit data size returned from failed boot.
494 // If Boot returned with failed status then we need to pop up a UI and wait
497 TmpStr
= Option
->StatusString
;
498 if (TmpStr
!= NULL
) {
499 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.
530 This function locks platform flash that is not allowed to be updated during normal boot path.
531 The flash layout is platform specific.
536 PlatformBdsLockNonUpdatableFlash (
544 Lock the ConsoleIn device in system table. All key
545 presses will be ignored until the Password is typed in. The only way to
546 disable the password is to type it in to a ConIn device.
548 @param Password Password used to lock ConIn device.
550 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
551 @retval EFI_UNSUPPORTED Password not found
560 return EFI_UNSUPPORTED
;