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