]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/Library/Nt32BdsLib/BdsPlatform.c
Move LockKeyboards API from GenericBdsLib to PlatformBdsLib
[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
238 IN BOOLEAN QuietBoot\r
239 )\r
240/*++\r
241\r
242Routine Description:\r
243\r
244 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
245 can customize this fuction to support specific platform diagnostic.\r
246 \r
247Arguments:\r
248\r
249 MemoryTestLevel - The memory test intensive level\r
250 \r
251 QuietBoot - Indicate if need to enable the quiet boot\r
252 \r
253Returns:\r
254\r
255 None.\r
256 \r
257--*/\r
258{\r
259 EFI_STATUS Status;\r
260\r
261 //\r
262 // Here we can decide if we need to show\r
263 // the diagnostics screen\r
264 // Notes: this quiet boot code should be remove\r
265 // from the graphic lib\r
266 //\r
267 if (QuietBoot) {\r
d46f3632 268 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
5fd5fcd3 269 //\r
270 // Perform system diagnostic\r
271 //\r
272 Status = BdsMemoryTest (MemoryTestLevel);\r
273 if (EFI_ERROR (Status)) {\r
274 DisableQuietBoot ();\r
275 }\r
276\r
277 return ;\r
278 }\r
279 //\r
280 // Perform system diagnostic\r
281 //\r
282 Status = BdsMemoryTest (MemoryTestLevel);\r
283}\r
284\r
285VOID\r
d5275ee6 286EFIAPI\r
5fd5fcd3 287PlatformBdsPolicyBehavior (\r
5fd5fcd3 288 IN OUT LIST_ENTRY *DriverOptionList,\r
289 IN OUT LIST_ENTRY *BootOptionList\r
290 )\r
291/*++\r
292\r
293Routine Description:\r
294\r
295 The function will excute with as the platform policy, current policy\r
296 is driven by boot mode. IBV/OEM can customize this code for their specific\r
297 policy action.\r
298 \r
299Arguments:\r
300\r
5fd5fcd3 301 DriverOptionList - The header of the driver option link list\r
302 \r
303 BootOptionList - The header of the boot option link list\r
304 \r
305Returns:\r
306\r
307 None.\r
308 \r
309--*/\r
310{\r
d5275ee6 311 EFI_STATUS Status;\r
312 UINT16 Timeout;\r
313 EFI_BOOT_MODE BootMode;\r
5fd5fcd3 314\r
315 //\r
316 // Init the time out value\r
317 //\r
21e97c72 318 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
5fd5fcd3 319\r
320 //\r
321 // Load the driver option as the driver option list\r
322 //\r
323 PlatformBdsGetDriverOption (DriverOptionList);\r
324\r
325 //\r
326 // Get current Boot Mode\r
327 //\r
d5275ee6 328 Status = BdsLibGetBootMode (&BootMode);\r
5fd5fcd3 329\r
330 //\r
331 // Go the different platform policy with different boot mode\r
332 // Notes: this part code can be change with the table policy\r
333 //\r
d5275ee6 334 switch (BootMode) {\r
5fd5fcd3 335\r
336 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
337 case BOOT_WITH_MINIMAL_CONFIGURATION:\r
338 //\r
339 // In no-configuration boot mode, we can connect the\r
340 // console directly.\r
341 //\r
342 BdsLibConnectAllDefaultConsoles ();\r
0b94e319 343 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);\r
5fd5fcd3 344\r
345 //\r
346 // Perform some platform specific connect sequence\r
347 //\r
348 PlatformBdsConnectSequence ();\r
349\r
350 //\r
351 // Notes: current time out = 0 can not enter the\r
352 // front page\r
353 //\r
354 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
355\r
356 //\r
357 // Check the boot option with the boot option list\r
358 //\r
359 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
360 break;\r
361\r
362 case BOOT_ON_FLASH_UPDATE:\r
363 //\r
364 // Boot with the specific configuration\r
365 //\r
366 PlatformBdsConnectConsole (gPlatformConsole);\r
367 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
368 BdsLibConnectAll ();\r
369 ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
370 break;\r
371\r
372 case BOOT_IN_RECOVERY_MODE:\r
373 //\r
374 // In recovery mode, just connect platform console\r
375 // and show up the front page\r
376 //\r
377 PlatformBdsConnectConsole (gPlatformConsole);\r
378 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
379\r
380 //\r
381 // In recovery boot mode, we still enter to the\r
382 // frong page now\r
383 //\r
384 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
385 break;\r
386\r
387 case BOOT_WITH_FULL_CONFIGURATION:\r
388 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
389 case BOOT_WITH_DEFAULT_SETTINGS:\r
390 default:\r
391 //\r
392 // Connect platform console\r
393 //\r
394 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
395 if (EFI_ERROR (Status)) {\r
396 //\r
397 // Here OEM/IBV can customize with defined action\r
398 //\r
399 PlatformBdsNoConsoleAction ();\r
400 }\r
401\r
0b94e319 402 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);\r
5fd5fcd3 403\r
404 //\r
405 // Perform some platform specific connect sequence\r
406 //\r
407 PlatformBdsConnectSequence ();\r
408\r
409 //\r
410 // Give one chance to enter the setup if we\r
411 // have the time out\r
412 //\r
413 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
414\r
415 //\r
416 // Here we have enough time to do the enumeration of boot device\r
417 //\r
418 BdsLibEnumerateAllBootOption (BootOptionList);\r
419 break;\r
420 }\r
421\r
422 return ;\r
423\r
424}\r
425\r
426VOID\r
d5275ee6 427EFIAPI\r
5fd5fcd3 428PlatformBdsBootSuccess (\r
429 IN BDS_COMMON_OPTION *Option\r
430 )\r
431/*++\r
432\r
433Routine Description:\r
434 \r
435 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
436 return, so the EFI 1.0 specification defines that you will default to an\r
437 interactive mode and stop processing the BootOrder list in this case. This\r
438 is alos a platform implementation and can be customized by IBV/OEM.\r
439\r
440Arguments:\r
441\r
442 Option - Pointer to Boot Option that succeeded to boot.\r
443\r
444Returns:\r
445 \r
446 None.\r
447\r
448--*/\r
449{\r
450 CHAR16 *TmpStr;\r
451\r
452 //\r
453 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
454 // select loop then we need to pop up a UI and wait for user input.\r
455 //\r
456 TmpStr = Option->StatusString;\r
457 if (TmpStr != NULL) {\r
458 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
459 FreePool (TmpStr);\r
460 }\r
461}\r
462\r
463VOID\r
d5275ee6 464EFIAPI\r
5fd5fcd3 465PlatformBdsBootFail (\r
466 IN BDS_COMMON_OPTION *Option,\r
467 IN EFI_STATUS Status,\r
468 IN CHAR16 *ExitData,\r
469 IN UINTN ExitDataSize\r
470 )\r
471/*++\r
472\r
473Routine Description:\r
474 \r
475 Hook point after a boot attempt fails.\r
476\r
477Arguments:\r
478 \r
479 Option - Pointer to Boot Option that failed to boot.\r
480\r
481 Status - Status returned from failed boot.\r
482\r
483 ExitData - Exit data returned from failed boot.\r
484\r
485 ExitDataSize - Exit data size returned from failed boot.\r
486\r
487Returns:\r
488 \r
489 None.\r
490\r
491--*/\r
492{\r
493 CHAR16 *TmpStr;\r
494\r
495 //\r
496 // If Boot returned with failed status then we need to pop up a UI and wait\r
497 // for user input.\r
498 //\r
499 TmpStr = Option->StatusString;\r
500 if (TmpStr != NULL) {\r
501 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
502 FreePool (TmpStr);\r
503 }\r
504\r
505}\r
506\r
507EFI_STATUS\r
508PlatformBdsNoConsoleAction (\r
509 VOID\r
510 )\r
511/*++\r
512\r
513Routine Description:\r
514 \r
515 This function is remained for IBV/OEM to do some platform action,\r
516 if there no console device can be connected.\r
517\r
518Arguments:\r
519 \r
520 None.\r
521 \r
522Returns:\r
523 \r
524 EFI_SUCCESS - Direct return success now.\r
525\r
526--*/\r
527{\r
528 return EFI_SUCCESS;\r
529}\r
530\r
24cdd14e
LG
531/**\r
532 This function locks platform flash that is not allowed to be updated during normal boot path.\r
533 The flash layout is platform specific.\r
534\r
535 **/\r
536VOID\r
5fd5fcd3 537EFIAPI\r
538PlatformBdsLockNonUpdatableFlash (\r
539 VOID\r
540 )\r
541{\r
24cdd14e
LG
542 return;\r
543}\r
544\r
545/**\r
546 Lock the ConsoleIn device in system table. All key\r
547 presses will be ignored until the Password is typed in. The only way to\r
548 disable the password is to type it in to a ConIn device.\r
549\r
550 @param Password Password used to lock ConIn device.\r
551\r
552 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
553 @retval EFI_UNSUPPORTED Password not found\r
554\r
555**/\r
556EFI_STATUS\r
557EFIAPI\r
558LockKeyboards (\r
559 IN CHAR16 *Password\r
560 )\r
561{\r
562 return EFI_UNSUPPORTED;\r
5fd5fcd3 563}\r