]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/Library/Nt32BdsLib/BdsPlatform.c
Enable UID support in NT32 platform
[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
aa115881 347 //\r
348 // Perform user identification process\r
349 //\r
350 PlatformBdsUserIdentify ();\r
351 \r
5fd5fcd3 352 //\r
353 // Notes: current time out = 0 can not enter the\r
354 // front page\r
355 //\r
356 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
357\r
358 //\r
359 // Check the boot option with the boot option list\r
360 //\r
361 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
362 break;\r
363\r
364 case BOOT_ON_FLASH_UPDATE:\r
365 //\r
366 // Boot with the specific configuration\r
367 //\r
368 PlatformBdsConnectConsole (gPlatformConsole);\r
f51c8a9d 369 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
5fd5fcd3 370 BdsLibConnectAll ();\r
aa115881 371 //\r
372 // Perform user identification process\r
373 //\r
374 PlatformBdsUserIdentify ();\r
5fd5fcd3 375 ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
376 break;\r
377\r
378 case BOOT_IN_RECOVERY_MODE:\r
379 //\r
380 // In recovery mode, just connect platform console\r
381 // and show up the front page\r
382 //\r
383 PlatformBdsConnectConsole (gPlatformConsole);\r
f51c8a9d 384 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);\r
5fd5fcd3 385\r
aa115881 386 //\r
387 // Perform user identification process\r
388 //\r
389 PlatformBdsUserIdentify ();\r
390 \r
5fd5fcd3 391 //\r
392 // In recovery boot mode, we still enter to the\r
393 // frong page now\r
394 //\r
395 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
396 break;\r
397\r
398 case BOOT_WITH_FULL_CONFIGURATION:\r
399 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
400 case BOOT_WITH_DEFAULT_SETTINGS:\r
401 default:\r
402 //\r
403 // Connect platform console\r
404 //\r
405 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
406 if (EFI_ERROR (Status)) {\r
407 //\r
408 // Here OEM/IBV can customize with defined action\r
409 //\r
410 PlatformBdsNoConsoleAction ();\r
411 }\r
412\r
f51c8a9d 413 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE, BaseMemoryTest);\r
5fd5fcd3 414\r
415 //\r
416 // Perform some platform specific connect sequence\r
417 //\r
418 PlatformBdsConnectSequence ();\r
419\r
aa115881 420 //\r
421 // Perform user identification process\r
422 //\r
423 PlatformBdsUserIdentify ();\r
424 \r
5fd5fcd3 425 //\r
426 // Give one chance to enter the setup if we\r
427 // have the time out\r
428 //\r
429 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
430\r
431 //\r
432 // Here we have enough time to do the enumeration of boot device\r
433 //\r
434 BdsLibEnumerateAllBootOption (BootOptionList);\r
435 break;\r
436 }\r
437\r
438 return ;\r
439\r
440}\r
441\r
442VOID\r
d5275ee6 443EFIAPI\r
5fd5fcd3 444PlatformBdsBootSuccess (\r
445 IN BDS_COMMON_OPTION *Option\r
446 )\r
447/*++\r
448\r
449Routine Description:\r
450 \r
451 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
452 return, so the EFI 1.0 specification defines that you will default to an\r
453 interactive mode and stop processing the BootOrder list in this case. This\r
454 is alos a platform implementation and can be customized by IBV/OEM.\r
455\r
456Arguments:\r
457\r
458 Option - Pointer to Boot Option that succeeded to boot.\r
459\r
460Returns:\r
461 \r
462 None.\r
463\r
464--*/\r
465{\r
466 CHAR16 *TmpStr;\r
467\r
468 //\r
469 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
470 // select loop then we need to pop up a UI and wait for user input.\r
471 //\r
472 TmpStr = Option->StatusString;\r
473 if (TmpStr != NULL) {\r
474 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
475 FreePool (TmpStr);\r
476 }\r
477}\r
478\r
479VOID\r
d5275ee6 480EFIAPI\r
5fd5fcd3 481PlatformBdsBootFail (\r
482 IN BDS_COMMON_OPTION *Option,\r
483 IN EFI_STATUS Status,\r
484 IN CHAR16 *ExitData,\r
485 IN UINTN ExitDataSize\r
486 )\r
487/*++\r
488\r
489Routine Description:\r
490 \r
491 Hook point after a boot attempt fails.\r
492\r
493Arguments:\r
494 \r
495 Option - Pointer to Boot Option that failed to boot.\r
496\r
497 Status - Status returned from failed boot.\r
498\r
499 ExitData - Exit data returned from failed boot.\r
500\r
501 ExitDataSize - Exit data size returned from failed boot.\r
502\r
503Returns:\r
504 \r
505 None.\r
506\r
507--*/\r
508{\r
509 CHAR16 *TmpStr;\r
510\r
511 //\r
512 // If Boot returned with failed status then we need to pop up a UI and wait\r
513 // for user input.\r
514 //\r
515 TmpStr = Option->StatusString;\r
516 if (TmpStr != NULL) {\r
517 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
518 FreePool (TmpStr);\r
519 }\r
520\r
521}\r
522\r
523EFI_STATUS\r
524PlatformBdsNoConsoleAction (\r
525 VOID\r
526 )\r
527/*++\r
528\r
529Routine Description:\r
530 \r
531 This function is remained for IBV/OEM to do some platform action,\r
532 if there no console device can be connected.\r
533\r
534Arguments:\r
535 \r
536 None.\r
537 \r
538Returns:\r
539 \r
540 EFI_SUCCESS - Direct return success now.\r
541\r
542--*/\r
543{\r
544 return EFI_SUCCESS;\r
545}\r
546\r
24cdd14e
LG
547/**\r
548 This function locks platform flash that is not allowed to be updated during normal boot path.\r
549 The flash layout is platform specific.\r
550\r
551 **/\r
552VOID\r
5fd5fcd3 553EFIAPI\r
554PlatformBdsLockNonUpdatableFlash (\r
555 VOID\r
556 )\r
557{\r
24cdd14e
LG
558 return;\r
559}\r
560\r
561/**\r
562 Lock the ConsoleIn device in system table. All key\r
563 presses will be ignored until the Password is typed in. The only way to\r
564 disable the password is to type it in to a ConIn device.\r
565\r
566 @param Password Password used to lock ConIn device.\r
567\r
568 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
569 @retval EFI_UNSUPPORTED Password not found\r
570\r
571**/\r
572EFI_STATUS\r
573EFIAPI\r
574LockKeyboards (\r
575 IN CHAR16 *Password\r
576 )\r
577{\r
578 return EFI_UNSUPPORTED;\r
5fd5fcd3 579}\r
aa115881 580\r
581\r
582EFI_STATUS\r
583PlatformBdsUserIdentify (\r
584 VOID\r
585 )\r
586/*++\r
587\r
588 Routine Description:\r
589\r
590 This function is to identify a valid user, if successed, handle the deferred images.\r
591\r
592 Arguments:\r
593\r
594 None.\r
595\r
596 Returns:\r
597\r
598 EFI_SUCCESS - User successfully identified.\r
599\r
600--*/\r
601{\r
602 EFI_STATUS Status;\r
603 EFI_USER_MANAGER_PROTOCOL *Manager;\r
604 EFI_USER_PROFILE_HANDLE User;\r
605\r
606 //\r
607 // Locate user manager driver\r
608 //\r
609 Status = gBS->LocateProtocol (\r
610 &gEfiUserManagerProtocolGuid,\r
611 NULL,\r
612 &Manager\r
613 );\r
614 if (EFI_ERROR (Status)) {\r
615 return Status;\r
616 }\r
617 \r
618 //\r
619 // Identity user\r
620 //\r
621 Status = Manager->Identify (Manager, &User);\r
622 return Status;\r
623}\r
624\r
625\r