]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/PlatformBdsDxe/Generic/FrontPage.c
Correct a bug that allocate a fix size buffer as input buffer for Hii->GetString...
[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 gHii->NewString (gHii, NULL, gStringPackHandle, &Token, StringBuffer);
351 FreePool (StringBuffer);
352 CopyMem (&OptionList[OptionCount].StringToken, &Token, sizeof (UINT16));
353 CopyMem (&OptionList[OptionCount].Value, &OptionCount, sizeof (UINT16));
354 Key = 0x1234;
355 CopyMem (&OptionList[OptionCount].Key, &Key, sizeof (UINT16));
356 OptionList[OptionCount].Flags = EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS;
357 OptionCount++;
358 }
359
360 FreePool (LanguageString);
361
362 if (ReInitializeStrings) {
363 FreePool (OptionList);
364 return EFI_SUCCESS;
365 }
366
367 Status = CreateOneOfOpCode (
368 FRONT_PAGE_QUESTION_ID, // Question ID
369 FRONT_PAGE_DATA_WIDTH, // Data Width
370 (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT), // Prompt Token
371 (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), // Help Token
372 OptionList, // List of Options
373 OptionCount, // Number of Options
374 &UpdateData->Data // Data Buffer
375 );
376
377 //
378 // Assign the number of options and the oneof and endoneof op-codes to count
379 //
380 UpdateData->DataCount = (UINT8) (OptionCount + 2);
381
382 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);
383
384 FreePool (UpdateData);
385 //
386 // FreePool (OptionList);
387 //
388 return Status;
389 }
390
391 EFI_STATUS
392 CallFrontPage (
393 VOID
394 )
395 /*++
396
397 Routine Description:
398
399 Call the browser and display the front page
400
401 Arguments:
402
403 None
404
405 Returns:
406
407 --*/
408 {
409 EFI_STATUS Status;
410 UINT8 FakeNvRamMap[1];
411 BOOLEAN FrontPageMenuResetRequired;
412
413 //
414 // Begin waiting for USER INPUT
415 //
416 REPORT_STATUS_CODE (
417 EFI_PROGRESS_CODE,
418 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
419 );
420
421 FakeNvRamMap[0] = (UINT8) mLastSelection;
422 FrontPageMenuResetRequired = FALSE;
423 Status = gBrowser->SendForm (
424 gBrowser,
425 TRUE, // Use the database
426 &gFrontPageHandle, // The HII Handle
427 1,
428 NULL,
429 FrontPageCallbackHandle, // This is the handle that the interface to the callback was installed on
430 FakeNvRamMap,
431 NULL,
432 &FrontPageMenuResetRequired
433 );
434 //
435 // Check whether user change any option setting which needs a reset to be effective
436 //
437 if (FrontPageMenuResetRequired) {
438 EnableResetRequired ();
439 }
440
441 gHii->ResetStrings (gHii, gFrontPageHandle);
442
443 return Status;
444 }
445
446 EFI_STATUS
447 GetStringFromToken (
448 IN EFI_GUID *ProducerGuid,
449 IN STRING_REF Token,
450 OUT CHAR16 **String
451 )
452 /*++
453
454 Routine Description:
455
456 Acquire the string associated with the ProducerGuid and return it.
457
458 Arguments:
459
460 ProducerGuid - The Guid to search the HII database for
461 Token - The token value of the string to extract
462 String - The string that is extracted
463
464 Returns:
465
466 EFI_SUCCESS - The function returns EFI_SUCCESS always.
467
468 --*/
469 {
470 EFI_STATUS Status;
471 UINT16 HandleBufferLength;
472 EFI_HII_HANDLE *HiiHandleBuffer;
473 UINTN StringBufferLength;
474 UINTN NumberOfHiiHandles;
475 UINTN Index;
476 UINT16 Length;
477 EFI_GUID HiiGuid;
478
479 //
480 // Initialize params.
481 //
482 HandleBufferLength = 0;
483 HiiHandleBuffer = NULL;
484
485 //
486 // Get all the Hii handles
487 //
488 Status = BdsLibGetHiiHandles (gHii, &HandleBufferLength, &HiiHandleBuffer);
489 ASSERT_EFI_ERROR (Status);
490
491 //
492 // Get the gHii Handle that matches the StructureNode->ProducerName
493 //
494 NumberOfHiiHandles = HandleBufferLength / sizeof (EFI_HII_HANDLE);
495 for (Index = 0; Index < NumberOfHiiHandles; Index++) {
496 Length = 0;
497 Status = ExtractDataFromHiiHandle (
498 HiiHandleBuffer[Index],
499 &Length,
500 NULL,
501 &HiiGuid
502 );
503 if (CompareGuid (ProducerGuid, &HiiGuid)) {
504 break;
505 }
506 }
507 //
508 // Find the string based on the current language
509 //
510 StringBufferLength = 0x100;
511 *String = AllocateZeroPool (0x100);
512 Status = gHii->GetString (
513 gHii,
514 HiiHandleBuffer[Index],
515 Token,
516 FALSE,
517 NULL,
518 &StringBufferLength,
519 *String
520 );
521
522 if (EFI_ERROR (Status)) {
523 FreePool (*String);
524 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
525 }
526
527 FreePool (HiiHandleBuffer);
528 return EFI_SUCCESS;
529 }
530
531 VOID
532 ConvertProcessorToString (
533 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency,
534 OUT CHAR16 **String
535 )
536 /*++
537
538 Routine Description:
539
540 Convert Processor Frequency Data to a string
541
542 Arguments:
543
544 ProcessorFrequency - The frequency data to process
545 String - The string that is created
546
547 Returns:
548
549 --*/
550 {
551 CHAR16 *StringBuffer;
552 UINTN Index;
553 UINT32 FreqMhz;
554
555 if (ProcessorFrequency->Exponent >= 6) {
556 FreqMhz = ProcessorFrequency->Value;
557 for (Index = 0; Index < (UINTN) (ProcessorFrequency->Exponent - 6); Index++) {
558 FreqMhz *= 10;
559 }
560 } else {
561 FreqMhz = 0;
562 }
563
564 StringBuffer = AllocateZeroPool (0x20);
565 ASSERT (StringBuffer != NULL);
566 Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
567 StrCat (StringBuffer, L".");
568 UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
569 StrCat (StringBuffer, L" GHz");
570
571 *String = (CHAR16 *) StringBuffer;
572
573 return ;
574 }
575
576 VOID
577 ConvertMemorySizeToString (
578 IN UINT32 MemorySize,
579 OUT CHAR16 **String
580 )
581 /*++
582
583 Routine Description:
584
585 Convert Memory Size to a string
586
587 Arguments:
588
589 MemorySize - The size of the memory to process
590 String - The string that is created
591
592 Returns:
593
594 --*/
595 {
596 CHAR16 *StringBuffer;
597
598 StringBuffer = AllocateZeroPool (0x20);
599 ASSERT (StringBuffer != NULL);
600 UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
601 StrCat (StringBuffer, L" MB RAM");
602
603 *String = (CHAR16 *) StringBuffer;
604
605 return ;
606 }
607
608 VOID
609 UpdateFrontPageStrings (
610 VOID
611 )
612 /*++
613
614 Routine Description:
615
616 Update the banner information for the Front Page based on DataHub information
617
618 Arguments:
619
620 None
621
622 Returns:
623
624 --*/
625 {
626 EFI_STATUS Status;
627 STRING_REF TokenToUpdate;
628 CHAR16 *NewString;
629 UINT64 MonotonicCount;
630 EFI_DATA_HUB_PROTOCOL *DataHub;
631 EFI_DATA_RECORD_HEADER *Record;
632 EFI_SUBCLASS_TYPE1_HEADER *DataHeader;
633 EFI_MISC_BIOS_VENDOR_DATA *BiosVendor;
634 EFI_MISC_SYSTEM_MANUFACTURER_DATA *SystemManufacturer;
635 EFI_PROCESSOR_VERSION_DATA *ProcessorVersion;
636 EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency;
637 EFI_MEMORY_ARRAY_START_ADDRESS_DATA *MemoryArray;
638 CHAR8 LangCode[3];
639 CHAR16 Lang[3];
640 UINTN Size;
641 UINTN Index;
642 BOOLEAN Find[5];
643
644 ZeroMem (Find, sizeof (Find));
645
646 //
647 // Update Front Page strings
648 //
649 Status = gBS->LocateProtocol (
650 &gEfiDataHubProtocolGuid,
651 NULL,
652 &DataHub
653 );
654 ASSERT_EFI_ERROR (Status);
655
656 Size = 3;
657
658 Status = gRT->GetVariable (
659 L"Lang",
660 &gEfiGlobalVariableGuid,
661 NULL,
662 &Size,
663 LangCode
664 );
665
666 for (Index = 0; Index < 3; Index++) {
667 Lang[Index] = (CHAR16) LangCode[Index];
668 }
669
670 MonotonicCount = 0;
671 Record = NULL;
672 do {
673 Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);
674 if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {
675 DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
676 if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&
677 (DataHeader->RecordType == EFI_MISC_BIOS_VENDOR_RECORD_NUMBER)
678 ) {
679 BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1);
680 GetStringFromToken (&Record->ProducerName, BiosVendor->BiosVersion, &NewString);
681 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_BIOS_VERSION;
682 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
683 FreePool (NewString);
684 Find[0] = TRUE;
685 }
686
687 if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&
688 (DataHeader->RecordType == EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER)
689 ) {
690 SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1);
691 GetStringFromToken (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString);
692 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_COMPUTER_MODEL;
693 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
694 FreePool (NewString);
695 Find[1] = TRUE;
696 }
697
698 if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&
699 (DataHeader->RecordType == ProcessorVersionRecordType)
700 ) {
701 ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1);
702 GetStringFromToken (&Record->ProducerName, *ProcessorVersion, &NewString);
703 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_MODEL;
704 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
705 FreePool (NewString);
706 Find[2] = TRUE;
707 }
708
709 if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&
710 (DataHeader->RecordType == ProcessorCoreFrequencyRecordType)
711 ) {
712 ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1);
713 ConvertProcessorToString (ProcessorFrequency, &NewString);
714 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_SPEED;
715 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
716 FreePool (NewString);
717 Find[3] = TRUE;
718 }
719
720 if (CompareGuid (&Record->DataRecordGuid, &mMemorySubClass) &&
721 (DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER)
722 ) {
723 MemoryArray = (EFI_MEMORY_ARRAY_START_ADDRESS_DATA *) (DataHeader + 1);
724 ConvertMemorySizeToString((UINT32)(RShiftU64((MemoryArray->MemoryArrayEndAddress -
725 MemoryArray->MemoryArrayStartAddress + 1), 20)),
726 &NewString);
727 TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_MEMORY_SIZE;
728 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
729 FreePool (NewString);
730 Find[4] = TRUE;
731 }
732 }
733 } while (!EFI_ERROR (Status) && (MonotonicCount != 0) && !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));
734
735 return ;
736 }
737
738 VOID
739 PlatformBdsEnterFrontPage (
740 IN UINT16 TimeoutDefault,
741 IN BOOLEAN ConnectAllHappened
742 )
743 /*++
744
745 Routine Description:
746 This function is the main entry of the platform setup entry.
747 The function will present the main menu of the system setup,
748 this is the platform reference part and can be customize.
749
750 Arguments:
751 TimeoutDefault - The fault time out value before the system
752 continue to boot.
753 ConnectAllHappened - The indicater to check if the connect all have
754 already happended.
755
756 Returns:
757 None
758
759 --*/
760 {
761 EFI_STATUS Status;
762 EFI_HII_UPDATE_DATA *UpdateData;
763 EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
764
765 //
766 // Indicate if we need connect all in the platform setup
767 //
768 if (ConnectAllHappened) {
769 gConnectAllHappened = TRUE;
770 }
771 //
772 // Allocate space for creation of Buffer
773 //
774 UpdateData = AllocateZeroPool (0x1000);
775 ASSERT (UpdateData != NULL);
776
777 UpdateData->FormSetUpdate = FALSE;
778 UpdateData->FormCallbackHandle = 0;
779 UpdateData->FormUpdate = FALSE;
780 UpdateData->FormTitle = 0;
781 UpdateData->DataCount = 1;
782
783 //
784 // Remove Banner Op-code if any at this label
785 //
786 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, FALSE, UpdateData);
787
788 //
789 // Create Banner Op-code which reflects correct timeout value
790 //
791 CreateBannerOpCode (
792 STRING_TOKEN (STR_TIME_OUT_PROMPT),
793 TimeoutDefault,
794 (UINT8) EFI_IFR_BANNER_TIMEOUT,
795 &UpdateData->Data
796 );
797
798 //
799 // Add Banner Op-code at this label
800 //
801 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, TRUE, UpdateData);
802
803 do {
804
805 InitializeFrontPage (TRUE);
806
807 //
808 // Update Front Page strings
809 //
810 UpdateFrontPageStrings ();
811
812 gCallbackKey = 0;
813 PERF_START (0, "BdsTimeOut", "BDS", 0);
814 Status = CallFrontPage ();
815 PERF_END (0, "BdsTimeOut", "BDS", 0);
816
817 //
818 // If gCallbackKey is greater than 1 and less or equal to 5,
819 // it will lauch configuration utilities.
820 // 2 = set language
821 // 3 = boot manager
822 // 4 = device manager
823 // 5 = boot maintainenance manager
824 //
825 if ((gCallbackKey > 0x0001) && (gCallbackKey <= 0x0005)) {
826 REPORT_STATUS_CODE (
827 EFI_PROGRESS_CODE,
828 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
829 );
830 }
831 //
832 // Based on the key that was set, we can determine what to do
833 //
834 switch (gCallbackKey) {
835 //
836 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
837 // describe to their customers in documentation how to find their setup information (namely
838 // under the device manager and specific buckets)
839 //
840 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
841 //
842 case 0x0001:
843 //
844 // User hit continue
845 //
846 break;
847
848 case 0x0002:
849 //
850 // User made a language setting change - display front page again
851 //
852 break;
853
854 case 0x0003:
855 //
856 // User chose to run the Boot Manager
857 //
858 CallBootManager ();
859 break;
860
861 case 0x0004:
862 //
863 // Display the Device Manager
864 //
865 do {
866 CallDeviceManager();
867 } while (gCallbackKey == 4);
868 break;
869
870 case 0x0005:
871 //
872 // Display the Boot Maintenance Manager
873 //
874 BdsStartBootMaint ();
875 break;
876 }
877
878 } while ((Status == EFI_SUCCESS) && (gCallbackKey != 1));
879
880 //
881 //Will leave browser, check any reset required change is applied? if yes, reset system
882 //
883 SetupResetReminder ();
884
885 //
886 // Automatically load current entry
887 // Note: The following lines of code only execute when Auto boot
888 // takes affect
889 //
890 Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);
891 ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);
892
893 }