]> git.proxmox.com Git - mirror_edk2.git/blame - EdkNt32Pkg/Dxe/PlatformBds/Generic/FrontPage.c
Merge GOP related code from r8->r9.
[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
406adcd1 77 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
78 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
79 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
878ddf1f 80\r
406adcd1 81 SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
82 SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
83 SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
878ddf1f 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
9e0e49fc 420 BOOLEAN FrontPageMenuResetRequired;\r
878ddf1f 421\r
422 //\r
423 // Begin waiting for USER INPUT\r
424 //\r
425 REPORT_STATUS_CODE (\r
426 EFI_PROGRESS_CODE,\r
427 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)\r
428 );\r
429\r
430 FakeNvRamMap[0] = (UINT8) mLastSelection;\r
9e0e49fc 431 FrontPageMenuResetRequired = FALSE;\r
878ddf1f 432 Status = gBrowser->SendForm (\r
433 gBrowser,\r
434 TRUE, // Use the database\r
435 &gFrontPageHandle, // The HII Handle\r
436 1,\r
437 NULL,\r
438 FrontPageCallbackHandle, // This is the handle that the interface to the callback was installed on\r
439 FakeNvRamMap,\r
440 NULL,\r
9e0e49fc 441 &FrontPageMenuResetRequired\r
878ddf1f 442 );\r
9e0e49fc 443 //\r
444 // Check whether user change any option setting which needs a reset to be effective\r
445 // \r
446 if (FrontPageMenuResetRequired) {\r
447 EnableResetRequired ();\r
448 }\r
878ddf1f 449\r
450 Hii->ResetStrings (Hii, gFrontPageHandle);\r
451\r
452 return Status;\r
453}\r
454\r
455EFI_STATUS\r
456GetStringFromToken (\r
457 IN EFI_GUID *ProducerGuid,\r
458 IN STRING_REF Token,\r
459 OUT CHAR16 **String\r
460 )\r
461/*++\r
462\r
463Routine Description:\r
464 \r
465 Acquire the string associated with the ProducerGuid and return it.\r
466\r
467Arguments:\r
468 \r
469 ProducerGuid - The Guid to search the HII database for\r
470 Token - The token value of the string to extract\r
471 String - The string that is extracted\r
472 \r
473Returns:\r
474\r
475 EFI_SUCCESS - The function returns EFI_SUCCESS always.\r
476\r
477--*/\r
478{\r
479 EFI_STATUS Status;\r
480 UINT16 HandleBufferLength;\r
481 EFI_HII_HANDLE *HiiHandleBuffer;\r
482 UINTN StringBufferLength;\r
483 UINTN NumberOfHiiHandles;\r
484 UINTN Index;\r
485 UINT16 Length;\r
486 EFI_GUID HiiGuid;\r
487\r
488 HandleBufferLength = 0x1000;\r
489 HiiHandleBuffer = NULL;\r
490\r
491 //\r
492 // Get all the Hii handles\r
493 //\r
494 HiiHandleBuffer = AllocateZeroPool (HandleBufferLength);\r
495\r
496 Status = Hii->FindHandles (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 &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
9e0e49fc 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
878ddf1f 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, &ConsoleControl);\r
899 ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
900\r
901}\r