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