]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/PlatformBdsDxe/Generic/FrontPage.c
Correct a bug that allocate a fix size buffer as input buffer for Hii->GetString...
[mirror_edk2.git] / Nt32Pkg / PlatformBdsDxe / Generic / FrontPage.c
CommitLineData
bc11b829 1/*++\r
2\r
3Copyright (c) 2006 - 2007, 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
bc11b829 21#include "Bds.h"\r
22#include "BdsPlatform.h"\r
23#include "FrontPage.h"\r
06335580 24#include "BdsString.h"\r
bc11b829 25\r
26EFI_GUID mProcessorSubClass = EFI_PROCESSOR_SUBCLASS_GUID;\r
27EFI_GUID mMemorySubClass = EFI_MEMORY_SUBCLASS_GUID;\r
28EFI_GUID mMiscSubClass = EFI_MISC_SUBCLASS_GUID;\r
29\r
30UINT16 mLastSelection;\r
31EFI_HII_HANDLE gFrontPageHandle;\r
32EFI_HANDLE FrontPageCallbackHandle;\r
33EFI_FORM_CALLBACK_PROTOCOL FrontPageCallback;\r
34EFI_FORM_BROWSER_PROTOCOL *gBrowser;\r
35UINTN gCallbackKey;\r
36BOOLEAN gConnectAllHappened = FALSE;\r
37\r
38extern EFI_HII_HANDLE gFrontPageHandle;\r
bc11b829 39\r
40EFI_STATUS\r
41EFIAPI\r
42FrontPageCallbackRoutine (\r
43 IN EFI_FORM_CALLBACK_PROTOCOL *This,\r
44 IN UINT16 KeyValue,\r
45 IN EFI_IFR_DATA_ARRAY *DataArray,\r
46 OUT EFI_HII_CALLBACK_PACKET **Packet\r
47 )\r
48/*++\r
49\r
50Routine Description:\r
51\r
52 This is the function that is called to provide results data to the driver. This data\r
53 consists of a unique key which is used to identify what data is either being passed back\r
54 or being asked for.\r
55\r
56Arguments:\r
57\r
58 KeyValue - A unique value which is sent to the original exporting driver so that it\r
59 can identify the type of data to expect. The format of the data tends to\r
60 vary based on the op-code that geerated the callback.\r
61\r
62 Data - A pointer to the data being sent to the original exporting driver.\r
63\r
64Returns:\r
65\r
66--*/\r
67{\r
68 CHAR16 *LanguageString;\r
69 UINTN Count;\r
70 CHAR16 UnicodeLang[3];\r
71 CHAR8 Lang[3];\r
72 EFI_STATUS Status;\r
73 UINTN Index;\r
74 CHAR16 *TmpStr;\r
75 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
76 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
77 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
78\r
79 SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
80 SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
81 SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
82\r
83 Count = 0;\r
84\r
85 //\r
86 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
87 // describe to their customers in documentation how to find their setup information (namely\r
88 // under the device manager and specific buckets)\r
89 //\r
90 switch (KeyValue) {\r
91 case 0x0001:\r
92 //\r
93 // This is the continue - clear the screen and return an error to get out of FrontPage loop\r
94 //\r
95 gCallbackKey = 1;\r
96 break;\r
97\r
98 case 0x1234:\r
99 //\r
100 // Collect the languages from what our current Language support is based on our VFR\r
101 //\r
d1477e4d 102 gHii->GetPrimaryLanguages (gHii, gFrontPageHandle, &LanguageString);\r
bc11b829 103\r
104 //\r
105 // Based on the DataArray->Data->Data value, we can determine\r
106 // which language was chosen by the user\r
107 //\r
108 for (Index = 0; Count != (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray + 1))->Data); Index += 3) {\r
109 Count++;\r
110 }\r
111 //\r
112 // Preserve the choice the user made\r
113 //\r
114 mLastSelection = (UINT16) Count;\r
115\r
116 //\r
117 // The Language (in Unicode format) the user chose\r
118 //\r
119 CopyMem (UnicodeLang, &LanguageString[Index], 6);\r
120\r
121 //\r
122 // Convert Unicode to ASCII (Since the ISO standard assumes ASCII equivalent abbreviations\r
123 // we can be safe in converting this Unicode stream to ASCII without any loss in meaning.\r
124 //\r
125 for (Index = 0; Index < 3; Index++) {\r
126 Lang[Index] = (CHAR8) UnicodeLang[Index];\r
127 }\r
128\r
129 Status = gRT->SetVariable (\r
130 L"Lang",\r
131 &gEfiGlobalVariableGuid,\r
132 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
133 3,\r
134 Lang\r
135 );\r
136\r
137 FreePool (LanguageString);\r
138 gCallbackKey = 2;\r
139 break;\r
140\r
141 case 0x1064:\r
142 //\r
143 // Boot Manager\r
144 //\r
145 gCallbackKey = 3;\r
146 break;\r
147\r
148 case 0x8567:\r
149 //\r
150 // Device Manager\r
151 //\r
152 gCallbackKey = 4;\r
153 break;\r
154\r
155 case 0x9876:\r
156 //\r
157 // Boot Maintenance Manager\r
158 //\r
159 gCallbackKey = 5;\r
160 break;\r
161\r
162 case 0xFFFE:\r
163\r
164 break;\r
165\r
166 case 0xFFFF:\r
167 //\r
168 // FrontPage TimeOut Callback\r
169 //\r
170 TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));\r
171 if (TmpStr != NULL) {\r
172 PlatformBdsShowProgress (\r
173 Foreground,\r
174 Background,\r
175 TmpStr,\r
176 Color,\r
177 (UINTN) (((EFI_IFR_DATA_ENTRY *) (DataArray+1))->Data),\r
178 0\r
179 );\r
180 FreePool (TmpStr);\r
181 }\r
182 break;\r
183\r
184 default:\r
185 gCallbackKey = 0;\r
186 break;\r
187 }\r
188\r
189 return EFI_SUCCESS;\r
190}\r
191\r
192EFI_STATUS\r
193InitializeFrontPage (\r
194 BOOLEAN ReInitializeStrings\r
195 )\r
196/*++\r
197\r
198Routine Description:\r
199\r
200 Initialize HII information for the FrontPage\r
201\r
202Arguments:\r
203 None\r
204\r
205Returns:\r
206 EFI_SUCCESS - The operation is successful.\r
207 EFI_DEVICE_ERROR - If the dynamic opcode creation failed.\r
208\r
209--*/\r
210{\r
211 EFI_STATUS Status;\r
212 EFI_HII_PACKAGES *PackageList;\r
213 EFI_HII_UPDATE_DATA *UpdateData;\r
214 IFR_OPTION *OptionList;\r
215 CHAR16 *LanguageString;\r
216 UINTN OptionCount;\r
217 UINTN Index;\r
218 STRING_REF Token;\r
219 UINT16 Key;\r
220 CHAR8 AsciiLang[4];\r
221 CHAR16 UnicodeLang[4];\r
222 CHAR16 Lang[4];\r
223 CHAR16 *StringBuffer;\r
224 UINTN BufferSize;\r
225 UINT8 *TempBuffer;\r
226\r
227 UpdateData = NULL;\r
228 OptionList = NULL;\r
229\r
230 if (ReInitializeStrings) {\r
231 //\r
232 // BugBug: Dont' use a goto\r
233 //\r
234 goto ReInitStrings;\r
235 }\r
236 //\r
237 // Go ahead and initialize the Device Manager\r
238 //\r
239 InitializeDeviceManager ();\r
240\r
241 //\r
242 // BugBug: if FrontPageVfrBin is generated by a tool, why are we patching it here\r
243 //\r
244 TempBuffer = (UINT8 *) FrontPageVfrBin;\r
245 TempBuffer = TempBuffer + sizeof (EFI_HII_PACK_HEADER);\r
246 TempBuffer = (UINT8 *) &((EFI_IFR_FORM_SET *) TempBuffer)->NvDataSize;\r
247 *TempBuffer = 1;\r
248\r
249 gCallbackKey = 0;\r
250\r
d1477e4d 251 PackageList = PreparePackages (1, &gEfiCallerIdGuid, FrontPageVfrBin);\r
bc11b829 252\r
d1477e4d 253 Status = gHii->NewPack (gHii, PackageList, &gFrontPageHandle);\r
bc11b829 254\r
255 FreePool (PackageList);\r
256\r
257 //\r
258 // There will be only one FormConfig in the system\r
259 // If there is another out there, someone is trying to install us\r
260 // again. Fail that scenario.\r
261 //\r
262 Status = gBS->LocateProtocol (\r
263 &gEfiFormBrowserProtocolGuid,\r
264 NULL,\r
265 &gBrowser\r
266 );\r
267\r
268 //\r
269 // This example does not implement worker functions\r
270 // for the NV accessor functions. Only a callback evaluator\r
271 //\r
272 FrontPageCallback.NvRead = NULL;\r
273 FrontPageCallback.NvWrite = NULL;\r
274 FrontPageCallback.Callback = FrontPageCallbackRoutine;\r
275\r
276 //\r
277 // Install protocol interface\r
278 //\r
279 FrontPageCallbackHandle = NULL;\r
280 Status = gBS->InstallProtocolInterface (\r
281 &FrontPageCallbackHandle,\r
282 &gEfiFormCallbackProtocolGuid,\r
283 EFI_NATIVE_INTERFACE,\r
284 &FrontPageCallback\r
285 );\r
286 ASSERT_EFI_ERROR (Status);\r
287\r
288ReInitStrings:\r
289 //\r
290 // BugBug: This logic is in BdsInitLanguage. It should not be in two places!\r
291 //\r
292 BufferSize = 4;\r
293 Status = gRT->GetVariable (\r
294 L"Lang",\r
295 &gEfiGlobalVariableGuid,\r
296 NULL,\r
297 &BufferSize,\r
298 AsciiLang\r
299 );\r
300\r
301 for (Index = 0; Index < 3; Index++) {\r
302 UnicodeLang[Index] = (CHAR16) AsciiLang[Index];\r
303 }\r
304\r
305 UnicodeLang[3] = 0;\r
306\r
307 //\r
308 // Allocate space for creation of UpdateData Buffer\r
309 //\r
310 UpdateData = AllocateZeroPool (0x1000);\r
311 ASSERT (UpdateData != NULL);\r
312\r
313 OptionList = AllocateZeroPool (0x1000);\r
314 ASSERT (OptionList != NULL);\r
315\r
316 //\r
317 // Flag update pending in FormSet\r
318 //\r
319 UpdateData->FormSetUpdate = TRUE;\r
320 //\r
321 // Register CallbackHandle data for FormSet\r
322 //\r
323 UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) FrontPageCallbackHandle;\r
324 UpdateData->FormUpdate = FALSE;\r
325 UpdateData->FormTitle = 0;\r
326 UpdateData->DataCount = 1;\r
327\r
328 //\r
329 // Collect the languages from what our current Language support is based on our VFR\r
330 //\r
d1477e4d 331 gHii->GetPrimaryLanguages (gHii, gFrontPageHandle, &LanguageString);\r
bc11b829 332\r
333 OptionCount = 0;\r
334\r
bc11b829 335 for (Index = 0; LanguageString[Index] != 0; Index += 3) {\r
336 Token = 0;\r
337 CopyMem (Lang, &LanguageString[Index], 6);\r
338 Lang[3] = 0;\r
339\r
340 if (!StrCmp (Lang, UnicodeLang)) {\r
341 mLastSelection = (UINT16) OptionCount;\r
342 }\r
343\r
6bfce83a 344 BufferSize = 0;\r
345 Status = gHii->GetString (gHii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, NULL);\r
346 ASSERT(Status == EFI_BUFFER_TOO_SMALL);\r
347 StringBuffer = AllocateZeroPool (BufferSize);\r
348 ASSERT (StringBuffer != NULL);\r
d1477e4d
A
349 Status = gHii->GetString (gHii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, StringBuffer);\r
350 gHii->NewString (gHii, NULL, gStringPackHandle, &Token, StringBuffer);\r
6bfce83a 351 FreePool (StringBuffer);\r
bc11b829 352 CopyMem (&OptionList[OptionCount].StringToken, &Token, sizeof (UINT16));\r
353 CopyMem (&OptionList[OptionCount].Value, &OptionCount, sizeof (UINT16));\r
354 Key = 0x1234;\r
355 CopyMem (&OptionList[OptionCount].Key, &Key, sizeof (UINT16));\r
356 OptionList[OptionCount].Flags = EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS;\r
357 OptionCount++;\r
358 }\r
359\r
360 FreePool (LanguageString);\r
361\r
362 if (ReInitializeStrings) {\r
bc11b829 363 FreePool (OptionList);\r
364 return EFI_SUCCESS;\r
365 }\r
366\r
367 Status = CreateOneOfOpCode (\r
368 FRONT_PAGE_QUESTION_ID, // Question ID\r
369 FRONT_PAGE_DATA_WIDTH, // Data Width\r
370 (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT), // Prompt Token\r
371 (STRING_REF) STRING_TOKEN (STR_LANGUAGE_SELECT_HELP), // Help Token\r
372 OptionList, // List of Options\r
373 OptionCount, // Number of Options\r
374 &UpdateData->Data // Data Buffer\r
375 );\r
376\r
377 //\r
378 // Assign the number of options and the oneof and endoneof op-codes to count\r
379 //\r
380 UpdateData->DataCount = (UINT8) (OptionCount + 2);\r
381\r
d1477e4d 382 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0x0002, TRUE, UpdateData);\r
bc11b829 383\r
384 FreePool (UpdateData);\r
385 //\r
386 // FreePool (OptionList);\r
387 //\r
bc11b829 388 return Status;\r
389}\r
390\r
391EFI_STATUS\r
392CallFrontPage (\r
393 VOID\r
394 )\r
395/*++\r
396\r
397Routine Description:\r
398\r
399 Call the browser and display the front page\r
400\r
401Arguments:\r
402\r
403 None\r
404\r
405Returns:\r
406\r
407--*/\r
408{\r
409 EFI_STATUS Status;\r
410 UINT8 FakeNvRamMap[1];\r
411 BOOLEAN FrontPageMenuResetRequired;\r
412\r
413 //\r
414 // Begin waiting for USER INPUT\r
415 //\r
416 REPORT_STATUS_CODE (\r
417 EFI_PROGRESS_CODE,\r
418 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)\r
419 );\r
420\r
421 FakeNvRamMap[0] = (UINT8) mLastSelection;\r
422 FrontPageMenuResetRequired = FALSE;\r
423 Status = gBrowser->SendForm (\r
424 gBrowser,\r
425 TRUE, // Use the database\r
426 &gFrontPageHandle, // The HII Handle\r
427 1,\r
428 NULL,\r
429 FrontPageCallbackHandle, // This is the handle that the interface to the callback was installed on\r
430 FakeNvRamMap,\r
431 NULL,\r
432 &FrontPageMenuResetRequired\r
433 );\r
434 //\r
435 // Check whether user change any option setting which needs a reset to be effective\r
436 //\r
437 if (FrontPageMenuResetRequired) {\r
438 EnableResetRequired ();\r
439 }\r
440\r
d1477e4d 441 gHii->ResetStrings (gHii, gFrontPageHandle);\r
bc11b829 442\r
443 return Status;\r
444}\r
445\r
446EFI_STATUS\r
447GetStringFromToken (\r
448 IN EFI_GUID *ProducerGuid,\r
449 IN STRING_REF Token,\r
450 OUT CHAR16 **String\r
451 )\r
452/*++\r
453\r
454Routine Description:\r
455\r
456 Acquire the string associated with the ProducerGuid and return it.\r
457\r
458Arguments:\r
459\r
460 ProducerGuid - The Guid to search the HII database for\r
461 Token - The token value of the string to extract\r
462 String - The string that is extracted\r
463\r
464Returns:\r
465\r
466 EFI_SUCCESS - The function returns EFI_SUCCESS always.\r
467\r
468--*/\r
469{\r
470 EFI_STATUS Status;\r
471 UINT16 HandleBufferLength;\r
472 EFI_HII_HANDLE *HiiHandleBuffer;\r
473 UINTN StringBufferLength;\r
474 UINTN NumberOfHiiHandles;\r
475 UINTN Index;\r
476 UINT16 Length;\r
477 EFI_GUID HiiGuid;\r
478\r
479 //\r
480 // Initialize params.\r
481 //\r
482 HandleBufferLength = 0;\r
483 HiiHandleBuffer = NULL;\r
484\r
485 //\r
486 // Get all the Hii handles\r
487 //\r
d1477e4d 488 Status = BdsLibGetHiiHandles (gHii, &HandleBufferLength, &HiiHandleBuffer);\r
bc11b829 489 ASSERT_EFI_ERROR (Status);\r
490\r
491 //\r
d1477e4d 492 // Get the gHii Handle that matches the StructureNode->ProducerName\r
bc11b829 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
d1477e4d
A
512 Status = gHii->GetString (\r
513 gHii,\r
bc11b829 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 FreePool (*String);\r
524 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
525 }\r
526\r
527 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
d1477e4d 682 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
bc11b829 683 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
d1477e4d 693 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
bc11b829 694 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
d1477e4d 704 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
bc11b829 705 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
d1477e4d 715 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
bc11b829 716 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
d1477e4d 728 gHii->NewString (gHii, Lang, gFrontPageHandle, &TokenToUpdate, NewString);\r
bc11b829 729 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
d1477e4d 786 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, FALSE, UpdateData);\r
bc11b829 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
d1477e4d 801 gHii->UpdateForm (gHii, gFrontPageHandle, (EFI_FORM_LABEL) 0xFFFF, TRUE, UpdateData);\r
bc11b829 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 //Will leave browser, check any reset required change is applied? if yes, reset system\r
882 //\r
883 SetupResetReminder ();\r
884\r
885 //\r
886 // Automatically load current entry\r
887 // Note: The following lines of code only execute when Auto boot\r
888 // takes affect\r
889 //\r
890 Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);\r
891 ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
892\r
893}\r