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