]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
EmulatorPkg: Remove all trailing whitespace
[mirror_edk2.git] / EmulatorPkg / Library / EmuBdsLib / BdsPlatform.c
CommitLineData
949f388f 1/*++ @file\r
2\r
3Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
4Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
d18d8a1d 5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
949f388f 12\r
13**/\r
14\r
15#include "BdsPlatform.h"\r
16\r
17EMU_SYSTEM_CONFIGURATION mSystemConfigData;\r
18\r
19VOID\r
20SetupVariableInit (\r
21 VOID\r
22 )\r
23{\r
24 EFI_STATUS Status;\r
25 UINTN Size;\r
26\r
27 Size = sizeof (mSystemConfigData);\r
28 Status = gRT->GetVariable (\r
29 L"Setup",\r
30 &gEmuSystemConfigGuid,\r
31 NULL,\r
32 &Size,\r
33 (VOID *) &mSystemConfigData\r
34 );\r
35\r
36 if (EFI_ERROR (Status)) {\r
37 //\r
38 // SetupVariable is corrupt\r
39 //\r
40 mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
41 mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
42\r
43 Status = gRT->SetVariable (\r
44 L"Setup",\r
45 &gEmuSystemConfigGuid,\r
46 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
47 sizeof (mSystemConfigData),\r
48 (VOID *) &mSystemConfigData\r
49 );\r
50 if (EFI_ERROR (Status)) {\r
51 DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
52 }\r
53 }\r
54}\r
55\r
56//\r
57// BDS Platform Functions\r
58//\r
59VOID\r
60EFIAPI\r
61PlatformBdsInit (\r
62 VOID\r
63 )\r
64/*++\r
65\r
66Routine Description:\r
67\r
68 Platform Bds init. Include the platform firmware vendor, revision\r
69 and so crc check.\r
70\r
71Arguments:\r
72\r
73Returns:\r
74\r
75 None.\r
76\r
77**/\r
78{\r
79 SetupVariableInit ();\r
80}\r
81\r
82EFI_STATUS\r
83PlatformBdsConnectConsole (\r
84 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
85 )\r
86/*++\r
87\r
88Routine Description:\r
89\r
90 Connect the predefined platform default console device. Always try to find\r
91 and enable the vga device if have.\r
92\r
93Arguments:\r
94\r
95 PlatformConsole - Predfined platform default console device array.\r
d18d8a1d 96\r
949f388f 97Returns:\r
98\r
d18d8a1d 99 EFI_SUCCESS - Success connect at least one ConIn and ConOut\r
100 device, there must have one ConOut device is\r
949f388f 101 active vga device.\r
d18d8a1d 102\r
103 EFI_STATUS - Return the status of\r
949f388f 104 BdsLibConnectAllDefaultConsoles ()\r
105\r
106**/\r
107{\r
108 EFI_STATUS Status;\r
109 UINTN Index;\r
110\r
111 Index = 0;\r
112 Status = EFI_SUCCESS;\r
113\r
114 //\r
115 // Have chance to connect the platform default console,\r
116 // the platform default console is the minimue device group\r
117 // the platform should support\r
118 //\r
119 while (PlatformConsole[Index].DevicePath != NULL) {\r
120 //\r
121 // Update the console variable with the connect type\r
122 //\r
123 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
124 BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
125 }\r
126\r
127 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
128 BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
129 }\r
130\r
131 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
132 BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
133 }\r
134\r
135 Index++;\r
136 }\r
137 //\r
138 // Connect the all the default console with current cosole variable\r
139 //\r
140 Status = BdsLibConnectAllDefaultConsoles ();\r
141 return Status;\r
142}\r
143\r
144VOID\r
145PlatformBdsConnectSequence (\r
146 VOID\r
147 )\r
148/*++\r
149\r
150Routine Description:\r
151\r
d18d8a1d 152 Connect with predeined platform connect sequence,\r
949f388f 153 the OEM/IBV can customize with their own connect sequence.\r
d18d8a1d 154\r
949f388f 155Arguments:\r
156\r
157 None.\r
d18d8a1d 158\r
949f388f 159Returns:\r
160\r
161 None.\r
d18d8a1d 162\r
949f388f 163**/\r
164{\r
165 UINTN Index;\r
166\r
167 Index = 0;\r
168\r
169 //\r
170 // Here we can get the customized platform connect sequence\r
171 // Notes: we can connect with new variable which record the\r
172 // last time boots connect device path sequence\r
173 //\r
174 while (gPlatformConnectSequence[Index] != NULL) {\r
175 //\r
176 // Build the platform boot option\r
177 //\r
178 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
179 Index++;\r
180 }\r
181\r
182 //\r
183 // Just use the simple policy to connect all devices\r
184 //\r
185 BdsLibConnectAll ();\r
186}\r
187\r
188VOID\r
189PlatformBdsGetDriverOption (\r
190 IN OUT LIST_ENTRY *BdsDriverLists\r
191 )\r
192/*++\r
193\r
194Routine Description:\r
195\r
196 Load the predefined driver option, OEM/IBV can customize this\r
197 to load their own drivers\r
d18d8a1d 198\r
949f388f 199Arguments:\r
200\r
201 BdsDriverLists - The header of the driver option link list.\r
d18d8a1d 202\r
949f388f 203Returns:\r
204\r
205 None.\r
d18d8a1d 206\r
949f388f 207**/\r
208{\r
209 UINTN Index;\r
210\r
211 Index = 0;\r
212\r
213 //\r
214 // Here we can get the customized platform driver option\r
215 //\r
216 while (gPlatformDriverOption[Index] != NULL) {\r
217 //\r
218 // Build the platform boot option\r
219 //\r
220 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
221 Index++;\r
222 }\r
223\r
224}\r
225\r
226VOID\r
227PlatformBdsDiagnostics (\r
228 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
229 IN BOOLEAN QuietBoot,\r
230 IN BASEM_MEMORY_TEST BaseMemoryTest\r
231 )\r
232/*++\r
233\r
234Routine Description:\r
235\r
236 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
237 can customize this fuction to support specific platform diagnostic.\r
d18d8a1d 238\r
949f388f 239Arguments:\r
240\r
241 MemoryTestLevel - The memory test intensive level\r
d18d8a1d 242\r
949f388f 243 QuietBoot - Indicate if need to enable the quiet boot\r
244\r
245 BaseMemoryTest - A pointer to BdsMemoryTest()\r
d18d8a1d 246\r
949f388f 247Returns:\r
248\r
249 None.\r
d18d8a1d 250\r
949f388f 251**/\r
252{\r
253 EFI_STATUS Status;\r
254\r
255 //\r
256 // Here we can decide if we need to show\r
257 // the diagnostics screen\r
258 // Notes: this quiet boot code should be remove\r
259 // from the graphic lib\r
260 //\r
261 if (QuietBoot) {\r
262 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
263 //\r
264 // Perform system diagnostic\r
265 //\r
266 Status = BaseMemoryTest (MemoryTestLevel);\r
267 if (EFI_ERROR (Status)) {\r
268 DisableQuietBoot ();\r
269 }\r
270\r
271 return ;\r
272 }\r
273 //\r
274 // Perform system diagnostic\r
275 //\r
276 Status = BaseMemoryTest (MemoryTestLevel);\r
277}\r
278\r
279VOID\r
280EFIAPI\r
281PlatformBdsPolicyBehavior (\r
282 IN OUT LIST_ENTRY *DriverOptionList,\r
283 IN OUT LIST_ENTRY *BootOptionList,\r
284 IN PROCESS_CAPSULES ProcessCapsules,\r
285 IN BASEM_MEMORY_TEST BaseMemoryTest\r
286 )\r
287/*++\r
288\r
289Routine Description:\r
290\r
291 The function will excute with as the platform policy, current policy\r
292 is driven by boot mode. IBV/OEM can customize this code for their specific\r
293 policy action.\r
d18d8a1d 294\r
949f388f 295Arguments:\r
296\r
297 DriverOptionList - The header of the driver option link list\r
d18d8a1d 298\r
949f388f 299 BootOptionList - The header of the boot option link list\r
300\r
301 ProcessCapsules - A pointer to ProcessCapsules()\r
302\r
303 BaseMemoryTest - A pointer to BaseMemoryTest()\r
304\r
305Returns:\r
306\r
307 None.\r
d18d8a1d 308\r
949f388f 309**/\r
310{\r
311 EFI_STATUS Status;\r
312 UINT16 Timeout;\r
313 EFI_BOOT_MODE BootMode;\r
314\r
315 //\r
316 // Init the time out value\r
317 //\r
318 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
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
328 Status = BdsLibGetBootMode (&BootMode);\r
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
334 switch (BootMode) {\r
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
343 PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
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, BaseMemoryTest);\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, BaseMemoryTest);\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
402 PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
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
427EFIAPI\r
428PlatformBdsBootSuccess (\r
429 IN BDS_COMMON_OPTION *Option\r
430 )\r
431/*++\r
432\r
433Routine Description:\r
d18d8a1d 434\r
949f388f 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
d18d8a1d 445\r
949f388f 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
464EFIAPI\r
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
d18d8a1d 474\r
949f388f 475 Hook point after a boot attempt fails.\r
476\r
477Arguments:\r
d18d8a1d 478\r
949f388f 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
d18d8a1d 488\r
949f388f 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
506EFI_STATUS\r
507PlatformBdsNoConsoleAction (\r
508 VOID\r
509 )\r
510/*++\r
511\r
512Routine Description:\r
d18d8a1d 513\r
949f388f 514 This function is remained for IBV/OEM to do some platform action,\r
515 if there no console device can be connected.\r
516\r
517Arguments:\r
d18d8a1d 518\r
949f388f 519 None.\r
d18d8a1d 520\r
949f388f 521Returns:\r
d18d8a1d 522\r
949f388f 523 EFI_SUCCESS - Direct return success now.\r
524\r
525**/\r
526{\r
527 return EFI_SUCCESS;\r
528}\r
529\r
530VOID\r
531EFIAPI\r
532PlatformBdsLockNonUpdatableFlash (\r
533 VOID\r
534 )\r
535{\r
536 return;\r
537}\r
538\r
539/**\r
540 Lock the ConsoleIn device in system table. All key\r
541 presses will be ignored until the Password is typed in. The only way to\r
542 disable the password is to type it in to a ConIn device.\r
543\r
544 @param Password Password used to lock ConIn device.\r
545\r
546 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
547 @retval EFI_UNSUPPORTED Password not found\r
548\r
549**/\r
550EFI_STATUS\r
551EFIAPI\r
552LockKeyboards (\r
553 IN CHAR16 *Password\r
554 )\r
555{\r
556 return EFI_UNSUPPORTED;\r
557}\r