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