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