]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Library/UnixBdsLib/BdsPlatform.c
Update the copyright notice format
[mirror_edk2.git] / UnixPkg / Library / UnixBdsLib / BdsPlatform.c
1 /*++
2
3 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 BdsPlatform.c
15
16 Abstract:
17
18 This file include all platform action which can be customized
19 by IBV/OEM.
20
21 --*/
22
23 #include "BdsPlatform.h"
24
25 UNIX_SYSTEM_CONFIGURATION mSystemConfigData;
26
27 VOID
28 SetupVariableInit (
29 VOID
30 )
31 {
32 EFI_STATUS Status;
33 UINTN Size;
34
35 Size = sizeof (mSystemConfigData);
36 Status = gRT->GetVariable (
37 L"Setup",
38 &gEfiUnixSystemConfigGuid,
39 NULL,
40 &Size,
41 (VOID *) &mSystemConfigData
42 );
43
44 if (EFI_ERROR (Status)) {
45 //
46 // SetupVariable is corrupt
47 //
48 mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
49 mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);
50
51 Status = gRT->SetVariable (
52 L"Setup",
53 &gEfiUnixSystemConfigGuid,
54 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
55 sizeof (mSystemConfigData),
56 (VOID *) &mSystemConfigData
57 );
58 if (EFI_ERROR (Status)) {
59 DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
60 }
61 }
62 }
63
64 //
65 // BDS Platform Functions
66 //
67 VOID
68 EFIAPI
69 PlatformBdsInit (
70 VOID
71 )
72 /*++
73
74 Routine Description:
75
76 Platform Bds init. Include the platform firmware vendor, revision
77 and so crc check.
78
79 Arguments:
80
81 Returns:
82
83 None.
84
85 --*/
86 {
87 SetupVariableInit ();
88 }
89
90 EFI_STATUS
91 PlatformBdsConnectConsole (
92 IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
93 )
94 /*++
95
96 Routine Description:
97
98 Connect the predefined platform default console device. Always try to find
99 and enable the vga device if have.
100
101 Arguments:
102
103 PlatformConsole - Predfined platform default console device array.
104
105 Returns:
106
107 EFI_SUCCESS - Success connect at least one ConIn and ConOut
108 device, there must have one ConOut device is
109 active vga device.
110
111 EFI_STATUS - Return the status of
112 BdsLibConnectAllDefaultConsoles ()
113
114 --*/
115 {
116 EFI_STATUS Status;
117 UINTN Index;
118
119 Index = 0;
120 Status = EFI_SUCCESS;
121
122 //
123 // Have chance to connect the platform default console,
124 // the platform default console is the minimue device group
125 // the platform should support
126 //
127 while (PlatformConsole[Index].DevicePath != NULL) {
128 //
129 // Update the console variable with the connect type
130 //
131 if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
132 BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);
133 }
134
135 if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
136 BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);
137 }
138
139 if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
140 BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);
141 }
142
143 Index++;
144 }
145 //
146 // Connect the all the default console with current cosole variable
147 //
148 Status = BdsLibConnectAllDefaultConsoles ();
149 return Status;
150 }
151
152 VOID
153 PlatformBdsConnectSequence (
154 VOID
155 )
156 /*++
157
158 Routine Description:
159
160 Connect with predeined platform connect sequence,
161 the OEM/IBV can customize with their own connect sequence.
162
163 Arguments:
164
165 None.
166
167 Returns:
168
169 None.
170
171 --*/
172 {
173 UINTN Index;
174
175 Index = 0;
176
177 //
178 // Here we can get the customized platform connect sequence
179 // Notes: we can connect with new variable which record the
180 // last time boots connect device path sequence
181 //
182 while (gPlatformConnectSequence[Index] != NULL) {
183 //
184 // Build the platform boot option
185 //
186 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
187 Index++;
188 }
189
190 //
191 // Just use the simple policy to connect all devices
192 //
193 BdsLibConnectAll ();
194 }
195
196 VOID
197 PlatformBdsGetDriverOption (
198 IN OUT LIST_ENTRY *BdsDriverLists
199 )
200 /*++
201
202 Routine Description:
203
204 Load the predefined driver option, OEM/IBV can customize this
205 to load their own drivers
206
207 Arguments:
208
209 BdsDriverLists - The header of the driver option link list.
210
211 Returns:
212
213 None.
214
215 --*/
216 {
217 UINTN Index;
218
219 Index = 0;
220
221 //
222 // Here we can get the customized platform driver option
223 //
224 while (gPlatformDriverOption[Index] != NULL) {
225 //
226 // Build the platform boot option
227 //
228 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");
229 Index++;
230 }
231
232 }
233
234 VOID
235 PlatformBdsDiagnostics (
236 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
237 IN BOOLEAN QuietBoot,
238 IN BASEM_MEMORY_TEST BaseMemoryTest
239 )
240 /*++
241
242 Routine Description:
243
244 Perform the platform diagnostic, such like test memory. OEM/IBV also
245 can customize this fuction to support specific platform diagnostic.
246
247 Arguments:
248
249 MemoryTestLevel - The memory test intensive level
250
251 QuietBoot - Indicate if need to enable the quiet boot
252
253 BaseMemoryTest - A pointer to BdsMemoryTest()
254
255 Returns:
256
257 None.
258
259 --*/
260 {
261 EFI_STATUS Status;
262
263 //
264 // Here we can decide if we need to show
265 // the diagnostics screen
266 // Notes: this quiet boot code should be remove
267 // from the graphic lib
268 //
269 if (QuietBoot) {
270 EnableQuietBoot (PcdGetPtr(PcdLogoFile));
271 //
272 // Perform system diagnostic
273 //
274 Status = BaseMemoryTest (MemoryTestLevel);
275 if (EFI_ERROR (Status)) {
276 DisableQuietBoot ();
277 }
278
279 return ;
280 }
281 //
282 // Perform system diagnostic
283 //
284 Status = BaseMemoryTest (MemoryTestLevel);
285 }
286
287 VOID
288 EFIAPI
289 PlatformBdsPolicyBehavior (
290 IN OUT LIST_ENTRY *DriverOptionList,
291 IN OUT LIST_ENTRY *BootOptionList,
292 IN PROCESS_CAPSULES ProcessCapsules,
293 IN BASEM_MEMORY_TEST BaseMemoryTest
294 )
295 /*++
296
297 Routine Description:
298
299 The function will excute with as the platform policy, current policy
300 is driven by boot mode. IBV/OEM can customize this code for their specific
301 policy action.
302
303 Arguments:
304
305 DriverOptionList - The header of the driver option link list
306
307 BootOptionList - The header of the boot option link list
308
309 ProcessCapsules - A pointer to ProcessCapsules()
310
311 BaseMemoryTest - A pointer to BaseMemoryTest()
312
313 Returns:
314
315 None.
316
317 --*/
318 {
319 EFI_STATUS Status;
320 UINT16 Timeout;
321 EFI_BOOT_MODE BootMode;
322
323 //
324 // Init the time out value
325 //
326 Timeout = PcdGet16 (PcdPlatformBootTimeOut);
327
328 //
329 // Load the driver option as the driver option list
330 //
331 PlatformBdsGetDriverOption (DriverOptionList);
332
333 //
334 // Get current Boot Mode
335 //
336 Status = BdsLibGetBootMode (&BootMode);
337
338 //
339 // Go the different platform policy with different boot mode
340 // Notes: this part code can be change with the table policy
341 //
342 switch (BootMode) {
343
344 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
345 case BOOT_WITH_MINIMAL_CONFIGURATION:
346 //
347 // In no-configuration boot mode, we can connect the
348 // console directly.
349 //
350 BdsLibConnectAllDefaultConsoles ();
351 PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
352
353 //
354 // Perform some platform specific connect sequence
355 //
356 PlatformBdsConnectSequence ();
357
358 //
359 // Notes: current time out = 0 can not enter the
360 // front page
361 //
362 PlatformBdsEnterFrontPage (Timeout, FALSE);
363
364 //
365 // Check the boot option with the boot option list
366 //
367 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
368 break;
369
370 case BOOT_ON_FLASH_UPDATE:
371 //
372 // Boot with the specific configuration
373 //
374 PlatformBdsConnectConsole (gPlatformConsole);
375 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);
376 BdsLibConnectAll ();
377 ProcessCapsules (BOOT_ON_FLASH_UPDATE);
378 break;
379
380 case BOOT_IN_RECOVERY_MODE:
381 //
382 // In recovery mode, just connect platform console
383 // and show up the front page
384 //
385 PlatformBdsConnectConsole (gPlatformConsole);
386 PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);
387
388 //
389 // In recovery boot mode, we still enter to the
390 // frong page now
391 //
392 PlatformBdsEnterFrontPage (Timeout, FALSE);
393 break;
394
395 case BOOT_WITH_FULL_CONFIGURATION:
396 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
397 case BOOT_WITH_DEFAULT_SETTINGS:
398 default:
399 //
400 // Connect platform console
401 //
402 Status = PlatformBdsConnectConsole (gPlatformConsole);
403 if (EFI_ERROR (Status)) {
404 //
405 // Here OEM/IBV can customize with defined action
406 //
407 PlatformBdsNoConsoleAction ();
408 }
409
410 PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
411
412 //
413 // Perform some platform specific connect sequence
414 //
415 PlatformBdsConnectSequence ();
416
417 //
418 // Give one chance to enter the setup if we
419 // have the time out
420 //
421 PlatformBdsEnterFrontPage (Timeout, FALSE);
422
423 //
424 // Here we have enough time to do the enumeration of boot device
425 //
426 BdsLibEnumerateAllBootOption (BootOptionList);
427 break;
428 }
429
430 return ;
431
432 }
433
434 VOID
435 EFIAPI
436 PlatformBdsBootSuccess (
437 IN BDS_COMMON_OPTION *Option
438 )
439 /*++
440
441 Routine Description:
442
443 Hook point after a boot attempt succeeds. We don't expect a boot option to
444 return, so the EFI 1.0 specification defines that you will default to an
445 interactive mode and stop processing the BootOrder list in this case. This
446 is alos a platform implementation and can be customized by IBV/OEM.
447
448 Arguments:
449
450 Option - Pointer to Boot Option that succeeded to boot.
451
452 Returns:
453
454 None.
455
456 --*/
457 {
458 CHAR16 *TmpStr;
459
460 //
461 // If Boot returned with EFI_SUCCESS and there is not in the boot device
462 // select loop then we need to pop up a UI and wait for user input.
463 //
464 TmpStr = Option->StatusString;
465 if (TmpStr != NULL) {
466 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
467 FreePool (TmpStr);
468 }
469 }
470
471 VOID
472 EFIAPI
473 PlatformBdsBootFail (
474 IN BDS_COMMON_OPTION *Option,
475 IN EFI_STATUS Status,
476 IN CHAR16 *ExitData,
477 IN UINTN ExitDataSize
478 )
479 /*++
480
481 Routine Description:
482
483 Hook point after a boot attempt fails.
484
485 Arguments:
486
487 Option - Pointer to Boot Option that failed to boot.
488
489 Status - Status returned from failed boot.
490
491 ExitData - Exit data returned from failed boot.
492
493 ExitDataSize - Exit data size returned from failed boot.
494
495 Returns:
496
497 None.
498
499 --*/
500 {
501 CHAR16 *TmpStr;
502
503 //
504 // If Boot returned with failed status then we need to pop up a UI and wait
505 // for user input.
506 //
507 TmpStr = Option->StatusString;
508 if (TmpStr != NULL) {
509 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
510 FreePool (TmpStr);
511 }
512 }
513
514 EFI_STATUS
515 PlatformBdsNoConsoleAction (
516 VOID
517 )
518 /*++
519
520 Routine Description:
521
522 This function is remained for IBV/OEM to do some platform action,
523 if there no console device can be connected.
524
525 Arguments:
526
527 None.
528
529 Returns:
530
531 EFI_SUCCESS - Direct return success now.
532
533 --*/
534 {
535 return EFI_SUCCESS;
536 }
537
538 VOID
539 EFIAPI
540 PlatformBdsLockNonUpdatableFlash (
541 VOID
542 )
543 {
544 return;
545 }
546
547 /**
548 Lock the ConsoleIn device in system table. All key
549 presses will be ignored until the Password is typed in. The only way to
550 disable the password is to type it in to a ConIn device.
551
552 @param Password Password used to lock ConIn device.
553
554 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
555 @retval EFI_UNSUPPORTED Password not found
556
557 **/
558 EFI_STATUS
559 EFIAPI
560 LockKeyboards (
561 IN CHAR16 *Password
562 )
563 {
564 return EFI_UNSUPPORTED;
565 }