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