]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++\r |
2 | \r | |
b672348f | 3 | Copyright (c) 2006 - 2009, Intel Corporation \r |
804405e7 | 4 | All rights reserved. This program and the accompanying materials \r |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | BdsPlatform.c\r | |
15 | \r | |
16 | Abstract:\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 | |
25 | CHAR16 mFirmwareVendor[] = L"TianoCore.org";\r | |
c71b6597 | 26 | UNIX_SYSTEM_CONFIGURATION mSystemConfigData;\r |
27 | \r | |
28 | VOID\r | |
29 | SetupVariableInit (\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 | &gEfiUnixSystemConfigGuid,\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 | &gEfiUnixSystemConfigGuid,\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 | |
804405e7 | 64 | \r |
65 | //\r | |
66 | // BDS Platform Functions\r | |
67 | //\r | |
68 | VOID\r | |
84478ded | 69 | EFIAPI\r |
804405e7 | 70 | PlatformBdsInit (\r |
84478ded | 71 | VOID\r |
804405e7 | 72 | )\r |
73 | /*++\r | |
74 | \r | |
75 | Routine Description:\r | |
76 | \r | |
c71b6597 | 77 | Platform Bds init. Include the platform firmware vendor, revision\r |
804405e7 | 78 | and so crc check.\r |
79 | \r | |
80 | Arguments:\r | |
81 | \r | |
804405e7 | 82 | Returns:\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 | |
b672348f | 104 | SetupVariableInit ();\r |
804405e7 | 105 | }\r |
106 | \r | |
107 | EFI_STATUS\r | |
108 | PlatformBdsConnectConsole (\r | |
109 | IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r | |
110 | )\r | |
111 | /*++\r | |
112 | \r | |
113 | Routine 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 | |
118 | Arguments:\r | |
119 | \r | |
120 | PlatformConsole - Predfined platform default console device array.\r | |
121 | \r | |
122 | Returns:\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 | return Status;\r | |
167 | }\r | |
168 | \r | |
169 | VOID\r | |
170 | PlatformBdsConnectSequence (\r | |
171 | VOID\r | |
172 | )\r | |
173 | /*++\r | |
174 | \r | |
175 | Routine Description:\r | |
176 | \r | |
177 | Connect with predeined platform connect sequence, \r | |
178 | the OEM/IBV can customize with their own connect sequence.\r | |
179 | \r | |
180 | Arguments:\r | |
181 | \r | |
182 | None.\r | |
183 | \r | |
184 | Returns:\r | |
185 | \r | |
186 | None.\r | |
187 | \r | |
188 | --*/\r | |
189 | {\r | |
190 | UINTN Index;\r | |
191 | \r | |
192 | Index = 0;\r | |
193 | \r | |
194 | //\r | |
195 | // Here we can get the customized platform connect sequence\r | |
196 | // Notes: we can connect with new variable which record the\r | |
197 | // last time boots connect device path sequence\r | |
198 | //\r | |
199 | while (gPlatformConnectSequence[Index] != NULL) {\r | |
200 | //\r | |
201 | // Build the platform boot option\r | |
202 | //\r | |
203 | BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r | |
204 | Index++;\r | |
205 | }\r | |
206 | \r | |
207 | //\r | |
208 | // Just use the simple policy to connect all devices\r | |
209 | //\r | |
210 | BdsLibConnectAll ();\r | |
211 | }\r | |
212 | \r | |
213 | VOID\r | |
214 | PlatformBdsGetDriverOption (\r | |
215 | IN OUT LIST_ENTRY *BdsDriverLists\r | |
216 | )\r | |
217 | /*++\r | |
218 | \r | |
219 | Routine Description:\r | |
220 | \r | |
221 | Load the predefined driver option, OEM/IBV can customize this\r | |
222 | to load their own drivers\r | |
223 | \r | |
224 | Arguments:\r | |
225 | \r | |
226 | BdsDriverLists - The header of the driver option link list.\r | |
227 | \r | |
228 | Returns:\r | |
229 | \r | |
230 | None.\r | |
231 | \r | |
232 | --*/\r | |
233 | {\r | |
234 | UINTN Index;\r | |
235 | \r | |
236 | Index = 0;\r | |
237 | \r | |
238 | //\r | |
239 | // Here we can get the customized platform driver option\r | |
240 | //\r | |
241 | while (gPlatformDriverOption[Index] != NULL) {\r | |
242 | //\r | |
243 | // Build the platform boot option\r | |
244 | //\r | |
245 | BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r | |
246 | Index++;\r | |
247 | }\r | |
248 | \r | |
249 | }\r | |
250 | \r | |
251 | VOID\r | |
252 | PlatformBdsDiagnostics (\r | |
253 | IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r | |
254 | IN BOOLEAN QuietBoot\r | |
255 | )\r | |
256 | /*++\r | |
257 | \r | |
258 | Routine Description:\r | |
259 | \r | |
260 | Perform the platform diagnostic, such like test memory. OEM/IBV also\r | |
261 | can customize this fuction to support specific platform diagnostic.\r | |
262 | \r | |
263 | Arguments:\r | |
264 | \r | |
265 | MemoryTestLevel - The memory test intensive level\r | |
266 | \r | |
267 | QuietBoot - Indicate if need to enable the quiet boot\r | |
268 | \r | |
269 | Returns:\r | |
270 | \r | |
271 | None.\r | |
272 | \r | |
273 | --*/\r | |
274 | {\r | |
275 | EFI_STATUS Status;\r | |
276 | \r | |
277 | //\r | |
278 | // Here we can decide if we need to show\r | |
279 | // the diagnostics screen\r | |
280 | // Notes: this quiet boot code should be remove\r | |
281 | // from the graphic lib\r | |
282 | //\r | |
283 | if (QuietBoot) {\r | |
d46f3632 | 284 | EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r |
804405e7 | 285 | //\r |
286 | // Perform system diagnostic\r | |
287 | //\r | |
288 | Status = BdsMemoryTest (MemoryTestLevel);\r | |
289 | if (EFI_ERROR (Status)) {\r | |
290 | DisableQuietBoot ();\r | |
291 | }\r | |
292 | \r | |
293 | return ;\r | |
294 | }\r | |
295 | //\r | |
296 | // Perform system diagnostic\r | |
297 | //\r | |
298 | Status = BdsMemoryTest (MemoryTestLevel);\r | |
299 | }\r | |
300 | \r | |
301 | VOID\r | |
84478ded | 302 | EFIAPI\r |
804405e7 | 303 | PlatformBdsPolicyBehavior (\r |
804405e7 | 304 | IN OUT LIST_ENTRY *DriverOptionList,\r |
305 | IN OUT LIST_ENTRY *BootOptionList\r | |
306 | )\r | |
307 | /*++\r | |
308 | \r | |
309 | Routine Description:\r | |
310 | \r | |
311 | The function will excute with as the platform policy, current policy\r | |
312 | is driven by boot mode. IBV/OEM can customize this code for their specific\r | |
313 | policy action.\r | |
314 | \r | |
315 | Arguments:\r | |
316 | \r | |
804405e7 | 317 | DriverOptionList - The header of the driver option link list\r |
318 | \r | |
319 | BootOptionList - The header of the boot option link list\r | |
320 | \r | |
321 | Returns:\r | |
322 | \r | |
323 | None.\r | |
324 | \r | |
325 | --*/\r | |
326 | {\r | |
84478ded | 327 | EFI_STATUS Status;\r |
328 | UINT16 Timeout;\r | |
329 | EFI_BOOT_MODE BootMode;\r | |
804405e7 | 330 | \r |
331 | //\r | |
332 | // Init the time out value\r | |
333 | //\r | |
12a738ed | 334 | Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r |
804405e7 | 335 | \r |
336 | //\r | |
337 | // Load the driver option as the driver option list\r | |
338 | //\r | |
339 | PlatformBdsGetDriverOption (DriverOptionList);\r | |
340 | \r | |
341 | //\r | |
342 | // Get current Boot Mode\r | |
343 | //\r | |
84478ded | 344 | Status = BdsLibGetBootMode (&BootMode);\r |
804405e7 | 345 | \r |
346 | //\r | |
347 | // Go the different platform policy with different boot mode\r | |
348 | // Notes: this part code can be change with the table policy\r | |
349 | //\r | |
84478ded | 350 | switch (BootMode) {\r |
804405e7 | 351 | \r |
352 | case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r | |
353 | case BOOT_WITH_MINIMAL_CONFIGURATION:\r | |
354 | //\r | |
355 | // In no-configuration boot mode, we can connect the\r | |
356 | // console directly.\r | |
357 | //\r | |
358 | BdsLibConnectAllDefaultConsoles ();\r | |
359 | PlatformBdsDiagnostics (IGNORE, TRUE);\r | |
360 | \r | |
361 | //\r | |
362 | // Perform some platform specific connect sequence\r | |
363 | //\r | |
364 | PlatformBdsConnectSequence ();\r | |
365 | \r | |
366 | //\r | |
367 | // Notes: current time out = 0 can not enter the\r | |
368 | // front page\r | |
369 | //\r | |
370 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
371 | \r | |
372 | //\r | |
373 | // Check the boot option with the boot option list\r | |
374 | //\r | |
375 | BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r | |
376 | break;\r | |
377 | \r | |
378 | case BOOT_ON_FLASH_UPDATE:\r | |
379 | //\r | |
380 | // Boot with the specific configuration\r | |
381 | //\r | |
382 | PlatformBdsConnectConsole (gPlatformConsole);\r | |
383 | PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r | |
384 | BdsLibConnectAll ();\r | |
385 | ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r | |
386 | break;\r | |
387 | \r | |
388 | case BOOT_IN_RECOVERY_MODE:\r | |
389 | //\r | |
390 | // In recovery mode, just connect platform console\r | |
391 | // and show up the front page\r | |
392 | //\r | |
393 | PlatformBdsConnectConsole (gPlatformConsole);\r | |
394 | PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r | |
395 | \r | |
396 | //\r | |
397 | // In recovery boot mode, we still enter to the\r | |
398 | // frong page now\r | |
399 | //\r | |
400 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
401 | break;\r | |
402 | \r | |
403 | case BOOT_WITH_FULL_CONFIGURATION:\r | |
404 | case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r | |
405 | case BOOT_WITH_DEFAULT_SETTINGS:\r | |
406 | default:\r | |
407 | //\r | |
408 | // Connect platform console\r | |
409 | //\r | |
410 | Status = PlatformBdsConnectConsole (gPlatformConsole);\r | |
411 | if (EFI_ERROR (Status)) {\r | |
412 | //\r | |
413 | // Here OEM/IBV can customize with defined action\r | |
414 | //\r | |
415 | PlatformBdsNoConsoleAction ();\r | |
416 | }\r | |
417 | \r | |
418 | PlatformBdsDiagnostics (IGNORE, TRUE);\r | |
419 | \r | |
420 | //\r | |
421 | // Perform some platform specific connect sequence\r | |
422 | //\r | |
423 | PlatformBdsConnectSequence ();\r | |
424 | \r | |
425 | //\r | |
426 | // Give one chance to enter the setup if we\r | |
427 | // have the time out\r | |
428 | //\r | |
429 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
430 | \r | |
431 | //\r | |
432 | // Here we have enough time to do the enumeration of boot device\r | |
433 | //\r | |
434 | BdsLibEnumerateAllBootOption (BootOptionList);\r | |
435 | break;\r | |
436 | }\r | |
437 | \r | |
438 | return ;\r | |
439 | \r | |
440 | }\r | |
441 | \r | |
442 | VOID\r | |
84478ded | 443 | EFIAPI\r |
804405e7 | 444 | PlatformBdsBootSuccess (\r |
445 | IN BDS_COMMON_OPTION *Option\r | |
446 | )\r | |
447 | /*++\r | |
448 | \r | |
449 | Routine Description:\r | |
450 | \r | |
451 | Hook point after a boot attempt succeeds. We don't expect a boot option to\r | |
452 | return, so the EFI 1.0 specification defines that you will default to an\r | |
453 | interactive mode and stop processing the BootOrder list in this case. This\r | |
454 | is alos a platform implementation and can be customized by IBV/OEM.\r | |
455 | \r | |
456 | Arguments:\r | |
457 | \r | |
458 | Option - Pointer to Boot Option that succeeded to boot.\r | |
459 | \r | |
460 | Returns:\r | |
461 | \r | |
462 | None.\r | |
463 | \r | |
464 | --*/\r | |
465 | {\r | |
466 | CHAR16 *TmpStr;\r | |
467 | \r | |
468 | //\r | |
469 | // If Boot returned with EFI_SUCCESS and there is not in the boot device\r | |
470 | // select loop then we need to pop up a UI and wait for user input.\r | |
471 | //\r | |
472 | TmpStr = Option->StatusString;\r | |
473 | if (TmpStr != NULL) {\r | |
474 | BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r | |
475 | FreePool (TmpStr);\r | |
476 | }\r | |
477 | }\r | |
478 | \r | |
479 | VOID\r | |
84478ded | 480 | EFIAPI\r |
804405e7 | 481 | PlatformBdsBootFail (\r |
482 | IN BDS_COMMON_OPTION *Option,\r | |
483 | IN EFI_STATUS Status,\r | |
484 | IN CHAR16 *ExitData,\r | |
485 | IN UINTN ExitDataSize\r | |
486 | )\r | |
487 | /*++\r | |
488 | \r | |
489 | Routine Description:\r | |
490 | \r | |
491 | Hook point after a boot attempt fails.\r | |
492 | \r | |
493 | Arguments:\r | |
494 | \r | |
495 | Option - Pointer to Boot Option that failed to boot.\r | |
496 | \r | |
497 | Status - Status returned from failed boot.\r | |
498 | \r | |
499 | ExitData - Exit data returned from failed boot.\r | |
500 | \r | |
501 | ExitDataSize - Exit data size returned from failed boot.\r | |
502 | \r | |
503 | Returns:\r | |
504 | \r | |
505 | None.\r | |
506 | \r | |
507 | --*/\r | |
508 | {\r | |
509 | CHAR16 *TmpStr;\r | |
510 | \r | |
511 | //\r | |
512 | // If Boot returned with failed status then we need to pop up a UI and wait\r | |
513 | // for user input.\r | |
514 | //\r | |
515 | TmpStr = Option->StatusString;\r | |
516 | if (TmpStr != NULL) {\r | |
517 | BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r | |
518 | FreePool (TmpStr);\r | |
519 | }\r | |
520 | }\r | |
521 | \r | |
522 | EFI_STATUS\r | |
523 | PlatformBdsNoConsoleAction (\r | |
524 | VOID\r | |
525 | )\r | |
526 | /*++\r | |
527 | \r | |
528 | Routine Description:\r | |
529 | \r | |
530 | This function is remained for IBV/OEM to do some platform action,\r | |
531 | if there no console device can be connected.\r | |
532 | \r | |
533 | Arguments:\r | |
534 | \r | |
535 | None.\r | |
536 | \r | |
537 | Returns:\r | |
538 | \r | |
539 | EFI_SUCCESS - Direct return success now.\r | |
540 | \r | |
541 | --*/\r | |
542 | {\r | |
543 | return EFI_SUCCESS;\r | |
544 | }\r | |
545 | \r | |
546 | EFI_STATUS\r | |
547 | EFIAPI\r | |
548 | PlatformBdsLockNonUpdatableFlash (\r | |
549 | VOID\r | |
550 | )\r | |
551 | {\r | |
552 | return EFI_SUCCESS;\r | |
553 | }\r |