Update for IntelFrameworkModulePkg.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / FrontPage.c
CommitLineData
5c08e117 1/** @file\r
2 FrontPage routines to handle the callbacks and browser calls\r
3\r
d394581d 4Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
180a5a35 5This program and the accompanying materials\r
5c08e117 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 "Bds.h"\r
16#include "FrontPage.h"\r
ad5a96ab 17#include "Language.h"\r
d394581d 18#include "Hotkey.h"\r
5c08e117 19\r
32bc1227 20BOOLEAN mSetupModeInitialized = FALSE;\r
21UINT32 mSetupTextModeColumn;\r
22UINT32 mSetupTextModeRow;\r
23UINT32 mSetupHorizontalResolution;\r
24UINT32 mSetupVerticalResolution;\r
25\r
5c08e117 26BOOLEAN gConnectAllHappened = FALSE;\r
27UINTN gCallbackKey;\r
28\r
5c08e117 29EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;\r
5c08e117 30\r
31FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate = {\r
32 FRONT_PAGE_CALLBACK_DATA_SIGNATURE,\r
33 NULL,\r
34 NULL,\r
35 NULL,\r
36 {\r
37 FakeExtractConfig,\r
38 FakeRouteConfig,\r
39 FrontPageCallback\r
40 }\r
41};\r
42\r
f6f910dd 43HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = {\r
44 {\r
45 {\r
46 HARDWARE_DEVICE_PATH,\r
47 HW_VENDOR_DP,\r
48 {\r
49 (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
50 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
51 }\r
52 },\r
e24fc103 53 FRONT_PAGE_FORMSET_GUID\r
f6f910dd 54 },\r
55 {\r
56 END_DEVICE_PATH_TYPE,\r
57 END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
128efbbc 58 {\r
f6f910dd 59 (UINT8) (END_DEVICE_PATH_LENGTH),\r
60 (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
61 }\r
62 }\r
63};\r
64\r
5c08e117 65/**\r
66 This function allows a caller to extract the current configuration for one\r
67 or more named elements from the target driver.\r
68\r
69\r
70 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
71 @param Request A null-terminated Unicode string in <ConfigRequest> format.\r
72 @param Progress On return, points to a character in the Request string.\r
73 Points to the string's null terminator if request was successful.\r
74 Points to the most recent '&' before the first failing name/value\r
75 pair (or the beginning of the string if the failure is in the\r
76 first name/value pair) if the request was not successful.\r
77 @param Results A null-terminated Unicode string in <ConfigAltResp> format which\r
78 has all values filled in for the names in the Request string.\r
79 String to be allocated by the called function.\r
80\r
81 @retval EFI_SUCCESS The Results is filled with the requested values.\r
82 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
59aefb7e 83 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
5c08e117 84 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
85\r
86**/\r
87EFI_STATUS\r
88EFIAPI\r
89FakeExtractConfig (\r
90 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
91 IN CONST EFI_STRING Request,\r
92 OUT EFI_STRING *Progress,\r
93 OUT EFI_STRING *Results\r
94 )\r
95{\r
59aefb7e 96 if (Progress == NULL || Results == NULL) {\r
dedfc3bb
LG
97 return EFI_INVALID_PARAMETER;\r
98 }\r
cdcc36ae 99 *Progress = Request;\r
5c08e117 100 return EFI_NOT_FOUND;\r
101}\r
102\r
103/**\r
104 This function processes the results of changes in configuration.\r
105\r
106\r
107 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
108 @param Configuration A null-terminated Unicode string in <ConfigResp> format.\r
109 @param Progress A pointer to a string filled in with the offset of the most\r
110 recent '&' before the first failing name/value pair (or the\r
111 beginning of the string if the failure is in the first\r
112 name/value pair) or the terminating NULL if all was successful.\r
113\r
114 @retval EFI_SUCCESS The Results is processed successfully.\r
115 @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
116 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
117\r
118**/\r
119EFI_STATUS\r
120EFIAPI\r
121FakeRouteConfig (\r
122 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
123 IN CONST EFI_STRING Configuration,\r
124 OUT EFI_STRING *Progress\r
125 )\r
126{\r
dedfc3bb 127 if (Configuration == NULL || Progress == NULL) {\r
cdcc36ae
LG
128 return EFI_INVALID_PARAMETER;\r
129 }\r
130\r
dedfc3bb 131 *Progress = Configuration;\r
e24fc103
LG
132 if (!HiiIsConfigHdrMatch (Configuration, &gBootMaintFormSetGuid, mBootMaintStorageName)\r
133 && !HiiIsConfigHdrMatch (Configuration, &gFileExploreFormSetGuid, mFileExplorerStorageName)) {\r
dedfc3bb 134 return EFI_NOT_FOUND;\r
cdcc36ae
LG
135 }\r
136\r
dedfc3bb
LG
137 *Progress = Configuration + StrLen (Configuration);\r
138 return EFI_SUCCESS;\r
5c08e117 139}\r
140\r
141/**\r
142 This function processes the results of changes in configuration.\r
143\r
144\r
145 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
146 @param Action Specifies the type of action taken by the browser.\r
147 @param QuestionId A unique value which is sent to the original exporting driver\r
148 so that it can identify the type of data to expect.\r
149 @param Type The type of value for the question.\r
150 @param Value A pointer to the data being sent to the original exporting driver.\r
151 @param ActionRequest On return, points to the action requested by the callback function.\r
152\r
153 @retval EFI_SUCCESS The callback successfully handled the action.\r
154 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
155 @retval EFI_DEVICE_ERROR The variable could not be saved.\r
156 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.\r
157\r
158**/\r
159EFI_STATUS\r
160EFIAPI\r
161FrontPageCallback (\r
162 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
163 IN EFI_BROWSER_ACTION Action,\r
164 IN EFI_QUESTION_ID QuestionId,\r
165 IN UINT8 Type,\r
166 IN EFI_IFR_TYPE_VALUE *Value,\r
167 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
168 )\r
169{\r
170 CHAR8 *LanguageString;\r
171 CHAR8 *LangCode;\r
a3a795af 172 CHAR8 *Lang;\r
5c08e117 173 UINTN Index;\r
174 EFI_STATUS Status;\r
a3a795af 175 CHAR8 *PlatformSupportedLanguages;\r
176 CHAR8 *BestLanguage;\r
5c08e117 177\r
84724077
ED
178 if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {\r
179 //\r
180 // All other action return unsupported.\r
181 //\r
182 return EFI_UNSUPPORTED;\r
183 }\r
184 \r
185 gCallbackKey = QuestionId;\r
186\r
187 if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
d88f86f1
ED
188 if ((Value == NULL) || (ActionRequest == NULL)) {\r
189 return EFI_INVALID_PARAMETER;\r
190 }\r
5c08e117 191\r
d88f86f1
ED
192 switch (QuestionId) {\r
193 case FRONT_PAGE_KEY_CONTINUE:\r
194 //\r
195 // This is the continue - clear the screen and return an error to get out of FrontPage loop\r
196 //\r
84724077 197 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
d88f86f1
ED
198 break;\r
199\r
200 case FRONT_PAGE_KEY_LANGUAGE:\r
201 //\r
202 // Collect the languages from what our current Language support is based on our VFR\r
203 //\r
204 LanguageString = HiiGetSupportedLanguages (gFrontPagePrivate.HiiHandle);\r
205 ASSERT (LanguageString != NULL);\r
206 //\r
207 // Allocate working buffer for RFC 4646 language in supported LanguageString.\r
208 //\r
209 Lang = AllocatePool (AsciiStrSize (LanguageString));\r
210 ASSERT (Lang != NULL);\r
211\r
212 Index = 0;\r
213 LangCode = LanguageString;\r
214 while (*LangCode != 0) {\r
215 GetNextLanguage (&LangCode, Lang);\r
216\r
217 if (Index == Value->u8) {\r
218 break;\r
219 }\r
220\r
221 Index++;\r
5c08e117 222 }\r
223\r
d88f86f1
ED
224 PlatformSupportedLanguages = GetEfiGlobalVariable (L"PlatformLangCodes");\r
225 if (PlatformSupportedLanguages == NULL) {\r
226 PlatformSupportedLanguages = AllocateCopyPool (\r
227 AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),\r
228 (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)\r
229 );\r
230 ASSERT (PlatformSupportedLanguages != NULL);\r
231 }\r
5c08e117 232\r
d88f86f1
ED
233 //\r
234 // Select the best language in platform supported Language.\r
235 //\r
236 BestLanguage = GetBestLanguage (\r
237 PlatformSupportedLanguages,\r
238 FALSE,\r
239 Lang,\r
240 NULL\r
241 );\r
242 if (BestLanguage != NULL) {\r
243 Status = gRT->SetVariable (\r
244 L"PlatformLang",\r
245 &gEfiGlobalVariableGuid,\r
246 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
247 AsciiStrSize (BestLanguage),\r
248 Lang\r
249 );\r
250 ASSERT_EFI_ERROR(Status);\r
251 FreePool (BestLanguage);\r
252 } else {\r
253 ASSERT (FALSE);\r
254 }\r
128efbbc 255\r
84724077
ED
256 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
257\r
d88f86f1
ED
258 FreePool (PlatformSupportedLanguages);\r
259 FreePool (Lang);\r
260 FreePool (LanguageString);\r
261 break;\r
262\r
84724077
ED
263 default:\r
264 break;\r
265 }\r
266 } else if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
267 if (Value == NULL) {\r
268 return EFI_INVALID_PARAMETER;\r
269 }\r
270\r
271 //\r
272 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
273 // describe to their customers in documentation how to find their setup information (namely\r
274 // under the device manager and specific buckets)\r
275 //\r
276 switch (QuestionId) {\r
d88f86f1
ED
277 case FRONT_PAGE_KEY_BOOT_MANAGER:\r
278 //\r
279 // Boot Manager\r
280 //\r
281 break;\r
282\r
283 case FRONT_PAGE_KEY_DEVICE_MANAGER:\r
284 //\r
285 // Device Manager\r
286 //\r
287 break;\r
288\r
289 case FRONT_PAGE_KEY_BOOT_MAINTAIN:\r
290 //\r
291 // Boot Maintenance Manager\r
292 //\r
293 break;\r
294\r
295 default:\r
296 gCallbackKey = 0;\r
297 break;\r
5c08e117 298 }\r
5c08e117 299 }\r
300\r
84724077 301 return EFI_SUCCESS; \r
5c08e117 302}\r
303\r
304/**\r
305 Initialize HII information for the FrontPage\r
306\r
307\r
308 @param InitializeHiiData TRUE if HII elements need to be initialized.\r
309\r
310 @retval EFI_SUCCESS The operation is successful.\r
311 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.\r
312\r
313**/\r
314EFI_STATUS\r
315InitializeFrontPage (\r
316 IN BOOLEAN InitializeHiiData\r
317 )\r
318{\r
319 EFI_STATUS Status;\r
5c08e117 320 CHAR8 *LanguageString;\r
321 CHAR8 *LangCode;\r
a3a795af 322 CHAR8 *Lang;\r
323 CHAR8 *CurrentLang;\r
324 CHAR8 *BestLanguage;\r
5c08e117 325 UINTN OptionCount;\r
5c08e117 326 CHAR16 *StringBuffer;\r
5c08e117 327 EFI_HII_HANDLE HiiHandle;\r
75bf9d0e
LG
328 VOID *OptionsOpCodeHandle;\r
329 VOID *StartOpCodeHandle;\r
330 VOID *EndOpCodeHandle;\r
331 EFI_IFR_GUID_LABEL *StartLabel;\r
332 EFI_IFR_GUID_LABEL *EndLabel;\r
333 BOOLEAN FirstFlag;\r
5c08e117 334\r
335 if (InitializeHiiData) {\r
336 //\r
337 // Initialize the Device Manager\r
338 //\r
339 InitializeDeviceManager ();\r
340\r
341 //\r
342 // Initialize the Device Manager\r
343 //\r
344 InitializeBootManager ();\r
345\r
346 gCallbackKey = 0;\r
347\r
348 //\r
349 // Locate Hii relative protocols\r
350 //\r
5c08e117 351 Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFormBrowser2);\r
352 if (EFI_ERROR (Status)) {\r
353 return Status;\r
354 }\r
355\r
5c08e117 356 //\r
f6f910dd 357 // Install Device Path Protocol and Config Access protocol to driver handle\r
5c08e117 358 //\r
f6f910dd 359 Status = gBS->InstallMultipleProtocolInterfaces (\r
5c08e117 360 &gFrontPagePrivate.DriverHandle,\r
f6f910dd 361 &gEfiDevicePathProtocolGuid,\r
362 &mFrontPageHiiVendorDevicePath,\r
5c08e117 363 &gEfiHiiConfigAccessProtocolGuid,\r
f6f910dd 364 &gFrontPagePrivate.ConfigAccess,\r
365 NULL\r
5c08e117 366 );\r
367 ASSERT_EFI_ERROR (Status);\r
368\r
369 //\r
370 // Publish our HII data\r
371 //\r
cb7d01c0 372 gFrontPagePrivate.HiiHandle = HiiAddPackages (\r
e24fc103 373 &gFrontPageFormSetGuid,\r
cb7d01c0 374 gFrontPagePrivate.DriverHandle,\r
375 FrontPageVfrBin,\r
376 BdsDxeStrings,\r
377 NULL\r
378 );\r
379 if (gFrontPagePrivate.HiiHandle == NULL) {\r
380 return EFI_OUT_OF_RESOURCES;\r
5c08e117 381 }\r
382 }\r
383\r
5c08e117 384\r
385 //\r
75bf9d0e 386 // Init OpCode Handle and Allocate space for creation of UpdateData Buffer\r
5c08e117 387 //\r
75bf9d0e
LG
388 StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
389 ASSERT (StartOpCodeHandle != NULL);\r
5c08e117 390\r
75bf9d0e
LG
391 EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
392 ASSERT (EndOpCodeHandle != NULL);\r
393\r
394 OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
395 ASSERT (OptionsOpCodeHandle != NULL);\r
396 //\r
397 // Create Hii Extend Label OpCode as the start opcode\r
398 //\r
399 StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
400 StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
401 StartLabel->Number = LABEL_SELECT_LANGUAGE;\r
402\r
403 //\r
404 // Create Hii Extend Label OpCode as the end opcode\r
405 //\r
406 EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
407 EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
408 EndLabel->Number = LABEL_END;\r
5c08e117 409\r
410 //\r
411 // Collect the languages from what our current Language support is based on our VFR\r
412 //\r
413 HiiHandle = gFrontPagePrivate.HiiHandle;\r
cb7d01c0 414 LanguageString = HiiGetSupportedLanguages (HiiHandle);\r
5c08e117 415 ASSERT (LanguageString != NULL);\r
a3a795af 416 //\r
417 // Allocate working buffer for RFC 4646 language in supported LanguageString.\r
418 //\r
419 Lang = AllocatePool (AsciiStrSize (LanguageString));\r
420 ASSERT (Lang != NULL);\r
421\r
422 CurrentLang = GetEfiGlobalVariable (L"PlatformLang");\r
423 //\r
424 // Select the best language in LanguageString as the default one.\r
425 //\r
426 BestLanguage = GetBestLanguage (\r
427 LanguageString,\r
428 FALSE,\r
429 (CurrentLang != NULL) ? CurrentLang : "",\r
430 (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang),\r
431 LanguageString,\r
432 NULL\r
433 );\r
434 //\r
435 // BestLanguage must be selected as it is the first language in LanguageString by default\r
436 //\r
437 ASSERT (BestLanguage != NULL);\r
5c08e117 438\r
75bf9d0e
LG
439 OptionCount = 0;\r
440 LangCode = LanguageString;\r
441 FirstFlag = FALSE;\r
128efbbc 442\r
75bf9d0e
LG
443 if (gFrontPagePrivate.LanguageToken == NULL) {\r
444 while (*LangCode != 0) {\r
0b3f5a4d 445 GetNextLanguage (&LangCode, Lang);\r
75bf9d0e
LG
446 OptionCount ++;\r
447 }\r
8df1634c 448 gFrontPagePrivate.LanguageToken = AllocatePool (OptionCount * sizeof (EFI_STRING_ID));\r
75bf9d0e
LG
449 ASSERT (gFrontPagePrivate.LanguageToken != NULL);\r
450 FirstFlag = TRUE;\r
451 }\r
452\r
5c08e117 453 OptionCount = 0;\r
454 LangCode = LanguageString;\r
455 while (*LangCode != 0) {\r
0f268521 456 GetNextLanguage (&LangCode, Lang);\r
5c08e117 457\r
75bf9d0e 458 if (FirstFlag) {\r
33bb6326 459 StringBuffer = HiiGetString (HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, Lang);\r
7f97c9bb 460 ASSERT (StringBuffer != NULL);\r
5c08e117 461\r
75bf9d0e
LG
462 //\r
463 // Save the string Id for each language\r
464 //\r
465 gFrontPagePrivate.LanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);\r
5c08e117 466 FreePool (StringBuffer);\r
5c08e117 467 }\r
468\r
a3a795af 469 if (AsciiStrCmp (Lang, BestLanguage) == 0) {\r
75bf9d0e
LG
470 HiiCreateOneOfOptionOpCode (\r
471 OptionsOpCodeHandle,\r
472 gFrontPagePrivate.LanguageToken[OptionCount],\r
473 EFI_IFR_OPTION_DEFAULT,\r
474 EFI_IFR_NUMERIC_SIZE_1,\r
475 (UINT8) OptionCount\r
476 );\r
5c08e117 477 } else {\r
75bf9d0e
LG
478 HiiCreateOneOfOptionOpCode (\r
479 OptionsOpCodeHandle,\r
480 gFrontPagePrivate.LanguageToken[OptionCount],\r
481 0,\r
482 EFI_IFR_NUMERIC_SIZE_1,\r
483 (UINT8) OptionCount\r
484 );\r
5c08e117 485 }\r
5c08e117 486\r
487 OptionCount++;\r
488 }\r
489\r
a3a795af 490 if (CurrentLang != NULL) {\r
491 FreePool (CurrentLang);\r
492 }\r
493 FreePool (BestLanguage);\r
494 FreePool (Lang);\r
5c08e117 495 FreePool (LanguageString);\r
496\r
75bf9d0e
LG
497 HiiCreateOneOfOpCode (\r
498 StartOpCodeHandle,\r
5c08e117 499 FRONT_PAGE_KEY_LANGUAGE,\r
500 0,\r
501 0,\r
502 STRING_TOKEN (STR_LANGUAGE_SELECT),\r
503 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP),\r
504 EFI_IFR_FLAG_CALLBACK,\r
505 EFI_IFR_NUMERIC_SIZE_1,\r
75bf9d0e
LG
506 OptionsOpCodeHandle,\r
507 NULL\r
5c08e117 508 );\r
509\r
75bf9d0e 510 Status = HiiUpdateForm (\r
5c08e117 511 HiiHandle,\r
e24fc103 512 &gFrontPageFormSetGuid,\r
5c08e117 513 FRONT_PAGE_FORM_ID,\r
75bf9d0e
LG
514 StartOpCodeHandle, // LABEL_SELECT_LANGUAGE\r
515 EndOpCodeHandle // LABEL_END\r
5c08e117 516 );\r
517\r
75bf9d0e
LG
518 HiiFreeOpCodeHandle (StartOpCodeHandle);\r
519 HiiFreeOpCodeHandle (EndOpCodeHandle);\r
520 HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
5c08e117 521 return Status;\r
522}\r
523\r
524/**\r
525 Call the browser and display the front page\r
526\r
527 @return Status code that will be returned by\r
528 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().\r
529\r
530**/\r
531EFI_STATUS\r
532CallFrontPage (\r
533 VOID\r
534 )\r
535{\r
536 EFI_STATUS Status;\r
537 EFI_BROWSER_ACTION_REQUEST ActionRequest;\r
538\r
539 //\r
540 // Begin waiting for USER INPUT\r
541 //\r
542 REPORT_STATUS_CODE (\r
543 EFI_PROGRESS_CODE,\r
544 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)\r
545 );\r
546\r
547 ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
548 Status = gFormBrowser2->SendForm (\r
549 gFormBrowser2,\r
550 &gFrontPagePrivate.HiiHandle,\r
551 1,\r
e24fc103 552 &gFrontPageFormSetGuid,\r
5c08e117 553 0,\r
554 NULL,\r
555 &ActionRequest\r
556 );\r
557 //\r
baf46e70 558 // Check whether user change any option setting which needs a reset to be effective\r
5c08e117 559 //\r
560 if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
561 EnableResetRequired ();\r
562 }\r
563\r
564 return Status;\r
565}\r
566\r
567/**\r
568 Acquire the string associated with the ProducerGuid and return it.\r
569\r
570\r
571 @param ProducerGuid The Guid to search the HII database for\r
572 @param Token The token value of the string to extract\r
573 @param String The string that is extracted\r
574\r
575 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.\r
576\r
577**/\r
578EFI_STATUS\r
579GetProducerString (\r
580 IN EFI_GUID *ProducerGuid,\r
581 IN EFI_STRING_ID Token,\r
582 OUT CHAR16 **String\r
583 )\r
584{\r
cb7d01c0 585 EFI_STRING TmpString;\r
5c08e117 586\r
cb7d01c0 587 TmpString = HiiGetPackageString (ProducerGuid, Token, NULL);\r
588 if (TmpString == NULL) {\r
5c08e117 589 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
cb7d01c0 590 } else {\r
591 *String = TmpString;\r
5c08e117 592 }\r
593\r
594 return EFI_SUCCESS;\r
595}\r
596\r
597/**\r
13078b3f 598 Convert Processor Frequency Data to a string.\r
5c08e117 599\r
600 @param ProcessorFrequency The frequency data to process\r
6cfbf7ad 601 @param Base10Exponent The exponent based on 10\r
5c08e117 602 @param String The string that is created\r
603\r
604**/\r
605VOID\r
606ConvertProcessorToString (\r
6cfbf7ad 607 IN UINT16 ProcessorFrequency,\r
608 IN UINT16 Base10Exponent,\r
609 OUT CHAR16 **String\r
5c08e117 610 )\r
611{\r
612 CHAR16 *StringBuffer;\r
613 UINTN Index;\r
614 UINT32 FreqMhz;\r
615\r
6cfbf7ad 616 if (Base10Exponent >= 6) {\r
617 FreqMhz = ProcessorFrequency;\r
618 for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) {\r
5c08e117 619 FreqMhz *= 10;\r
620 }\r
621 } else {\r
622 FreqMhz = 0;\r
623 }\r
624\r
625 StringBuffer = AllocateZeroPool (0x20);\r
626 ASSERT (StringBuffer != NULL);\r
627 Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);\r
628 StrCat (StringBuffer, L".");\r
629 UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);\r
630 StrCat (StringBuffer, L" GHz");\r
5c08e117 631 *String = (CHAR16 *) StringBuffer;\r
5c08e117 632 return ;\r
633}\r
634\r
6cfbf7ad 635\r
5c08e117 636/**\r
637 Convert Memory Size to a string.\r
638\r
639 @param MemorySize The size of the memory to process\r
640 @param String The string that is created\r
641\r
642**/\r
643VOID\r
644ConvertMemorySizeToString (\r
645 IN UINT32 MemorySize,\r
646 OUT CHAR16 **String\r
647 )\r
648{\r
649 CHAR16 *StringBuffer;\r
650\r
651 StringBuffer = AllocateZeroPool (0x20);\r
652 ASSERT (StringBuffer != NULL);\r
653 UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);\r
654 StrCat (StringBuffer, L" MB RAM");\r
655\r
656 *String = (CHAR16 *) StringBuffer;\r
657\r
658 return ;\r
659}\r
660\r
6cfbf7ad 661/**\r
662\r
663 Acquire the string associated with the Index from smbios structure and return it.\r
664 The caller is responsible for free the string buffer.\r
665\r
666 @param OptionalStrStart The start position to search the string\r
667 @param Index The index of the string to extract\r
668 @param String The string that is extracted\r
669\r
670 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.\r
671\r
672**/\r
673EFI_STATUS\r
674GetOptionalStringByIndex (\r
675 IN CHAR8 *OptionalStrStart,\r
676 IN UINT8 Index,\r
677 OUT CHAR16 **String\r
678 )\r
679{\r
2ca7eca4 680 UINTN StrSize;\r
6cfbf7ad 681\r
2ca7eca4
RN
682 if (Index == 0) {\r
683 *String = AllocateZeroPool (sizeof (CHAR16));\r
684 return EFI_SUCCESS;\r
685 }\r
6cfbf7ad 686\r
2ca7eca4
RN
687 StrSize = 0;\r
688 do {\r
689 Index--;\r
690 OptionalStrStart += StrSize;\r
691 StrSize = AsciiStrSize (OptionalStrStart);\r
692 } while (OptionalStrStart[StrSize] != 0 && Index != 0);\r
693\r
d69bf66d
RN
694 if ((Index != 0) || (StrSize == 1)) {\r
695 //\r
696 // Meet the end of strings set but Index is non-zero, or\r
697 // Find an empty string\r
698 //\r
2ca7eca4 699 *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
6cfbf7ad 700 } else {\r
2ca7eca4
RN
701 *String = AllocatePool (StrSize * sizeof (CHAR16));\r
702 AsciiStrToUnicodeStr (OptionalStrStart, *String);\r
6cfbf7ad 703 }\r
704\r
6cfbf7ad 705 return EFI_SUCCESS;\r
706}\r
707\r
708\r
5c08e117 709/**\r
710 Update the banner information for the Front Page based on DataHub information.\r
711\r
712**/\r
713VOID\r
714UpdateFrontPageStrings (\r
715 VOID\r
716 )\r
717{\r
6cfbf7ad 718 UINT8 StrIndex;\r
5c08e117 719 CHAR16 *NewString;\r
5c08e117 720 BOOLEAN Find[5];\r
6cfbf7ad 721 EFI_STATUS Status;\r
722 EFI_STRING_ID TokenToUpdate;\r
723 EFI_SMBIOS_HANDLE SmbiosHandle;\r
724 EFI_SMBIOS_PROTOCOL *Smbios;\r
725 SMBIOS_TABLE_TYPE0 *Type0Record;\r
726 SMBIOS_TABLE_TYPE1 *Type1Record;\r
727 SMBIOS_TABLE_TYPE4 *Type4Record;\r
728 SMBIOS_TABLE_TYPE19 *Type19Record;\r
729 EFI_SMBIOS_TABLE_HEADER *Record;\r
5c08e117 730\r
731 ZeroMem (Find, sizeof (Find));\r
732\r
733 //\r
734 // Update Front Page strings\r
735 //\r
736 Status = gBS->LocateProtocol (\r
6cfbf7ad 737 &gEfiSmbiosProtocolGuid,\r
5c08e117 738 NULL,\r
6cfbf7ad 739 (VOID **) &Smbios\r
5c08e117 740 );\r
741 ASSERT_EFI_ERROR (Status);\r
742\r
49975acb 743 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
5c08e117 744 do {\r
6cfbf7ad 745 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);\r
746 if (EFI_ERROR(Status)) {\r
b55f8b01
LG
747 break;\r
748 }\r
5c08e117 749\r
6cfbf7ad 750 if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {\r
751 Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;\r
752 StrIndex = Type0Record->BiosVersion;\r
ed79462b 753 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);\r
6cfbf7ad 754 TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);\r
755 HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
756 FreePool (NewString);\r
757 Find[0] = TRUE;\r
758 } \r
759\r
760 if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {\r
761 Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;\r
762 StrIndex = Type1Record->ProductName;\r
ed79462b 763 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);\r
6cfbf7ad 764 TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);\r
765 HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
766 FreePool (NewString);\r
767 Find[1] = TRUE;\r
5c08e117 768 }\r
6cfbf7ad 769 \r
770 if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {\r
771 Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;\r
772 StrIndex = Type4Record->ProcessorVersion;\r
ed79462b 773 GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);\r
6cfbf7ad 774 TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);\r
775 HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
776 FreePool (NewString);\r
777 Find[2] = TRUE;\r
778 } \r
779\r
780 if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {\r
781 Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;\r
782 ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);\r
783 TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);\r
784 HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
785 FreePool (NewString);\r
786 Find[3] = TRUE;\r
787 } \r
788\r
789 if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {\r
790 Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;\r
791 ConvertMemorySizeToString (\r
792 (UINT32)(RShiftU64((Type19Record->EndingAddress - Type19Record->StartingAddress + 1), 10)),\r
793 &NewString\r
794 );\r
795 TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);\r
796 HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
797 FreePool (NewString);\r
798 Find[4] = TRUE; \r
799 }\r
800 } while ( !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));\r
5c08e117 801 return ;\r
802}\r
803\r
6cfbf7ad 804\r
5c08e117 805/**\r
806 Function waits for a given event to fire, or for an optional timeout to expire.\r
807\r
6cfbf7ad 808 @param Event The event to wait for\r
809 @param Timeout An optional timeout value in 100 ns units.\r
5c08e117 810\r
811 @retval EFI_SUCCESS Event fired before Timeout expired.\r
812 @retval EFI_TIME_OUT Timout expired before Event fired..\r
813\r
814**/\r
815EFI_STATUS\r
816WaitForSingleEvent (\r
817 IN EFI_EVENT Event,\r
818 IN UINT64 Timeout OPTIONAL\r
819 )\r
820{\r
5c08e117 821 UINTN Index;\r
6cfbf7ad 822 EFI_STATUS Status;\r
5c08e117 823 EFI_EVENT TimerEvent;\r
824 EFI_EVENT WaitList[2];\r
825\r
826 if (Timeout != 0) {\r
827 //\r
828 // Create a timer event\r
829 //\r
830 Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);\r
831 if (!EFI_ERROR (Status)) {\r
832 //\r
833 // Set the timer event\r
834 //\r
835 gBS->SetTimer (\r
6cfbf7ad 836 TimerEvent,\r
837 TimerRelative,\r
838 Timeout\r
839 );\r
5c08e117 840\r
841 //\r
842 // Wait for the original event or the timer\r
843 //\r
844 WaitList[0] = Event;\r
845 WaitList[1] = TimerEvent;\r
846 Status = gBS->WaitForEvent (2, WaitList, &Index);\r
847 gBS->CloseEvent (TimerEvent);\r
848\r
849 //\r
850 // If the timer expired, change the return to timed out\r
851 //\r
852 if (!EFI_ERROR (Status) && Index == 1) {\r
853 Status = EFI_TIMEOUT;\r
854 }\r
855 }\r
856 } else {\r
857 //\r
858 // No timeout... just wait on the event\r
859 //\r
860 Status = gBS->WaitForEvent (1, &Event, &Index);\r
861 ASSERT (!EFI_ERROR (Status));\r
862 ASSERT (Index == 0);\r
863 }\r
864\r
865 return Status;\r
866}\r
867\r
868/**\r
869 Function show progress bar to wait for user input.\r
870\r
871\r
6cfbf7ad 872 @param TimeoutDefault The fault time out value before the system continue to boot.\r
5c08e117 873\r
874 @retval EFI_SUCCESS User pressed some key except "Enter"\r
baf46e70 875 @retval EFI_TIME_OUT Timeout expired or user press "Enter"\r
5c08e117 876\r
877**/\r
878EFI_STATUS\r
879ShowProgress (\r
880 IN UINT16 TimeoutDefault\r
881 )\r
882{\r
5c08e117 883 CHAR16 *TmpStr;\r
6cfbf7ad 884 UINT16 TimeoutRemain;\r
885 EFI_STATUS Status;\r
886 EFI_INPUT_KEY Key;\r
5c08e117 887 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
888 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
889 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;\r
5c08e117 890\r
891 if (TimeoutDefault == 0) {\r
892 return EFI_TIMEOUT;\r
893 }\r
894\r
895 DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));\r
128efbbc 896\r
5c08e117 897 SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
898 SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);\r
899 SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);\r
900\r
901 //\r
902 // Clear the progress status bar first\r
903 //\r
904 TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));\r
905 if (TmpStr != NULL) {\r
906 PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);\r
907 }\r
908\r
909 TimeoutRemain = TimeoutDefault;\r
910 while (TimeoutRemain != 0) {\r
911 DEBUG ((EFI_D_INFO, "Showing progress bar...Remaining %d second!\n", TimeoutRemain));\r
128efbbc 912\r
5c08e117 913 Status = WaitForSingleEvent (gST->ConIn->WaitForKey, ONE_SECOND);\r
914 if (Status != EFI_TIMEOUT) {\r
915 break;\r
916 }\r
917 TimeoutRemain--;\r
918\r
919 //\r
920 // Show progress\r
921 //\r
922 if (TmpStr != NULL) {\r
923 PlatformBdsShowProgress (\r
924 Foreground,\r
925 Background,\r
926 TmpStr,\r
927 Color,\r
928 ((TimeoutDefault - TimeoutRemain) * 100 / TimeoutDefault),\r
929 0\r
930 );\r
931 }\r
932 }\r
933 gBS->FreePool (TmpStr);\r
934\r
935 //\r
936 // Timeout expired\r
937 //\r
938 if (TimeoutRemain == 0) {\r
939 return EFI_TIMEOUT;\r
940 }\r
941\r
942 //\r
943 // User pressed some key\r
944 //\r
945 Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
946 if (EFI_ERROR (Status)) {\r
947 return Status;\r
948 }\r
949\r
950 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
951 //\r
952 // User pressed enter, equivalent to select "continue"\r
953 //\r
954 return EFI_TIMEOUT;\r
955 }\r
956\r
957 return EFI_SUCCESS;\r
958}\r
959\r
72861c22 960/**\r
961 This function will change video resolution and text mode for setup when setup is launched.\r
962\r
963 @param None.\r
964\r
965 @retval EFI_SUCCESS Mode is changed successfully.\r
966 @retval Others Mode failed to changed.\r
967\r
968**/\r
969EFI_STATUS\r
970EFIAPI\r
971ChangeModeForSetup (\r
972 VOID\r
973 )\r
974{\r
975 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
976 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
977 UINTN SizeOfInfo;\r
978 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
979 UINT32 MaxGopMode;\r
980 UINT32 MaxTextMode;\r
981 UINT32 ModeNumber;\r
72861c22 982 UINTN HandleCount;\r
983 EFI_HANDLE *HandleBuffer;\r
984 EFI_STATUS Status;\r
985 UINTN Index;\r
986 UINTN CurrentColumn;\r
987 UINTN CurrentRow; \r
988\r
989 Status = gBS->HandleProtocol (\r
990 gST->ConsoleOutHandle,\r
991 &gEfiGraphicsOutputProtocolGuid,\r
992 (VOID**)&GraphicsOutput\r
993 );\r
994 if (EFI_ERROR (Status)) {\r
995 GraphicsOutput = NULL;\r
996 }\r
997\r
998 Status = gBS->HandleProtocol (\r
999 gST->ConsoleOutHandle,\r
1000 &gEfiSimpleTextOutProtocolGuid,\r
1001 (VOID**)&SimpleTextOut\r
1002 );\r
1003 if (EFI_ERROR (Status)) {\r
1004 SimpleTextOut = NULL;\r
1005 } \r
1006\r
80140187 1007 if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {\r
72861c22 1008 return EFI_UNSUPPORTED;\r
1009 }\r
1010\r
1011 //\r
32bc1227 1012 // Get user defined text mode for setup only once.\r
72861c22 1013 // \r
32bc1227 1014 if (!mSetupModeInitialized) {\r
1015 mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
1016 mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution); \r
1017 mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);\r
1018 mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);\r
1019 mSetupModeInitialized = TRUE;\r
1020 }\r
72861c22 1021\r
1022 MaxGopMode = GraphicsOutput->Mode->MaxMode;\r
1023 MaxTextMode = SimpleTextOut->Mode->MaxMode;\r
1024\r
1025 //\r
1026 // 1. If current video resolution is same with setup video resolution,\r
1027 // video resolution need not be changed.\r
1028 // 1.1. If current text mode is same with setup text mode, text mode need not be changed.\r
1029 // 1.2. If current text mode is different with setup text mode, text mode need be changed to setup text mode.\r
1030 // 2. If current video resolution is different with setup video resolution, we need restart whole console drivers.\r
1031 //\r
1032 for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {\r
1033 Status = GraphicsOutput->QueryMode (\r
1034 GraphicsOutput,\r
1035 ModeNumber,\r
1036 &SizeOfInfo,\r
1037 &Info\r
1038 );\r
1039 if (!EFI_ERROR (Status)) {\r
32bc1227 1040 if ((Info->HorizontalResolution == mSetupHorizontalResolution) &&\r
1041 (Info->VerticalResolution == mSetupVerticalResolution)) {\r
1042 if ((GraphicsOutput->Mode->Info->HorizontalResolution == mSetupHorizontalResolution) &&\r
1043 (GraphicsOutput->Mode->Info->VerticalResolution == mSetupVerticalResolution)) {\r
72861c22 1044 //\r
1045 // If current video resolution is same with setup video resolution, \r
1046 // then check if current text mode is same with setup text mode.\r
1047 //\r
1048 Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);\r
1049 ASSERT_EFI_ERROR (Status);\r
32bc1227 1050 if (CurrentColumn == mSetupTextModeColumn && CurrentRow == mSetupTextModeRow) {\r
72861c22 1051 //\r
1052 // Current text mode is same with setup text mode, text mode need not be change.\r
1053 //\r
1054 FreePool (Info);\r
1055 return EFI_SUCCESS;\r
1056 } else {\r
1057 //\r
1058 // Current text mode is different with setup text mode, text mode need be change to new text mode.\r
1059 //\r
1060 for (Index = 0; Index < MaxTextMode; Index++) {\r
1061 Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
1062 if (!EFI_ERROR(Status)) {\r
32bc1227 1063 if ((CurrentColumn == mSetupTextModeColumn) && (CurrentRow == mSetupTextModeRow)) {\r
72861c22 1064 //\r
1065 // setup text mode is supported, set it.\r
1066 //\r
1067 Status = SimpleTextOut->SetMode (SimpleTextOut, Index);\r
1068 ASSERT_EFI_ERROR (Status);\r
1069 //\r
1070 // Update text mode PCD.\r
1071 //\r
32bc1227 1072 PcdSet32 (PcdConOutColumn, mSetupTextModeColumn);\r
1073 PcdSet32 (PcdConOutRow, mSetupTextModeRow);\r
72861c22 1074 FreePool (Info);\r
1075 return EFI_SUCCESS;\r
1076 }\r
1077 }\r
1078 }\r
1079 if (Index == MaxTextMode) {\r
1080 //\r
1081 // If setup text mode is not supported, return error.\r
1082 //\r
1083 FreePool (Info);\r
1084 return EFI_UNSUPPORTED;\r
1085 }\r
1086 }\r
1087 } else {\r
1088 FreePool (Info);\r
1089 //\r
1090 // If current video resolution is not same with the setup video resolution, set new video resolution.\r
1091 // In this case, the drivers which produce simple text out need be restarted.\r
1092 //\r
1093 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);\r
1094 if (!EFI_ERROR (Status)) {\r
1095 //\r
1096 // Set PCD to restart GraphicsConsole and Consplitter to change video resolution \r
1097 // and produce new text mode based on new resolution.\r
1098 //\r
32bc1227 1099 PcdSet32 (PcdVideoHorizontalResolution, mSetupHorizontalResolution);\r
1100 PcdSet32 (PcdVideoVerticalResolution, mSetupVerticalResolution);\r
1101 PcdSet32 (PcdConOutColumn, mSetupTextModeColumn);\r
1102 PcdSet32 (PcdConOutRow, mSetupTextModeRow);\r
72861c22 1103 \r
1104 Status = gBS->LocateHandleBuffer (\r
1105 ByProtocol,\r
1106 &gEfiSimpleTextOutProtocolGuid,\r
1107 NULL,\r
1108 &HandleCount,\r
1109 &HandleBuffer\r
1110 );\r
1111 if (!EFI_ERROR (Status)) {\r
1112 for (Index = 0; Index < HandleCount; Index++) {\r
1113 gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
1114 }\r
1115 for (Index = 0; Index < HandleCount; Index++) {\r
1116 gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);\r
1117 }\r
1118 if (HandleBuffer != NULL) {\r
1119 FreePool (HandleBuffer);\r
1120 }\r
1121 break;\r
1122 }\r
1123 }\r
1124 }\r
1125 }\r
1126 FreePool (Info);\r
1127 }\r
1128 }\r
1129\r
1130 if (ModeNumber == MaxGopMode) {\r
1131 //\r
1132 // If the new resolution is not supported, return error.\r
1133 //\r
1134 return EFI_UNSUPPORTED;\r
1135 }\r
1136\r
1137 return EFI_SUCCESS;\r
1138}\r
1139\r
5c08e117 1140/**\r
1141 This function is the main entry of the platform setup entry.\r
1142 The function will present the main menu of the system setup,\r
1143 this is the platform reference part and can be customize.\r
1144\r
1145\r
1146 @param TimeoutDefault The fault time out value before the system\r
1147 continue to boot.\r
1148 @param ConnectAllHappened The indicater to check if the connect all have\r
baf46e70 1149 already happened.\r
5c08e117 1150\r
1151**/\r
1152VOID\r
1153PlatformBdsEnterFrontPage (\r
1154 IN UINT16 TimeoutDefault,\r
1155 IN BOOLEAN ConnectAllHappened\r
1156 )\r
1157{\r
1158 EFI_STATUS Status;\r
a637802c 1159 EFI_BOOT_LOGO_PROTOCOL *BootLogo;\r
5c08e117 1160\r
128efbbc 1161 PERF_START (NULL, "BdsTimeOut", "BDS", 0);\r
5c08e117 1162 //\r
1163 // Indicate if we need connect all in the platform setup\r
1164 //\r
1165 if (ConnectAllHappened) {\r
1166 gConnectAllHappened = TRUE;\r
1167 }\r
1168\r
d394581d 1169 HotkeyBoot ();\r
5c08e117 1170 if (TimeoutDefault != 0xffff) {\r
1171 Status = ShowProgress (TimeoutDefault);\r
d394581d 1172 HotkeyBoot ();\r
5c08e117 1173\r
1174 //\r
1175 // Ensure screen is clear when switch Console from Graphics mode to Text mode\r
1176 //\r
1177 gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
1178 gST->ConOut->ClearScreen (gST->ConOut);\r
1179\r
1180 if (EFI_ERROR (Status)) {\r
1181 //\r
1182 // Timeout or user press enter to continue\r
1183 //\r
1184 goto Exit;\r
1185 }\r
1186 }\r
1187\r
a637802c 1188 //\r
1189 // Boot Logo is corrupted, report it using Boot Logo protocol.\r
1190 //\r
1191 Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);\r
1192 if (!EFI_ERROR (Status) && (BootLogo != NULL)) {\r
1193 BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);\r
1194 }\r
1195\r
84724077 1196 Status = EFI_SUCCESS;\r
5c08e117 1197 do {\r
72861c22 1198 //\r
1199 // Set proper video resolution and text mode for setup\r
1200 //\r
1201 ChangeModeForSetup ();\r
1202 \r
5c08e117 1203 InitializeFrontPage (FALSE);\r
1204\r
1205 //\r
1206 // Update Front Page strings\r
1207 //\r
1208 UpdateFrontPageStrings ();\r
1209\r
1210 gCallbackKey = 0;\r
84724077 1211 CallFrontPage ();\r
5c08e117 1212\r
1213 //\r
1214 // If gCallbackKey is greater than 1 and less or equal to 5,\r
baf46e70 1215 // it will launch configuration utilities.\r
5c08e117 1216 // 2 = set language\r
1217 // 3 = boot manager\r
1218 // 4 = device manager\r
baf46e70 1219 // 5 = boot maintenance manager\r
5c08e117 1220 //\r
1221 if (gCallbackKey != 0) {\r
1222 REPORT_STATUS_CODE (\r
1223 EFI_PROGRESS_CODE,\r
1224 (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)\r
1225 );\r
1226 }\r
1227 //\r
1228 // Based on the key that was set, we can determine what to do\r
1229 //\r
1230 switch (gCallbackKey) {\r
1231 //\r
1232 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can\r
1233 // describe to their customers in documentation how to find their setup information (namely\r
1234 // under the device manager and specific buckets)\r
1235 //\r
1236 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager\r
1237 //\r
1238 case FRONT_PAGE_KEY_CONTINUE:\r
1239 //\r
1240 // User hit continue\r
1241 //\r
1242 break;\r
1243\r
1244 case FRONT_PAGE_KEY_LANGUAGE:\r
1245 //\r
1246 // User made a language setting change - display front page again\r
1247 //\r
1248 break;\r
1249\r
1250 case FRONT_PAGE_KEY_BOOT_MANAGER:\r
1251 //\r
1252 // User chose to run the Boot Manager\r
1253 //\r
bd2057a8 1254 CallBootManager ();\r
5c08e117 1255 break;\r
1256\r
1257 case FRONT_PAGE_KEY_DEVICE_MANAGER:\r
1258 //\r
1259 // Display the Device Manager\r
1260 //\r
1261 do {\r
bd2057a8 1262 CallDeviceManager ();\r
5c08e117 1263 } while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER);\r
1264 break;\r
1265\r
1266 case FRONT_PAGE_KEY_BOOT_MAINTAIN:\r
1267 //\r
1268 // Display the Boot Maintenance Manager\r
1269 //\r
1270 BdsStartBootMaint ();\r
1271 break;\r
1272 }\r
1273\r
1274 } while ((Status == EFI_SUCCESS) && (gCallbackKey != FRONT_PAGE_KEY_CONTINUE));\r
1275\r
1276 //\r
1277 //Will leave browser, check any reset required change is applied? if yes, reset system\r
1278 //\r
1279 SetupResetReminder ();\r
1280\r
1281Exit:\r
1282 //\r
1283 // Automatically load current entry\r
1284 // Note: The following lines of code only execute when Auto boot\r
1285 // takes affect\r
1286 //\r
128efbbc 1287 PERF_END (NULL, "BdsTimeOut", "BDS", 0);\r
5c08e117 1288}\r