]>
Commit | Line | Data |
---|---|---|
c9093a06 | 1 | /*++\r |
2 | \r | |
17fb73c8 | 3 | Copyright (c) 2006 - 2007, Intel Corporation \r |
c9093a06 | 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 | |
c9093a06 | 23 | #include "BdsPlatform.h"\r |
c9093a06 | 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 = EFI_FIRMWARE_REVISION;\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 | |
c9093a06 | 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 | if (EFI_ERROR (Status)) {\r | |
129 | return Status;\r | |
130 | }\r | |
131 | \r | |
132 | return EFI_SUCCESS;\r | |
133 | }\r | |
134 | \r | |
135 | VOID\r | |
136 | PlatformBdsConnectSequence (\r | |
137 | VOID\r | |
138 | )\r | |
139 | /*++\r | |
140 | \r | |
141 | Routine Description:\r | |
142 | \r | |
143 | Connect with predeined platform connect sequence, \r | |
144 | the OEM/IBV can customize with their own connect sequence.\r | |
145 | \r | |
146 | Arguments:\r | |
147 | \r | |
148 | None.\r | |
149 | \r | |
150 | Returns:\r | |
151 | \r | |
152 | None.\r | |
153 | \r | |
154 | --*/\r | |
155 | {\r | |
156 | UINTN Index;\r | |
157 | \r | |
158 | Index = 0;\r | |
159 | \r | |
160 | //\r | |
161 | // Here we can get the customized platform connect sequence\r | |
162 | // Notes: we can connect with new variable which record the\r | |
163 | // last time boots connect device path sequence\r | |
164 | //\r | |
165 | while (gPlatformConnectSequence[Index] != NULL) {\r | |
166 | //\r | |
167 | // Build the platform boot option\r | |
168 | //\r | |
169 | BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r | |
170 | Index++;\r | |
171 | }\r | |
172 | \r | |
173 | }\r | |
174 | \r | |
175 | VOID\r | |
176 | PlatformBdsGetDriverOption (\r | |
177 | IN OUT LIST_ENTRY *BdsDriverLists\r | |
178 | )\r | |
179 | /*++\r | |
180 | \r | |
181 | Routine 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 | |
186 | Arguments:\r | |
187 | \r | |
188 | BdsDriverLists - The header of the driver option link list.\r | |
189 | \r | |
190 | Returns:\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 | |
213 | VOID\r | |
214 | PlatformBdsDiagnostics (\r | |
215 | IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r | |
216 | IN BOOLEAN QuietBoot\r | |
217 | )\r | |
218 | /*++\r | |
219 | \r | |
220 | Routine 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 | |
225 | Arguments:\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 | |
231 | Returns:\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 | |
13de892c | 246 | EnableQuietBoot (&gEfiDefaultBmpLogoGuid);\r |
c9093a06 | 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 | |
263 | VOID\r | |
264 | PlatformBdsPolicyBehavior (\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 | |
271 | Routine 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 | |
277 | Arguments:\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 | |
285 | Returns:\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 | |
17fb73c8 | 307 | PrivateData->BootMode = GetBootModeHob();\r |
c9093a06 | 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 | |
c9093a06 | 405 | EFI_STATUS\r |
406 | PlatformBdsNoConsoleAction (\r | |
407 | VOID\r | |
408 | )\r | |
409 | /*++\r | |
410 | \r | |
411 | Routine Description:\r | |
412 | \r | |
413 | This function is remained for IBV/OEM to do some platform action,\r | |
414 | if there no console device can be connected.\r | |
415 | \r | |
416 | Arguments:\r | |
417 | \r | |
418 | None.\r | |
419 | \r | |
420 | Returns:\r | |
421 | \r | |
422 | EFI_SUCCESS - Direct return success now.\r | |
423 | \r | |
424 | --*/\r | |
425 | {\r | |
426 | return EFI_SUCCESS;\r | |
427 | }\r |