]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/Library/Nt32BdsLib/BdsPlatform.c
Retire Logo and Shell guid header file, which are replaced by gEfiIntelFrameworkModul...
[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
25CHAR16 mFirmwareVendor[] = L"TianoCore.org";\r
fcf24bad 26WIN_NT_SYSTEM_CONFIGURATION mSystemConfigData;\r
27\r
28VOID\r
29SetupVariableInit (\r
30 VOID\r
31 )\r
32{\r
33 EFI_STATUS Status;\r
34 UINTN Size;\r
35\r
36 Size = sizeof (mSystemConfigData);\r
37 Status = gRT->GetVariable (\r
38 L"Setup",\r
39 &gEfiWinNtSystemConfigGuid,\r
40 NULL,\r
41 &Size,\r
42 (VOID *) &mSystemConfigData\r
43 );\r
44\r
45 if (EFI_ERROR (Status)) {\r
46 //\r
47 // SetupVariable is corrupt\r
48 //\r
49 mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);\r
50 mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);\r
51\r
52 Status = gRT->SetVariable (\r
53 L"Setup",\r
54 &gEfiWinNtSystemConfigGuid,\r
55 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
56 sizeof (mSystemConfigData),\r
57 (VOID *) &mSystemConfigData\r
58 );\r
59 if (EFI_ERROR (Status)) {\r
60 DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));\r
61 }\r
62 }\r
63}\r
5fd5fcd3 64\r
65//\r
66// BDS Platform Functions\r
67//\r
68VOID\r
d5275ee6 69EFIAPI\r
5fd5fcd3 70PlatformBdsInit (\r
d5275ee6 71 VOID\r
5fd5fcd3 72 )\r
73/*++\r
74\r
75Routine Description:\r
76\r
fcf24bad 77 Platform Bds init. Include the platform firmware vendor, revision\r
5fd5fcd3 78 and so crc check.\r
79\r
80Arguments:\r
81\r
5fd5fcd3 82Returns:\r
83\r
84 None.\r
85\r
86--*/\r
87{\r
88 //\r
89 // set firmwarevendor, here can be IBV/OEM customize\r
90 //\r
91 gST->FirmwareVendor = AllocateRuntimeCopyPool (\r
92 sizeof (mFirmwareVendor),\r
93 &mFirmwareVendor\r
94 );\r
95 ASSERT (gST->FirmwareVendor != NULL);\r
96\r
97 gST->FirmwareRevision = 0;\r
98\r
99 //\r
100 // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
101 //\r
102 gBS->CalculateCrc32 ((VOID *) gST, sizeof (EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
103\r
fcf24bad 104 SetupVariableInit ();\r
5fd5fcd3 105}\r
106\r
107EFI_STATUS\r
108PlatformBdsConnectConsole (\r
109 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
110 )\r
111/*++\r
112\r
113Routine Description:\r
114\r
115 Connect the predefined platform default console device. Always try to find\r
116 and enable the vga device if have.\r
117\r
118Arguments:\r
119\r
120 PlatformConsole - Predfined platform default console device array.\r
121 \r
122Returns:\r
123\r
124 EFI_SUCCESS - Success connect at least one ConIn and ConOut \r
125 device, there must have one ConOut device is \r
126 active vga device.\r
127 \r
128 EFI_STATUS - Return the status of \r
129 BdsLibConnectAllDefaultConsoles ()\r
130\r
131--*/\r
132{\r
133 EFI_STATUS Status;\r
134 UINTN Index;\r
135\r
136 Index = 0;\r
137 Status = EFI_SUCCESS;\r
138\r
139 //\r
140 // Have chance to connect the platform default console,\r
141 // the platform default console is the minimue device group\r
142 // the platform should support\r
143 //\r
144 while (PlatformConsole[Index].DevicePath != NULL) {\r
145 //\r
146 // Update the console variable with the connect type\r
147 //\r
148 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
149 BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
150 }\r
151\r
152 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
153 BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
154 }\r
155\r
156 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
157 BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
158 }\r
159\r
160 Index++;\r
161 }\r
162 //\r
163 // Connect the all the default console with current cosole variable\r
164 //\r
165 Status = BdsLibConnectAllDefaultConsoles ();\r
166 \r
167 return Status;\r
168}\r
169\r
170VOID\r
171PlatformBdsConnectSequence (\r
172 VOID\r
173 )\r
174/*++\r
175\r
176Routine Description:\r
177\r
178 Connect with predeined platform connect sequence, \r
179 the OEM/IBV can customize with their own connect sequence.\r
180 \r
181Arguments:\r
182\r
183 None.\r
184 \r
185Returns:\r
186\r
187 None.\r
188 \r
189--*/\r
190{\r
191 UINTN Index;\r
192\r
193 Index = 0;\r
194\r
195 //\r
196 // Here we can get the customized platform connect sequence\r
197 // Notes: we can connect with new variable which record the\r
198 // last time boots connect device path sequence\r
199 //\r
200 while (gPlatformConnectSequence[Index] != NULL) {\r
201 //\r
202 // Build the platform boot option\r
203 //\r
204 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
205 Index++;\r
206 }\r
207\r
208 //\r
209 // Jst use the simple policy to connect all devices\r
210 //\r
211 BdsLibConnectAll ();\r
212}\r
213\r
214VOID\r
215PlatformBdsGetDriverOption (\r
216 IN OUT LIST_ENTRY *BdsDriverLists\r
217 )\r
218/*++\r
219\r
220Routine Description:\r
221\r
222 Load the predefined driver option, OEM/IBV can customize this\r
223 to load their own drivers\r
224 \r
225Arguments:\r
226\r
227 BdsDriverLists - The header of the driver option link list.\r
228 \r
229Returns:\r
230\r
231 None.\r
232 \r
233--*/\r
234{\r
235 UINTN Index;\r
236\r
237 Index = 0;\r
238\r
239 //\r
240 // Here we can get the customized platform driver option\r
241 //\r
242 while (gPlatformDriverOption[Index] != NULL) {\r
243 //\r
244 // Build the platform boot option\r
245 //\r
246 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
247 Index++;\r
248 }\r
249\r
250}\r
251\r
252VOID\r
253PlatformBdsDiagnostics (\r
254 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
255 IN BOOLEAN QuietBoot\r
256 )\r
257/*++\r
258\r
259Routine Description:\r
260\r
261 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
262 can customize this fuction to support specific platform diagnostic.\r
263 \r
264Arguments:\r
265\r
266 MemoryTestLevel - The memory test intensive level\r
267 \r
268 QuietBoot - Indicate if need to enable the quiet boot\r
269 \r
270Returns:\r
271\r
272 None.\r
273 \r
274--*/\r
275{\r
276 EFI_STATUS Status;\r
277\r
278 //\r
279 // Here we can decide if we need to show\r
280 // the diagnostics screen\r
281 // Notes: this quiet boot code should be remove\r
282 // from the graphic lib\r
283 //\r
284 if (QuietBoot) {\r
d46f3632 285 EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
5fd5fcd3 286 //\r
287 // Perform system diagnostic\r
288 //\r
289 Status = BdsMemoryTest (MemoryTestLevel);\r
290 if (EFI_ERROR (Status)) {\r
291 DisableQuietBoot ();\r
292 }\r
293\r
294 return ;\r
295 }\r
296 //\r
297 // Perform system diagnostic\r
298 //\r
299 Status = BdsMemoryTest (MemoryTestLevel);\r
300}\r
301\r
302VOID\r
d5275ee6 303EFIAPI\r
5fd5fcd3 304PlatformBdsPolicyBehavior (\r
5fd5fcd3 305 IN OUT LIST_ENTRY *DriverOptionList,\r
306 IN OUT LIST_ENTRY *BootOptionList\r
307 )\r
308/*++\r
309\r
310Routine Description:\r
311\r
312 The function will excute with as the platform policy, current policy\r
313 is driven by boot mode. IBV/OEM can customize this code for their specific\r
314 policy action.\r
315 \r
316Arguments:\r
317\r
5fd5fcd3 318 DriverOptionList - The header of the driver option link list\r
319 \r
320 BootOptionList - The header of the boot option link list\r
321 \r
322Returns:\r
323\r
324 None.\r
325 \r
326--*/\r
327{\r
d5275ee6 328 EFI_STATUS Status;\r
329 UINT16 Timeout;\r
330 EFI_BOOT_MODE BootMode;\r
5fd5fcd3 331\r
332 //\r
333 // Init the time out value\r
334 //\r
21e97c72 335 Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
5fd5fcd3 336\r
337 //\r
338 // Load the driver option as the driver option list\r
339 //\r
340 PlatformBdsGetDriverOption (DriverOptionList);\r
341\r
342 //\r
343 // Get current Boot Mode\r
344 //\r
d5275ee6 345 Status = BdsLibGetBootMode (&BootMode);\r
5fd5fcd3 346\r
347 //\r
348 // Go the different platform policy with different boot mode\r
349 // Notes: this part code can be change with the table policy\r
350 //\r
d5275ee6 351 switch (BootMode) {\r
5fd5fcd3 352\r
353 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
354 case BOOT_WITH_MINIMAL_CONFIGURATION:\r
355 //\r
356 // In no-configuration boot mode, we can connect the\r
357 // console directly.\r
358 //\r
359 BdsLibConnectAllDefaultConsoles ();\r
0b94e319 360 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);\r
5fd5fcd3 361\r
362 //\r
363 // Perform some platform specific connect sequence\r
364 //\r
365 PlatformBdsConnectSequence ();\r
366\r
367 //\r
368 // Notes: current time out = 0 can not enter the\r
369 // front page\r
370 //\r
371 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
372\r
373 //\r
374 // Check the boot option with the boot option list\r
375 //\r
376 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
377 break;\r
378\r
379 case BOOT_ON_FLASH_UPDATE:\r
380 //\r
381 // Boot with the specific configuration\r
382 //\r
383 PlatformBdsConnectConsole (gPlatformConsole);\r
384 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
385 BdsLibConnectAll ();\r
386 ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
387 break;\r
388\r
389 case BOOT_IN_RECOVERY_MODE:\r
390 //\r
391 // In recovery mode, just connect platform console\r
392 // and show up the front page\r
393 //\r
394 PlatformBdsConnectConsole (gPlatformConsole);\r
395 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
396\r
397 //\r
398 // In recovery boot mode, we still enter to the\r
399 // frong page now\r
400 //\r
401 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
402 break;\r
403\r
404 case BOOT_WITH_FULL_CONFIGURATION:\r
405 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
406 case BOOT_WITH_DEFAULT_SETTINGS:\r
407 default:\r
408 //\r
409 // Connect platform console\r
410 //\r
411 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
412 if (EFI_ERROR (Status)) {\r
413 //\r
414 // Here OEM/IBV can customize with defined action\r
415 //\r
416 PlatformBdsNoConsoleAction ();\r
417 }\r
418\r
0b94e319 419 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);\r
5fd5fcd3 420\r
421 //\r
422 // Perform some platform specific connect sequence\r
423 //\r
424 PlatformBdsConnectSequence ();\r
425\r
426 //\r
427 // Give one chance to enter the setup if we\r
428 // have the time out\r
429 //\r
430 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
431\r
432 //\r
433 // Here we have enough time to do the enumeration of boot device\r
434 //\r
435 BdsLibEnumerateAllBootOption (BootOptionList);\r
436 break;\r
437 }\r
438\r
439 return ;\r
440\r
441}\r
442\r
443VOID\r
d5275ee6 444EFIAPI\r
5fd5fcd3 445PlatformBdsBootSuccess (\r
446 IN BDS_COMMON_OPTION *Option\r
447 )\r
448/*++\r
449\r
450Routine Description:\r
451 \r
452 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
453 return, so the EFI 1.0 specification defines that you will default to an\r
454 interactive mode and stop processing the BootOrder list in this case. This\r
455 is alos a platform implementation and can be customized by IBV/OEM.\r
456\r
457Arguments:\r
458\r
459 Option - Pointer to Boot Option that succeeded to boot.\r
460\r
461Returns:\r
462 \r
463 None.\r
464\r
465--*/\r
466{\r
467 CHAR16 *TmpStr;\r
468\r
469 //\r
470 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
471 // select loop then we need to pop up a UI and wait for user input.\r
472 //\r
473 TmpStr = Option->StatusString;\r
474 if (TmpStr != NULL) {\r
475 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
476 FreePool (TmpStr);\r
477 }\r
478}\r
479\r
480VOID\r
d5275ee6 481EFIAPI\r
5fd5fcd3 482PlatformBdsBootFail (\r
483 IN BDS_COMMON_OPTION *Option,\r
484 IN EFI_STATUS Status,\r
485 IN CHAR16 *ExitData,\r
486 IN UINTN ExitDataSize\r
487 )\r
488/*++\r
489\r
490Routine Description:\r
491 \r
492 Hook point after a boot attempt fails.\r
493\r
494Arguments:\r
495 \r
496 Option - Pointer to Boot Option that failed to boot.\r
497\r
498 Status - Status returned from failed boot.\r
499\r
500 ExitData - Exit data returned from failed boot.\r
501\r
502 ExitDataSize - Exit data size returned from failed boot.\r
503\r
504Returns:\r
505 \r
506 None.\r
507\r
508--*/\r
509{\r
510 CHAR16 *TmpStr;\r
511\r
512 //\r
513 // If Boot returned with failed status then we need to pop up a UI and wait\r
514 // for user input.\r
515 //\r
516 TmpStr = Option->StatusString;\r
517 if (TmpStr != NULL) {\r
518 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
519 FreePool (TmpStr);\r
520 }\r
521\r
522}\r
523\r
524EFI_STATUS\r
525PlatformBdsNoConsoleAction (\r
526 VOID\r
527 )\r
528/*++\r
529\r
530Routine Description:\r
531 \r
532 This function is remained for IBV/OEM to do some platform action,\r
533 if there no console device can be connected.\r
534\r
535Arguments:\r
536 \r
537 None.\r
538 \r
539Returns:\r
540 \r
541 EFI_SUCCESS - Direct return success now.\r
542\r
543--*/\r
544{\r
545 return EFI_SUCCESS;\r
546}\r
547\r
548EFI_STATUS\r
549EFIAPI\r
550PlatformBdsLockNonUpdatableFlash (\r
551 VOID\r
552 )\r
553{\r
554 return EFI_SUCCESS;\r
555}\r