]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/Library/Nt32BdsLib/BdsPlatform.c
Move LockKeyboards API from GenericBdsLib to PlatformBdsLib
[mirror_edk2.git] / Nt32Pkg / Library / Nt32BdsLib / BdsPlatform.c
1 /**@file
2
3 Copyright (c) 2004 - 2006, 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 WIN_NT_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 &gEfiWinNtSystemConfigGuid,
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 &gEfiWinNtSystemConfigGuid,
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
150 return Status;
151 }
152
153 VOID
154 PlatformBdsConnectSequence (
155 VOID
156 )
157 /*++
158
159 Routine Description:
160
161 Connect with predeined platform connect sequence,
162 the OEM/IBV can customize with their own connect sequence.
163
164 Arguments:
165
166 None.
167
168 Returns:
169
170 None.
171
172 --*/
173 {
174 UINTN Index;
175
176 Index = 0;
177
178 //
179 // Here we can get the customized platform connect sequence
180 // Notes: we can connect with new variable which record the
181 // last time boots connect device path sequence
182 //
183 while (gPlatformConnectSequence[Index] != NULL) {
184 //
185 // Build the platform boot option
186 //
187 BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
188 Index++;
189 }
190
191 //
192 // Jst use the simple policy to connect all devices
193 //
194 BdsLibConnectAll ();
195 }
196
197 VOID
198 PlatformBdsGetDriverOption (
199 IN OUT LIST_ENTRY *BdsDriverLists
200 )
201 /*++
202
203 Routine Description:
204
205 Load the predefined driver option, OEM/IBV can customize this
206 to load their own drivers
207
208 Arguments:
209
210 BdsDriverLists - The header of the driver option link list.
211
212 Returns:
213
214 None.
215
216 --*/
217 {
218 UINTN Index;
219
220 Index = 0;
221
222 //
223 // Here we can get the customized platform driver option
224 //
225 while (gPlatformDriverOption[Index] != NULL) {
226 //
227 // Build the platform boot option
228 //
229 BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");
230 Index++;
231 }
232
233 }
234
235 VOID
236 PlatformBdsDiagnostics (
237 IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
238 IN BOOLEAN QuietBoot
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 Returns:
254
255 None.
256
257 --*/
258 {
259 EFI_STATUS Status;
260
261 //
262 // Here we can decide if we need to show
263 // the diagnostics screen
264 // Notes: this quiet boot code should be remove
265 // from the graphic lib
266 //
267 if (QuietBoot) {
268 EnableQuietBoot (PcdGetPtr(PcdLogoFile));
269 //
270 // Perform system diagnostic
271 //
272 Status = BdsMemoryTest (MemoryTestLevel);
273 if (EFI_ERROR (Status)) {
274 DisableQuietBoot ();
275 }
276
277 return ;
278 }
279 //
280 // Perform system diagnostic
281 //
282 Status = BdsMemoryTest (MemoryTestLevel);
283 }
284
285 VOID
286 EFIAPI
287 PlatformBdsPolicyBehavior (
288 IN OUT LIST_ENTRY *DriverOptionList,
289 IN OUT LIST_ENTRY *BootOptionList
290 )
291 /*++
292
293 Routine Description:
294
295 The function will excute with as the platform policy, current policy
296 is driven by boot mode. IBV/OEM can customize this code for their specific
297 policy action.
298
299 Arguments:
300
301 DriverOptionList - The header of the driver option link list
302
303 BootOptionList - The header of the boot option link list
304
305 Returns:
306
307 None.
308
309 --*/
310 {
311 EFI_STATUS Status;
312 UINT16 Timeout;
313 EFI_BOOT_MODE BootMode;
314
315 //
316 // Init the time out value
317 //
318 Timeout = PcdGet16 (PcdPlatformBootTimeOut);
319
320 //
321 // Load the driver option as the driver option list
322 //
323 PlatformBdsGetDriverOption (DriverOptionList);
324
325 //
326 // Get current Boot Mode
327 //
328 Status = BdsLibGetBootMode (&BootMode);
329
330 //
331 // Go the different platform policy with different boot mode
332 // Notes: this part code can be change with the table policy
333 //
334 switch (BootMode) {
335
336 case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
337 case BOOT_WITH_MINIMAL_CONFIGURATION:
338 //
339 // In no-configuration boot mode, we can connect the
340 // console directly.
341 //
342 BdsLibConnectAllDefaultConsoles ();
343 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);
344
345 //
346 // Perform some platform specific connect sequence
347 //
348 PlatformBdsConnectSequence ();
349
350 //
351 // Notes: current time out = 0 can not enter the
352 // front page
353 //
354 PlatformBdsEnterFrontPage (Timeout, FALSE);
355
356 //
357 // Check the boot option with the boot option list
358 //
359 BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
360 break;
361
362 case BOOT_ON_FLASH_UPDATE:
363 //
364 // Boot with the specific configuration
365 //
366 PlatformBdsConnectConsole (gPlatformConsole);
367 PlatformBdsDiagnostics (EXTENSIVE, FALSE);
368 BdsLibConnectAll ();
369 ProcessCapsules (BOOT_ON_FLASH_UPDATE);
370 break;
371
372 case BOOT_IN_RECOVERY_MODE:
373 //
374 // In recovery mode, just connect platform console
375 // and show up the front page
376 //
377 PlatformBdsConnectConsole (gPlatformConsole);
378 PlatformBdsDiagnostics (EXTENSIVE, FALSE);
379
380 //
381 // In recovery boot mode, we still enter to the
382 // frong page now
383 //
384 PlatformBdsEnterFrontPage (Timeout, FALSE);
385 break;
386
387 case BOOT_WITH_FULL_CONFIGURATION:
388 case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
389 case BOOT_WITH_DEFAULT_SETTINGS:
390 default:
391 //
392 // Connect platform console
393 //
394 Status = PlatformBdsConnectConsole (gPlatformConsole);
395 if (EFI_ERROR (Status)) {
396 //
397 // Here OEM/IBV can customize with defined action
398 //
399 PlatformBdsNoConsoleAction ();
400 }
401
402 PlatformBdsDiagnostics ((EXTENDMEM_COVERAGE_LEVEL)IGNORE, TRUE);
403
404 //
405 // Perform some platform specific connect sequence
406 //
407 PlatformBdsConnectSequence ();
408
409 //
410 // Give one chance to enter the setup if we
411 // have the time out
412 //
413 PlatformBdsEnterFrontPage (Timeout, FALSE);
414
415 //
416 // Here we have enough time to do the enumeration of boot device
417 //
418 BdsLibEnumerateAllBootOption (BootOptionList);
419 break;
420 }
421
422 return ;
423
424 }
425
426 VOID
427 EFIAPI
428 PlatformBdsBootSuccess (
429 IN BDS_COMMON_OPTION *Option
430 )
431 /*++
432
433 Routine Description:
434
435 Hook point after a boot attempt succeeds. We don't expect a boot option to
436 return, so the EFI 1.0 specification defines that you will default to an
437 interactive mode and stop processing the BootOrder list in this case. This
438 is alos a platform implementation and can be customized by IBV/OEM.
439
440 Arguments:
441
442 Option - Pointer to Boot Option that succeeded to boot.
443
444 Returns:
445
446 None.
447
448 --*/
449 {
450 CHAR16 *TmpStr;
451
452 //
453 // If Boot returned with EFI_SUCCESS and there is not in the boot device
454 // select loop then we need to pop up a UI and wait for user input.
455 //
456 TmpStr = Option->StatusString;
457 if (TmpStr != NULL) {
458 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
459 FreePool (TmpStr);
460 }
461 }
462
463 VOID
464 EFIAPI
465 PlatformBdsBootFail (
466 IN BDS_COMMON_OPTION *Option,
467 IN EFI_STATUS Status,
468 IN CHAR16 *ExitData,
469 IN UINTN ExitDataSize
470 )
471 /*++
472
473 Routine Description:
474
475 Hook point after a boot attempt fails.
476
477 Arguments:
478
479 Option - Pointer to Boot Option that failed to boot.
480
481 Status - Status returned from failed boot.
482
483 ExitData - Exit data returned from failed boot.
484
485 ExitDataSize - Exit data size returned from failed boot.
486
487 Returns:
488
489 None.
490
491 --*/
492 {
493 CHAR16 *TmpStr;
494
495 //
496 // If Boot returned with failed status then we need to pop up a UI and wait
497 // for user input.
498 //
499 TmpStr = Option->StatusString;
500 if (TmpStr != NULL) {
501 BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
502 FreePool (TmpStr);
503 }
504
505 }
506
507 EFI_STATUS
508 PlatformBdsNoConsoleAction (
509 VOID
510 )
511 /*++
512
513 Routine Description:
514
515 This function is remained for IBV/OEM to do some platform action,
516 if there no console device can be connected.
517
518 Arguments:
519
520 None.
521
522 Returns:
523
524 EFI_SUCCESS - Direct return success now.
525
526 --*/
527 {
528 return EFI_SUCCESS;
529 }
530
531 /**
532 This function locks platform flash that is not allowed to be updated during normal boot path.
533 The flash layout is platform specific.
534
535 **/
536 VOID
537 EFIAPI
538 PlatformBdsLockNonUpdatableFlash (
539 VOID
540 )
541 {
542 return;
543 }
544
545 /**
546 Lock the ConsoleIn device in system table. All key
547 presses will be ignored until the Password is typed in. The only way to
548 disable the password is to type it in to a ConIn device.
549
550 @param Password Password used to lock ConIn device.
551
552 @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
553 @retval EFI_UNSUPPORTED Password not found
554
555 **/
556 EFI_STATUS
557 EFIAPI
558 LockKeyboards (
559 IN CHAR16 *Password
560 )
561 {
562 return EFI_UNSUPPORTED;
563 }