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