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