2 This file include all platform action which can be customized
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "PlatformBootManager.h"
19 Perform the platform diagnostic, such like test memory. OEM/IBV also
20 can customize this function to support specific platform diagnostic.
22 @param MemoryTestLevel The memory test intensive level
23 @param QuietBoot Indicate if need to enable the quiet boot
27 PlatformBootManagerDiagnostics (
28 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel
,
35 // Here we can decide if we need to show
36 // the diagnostics screen
37 // Notes: this quiet boot code should be remove
38 // from the graphic lib
41 BootLogoEnableLogo (ImageFormatBmp
, PcdGetPtr(PcdLogoFile
), EdkiiPlatformLogoDisplayAttributeCenter
, 0, 0);
44 // Perform system diagnostic
46 Status
= PlatformBootManagerMemoryTest (MemoryTestLevel
);
47 if (EFI_ERROR (Status
)) {
48 BootLogoDisableLogo ();
55 // Perform system diagnostic
57 Status
= PlatformBootManagerMemoryTest (MemoryTestLevel
);
61 Do the platform specific action before the console is connected.
64 Update console variable;
65 Register new Driver#### or Boot####;
66 Signal ReadyToLock event.
70 PlatformBootManagerBeforeConsole (
76 WIN_NT_SYSTEM_CONFIGURATION
*Configuration
;
78 GetVariable2 (L
"Setup", &gEfiWinNtSystemConfigGuid
, (VOID
**) &Configuration
, NULL
);
79 if (Configuration
!= NULL
) {
81 // SetupVariable is corrupt
83 Configuration
->ConOutRow
= PcdGet32 (PcdConOutColumn
);
84 Configuration
->ConOutColumn
= PcdGet32 (PcdConOutRow
);
86 Status
= gRT
->SetVariable (
88 &gEfiWinNtSystemConfigGuid
,
89 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
90 sizeof (WIN_NT_SYSTEM_CONFIGURATION
),
93 if (EFI_ERROR (Status
)) {
94 DEBUG ((EFI_D_ERROR
, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status
));
96 FreePool (Configuration
);
100 // Update the ocnsole variables.
102 for (Index
= 0; gPlatformConsole
[Index
].DevicePath
!= NULL
; Index
++) {
103 if ((gPlatformConsole
[Index
].ConnectType
& CONSOLE_IN
) == CONSOLE_IN
) {
104 EfiBootManagerUpdateConsoleVariable (ConIn
, gPlatformConsole
[Index
].DevicePath
, NULL
);
107 if ((gPlatformConsole
[Index
].ConnectType
& CONSOLE_OUT
) == CONSOLE_OUT
) {
108 EfiBootManagerUpdateConsoleVariable (ConOut
, gPlatformConsole
[Index
].DevicePath
, NULL
);
111 if ((gPlatformConsole
[Index
].ConnectType
& STD_ERROR
) == STD_ERROR
) {
112 EfiBootManagerUpdateConsoleVariable (ErrOut
, gPlatformConsole
[Index
].DevicePath
, NULL
);
118 Returns the priority number.
124 CONST EFI_BOOT_MANAGER_LOAD_OPTION
*BootOption
128 // Make sure Shell is first
130 if (StrCmp (BootOption
->Description
, L
"UEFI Shell") == 0) {
139 CONST EFI_BOOT_MANAGER_LOAD_OPTION
*Left
,
140 CONST EFI_BOOT_MANAGER_LOAD_OPTION
*Right
143 return BootOptionPriority (Left
) - BootOptionPriority (Right
);
147 Do the platform specific action after the console is connected.
150 Dynamically switch output mode;
151 Signal console ready platform customized event;
152 Run diagnostics like memory testing;
153 Connect certain devices;
154 Dispatch aditional option roms.
158 PlatformBootManagerAfterConsole (
162 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black
;
163 EFI_GRAPHICS_OUTPUT_BLT_PIXEL White
;
166 EFI_BOOT_MANAGER_LOAD_OPTION BootOption
;
168 Black
.Blue
= Black
.Green
= Black
.Red
= Black
.Reserved
= 0;
169 White
.Blue
= White
.Green
= White
.Red
= White
.Reserved
= 0xFF;
171 EfiBootManagerConnectAll ();
172 EfiBootManagerRefreshAllBootOption ();
175 // Register ENTER as CONTINUE key
177 Enter
.ScanCode
= SCAN_NULL
;
178 Enter
.UnicodeChar
= CHAR_CARRIAGE_RETURN
;
179 EfiBootManagerRegisterContinueKeyOption (0, &Enter
, NULL
);
181 // Map F2 to Boot Manager Menu
183 F2
.ScanCode
= SCAN_F2
;
184 F2
.UnicodeChar
= CHAR_NULL
;
185 EfiBootManagerGetBootManagerMenu (&BootOption
);
186 EfiBootManagerAddKeyOptionVariable (NULL
, (UINT16
) BootOption
.OptionNumber
, 0, &F2
, NULL
);
189 // Make Shell as the first boot option
191 EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot
, (SORT_COMPARE
) CompareBootOption
);
193 PlatformBootManagerDiagnostics (QUICK
, TRUE
);
195 PrintXY (10, 10, &White
, &Black
, L
"F2 to enter Boot Manager Menu. ");
196 PrintXY (10, 30, &White
, &Black
, L
"Enter to boot directly.");
200 This function is called each second during the boot manager waits the timeout.
202 @param TimeoutRemain The remaining timeout.
206 PlatformBootManagerWaitCallback (
210 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black
;
211 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White
;
214 Timeout
= PcdGet16 (PcdPlatformBootTimeOut
);
216 Black
.Raw
= 0x00000000;
217 White
.Raw
= 0x00FFFFFF;
219 BootLogoUpdateProgress (
222 L
"Start boot option",
224 (Timeout
- TimeoutRemain
) * 100 / Timeout
,