summaryrefslogtreecommitdiff
path: root/Nt32Pkg/PlatformBdsDxe/Generic/FrontPage.c
blob: 9ed9bfd38c7c85ed6d0ab59e27713d315f602710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
/*++

Copyright (c) 2006 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Module Name:

  FrontPage.c

Abstract:

  FrontPage routines to handle the callbacks and browser calls

--*/
#include "Bds.h"
#include "BdsPlatform.h"
#include "FrontPage.h"
#include "BdsString.h"

EFI_GUID                    mProcessorSubClass  = EFI_PROCESSOR_SUBCLASS_GUID;
EFI_GUID                    mMemorySubClass     = EFI_MEMORY_SUBCLASS_GUID;
EFI_GUID                    mMiscSubClass       = EFI_MISC_SUBCLASS_GUID;

UINT16                      mLastSelection;
EFI_HII_HANDLE              gFrontPageHandle;
EFI_HANDLE                  FrontPageCallbackHandle;
EFI_FORM_CALLBACK_PROTOCOL  FrontPageCallback;
EFI_FORM_BROWSER_PROTOCOL   *gBrowser;
UINTN                       gCallbackKey;
BOOLEAN                     gConnectAllHappened = FALSE;

extern EFI_HII_HANDLE       gFrontPageHandle;

EFI_STATUS
EFIAPI
FrontPageCallbackRoutine (
  IN EFI_FORM_CALLBACK_PROTOCOL       *This,
  IN UINT16                           KeyValue,
  IN EFI_IFR_DATA_ARRAY               *DataArray,
  OUT EFI_HII_CALLBACK_PACKET         **Packet
  )
/*++

Routine Description:

  This is the function that is called to provide results data to the driver.  This data
  consists of a unique key which is used to identify what data is either being passed back
  or being asked for.

Arguments:

  KeyValue -        A unique value which is sent to the original exporting driver so that it
                    can identify the type of data to expect.  The format of the data tends to
                    vary based on the op-code that geerated the callback.

  Data -            A pointer to the data being sent to the original exporting driver.

Returns:

--*/
{
  CHAR16        *LanguageString;
  UINTN         Count;
  CHAR16        UnicodeLang[3];
  CHAR8         Lang[3];
  EFI_STATUS    Status;
  UINTN         Index;
  CHAR16        *TmpStr;
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;

  SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
  SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
  SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);

  Count = 0;

  //
  // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
  // describe to their customers in documentation how to find their setup information (namely
  // under the device manager and specific buckets)
  //
  switch (KeyValue) {
  case 0x0001:
    //
    // This is the continue - clear the screen and return an error to get out of FrontPage loop
    //
    gCallbackKey = 1;
    break;

  case 0x1234:
    //
    // Collect the languages from what our current Language support is based on our VFR
    //
    gHii->GetPrimaryLanguages (gHii, gFrontPageHandle, &LanguageString);

    //
    // Based on the DataArray->Data->Data value, we can determine
    // which language was chosen by the user
    //
    for (Index = 0; Count != (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray + 1))->Data); Index += 3) {
      Count++;
    }
    //
    // Preserve the choice the user made
    //
    mLastSelection = (UINT16) Count;

    //
    // The Language (in Unicode format) the user chose
    //
    CopyMem (UnicodeLang, &LanguageString[Index], 6);

    //
    // Convert Unicode to ASCII (Since the ISO standard assumes ASCII equivalent abbreviations
    // we can be safe in converting this Unicode stream to ASCII without any loss in meaning.
    //
    for (Index = 0; Index < 3; Index++) {
      Lang[Index] = (CHAR8) UnicodeLang[Index];
    }

    Status = gRT->SetVariable (
                    L"Lang",
                    &gEfiGlobalVariableGuid,
                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
                    3,
                    Lang
                    );

    FreePool (LanguageString);
    gCallbackKey = 2;
    break;

  case 0x1064:
    //
    // Boot Manager
    //
    gCallbackKey = 3;
    break;

  case 0x8567:
    //
    // Device Manager
    //
    gCallbackKey = 4;
    break;

  case 0x9876:
    //
    // Boot Maintenance Manager
    //
    gCallbackKey = 5;
    break;

  case 0xFFFE:

    break;

  case 0xFFFF:
    //
    // FrontPage TimeOut Callback
    //
    TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));
    if (TmpStr != NULL) {
      PlatformBdsShowProgress (
        Foreground,
        Background,
        TmpStr,
        Color,
        (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray+1))->Data),
        0
        );
      FreePool (TmpStr);
    }
    break;

  default:
    gCallbackKey = 0;
    break;
  }

  return EFI_SUCCESS;
}

EFI_STATUS
InitializeFrontPage (
  BOOLEAN                         ReInitializeStrings
  )
/*++

Routine Description:

  Initialize HII information for the FrontPage

Arguments:
  None

Returns:
  EFI_SUCCESS       - The operation is successful.
  EFI_DEVICE_ERROR  - If the dynamic opcode creation failed.

--*/
{
  EFI_STATUS          Status;
  EFI_HII_PACKAGES    *PackageList;
  EFI_HII_UPDATE_DATA *UpdateData;
  IFR_OPTION          *OptionList;
  CHAR16              *LanguageString;
  UINTN               OptionCount;
  UINTN               Index;
  STRING_REF          Token;
  UINT16              Key;
  CHAR8               AsciiLang[4];
  CHAR16              UnicodeLang[4];
  CHAR16              Lang[4];
  CHAR16              *StringBuffer;
  UINTN               BufferSize;
  UINT8               *TempBuffer;

  UpdateData  = NULL;
  OptionList  = NULL;

  if (ReInitializeStrings) {
    //
    // BugBug: Dont' use a goto
    //
    goto ReInitStrings;
  }
  //
  // Go ahead and initialize the Device Manager
  //
  InitializeDeviceManager ();

  //
  // BugBug: if FrontPageVfrBin is generated by a tool, why are we patching it here
  //
  TempBuffer    = (UINT8 *) FrontPageVfrBin;
  TempBuffer    = TempBuffer + sizeof (EFI_HII_PACK_HEADER);
  TempBuffer    = (UINT8 *) &((EFI_IFR_FORM_SET *) TempBuffer)->NvDataSize;
  *TempBuffer   = 1;

  gCallbackKey  = 0;

  PackageList   = PreparePackages (1, &gEfiCallerIdGuid, FrontPageVfrBin);

  Status        = gHii->NewPack (gHii, PackageList, &gFrontPageHandle);

  FreePool (PackageList);

  //
  // There will be only one FormConfig in the system
  // If there is another out there, someone is trying to install us
  // again.  Fail that scenario.
  //
  Status = gBS->LocateProtocol (
                  &gEfiFormBrowserProtocolGuid,
                  NULL,
                  &gBrowser
                  );

  //
  // This example does not implement worker functions
  // for the NV accessor functions.  Only a callback evaluator
  //
  FrontPageCallback.NvRead    = NULL;
  FrontPageCallback.NvWrite   = NULL;
  FrontPageCallback.Callback  = FrontPageCallbackRoutine;

  //
  // Install protocol interface
  //
  FrontPageCallbackHandle = NULL;
  Status = gBS->InstallProtocolInterface (
                  &FrontPageCallbackHandle,
                  &gEfiFormCallbackProtocolGuid,
                  EFI_NATIVE_INTERFACE,
                  &FrontPageCallback
                  );
  ASSERT_EFI_ERROR (Status);

ReInitStrings:
  //
  // BugBug: This logic is in BdsInitLanguage. It should not be in two places!
  //
  BufferSize = 4;
  Status = gRT->GetVariable (
                  L"Lang",
                  &gEfiGlobalVariableGuid,
                  NULL,
                  &BufferSize,
                  AsciiLang
                  );

  for (Index = 0; Index < 3; Index++) {
    UnicodeLang[Index] = (CHAR16) AsciiLang[Index];
  }

  UnicodeLang[3] = 0;

  //
  // Allocate space for creation of UpdateData Buffer
  //
  UpdateData = AllocateZeroPool (0x1000);
  ASSERT (UpdateData != NULL);

  OptionList = AllocateZeroPool (0x1000);
  ASSERT (OptionList != NULL);

  //
  // Flag update pending in FormSet
  //
  UpdateData->FormSetUpdate = TRUE;
  //
  // Register CallbackHandle data for FormSet
  //
  UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) FrontPageCallbackHandle;
  UpdateData->FormUpdate  = FALSE;
  UpdateData->FormTitle   = 0;
  UpdateData->DataCount   = 1;

  //
  // Collect the languages from what our current Language support is based on our VFR
  //
  gHii->GetPrimaryLanguages (gHii, gFrontPageHandle, &LanguageString);

  OptionCount = 0;

  for (Index = 0; LanguageString[Index] != 0; Index += 3) {
    Token = 0;
    CopyMem (Lang, &LanguageString[Index], 6);
    Lang[3] = 0;

    if (!StrCmp (Lang, UnicodeLang)) {
      mLastSelection = (UINT16) OptionCount;
    }

    BufferSize = 0;
    Status = gHii->GetString (gHii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, NULL);
    ASSERT (Status == EFI_BUFFER_TOO_SMALL);
    StringBuffer = AllocateZeroPool (BufferSize);
    ASSERT (StringBuffer != NULL);
    Status = gHii->GetString (gHii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, StringBuffer);
    ASSERT_EFI_ERROR (Status);
    gHii->NewString (gHii, NULL, gStringPackHandle, &Token, StringBuffer);
    FreePool (StringBuffer);
    CopyMem (&OptionList[OptionCount].StringToken, &Token, sizeof (UINT16));
    CopyMem (&OptionList[OptionCount].Value, &OptionCount, sizeof (UINT16));
    Key = 0x1234;
    CopyMem (&OptionList[OptionCount].Key, &Key, sizeof (UINT16));
    OptionList[OptionCount].Flags = EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS;
    OptionCount++;
  }

  FreePool (LanguageString);

  if (ReInitializeStrings) {
    FreePool (OptionList);
    return EFI_SUCCESS;
  }

  Status = CreateOneOfOpCode (
            FRONT_PAGE_QUESTION_ID,                               // Question ID
            FRONT_PAGE_DATA_WIDTH,                                // Data Width
            (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT),      // Prompt Token
            (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), // Help Token
            OptionList,       // List of Options
            OptionCount,      // Number of Options
            &UpdateData->Data // Data Buffer
            );

  //
  // Assign the number of options and the oneof and endoneof op-codes to count
  //
  UpdateData->DataCount = (UINT8) (OptionCount + 2);

  gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);

  FreePool (UpdateData);
  FreePool (OptionList);
  return Status;
}

EFI_STATUS
CallFrontPage (
  VOID
  )
/*++

Routine Description:

  Call the browser and display the front page

Arguments:

  None

Returns:

--*/
{
  EFI_STATUS  Status;
  UINT8       FakeNvRamMap[1];
  BOOLEAN     FrontPageMenuResetRequired;

  //
  // Begin waiting for USER INPUT
  //
  REPORT_STATUS_CODE (
        EFI_PROGRESS_CODE,
        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
        );

  FakeNvRamMap[0] = (UINT8) mLastSelection;
  FrontPageMenuResetRequired = FALSE;
  Status = gBrowser->SendForm (
                      gBrowser,
                      TRUE,                     // Use the database
                      &gFrontPageHandle,        // The HII Handle
                      1,
                      NULL,
                      FrontPageCallbackHandle,  // This is the handle that the interface to the callback was installed on
                      FakeNvRamMap,
                      NULL,
                      &FrontPageMenuResetRequired
                      );
  //
  // Check whether user change any option setting which needs a reset to be effective
  //
  if (FrontPageMenuResetRequired) {
    EnableResetRequired ();
  }

  gHii->ResetStrings (gHii, gFrontPageHandle);

  return Status;
}

EFI_STATUS
GetStringFromToken (
  IN      EFI_GUID                  *ProducerGuid,
  IN      STRING_REF                Token,
  OUT     CHAR16                    **String
  )
/*++

Routine Description:

  Acquire the string associated with the ProducerGuid and return it.

Arguments:

  ProducerGuid - The Guid to search the HII database for
  Token - The token value of the string to extract
  String - The string that is extracted

Returns:

  EFI_SUCCESS - The function returns EFI_SUCCESS always.

--*/
{
  EFI_STATUS      Status;
  UINT16          HandleBufferLength;
  EFI_HII_HANDLE  *HiiHandleBuffer;
  UINTN           StringBufferLength;
  UINTN           NumberOfHiiHandles;
  UINTN           Index;
  UINT16          Length;
  EFI_GUID        HiiGuid;

  //
  // Initialize params.
  //
  HandleBufferLength  = 0;
  HiiHandleBuffer     = NULL;

  //
  // Get all the Hii handles
  //
  Status = BdsLibGetHiiHandles (gHii, &HandleBufferLength, &HiiHandleBuffer);
  ASSERT_EFI_ERROR (Status);

  //
  // Get the gHii Handle that matches the StructureNode->ProducerName
  //
  NumberOfHiiHandles = HandleBufferLength / sizeof (EFI_HII_HANDLE);
  for (Index = 0; Index < NumberOfHiiHandles; Index++) {
    Length = 0;
    Status = ExtractDataFromHiiHandle (
              HiiHandleBuffer[Index],
              &Length,
              NULL,
              &HiiGuid
              );
    if (CompareGuid (ProducerGuid, &HiiGuid)) {
      break;
    }
  }
  //
  // Find the string based on the current language
  //
  StringBufferLength  = 0x100;
  *String             = AllocateZeroPool (0x100);
  Status = gHii->GetString (
                  gHii,
                  HiiHandleBuffer[Index],
                  Token,
                  FALSE,
                  NULL,
                  &StringBufferLength,
                  *String
                  );

  if (EFI_ERROR (Status)) {
    FreePool (*String);
    *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
  }

  FreePool (HiiHandleBuffer);
  return EFI_SUCCESS;
}

VOID
ConvertProcessorToString (
  IN  EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency,
  OUT CHAR16                            **String
  )
/*++

Routine Description:

  Convert Processor Frequency Data to a string

Arguments:

  ProcessorFrequency - The frequency data to process
  String - The string that is created

Returns:

--*/
{
  CHAR16  *StringBuffer;
  UINTN   Index;
  UINT32  FreqMhz;

  if (ProcessorFrequency->Exponent >= 6) {
    FreqMhz = ProcessorFrequency->Value;
    for (Index = 0; Index < (UINTN) (ProcessorFrequency->Exponent - 6); Index++) {
      FreqMhz *= 10;
    }
  } else {
    FreqMhz = 0;
  }

  StringBuffer = AllocateZeroPool (0x20);
  ASSERT (StringBuffer != NULL);
  Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
  StrCat (StringBuffer, L".");
  UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
  StrCat (StringBuffer, L" GHz");

  *String = (CHAR16 *) StringBuffer;

  return ;
}

VOID
ConvertMemorySizeToString (
  IN  UINT32          MemorySize,
  OUT CHAR16          **String
  )
/*++

Routine Description:

  Convert Memory Size to a string

Arguments:

  MemorySize - The size of the memory to process
  String - The string that is created

Returns:

--*/
{
  CHAR16  *StringBuffer;

  StringBuffer = AllocateZeroPool (0x20);
  ASSERT (StringBuffer != NULL);
  UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
  StrCat (StringBuffer, L" MB RAM");

  *String = (CHAR16 *) StringBuffer;

  return ;
}

VOID
UpdateFrontPageStrings (
  VOID
  )
/*++

Routine Description:

  Update the banner information for the Front Page based on DataHub information

Arguments:

  None

Returns:

--*/
{
  EFI_STATUS                        Status;
  STRING_REF                        TokenToUpdate;
  CHAR16                            *NewString;
  UINT64                            MonotonicCount;
  EFI_DATA_HUB_PROTOCOL             *DataHub;
  EFI_DATA_RECORD_HEADER            *Record;
  EFI_SUBCLASS_TYPE1_HEADER         *DataHeader;
  EFI_MISC_BIOS_VENDOR_DATA         *BiosVendor;
  EFI_MISC_SYSTEM_MANUFACTURER_DATA *SystemManufacturer;
  EFI_PROCESSOR_VERSION_DATA        *ProcessorVersion;
  EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency;
  EFI_MEMORY_ARRAY_START_ADDRESS_DATA *MemoryArray;
  CHAR8                             LangCode[3];
  CHAR16                            Lang[3];
  UINTN                             Size;
  UINTN                             Index;
  BOOLEAN                           Find[5];

  ZeroMem (Find, sizeof (Find));

  //
  // Update Front Page strings
  //
  Status = gBS->LocateProtocol (
                  &gEfiDataHubProtocolGuid,
                  NULL,
                  &DataHub
                  );
  ASSERT_EFI_ERROR (Status);

  Size = 3;

  Status = gRT->GetVariable (
                  L"Lang",
                  &gEfiGlobalVariableGuid,
                  NULL,
                  &Size,
                  LangCode
                  );

  for (Index = 0; Index < 3; Index++) {
    Lang[Index] = (CHAR16) LangCode[Index];
  }

  MonotonicCount  = 0;
  Record          = NULL;
  do {
    Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record);
    if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {
      DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
      if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&
          (DataHeader->RecordType == EFI_MISC_BIOS_VENDOR_RECORD_NUMBER)
          ) {
        BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1);
        GetStringFromToken (&Record->ProducerName, BiosVendor->BiosVersion, &NewString);
        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_BIOS_VERSION;
        gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
        FreePool (NewString);
        Find[0] = TRUE;
      }

      if (CompareGuid (&Record->DataRecordGuid, &mMiscSubClass) &&
          (DataHeader->RecordType == EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER)
          ) {
        SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1);
        GetStringFromToken (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString);
        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_COMPUTER_MODEL;
        gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
        FreePool (NewString);
        Find[1] = TRUE;
      }

      if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&
          (DataHeader->RecordType == ProcessorVersionRecordType)
          ) {
        ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1);
        GetStringFromToken (&Record->ProducerName, *ProcessorVersion, &NewString);
        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_MODEL;
        gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
        FreePool (NewString);
        Find[2] = TRUE;
      }

      if (CompareGuid (&Record->DataRecordGuid, &mProcessorSubClass) &&
          (DataHeader->RecordType == ProcessorCoreFrequencyRecordType)
          ) {
        ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1);
        ConvertProcessorToString (ProcessorFrequency, &NewString);
        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_CPU_SPEED;
        gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
        FreePool (NewString);
        Find[3] = TRUE;
      }

      if (CompareGuid (&Record->DataRecordGuid, &mMemorySubClass) &&
          (DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER)
          ) {
        MemoryArray = (EFI_MEMORY_ARRAY_START_ADDRESS_DATA *) (DataHeader + 1);
        ConvertMemorySizeToString((UINT32)(RShiftU64((MemoryArray->MemoryArrayEndAddress -
                                  MemoryArray->MemoryArrayStartAddress + 1), 20)),
                                  &NewString);
        TokenToUpdate = (STRING_REF) STR_FRONT_PAGE_MEMORY_SIZE;
        gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);
        FreePool (NewString);
        Find[4] = TRUE;
      }
    }
  } while (!EFI_ERROR (Status) && (MonotonicCount != 0) && !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));

  return ;
}

VOID
PlatformBdsEnterFrontPage (
  IN UINT16                       TimeoutDefault,
  IN BOOLEAN                      ConnectAllHappened
  )
/*++

Routine Description:
  This function is the main entry of the platform setup entry.
  The function will present the main menu of the system setup,
  this is the platform reference part and can be customize.

Arguments:
  TimeoutDefault     - The fault time out value before the system
                       continue to boot.
  ConnectAllHappened - The indicater to check if the connect all have
                       already happended.

Returns:
  None

--*/
{
  EFI_STATUS                    Status;
  EFI_HII_UPDATE_DATA           *UpdateData;
  EFI_CONSOLE_CONTROL_PROTOCOL  *ConsoleControl;

  //
  // Indicate if we need connect all in the platform setup
  //
  if (ConnectAllHappened) {
    gConnectAllHappened = TRUE;
  }
  //
  // Allocate space for creation of Buffer
  //
  UpdateData = AllocateZeroPool (0x1000);
  ASSERT (UpdateData != NULL);

  UpdateData->FormSetUpdate       = FALSE;
  UpdateData->FormCallbackHandle  = 0;
  UpdateData->FormUpdate          = FALSE;
  UpdateData->FormTitle           = 0;
  UpdateData->DataCount           = 1;

  //
  // Remove Banner Op-code if any at this label
  //
  gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, FALSE, UpdateData);

  //
  // Create Banner Op-code which reflects correct timeout value
  //
  CreateBannerOpCode (
    STRING_TOKEN (STR_TIME_OUT_PROMPT),
    TimeoutDefault,
    (UINT8) EFI_IFR_BANNER_TIMEOUT,
    &UpdateData->Data
    );

  //
  // Add Banner Op-code at this label
  //
  gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, TRUE, UpdateData);

  do {

    InitializeFrontPage (TRUE);

    //
    // Update Front Page strings
    //
    UpdateFrontPageStrings ();

    gCallbackKey = 0;
    PERF_START (0, "BdsTimeOut", "BDS", 0);
    Status = CallFrontPage ();
    PERF_END (0, "BdsTimeOut", "BDS", 0);

    //
    // If gCallbackKey is greater than 1 and less or equal to 5,
    // it will lauch configuration utilities.
    // 2 = set language
    // 3 = boot manager
    // 4 = device manager
    // 5 = boot maintainenance manager
    //
    if ((gCallbackKey > 0x0001) && (gCallbackKey <= 0x0005)) {
      REPORT_STATUS_CODE (
            EFI_PROGRESS_CODE,
            (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
            );
    }
    //
    // Based on the key that was set, we can determine what to do
    //
    switch (gCallbackKey) {
    //
    // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
    // describe to their customers in documentation how to find their setup information (namely
    // under the device manager and specific buckets)
    //
    // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
    //
    case 0x0001:
      //
      // User hit continue
      //
      break;

    case 0x0002:
      //
      // User made a language setting change - display front page again
      //
      break;

    case 0x0003:
      //
      // User chose to run the Boot Manager
      //
      CallBootManager ();
      break;

    case 0x0004:
      //
      // Display the Device Manager
      //
      do {
        CallDeviceManager();
      } while (gCallbackKey == 4);
      break;

    case 0x0005:
      //
      // Display the Boot Maintenance Manager
      //
      BdsStartBootMaint ();
      break;
    }

  } while ((Status == EFI_SUCCESS) && (gCallbackKey != 1));

  //
  //Will leave browser, check any reset required change is applied? if yes, reset system
  //
  SetupResetReminder ();

  //
  // Automatically load current entry
  // Note: The following lines of code only execute when Auto boot
  // takes affect
  //
  Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);
  ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);

}