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