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 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
,
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
262 // Here we can decide if we need to show
263 // the diagnostics screen
264 // Notes: this quiet boot code should be remove
265 // from the graphic lib
268 EnableQuietBoot (PcdGetPtr(PcdLogoFile
));
270 // Perform system diagnostic
272 Status
= BdsMemoryTest (MemoryTestLevel
);
273 if (EFI_ERROR (Status
)) {
280 // Perform system diagnostic
282 Status
= BdsMemoryTest (MemoryTestLevel
);
287 PlatformBdsPolicyBehavior (
288 IN OUT LIST_ENTRY
*DriverOptionList
,
289 IN OUT LIST_ENTRY
*BootOptionList
295 The function will excute with as the platform policy, current policy
296 is driven by boot mode. IBV/OEM can customize this code for their specific
301 DriverOptionList - The header of the driver option link list
303 BootOptionList - The header of the boot option link list
313 EFI_BOOT_MODE BootMode
;
316 // Init the time out value
318 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
321 // Load the driver option as the driver option list
323 PlatformBdsGetDriverOption (DriverOptionList
);
326 // Get current Boot Mode
328 Status
= BdsLibGetBootMode (&BootMode
);
331 // Go the different platform policy with different boot mode
332 // Notes: this part code can be change with the table policy
336 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES
:
337 case BOOT_WITH_MINIMAL_CONFIGURATION
:
339 // In no-configuration boot mode, we can connect the
342 BdsLibConnectAllDefaultConsoles ();
343 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
);
346 // Perform some platform specific connect sequence
348 PlatformBdsConnectSequence ();
351 // Notes: current time out = 0 can not enter the
354 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
357 // Check the boot option with the boot option list
359 BdsLibBuildOptionFromVar (BootOptionList
, L
"BootOrder");
362 case BOOT_ON_FLASH_UPDATE
:
364 // Boot with the specific configuration
366 PlatformBdsConnectConsole (gPlatformConsole
);
367 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
369 ProcessCapsules (BOOT_ON_FLASH_UPDATE
);
372 case BOOT_IN_RECOVERY_MODE
:
374 // In recovery mode, just connect platform console
375 // and show up the front page
377 PlatformBdsConnectConsole (gPlatformConsole
);
378 PlatformBdsDiagnostics (EXTENSIVE
, FALSE
);
381 // In recovery boot mode, we still enter to the
384 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
387 case BOOT_WITH_FULL_CONFIGURATION
:
388 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS
:
389 case BOOT_WITH_DEFAULT_SETTINGS
:
392 // Connect platform console
394 Status
= PlatformBdsConnectConsole (gPlatformConsole
);
395 if (EFI_ERROR (Status
)) {
397 // Here OEM/IBV can customize with defined action
399 PlatformBdsNoConsoleAction ();
402 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL
)IGNORE
, TRUE
);
405 // Perform some platform specific connect sequence
407 PlatformBdsConnectSequence ();
410 // Give one chance to enter the setup if we
413 PlatformBdsEnterFrontPage (Timeout
, FALSE
);
416 // Here we have enough time to do the enumeration of boot device
418 BdsLibEnumerateAllBootOption (BootOptionList
);
428 PlatformBdsBootSuccess (
429 IN BDS_COMMON_OPTION
*Option
435 Hook point after a boot attempt succeeds. We don't expect a boot option to
436 return, so the EFI 1.0 specification defines that you will default to an
437 interactive mode and stop processing the BootOrder list in this case. This
438 is alos a platform implementation and can be customized by IBV/OEM.
442 Option - Pointer to Boot Option that succeeded to boot.
453 // If Boot returned with EFI_SUCCESS and there is not in the boot device
454 // select loop then we need to pop up a UI and wait for user input.
456 TmpStr
= Option
->StatusString
;
457 if (TmpStr
!= NULL
) {
458 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
465 PlatformBdsBootFail (
466 IN BDS_COMMON_OPTION
*Option
,
467 IN EFI_STATUS Status
,
469 IN UINTN ExitDataSize
475 Hook point after a boot attempt fails.
479 Option - Pointer to Boot Option that failed to boot.
481 Status - Status returned from failed boot.
483 ExitData - Exit data returned from failed boot.
485 ExitDataSize - Exit data size returned from failed boot.
496 // If Boot returned with failed status then we need to pop up a UI and wait
499 TmpStr
= Option
->StatusString
;
500 if (TmpStr
!= NULL
) {
501 BdsLibOutputStrings (gST
->ConOut
, TmpStr
, Option
->Description
, L
"\n\r", NULL
);
508 PlatformBdsNoConsoleAction (
515 This function is remained for IBV/OEM to do some platform action,
516 if there no console device can be connected.
524 EFI_SUCCESS - Direct return success now.
533 PlatformBdsLockNonUpdatableFlash (