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