]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/Library/UnixBdsLib/BdsPlatform.c
Move LockKeyboards API from GenericBdsLib to PlatformBdsLib
[mirror_edk2.git] / UnixPkg / Library / UnixBdsLib / BdsPlatform.c
1 /*++
2
3 Copyright (c) 2006 - 2009, Intel Corporation
4 All rights reserved. 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 )
239 /*++
240
241 Routine Description:
242
243 Perform the platform diagnostic, such like test memory. OEM/IBV also
244 can customize this fuction to support specific platform diagnostic.
245
246 Arguments:
247
248 MemoryTestLevel - The memory test intensive level
249
250 QuietBoot - Indicate if need to enable the quiet boot
251
252 Returns:
253
254 None.
255
256 --*/
257 {
258 EFI_STATUS Status;
259
260 //
261 // Here we can decide if we need to show
262 // the diagnostics screen
263 // Notes: this quiet boot code should be remove
264 // from the graphic lib
265 //
266 if (QuietBoot) {
267 EnableQuietBoot (PcdGetPtr(PcdLogoFile));
268 //
269 // Perform system diagnostic
270 //
271 Status = BdsMemoryTest (MemoryTestLevel);
272 if (EFI_ERROR (Status)) {
273 DisableQuietBoot ();
274 }
275
276 return ;
277 }
278 //
279 // Perform system diagnostic
280 //
281 Status = BdsMemoryTest (MemoryTestLevel);
282 }
283
284 VOID
285 EFIAPI
286 PlatformBdsPolicyBehavior (
287 IN OUT LIST_ENTRY *DriverOptionList,
288 IN OUT LIST_ENTRY *BootOptionList
289 )
290 /*++
291
292 Routine Description:
293
294 The function will excute with as the platform policy, current policy
295 is driven by boot mode. IBV/OEM can customize this code for their specific
296 policy action.
297
298 Arguments:
299
300 DriverOptionList - The header of the driver option link list
301
302 BootOptionList - The header of the boot option link list
303
304 Returns:
305
306 None.
307
308 --*/
309 {
310 EFI_STATUS Status;
311 UINT16 Timeout;
312 EFI_BOOT_MODE BootMode;
313
314 //
315 // Init the time out value
316 //
317 Timeout = PcdGet16 (PcdPlatformBootTimeOut);
318
319 //
320 // Load the driver option as the driver option list
321 //
322 PlatformBdsGetDriverOption (DriverOptionList);
323
324 //
325 // Get current Boot Mode
326 //
327 Status = BdsLibGetBootMode (&BootMode);
328
329 //
330 // Go the different platform policy with different boot mode
331 // Notes: this part code can be change with the table policy
332 //
333 switch (BootMode) {
334
335 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
336 case BOOT_WITH_MINIMAL_CONFIGURATION:
337 //
338 // In no-configuration boot mode, we can connect the
339 // console directly.
340 //
341 BdsLibConnectAllDefaultConsoles ();
342 PlatformBdsDiagnostics (IGNORE, TRUE);
343
344 //
345 // Perform some platform specific connect sequence
346 //
347 PlatformBdsConnectSequence ();
348
349 //
350 // Notes: current time out = 0 can not enter the
351 // front page
352 //
353 PlatformBdsEnterFrontPage (Timeout, FALSE);
354
355 //
356 // Check the boot option with the boot option list
357 //
358 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
359 break;
360
361 case BOOT_ON_FLASH_UPDATE:
362 //
363 // Boot with the specific configuration
364 //
365 PlatformBdsConnectConsole (gPlatformConsole);
366 PlatformBdsDiagnostics (EXTENSIVE, FALSE);
367 BdsLibConnectAll ();
368 ProcessCapsules (BOOT_ON_FLASH_UPDATE);
369 break;
370
371 case BOOT_IN_RECOVERY_MODE:
372 //
373 // In recovery mode, just connect platform console
374 // and show up the front page
375 //
376 PlatformBdsConnectConsole (gPlatformConsole);
377 PlatformBdsDiagnostics (EXTENSIVE, FALSE);
378
379 //
380 // In recovery boot mode, we still enter to the
381 // frong page now
382 //
383 PlatformBdsEnterFrontPage (Timeout, FALSE);
384 break;
385
386 case BOOT_WITH_FULL_CONFIGURATION:
387 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
388 case BOOT_WITH_DEFAULT_SETTINGS:
389 default:
390 //
391 // Connect platform console
392 //
393 Status = PlatformBdsConnectConsole (gPlatformConsole);
394 if (EFI_ERROR (Status)) {
395 //
396 // Here OEM/IBV can customize with defined action
397 //
398 PlatformBdsNoConsoleAction ();
399 }
400
401 PlatformBdsDiagnostics (IGNORE, TRUE);
402
403 //
404 // Perform some platform specific connect sequence
405 //
406 PlatformBdsConnectSequence ();
407
408 //
409 // Give one chance to enter the setup if we
410 // have the time out
411 //
412 PlatformBdsEnterFrontPage (Timeout, FALSE);
413
414 //
415 // Here we have enough time to do the enumeration of boot device
416 //
417 BdsLibEnumerateAllBootOption (BootOptionList);
418 break;
419 }
420
421 return ;
422
423 }
424
425 VOID
426 EFIAPI
427 PlatformBdsBootSuccess (
428 IN BDS_COMMON_OPTION *Option
429 )
430 /*++
431
432 Routine Description:
433
434 Hook point after a boot attempt succeeds. We don't expect a boot option to
435 return, so the EFI 1.0 specification defines that you will default to an
436 interactive mode and stop processing the BootOrder list in this case. This
437 is alos a platform implementation and can be customized by IBV/OEM.
438
439 Arguments:
440
441 Option - Pointer to Boot Option that succeeded to boot.
442
443 Returns:
444
445 None.
446
447 --*/
448 {
449 CHAR16 *TmpStr;
450
451 //
452 // If Boot returned with EFI_SUCCESS and there is not in the boot device
453 // select loop then we need to pop up a UI and wait for user input.
454 //
455 TmpStr = Option->StatusString;
456 if (TmpStr != NULL) {
457 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
458 FreePool (TmpStr);
459 }
460 }
461
462 VOID
463 EFIAPI
464 PlatformBdsBootFail (
465 IN BDS_COMMON_OPTION *Option,
466 IN EFI_STATUS Status,
467 IN CHAR16 *ExitData,
468 IN UINTN ExitDataSize
469 )
470 /*++
471
472 Routine Description:
473
474 Hook point after a boot attempt fails.
475
476 Arguments:
477
478 Option - Pointer to Boot Option that failed to boot.
479
480 Status - Status returned from failed boot.
481
482 ExitData - Exit data returned from failed boot.
483
484 ExitDataSize - Exit data size returned from failed boot.
485
486 Returns:
487
488 None.
489
490 --*/
491 {
492 CHAR16 *TmpStr;
493
494 //
495 // If Boot returned with failed status then we need to pop up a UI and wait
496 // for user input.
497 //
498 TmpStr = Option->StatusString;
499 if (TmpStr != NULL) {
500 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
501 FreePool (TmpStr);
502 }
503 }
504
505 EFI_STATUS
506 PlatformBdsNoConsoleAction (
507 VOID
508 )
509 /*++
510
511 Routine Description:
512
513 This function is remained for IBV/OEM to do some platform action,
514 if there no console device can be connected.
515
516 Arguments:
517
518 None.
519
520 Returns:
521
522 EFI_SUCCESS - Direct return success now.
523
524 --*/
525 {
526 return EFI_SUCCESS;
527 }
528
529 VOID
530 EFIAPI
531 PlatformBdsLockNonUpdatableFlash (
532 VOID
533 )
534 {
535 return;
536 }
537
538 /**
539 Lock the ConsoleIn device in system table. All key
540 presses will be ignored until the Password is typed in. The only way to
541 disable the password is to type it in to a ConIn device.
542
543 @param Password Password used to lock ConIn device.
544
545 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
546 @retval EFI_UNSUPPORTED Password not found
547
548 **/
549 EFI_STATUS
550 EFIAPI
551 LockKeyboards (
552 IN CHAR16 *Password
553 )
554 {
555 return EFI_UNSUPPORTED;
556 }