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