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
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 ();
154 PlatformBdsConnectSequence (
161 Connect with predeined platform connect sequence,
162 the OEM/IBV can customize with their own connect sequence.
179 // Here we can get the customized platform connect sequence
180 // Notes: we can connect with new variable which record the
181 // last time boots connect device path sequence
183 while (gPlatformConnectSequence
[Index
] != NULL
) {
185 // Build the platform boot option
187 BdsLibConnectDevicePath (gPlatformConnectSequence
[Index
]);
192 // Jst use the simple policy to connect all devices
198 PlatformBdsGetDriverOption (
199 IN OUT LIST_ENTRY
*BdsDriverLists
205 Load the predefined driver option, OEM/IBV can customize this
206 to load their own drivers
210 BdsDriverLists - The header of the driver option link list.
223 // Here we can get the customized platform driver option
225 while (gPlatformDriverOption
[Index
] != NULL
) {
227 // Build the platform boot option
229 BdsLibRegisterNewOption (BdsDriverLists
, gPlatformDriverOption
[Index
], NULL
, L
"DriverOrder");
236 PlatformBdsDiagnostics (
237 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
238 IN BOOLEAN QuietBoot
,
239 IN BASEM_MEMORY_TEST BaseMemoryTest
245 Perform the platform diagnostic, such like test memory. OEM/IBV also
246 can customize this fuction to support specific platform diagnostic.
250 MemoryTestLevel - The memory test intensive level
252 QuietBoot - Indicate if need to enable the quiet boot
254 BaseMemoryTest - A pointer to BdsMemoryTest()
265 // Here we can decide if we need to show
266 // the diagnostics screen
267 // Notes: this quiet boot code should be remove
268 // from the graphic lib
271 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
273 // Perform system diagnostic
275 Status
= BaseMemoryTest (MemoryTestLevel
);
276 if (EFI_ERROR (Status
)) {
283 // Perform system diagnostic
285 Status
= BaseMemoryTest (MemoryTestLevel
);
289 The function will excute with as the platform policy, current policy
290 is driven by boot mode. IBV/OEM can customize this code for their specific
293 @param DriverOptionList The header of the driver option link list
294 @param BootOptionList The header of the boot option link list
295 @param ProcessCapsules A pointer to ProcessCapsules()
296 @param BaseMemoryTest A pointer to BaseMemoryTest()
301 PlatformBdsPolicyBehavior (
302 IN OUT LIST_ENTRY
*DriverOptionList
,
303 IN OUT LIST_ENTRY
*BootOptionList
,
304 IN PROCESS_CAPSULES ProcessCapsules
,
305 IN BASEM_MEMORY_TEST BaseMemoryTest
310 EFI_BOOT_MODE BootMode
;
313 // Init the time out value
315 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
318 // Load the driver option as the driver option list
320 PlatformBdsGetDriverOption (DriverOptionList
);
323 // Get current Boot Mode
325 Status
= BdsLibGetBootMode (&BootMode
);
328 // Go the different platform policy with different boot mode
329 // Notes: this part code can be change with the table policy
333 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
334 case BOOT_WITH_MINIMAL_CONFIGURATION
:
336 // In no-configuration boot mode, we can connect the
339 BdsLibConnectAllDefaultConsoles ();
340 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
, BaseMemoryTest
);
343 // Perform some platform specific connect sequence
345 PlatformBdsConnectSequence ();
348 // Notes: current time out = 0 can not enter the
351 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
354 // Check the boot option with the boot option list
356 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
359 case BOOT_ON_FLASH_UPDATE
:
361 // Boot with the specific configuration
363 PlatformBdsConnectConsole (gPlatformConsole
);
364 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
366 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
369 case BOOT_IN_RECOVERY_MODE
:
371 // In recovery mode, just connect platform console
372 // and show up the front page
374 PlatformBdsConnectConsole (gPlatformConsole
);
375 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
, BaseMemoryTest
);
378 // In recovery boot mode, we still enter to the
381 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
384 case BOOT_WITH_FULL_CONFIGURATION
:
385 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
386 case BOOT_WITH_DEFAULT_SETTINGS
:
389 // Connect platform console
391 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
392 if (EFI_ERROR (Status
)) {
394 // Here OEM/IBV can customize with defined action
396 PlatformBdsNoConsoleAction ();
399 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
, BaseMemoryTest
);
402 // Perform some platform specific connect sequence
404 PlatformBdsConnectSequence ();
407 // Give one chance to enter the setup if we
410 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
413 // Here we have enough time to do the enumeration of boot device
415 BdsLibEnumerateAllBootOption (BootOptionList
);
425 PlatformBdsBootSuccess (
426 IN BDS_COMMON_OPTION
*Option
432 Hook point after a boot attempt succeeds. We don't expect a boot option to
433 return, so the EFI 1.0 specification defines that you will default to an
434 interactive mode and stop processing the BootOrder list in this case. This
435 is alos a platform implementation and can be customized by IBV/OEM.
439 Option - Pointer to Boot Option that succeeded to boot.
450 // If Boot returned with EFI_SUCCESS and there is not in the boot device
451 // select loop then we need to pop up a UI and wait for user input.
453 TmpStr
= Option
->StatusString
;
454 if (TmpStr
!= NULL
) {
455 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
462 PlatformBdsBootFail (
463 IN BDS_COMMON_OPTION
*Option
,
464 IN EFI_STATUS Status
,
466 IN UINTN ExitDataSize
472 Hook point after a boot attempt fails.
476 Option - Pointer to Boot Option that failed to boot.
478 Status - Status returned from failed boot.
480 ExitData - Exit data returned from failed boot.
482 ExitDataSize - Exit data size returned from failed boot.
493 // If Boot returned with failed status then we need to pop up a UI and wait
496 TmpStr
= Option
->StatusString
;
497 if (TmpStr
!= NULL
) {
498 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
505 PlatformBdsNoConsoleAction (
512 This function is remained for IBV/OEM to do some platform action,
513 if there no console device can be connected.
521 EFI_SUCCESS - Direct return success now.
529 This function locks platform flash that is not allowed to be updated during normal boot path.
530 The flash layout is platform specific.
535 PlatformBdsLockNonUpdatableFlash (
543 Lock the ConsoleIn device in system table. All key
544 presses will be ignored until the Password is typed in. The only way to
545 disable the password is to type it in to a ConIn device.
547 @param Password Password used to lock ConIn device.
549 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
550 @retval EFI_UNSUPPORTED Password not found
559 return EFI_UNSUPPORTED
;