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