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