]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/Library/Nt32BdsLib/BdsPlatform.c
Update Nt32 platform to use dynamic HII pcd to save console output mode.
[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
69PlatformBdsInit (\r
70 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData\r
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
81 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r
82\r
83Returns:\r
84\r
85 None.\r
86\r
87--*/\r
88{\r
89 //\r
90 // set firmwarevendor, here can be IBV/OEM customize\r
91 //\r
92 gST->FirmwareVendor = AllocateRuntimeCopyPool (\r
93 sizeof (mFirmwareVendor),\r
94 &mFirmwareVendor\r
95 );\r
96 ASSERT (gST->FirmwareVendor != NULL);\r
97\r
98 gST->FirmwareRevision = 0;\r
99\r
100 //\r
101 // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
102 //\r
103 gBS->CalculateCrc32 ((VOID *) gST, sizeof (EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
104\r
fcf24bad 105 SetupVariableInit ();\r
5fd5fcd3 106}\r
107\r
108EFI_STATUS\r
109PlatformBdsConnectConsole (\r
110 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
111 )\r
112/*++\r
113\r
114Routine Description:\r
115\r
116 Connect the predefined platform default console device. Always try to find\r
117 and enable the vga device if have.\r
118\r
119Arguments:\r
120\r
121 PlatformConsole - Predfined platform default console device array.\r
122 \r
123Returns:\r
124\r
125 EFI_SUCCESS - Success connect at least one ConIn and ConOut \r
126 device, there must have one ConOut device is \r
127 active vga device.\r
128 \r
129 EFI_STATUS - Return the status of \r
130 BdsLibConnectAllDefaultConsoles ()\r
131\r
132--*/\r
133{\r
134 EFI_STATUS Status;\r
135 UINTN Index;\r
136\r
137 Index = 0;\r
138 Status = EFI_SUCCESS;\r
139\r
140 //\r
141 // Have chance to connect the platform default console,\r
142 // the platform default console is the minimue device group\r
143 // the platform should support\r
144 //\r
145 while (PlatformConsole[Index].DevicePath != NULL) {\r
146 //\r
147 // Update the console variable with the connect type\r
148 //\r
149 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
150 BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);\r
151 }\r
152\r
153 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
154 BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);\r
155 }\r
156\r
157 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
158 BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);\r
159 }\r
160\r
161 Index++;\r
162 }\r
163 //\r
164 // Connect the all the default console with current cosole variable\r
165 //\r
166 Status = BdsLibConnectAllDefaultConsoles ();\r
167 \r
168 return Status;\r
169}\r
170\r
171VOID\r
172PlatformBdsConnectSequence (\r
173 VOID\r
174 )\r
175/*++\r
176\r
177Routine Description:\r
178\r
179 Connect with predeined platform connect sequence, \r
180 the OEM/IBV can customize with their own connect sequence.\r
181 \r
182Arguments:\r
183\r
184 None.\r
185 \r
186Returns:\r
187\r
188 None.\r
189 \r
190--*/\r
191{\r
192 UINTN Index;\r
193\r
194 Index = 0;\r
195\r
196 //\r
197 // Here we can get the customized platform connect sequence\r
198 // Notes: we can connect with new variable which record the\r
199 // last time boots connect device path sequence\r
200 //\r
201 while (gPlatformConnectSequence[Index] != NULL) {\r
202 //\r
203 // Build the platform boot option\r
204 //\r
205 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
206 Index++;\r
207 }\r
208\r
209 //\r
210 // Jst use the simple policy to connect all devices\r
211 //\r
212 BdsLibConnectAll ();\r
213}\r
214\r
215VOID\r
216PlatformBdsGetDriverOption (\r
217 IN OUT LIST_ENTRY *BdsDriverLists\r
218 )\r
219/*++\r
220\r
221Routine Description:\r
222\r
223 Load the predefined driver option, OEM/IBV can customize this\r
224 to load their own drivers\r
225 \r
226Arguments:\r
227\r
228 BdsDriverLists - The header of the driver option link list.\r
229 \r
230Returns:\r
231\r
232 None.\r
233 \r
234--*/\r
235{\r
236 UINTN Index;\r
237\r
238 Index = 0;\r
239\r
240 //\r
241 // Here we can get the customized platform driver option\r
242 //\r
243 while (gPlatformDriverOption[Index] != NULL) {\r
244 //\r
245 // Build the platform boot option\r
246 //\r
247 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
248 Index++;\r
249 }\r
250\r
251}\r
252\r
253VOID\r
254PlatformBdsDiagnostics (\r
255 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
256 IN BOOLEAN QuietBoot\r
257 )\r
258/*++\r
259\r
260Routine Description:\r
261\r
262 Perform the platform diagnostic, such like test memory. OEM/IBV also\r
263 can customize this fuction to support specific platform diagnostic.\r
264 \r
265Arguments:\r
266\r
267 MemoryTestLevel - The memory test intensive level\r
268 \r
269 QuietBoot - Indicate if need to enable the quiet boot\r
270 \r
271Returns:\r
272\r
273 None.\r
274 \r
275--*/\r
276{\r
277 EFI_STATUS Status;\r
278\r
279 //\r
280 // Here we can decide if we need to show\r
281 // the diagnostics screen\r
282 // Notes: this quiet boot code should be remove\r
283 // from the graphic lib\r
284 //\r
285 if (QuietBoot) {\r
519f076a 286 EnableQuietBoot (&gEfiDefaultBmpLogoGuid);\r
5fd5fcd3 287 //\r
288 // Perform system diagnostic\r
289 //\r
290 Status = BdsMemoryTest (MemoryTestLevel);\r
291 if (EFI_ERROR (Status)) {\r
292 DisableQuietBoot ();\r
293 }\r
294\r
295 return ;\r
296 }\r
297 //\r
298 // Perform system diagnostic\r
299 //\r
300 Status = BdsMemoryTest (MemoryTestLevel);\r
301}\r
302\r
303VOID\r
304PlatformBdsPolicyBehavior (\r
305 IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData,\r
306 IN OUT LIST_ENTRY *DriverOptionList,\r
307 IN OUT LIST_ENTRY *BootOptionList\r
308 )\r
309/*++\r
310\r
311Routine Description:\r
312\r
313 The function will excute with as the platform policy, current policy\r
314 is driven by boot mode. IBV/OEM can customize this code for their specific\r
315 policy action.\r
316 \r
317Arguments:\r
318\r
319 PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r
320 \r
321 DriverOptionList - The header of the driver option link list\r
322 \r
323 BootOptionList - The header of the boot option link list\r
324 \r
325Returns:\r
326\r
327 None.\r
328 \r
329--*/\r
330{\r
331 EFI_STATUS Status;\r
332 UINT16 Timeout;\r
333\r
334 //\r
335 // Init the time out value\r
336 //\r
337 Timeout = BdsLibGetTimeout ();\r
338\r
339 //\r
340 // Load the driver option as the driver option list\r
341 //\r
342 PlatformBdsGetDriverOption (DriverOptionList);\r
343\r
344 //\r
345 // Get current Boot Mode\r
346 //\r
347 Status = BdsLibGetBootMode (&PrivateData->BootMode);\r
348\r
349 //\r
350 // Go the different platform policy with different boot mode\r
351 // Notes: this part code can be change with the table policy\r
352 //\r
353 switch (PrivateData->BootMode) {\r
354\r
355 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r
356 case BOOT_WITH_MINIMAL_CONFIGURATION:\r
357 //\r
358 // In no-configuration boot mode, we can connect the\r
359 // console directly.\r
360 //\r
361 BdsLibConnectAllDefaultConsoles ();\r
0b94e319 362 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);\r
5fd5fcd3 363\r
364 //\r
365 // Perform some platform specific connect sequence\r
366 //\r
367 PlatformBdsConnectSequence ();\r
368\r
369 //\r
370 // Notes: current time out = 0 can not enter the\r
371 // front page\r
372 //\r
373 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
374\r
375 //\r
376 // Check the boot option with the boot option list\r
377 //\r
378 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
379 break;\r
380\r
381 case BOOT_ON_FLASH_UPDATE:\r
382 //\r
383 // Boot with the specific configuration\r
384 //\r
385 PlatformBdsConnectConsole (gPlatformConsole);\r
386 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
387 BdsLibConnectAll ();\r
388 ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r
389 break;\r
390\r
391 case BOOT_IN_RECOVERY_MODE:\r
392 //\r
393 // In recovery mode, just connect platform console\r
394 // and show up the front page\r
395 //\r
396 PlatformBdsConnectConsole (gPlatformConsole);\r
397 PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r
398\r
399 //\r
400 // In recovery boot mode, we still enter to the\r
401 // frong page now\r
402 //\r
403 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
404 break;\r
405\r
406 case BOOT_WITH_FULL_CONFIGURATION:\r
407 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r
408 case BOOT_WITH_DEFAULT_SETTINGS:\r
409 default:\r
410 //\r
411 // Connect platform console\r
412 //\r
413 Status = PlatformBdsConnectConsole (gPlatformConsole);\r
414 if (EFI_ERROR (Status)) {\r
415 //\r
416 // Here OEM/IBV can customize with defined action\r
417 //\r
418 PlatformBdsNoConsoleAction ();\r
419 }\r
420\r
0b94e319 421 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);\r
5fd5fcd3 422\r
423 //\r
424 // Perform some platform specific connect sequence\r
425 //\r
426 PlatformBdsConnectSequence ();\r
427\r
428 //\r
429 // Give one chance to enter the setup if we\r
430 // have the time out\r
431 //\r
432 PlatformBdsEnterFrontPage (Timeout, FALSE);\r
433\r
434 //\r
435 // Here we have enough time to do the enumeration of boot device\r
436 //\r
437 BdsLibEnumerateAllBootOption (BootOptionList);\r
438 break;\r
439 }\r
440\r
441 return ;\r
442\r
443}\r
444\r
445VOID\r
446PlatformBdsBootSuccess (\r
447 IN BDS_COMMON_OPTION *Option\r
448 )\r
449/*++\r
450\r
451Routine Description:\r
452 \r
453 Hook point after a boot attempt succeeds. We don't expect a boot option to\r
454 return, so the EFI 1.0 specification defines that you will default to an\r
455 interactive mode and stop processing the BootOrder list in this case. This\r
456 is alos a platform implementation and can be customized by IBV/OEM.\r
457\r
458Arguments:\r
459\r
460 Option - Pointer to Boot Option that succeeded to boot.\r
461\r
462Returns:\r
463 \r
464 None.\r
465\r
466--*/\r
467{\r
468 CHAR16 *TmpStr;\r
469\r
470 //\r
471 // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
472 // select loop then we need to pop up a UI and wait for user input.\r
473 //\r
474 TmpStr = Option->StatusString;\r
475 if (TmpStr != NULL) {\r
476 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
477 FreePool (TmpStr);\r
478 }\r
479}\r
480\r
481VOID\r
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