]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Application/UiApp/FrontPage.c
MdeModulePkg UiApp: Use definition in IndustryStandard/Smbios.h
[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 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
402 for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) {\r
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
411 Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r
d91cb870 412 StrCatS (StringBuffer, DestMax, L".");\r
143f0b1d 413 UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);\r
d91cb870 414 StrCatS (StringBuffer, DestMax, L" GHz");\r
143f0b1d
ED
415 *String = (CHAR16 *) StringBuffer;\r
416 return ;\r
417}\r
418\r
419\r
420/**\r
421 Convert Memory Size to a string.\r
422\r
423 @param MemorySize The size of the memory to process\r
424 @param String The string that is created\r
425\r
426**/\r
427VOID\r
428ConvertMemorySizeToString (\r
429 IN UINT32 MemorySize,\r
430 OUT CHAR16 **String\r
431 )\r
432{\r
433 CHAR16 *StringBuffer;\r
434\r
435 StringBuffer = AllocateZeroPool (0x24);\r
436 ASSERT (StringBuffer != NULL);\r
437 UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 10);\r
d91cb870 438 StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM");\r
143f0b1d
ED
439\r
440 *String = (CHAR16 *) StringBuffer;\r
441\r
442 return ;\r
443}\r
444\r
445/**\r
446\r
447 Acquire the string associated with the Index from smbios structure and return it.\r
448 The caller is responsible for free the string buffer.\r
449\r
450 @param OptionalStrStart The start position to search the string\r
451 @param Index The index of the string to extract\r
452 @param String The string that is extracted\r
453\r
454 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.\r
455\r
456**/\r
457EFI_STATUS\r
458GetOptionalStringByIndex (\r
459 IN CHAR8 *OptionalStrStart,\r
460 IN UINT8 Index,\r
461 OUT CHAR16 **String\r
462 )\r
463{\r
464 UINTN StrSize;\r
465\r
466 if (Index == 0) {\r
467 *String = AllocateZeroPool (sizeof (CHAR16));\r
468 return EFI_SUCCESS;\r
469 }\r
470\r
471 StrSize = 0;\r
472 do {\r
473 Index--;\r
474 OptionalStrStart += StrSize;\r
475 StrSize = AsciiStrSize (OptionalStrStart);\r
476 } while (OptionalStrStart[StrSize] != 0 && Index != 0);\r
477\r
478 if ((Index != 0) || (StrSize == 1)) {\r
479 //\r
480 // Meet the end of strings set but Index is non-zero, or\r
481 // Find an empty string\r
482 //\r
483 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
484 } else {\r
485 *String = AllocatePool (StrSize * sizeof (CHAR16));\r
b68ccac1 486 AsciiStrToUnicodeStrS (OptionalStrStart, *String, StrSize);\r
143f0b1d
ED
487 }\r
488\r
489 return EFI_SUCCESS;\r
490}\r
491\r
492\r
493/**\r
c9802c45 494\r
143f0b1d 495 Update the banner information for the Front Page based on Smbios information.\r
c9802c45 496\r
143f0b1d
ED
497**/\r
498VOID\r
c9802c45 499UpdateFrontPageBannerStrings (\r
143f0b1d
ED
500 VOID\r
501 )\r
502{\r
503 UINT8 StrIndex;\r
504 CHAR16 *NewString;\r
505 CHAR16 *FirmwareVersionString;\r
143f0b1d 506 EFI_STATUS Status;\r
143f0b1d
ED
507 EFI_SMBIOS_HANDLE SmbiosHandle;\r
508 EFI_SMBIOS_PROTOCOL *Smbios;\r
509 SMBIOS_TABLE_TYPE0 *Type0Record;\r
510 SMBIOS_TABLE_TYPE1 *Type1Record;\r
511 SMBIOS_TABLE_TYPE4 *Type4Record;\r
512 SMBIOS_TABLE_TYPE19 *Type19Record;\r
513 EFI_SMBIOS_TABLE_HEADER *Record;\r
15f69ddf
JL
514 UINT64 InstalledMemory;\r
515 BOOLEAN FoundCpu;\r
143f0b1d 516\r
15f69ddf
JL
517 InstalledMemory = 0;\r
518 FoundCpu = 0;\r
143f0b1d
ED
519\r
520 //\r
c9802c45 521 // Update default banner string.\r
143f0b1d 522 //\r
c9802c45
ED
523 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NULL);\r
524 UiCustomizeFrontPageBanner (4, TRUE, &NewString);\r
525 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NewString, NULL);\r
526 FreePool (NewString);\r
527\r
528 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NULL);\r
529 UiCustomizeFrontPageBanner (4, FALSE, &NewString);\r
530 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NewString, NULL);\r
531 FreePool (NewString);\r
532\r
533 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NULL);\r
534 UiCustomizeFrontPageBanner (5, TRUE, &NewString);\r
535 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NewString, NULL);\r
536 FreePool (NewString);\r
537\r
538 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NULL);\r
539 UiCustomizeFrontPageBanner (5, FALSE, &NewString);\r
540 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NewString, NULL);\r
541 FreePool (NewString);\r
542\r
543 //\r
544 // Update Front Page banner strings base on SmBios Table.\r
545 //\r
546 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **) &Smbios);\r
547 if (EFI_ERROR (Status)) {\r
548 //\r
549 // Smbios protocol not found, get the default value.\r
550 //\r
551 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NULL);\r
552 UiCustomizeFrontPageBanner (1, TRUE, &NewString);\r
553 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);\r
554 FreePool (NewString);\r
555\r
556 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NULL);\r
557 UiCustomizeFrontPageBanner (2, TRUE, &NewString);\r
558 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);\r
559 FreePool (NewString);\r
560\r
561 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NULL);\r
562 UiCustomizeFrontPageBanner (2, FALSE, &NewString);\r
563 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);\r
564 FreePool (NewString);\r
565\r
566 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NULL);\r
567 UiCustomizeFrontPageBanner (3, TRUE, &NewString);\r
568 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);\r
569 FreePool (NewString);\r
570\r
571 NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NULL);\r
572 UiCustomizeFrontPageBanner (3, FALSE, &NewString);\r
573 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);\r
574 FreePool (NewString);\r
143f0b1d 575\r
c9802c45
ED
576 return;\r
577 }\r
578\r
579 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
580 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
581 while (!EFI_ERROR(Status)) {\r
66db6e56 582 if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {\r
c9802c45
ED
583 Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;\r
584 StrIndex = Type0Record->BiosVersion;\r
585 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);\r
586\r
587 FirmwareVersionString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);\r
588 if (*FirmwareVersionString != 0x0000 ) {\r
589 FreePool (NewString);\r
590 NewString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);\r
591 UiCustomizeFrontPageBanner (3, TRUE, &NewString);\r
592 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);\r
593 } else {\r
594 UiCustomizeFrontPageBanner (3, TRUE, &NewString);\r
595 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);\r
143f0b1d
ED
596 FreePool (NewString);\r
597 }\r
c9802c45 598 }\r
143f0b1d 599\r
66db6e56 600 if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {\r
c9802c45
ED
601 Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;\r
602 StrIndex = Type1Record->ProductName;\r
603 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);\r
604 UiCustomizeFrontPageBanner (1, TRUE, &NewString);\r
605 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);\r
606 FreePool (NewString);\r
607 }\r
143f0b1d 608\r
66db6e56 609 if ((Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {\r
c9802c45
ED
610 Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;\r
611 //\r
612 // The information in the record should be only valid when the CPU Socket is populated.\r
613 //\r
614 if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) {\r
615 StrIndex = Type4Record->ProcessorVersion;\r
616 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);\r
617 UiCustomizeFrontPageBanner (2, TRUE, &NewString);\r
618 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);\r
619 FreePool (NewString);\r
620\r
621 ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);\r
622 UiCustomizeFrontPageBanner (2, FALSE, &NewString);\r
623 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);\r
624 FreePool (NewString);\r
625\r
626 FoundCpu = TRUE;\r
143f0b1d 627 }\r
c9802c45 628 }\r
143f0b1d 629\r
66db6e56 630 if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {\r
c9802c45
ED
631 Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;\r
632 if (Type19Record->StartingAddress != 0xFFFFFFFF ) {\r
633 InstalledMemory += RShiftU64(Type19Record->EndingAddress -\r
634 Type19Record->StartingAddress + 1, 10);\r
635 } else {\r
636 InstalledMemory += RShiftU64(Type19Record->ExtendedEndingAddress -\r
637 Type19Record->ExtendedStartingAddress + 1, 20);\r
638 }\r
143f0b1d 639 }\r
15f69ddf 640\r
c9802c45 641 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
15f69ddf
JL
642 }\r
643\r
c9802c45
ED
644 //\r
645 // Now update the total installed RAM size\r
646 //\r
647 ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString );\r
648 UiCustomizeFrontPageBanner (3, FALSE, &NewString);\r
649 HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);\r
650 FreePool (NewString);\r
143f0b1d
ED
651}\r
652\r
653/**\r
654 This function will change video resolution and text mode\r
c9802c45 655 according to defined setup mode or defined boot mode\r
143f0b1d 656\r
c9802c45 657 @param IsSetupMode Indicate mode is changed to setup mode or boot mode.\r
143f0b1d
ED
658\r
659 @retval EFI_SUCCESS Mode is changed successfully.\r
660 @retval Others Mode failed to be changed.\r
661\r
662**/\r
663EFI_STATUS\r
bcfe5adb 664UiSetConsoleMode (\r
143f0b1d
ED
665 BOOLEAN IsSetupMode\r
666 )\r
667{\r
668 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
669 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
670 UINTN SizeOfInfo;\r
671 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
672 UINT32 MaxGopMode;\r
673 UINT32 MaxTextMode;\r
674 UINT32 ModeNumber;\r
675 UINT32 NewHorizontalResolution;\r
676 UINT32 NewVerticalResolution;\r
677 UINT32 NewColumns;\r
678 UINT32 NewRows;\r
679 UINTN HandleCount;\r
680 EFI_HANDLE *HandleBuffer;\r
681 EFI_STATUS Status;\r
682 UINTN Index;\r
683 UINTN CurrentColumn;\r
c9802c45 684 UINTN CurrentRow;\r
143f0b1d
ED
685\r
686 MaxGopMode = 0;\r
687 MaxTextMode = 0;\r
688\r
689 //\r
c9802c45 690 // Get current video resolution and text mode\r
143f0b1d
ED
691 //\r
692 Status = gBS->HandleProtocol (\r
693 gST->ConsoleOutHandle,\r
694 &gEfiGraphicsOutputProtocolGuid,\r
695 (VOID**)&GraphicsOutput\r
696 );\r
697 if (EFI_ERROR (Status)) {\r
698 GraphicsOutput = NULL;\r
699 }\r
700\r
701 Status = gBS->HandleProtocol (\r
702 gST->ConsoleOutHandle,\r
703 &gEfiSimpleTextOutProtocolGuid,\r
704 (VOID**)&SimpleTextOut\r
705 );\r
706 if (EFI_ERROR (Status)) {\r
707 SimpleTextOut = NULL;\r
c9802c45 708 }\r
143f0b1d
ED
709\r
710 if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {\r
711 return EFI_UNSUPPORTED;\r
712 }\r
713\r
714 if (IsSetupMode) {\r
715 //\r
2048c585 716 // The required resolution and text mode is setup mode.\r
143f0b1d
ED
717 //\r
718 NewHorizontalResolution = mSetupHorizontalResolution;\r
719 NewVerticalResolution = mSetupVerticalResolution;\r
720 NewColumns = mSetupTextModeColumn;\r
721 NewRows = mSetupTextModeRow;\r
722 } else {\r
723 //\r
724 // The required resolution and text mode is boot mode.\r
725 //\r
726 NewHorizontalResolution = mBootHorizontalResolution;\r
727 NewVerticalResolution = mBootVerticalResolution;\r
728 NewColumns = mBootTextModeColumn;\r
c9802c45 729 NewRows = mBootTextModeRow;\r
143f0b1d 730 }\r
c9802c45 731\r
143f0b1d
ED
732 if (GraphicsOutput != NULL) {\r
733 MaxGopMode = GraphicsOutput->Mode->MaxMode;\r
c9802c45 734 }\r
143f0b1d
ED
735\r
736 if (SimpleTextOut != NULL) {\r
737 MaxTextMode = SimpleTextOut->Mode->MaxMode;\r
738 }\r
739\r
740 //\r
741 // 1. If current video resolution is same with required video resolution,\r
742 // video resolution need not be changed.\r
743 // 1.1. If current text mode is same with required text mode, text mode need not be changed.\r
744 // 1.2. If current text mode is different from required text mode, text mode need be changed.\r
745 // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.\r
746 //\r
747 for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {\r
748 Status = GraphicsOutput->QueryMode (\r
749 GraphicsOutput,\r
750 ModeNumber,\r
751 &SizeOfInfo,\r
752 &Info\r
753 );\r
754 if (!EFI_ERROR (Status)) {\r
755 if ((Info->HorizontalResolution == NewHorizontalResolution) &&\r
756 (Info->VerticalResolution == NewVerticalResolution)) {\r
757 if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&\r
758 (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {\r
759 //\r
760 // Current resolution is same with required resolution, check if text mode need be set\r
761 //\r
762 Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);\r
763 ASSERT_EFI_ERROR (Status);\r
764 if (CurrentColumn == NewColumns && CurrentRow == NewRows) {\r
765 //\r
766 // If current text mode is same with required text mode. Do nothing\r
767 //\r
768 FreePool (Info);\r
769 return EFI_SUCCESS;\r
770 } else {\r
771 //\r
2048c585 772 // If current text mode is different from required text mode. Set new video mode\r
143f0b1d
ED
773 //\r
774 for (Index = 0; Index < MaxTextMode; Index++) {\r
775 Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
776 if (!EFI_ERROR(Status)) {\r
777 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {\r
778 //\r
779 // Required text mode is supported, set it.\r
780 //\r
781 Status = SimpleTextOut->SetMode (SimpleTextOut, Index);\r
782 ASSERT_EFI_ERROR (Status);\r
783 //\r
784 // Update text mode PCD.\r
785 //\r
377680ae
ED
786 Status = PcdSet32S (PcdConOutColumn, mSetupTextModeColumn);\r
787 ASSERT_EFI_ERROR (Status);\r
788 Status = PcdSet32S (PcdConOutRow, mSetupTextModeRow);\r
789 ASSERT_EFI_ERROR (Status);\r
143f0b1d
ED
790 FreePool (Info);\r
791 return EFI_SUCCESS;\r
792 }\r
793 }\r
794 }\r
795 if (Index == MaxTextMode) {\r
796 //\r
2048c585 797 // If required text mode is not supported, return error.\r
143f0b1d
ED
798 //\r
799 FreePool (Info);\r
800 return EFI_UNSUPPORTED;\r
801 }\r
802 }\r
803 } else {\r
804 //\r
805 // If current video resolution is not same with the new one, set new video resolution.\r
806 // In this case, the driver which produces simple text out need be restarted.\r
807 //\r
808 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r
809 if (!EFI_ERROR (Status)) {\r
810 FreePool (Info);\r
811 break;\r
812 }\r
813 }\r
814 }\r
815 FreePool (Info);\r
816 }\r
817 }\r
818\r
819 if (ModeNumber == MaxGopMode) {\r
820 //\r
821 // If the resolution is not supported, return error.\r
822 //\r
823 return EFI_UNSUPPORTED;\r
824 }\r
825\r
826 //\r
827 // Set PCD to Inform GraphicsConsole to change video resolution.\r
828 // Set PCD to Inform Consplitter to change text mode.\r
829 //\r
377680ae
ED
830 Status = PcdSet32S (PcdVideoHorizontalResolution, NewHorizontalResolution);\r
831 ASSERT_EFI_ERROR (Status);\r
832 Status = PcdSet32S (PcdVideoVerticalResolution, NewVerticalResolution);\r
833 ASSERT_EFI_ERROR (Status);\r
834 Status = PcdSet32S (PcdConOutColumn, NewColumns);\r
835 ASSERT_EFI_ERROR (Status);\r
836 Status = PcdSet32S (PcdConOutRow, NewRows);\r
837 ASSERT_EFI_ERROR (Status);\r
c9802c45 838\r
143f0b1d
ED
839 //\r
840 // Video mode is changed, so restart graphics console driver and higher level driver.\r
841 // Reconnect graphics console driver and higher level driver.\r
842 // Locate all the handles with GOP protocol and reconnect it.\r
843 //\r
844 Status = gBS->LocateHandleBuffer (\r
845 ByProtocol,\r
846 &gEfiSimpleTextOutProtocolGuid,\r
847 NULL,\r
848 &HandleCount,\r
849 &HandleBuffer\r
850 );\r
851 if (!EFI_ERROR (Status)) {\r
852 for (Index = 0; Index < HandleCount; Index++) {\r
853 gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
854 }\r
855 for (Index = 0; Index < HandleCount; Index++) {\r
856 gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
857 }\r
858 if (HandleBuffer != NULL) {\r
859 FreePool (HandleBuffer);\r
860 }\r
861 }\r
862\r
863 return EFI_SUCCESS;\r
864}\r
865\r
866/**\r
867 The user Entry Point for Application. The user code starts with this function\r
c9802c45 868 as the real entry point for the image goes into a library that calls this\r
143f0b1d
ED
869 function.\r
870\r
c9802c45 871 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
143f0b1d 872 @param[in] SystemTable A pointer to the EFI System Table.\r
c9802c45 873\r
143f0b1d
ED
874 @retval EFI_SUCCESS The entry point is executed successfully.\r
875 @retval other Some error occurs when executing this entry point.\r
876\r
877**/\r
878EFI_STATUS\r
879EFIAPI\r
880InitializeUserInterface (\r
881 IN EFI_HANDLE ImageHandle,\r
882 IN EFI_SYSTEM_TABLE *SystemTable\r
883 )\r
884{\r
885 EFI_HII_HANDLE HiiHandle;\r
886 EFI_STATUS Status;\r
887 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
888 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
889 UINTN BootTextColumn;\r
890 UINTN BootTextRow;\r
891\r
892 if (!mModeInitialized) {\r
893 //\r
c9802c45 894 // After the console is ready, get current video resolution\r
143f0b1d
ED
895 // and text mode before launching setup at first time.\r
896 //\r
897 Status = gBS->HandleProtocol (\r
898 gST->ConsoleOutHandle,\r
899 &gEfiGraphicsOutputProtocolGuid,\r
900 (VOID**)&GraphicsOutput\r
901 );\r
902 if (EFI_ERROR (Status)) {\r
903 GraphicsOutput = NULL;\r
904 }\r
c9802c45 905\r
143f0b1d
ED
906 Status = gBS->HandleProtocol (\r
907 gST->ConsoleOutHandle,\r
908 &gEfiSimpleTextOutProtocolGuid,\r
909 (VOID**)&SimpleTextOut\r
910 );\r
911 if (EFI_ERROR (Status)) {\r
912 SimpleTextOut = NULL;\r
c9802c45 913 }\r
143f0b1d
ED
914\r
915 if (GraphicsOutput != NULL) {\r
916 //\r
917 // Get current video resolution and text mode.\r
918 //\r
919 mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
920 mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
921 }\r
922\r
923 if (SimpleTextOut != NULL) {\r
924 Status = SimpleTextOut->QueryMode (\r
925 SimpleTextOut,\r
926 SimpleTextOut->Mode->Mode,\r
927 &BootTextColumn,\r
928 &BootTextRow\r
929 );\r
930 mBootTextModeColumn = (UINT32)BootTextColumn;\r
931 mBootTextModeRow = (UINT32)BootTextRow;\r
932 }\r
933\r
934 //\r
935 // Get user defined text mode for setup.\r
c9802c45 936 //\r
143f0b1d 937 mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
c9802c45 938 mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);\r
143f0b1d
ED
939 mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);\r
940 mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);\r
941\r
942 mModeInitialized = TRUE;\r
943 }\r
944\r
945 gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
946 gST->ConOut->ClearScreen (gST->ConOut);\r
c9802c45 947\r
143f0b1d
ED
948 //\r
949 // Install customized fonts needed by Front Page\r
950 //\r
143f0b1d
ED
951 HiiHandle = ExportFonts ();\r
952 ASSERT (HiiHandle != NULL);\r
953\r
954 InitializeStringSupport ();\r
955\r
bcfe5adb 956 UiSetConsoleMode (TRUE);\r
143f0b1d 957 UiEntry (FALSE);\r
bcfe5adb 958 UiSetConsoleMode (FALSE);\r
143f0b1d
ED
959\r
960 UninitializeStringSupport ();\r
961 HiiRemovePackages (HiiHandle);\r
962\r
963 return EFI_SUCCESS;\r
964}\r
965\r
966/**\r
967 This function is the main entry of the UI entry.\r
968 The function will present the main menu of the system UI.\r
969\r
970 @param ConnectAllHappened Caller passes the value to UI to avoid unnecessary connect-all.\r
971\r
972**/\r
973VOID\r
974EFIAPI\r
975UiEntry (\r
976 IN BOOLEAN ConnectAllHappened\r
977 )\r
978{\r
979 EFI_STATUS Status;\r
980 EFI_BOOT_LOGO_PROTOCOL *BootLogo;\r
981\r
7266e2f6
ED
982 //\r
983 // Enter Setup page.\r
984 //\r
985 REPORT_STATUS_CODE (\r
986 EFI_PROGRESS_CODE,\r
987 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)\r
988 );\r
989\r
143f0b1d
ED
990 //\r
991 // Indicate if the connect all has been performed before.\r
a0d1206f 992 // If has not been performed before, do here.\r
143f0b1d 993 //\r
a0d1206f
DB
994 if (!ConnectAllHappened) {\r
995 EfiBootManagerConnectAll ();\r
143f0b1d
ED
996 }\r
997\r
998 //\r
999 // The boot option enumeration time is acceptable in Ui driver\r
1000 //\r
1001 EfiBootManagerRefreshAllBootOption ();\r
1002\r
1003 //\r
1004 // Boot Logo is corrupted, report it using Boot Logo protocol.\r
1005 //\r
1006 Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);\r
1007 if (!EFI_ERROR (Status) && (BootLogo != NULL)) {\r
1008 BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);\r
1009 }\r
1010\r
1011 InitializeFrontPage ();\r
143f0b1d
ED
1012\r
1013 CallFrontPage ();\r
1014\r
143f0b1d
ED
1015 FreeFrontPage ();\r
1016\r
1017 if (mLanguageString != NULL) {\r
1018 FreePool (mLanguageString);\r
1019 mLanguageString = NULL;\r
1020 }\r
1021\r
1022 //\r
1023 //Will leave browser, check any reset required change is applied? if yes, reset system\r
1024 //\r
1025 SetupResetReminder ();\r
1026}\r
1027\r
143f0b1d
ED
1028//\r
1029// Following are BDS Lib functions which contain all the code about setup browser reset reminder feature.\r
1030// Setup Browser reset reminder feature is that an reset reminder will be given before user leaves the setup browser if\r
1031// user change any option setting which needs a reset to be effective, and the reset will be applied according to the user selection.\r
1032//\r
1033\r
1034\r
1035/**\r
1036 Enable the setup browser reset reminder feature.\r
1037 This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.\r
1038\r
1039**/\r
1040VOID\r
1041EFIAPI\r
1042EnableResetReminderFeature (\r
1043 VOID\r
1044 )\r
1045{\r
1046 mFeaturerSwitch = TRUE;\r
1047}\r
1048\r
1049\r
1050/**\r
1051 Disable the setup browser reset reminder feature.\r
1052 This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.\r
1053\r
1054**/\r
1055VOID\r
1056EFIAPI\r
1057DisableResetReminderFeature (\r
1058 VOID\r
1059 )\r
1060{\r
1061 mFeaturerSwitch = FALSE;\r
1062}\r
1063\r
1064\r
1065/**\r
1066 Record the info that a reset is required.\r
1067 A module boolean variable is used to record whether a reset is required.\r
1068\r
1069**/\r
1070VOID\r
1071EFIAPI\r
1072EnableResetRequired (\r
1073 VOID\r
1074 )\r
1075{\r
1076 mResetRequired = TRUE;\r
1077}\r
1078\r
1079\r
1080/**\r
1081 Record the info that no reset is required.\r
1082 A module boolean variable is used to record whether a reset is required.\r
1083\r
1084**/\r
1085VOID\r
1086EFIAPI\r
1087DisableResetRequired (\r
1088 VOID\r
1089 )\r
1090{\r
1091 mResetRequired = FALSE;\r
1092}\r
1093\r
1094\r
1095/**\r
1096 Check whether platform policy enable the reset reminder feature. The default is enabled.\r
1097\r
1098**/\r
1099BOOLEAN\r
1100EFIAPI\r
1101IsResetReminderFeatureEnable (\r
1102 VOID\r
1103 )\r
1104{\r
1105 return mFeaturerSwitch;\r
1106}\r
1107\r
1108\r
1109/**\r
1110 Check if user changed any option setting which needs a system reset to be effective.\r
1111\r
1112**/\r
1113BOOLEAN\r
1114EFIAPI\r
1115IsResetRequired (\r
1116 VOID\r
1117 )\r
1118{\r
1119 return mResetRequired;\r
1120}\r
1121\r
1122\r
1123/**\r
1124 Check whether a reset is needed, and finish the reset reminder feature.\r
1125 If a reset is needed, Popup a menu to notice user, and finish the feature\r
1126 according to the user selection.\r
1127\r
1128**/\r
1129VOID\r
1130EFIAPI\r
1131SetupResetReminder (\r
1132 VOID\r
1133 )\r
1134{\r
1135 EFI_INPUT_KEY Key;\r
1136 CHAR16 *StringBuffer1;\r
1137 CHAR16 *StringBuffer2;\r
1138\r
1139\r
1140 //\r
1141 //check any reset required change is applied? if yes, reset system\r
1142 //\r
1143 if (IsResetReminderFeatureEnable ()) {\r
1144 if (IsResetRequired ()) {\r
1145\r
1146 StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
1147 ASSERT (StringBuffer1 != NULL);\r
1148 StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
1149 ASSERT (StringBuffer2 != NULL);\r
d91cb870
DB
1150 StrCpyS (StringBuffer1, MAX_STRING_LEN, L"Configuration changed. Reset to apply it Now.");\r
1151 StrCpyS (StringBuffer2, MAX_STRING_LEN, L"Press ENTER to reset");\r
143f0b1d
ED
1152 //\r
1153 // Popup a menu to notice user\r
1154 //\r
1155 do {\r
1156 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
1157 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
1158\r
1159 FreePool (StringBuffer1);\r
1160 FreePool (StringBuffer2);\r
1161\r
1162 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
1163 }\r
1164 }\r
1165}\r
1166\r