]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/Library/Nt32BdsLib/BdsPlatform.c
Nt32Pkg: Use the new PCDs defined in MdePkg and MdeModulePkg.
[mirror_edk2.git] / Nt32Pkg / Library / Nt32BdsLib / BdsPlatform.c
CommitLineData
6ae81428 1/**@file\r
5fd5fcd3 2\r
8f2a5f80
HT
3Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
5fd5fcd3 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 BdsPlatform.c\r
15\r
16Abstract:\r
17\r
18 This file include all platform action which can be customized\r
19 by IBV/OEM.\r
20\r
6ae81428 21**/\r
5fd5fcd3 22\r
23#include "BdsPlatform.h"\r
24\r
fcf24bad 25WIN_NT_SYSTEM_CONFIGURATION mSystemConfigData;\r
26\r
27VOID\r
28SetupVariableInit (\r
29 VOID\r
30 )\r
31{\r
32 EFI_STATUS Status;\r
33 UINTN Size;\r
34\r
35 Size = sizeof (mSystemConfigData);\r
36 Status = gRT->GetVariable (\r
37 L"Setup",\r
38 &gEfiWinNtSystemConfigGuid,\r
39 NULL,\r
40 &Size,\r
41 (VOID *) &mSystemConfigData\r
42 );\r
43\r
44 if (EFI_ERROR (Status)) {\r
45 //\r
46 // SetupVariable is corrupt\r
47 //\r
48 mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
49 mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
50\r
51 Status = gRT->SetVariable (\r
52 L"Setup",\r
53 &gEfiWinNtSystemConfigGuid,\r
54 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
55 sizeof (mSystemConfigData),\r
56 (VOID *) &mSystemConfigData\r
57 );\r
58 if (EFI_ERROR (Status)) {\r
59 DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
60 }\r
61 }\r
62}\r
5fd5fcd3 63\r
64//\r
65// BDS Platform Functions\r
66//\r
67VOID\r
d5275ee6 68EFIAPI\r
5fd5fcd3 69PlatformBdsInit (\r
d5275ee6 70 VOID\r
5fd5fcd3 71 )\r
72/*++\r
73\r
74Routine Description:\r
75\r
fcf24bad 76 Platform Bds init. Include the platform firmware vendor, revision\r
5fd5fcd3 77 and so crc check.\r
78\r
79Arguments:\r
80\r
5fd5fcd3 81Returns:\r
82\r
83 None.\r
84\r
85--*/\r
86{\r
ea3cfce6 87 BdsLibSaveMemoryTypeInformation ();\r
fcf24bad 88 SetupVariableInit ();\r
5fd5fcd3 89}\r
90\r
91EFI_STATUS\r
92PlatformBdsConnectConsole (\r
93 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
94 )\r
95/*++\r
96\r
97Routine Description:\r
98\r
99 Connect the predefined platform default console device. Always try to find\r
100 and enable the vga device if have.\r
101\r
102Arguments:\r
103\r
104 PlatformConsole - Predfined platform default console device array.\r
105 \r
106Returns:\r
107\r
108 EFI_SUCCESS - Success connect at least one ConIn and ConOut \r
109 device, there must have one ConOut device is \r
110 active vga device.\r
111 \r
112 EFI_STATUS - Return the status of \r
113 BdsLibConnectAllDefaultConsoles ()\r
114\r
115--*/\r
116{\r
117 EFI_STATUS Status;\r
118 UINTN Index;\r
119\r
120 Index = 0;\r
121 Status = EFI_SUCCESS;\r
122\r
123 //\r
124 // Have chance to connect the platform default console,\r
125 // the platform default console is the minimue device group\r
126 // the platform should support\r
127 //\r
128 while (PlatformConsole[Index].DevicePath != NULL) {\r
129 //\r
130 // Update the console variable with the connect type\r
131 //\r
132 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
133 BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
134 }\r
135\r
136 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
137 BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
138 }\r
139\r
140 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
141 BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
142 }\r
143\r
144 Index++;\r
145 }\r
146 //\r
147 // Connect the all the default console with current cosole variable\r
148 //\r
149 Status = BdsLibConnectAllDefaultConsoles ();\r
150 \r
151 return Status;\r
152}\r
153\r
154VOID\r
155PlatformBdsConnectSequence (\r
156 VOID\r
157 )\r
158/*++\r
159\r
160Routine Description:\r
161\r
162 Connect with predeined platform connect sequence, \r
163 the OEM/IBV can customize with their own connect sequence.\r
164 \r
165Arguments:\r
166\r
167 None.\r
168 \r
169Returns:\r
170\r
171 None.\r
172 \r
173--*/\r
174{\r
175 UINTN Index;\r
176\r
177 Index = 0;\r
178\r
179 //\r
180 // Here we can get the customized platform connect sequence\r
181 // Notes: we can connect with new variable which record the\r
182 // last time boots connect device path sequence\r
183 //\r
184 while (gPlatformConnectSequence[Index] != NULL) {\r
185 //\r
186 // Build the platform boot option\r
187 //\r
188 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
189 Index++;\r
190 }\r
191\r
192 //\r
193 // Jst use the simple policy to connect all devices\r
194 //\r
195 BdsLibConnectAll ();\r
196}\r
197\r
198VOID\r
199PlatformBdsGetDriverOption (\r
200 IN OUT LIST_ENTRY *BdsDriverLists\r
201 )\r
202/*++\r
203\r
204Routine Description:\r
205\r
206 Load the predefined driver option, OEM/IBV can customize this\r
207 to load their own drivers\r
208 \r
209Arguments:\r
210\r
211 BdsDriverLists - The header of the driver option link list.\r
212 \r
213Returns:\r
214\r
215 None.\r
216 \r
217--*/\r
218{\r
219 UINTN Index;\r
220\r
221 Index = 0;\r
222\r
223 //\r
224 // Here we can get the customized platform driver option\r
225 //\r
226 while (gPlatformDriverOption[Index] != NULL) {\r
227 //\r
228 // Build the platform boot option\r
229 //\r
230 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
231 Index++;\r
232 }\r
233\r
234}\r
235\r
236VOID\r
237PlatformBdsDiagnostics (\r
238 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
f51c8a9d 239 IN BOOLEAN QuietBoot,\r
240 IN BASEM_MEMORY_TEST BaseMemoryTest \r
5fd5fcd3 241 )\r
242/*++\r
243\r
244Routine Description:\r
245\r
246 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
247 can customize this fuction to support specific platform diagnostic.\r
248 \r
249Arguments:\r
250\r
251 MemoryTestLevel - The memory test intensive level\r
252 \r
253 QuietBoot - Indicate if need to enable the quiet boot\r
f51c8a9d 254\r
255 BaseMemoryTest - A pointer to BdsMemoryTest() \r
256\r
5fd5fcd3 257Returns:\r
258\r
259 None.\r
260 \r
261--*/\r
262{\r
263 EFI_STATUS Status;\r
264\r
265 //\r
266 // Here we can decide if we need to show\r
267 // the diagnostics screen\r
268 // Notes: this quiet boot code should be remove\r
269 // from the graphic lib\r
270 //\r
271 if (QuietBoot) {\r
d46f3632 272 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
5fd5fcd3 273 //\r
274 // Perform system diagnostic\r
275 //\r
f51c8a9d 276 Status = BaseMemoryTest (MemoryTestLevel);\r
5fd5fcd3 277 if (EFI_ERROR (Status)) {\r
278 DisableQuietBoot ();\r
279 }\r
280\r
281 return ;\r
282 }\r
283 //\r
284 // Perform system diagnostic\r
285 //\r
f51c8a9d 286 Status = BaseMemoryTest (MemoryTestLevel);\r
5fd5fcd3 287}\r
288\r
f51c8a9d 289/**\r
5fd5fcd3 290 The function will excute with as the platform policy, current policy\r
291 is driven by boot mode. IBV/OEM can customize this code for their specific\r
292 policy action.\r
5fd5fcd3 293\r
f51c8a9d 294 @param DriverOptionList The header of the driver option link list\r
295 @param BootOptionList The header of the boot option link list\r
296 @param ProcessCapsules A pointer to ProcessCapsules()\r
297 @param BaseMemoryTest A pointer to BaseMemoryTest()\r
5fd5fcd3 298\r
f51c8a9d 299**/\r
300VOID\r
301EFIAPI\r
302PlatformBdsPolicyBehavior (\r
303 IN OUT LIST_ENTRY *DriverOptionList,\r
304 IN OUT LIST_ENTRY *BootOptionList,\r
305 IN PROCESS_CAPSULES ProcessCapsules,\r
306 IN BASEM_MEMORY_TEST BaseMemoryTest\r
307 )\r
5fd5fcd3 308{\r
d5275ee6 309 EFI_STATUS Status;\r
310 UINT16 Timeout;\r
311 EFI_BOOT_MODE BootMode;\r
5fd5fcd3 312\r
313 //\r
314 // Init the time out value\r
315 //\r
21e97c72 316 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
5fd5fcd3 317\r
318 //\r
319 // Load the driver option as the driver option list\r
320 //\r
321 PlatformBdsGetDriverOption (DriverOptionList);\r
322\r
323 //\r
324 // Get current Boot Mode\r
325 //\r
d5275ee6 326 Status = BdsLibGetBootMode (&BootMode);\r
5fd5fcd3 327\r
328 //\r
329 // Go the different platform policy with different boot mode\r
330 // Notes: this part code can be change with the table policy\r
331 //\r
d5275ee6 332 switch (BootMode) {\r
5fd5fcd3 333\r
334 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
335 case BOOT_WITH_MINIMAL_CONFIGURATION:\r
336 //\r
337 // In no-configuration boot mode, we can connect the\r
338 // console directly.\r
339 //\r
340 BdsLibConnectAllDefaultConsoles ();\r
f51c8a9d 341 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE, BaseMemoryTest);\r
5fd5fcd3 342\r
343 //\r
344 // Perform some platform specific connect sequence\r
345 //\r
346 PlatformBdsConnectSequence ();\r
347\r
348 //\r
349 // Notes: current time out = 0 can not enter the\r
350 // front page\r
351 //\r
352 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
353\r
354 //\r
355 // Check the boot option with the boot option list\r
356 //\r
357 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
358 break;\r
359\r
360 case BOOT_ON_FLASH_UPDATE:\r
361 //\r
362 // Boot with the specific configuration\r
363 //\r
364 PlatformBdsConnectConsole (gPlatformConsole);\r
f51c8a9d 365 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
5fd5fcd3 366 BdsLibConnectAll ();\r
367 ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
368 break;\r
369\r
370 case BOOT_IN_RECOVERY_MODE:\r
371 //\r
372 // In recovery mode, just connect platform console\r
373 // and show up the front page\r
374 //\r
375 PlatformBdsConnectConsole (gPlatformConsole);\r
f51c8a9d 376 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
5fd5fcd3 377\r
378 //\r
379 // In recovery boot mode, we still enter to the\r
380 // frong page now\r
381 //\r
382 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
383 break;\r
384\r
385 case BOOT_WITH_FULL_CONFIGURATION:\r
386 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
387 case BOOT_WITH_DEFAULT_SETTINGS:\r
388 default:\r
389 //\r
390 // Connect platform console\r
391 //\r
392 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
393 if (EFI_ERROR (Status)) {\r
394 //\r
395 // Here OEM/IBV can customize with defined action\r
396 //\r
397 PlatformBdsNoConsoleAction ();\r
398 }\r
399\r
f51c8a9d 400 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE, BaseMemoryTest);\r
5fd5fcd3 401\r
402 //\r
403 // Perform some platform specific connect sequence\r
404 //\r
405 PlatformBdsConnectSequence ();\r
406\r
407 //\r
408 // Give one chance to enter the setup if we\r
409 // have the time out\r
410 //\r
411 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
412\r
413 //\r
414 // Here we have enough time to do the enumeration of boot device\r
415 //\r
416 BdsLibEnumerateAllBootOption (BootOptionList);\r
417 break;\r
418 }\r
419\r
420 return ;\r
421\r
422}\r
423\r
424VOID\r
d5275ee6 425EFIAPI\r
5fd5fcd3 426PlatformBdsBootSuccess (\r
427 IN BDS_COMMON_OPTION *Option\r
428 )\r
429/*++\r
430\r
431Routine Description:\r
432 \r
433 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
434 return, so the EFI 1.0 specification defines that you will default to an\r
435 interactive mode and stop processing the BootOrder list in this case. This\r
436 is alos a platform implementation and can be customized by IBV/OEM.\r
437\r
438Arguments:\r
439\r
440 Option - Pointer to Boot Option that succeeded to boot.\r
441\r
442Returns:\r
443 \r
444 None.\r
445\r
446--*/\r
447{\r
448 CHAR16 *TmpStr;\r
449\r
450 //\r
451 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
452 // select loop then we need to pop up a UI and wait for user input.\r
453 //\r
454 TmpStr = Option->StatusString;\r
455 if (TmpStr != NULL) {\r
456 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
457 FreePool (TmpStr);\r
458 }\r
459}\r
460\r
461VOID\r
d5275ee6 462EFIAPI\r
5fd5fcd3 463PlatformBdsBootFail (\r
464 IN BDS_COMMON_OPTION *Option,\r
465 IN EFI_STATUS Status,\r
466 IN CHAR16 *ExitData,\r
467 IN UINTN ExitDataSize\r
468 )\r
469/*++\r
470\r
471Routine Description:\r
472 \r
473 Hook point after a boot attempt fails.\r
474\r
475Arguments:\r
476 \r
477 Option - Pointer to Boot Option that failed to boot.\r
478\r
479 Status - Status returned from failed boot.\r
480\r
481 ExitData - Exit data returned from failed boot.\r
482\r
483 ExitDataSize - Exit data size returned from failed boot.\r
484\r
485Returns:\r
486 \r
487 None.\r
488\r
489--*/\r
490{\r
491 CHAR16 *TmpStr;\r
492\r
493 //\r
494 // If Boot returned with failed status then we need to pop up a UI and wait\r
495 // for user input.\r
496 //\r
497 TmpStr = Option->StatusString;\r
498 if (TmpStr != NULL) {\r
499 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
500 FreePool (TmpStr);\r
501 }\r
502\r
503}\r
504\r
505EFI_STATUS\r
506PlatformBdsNoConsoleAction (\r
507 VOID\r
508 )\r
509/*++\r
510\r
511Routine Description:\r
512 \r
513 This function is remained for IBV/OEM to do some platform action,\r
514 if there no console device can be connected.\r
515\r
516Arguments:\r
517 \r
518 None.\r
519 \r
520Returns:\r
521 \r
522 EFI_SUCCESS - Direct return success now.\r
523\r
524--*/\r
525{\r
526 return EFI_SUCCESS;\r
527}\r
528\r
24cdd14e
LG
529/**\r
530 This function locks platform flash that is not allowed to be updated during normal boot path.\r
531 The flash layout is platform specific.\r
532\r
533 **/\r
534VOID\r
5fd5fcd3 535EFIAPI\r
536PlatformBdsLockNonUpdatableFlash (\r
537 VOID\r
538 )\r
539{\r
24cdd14e
LG
540 return;\r
541}\r
542\r
543/**\r
544 Lock the ConsoleIn device in system table. All key\r
545 presses will be ignored until the Password is typed in. The only way to\r
546 disable the password is to type it in to a ConIn device.\r
547\r
548 @param Password Password used to lock ConIn device.\r
549\r
550 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
551 @retval EFI_UNSUPPORTED Password not found\r
552\r
553**/\r
554EFI_STATUS\r
555EFIAPI\r
556LockKeyboards (\r
557 IN CHAR16 *Password\r
558 )\r
559{\r
560 return EFI_UNSUPPORTED;\r
5fd5fcd3 561}\r