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