]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/PlatformBdsDxe/Generic/FrontPage.c
9b8a805e462d8835d430b6d7559eebf7a05b3bdc
[mirror_edk2.git] / Nt32Pkg / PlatformBdsDxe / Generic / FrontPage.c
1 /*++
2
3 Copyright (c) 2006 - 2007, 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 FrontPage.c
15
16 Abstract:
17
18 FrontPage routines to handle the callbacks and browser calls
19
20 --*/
21
22 //
23 // Include common header file for this module.
24 //
25 #include "CommonHeader.h"
26
27 #include "Bds.h"
28 #include "BdsPlatform.h"
29 #include "FrontPage.h"
30 #include "BdsString.h"
31
32 EFI_GUID mProcessorSubClass = EFI_PROCESSOR_SUBCLASS_GUID;
33 EFI_GUID mMemorySubClass = EFI_MEMORY_SUBCLASS_GUID;
34 EFI_GUID mMiscSubClass = EFI_MISC_SUBCLASS_GUID;
35
36 UINT16 mLastSelection;
37 EFI_HII_HANDLE gFrontPageHandle;
38 EFI_HANDLE FrontPageCallbackHandle;
39 EFI_FORM_CALLBACK_PROTOCOL FrontPageCallback;
40 EFI_FORM_BROWSER_PROTOCOL *gBrowser;
41 UINTN gCallbackKey;
42 BOOLEAN gConnectAllHappened = FALSE;
43
44 extern EFI_HII_HANDLE gFrontPageHandle;
45
46 EFI_STATUS
47 EFIAPI
48 FrontPageCallbackRoutine (
49 IN EFI_FORM_CALLBACK_PROTOCOL *This,
50 IN UINT16 KeyValue,
51 IN EFI_IFR_DATA_ARRAY *DataArray,
52 OUT EFI_HII_CALLBACK_PACKET **Packet
53 )
54 /*++
55
56 Routine Description:
57
58 This is the function that is called to provide results data to the driver. This data
59 consists of a unique key which is used to identify what data is either being passed back
60 or being asked for.
61
62 Arguments:
63
64 KeyValue - A unique value which is sent to the original exporting driver so that it
65 can identify the type of data to expect. The format of the data tends to
66 vary based on the op-code that geerated the callback.
67
68 Data - A pointer to the data being sent to the original exporting driver.
69
70 Returns:
71
72 --*/
73 {
74 CHAR16 *LanguageString;
75 UINTN Count;
76 CHAR16 UnicodeLang[3];
77 CHAR8 Lang[3];
78 EFI_STATUS Status;
79 UINTN Index;
80 CHAR16 *TmpStr;
81 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
82 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
83 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
84
85 SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
86 SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
87 SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
88
89 Count = 0;
90
91 //
92 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
93 // describe to their customers in documentation how to find their setup information (namely
94 // under the device manager and specific buckets)
95 //
96 switch (KeyValue) {
97 case 0x0001:
98 //
99 // This is the continue - clear the screen and return an error to get out of FrontPage loop
100 //
101 gCallbackKey = 1;
102 break;
103
104 case 0x1234:
105 //
106 // Collect the languages from what our current Language support is based on our VFR
107 //
108 gHii->GetPrimaryLanguages (gHii, gFrontPageHandle, &LanguageString);
109
110 //
111 // Based on the DataArray->Data->Data value, we can determine
112 // which language was chosen by the user
113 //
114 for (Index = 0; Count != (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray + 1))->Data); Index += 3) {
115 Count++;
116 }
117 //
118 // Preserve the choice the user made
119 //
120 mLastSelection = (UINT16) Count;
121
122 //
123 // The Language (in Unicode format) the user chose
124 //
125 CopyMem (UnicodeLang, &LanguageString[Index], 6);
126
127 //
128 // Convert Unicode to ASCII (Since the ISO standard assumes ASCII equivalent abbreviations
129 // we can be safe in converting this Unicode stream to ASCII without any loss in meaning.
130 //
131 for (Index = 0; Index < 3; Index++) {
132 Lang[Index] = (CHAR8) UnicodeLang[Index];
133 }
134
135 Status = gRT->SetVariable (
136 L"Lang",
137 &gEfiGlobalVariableGuid,
138 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
139 3,
140 Lang
141 );
142
143 FreePool (LanguageString);
144 gCallbackKey = 2;
145 break;
146
147 case 0x1064:
148 //
149 // Boot Manager
150 //
151 gCallbackKey = 3;
152 break;
153
154 case 0x8567:
155 //
156 // Device Manager
157 //
158 gCallbackKey = 4;
159 break;
160
161 case 0x9876:
162 //
163 // Boot Maintenance Manager
164 //
165 gCallbackKey = 5;
166 break;
167
168 case 0xFFFE:
169
170 break;
171
172 case 0xFFFF:
173 //
174 // FrontPage TimeOut Callback
175 //
176 TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));
177 if (TmpStr != NULL) {
178 PlatformBdsShowProgress (
179 Foreground,
180 Background,
181 TmpStr,
182 Color,
183 (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray+1))->Data),
184 0
185 );
186 FreePool (TmpStr);
187 }
188 break;
189
190 default:
191 gCallbackKey = 0;
192 break;
193 }
194
195 return EFI_SUCCESS;
196 }
197
198 EFI_STATUS
199 InitializeFrontPage (
200 BOOLEAN ReInitializeStrings
201 )
202 /*++
203
204 Routine Description:
205
206 Initialize HII information for the FrontPage
207
208 Arguments:
209 None
210
211 Returns:
212 EFI_SUCCESS - The operation is successful.
213 EFI_DEVICE_ERROR - If the dynamic opcode creation failed.
214
215 --*/
216 {
217 EFI_STATUS Status;
218 EFI_HII_PACKAGES *PackageList;
219 EFI_HII_UPDATE_DATA *UpdateData;
220 IFR_OPTION *OptionList;
221 CHAR16 *LanguageString;
222 UINTN OptionCount;
223 UINTN Index;
224 STRING_REF Token;
225 UINT16 Key;
226 CHAR8 AsciiLang[4];
227 CHAR16 UnicodeLang[4];
228 CHAR16 Lang[4];
229 CHAR16 *StringBuffer;
230 UINTN BufferSize;
231 UINT8 *TempBuffer;
232
233 UpdateData = NULL;
234 OptionList = NULL;
235
236 if (ReInitializeStrings) {
237 //
238 // BugBug: Dont' use a goto
239 //
240 goto ReInitStrings;
241 }
242 //
243 // Go ahead and initialize the Device Manager
244 //
245 InitializeDeviceManager ();
246
247 //
248 // BugBug: if FrontPageVfrBin is generated by a tool, why are we patching it here
249 //
250 TempBuffer = (UINT8 *) FrontPageVfrBin;
251 TempBuffer = TempBuffer + sizeof (EFI_HII_PACK_HEADER);
252 TempBuffer = (UINT8 *) &((EFI_IFR_FORM_SET *) TempBuffer)->NvDataSize;
253 *TempBuffer = 1;
254
255 gCallbackKey = 0;
256
257 PackageList = PreparePackages (1, &gEfiCallerIdGuid, FrontPageVfrBin);
258
259 Status = gHii->NewPack (gHii, PackageList, &gFrontPageHandle);
260
261 FreePool (PackageList);
262
263 //
264 // There will be only one FormConfig in the system
265 // If there is another out there, someone is trying to install us
266 // again. Fail that scenario.
267 //
268 Status = gBS->LocateProtocol (
269 &gEfiFormBrowserProtocolGuid,
270 NULL,
271 &gBrowser
272 );
273
274 //
275 // This example does not implement worker functions
276 // for the NV accessor functions. Only a callback evaluator
277 //
278 FrontPageCallback.NvRead = NULL;
279 FrontPageCallback.NvWrite = NULL;
280 FrontPageCallback.Callback = FrontPageCallbackRoutine;
281
282 //
283 // Install protocol interface
284 //
285 FrontPageCallbackHandle = NULL;
286 Status = gBS->InstallProtocolInterface (
287 &FrontPageCallbackHandle,
288 &gEfiFormCallbackProtocolGuid,
289 EFI_NATIVE_INTERFACE,
290 &FrontPageCallback
291 );
292 ASSERT_EFI_ERROR (Status);
293
294 ReInitStrings:
295 //
296 // BugBug: This logic is in BdsInitLanguage. It should not be in two places!
297 //
298 BufferSize = 4;
299 Status = gRT->GetVariable (
300 L"Lang",
301 &gEfiGlobalVariableGuid,
302 NULL,
303 &BufferSize,
304 AsciiLang
305 );
306
307 for (Index = 0; Index < 3; Index++) {
308 UnicodeLang[Index] = (CHAR16) AsciiLang[Index];
309 }
310
311 UnicodeLang[3] = 0;
312
313 //
314 // Allocate space for creation of UpdateData Buffer
315 //
316 UpdateData = AllocateZeroPool (0x1000);
317 ASSERT (UpdateData != NULL);
318
319 OptionList = AllocateZeroPool (0x1000);
320 ASSERT (OptionList != NULL);
321
322 //
323 // Flag update pending in FormSet
324 //
325 UpdateData->FormSetUpdate = TRUE;
326 //
327 // Register CallbackHandle data for FormSet
328 //
329 UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) FrontPageCallbackHandle;
330 UpdateData->FormUpdate = FALSE;
331 UpdateData->FormTitle = 0;
332 UpdateData->DataCount = 1;
333
334 //
335 // Collect the languages from what our current Language support is based on our VFR
336 //
337 gHii->GetPrimaryLanguages (gHii, gFrontPageHandle, &LanguageString);
338
339 OptionCount = 0;
340
341 //
342 // Try for a 512 byte Buffer
343 //
344 BufferSize = 0x200;
345
346 //
347 // Allocate memory for our Form binary
348 //
349 StringBuffer = AllocateZeroPool (BufferSize);
350 ASSERT (StringBuffer != NULL);
351
352 for (Index = 0; LanguageString[Index] != 0; Index += 3) {
353 Token = 0;
354 CopyMem (Lang, &LanguageString[Index], 6);
355 Lang[3] = 0;
356
357 if (!StrCmp (Lang, UnicodeLang)) {
358 mLastSelection = (UINT16) OptionCount;
359 }
360
361 Status = gHii->GetString (gHii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, StringBuffer);
362 gHii->NewString (gHii, NULL, gStringPackHandle, &Token, StringBuffer);
363 CopyMem (&OptionList[OptionCount].StringToken, &Token, sizeof (UINT16));
364 CopyMem (&OptionList[OptionCount].Value, &OptionCount, sizeof (UINT16));
365 Key = 0x1234;
366 CopyMem (&OptionList[OptionCount].Key, &Key, sizeof (UINT16));
367 OptionList[OptionCount].Flags = EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS;
368 OptionCount++;
369 }
370
371 FreePool (LanguageString);
372
373 if (ReInitializeStrings) {
374 FreePool (StringBuffer);
375 FreePool (OptionList);
376 return EFI_SUCCESS;
377 }
378
379 Status = CreateOneOfOpCode (
380 FRONT_PAGE_QUESTION_ID, // Question ID
381 FRONT_PAGE_DATA_WIDTH, // Data Width
382 (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT), // Prompt Token
383 (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), // Help Token
384 OptionList, // List of Options
385 OptionCount, // Number of Options
386 &UpdateData->Data // Data Buffer
387 );
388
389 //
390 // Assign the number of options and the oneof and endoneof op-codes to count
391 //
392 UpdateData->DataCount = (UINT8) (OptionCount + 2);
393
394 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);
395
396 FreePool (UpdateData);
397 //
398 // FreePool (OptionList);
399 //
400 FreePool (StringBuffer);
401 return Status;
402 }
403
404 EFI_STATUS
405 CallFrontPage (
406 VOID
407 )
408 /*++
409
410 Routine Description:
411
412 Call the browser and display the front page
413
414 Arguments:
415
416 None
417
418 Returns:
419
420 --*/
421 {
422 EFI_STATUS Status;
423 UINT8 FakeNvRamMap[1];
424 BOOLEAN FrontPageMenuResetRequired;
425
426 //
427 // Begin waiting for USER INPUT
428 //
429 REPORT_STATUS_CODE (
430 EFI_PROGRESS_CODE,
431 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
432 );
433
434 FakeNvRamMap[0] = (UINT8) mLastSelection;
435 FrontPageMenuResetRequired = FALSE;
436 Status = gBrowser->SendForm (
437 gBrowser,
438 TRUE, // Use the database
439 &gFrontPageHandle, // The HII Handle
440 1,
441 NULL,
442 FrontPageCallbackHandle, // This is the handle that the interface to the callback was installed on
443 FakeNvRamMap,
444 NULL,
445 &FrontPageMenuResetRequired
446 );
447 //
448 // Check whether user change any option setting which needs a reset to be effective
449 //
450 if (FrontPageMenuResetRequired) {
451 EnableResetRequired ();
452 }
453
454 gHii->ResetStrings (gHii, gFrontPageHandle);
455
456 return Status;
457 }
458
459 EFI_STATUS
460 GetStringFromToken (
461 IN EFI_GUID *ProducerGuid,
462 IN STRING_REF Token,
463 OUT CHAR16 **String
464 )
465 /*++
466
467 Routine Description:
468
469 Acquire the string associated with the ProducerGuid and return it.
470
471 Arguments:
472
473 ProducerGuid - The Guid to search the HII database for
474 Token - The token value of the string to extract
475 String - The string that is extracted
476
477 Returns:
478
479 EFI_SUCCESS - The function returns EFI_SUCCESS always.
480
481 --*/
482 {
483 EFI_STATUS Status;
484 UINT16 HandleBufferLength;
485 EFI_HII_HANDLE *HiiHandleBuffer;
486 UINTN StringBufferLength;
487 UINTN NumberOfHiiHandles;
488 UINTN Index;
489 UINT16 Length;
490 EFI_GUID HiiGuid;
491
492 //
493 // Initialize params.
494 //
495 HandleBufferLength = 0;
496 HiiHandleBuffer = NULL;
497
498 //
499 // Get all the Hii handles
500 //
501 Status = BdsLibGetHiiHandles (gHii, &HandleBufferLength, &HiiHandleBuffer);
502 ASSERT_EFI_ERROR (Status);
503
504 //
505 // Get the gHii Handle that matches the StructureNode->ProducerName
506 //
507 NumberOfHiiHandles = HandleBufferLength / sizeof (EFI_HII_HANDLE);
508 for (Index = 0; Index < NumberOfHiiHandles; Index++) {
509 Length = 0;
510 Status = ExtractDataFromHiiHandle (
511 HiiHandleBuffer[Index],
512 &Length,
513 NULL,
514 &HiiGuid
515 );
516 if (CompareGuid (ProducerGuid, &HiiGuid)) {
517 break;
518 }
519 }
520 //
521 // Find the string based on the current language
522 //
523 StringBufferLength = 0x100;
524 *String = AllocateZeroPool (0x100);
525 Status = gHii->GetString (
526 gHii,
527 HiiHandleBuffer[Index],
528 Token,
529 FALSE,
530 NULL,
531 &StringBufferLength,
532 *String
533 );
534
535 if (EFI_ERROR (Status)) {
536 FreePool (*String);
537 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
538 }
539
540 FreePool (HiiHandleBuffer);
541 return EFI_SUCCESS;
542 }
543
544 VOID
545 ConvertProcessorToString (
546 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency,
547 OUT CHAR16 **String
548 )
549 /*++
550
551 Routine Description:
552
553 Convert Processor Frequency Data to a string
554
555 Arguments:
556
557 ProcessorFrequency - The frequency data to process
558 String - The string that is created
559
560 Returns:
561
562 --*/
563 {
564 CHAR16 *StringBuffer;
565 UINTN Index;
566 UINT32 FreqMhz;
567
568 if (ProcessorFrequency->Exponent >= 6) {
569 FreqMhz = ProcessorFrequency->Value;
570 for (Index = 0; Index < (UINTN) (ProcessorFrequency->Exponent - 6); Index++) {
571 FreqMhz *= 10;
572 }
573 } else {
574 FreqMhz = 0;
575 }
576
577 StringBuffer = AllocateZeroPool (0x20);
578 ASSERT (StringBuffer != NULL);
579 Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
580 StrCat (StringBuffer, L".");
581 UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
582 StrCat (StringBuffer, L" GHz");
583
584 *String = (CHAR16 *) StringBuffer;
585
586 return ;
587 }
588
589 VOID
590 ConvertMemorySizeToString (
591 IN UINT32 MemorySize,
592 OUT CHAR16 **String
593 )
594 /*++
595
596 Routine Description:
597
598 Convert Memory Size to a string
599
600 Arguments:
601
602 MemorySize - The size of the memory to process
603 String - The string that is created
604
605 Returns:
606
607 --*/
608 {
609 CHAR16 *StringBuffer;
610
611 StringBuffer = AllocateZeroPool (0x20);
612 ASSERT (StringBuffer != NULL);
613 UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
614 StrCat (StringBuffer, L" MB RAM");
615
616 *String = (CHAR16 *) StringBuffer;
617
618 return ;
619 }
620
621 VOID
622 UpdateFrontPageStrings (
623 VOID
624 )
625 /*++
626
627 Routine Description:
628
629 Update the banner information for the Front Page based on DataHub information
630
631 Arguments:
632
633 None
634
635 Returns:
636
637 --*/
638 {
639 EFI_STATUS Status;
640 STRING_REF TokenToUpdate;
641 CHAR16 *NewString;
642 UINT64 MonotonicCount;
643 EFI_DATA_HUB_PROTOCOL *DataHub;
644 EFI_DATA_RECORD_HEADER *Record;
645 EFI_SUBCLASS_TYPE1_HEADER *DataHeader;
646 EFI_MISC_BIOS_VENDOR_DATA *BiosVendor;
647 EFI_MISC_SYSTEM_MANUFACTURER_DATA *SystemManufacturer;
648 EFI_PROCESSOR_VERSION_DATA *ProcessorVersion;
649 EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency;
650 EFI_MEMORY_ARRAY_START_ADDRESS_DATA *MemoryArray;
651 CHAR8 LangCode[3];
652 CHAR16 Lang[3];
653 UINTN Size;
654 UINTN Index;
655 BOOLEAN Find[5];
656
657 ZeroMem (Find, sizeof (Find));
658
659 //
660 // Update Front Page strings
661 //
662 Status = gBS->LocateProtocol (
663 &gEfiDataHubProtocolGuid,
664 NULL,
665 &DataHub
666 );
667 ASSERT_EFI_ERROR (Status);
668
669 Size = 3;
670
671 Status = gRT->GetVariable (
672 L"Lang",
673 &gEfiGlobalVariableGuid,
674 NULL,
675 &Size,
676 LangCode
677 );
678
679 for (Index = 0; Index < 3; Index++) {
680 Lang[Index] = (CHAR16) LangCode[Index];
681 }
682
683 MonotonicCount = 0;
684 Record = NULL;
685 do {
686 Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);
687 if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {
688 DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
689 if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&
690 (DataHeader->RecordType == EFI_MISC_BIOS_VENDOR_RECORD_NUMBER)
691 ) {
692 BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1);
693 GetStringFromToken (&Record->ProducerName, BiosVendor->BiosVersion, &NewString);
694 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_BIOS_VERSION;
695 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
696 FreePool (NewString);
697 Find[0] = TRUE;
698 }
699
700 if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&
701 (DataHeader->RecordType == EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER)
702 ) {
703 SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1);
704 GetStringFromToken (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString);
705 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_COMPUTER_MODEL;
706 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
707 FreePool (NewString);
708 Find[1] = TRUE;
709 }
710
711 if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&
712 (DataHeader->RecordType == ProcessorVersionRecordType)
713 ) {
714 ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1);
715 GetStringFromToken (&Record->ProducerName, *ProcessorVersion, &NewString);
716 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_MODEL;
717 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
718 FreePool (NewString);
719 Find[2] = TRUE;
720 }
721
722 if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&
723 (DataHeader->RecordType == ProcessorCoreFrequencyRecordType)
724 ) {
725 ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1);
726 ConvertProcessorToString (ProcessorFrequency, &NewString);
727 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_SPEED;
728 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
729 FreePool (NewString);
730 Find[3] = TRUE;
731 }
732
733 if (CompareGuid (&Record->DataRecordGuid, &mMemorySubClass) &&
734 (DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER)
735 ) {
736 MemoryArray = (EFI_MEMORY_ARRAY_START_ADDRESS_DATA *) (DataHeader + 1);
737 ConvertMemorySizeToString((UINT32)(RShiftU64((MemoryArray->MemoryArrayEndAddress -
738 MemoryArray->MemoryArrayStartAddress + 1), 20)),
739 &NewString);
740 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_MEMORY_SIZE;
741 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
742 FreePool (NewString);
743 Find[4] = TRUE;
744 }
745 }
746 } while (!EFI_ERROR (Status) && (MonotonicCount != 0) && !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));
747
748 return ;
749 }
750
751 VOID
752 PlatformBdsEnterFrontPage (
753 IN UINT16 TimeoutDefault,
754 IN BOOLEAN ConnectAllHappened
755 )
756 /*++
757
758 Routine Description:
759 This function is the main entry of the platform setup entry.
760 The function will present the main menu of the system setup,
761 this is the platform reference part and can be customize.
762
763 Arguments:
764 TimeoutDefault - The fault time out value before the system
765 continue to boot.
766 ConnectAllHappened - The indicater to check if the connect all have
767 already happended.
768
769 Returns:
770 None
771
772 --*/
773 {
774 EFI_STATUS Status;
775 EFI_HII_UPDATE_DATA *UpdateData;
776 EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
777
778 //
779 // Indicate if we need connect all in the platform setup
780 //
781 if (ConnectAllHappened) {
782 gConnectAllHappened = TRUE;
783 }
784 //
785 // Allocate space for creation of Buffer
786 //
787 UpdateData = AllocateZeroPool (0x1000);
788 ASSERT (UpdateData != NULL);
789
790 UpdateData->FormSetUpdate = FALSE;
791 UpdateData->FormCallbackHandle = 0;
792 UpdateData->FormUpdate = FALSE;
793 UpdateData->FormTitle = 0;
794 UpdateData->DataCount = 1;
795
796 //
797 // Remove Banner Op-code if any at this label
798 //
799 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, FALSE, UpdateData);
800
801 //
802 // Create Banner Op-code which reflects correct timeout value
803 //
804 CreateBannerOpCode (
805 STRING_TOKEN (STR_TIME_OUT_PROMPT),
806 TimeoutDefault,
807 (UINT8) EFI_IFR_BANNER_TIMEOUT,
808 &UpdateData->Data
809 );
810
811 //
812 // Add Banner Op-code at this label
813 //
814 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, TRUE, UpdateData);
815
816 do {
817
818 InitializeFrontPage (TRUE);
819
820 //
821 // Update Front Page strings
822 //
823 UpdateFrontPageStrings ();
824
825 gCallbackKey = 0;
826 PERF_START (0, "BdsTimeOut", "BDS", 0);
827 Status = CallFrontPage ();
828 PERF_END (0, "BdsTimeOut", "BDS", 0);
829
830 //
831 // If gCallbackKey is greater than 1 and less or equal to 5,
832 // it will lauch configuration utilities.
833 // 2 = set language
834 // 3 = boot manager
835 // 4 = device manager
836 // 5 = boot maintainenance manager
837 //
838 if ((gCallbackKey > 0x0001) && (gCallbackKey <= 0x0005)) {
839 REPORT_STATUS_CODE (
840 EFI_PROGRESS_CODE,
841 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
842 );
843 }
844 //
845 // Based on the key that was set, we can determine what to do
846 //
847 switch (gCallbackKey) {
848 //
849 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
850 // describe to their customers in documentation how to find their setup information (namely
851 // under the device manager and specific buckets)
852 //
853 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
854 //
855 case 0x0001:
856 //
857 // User hit continue
858 //
859 break;
860
861 case 0x0002:
862 //
863 // User made a language setting change - display front page again
864 //
865 break;
866
867 case 0x0003:
868 //
869 // User chose to run the Boot Manager
870 //
871 CallBootManager ();
872 break;
873
874 case 0x0004:
875 //
876 // Display the Device Manager
877 //
878 do {
879 CallDeviceManager();
880 } while (gCallbackKey == 4);
881 break;
882
883 case 0x0005:
884 //
885 // Display the Boot Maintenance Manager
886 //
887 BdsStartBootMaint ();
888 break;
889 }
890
891 } while ((Status == EFI_SUCCESS) && (gCallbackKey != 1));
892
893 //
894 //Will leave browser, check any reset required change is applied? if yes, reset system
895 //
896 SetupResetReminder ();
897
898 //
899 // Automatically load current entry
900 // Note: The following lines of code only execute when Auto boot
901 // takes affect
902 //
903 Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);
904 ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);
905
906 }