]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Application/UiApp/FrontPage.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Application / UiApp / FrontPage.c
CommitLineData
143f0b1d
ED
1/** @file\r
2 FrontPage routines to handle the callbacks and browser calls\r
3\r
9f4048f7 4Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
e00cd955 5(C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
143f0b1d
ED
7\r
8**/\r
9\r
10#include "FrontPage.h"\r
c9802c45
ED
11#include "FrontPageCustomizedUi.h"\r
12\r
1436aea4 13#define MAX_STRING_LEN 200\r
143f0b1d 14\r
1436aea4 15EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID;\r
143f0b1d 16\r
1436aea4 17BOOLEAN mResetRequired = FALSE;\r
143f0b1d 18\r
1436aea4
MK
19EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;\r
20CHAR8 *mLanguageString;\r
21BOOLEAN mModeInitialized = FALSE;\r
143f0b1d
ED
22//\r
23// Boot video resolution and text mode.\r
24//\r
1436aea4
MK
25UINT32 mBootHorizontalResolution = 0;\r
26UINT32 mBootVerticalResolution = 0;\r
27UINT32 mBootTextModeColumn = 0;\r
28UINT32 mBootTextModeRow = 0;\r
143f0b1d
ED
29//\r
30// BIOS setup video resolution and text mode.\r
31//\r
1436aea4
MK
32UINT32 mSetupTextModeColumn = 0;\r
33UINT32 mSetupTextModeRow = 0;\r
34UINT32 mSetupHorizontalResolution = 0;\r
35UINT32 mSetupVerticalResolution = 0;\r
143f0b1d
ED
36\r
37FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate = {\r
38 FRONT_PAGE_CALLBACK_DATA_SIGNATURE,\r
39 NULL,\r
40 NULL,\r
41 NULL,\r
42 {\r
43 FakeExtractConfig,\r
44 FakeRouteConfig,\r
45 FrontPageCallback\r
46 }\r
47};\r
48\r
49HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = {\r
50 {\r
51 {\r
52 HARDWARE_DEVICE_PATH,\r
53 HW_VENDOR_DP,\r
54 {\r
1436aea4
MK
55 (UINT8)(sizeof (VENDOR_DEVICE_PATH)),\r
56 (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
143f0b1d
ED
57 }\r
58 },\r
59 //\r
60 // {8E6D99EE-7531-48f8-8745-7F6144468FF2}\r
61 //\r
1436aea4
MK
62 { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 }\r
63 }\r
143f0b1d
ED
64 },\r
65 {\r
66 END_DEVICE_PATH_TYPE,\r
67 END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
68 {\r
1436aea4
MK
69 (UINT8)(END_DEVICE_PATH_LENGTH),\r
70 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)\r
143f0b1d
ED
71 }\r
72 }\r
73};\r
74\r
75/**\r
76 Update the banner information for the Front Page based on Smbios information.\r
77\r
78**/\r
79VOID\r
c9802c45 80UpdateFrontPageBannerStrings (\r
143f0b1d
ED
81 VOID\r
82 );\r
83\r
84/**\r
85 This function allows a caller to extract the current configuration for one\r
86 or more named elements from the target driver.\r
87\r
88\r
89 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
90 @param Request A null-terminated Unicode string in <ConfigRequest> format.\r
91 @param Progress On return, points to a character in the Request string.\r
92 Points to the string's null terminator if request was successful.\r
93 Points to the most recent '&' before the first failing name/value\r
94 pair (or the beginning of the string if the failure is in the\r
95 first name/value pair) if the request was not successful.\r
96 @param Results A null-terminated Unicode string in <ConfigAltResp> format which\r
97 has all values filled in for the names in the Request string.\r
98 String to be allocated by the called function.\r
99\r
100 @retval EFI_SUCCESS The Results is filled with the requested values.\r
101 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
102 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
103 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
104\r
105**/\r
106EFI_STATUS\r
107EFIAPI\r
108FakeExtractConfig (\r
1436aea4
MK
109 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
110 IN CONST EFI_STRING Request,\r
111 OUT EFI_STRING *Progress,\r
112 OUT EFI_STRING *Results\r
143f0b1d
ED
113 )\r
114{\r
1436aea4 115 if ((Progress == NULL) || (Results == NULL)) {\r
143f0b1d
ED
116 return EFI_INVALID_PARAMETER;\r
117 }\r
1436aea4 118\r
143f0b1d
ED
119 *Progress = Request;\r
120 return EFI_NOT_FOUND;\r
121}\r
122\r
123/**\r
124 This function processes the results of changes in configuration.\r
125\r
126\r
127 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
128 @param Configuration A null-terminated Unicode string in <ConfigResp> format.\r
129 @param Progress A pointer to a string filled in with the offset of the most\r
130 recent '&' before the first failing name/value pair (or the\r
131 beginning of the string if the failure is in the first\r
132 name/value pair) or the terminating NULL if all was successful.\r
133\r
134 @retval EFI_SUCCESS The Results is processed successfully.\r
135 @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
136 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
137\r
138**/\r
139EFI_STATUS\r
140EFIAPI\r
141FakeRouteConfig (\r
1436aea4
MK
142 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
143 IN CONST EFI_STRING Configuration,\r
144 OUT EFI_STRING *Progress\r
143f0b1d
ED
145 )\r
146{\r
1436aea4 147 if ((Configuration == NULL) || (Progress == NULL)) {\r
143f0b1d
ED
148 return EFI_INVALID_PARAMETER;\r
149 }\r
150\r
e00cd955
TP
151 *Progress = Configuration;\r
152\r
ce7690e2 153 return EFI_NOT_FOUND;\r
143f0b1d
ED
154}\r
155\r
143f0b1d
ED
156/**\r
157 This function processes the results of changes in configuration.\r
158\r
159\r
160 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
161 @param Action Specifies the type of action taken by the browser.\r
162 @param QuestionId A unique value which is sent to the original exporting driver\r
163 so that it can identify the type of data to expect.\r
164 @param Type The type of value for the question.\r
165 @param Value A pointer to the data being sent to the original exporting driver.\r
166 @param ActionRequest On return, points to the action requested by the callback function.\r
167\r
168 @retval EFI_SUCCESS The callback successfully handled the action.\r
169 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
170 @retval EFI_DEVICE_ERROR The variable could not be saved.\r
171 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.\r
172\r
173**/\r
174EFI_STATUS\r
175EFIAPI\r
176FrontPageCallback (\r
1436aea4
MK
177 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
178 IN EFI_BROWSER_ACTION Action,\r
179 IN EFI_QUESTION_ID QuestionId,\r
180 IN UINT8 Type,\r
181 IN EFI_IFR_TYPE_VALUE *Value,\r
182 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
143f0b1d
ED
183 )\r
184{\r
c9802c45 185 return UiFrontPageCallbackHandler (gFrontPagePrivate.HiiHandle, Action, QuestionId, Type, Value, ActionRequest);\r
ce7690e2
DB
186}\r
187\r
188/**\r
c9802c45
ED
189\r
190 Update the menus in the front page.\r
ce7690e2
DB
191\r
192**/\r
193VOID\r
194UpdateFrontPageForm (\r
195 VOID\r
196 )\r
197{\r
1436aea4
MK
198 VOID *StartOpCodeHandle;\r
199 VOID *EndOpCodeHandle;\r
200 EFI_IFR_GUID_LABEL *StartGuidLabel;\r
201 EFI_IFR_GUID_LABEL *EndGuidLabel;\r
ce7690e2
DB
202\r
203 //\r
204 // Allocate space for creation of UpdateData Buffer\r
205 //\r
206 StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
207 ASSERT (StartOpCodeHandle != NULL);\r
208\r
209 EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
210 ASSERT (EndOpCodeHandle != NULL);\r
211 //\r
212 // Create Hii Extend Label OpCode as the start opcode\r
213 //\r
1436aea4 214 StartGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
c9802c45 215 StartGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
96b8b5fd 216 StartGuidLabel->Number = LABEL_FRONTPAGE_INFORMATION;\r
ce7690e2
DB
217 //\r
218 // Create Hii Extend Label OpCode as the end opcode\r
219 //\r
1436aea4 220 EndGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
c9802c45
ED
221 EndGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
222 EndGuidLabel->Number = LABEL_END;\r
ce7690e2
DB
223\r
224 //\r
1436aea4 225 // Updata Front Page form\r
ce7690e2 226 //\r
c9802c45
ED
227 UiCustomizeFrontPage (\r
228 gFrontPagePrivate.HiiHandle,\r
229 StartOpCodeHandle\r
230 );\r
143f0b1d 231\r
ce7690e2 232 HiiUpdateForm (\r
c9802c45 233 gFrontPagePrivate.HiiHandle,\r
ce7690e2
DB
234 &mFrontPageGuid,\r
235 FRONT_PAGE_FORM_ID,\r
236 StartOpCodeHandle,\r
237 EndOpCodeHandle\r
238 );\r
239\r
240 HiiFreeOpCodeHandle (StartOpCodeHandle);\r
241 HiiFreeOpCodeHandle (EndOpCodeHandle);\r
143f0b1d
ED
242}\r
243\r
244/**\r
245 Initialize HII information for the FrontPage\r
246\r
247\r
248 @retval EFI_SUCCESS The operation is successful.\r
249 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.\r
250\r
251**/\r
252EFI_STATUS\r
253InitializeFrontPage (\r
254 VOID\r
255 )\r
256{\r
1436aea4
MK
257 EFI_STATUS Status;\r
258\r
143f0b1d
ED
259 //\r
260 // Locate Hii relative protocols\r
261 //\r
1436aea4 262 Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&gFormBrowser2);\r
143f0b1d
ED
263 if (EFI_ERROR (Status)) {\r
264 return Status;\r
265 }\r
266\r
267 //\r
268 // Install Device Path Protocol and Config Access protocol to driver handle\r
269 //\r
270 gFrontPagePrivate.DriverHandle = NULL;\r
1436aea4
MK
271 Status = gBS->InstallMultipleProtocolInterfaces (\r
272 &gFrontPagePrivate.DriverHandle,\r
273 &gEfiDevicePathProtocolGuid,\r
274 &mFrontPageHiiVendorDevicePath,\r
275 &gEfiHiiConfigAccessProtocolGuid,\r
276 &gFrontPagePrivate.ConfigAccess,\r
277 NULL\r
278 );\r
143f0b1d
ED
279 ASSERT_EFI_ERROR (Status);\r
280\r
281 //\r
282 // Publish our HII data\r
283 //\r
284 gFrontPagePrivate.HiiHandle = HiiAddPackages (\r
285 &mFrontPageGuid,\r
286 gFrontPagePrivate.DriverHandle,\r
287 FrontPageVfrBin,\r
288 UiAppStrings,\r
289 NULL\r
290 );\r
291 ASSERT (gFrontPagePrivate.HiiHandle != NULL);\r
292\r
293 //\r
1436aea4 294 // Updata Front Page banner strings\r
143f0b1d 295 //\r
c9802c45 296 UpdateFrontPageBannerStrings ();\r
143f0b1d 297\r
ce7690e2 298 //\r
c9802c45 299 // Update front page menus.\r
ce7690e2 300 //\r
1436aea4 301 UpdateFrontPageForm ();\r
ce7690e2 302\r
143f0b1d
ED
303 return Status;\r
304}\r
305\r
306/**\r
307 Call the browser and display the front page\r
308\r
309 @return Status code that will be returned by\r
310 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().\r
311\r
312**/\r
313EFI_STATUS\r
314CallFrontPage (\r
315 VOID\r
316 )\r
317{\r
318 EFI_STATUS Status;\r
319 EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
320\r
321 //\r
322 // Begin waiting for USER INPUT\r
323 //\r
324 REPORT_STATUS_CODE (\r
325 EFI_PROGRESS_CODE,\r
326 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)\r
327 );\r
328\r
329 ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
1436aea4
MK
330 Status = gFormBrowser2->SendForm (\r
331 gFormBrowser2,\r
332 &gFrontPagePrivate.HiiHandle,\r
333 1,\r
334 &mFrontPageGuid,\r
335 0,\r
336 NULL,\r
337 &ActionRequest\r
338 );\r
143f0b1d
ED
339 //\r
340 // Check whether user change any option setting which needs a reset to be effective\r
341 //\r
342 if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
343 EnableResetRequired ();\r
344 }\r
345\r
346 return Status;\r
347}\r
348\r
3194d76f
DB
349/**\r
350 Remove the installed packages from the HiiDatabase.\r
351\r
352**/\r
143f0b1d 353VOID\r
1436aea4 354FreeFrontPage (\r
143f0b1d
ED
355 VOID\r
356 )\r
357{\r
1436aea4
MK
358 EFI_STATUS Status;\r
359\r
143f0b1d
ED
360 Status = gBS->UninstallMultipleProtocolInterfaces (\r
361 gFrontPagePrivate.DriverHandle,\r
362 &gEfiDevicePathProtocolGuid,\r
363 &mFrontPageHiiVendorDevicePath,\r
364 &gEfiHiiConfigAccessProtocolGuid,\r
365 &gFrontPagePrivate.ConfigAccess,\r
366 NULL\r
367 );\r
368 ASSERT_EFI_ERROR (Status);\r
369\r
370 //\r
371 // Publish our HII data\r
372 //\r
373 HiiRemovePackages (gFrontPagePrivate.HiiHandle);\r
374 if (gFrontPagePrivate.LanguageToken != NULL) {\r
375 FreePool (gFrontPagePrivate.LanguageToken);\r
376 gFrontPagePrivate.LanguageToken = NULL;\r
377 }\r
378}\r
379\r
380/**\r
381 Convert Processor Frequency Data to a string.\r
382\r
383 @param ProcessorFrequency The frequency data to process\r
384 @param Base10Exponent The exponent based on 10\r
385 @param String The string that is created\r
386\r
387**/\r
388VOID\r
389ConvertProcessorToString (\r
1436aea4
MK
390 IN UINT16 ProcessorFrequency,\r
391 IN UINT16 Base10Exponent,\r
392 OUT CHAR16 **String\r
143f0b1d
ED
393 )\r
394{\r
395 CHAR16 *StringBuffer;\r
396 UINTN Index;\r
d91cb870 397 UINTN DestMax;\r
143f0b1d
ED
398 UINT32 FreqMhz;\r
399\r
400 if (Base10Exponent >= 6) {\r
401 FreqMhz = ProcessorFrequency;\r
1436aea4 402 for (Index = 0; Index < (UINT32)Base10Exponent - 6; Index++) {\r
143f0b1d
ED
403 FreqMhz *= 10;\r
404 }\r
405 } else {\r
406 FreqMhz = 0;\r
407 }\r
1436aea4
MK
408\r
409 DestMax = 0x20 / sizeof (CHAR16);\r
143f0b1d
ED
410 StringBuffer = AllocateZeroPool (0x20);\r
411 ASSERT (StringBuffer != NULL);\r
9f4048f7
HW
412 UnicodeValueToStringS (StringBuffer, sizeof (CHAR16) * DestMax, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r
413 Index = StrnLenS (StringBuffer, DestMax);\r
d91cb870 414 StrCatS (StringBuffer, DestMax, L".");\r
9f4048f7
HW
415 UnicodeValueToStringS (\r
416 StringBuffer + Index + 1,\r
417 sizeof (CHAR16) * (DestMax - (Index + 1)),\r
418 PREFIX_ZERO,\r
419 (FreqMhz % 1000) / 10,\r
420 2\r
421 );\r
d91cb870 422 StrCatS (StringBuffer, DestMax, L" GHz");\r
1436aea4
MK
423 *String = (CHAR16 *)StringBuffer;\r
424 return;\r
143f0b1d
ED
425}\r
426\r
143f0b1d
ED
427/**\r
428 Convert Memory Size to a string.\r
429\r
430 @param MemorySize The size of the memory to process\r
431 @param String The string that is created\r
432\r
433**/\r
434VOID\r
435ConvertMemorySizeToString (\r
1436aea4
MK
436 IN UINT32 MemorySize,\r
437 OUT CHAR16 **String\r
143f0b1d
ED
438 )\r
439{\r
440 CHAR16 *StringBuffer;\r
441\r
442 StringBuffer = AllocateZeroPool (0x24);\r
443 ASSERT (StringBuffer != NULL);\r
9f4048f7 444 UnicodeValueToStringS (StringBuffer, 0x24, LEFT_JUSTIFY, MemorySize, 10);\r
d91cb870 445 StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM");\r
143f0b1d 446\r
1436aea4 447 *String = (CHAR16 *)StringBuffer;\r
143f0b1d 448\r
1436aea4 449 return;\r
143f0b1d
ED
450}\r
451\r
452/**\r
453\r
454 Acquire the string associated with the Index from smbios structure and return it.\r
455 The caller is responsible for free the string buffer.\r
456\r
457 @param OptionalStrStart The start position to search the string\r
458 @param Index The index of the string to extract\r
459 @param String The string that is extracted\r
460\r
461 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.\r
462\r
463**/\r
464EFI_STATUS\r
465GetOptionalStringByIndex (\r
1436aea4
MK
466 IN CHAR8 *OptionalStrStart,\r
467 IN UINT8 Index,\r
468 OUT CHAR16 **String\r
143f0b1d
ED
469 )\r
470{\r
1436aea4 471 UINTN StrSize;\r
143f0b1d
ED
472\r
473 if (Index == 0) {\r
474 *String = AllocateZeroPool (sizeof (CHAR16));\r
475 return EFI_SUCCESS;\r
476 }\r
477\r
478 StrSize = 0;\r
479 do {\r
480 Index--;\r
481 OptionalStrStart += StrSize;\r
482 StrSize = AsciiStrSize (OptionalStrStart);\r
483 } while (OptionalStrStart[StrSize] != 0 && Index != 0);\r
484\r
485 if ((Index != 0) || (StrSize == 1)) {\r
486 //\r
487 // Meet the end of strings set but Index is non-zero, or\r
488 // Find an empty string\r
489 //\r
490 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
491 } else {\r
492 *String = AllocatePool (StrSize * sizeof (CHAR16));\r
b68ccac1 493 AsciiStrToUnicodeStrS (OptionalStrStart, *String, StrSize);\r
143f0b1d
ED
494 }\r
495\r
496 return EFI_SUCCESS;\r
497}\r
498\r
143f0b1d 499/**\r
c9802c45 500\r
143f0b1d 501 Update the banner information for the Front Page based on Smbios information.\r
c9802c45 502\r
143f0b1d
ED
503**/\r
504VOID\r
c9802c45 505UpdateFrontPageBannerStrings (\r
143f0b1d
ED
506 VOID\r
507 )\r
508{\r
1436aea4
MK
509 UINT8 StrIndex;\r
510 CHAR16 *NewString;\r
511 CHAR16 *FirmwareVersionString;\r
512 EFI_STATUS Status;\r
513 EFI_SMBIOS_HANDLE SmbiosHandle;\r
514 EFI_SMBIOS_PROTOCOL *Smbios;\r
515 SMBIOS_TABLE_TYPE0 *Type0Record;\r
516 SMBIOS_TABLE_TYPE1 *Type1Record;\r
517 SMBIOS_TABLE_TYPE4 *Type4Record;\r
518 SMBIOS_TABLE_TYPE19 *Type19Record;\r
519 EFI_SMBIOS_TABLE_HEADER *Record;\r
520 UINT64 InstalledMemory;\r
521 BOOLEAN FoundCpu;\r
143f0b1d 522\r
15f69ddf 523 InstalledMemory = 0;\r
1436aea4 524 FoundCpu = 0;\r
143f0b1d
ED
525\r
526 //\r
c9802c45 527 // Update default banner string.\r
143f0b1d 528 //\r
c9802c45
ED
529 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NULL);\r
530 UiCustomizeFrontPageBanner (4, TRUE, &NewString);\r
531 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NewString, NULL);\r
532 FreePool (NewString);\r
533\r
534 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NULL);\r
535 UiCustomizeFrontPageBanner (4, FALSE, &NewString);\r
536 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NewString, NULL);\r
537 FreePool (NewString);\r
538\r
539 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NULL);\r
540 UiCustomizeFrontPageBanner (5, TRUE, &NewString);\r
541 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NewString, NULL);\r
542 FreePool (NewString);\r
543\r
544 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NULL);\r
545 UiCustomizeFrontPageBanner (5, FALSE, &NewString);\r
546 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NewString, NULL);\r
547 FreePool (NewString);\r
548\r
549 //\r
550 // Update Front Page banner strings base on SmBios Table.\r
551 //\r
1436aea4 552 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);\r
c9802c45
ED
553 if (EFI_ERROR (Status)) {\r
554 //\r
555 // Smbios protocol not found, get the default value.\r
556 //\r
557 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NULL);\r
558 UiCustomizeFrontPageBanner (1, TRUE, &NewString);\r
559 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);\r
560 FreePool (NewString);\r
561\r
562 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NULL);\r
563 UiCustomizeFrontPageBanner (2, TRUE, &NewString);\r
564 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);\r
565 FreePool (NewString);\r
566\r
567 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NULL);\r
568 UiCustomizeFrontPageBanner (2, FALSE, &NewString);\r
569 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);\r
570 FreePool (NewString);\r
571\r
572 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NULL);\r
573 UiCustomizeFrontPageBanner (3, TRUE, &NewString);\r
574 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);\r
575 FreePool (NewString);\r
576\r
577 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NULL);\r
578 UiCustomizeFrontPageBanner (3, FALSE, &NewString);\r
579 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);\r
580 FreePool (NewString);\r
143f0b1d 581\r
c9802c45
ED
582 return;\r
583 }\r
584\r
585 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
1436aea4
MK
586 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
587 while (!EFI_ERROR (Status)) {\r
66db6e56 588 if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {\r
1436aea4
MK
589 Type0Record = (SMBIOS_TABLE_TYPE0 *)Record;\r
590 StrIndex = Type0Record->BiosVersion;\r
591 GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);\r
c9802c45 592\r
1436aea4 593 FirmwareVersionString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);\r
c9802c45
ED
594 if (*FirmwareVersionString != 0x0000 ) {\r
595 FreePool (NewString);\r
1436aea4 596 NewString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);\r
c9802c45
ED
597 UiCustomizeFrontPageBanner (3, TRUE, &NewString);\r
598 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);\r
599 } else {\r
600 UiCustomizeFrontPageBanner (3, TRUE, &NewString);\r
601 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);\r
143f0b1d
ED
602 FreePool (NewString);\r
603 }\r
c9802c45 604 }\r
143f0b1d 605\r
66db6e56 606 if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {\r
1436aea4
MK
607 Type1Record = (SMBIOS_TABLE_TYPE1 *)Record;\r
608 StrIndex = Type1Record->ProductName;\r
609 GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);\r
c9802c45
ED
610 UiCustomizeFrontPageBanner (1, TRUE, &NewString);\r
611 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);\r
612 FreePool (NewString);\r
613 }\r
143f0b1d 614\r
66db6e56 615 if ((Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {\r
1436aea4 616 Type4Record = (SMBIOS_TABLE_TYPE4 *)Record;\r
c9802c45
ED
617 //\r
618 // The information in the record should be only valid when the CPU Socket is populated.\r
619 //\r
620 if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) {\r
621 StrIndex = Type4Record->ProcessorVersion;\r
1436aea4 622 GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);\r
c9802c45
ED
623 UiCustomizeFrontPageBanner (2, TRUE, &NewString);\r
624 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);\r
625 FreePool (NewString);\r
626\r
1436aea4 627 ConvertProcessorToString (Type4Record->CurrentSpeed, 6, &NewString);\r
be689ecc
LE
628 UiCustomizeFrontPageBanner (2, FALSE, &NewString);\r
629 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);\r
630 FreePool (NewString);\r
631\r
c9802c45 632 FoundCpu = TRUE;\r
143f0b1d 633 }\r
c9802c45 634 }\r
143f0b1d 635\r
66db6e56 636 if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {\r
1436aea4 637 Type19Record = (SMBIOS_TABLE_TYPE19 *)Record;\r
c9802c45 638 if (Type19Record->StartingAddress != 0xFFFFFFFF ) {\r
1436aea4
MK
639 InstalledMemory += RShiftU64 (\r
640 Type19Record->EndingAddress -\r
641 Type19Record->StartingAddress + 1,\r
642 10\r
643 );\r
c9802c45 644 } else {\r
1436aea4
MK
645 InstalledMemory += RShiftU64 (\r
646 Type19Record->ExtendedEndingAddress -\r
647 Type19Record->ExtendedStartingAddress + 1,\r
648 20\r
649 );\r
c9802c45 650 }\r
143f0b1d 651 }\r
15f69ddf 652\r
c9802c45 653 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
15f69ddf
JL
654 }\r
655\r
c9802c45
ED
656 //\r
657 // Now update the total installed RAM size\r
658 //\r
1436aea4 659 ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString);\r
c9802c45
ED
660 UiCustomizeFrontPageBanner (3, FALSE, &NewString);\r
661 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);\r
662 FreePool (NewString);\r
143f0b1d
ED
663}\r
664\r
665/**\r
666 This function will change video resolution and text mode\r
c9802c45 667 according to defined setup mode or defined boot mode\r
143f0b1d 668\r
c9802c45 669 @param IsSetupMode Indicate mode is changed to setup mode or boot mode.\r
143f0b1d
ED
670\r
671 @retval EFI_SUCCESS Mode is changed successfully.\r
672 @retval Others Mode failed to be changed.\r
673\r
674**/\r
675EFI_STATUS\r
bcfe5adb 676UiSetConsoleMode (\r
143f0b1d
ED
677 BOOLEAN IsSetupMode\r
678 )\r
679{\r
680 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
681 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
682 UINTN SizeOfInfo;\r
683 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
684 UINT32 MaxGopMode;\r
685 UINT32 MaxTextMode;\r
686 UINT32 ModeNumber;\r
687 UINT32 NewHorizontalResolution;\r
688 UINT32 NewVerticalResolution;\r
689 UINT32 NewColumns;\r
690 UINT32 NewRows;\r
691 UINTN HandleCount;\r
692 EFI_HANDLE *HandleBuffer;\r
693 EFI_STATUS Status;\r
694 UINTN Index;\r
695 UINTN CurrentColumn;\r
c9802c45 696 UINTN CurrentRow;\r
143f0b1d
ED
697\r
698 MaxGopMode = 0;\r
699 MaxTextMode = 0;\r
700\r
701 //\r
c9802c45 702 // Get current video resolution and text mode\r
143f0b1d
ED
703 //\r
704 Status = gBS->HandleProtocol (\r
705 gST->ConsoleOutHandle,\r
706 &gEfiGraphicsOutputProtocolGuid,\r
1436aea4 707 (VOID **)&GraphicsOutput\r
143f0b1d
ED
708 );\r
709 if (EFI_ERROR (Status)) {\r
710 GraphicsOutput = NULL;\r
711 }\r
712\r
713 Status = gBS->HandleProtocol (\r
714 gST->ConsoleOutHandle,\r
715 &gEfiSimpleTextOutProtocolGuid,\r
1436aea4 716 (VOID **)&SimpleTextOut\r
143f0b1d
ED
717 );\r
718 if (EFI_ERROR (Status)) {\r
719 SimpleTextOut = NULL;\r
c9802c45 720 }\r
143f0b1d
ED
721\r
722 if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {\r
723 return EFI_UNSUPPORTED;\r
724 }\r
725\r
726 if (IsSetupMode) {\r
727 //\r
2048c585 728 // The required resolution and text mode is setup mode.\r
143f0b1d
ED
729 //\r
730 NewHorizontalResolution = mSetupHorizontalResolution;\r
731 NewVerticalResolution = mSetupVerticalResolution;\r
732 NewColumns = mSetupTextModeColumn;\r
733 NewRows = mSetupTextModeRow;\r
734 } else {\r
735 //\r
736 // The required resolution and text mode is boot mode.\r
737 //\r
738 NewHorizontalResolution = mBootHorizontalResolution;\r
739 NewVerticalResolution = mBootVerticalResolution;\r
740 NewColumns = mBootTextModeColumn;\r
c9802c45 741 NewRows = mBootTextModeRow;\r
143f0b1d 742 }\r
c9802c45 743\r
143f0b1d 744 if (GraphicsOutput != NULL) {\r
1436aea4 745 MaxGopMode = GraphicsOutput->Mode->MaxMode;\r
c9802c45 746 }\r
143f0b1d
ED
747\r
748 if (SimpleTextOut != NULL) {\r
749 MaxTextMode = SimpleTextOut->Mode->MaxMode;\r
750 }\r
751\r
752 //\r
753 // 1. If current video resolution is same with required video resolution,\r
754 // video resolution need not be changed.\r
755 // 1.1. If current text mode is same with required text mode, text mode need not be changed.\r
756 // 1.2. If current text mode is different from required text mode, text mode need be changed.\r
757 // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.\r
758 //\r
759 for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {\r
760 Status = GraphicsOutput->QueryMode (\r
1436aea4
MK
761 GraphicsOutput,\r
762 ModeNumber,\r
763 &SizeOfInfo,\r
764 &Info\r
765 );\r
143f0b1d
ED
766 if (!EFI_ERROR (Status)) {\r
767 if ((Info->HorizontalResolution == NewHorizontalResolution) &&\r
1436aea4
MK
768 (Info->VerticalResolution == NewVerticalResolution))\r
769 {\r
143f0b1d 770 if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&\r
1436aea4
MK
771 (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution))\r
772 {\r
143f0b1d
ED
773 //\r
774 // Current resolution is same with required resolution, check if text mode need be set\r
775 //\r
776 Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);\r
777 ASSERT_EFI_ERROR (Status);\r
1436aea4 778 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {\r
143f0b1d
ED
779 //\r
780 // If current text mode is same with required text mode. Do nothing\r
781 //\r
782 FreePool (Info);\r
783 return EFI_SUCCESS;\r
784 } else {\r
785 //\r
2048c585 786 // If current text mode is different from required text mode. Set new video mode\r
143f0b1d
ED
787 //\r
788 for (Index = 0; Index < MaxTextMode; Index++) {\r
789 Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
1436aea4 790 if (!EFI_ERROR (Status)) {\r
143f0b1d
ED
791 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {\r
792 //\r
793 // Required text mode is supported, set it.\r
794 //\r
795 Status = SimpleTextOut->SetMode (SimpleTextOut, Index);\r
796 ASSERT_EFI_ERROR (Status);\r
797 //\r
798 // Update text mode PCD.\r
799 //\r
377680ae
ED
800 Status = PcdSet32S (PcdConOutColumn, mSetupTextModeColumn);\r
801 ASSERT_EFI_ERROR (Status);\r
802 Status = PcdSet32S (PcdConOutRow, mSetupTextModeRow);\r
803 ASSERT_EFI_ERROR (Status);\r
143f0b1d
ED
804 FreePool (Info);\r
805 return EFI_SUCCESS;\r
806 }\r
807 }\r
808 }\r
1436aea4 809\r
143f0b1d
ED
810 if (Index == MaxTextMode) {\r
811 //\r
2048c585 812 // If required text mode is not supported, return error.\r
143f0b1d
ED
813 //\r
814 FreePool (Info);\r
815 return EFI_UNSUPPORTED;\r
816 }\r
817 }\r
818 } else {\r
819 //\r
820 // If current video resolution is not same with the new one, set new video resolution.\r
821 // In this case, the driver which produces simple text out need be restarted.\r
822 //\r
823 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r
824 if (!EFI_ERROR (Status)) {\r
825 FreePool (Info);\r
826 break;\r
827 }\r
828 }\r
829 }\r
1436aea4 830\r
143f0b1d
ED
831 FreePool (Info);\r
832 }\r
833 }\r
834\r
835 if (ModeNumber == MaxGopMode) {\r
836 //\r
837 // If the resolution is not supported, return error.\r
838 //\r
839 return EFI_UNSUPPORTED;\r
840 }\r
841\r
842 //\r
843 // Set PCD to Inform GraphicsConsole to change video resolution.\r
844 // Set PCD to Inform Consplitter to change text mode.\r
845 //\r
377680ae
ED
846 Status = PcdSet32S (PcdVideoHorizontalResolution, NewHorizontalResolution);\r
847 ASSERT_EFI_ERROR (Status);\r
848 Status = PcdSet32S (PcdVideoVerticalResolution, NewVerticalResolution);\r
849 ASSERT_EFI_ERROR (Status);\r
850 Status = PcdSet32S (PcdConOutColumn, NewColumns);\r
851 ASSERT_EFI_ERROR (Status);\r
852 Status = PcdSet32S (PcdConOutRow, NewRows);\r
853 ASSERT_EFI_ERROR (Status);\r
c9802c45 854\r
143f0b1d
ED
855 //\r
856 // Video mode is changed, so restart graphics console driver and higher level driver.\r
857 // Reconnect graphics console driver and higher level driver.\r
858 // Locate all the handles with GOP protocol and reconnect it.\r
859 //\r
860 Status = gBS->LocateHandleBuffer (\r
1436aea4
MK
861 ByProtocol,\r
862 &gEfiSimpleTextOutProtocolGuid,\r
863 NULL,\r
864 &HandleCount,\r
865 &HandleBuffer\r
866 );\r
143f0b1d
ED
867 if (!EFI_ERROR (Status)) {\r
868 for (Index = 0; Index < HandleCount; Index++) {\r
869 gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
870 }\r
1436aea4 871\r
143f0b1d
ED
872 for (Index = 0; Index < HandleCount; Index++) {\r
873 gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
874 }\r
1436aea4 875\r
143f0b1d
ED
876 if (HandleBuffer != NULL) {\r
877 FreePool (HandleBuffer);\r
878 }\r
879 }\r
880\r
881 return EFI_SUCCESS;\r
882}\r
883\r
884/**\r
885 The user Entry Point for Application. The user code starts with this function\r
c9802c45 886 as the real entry point for the image goes into a library that calls this\r
143f0b1d
ED
887 function.\r
888\r
c9802c45 889 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
143f0b1d 890 @param[in] SystemTable A pointer to the EFI System Table.\r
c9802c45 891\r
143f0b1d
ED
892 @retval EFI_SUCCESS The entry point is executed successfully.\r
893 @retval other Some error occurs when executing this entry point.\r
894\r
895**/\r
896EFI_STATUS\r
897EFIAPI\r
898InitializeUserInterface (\r
899 IN EFI_HANDLE ImageHandle,\r
900 IN EFI_SYSTEM_TABLE *SystemTable\r
901 )\r
902{\r
1436aea4
MK
903 EFI_HII_HANDLE HiiHandle;\r
904 EFI_STATUS Status;\r
905 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
906 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
907 UINTN BootTextColumn;\r
908 UINTN BootTextRow;\r
143f0b1d
ED
909\r
910 if (!mModeInitialized) {\r
911 //\r
c9802c45 912 // After the console is ready, get current video resolution\r
143f0b1d
ED
913 // and text mode before launching setup at first time.\r
914 //\r
915 Status = gBS->HandleProtocol (\r
916 gST->ConsoleOutHandle,\r
917 &gEfiGraphicsOutputProtocolGuid,\r
1436aea4 918 (VOID **)&GraphicsOutput\r
143f0b1d
ED
919 );\r
920 if (EFI_ERROR (Status)) {\r
921 GraphicsOutput = NULL;\r
922 }\r
c9802c45 923\r
143f0b1d
ED
924 Status = gBS->HandleProtocol (\r
925 gST->ConsoleOutHandle,\r
926 &gEfiSimpleTextOutProtocolGuid,\r
1436aea4 927 (VOID **)&SimpleTextOut\r
143f0b1d
ED
928 );\r
929 if (EFI_ERROR (Status)) {\r
930 SimpleTextOut = NULL;\r
c9802c45 931 }\r
143f0b1d
ED
932\r
933 if (GraphicsOutput != NULL) {\r
934 //\r
935 // Get current video resolution and text mode.\r
936 //\r
937 mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
938 mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
939 }\r
940\r
941 if (SimpleTextOut != NULL) {\r
942 Status = SimpleTextOut->QueryMode (\r
943 SimpleTextOut,\r
944 SimpleTextOut->Mode->Mode,\r
945 &BootTextColumn,\r
946 &BootTextRow\r
947 );\r
948 mBootTextModeColumn = (UINT32)BootTextColumn;\r
949 mBootTextModeRow = (UINT32)BootTextRow;\r
950 }\r
951\r
952 //\r
953 // Get user defined text mode for setup.\r
c9802c45 954 //\r
143f0b1d 955 mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
c9802c45 956 mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);\r
143f0b1d
ED
957 mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);\r
958 mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);\r
959\r
1436aea4 960 mModeInitialized = TRUE;\r
143f0b1d
ED
961 }\r
962\r
963 gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
964 gST->ConOut->ClearScreen (gST->ConOut);\r
c9802c45 965\r
143f0b1d
ED
966 //\r
967 // Install customized fonts needed by Front Page\r
968 //\r
143f0b1d
ED
969 HiiHandle = ExportFonts ();\r
970 ASSERT (HiiHandle != NULL);\r
971\r
972 InitializeStringSupport ();\r
973\r
bcfe5adb 974 UiSetConsoleMode (TRUE);\r
143f0b1d 975 UiEntry (FALSE);\r
bcfe5adb 976 UiSetConsoleMode (FALSE);\r
143f0b1d
ED
977\r
978 UninitializeStringSupport ();\r
979 HiiRemovePackages (HiiHandle);\r
980\r
981 return EFI_SUCCESS;\r
982}\r
983\r
984/**\r
985 This function is the main entry of the UI entry.\r
986 The function will present the main menu of the system UI.\r
987\r
988 @param ConnectAllHappened Caller passes the value to UI to avoid unnecessary connect-all.\r
989\r
990**/\r
991VOID\r
992EFIAPI\r
993UiEntry (\r
1436aea4 994 IN BOOLEAN ConnectAllHappened\r
143f0b1d
ED
995 )\r
996{\r
1436aea4
MK
997 EFI_STATUS Status;\r
998 EFI_BOOT_LOGO_PROTOCOL *BootLogo;\r
143f0b1d 999\r
7266e2f6
ED
1000 //\r
1001 // Enter Setup page.\r
1002 //\r
1003 REPORT_STATUS_CODE (\r
1004 EFI_PROGRESS_CODE,\r
1005 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)\r
1006 );\r
1007\r
143f0b1d
ED
1008 //\r
1009 // Indicate if the connect all has been performed before.\r
a0d1206f 1010 // If has not been performed before, do here.\r
143f0b1d 1011 //\r
a0d1206f
DB
1012 if (!ConnectAllHappened) {\r
1013 EfiBootManagerConnectAll ();\r
143f0b1d
ED
1014 }\r
1015\r
1016 //\r
1017 // The boot option enumeration time is acceptable in Ui driver\r
1018 //\r
1019 EfiBootManagerRefreshAllBootOption ();\r
1020\r
1021 //\r
1022 // Boot Logo is corrupted, report it using Boot Logo protocol.\r
1023 //\r
1436aea4 1024 Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);\r
143f0b1d
ED
1025 if (!EFI_ERROR (Status) && (BootLogo != NULL)) {\r
1026 BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);\r
1027 }\r
1028\r
1029 InitializeFrontPage ();\r
143f0b1d
ED
1030\r
1031 CallFrontPage ();\r
1032\r
143f0b1d
ED
1033 FreeFrontPage ();\r
1034\r
1035 if (mLanguageString != NULL) {\r
1036 FreePool (mLanguageString);\r
1037 mLanguageString = NULL;\r
1038 }\r
1039\r
1040 //\r
1436aea4 1041 // Will leave browser, check any reset required change is applied? if yes, reset system\r
143f0b1d
ED
1042 //\r
1043 SetupResetReminder ();\r
1044}\r
1045\r
143f0b1d
ED
1046//\r
1047// Following are BDS Lib functions which contain all the code about setup browser reset reminder feature.\r
1048// Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser if\r
1049// user change any option setting which needs a reset to be effective, and the reset will be applied according to the user selection.\r
1050//\r
1051\r
143f0b1d
ED
1052/**\r
1053 Record the info that a reset is required.\r
1054 A module boolean variable is used to record whether a reset is required.\r
1055\r
1056**/\r
1057VOID\r
1058EFIAPI\r
1059EnableResetRequired (\r
1060 VOID\r
1061 )\r
1062{\r
1063 mResetRequired = TRUE;\r
1064}\r
1065\r
143f0b1d
ED
1066/**\r
1067 Check if user changed any option setting which needs a system reset to be effective.\r
1068\r
1069**/\r
1070BOOLEAN\r
1071EFIAPI\r
1072IsResetRequired (\r
1073 VOID\r
1074 )\r
1075{\r
1076 return mResetRequired;\r
1077}\r
1078\r
143f0b1d
ED
1079/**\r
1080 Check whether a reset is needed, and finish the reset reminder feature.\r
1081 If a reset is needed, Popup a menu to notice user, and finish the feature\r
1082 according to the user selection.\r
1083\r
1084**/\r
1085VOID\r
1086EFIAPI\r
1087SetupResetReminder (\r
1088 VOID\r
1089 )\r
1090{\r
1436aea4
MK
1091 EFI_INPUT_KEY Key;\r
1092 CHAR16 *StringBuffer1;\r
1093 CHAR16 *StringBuffer2;\r
143f0b1d 1094\r
143f0b1d 1095 //\r
1436aea4 1096 // check any reset required change is applied? if yes, reset system\r
143f0b1d 1097 //\r
cc693906 1098 if (IsResetRequired ()) {\r
cc693906
SZ
1099 StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
1100 ASSERT (StringBuffer1 != NULL);\r
1101 StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
1102 ASSERT (StringBuffer2 != NULL);\r
1103 StrCpyS (StringBuffer1, MAX_STRING_LEN, L"Configuration changed. Reset to apply it Now.");\r
1104 StrCpyS (StringBuffer2, MAX_STRING_LEN, L"Press ENTER to reset");\r
1105 //\r
1106 // Popup a menu to notice user\r
1107 //\r
1108 do {\r
1109 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
1110 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
143f0b1d 1111\r
cc693906
SZ
1112 FreePool (StringBuffer1);\r
1113 FreePool (StringBuffer2);\r
143f0b1d 1114\r
cc693906 1115 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
143f0b1d
ED
1116 }\r
1117}\r