]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Library/UnixBdsLib/BdsPlatform.c
Move LockKeyboards API from GenericBdsLib to PlatformBdsLib
[mirror_edk2.git] / UnixPkg / Library / UnixBdsLib / BdsPlatform.c
CommitLineData
804405e7 1/*++\r
2\r
b672348f 3Copyright (c) 2006 - 2009, Intel Corporation \r
804405e7 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
21--*/\r
22\r
23#include "BdsPlatform.h"\r
24\r
c71b6597 25UNIX_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 &gEfiUnixSystemConfigGuid,\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 &gEfiUnixSystemConfigGuid,\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
804405e7 63\r
64//\r
65// BDS Platform Functions\r
66//\r
67VOID\r
84478ded 68EFIAPI\r
804405e7 69PlatformBdsInit (\r
84478ded 70 VOID\r
804405e7 71 )\r
72/*++\r
73\r
74Routine Description:\r
75\r
c71b6597 76 Platform Bds init. Include the platform firmware vendor, revision\r
804405e7 77 and so crc check.\r
78\r
79Arguments:\r
80\r
804405e7 81Returns:\r
82\r
83 None.\r
84\r
85--*/\r
86{\r
b672348f 87 SetupVariableInit ();\r
804405e7 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 return Status;\r
150}\r
151\r
152VOID\r
153PlatformBdsConnectSequence (\r
154 VOID\r
155 )\r
156/*++\r
157\r
158Routine Description:\r
159\r
160 Connect with predeined platform connect sequence, \r
161 the OEM/IBV can customize with their own connect sequence.\r
162 \r
163Arguments:\r
164\r
165 None.\r
166 \r
167Returns:\r
168\r
169 None.\r
170 \r
171--*/\r
172{\r
173 UINTN Index;\r
174\r
175 Index = 0;\r
176\r
177 //\r
178 // Here we can get the customized platform connect sequence\r
179 // Notes: we can connect with new variable which record the\r
180 // last time boots connect device path sequence\r
181 //\r
182 while (gPlatformConnectSequence[Index] != NULL) {\r
183 //\r
184 // Build the platform boot option\r
185 //\r
186 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
187 Index++;\r
188 }\r
189\r
190 //\r
191 // Just use the simple policy to connect all devices\r
192 //\r
193 BdsLibConnectAll ();\r
194}\r
195\r
196VOID\r
197PlatformBdsGetDriverOption (\r
198 IN OUT LIST_ENTRY *BdsDriverLists\r
199 )\r
200/*++\r
201\r
202Routine Description:\r
203\r
204 Load the predefined driver option, OEM/IBV can customize this\r
205 to load their own drivers\r
206 \r
207Arguments:\r
208\r
209 BdsDriverLists - The header of the driver option link list.\r
210 \r
211Returns:\r
212\r
213 None.\r
214 \r
215--*/\r
216{\r
217 UINTN Index;\r
218\r
219 Index = 0;\r
220\r
221 //\r
222 // Here we can get the customized platform driver option\r
223 //\r
224 while (gPlatformDriverOption[Index] != NULL) {\r
225 //\r
226 // Build the platform boot option\r
227 //\r
228 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
229 Index++;\r
230 }\r
231\r
232}\r
233\r
234VOID\r
235PlatformBdsDiagnostics (\r
236 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
237 IN BOOLEAN QuietBoot\r
238 )\r
239/*++\r
240\r
241Routine Description:\r
242\r
243 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
244 can customize this fuction to support specific platform diagnostic.\r
245 \r
246Arguments:\r
247\r
248 MemoryTestLevel - The memory test intensive level\r
249 \r
250 QuietBoot - Indicate if need to enable the quiet boot\r
251 \r
252Returns:\r
253\r
254 None.\r
255 \r
256--*/\r
257{\r
258 EFI_STATUS Status;\r
259\r
260 //\r
261 // Here we can decide if we need to show\r
262 // the diagnostics screen\r
263 // Notes: this quiet boot code should be remove\r
264 // from the graphic lib\r
265 //\r
266 if (QuietBoot) {\r
d46f3632 267 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
804405e7 268 //\r
269 // Perform system diagnostic\r
270 //\r
271 Status = BdsMemoryTest (MemoryTestLevel);\r
272 if (EFI_ERROR (Status)) {\r
273 DisableQuietBoot ();\r
274 }\r
275\r
276 return ;\r
277 }\r
278 //\r
279 // Perform system diagnostic\r
280 //\r
281 Status = BdsMemoryTest (MemoryTestLevel);\r
282}\r
283\r
284VOID\r
84478ded 285EFIAPI\r
804405e7 286PlatformBdsPolicyBehavior (\r
804405e7 287 IN OUT LIST_ENTRY *DriverOptionList,\r
288 IN OUT LIST_ENTRY *BootOptionList\r
289 )\r
290/*++\r
291\r
292Routine Description:\r
293\r
294 The function will excute with as the platform policy, current policy\r
295 is driven by boot mode. IBV/OEM can customize this code for their specific\r
296 policy action.\r
297 \r
298Arguments:\r
299\r
804405e7 300 DriverOptionList - The header of the driver option link list\r
301 \r
302 BootOptionList - The header of the boot option link list\r
303 \r
304Returns:\r
305\r
306 None.\r
307 \r
308--*/\r
309{\r
84478ded 310 EFI_STATUS Status;\r
311 UINT16 Timeout;\r
312 EFI_BOOT_MODE BootMode;\r
804405e7 313\r
314 //\r
315 // Init the time out value\r
316 //\r
12a738ed 317 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
804405e7 318\r
319 //\r
320 // Load the driver option as the driver option list\r
321 //\r
322 PlatformBdsGetDriverOption (DriverOptionList);\r
323\r
324 //\r
325 // Get current Boot Mode\r
326 //\r
84478ded 327 Status = BdsLibGetBootMode (&BootMode);\r
804405e7 328\r
329 //\r
330 // Go the different platform policy with different boot mode\r
331 // Notes: this part code can be change with the table policy\r
332 //\r
84478ded 333 switch (BootMode) {\r
804405e7 334\r
335 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
336 case BOOT_WITH_MINIMAL_CONFIGURATION:\r
337 //\r
338 // In no-configuration boot mode, we can connect the\r
339 // console directly.\r
340 //\r
341 BdsLibConnectAllDefaultConsoles ();\r
342 PlatformBdsDiagnostics (IGNORE, TRUE);\r
343\r
344 //\r
345 // Perform some platform specific connect sequence\r
346 //\r
347 PlatformBdsConnectSequence ();\r
348\r
349 //\r
350 // Notes: current time out = 0 can not enter the\r
351 // front page\r
352 //\r
353 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
354\r
355 //\r
356 // Check the boot option with the boot option list\r
357 //\r
358 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
359 break;\r
360\r
361 case BOOT_ON_FLASH_UPDATE:\r
362 //\r
363 // Boot with the specific configuration\r
364 //\r
365 PlatformBdsConnectConsole (gPlatformConsole);\r
366 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
367 BdsLibConnectAll ();\r
368 ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
369 break;\r
370\r
371 case BOOT_IN_RECOVERY_MODE:\r
372 //\r
373 // In recovery mode, just connect platform console\r
374 // and show up the front page\r
375 //\r
376 PlatformBdsConnectConsole (gPlatformConsole);\r
377 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
378\r
379 //\r
380 // In recovery boot mode, we still enter to the\r
381 // frong page now\r
382 //\r
383 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
384 break;\r
385\r
386 case BOOT_WITH_FULL_CONFIGURATION:\r
387 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
388 case BOOT_WITH_DEFAULT_SETTINGS:\r
389 default:\r
390 //\r
391 // Connect platform console\r
392 //\r
393 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
394 if (EFI_ERROR (Status)) {\r
395 //\r
396 // Here OEM/IBV can customize with defined action\r
397 //\r
398 PlatformBdsNoConsoleAction ();\r
399 }\r
400\r
401 PlatformBdsDiagnostics (IGNORE, TRUE);\r
402\r
403 //\r
404 // Perform some platform specific connect sequence\r
405 //\r
406 PlatformBdsConnectSequence ();\r
407\r
408 //\r
409 // Give one chance to enter the setup if we\r
410 // have the time out\r
411 //\r
412 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
413\r
414 //\r
415 // Here we have enough time to do the enumeration of boot device\r
416 //\r
417 BdsLibEnumerateAllBootOption (BootOptionList);\r
418 break;\r
419 }\r
420\r
421 return ;\r
422\r
423}\r
424\r
425VOID\r
84478ded 426EFIAPI\r
804405e7 427PlatformBdsBootSuccess (\r
428 IN BDS_COMMON_OPTION *Option\r
429 )\r
430/*++\r
431\r
432Routine Description:\r
433 \r
434 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
435 return, so the EFI 1.0 specification defines that you will default to an\r
436 interactive mode and stop processing the BootOrder list in this case. This\r
437 is alos a platform implementation and can be customized by IBV/OEM.\r
438\r
439Arguments:\r
440\r
441 Option - Pointer to Boot Option that succeeded to boot.\r
442\r
443Returns:\r
444 \r
445 None.\r
446\r
447--*/\r
448{\r
449 CHAR16 *TmpStr;\r
450\r
451 //\r
452 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
453 // select loop then we need to pop up a UI and wait for user input.\r
454 //\r
455 TmpStr = Option->StatusString;\r
456 if (TmpStr != NULL) {\r
457 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
458 FreePool (TmpStr);\r
459 }\r
460}\r
461\r
462VOID\r
84478ded 463EFIAPI\r
804405e7 464PlatformBdsBootFail (\r
465 IN BDS_COMMON_OPTION *Option,\r
466 IN EFI_STATUS Status,\r
467 IN CHAR16 *ExitData,\r
468 IN UINTN ExitDataSize\r
469 )\r
470/*++\r
471\r
472Routine Description:\r
473 \r
474 Hook point after a boot attempt fails.\r
475\r
476Arguments:\r
477 \r
478 Option - Pointer to Boot Option that failed to boot.\r
479\r
480 Status - Status returned from failed boot.\r
481\r
482 ExitData - Exit data returned from failed boot.\r
483\r
484 ExitDataSize - Exit data size returned from failed boot.\r
485\r
486Returns:\r
487 \r
488 None.\r
489\r
490--*/\r
491{\r
492 CHAR16 *TmpStr;\r
493\r
494 //\r
495 // If Boot returned with failed status then we need to pop up a UI and wait\r
496 // for user input.\r
497 //\r
498 TmpStr = Option->StatusString;\r
499 if (TmpStr != NULL) {\r
500 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
501 FreePool (TmpStr);\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 529VOID\r
804405e7 530EFIAPI\r
531PlatformBdsLockNonUpdatableFlash (\r
532 VOID\r
533 )\r
534{\r
24cdd14e
LG
535 return;\r
536}\r
537\r
538/**\r
539 Lock the ConsoleIn device in system table. All key\r
540 presses will be ignored until the Password is typed in. The only way to\r
541 disable the password is to type it in to a ConIn device.\r
542\r
543 @param Password Password used to lock ConIn device.\r
544\r
545 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
546 @retval EFI_UNSUPPORTED Password not found\r
547\r
548**/\r
549EFI_STATUS\r
550EFIAPI\r
551LockKeyboards (\r
552 IN CHAR16 *Password\r
553 )\r
554{\r
555 return EFI_UNSUPPORTED;\r
804405e7 556}\r