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