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