]>
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 | |
69 | PlatformBdsInit (\r | |
70 | IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData\r | |
71 | )\r | |
72 | /*++\r | |
73 | \r | |
74 | Routine Description:\r | |
75 | \r | |
c71b6597 | 76 | Platform Bds init. Include the platform firmware vendor, revision\r |
804405e7 | 77 | and so crc check.\r |
78 | \r | |
79 | Arguments:\r | |
80 | \r | |
81 | PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r | |
82 | \r | |
83 | Returns:\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 | |
b672348f | 105 | SetupVariableInit ();\r |
804405e7 | 106 | }\r |
107 | \r | |
108 | EFI_STATUS\r | |
109 | PlatformBdsConnectConsole (\r | |
110 | IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r | |
111 | )\r | |
112 | /*++\r | |
113 | \r | |
114 | Routine 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 | |
119 | Arguments:\r | |
120 | \r | |
121 | PlatformConsole - Predfined platform default console device array.\r | |
122 | \r | |
123 | Returns:\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 | return Status;\r | |
168 | }\r | |
169 | \r | |
170 | VOID\r | |
171 | PlatformBdsConnectSequence (\r | |
172 | VOID\r | |
173 | )\r | |
174 | /*++\r | |
175 | \r | |
176 | Routine 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 | |
181 | Arguments:\r | |
182 | \r | |
183 | None.\r | |
184 | \r | |
185 | Returns:\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 | // Just use the simple policy to connect all devices\r | |
210 | //\r | |
211 | BdsLibConnectAll ();\r | |
212 | }\r | |
213 | \r | |
214 | VOID\r | |
215 | PlatformBdsGetDriverOption (\r | |
216 | IN OUT LIST_ENTRY *BdsDriverLists\r | |
217 | )\r | |
218 | /*++\r | |
219 | \r | |
220 | Routine 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 | |
225 | Arguments:\r | |
226 | \r | |
227 | BdsDriverLists - The header of the driver option link list.\r | |
228 | \r | |
229 | Returns:\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 | |
252 | VOID\r | |
253 | PlatformBdsDiagnostics (\r | |
254 | IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r | |
255 | IN BOOLEAN QuietBoot\r | |
256 | )\r | |
257 | /*++\r | |
258 | \r | |
259 | Routine 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 | |
264 | Arguments:\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 | |
270 | Returns:\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 | |
b5a1d1d9 | 285 | EnableQuietBoot (&gEfiDefaultBmpLogoGuid);\r |
804405e7 | 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 | |
302 | VOID\r | |
303 | PlatformBdsPolicyBehavior (\r | |
304 | IN EFI_BDS_ARCH_PROTOCOL_INSTANCE *PrivateData,\r | |
305 | IN OUT LIST_ENTRY *DriverOptionList,\r | |
306 | IN OUT LIST_ENTRY *BootOptionList\r | |
307 | )\r | |
308 | /*++\r | |
309 | \r | |
310 | Routine 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 | |
316 | Arguments:\r | |
317 | \r | |
318 | PrivateData - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r | |
319 | \r | |
320 | DriverOptionList - The header of the driver option link list\r | |
321 | \r | |
322 | BootOptionList - The header of the boot option link list\r | |
323 | \r | |
324 | Returns:\r | |
325 | \r | |
326 | None.\r | |
327 | \r | |
328 | --*/\r | |
329 | {\r | |
330 | EFI_STATUS Status;\r | |
331 | UINT16 Timeout;\r | |
332 | \r | |
333 | //\r | |
334 | // Init the time out value\r | |
335 | //\r | |
12a738ed | 336 | Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r |
804405e7 | 337 | \r |
338 | //\r | |
339 | // Load the driver option as the driver option list\r | |
340 | //\r | |
341 | PlatformBdsGetDriverOption (DriverOptionList);\r | |
342 | \r | |
343 | //\r | |
344 | // Get current Boot Mode\r | |
345 | //\r | |
346 | Status = BdsLibGetBootMode (&PrivateData->BootMode);\r | |
347 | \r | |
348 | //\r | |
349 | // Go the different platform policy with different boot mode\r | |
350 | // Notes: this part code can be change with the table policy\r | |
351 | //\r | |
352 | switch (PrivateData->BootMode) {\r | |
353 | \r | |
354 | case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:\r | |
355 | case BOOT_WITH_MINIMAL_CONFIGURATION:\r | |
356 | //\r | |
357 | // In no-configuration boot mode, we can connect the\r | |
358 | // console directly.\r | |
359 | //\r | |
360 | BdsLibConnectAllDefaultConsoles ();\r | |
361 | PlatformBdsDiagnostics (IGNORE, TRUE);\r | |
362 | \r | |
363 | //\r | |
364 | // Perform some platform specific connect sequence\r | |
365 | //\r | |
366 | PlatformBdsConnectSequence ();\r | |
367 | \r | |
368 | //\r | |
369 | // Notes: current time out = 0 can not enter the\r | |
370 | // front page\r | |
371 | //\r | |
372 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
373 | \r | |
374 | //\r | |
375 | // Check the boot option with the boot option list\r | |
376 | //\r | |
377 | BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r | |
378 | break;\r | |
379 | \r | |
380 | case BOOT_ON_FLASH_UPDATE:\r | |
381 | //\r | |
382 | // Boot with the specific configuration\r | |
383 | //\r | |
384 | PlatformBdsConnectConsole (gPlatformConsole);\r | |
385 | PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r | |
386 | BdsLibConnectAll ();\r | |
387 | ProcessCapsules (BOOT_ON_FLASH_UPDATE);\r | |
388 | break;\r | |
389 | \r | |
390 | case BOOT_IN_RECOVERY_MODE:\r | |
391 | //\r | |
392 | // In recovery mode, just connect platform console\r | |
393 | // and show up the front page\r | |
394 | //\r | |
395 | PlatformBdsConnectConsole (gPlatformConsole);\r | |
396 | PlatformBdsDiagnostics (EXTENSIVE, FALSE);\r | |
397 | \r | |
398 | //\r | |
399 | // In recovery boot mode, we still enter to the\r | |
400 | // frong page now\r | |
401 | //\r | |
402 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
403 | break;\r | |
404 | \r | |
405 | case BOOT_WITH_FULL_CONFIGURATION:\r | |
406 | case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:\r | |
407 | case BOOT_WITH_DEFAULT_SETTINGS:\r | |
408 | default:\r | |
409 | //\r | |
410 | // Connect platform console\r | |
411 | //\r | |
412 | Status = PlatformBdsConnectConsole (gPlatformConsole);\r | |
413 | if (EFI_ERROR (Status)) {\r | |
414 | //\r | |
415 | // Here OEM/IBV can customize with defined action\r | |
416 | //\r | |
417 | PlatformBdsNoConsoleAction ();\r | |
418 | }\r | |
419 | \r | |
420 | PlatformBdsDiagnostics (IGNORE, TRUE);\r | |
421 | \r | |
422 | //\r | |
423 | // Perform some platform specific connect sequence\r | |
424 | //\r | |
425 | PlatformBdsConnectSequence ();\r | |
426 | \r | |
427 | //\r | |
428 | // Give one chance to enter the setup if we\r | |
429 | // have the time out\r | |
430 | //\r | |
431 | PlatformBdsEnterFrontPage (Timeout, FALSE);\r | |
432 | \r | |
433 | //\r | |
434 | // Here we have enough time to do the enumeration of boot device\r | |
435 | //\r | |
436 | BdsLibEnumerateAllBootOption (BootOptionList);\r | |
437 | break;\r | |
438 | }\r | |
439 | \r | |
440 | return ;\r | |
441 | \r | |
442 | }\r | |
443 | \r | |
444 | VOID\r | |
445 | PlatformBdsBootSuccess (\r | |
446 | IN BDS_COMMON_OPTION *Option\r | |
447 | )\r | |
448 | /*++\r | |
449 | \r | |
450 | Routine 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 | |
457 | Arguments:\r | |
458 | \r | |
459 | Option - Pointer to Boot Option that succeeded to boot.\r | |
460 | \r | |
461 | Returns:\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 | |
480 | VOID\r | |
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 |