]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
MdeModulePkg/ResetSystemRuntimeDxe: Support EfiResetPlatformSpecific
[mirror_edk2.git] / Nt32Pkg / Library / PlatformBootManagerLib / PlatformBootManager.c
CommitLineData
123e9f62
RN
1/** @file\r
2 This file include all platform action which can be customized\r
3 by IBV/OEM.\r
4\r
5Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "PlatformBootManager.h"\r
17\r
8f227c2f 18/**\r
703da8b4
RN
19 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
20 can customize this function to support specific platform diagnostic.\r
8f227c2f 21\r
703da8b4
RN
22 @param MemoryTestLevel The memory test intensive level\r
23 @param QuietBoot Indicate if need to enable the quiet boot\r
8f227c2f
RN
24\r
25**/\r
703da8b4
RN
26VOID\r
27PlatformBootManagerDiagnostics (\r
28 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
29 IN BOOLEAN QuietBoot\r
8f227c2f
RN
30 )\r
31{\r
703da8b4
RN
32 EFI_STATUS Status;\r
33\r
34 //\r
35 // Here we can decide if we need to show\r
36 // the diagnostics screen\r
37 // Notes: this quiet boot code should be remove\r
38 // from the graphic lib\r
39 //\r
40 if (QuietBoot) {\r
859e75c4 41 BootLogoEnableLogo (ImageFormatBmp, PcdGetPtr(PcdLogoFile), EdkiiPlatformLogoDisplayAttributeCenter, 0, 0);\r
8f227c2f 42\r
8f227c2f 43 //\r
703da8b4 44 // Perform system diagnostic\r
8f227c2f 45 //\r
703da8b4
RN
46 Status = PlatformBootManagerMemoryTest (MemoryTestLevel);\r
47 if (EFI_ERROR (Status)) {\r
859e75c4 48 BootLogoDisableLogo ();\r
8f227c2f 49 }\r
8f227c2f 50\r
703da8b4
RN
51 return;\r
52 }\r
8f227c2f 53\r
703da8b4
RN
54 //\r
55 // Perform system diagnostic\r
56 //\r
57 Status = PlatformBootManagerMemoryTest (MemoryTestLevel);\r
8f227c2f
RN
58}\r
59\r
123e9f62
RN
60/**\r
61 Do the platform specific action before the console is connected.\r
62\r
63 Such as:\r
64 Update console variable;\r
65 Register new Driver#### or Boot####;\r
66 Signal ReadyToLock event.\r
67**/\r
68VOID\r
69EFIAPI\r
70PlatformBootManagerBeforeConsole (\r
71 VOID\r
72 )\r
73{\r
74 UINTN Index;\r
75 EFI_STATUS Status;\r
76 WIN_NT_SYSTEM_CONFIGURATION *Configuration;\r
123e9f62
RN
77\r
78 GetVariable2 (L"Setup", &gEfiWinNtSystemConfigGuid, (VOID **) &Configuration, NULL);\r
79 if (Configuration != NULL) {\r
80 //\r
81 // SetupVariable is corrupt\r
82 //\r
83 Configuration->ConOutRow = PcdGet32 (PcdConOutColumn);\r
84 Configuration->ConOutColumn = PcdGet32 (PcdConOutRow);\r
85\r
86 Status = gRT->SetVariable (\r
87 L"Setup",\r
88 &gEfiWinNtSystemConfigGuid,\r
89 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
90 sizeof (WIN_NT_SYSTEM_CONFIGURATION),\r
91 Configuration\r
92 );\r
93 if (EFI_ERROR (Status)) {\r
94 DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
95 }\r
96 FreePool (Configuration);\r
97 }\r
98\r
99 //\r
100 // Update the ocnsole variables.\r
101 //\r
102 for (Index = 0; gPlatformConsole[Index].DevicePath != NULL; Index++) {\r
103 if ((gPlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
104 EfiBootManagerUpdateConsoleVariable (ConIn, gPlatformConsole[Index].DevicePath, NULL);\r
105 }\r
106\r
107 if ((gPlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
108 EfiBootManagerUpdateConsoleVariable (ConOut, gPlatformConsole[Index].DevicePath, NULL);\r
109 }\r
110\r
111 if ((gPlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
112 EfiBootManagerUpdateConsoleVariable (ErrOut, gPlatformConsole[Index].DevicePath, NULL);\r
113 }\r
114 }\r
123e9f62
RN
115}\r
116\r
3d8fab57
LG
117/**\r
118 Returns the priority number.\r
119\r
120 @param BootOption\r
121**/\r
122UINTN\r
123BootOptionPriority (\r
124 CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption\r
125 )\r
126{\r
127 //\r
128 // Make sure Shell is first\r
129 //\r
130 if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) {\r
131 return 0;\r
132 }\r
133 return 100;\r
134}\r
135\r
136INTN\r
137EFIAPI\r
138CompareBootOption (\r
139 CONST EFI_BOOT_MANAGER_LOAD_OPTION *Left,\r
140 CONST EFI_BOOT_MANAGER_LOAD_OPTION *Right\r
141 )\r
142{\r
143 return BootOptionPriority (Left) - BootOptionPriority (Right);\r
144}\r
145\r
123e9f62
RN
146/**\r
147 Do the platform specific action after the console is connected.\r
148\r
149 Such as:\r
150 Dynamically switch output mode;\r
151 Signal console ready platform customized event;\r
152 Run diagnostics like memory testing;\r
153 Connect certain devices;\r
154 Dispatch aditional option roms.\r
155**/\r
156VOID\r
157EFIAPI\r
158PlatformBootManagerAfterConsole (\r
159 VOID\r
160 )\r
161{\r
703da8b4
RN
162 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;\r
163 EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;\r
e2e9b3b4
LG
164 EFI_INPUT_KEY Enter;\r
165 EFI_INPUT_KEY F2;\r
166 EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
703da8b4
RN
167\r
168 Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
169 White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
170\r
99eda885
ED
171 EfiBootManagerConnectAll ();\r
172 EfiBootManagerRefreshAllBootOption ();\r
703da8b4 173\r
e2e9b3b4
LG
174 //\r
175 // Register ENTER as CONTINUE key\r
176 //\r
177 Enter.ScanCode = SCAN_NULL;\r
178 Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;\r
179 EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);\r
180 //\r
181 // Map F2 to Boot Manager Menu\r
182 //\r
183 F2.ScanCode = SCAN_F2;\r
184 F2.UnicodeChar = CHAR_NULL;\r
185 EfiBootManagerGetBootManagerMenu (&BootOption);\r
186 EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);\r
187\r
3d8fab57
LG
188 //\r
189 // Make Shell as the first boot option\r
190 //\r
191 EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption);\r
192\r
703da8b4
RN
193 PlatformBootManagerDiagnostics (QUICK, TRUE);\r
194 \r
195 PrintXY (10, 10, &White, &Black, L"F2 to enter Boot Manager Menu. ");\r
196 PrintXY (10, 30, &White, &Black, L"Enter to boot directly.");\r
123e9f62
RN
197}\r
198\r
199/**\r
200 This function is called each second during the boot manager waits the timeout.\r
201\r
202 @param TimeoutRemain The remaining timeout.\r
203**/\r
204VOID\r
205EFIAPI\r
206PlatformBootManagerWaitCallback (\r
207 UINT16 TimeoutRemain\r
208 )\r
209{\r
ef3216eb
LE
210 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;\r
211 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;\r
212 UINT16 Timeout;\r
703da8b4
RN
213\r
214 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
215\r
ef3216eb
LE
216 Black.Raw = 0x00000000;\r
217 White.Raw = 0x00FFFFFF;\r
703da8b4 218\r
859e75c4 219 BootLogoUpdateProgress (\r
ef3216eb
LE
220 White.Pixel,\r
221 Black.Pixel,\r
703da8b4 222 L"Start boot option",\r
ef3216eb 223 White.Pixel,\r
703da8b4
RN
224 (Timeout - TimeoutRemain) * 100 / Timeout,\r
225 0\r
226 );\r
123e9f62 227}\r