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