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