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