15c08e1173703234cc2913757f237ee916087498aklu/** @file
25c08e1173703234cc2913757f237ee916087498aklu  FrontPage routines to handle the callbacks and browser calls
35c08e1173703234cc2913757f237ee916087498aklu
419d02cc20c6bf888532d3616957eee5bacaf67caHao WuCopyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5180a5a35cb49699bd249dee19e41cee34c856a58hhtianThis program and the accompanying materials
65c08e1173703234cc2913757f237ee916087498akluare licensed and made available under the terms and conditions of the BSD License
75c08e1173703234cc2913757f237ee916087498akluwhich accompanies this distribution.  The full text of the license may be found at
85c08e1173703234cc2913757f237ee916087498akluhttp://opensource.org/licenses/bsd-license.php
95c08e1173703234cc2913757f237ee916087498aklu
105c08e1173703234cc2913757f237ee916087498akluTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
115c08e1173703234cc2913757f237ee916087498akluWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
125c08e1173703234cc2913757f237ee916087498aklu
135c08e1173703234cc2913757f237ee916087498aklu**/
145c08e1173703234cc2913757f237ee916087498aklu
155c08e1173703234cc2913757f237ee916087498aklu#include "Bds.h"
165c08e1173703234cc2913757f237ee916087498aklu#include "FrontPage.h"
17ad5a96ab2daeeac53f0c924113f23dc931f965c5rsun#include "Language.h"
18d394581d11ff0c7ba2c32e01a676c80e090ecdb8niruiyu#include "Hotkey.h"
195c08e1173703234cc2913757f237ee916087498aklu
202df686c67c7819e01a1487dd703faffef2b59dceczhangBOOLEAN   mModeInitialized = FALSE;
2132bc1227a5a75fe086970420f98c91e500fd88cbli-elvin
225c08e1173703234cc2913757f237ee916087498akluBOOLEAN   gConnectAllHappened = FALSE;
235c08e1173703234cc2913757f237ee916087498akluUINTN     gCallbackKey;
24a412ad88e5737735ab54b35392b51d8a210c3b74ydongCHAR8     *mLanguageString;
255c08e1173703234cc2913757f237ee916087498aklu
262df686c67c7819e01a1487dd703faffef2b59dceczhang//
272df686c67c7819e01a1487dd703faffef2b59dceczhang// Boot video resolution and text mode.
282df686c67c7819e01a1487dd703faffef2b59dceczhang//
292df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mBootHorizontalResolution    = 0;
302df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mBootVerticalResolution      = 0;
312df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mBootTextModeColumn          = 0;
322df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mBootTextModeRow             = 0;
332df686c67c7819e01a1487dd703faffef2b59dceczhang//
342df686c67c7819e01a1487dd703faffef2b59dceczhang// BIOS setup video resolution and text mode.
352df686c67c7819e01a1487dd703faffef2b59dceczhang//
362df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mSetupTextModeColumn         = 0;
372df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mSetupTextModeRow            = 0;
382df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mSetupHorizontalResolution   = 0;
392df686c67c7819e01a1487dd703faffef2b59dceczhangUINT32    mSetupVerticalResolution     = 0;
402df686c67c7819e01a1487dd703faffef2b59dceczhang
415c08e1173703234cc2913757f237ee916087498akluEFI_FORM_BROWSER2_PROTOCOL      *gFormBrowser2;
425c08e1173703234cc2913757f237ee916087498aklu
435c08e1173703234cc2913757f237ee916087498akluFRONT_PAGE_CALLBACK_DATA  gFrontPagePrivate = {
445c08e1173703234cc2913757f237ee916087498aklu  FRONT_PAGE_CALLBACK_DATA_SIGNATURE,
455c08e1173703234cc2913757f237ee916087498aklu  NULL,
465c08e1173703234cc2913757f237ee916087498aklu  NULL,
475c08e1173703234cc2913757f237ee916087498aklu  NULL,
485c08e1173703234cc2913757f237ee916087498aklu  {
495c08e1173703234cc2913757f237ee916087498aklu    FakeExtractConfig,
505c08e1173703234cc2913757f237ee916087498aklu    FakeRouteConfig,
515c08e1173703234cc2913757f237ee916087498aklu    FrontPageCallback
525c08e1173703234cc2913757f237ee916087498aklu  }
535c08e1173703234cc2913757f237ee916087498aklu};
545c08e1173703234cc2913757f237ee916087498aklu
55f6f910dd125144707e3516bbb517b8ec7a388c06rsunHII_VENDOR_DEVICE_PATH  mFrontPageHiiVendorDevicePath = {
56f6f910dd125144707e3516bbb517b8ec7a388c06rsun  {
57f6f910dd125144707e3516bbb517b8ec7a388c06rsun    {
58f6f910dd125144707e3516bbb517b8ec7a388c06rsun      HARDWARE_DEVICE_PATH,
59f6f910dd125144707e3516bbb517b8ec7a388c06rsun      HW_VENDOR_DP,
60f6f910dd125144707e3516bbb517b8ec7a388c06rsun      {
61f6f910dd125144707e3516bbb517b8ec7a388c06rsun        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
62f6f910dd125144707e3516bbb517b8ec7a388c06rsun        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
63f6f910dd125144707e3516bbb517b8ec7a388c06rsun      }
64f6f910dd125144707e3516bbb517b8ec7a388c06rsun    },
65e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao    FRONT_PAGE_FORMSET_GUID
66f6f910dd125144707e3516bbb517b8ec7a388c06rsun  },
67f6f910dd125144707e3516bbb517b8ec7a388c06rsun  {
68f6f910dd125144707e3516bbb517b8ec7a388c06rsun    END_DEVICE_PATH_TYPE,
69f6f910dd125144707e3516bbb517b8ec7a388c06rsun    END_ENTIRE_DEVICE_PATH_SUBTYPE,
70128efbbcc2e3e8d4ee3c269563a5e2ee461dc3e3darylm    {
71f6f910dd125144707e3516bbb517b8ec7a388c06rsun      (UINT8) (END_DEVICE_PATH_LENGTH),
72f6f910dd125144707e3516bbb517b8ec7a388c06rsun      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
73f6f910dd125144707e3516bbb517b8ec7a388c06rsun    }
74f6f910dd125144707e3516bbb517b8ec7a388c06rsun  }
75f6f910dd125144707e3516bbb517b8ec7a388c06rsun};
76f6f910dd125144707e3516bbb517b8ec7a388c06rsun
775c08e1173703234cc2913757f237ee916087498aklu/**
785c08e1173703234cc2913757f237ee916087498aklu  This function allows a caller to extract the current configuration for one
795c08e1173703234cc2913757f237ee916087498aklu  or more named elements from the target driver.
805c08e1173703234cc2913757f237ee916087498aklu
815c08e1173703234cc2913757f237ee916087498aklu
825c08e1173703234cc2913757f237ee916087498aklu  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
835c08e1173703234cc2913757f237ee916087498aklu  @param Request         A null-terminated Unicode string in <ConfigRequest> format.
845c08e1173703234cc2913757f237ee916087498aklu  @param Progress        On return, points to a character in the Request string.
855c08e1173703234cc2913757f237ee916087498aklu                         Points to the string's null terminator if request was successful.
865c08e1173703234cc2913757f237ee916087498aklu                         Points to the most recent '&' before the first failing name/value
875c08e1173703234cc2913757f237ee916087498aklu                         pair (or the beginning of the string if the failure is in the
885c08e1173703234cc2913757f237ee916087498aklu                         first name/value pair) if the request was not successful.
895c08e1173703234cc2913757f237ee916087498aklu  @param Results         A null-terminated Unicode string in <ConfigAltResp> format which
905c08e1173703234cc2913757f237ee916087498aklu                         has all values filled in for the names in the Request string.
915c08e1173703234cc2913757f237ee916087498aklu                         String to be allocated by the called function.
925c08e1173703234cc2913757f237ee916087498aklu
935c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCCESS            The Results is filled with the requested values.
945c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.
9559aefb7e0dc811a3e66ae23c1730028365354361lgao  @retval  EFI_INVALID_PARAMETER  Request is illegal syntax, or unknown name.
965c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.
975c08e1173703234cc2913757f237ee916087498aklu
985c08e1173703234cc2913757f237ee916087498aklu**/
995c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
1005c08e1173703234cc2913757f237ee916087498akluEFIAPI
1015c08e1173703234cc2913757f237ee916087498akluFakeExtractConfig (
1025c08e1173703234cc2913757f237ee916087498aklu  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
1035c08e1173703234cc2913757f237ee916087498aklu  IN  CONST EFI_STRING                       Request,
1045c08e1173703234cc2913757f237ee916087498aklu  OUT EFI_STRING                             *Progress,
1055c08e1173703234cc2913757f237ee916087498aklu  OUT EFI_STRING                             *Results
1065c08e1173703234cc2913757f237ee916087498aklu  )
1075c08e1173703234cc2913757f237ee916087498aklu{
10859aefb7e0dc811a3e66ae23c1730028365354361lgao  if (Progress == NULL || Results == NULL) {
109dedfc3bbc97e726e259bfadbdf22502133faa8a8lgao    return EFI_INVALID_PARAMETER;
110dedfc3bbc97e726e259bfadbdf22502133faa8a8lgao  }
111cdcc36ae921c4c1e157907ec44bb98a67d3be96flgao  *Progress = Request;
1125c08e1173703234cc2913757f237ee916087498aklu  return EFI_NOT_FOUND;
1135c08e1173703234cc2913757f237ee916087498aklu}
1145c08e1173703234cc2913757f237ee916087498aklu
1155c08e1173703234cc2913757f237ee916087498aklu/**
1165c08e1173703234cc2913757f237ee916087498aklu  This function processes the results of changes in configuration.
1175c08e1173703234cc2913757f237ee916087498aklu
1185c08e1173703234cc2913757f237ee916087498aklu
1195c08e1173703234cc2913757f237ee916087498aklu  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1205c08e1173703234cc2913757f237ee916087498aklu  @param Configuration   A null-terminated Unicode string in <ConfigResp> format.
1215c08e1173703234cc2913757f237ee916087498aklu  @param Progress        A pointer to a string filled in with the offset of the most
1225c08e1173703234cc2913757f237ee916087498aklu                         recent '&' before the first failing name/value pair (or the
1235c08e1173703234cc2913757f237ee916087498aklu                         beginning of the string if the failure is in the first
1245c08e1173703234cc2913757f237ee916087498aklu                         name/value pair) or the terminating NULL if all was successful.
1255c08e1173703234cc2913757f237ee916087498aklu
1265c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCCESS            The Results is processed successfully.
1275c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_INVALID_PARAMETER  Configuration is NULL.
1285c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.
1295c08e1173703234cc2913757f237ee916087498aklu
1305c08e1173703234cc2913757f237ee916087498aklu**/
1315c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
1325c08e1173703234cc2913757f237ee916087498akluEFIAPI
1335c08e1173703234cc2913757f237ee916087498akluFakeRouteConfig (
1345c08e1173703234cc2913757f237ee916087498aklu  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
1355c08e1173703234cc2913757f237ee916087498aklu  IN  CONST EFI_STRING                       Configuration,
1365c08e1173703234cc2913757f237ee916087498aklu  OUT EFI_STRING                             *Progress
1375c08e1173703234cc2913757f237ee916087498aklu  )
1385c08e1173703234cc2913757f237ee916087498aklu{
139dedfc3bbc97e726e259bfadbdf22502133faa8a8lgao  if (Configuration == NULL || Progress == NULL) {
140cdcc36ae921c4c1e157907ec44bb98a67d3be96flgao    return EFI_INVALID_PARAMETER;
141cdcc36ae921c4c1e157907ec44bb98a67d3be96flgao  }
142cdcc36ae921c4c1e157907ec44bb98a67d3be96flgao
143dedfc3bbc97e726e259bfadbdf22502133faa8a8lgao  *Progress = Configuration;
144e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao  if (!HiiIsConfigHdrMatch (Configuration, &gBootMaintFormSetGuid, mBootMaintStorageName)
145e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao      && !HiiIsConfigHdrMatch (Configuration, &gFileExploreFormSetGuid, mFileExplorerStorageName)) {
146dedfc3bbc97e726e259bfadbdf22502133faa8a8lgao    return EFI_NOT_FOUND;
147cdcc36ae921c4c1e157907ec44bb98a67d3be96flgao  }
148cdcc36ae921c4c1e157907ec44bb98a67d3be96flgao
149dedfc3bbc97e726e259bfadbdf22502133faa8a8lgao  *Progress = Configuration + StrLen (Configuration);
150dedfc3bbc97e726e259bfadbdf22502133faa8a8lgao  return EFI_SUCCESS;
1515c08e1173703234cc2913757f237ee916087498aklu}
1525c08e1173703234cc2913757f237ee916087498aklu
1535c08e1173703234cc2913757f237ee916087498aklu/**
1545c08e1173703234cc2913757f237ee916087498aklu  This function processes the results of changes in configuration.
1555c08e1173703234cc2913757f237ee916087498aklu
1565c08e1173703234cc2913757f237ee916087498aklu
1575c08e1173703234cc2913757f237ee916087498aklu  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1585c08e1173703234cc2913757f237ee916087498aklu  @param Action          Specifies the type of action taken by the browser.
1595c08e1173703234cc2913757f237ee916087498aklu  @param QuestionId      A unique value which is sent to the original exporting driver
1605c08e1173703234cc2913757f237ee916087498aklu                         so that it can identify the type of data to expect.
1615c08e1173703234cc2913757f237ee916087498aklu  @param Type            The type of value for the question.
1625c08e1173703234cc2913757f237ee916087498aklu  @param Value           A pointer to the data being sent to the original exporting driver.
1635c08e1173703234cc2913757f237ee916087498aklu  @param ActionRequest   On return, points to the action requested by the callback function.
1645c08e1173703234cc2913757f237ee916087498aklu
1655c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCCESS           The callback successfully handled the action.
1665c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.
1675c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_DEVICE_ERROR      The variable could not be saved.
1685c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_UNSUPPORTED       The specified Action is not supported by the callback.
1695c08e1173703234cc2913757f237ee916087498aklu
1705c08e1173703234cc2913757f237ee916087498aklu**/
1715c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
1725c08e1173703234cc2913757f237ee916087498akluEFIAPI
1735c08e1173703234cc2913757f237ee916087498akluFrontPageCallback (
1745c08e1173703234cc2913757f237ee916087498aklu  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
1755c08e1173703234cc2913757f237ee916087498aklu  IN  EFI_BROWSER_ACTION                     Action,
1765c08e1173703234cc2913757f237ee916087498aklu  IN  EFI_QUESTION_ID                        QuestionId,
1775c08e1173703234cc2913757f237ee916087498aklu  IN  UINT8                                  Type,
1785c08e1173703234cc2913757f237ee916087498aklu  IN  EFI_IFR_TYPE_VALUE                     *Value,
1795c08e1173703234cc2913757f237ee916087498aklu  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest
1805c08e1173703234cc2913757f237ee916087498aklu  )
1815c08e1173703234cc2913757f237ee916087498aklu{
1825c08e1173703234cc2913757f237ee916087498aklu  CHAR8                         *LangCode;
183a3a795afdb9d8efd8e6603cce92103d610346b78qhuang  CHAR8                         *Lang;
1845c08e1173703234cc2913757f237ee916087498aklu  UINTN                         Index;
1855c08e1173703234cc2913757f237ee916087498aklu
186847240774030f9da79140a9d515a64ec817eb6ebydong  if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {
187847240774030f9da79140a9d515a64ec817eb6ebydong    //
188847240774030f9da79140a9d515a64ec817eb6ebydong    // All other action return unsupported.
189847240774030f9da79140a9d515a64ec817eb6ebydong    //
190847240774030f9da79140a9d515a64ec817eb6ebydong    return EFI_UNSUPPORTED;
191847240774030f9da79140a9d515a64ec817eb6ebydong  }
192847240774030f9da79140a9d515a64ec817eb6ebydong
193847240774030f9da79140a9d515a64ec817eb6ebydong  gCallbackKey = QuestionId;
194847240774030f9da79140a9d515a64ec817eb6ebydong
195847240774030f9da79140a9d515a64ec817eb6ebydong  if (Action == EFI_BROWSER_ACTION_CHANGED) {
196d88f86f154ddbe39355fcf0aca03438f219b2660ydong    if ((Value == NULL) || (ActionRequest == NULL)) {
197d88f86f154ddbe39355fcf0aca03438f219b2660ydong      return EFI_INVALID_PARAMETER;
198d88f86f154ddbe39355fcf0aca03438f219b2660ydong    }
1995c08e1173703234cc2913757f237ee916087498aklu
200d88f86f154ddbe39355fcf0aca03438f219b2660ydong    switch (QuestionId) {
201d88f86f154ddbe39355fcf0aca03438f219b2660ydong    case FRONT_PAGE_KEY_CONTINUE:
202d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
203d88f86f154ddbe39355fcf0aca03438f219b2660ydong      // This is the continue - clear the screen and return an error to get out of FrontPage loop
204d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
205847240774030f9da79140a9d515a64ec817eb6ebydong      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
206d88f86f154ddbe39355fcf0aca03438f219b2660ydong      break;
207d88f86f154ddbe39355fcf0aca03438f219b2660ydong
208d88f86f154ddbe39355fcf0aca03438f219b2660ydong    case FRONT_PAGE_KEY_LANGUAGE:
209d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
210d88f86f154ddbe39355fcf0aca03438f219b2660ydong      // Allocate working buffer for RFC 4646 language in supported LanguageString.
211d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
212a412ad88e5737735ab54b35392b51d8a210c3b74ydong      Lang = AllocatePool (AsciiStrSize (mLanguageString));
213a412ad88e5737735ab54b35392b51d8a210c3b74ydong      ASSERT (Lang != NULL);
214d88f86f154ddbe39355fcf0aca03438f219b2660ydong
215d88f86f154ddbe39355fcf0aca03438f219b2660ydong      Index = 0;
216a412ad88e5737735ab54b35392b51d8a210c3b74ydong      LangCode = mLanguageString;
217d88f86f154ddbe39355fcf0aca03438f219b2660ydong      while (*LangCode != 0) {
218d88f86f154ddbe39355fcf0aca03438f219b2660ydong        GetNextLanguage (&LangCode, Lang);
219d88f86f154ddbe39355fcf0aca03438f219b2660ydong
220d88f86f154ddbe39355fcf0aca03438f219b2660ydong        if (Index == Value->u8) {
221d88f86f154ddbe39355fcf0aca03438f219b2660ydong          break;
222d88f86f154ddbe39355fcf0aca03438f219b2660ydong        }
223d88f86f154ddbe39355fcf0aca03438f219b2660ydong
224d88f86f154ddbe39355fcf0aca03438f219b2660ydong        Index++;
2255c08e1173703234cc2913757f237ee916087498aklu      }
2265c08e1173703234cc2913757f237ee916087498aklu
227a412ad88e5737735ab54b35392b51d8a210c3b74ydong      if (Index == Value->u8) {
22869fc8f080e07ea026e8fbb8610cfb89c099d6db2Ruiyu Ni        BdsDxeSetVariableAndReportStatusCodeOnError (
229d88f86f154ddbe39355fcf0aca03438f219b2660ydong                        L"PlatformLang",
230d88f86f154ddbe39355fcf0aca03438f219b2660ydong                        &gEfiGlobalVariableGuid,
231d88f86f154ddbe39355fcf0aca03438f219b2660ydong                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
232a412ad88e5737735ab54b35392b51d8a210c3b74ydong                        AsciiStrSize (Lang),
233d88f86f154ddbe39355fcf0aca03438f219b2660ydong                        Lang
234d88f86f154ddbe39355fcf0aca03438f219b2660ydong                        );
235d88f86f154ddbe39355fcf0aca03438f219b2660ydong      } else {
236d88f86f154ddbe39355fcf0aca03438f219b2660ydong        ASSERT (FALSE);
237d88f86f154ddbe39355fcf0aca03438f219b2660ydong      }
238128efbbcc2e3e8d4ee3c269563a5e2ee461dc3e3darylm
239847240774030f9da79140a9d515a64ec817eb6ebydong      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
240847240774030f9da79140a9d515a64ec817eb6ebydong
241d88f86f154ddbe39355fcf0aca03438f219b2660ydong      FreePool (Lang);
242d88f86f154ddbe39355fcf0aca03438f219b2660ydong      break;
243d88f86f154ddbe39355fcf0aca03438f219b2660ydong
244847240774030f9da79140a9d515a64ec817eb6ebydong    default:
245847240774030f9da79140a9d515a64ec817eb6ebydong      break;
246847240774030f9da79140a9d515a64ec817eb6ebydong    }
247847240774030f9da79140a9d515a64ec817eb6ebydong  } else if (Action == EFI_BROWSER_ACTION_CHANGING) {
248847240774030f9da79140a9d515a64ec817eb6ebydong    if (Value == NULL) {
249847240774030f9da79140a9d515a64ec817eb6ebydong      return EFI_INVALID_PARAMETER;
250847240774030f9da79140a9d515a64ec817eb6ebydong    }
251847240774030f9da79140a9d515a64ec817eb6ebydong
252847240774030f9da79140a9d515a64ec817eb6ebydong    //
253847240774030f9da79140a9d515a64ec817eb6ebydong    // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
254847240774030f9da79140a9d515a64ec817eb6ebydong    // describe to their customers in documentation how to find their setup information (namely
255847240774030f9da79140a9d515a64ec817eb6ebydong    // under the device manager and specific buckets)
256847240774030f9da79140a9d515a64ec817eb6ebydong    //
257847240774030f9da79140a9d515a64ec817eb6ebydong    switch (QuestionId) {
258d88f86f154ddbe39355fcf0aca03438f219b2660ydong    case FRONT_PAGE_KEY_BOOT_MANAGER:
259d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
260d88f86f154ddbe39355fcf0aca03438f219b2660ydong      // Boot Manager
261d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
262d88f86f154ddbe39355fcf0aca03438f219b2660ydong      break;
263d88f86f154ddbe39355fcf0aca03438f219b2660ydong
264d88f86f154ddbe39355fcf0aca03438f219b2660ydong    case FRONT_PAGE_KEY_DEVICE_MANAGER:
265d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
266d88f86f154ddbe39355fcf0aca03438f219b2660ydong      // Device Manager
267d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
268d88f86f154ddbe39355fcf0aca03438f219b2660ydong      break;
269d88f86f154ddbe39355fcf0aca03438f219b2660ydong
270d88f86f154ddbe39355fcf0aca03438f219b2660ydong    case FRONT_PAGE_KEY_BOOT_MAINTAIN:
271d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
272d88f86f154ddbe39355fcf0aca03438f219b2660ydong      // Boot Maintenance Manager
273d88f86f154ddbe39355fcf0aca03438f219b2660ydong      //
274d88f86f154ddbe39355fcf0aca03438f219b2660ydong      break;
275d88f86f154ddbe39355fcf0aca03438f219b2660ydong
276d88f86f154ddbe39355fcf0aca03438f219b2660ydong    default:
277d88f86f154ddbe39355fcf0aca03438f219b2660ydong      gCallbackKey = 0;
278d88f86f154ddbe39355fcf0aca03438f219b2660ydong      break;
2795c08e1173703234cc2913757f237ee916087498aklu    }
2805c08e1173703234cc2913757f237ee916087498aklu  }
2815c08e1173703234cc2913757f237ee916087498aklu
282847240774030f9da79140a9d515a64ec817eb6ebydong  return EFI_SUCCESS;
2835c08e1173703234cc2913757f237ee916087498aklu}
2845c08e1173703234cc2913757f237ee916087498aklu
2855c08e1173703234cc2913757f237ee916087498aklu/**
2865c08e1173703234cc2913757f237ee916087498aklu  Initialize HII information for the FrontPage
2875c08e1173703234cc2913757f237ee916087498aklu
2885c08e1173703234cc2913757f237ee916087498aklu
2895c08e1173703234cc2913757f237ee916087498aklu  @param InitializeHiiData    TRUE if HII elements need to be initialized.
2905c08e1173703234cc2913757f237ee916087498aklu
2915c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCCESS        The operation is successful.
2925c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_DEVICE_ERROR   If the dynamic opcode creation failed.
2935c08e1173703234cc2913757f237ee916087498aklu
2945c08e1173703234cc2913757f237ee916087498aklu**/
2955c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
2965c08e1173703234cc2913757f237ee916087498akluInitializeFrontPage (
2975c08e1173703234cc2913757f237ee916087498aklu  IN BOOLEAN                         InitializeHiiData
2985c08e1173703234cc2913757f237ee916087498aklu  )
2995c08e1173703234cc2913757f237ee916087498aklu{
3005c08e1173703234cc2913757f237ee916087498aklu  EFI_STATUS                  Status;
3015c08e1173703234cc2913757f237ee916087498aklu  CHAR8                       *LangCode;
302a3a795afdb9d8efd8e6603cce92103d610346b78qhuang  CHAR8                       *Lang;
303a3a795afdb9d8efd8e6603cce92103d610346b78qhuang  CHAR8                       *CurrentLang;
3045c08e1173703234cc2913757f237ee916087498aklu  UINTN                       OptionCount;
3055c08e1173703234cc2913757f237ee916087498aklu  CHAR16                      *StringBuffer;
3065c08e1173703234cc2913757f237ee916087498aklu  EFI_HII_HANDLE              HiiHandle;
30775bf9d0ecca38dfec9b645a6eb1119c025892304lgao  VOID                        *OptionsOpCodeHandle;
30875bf9d0ecca38dfec9b645a6eb1119c025892304lgao  VOID                        *StartOpCodeHandle;
30975bf9d0ecca38dfec9b645a6eb1119c025892304lgao  VOID                        *EndOpCodeHandle;
31075bf9d0ecca38dfec9b645a6eb1119c025892304lgao  EFI_IFR_GUID_LABEL          *StartLabel;
31175bf9d0ecca38dfec9b645a6eb1119c025892304lgao  EFI_IFR_GUID_LABEL          *EndLabel;
312a412ad88e5737735ab54b35392b51d8a210c3b74ydong  EFI_HII_STRING_PROTOCOL     *HiiString;
313a412ad88e5737735ab54b35392b51d8a210c3b74ydong  UINTN                       StringSize;
314a412ad88e5737735ab54b35392b51d8a210c3b74ydong
315a412ad88e5737735ab54b35392b51d8a210c3b74ydong  Lang         = NULL;
316a412ad88e5737735ab54b35392b51d8a210c3b74ydong  StringBuffer = NULL;
3175c08e1173703234cc2913757f237ee916087498aklu
3185c08e1173703234cc2913757f237ee916087498aklu  if (InitializeHiiData) {
3195c08e1173703234cc2913757f237ee916087498aklu    //
3205c08e1173703234cc2913757f237ee916087498aklu    // Initialize the Device Manager
3215c08e1173703234cc2913757f237ee916087498aklu    //
3225c08e1173703234cc2913757f237ee916087498aklu    InitializeDeviceManager ();
3235c08e1173703234cc2913757f237ee916087498aklu
3245c08e1173703234cc2913757f237ee916087498aklu    //
3255c08e1173703234cc2913757f237ee916087498aklu    // Initialize the Device Manager
3265c08e1173703234cc2913757f237ee916087498aklu    //
3275c08e1173703234cc2913757f237ee916087498aklu    InitializeBootManager ();
3285c08e1173703234cc2913757f237ee916087498aklu
3295c08e1173703234cc2913757f237ee916087498aklu    gCallbackKey  = 0;
3305c08e1173703234cc2913757f237ee916087498aklu
3315c08e1173703234cc2913757f237ee916087498aklu    //
3325c08e1173703234cc2913757f237ee916087498aklu    // Locate Hii relative protocols
3335c08e1173703234cc2913757f237ee916087498aklu    //
3345c08e1173703234cc2913757f237ee916087498aklu    Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFormBrowser2);
3355c08e1173703234cc2913757f237ee916087498aklu    if (EFI_ERROR (Status)) {
3365c08e1173703234cc2913757f237ee916087498aklu      return Status;
3375c08e1173703234cc2913757f237ee916087498aklu    }
3385c08e1173703234cc2913757f237ee916087498aklu
3395c08e1173703234cc2913757f237ee916087498aklu    //
340f6f910dd125144707e3516bbb517b8ec7a388c06rsun    // Install Device Path Protocol and Config Access protocol to driver handle
3415c08e1173703234cc2913757f237ee916087498aklu    //
342f6f910dd125144707e3516bbb517b8ec7a388c06rsun    Status = gBS->InstallMultipleProtocolInterfaces (
3435c08e1173703234cc2913757f237ee916087498aklu                    &gFrontPagePrivate.DriverHandle,
344f6f910dd125144707e3516bbb517b8ec7a388c06rsun                    &gEfiDevicePathProtocolGuid,
345f6f910dd125144707e3516bbb517b8ec7a388c06rsun                    &mFrontPageHiiVendorDevicePath,
3465c08e1173703234cc2913757f237ee916087498aklu                    &gEfiHiiConfigAccessProtocolGuid,
347f6f910dd125144707e3516bbb517b8ec7a388c06rsun                    &gFrontPagePrivate.ConfigAccess,
348f6f910dd125144707e3516bbb517b8ec7a388c06rsun                    NULL
3495c08e1173703234cc2913757f237ee916087498aklu                    );
3505c08e1173703234cc2913757f237ee916087498aklu    ASSERT_EFI_ERROR (Status);
3515c08e1173703234cc2913757f237ee916087498aklu
3525c08e1173703234cc2913757f237ee916087498aklu    //
3535c08e1173703234cc2913757f237ee916087498aklu    // Publish our HII data
3545c08e1173703234cc2913757f237ee916087498aklu    //
355cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun    gFrontPagePrivate.HiiHandle = HiiAddPackages (
356e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao                                    &gFrontPageFormSetGuid,
357cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun                                    gFrontPagePrivate.DriverHandle,
358cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun                                    FrontPageVfrBin,
359cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun                                    BdsDxeStrings,
360cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun                                    NULL
361cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun                                    );
362cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun    if (gFrontPagePrivate.HiiHandle == NULL) {
363cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun      return EFI_OUT_OF_RESOURCES;
3645c08e1173703234cc2913757f237ee916087498aklu    }
3655c08e1173703234cc2913757f237ee916087498aklu  }
3665c08e1173703234cc2913757f237ee916087498aklu
3675c08e1173703234cc2913757f237ee916087498aklu
3685c08e1173703234cc2913757f237ee916087498aklu  //
36975bf9d0ecca38dfec9b645a6eb1119c025892304lgao  // Init OpCode Handle and Allocate space for creation of UpdateData Buffer
3705c08e1173703234cc2913757f237ee916087498aklu  //
37175bf9d0ecca38dfec9b645a6eb1119c025892304lgao  StartOpCodeHandle = HiiAllocateOpCodeHandle ();
37275bf9d0ecca38dfec9b645a6eb1119c025892304lgao  ASSERT (StartOpCodeHandle != NULL);
3735c08e1173703234cc2913757f237ee916087498aklu
37475bf9d0ecca38dfec9b645a6eb1119c025892304lgao  EndOpCodeHandle = HiiAllocateOpCodeHandle ();
37575bf9d0ecca38dfec9b645a6eb1119c025892304lgao  ASSERT (EndOpCodeHandle != NULL);
37675bf9d0ecca38dfec9b645a6eb1119c025892304lgao
37775bf9d0ecca38dfec9b645a6eb1119c025892304lgao  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
37875bf9d0ecca38dfec9b645a6eb1119c025892304lgao  ASSERT (OptionsOpCodeHandle != NULL);
37975bf9d0ecca38dfec9b645a6eb1119c025892304lgao  //
38075bf9d0ecca38dfec9b645a6eb1119c025892304lgao  // Create Hii Extend Label OpCode as the start opcode
38175bf9d0ecca38dfec9b645a6eb1119c025892304lgao  //
38275bf9d0ecca38dfec9b645a6eb1119c025892304lgao  StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
38375bf9d0ecca38dfec9b645a6eb1119c025892304lgao  StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
38475bf9d0ecca38dfec9b645a6eb1119c025892304lgao  StartLabel->Number       = LABEL_SELECT_LANGUAGE;
38575bf9d0ecca38dfec9b645a6eb1119c025892304lgao
38675bf9d0ecca38dfec9b645a6eb1119c025892304lgao  //
38775bf9d0ecca38dfec9b645a6eb1119c025892304lgao  // Create Hii Extend Label OpCode as the end opcode
38875bf9d0ecca38dfec9b645a6eb1119c025892304lgao  //
38975bf9d0ecca38dfec9b645a6eb1119c025892304lgao  EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
39075bf9d0ecca38dfec9b645a6eb1119c025892304lgao  EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
39175bf9d0ecca38dfec9b645a6eb1119c025892304lgao  EndLabel->Number       = LABEL_END;
3925c08e1173703234cc2913757f237ee916087498aklu
3935c08e1173703234cc2913757f237ee916087498aklu  //
3945c08e1173703234cc2913757f237ee916087498aklu  // Collect the languages from what our current Language support is based on our VFR
3955c08e1173703234cc2913757f237ee916087498aklu  //
3965c08e1173703234cc2913757f237ee916087498aklu  HiiHandle = gFrontPagePrivate.HiiHandle;
397a3a795afdb9d8efd8e6603cce92103d610346b78qhuang
39844873d305668a9ca0e99ff6c73dff14e6cbde9afEric Dong  GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL);
399128efbbcc2e3e8d4ee3c269563a5e2ee461dc3e3darylm
400de12ae821ca969dc99665a00ed95b91fa8215429ydong  //
401de12ae821ca969dc99665a00ed95b91fa8215429ydong  // Get Support language list from variable.
402de12ae821ca969dc99665a00ed95b91fa8215429ydong  //
403de12ae821ca969dc99665a00ed95b91fa8215429ydong  if (mLanguageString == NULL){
40444873d305668a9ca0e99ff6c73dff14e6cbde9afEric Dong    GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID**)&mLanguageString, NULL);
405a412ad88e5737735ab54b35392b51d8a210c3b74ydong    if (mLanguageString == NULL) {
406a412ad88e5737735ab54b35392b51d8a210c3b74ydong      mLanguageString = AllocateCopyPool (
407a412ad88e5737735ab54b35392b51d8a210c3b74ydong                                 AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),
408a412ad88e5737735ab54b35392b51d8a210c3b74ydong                                 (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)
409a412ad88e5737735ab54b35392b51d8a210c3b74ydong                                 );
410a412ad88e5737735ab54b35392b51d8a210c3b74ydong      ASSERT (mLanguageString != NULL);
411a412ad88e5737735ab54b35392b51d8a210c3b74ydong    }
412de12ae821ca969dc99665a00ed95b91fa8215429ydong  }
413a412ad88e5737735ab54b35392b51d8a210c3b74ydong
414de12ae821ca969dc99665a00ed95b91fa8215429ydong  if (gFrontPagePrivate.LanguageToken == NULL) {
415a412ad88e5737735ab54b35392b51d8a210c3b74ydong    //
416a412ad88e5737735ab54b35392b51d8a210c3b74ydong    // Count the language list number.
417a412ad88e5737735ab54b35392b51d8a210c3b74ydong    //
418a412ad88e5737735ab54b35392b51d8a210c3b74ydong    LangCode      = mLanguageString;
419a412ad88e5737735ab54b35392b51d8a210c3b74ydong    Lang          = AllocatePool (AsciiStrSize (mLanguageString));
420a412ad88e5737735ab54b35392b51d8a210c3b74ydong    ASSERT (Lang != NULL);
421a412ad88e5737735ab54b35392b51d8a210c3b74ydong    OptionCount = 0;
42275bf9d0ecca38dfec9b645a6eb1119c025892304lgao    while (*LangCode != 0) {
4230b3f5a4dfd2e7acf36903bb4a8e210aef4225a55lgao      GetNextLanguage (&LangCode, Lang);
42475bf9d0ecca38dfec9b645a6eb1119c025892304lgao      OptionCount ++;
42575bf9d0ecca38dfec9b645a6eb1119c025892304lgao    }
426a412ad88e5737735ab54b35392b51d8a210c3b74ydong
427a412ad88e5737735ab54b35392b51d8a210c3b74ydong    //
428a412ad88e5737735ab54b35392b51d8a210c3b74ydong    // Allocate extra 1 as the end tag.
429a412ad88e5737735ab54b35392b51d8a210c3b74ydong    //
430a412ad88e5737735ab54b35392b51d8a210c3b74ydong    gFrontPagePrivate.LanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID));
43175bf9d0ecca38dfec9b645a6eb1119c025892304lgao    ASSERT (gFrontPagePrivate.LanguageToken != NULL);
43275bf9d0ecca38dfec9b645a6eb1119c025892304lgao
433a412ad88e5737735ab54b35392b51d8a210c3b74ydong    Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);
434a412ad88e5737735ab54b35392b51d8a210c3b74ydong    ASSERT_EFI_ERROR (Status);
4355c08e1173703234cc2913757f237ee916087498aklu
436a412ad88e5737735ab54b35392b51d8a210c3b74ydong    LangCode     = mLanguageString;
437a412ad88e5737735ab54b35392b51d8a210c3b74ydong    OptionCount  = 0;
438a412ad88e5737735ab54b35392b51d8a210c3b74ydong    while (*LangCode != 0) {
439a412ad88e5737735ab54b35392b51d8a210c3b74ydong      GetNextLanguage (&LangCode, Lang);
4405c08e1173703234cc2913757f237ee916087498aklu
441a412ad88e5737735ab54b35392b51d8a210c3b74ydong      StringSize = 0;
442a412ad88e5737735ab54b35392b51d8a210c3b74ydong      Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
443a412ad88e5737735ab54b35392b51d8a210c3b74ydong      if (Status == EFI_BUFFER_TOO_SMALL) {
444a412ad88e5737735ab54b35392b51d8a210c3b74ydong        StringBuffer = AllocateZeroPool (StringSize);
445a412ad88e5737735ab54b35392b51d8a210c3b74ydong        ASSERT (StringBuffer != NULL);
446a412ad88e5737735ab54b35392b51d8a210c3b74ydong        Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
447a412ad88e5737735ab54b35392b51d8a210c3b74ydong        ASSERT_EFI_ERROR (Status);
448a412ad88e5737735ab54b35392b51d8a210c3b74ydong      }
449a412ad88e5737735ab54b35392b51d8a210c3b74ydong
450a412ad88e5737735ab54b35392b51d8a210c3b74ydong      if (EFI_ERROR (Status)) {
451a412ad88e5737735ab54b35392b51d8a210c3b74ydong        StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16));
452a412ad88e5737735ab54b35392b51d8a210c3b74ydong        ASSERT (StringBuffer != NULL);
453a412ad88e5737735ab54b35392b51d8a210c3b74ydong        AsciiStrToUnicodeStr (Lang, StringBuffer);
454a412ad88e5737735ab54b35392b51d8a210c3b74ydong      }
455a412ad88e5737735ab54b35392b51d8a210c3b74ydong
456a412ad88e5737735ab54b35392b51d8a210c3b74ydong      ASSERT (StringBuffer != NULL);
45775bf9d0ecca38dfec9b645a6eb1119c025892304lgao      gFrontPagePrivate.LanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);
4585c08e1173703234cc2913757f237ee916087498aklu      FreePool (StringBuffer);
459a412ad88e5737735ab54b35392b51d8a210c3b74ydong
460a412ad88e5737735ab54b35392b51d8a210c3b74ydong      OptionCount++;
4615c08e1173703234cc2913757f237ee916087498aklu    }
462a412ad88e5737735ab54b35392b51d8a210c3b74ydong  }
4635c08e1173703234cc2913757f237ee916087498aklu
464a412ad88e5737735ab54b35392b51d8a210c3b74ydong  ASSERT (gFrontPagePrivate.LanguageToken != NULL);
465a412ad88e5737735ab54b35392b51d8a210c3b74ydong  LangCode     = mLanguageString;
466a412ad88e5737735ab54b35392b51d8a210c3b74ydong  OptionCount  = 0;
467a412ad88e5737735ab54b35392b51d8a210c3b74ydong  if (Lang == NULL) {
468a412ad88e5737735ab54b35392b51d8a210c3b74ydong    Lang = AllocatePool (AsciiStrSize (mLanguageString));
469a412ad88e5737735ab54b35392b51d8a210c3b74ydong    ASSERT (Lang != NULL);
470a412ad88e5737735ab54b35392b51d8a210c3b74ydong  }
471a412ad88e5737735ab54b35392b51d8a210c3b74ydong  while (*LangCode != 0) {
472a412ad88e5737735ab54b35392b51d8a210c3b74ydong    GetNextLanguage (&LangCode, Lang);
473a412ad88e5737735ab54b35392b51d8a210c3b74ydong
474a412ad88e5737735ab54b35392b51d8a210c3b74ydong    if (CurrentLang != NULL && AsciiStrCmp (Lang, CurrentLang) == 0) {
47575bf9d0ecca38dfec9b645a6eb1119c025892304lgao      HiiCreateOneOfOptionOpCode (
47675bf9d0ecca38dfec9b645a6eb1119c025892304lgao        OptionsOpCodeHandle,
47775bf9d0ecca38dfec9b645a6eb1119c025892304lgao        gFrontPagePrivate.LanguageToken[OptionCount],
47875bf9d0ecca38dfec9b645a6eb1119c025892304lgao        EFI_IFR_OPTION_DEFAULT,
47975bf9d0ecca38dfec9b645a6eb1119c025892304lgao        EFI_IFR_NUMERIC_SIZE_1,
48075bf9d0ecca38dfec9b645a6eb1119c025892304lgao        (UINT8) OptionCount
48175bf9d0ecca38dfec9b645a6eb1119c025892304lgao        );
4825c08e1173703234cc2913757f237ee916087498aklu    } else {
48375bf9d0ecca38dfec9b645a6eb1119c025892304lgao      HiiCreateOneOfOptionOpCode (
48475bf9d0ecca38dfec9b645a6eb1119c025892304lgao        OptionsOpCodeHandle,
48575bf9d0ecca38dfec9b645a6eb1119c025892304lgao        gFrontPagePrivate.LanguageToken[OptionCount],
48675bf9d0ecca38dfec9b645a6eb1119c025892304lgao        0,
48775bf9d0ecca38dfec9b645a6eb1119c025892304lgao        EFI_IFR_NUMERIC_SIZE_1,
48875bf9d0ecca38dfec9b645a6eb1119c025892304lgao        (UINT8) OptionCount
48975bf9d0ecca38dfec9b645a6eb1119c025892304lgao        );
4905c08e1173703234cc2913757f237ee916087498aklu    }
4915c08e1173703234cc2913757f237ee916087498aklu
4925c08e1173703234cc2913757f237ee916087498aklu    OptionCount++;
4935c08e1173703234cc2913757f237ee916087498aklu  }
4945c08e1173703234cc2913757f237ee916087498aklu
495a3a795afdb9d8efd8e6603cce92103d610346b78qhuang  if (CurrentLang != NULL) {
496a3a795afdb9d8efd8e6603cce92103d610346b78qhuang    FreePool (CurrentLang);
497a3a795afdb9d8efd8e6603cce92103d610346b78qhuang  }
498a3a795afdb9d8efd8e6603cce92103d610346b78qhuang  FreePool (Lang);
4995c08e1173703234cc2913757f237ee916087498aklu
50075bf9d0ecca38dfec9b645a6eb1119c025892304lgao  HiiCreateOneOfOpCode (
50175bf9d0ecca38dfec9b645a6eb1119c025892304lgao    StartOpCodeHandle,
5025c08e1173703234cc2913757f237ee916087498aklu    FRONT_PAGE_KEY_LANGUAGE,
5035c08e1173703234cc2913757f237ee916087498aklu    0,
5045c08e1173703234cc2913757f237ee916087498aklu    0,
5055c08e1173703234cc2913757f237ee916087498aklu    STRING_TOKEN (STR_LANGUAGE_SELECT),
5065c08e1173703234cc2913757f237ee916087498aklu    STRING_TOKEN (STR_LANGUAGE_SELECT_HELP),
5075c08e1173703234cc2913757f237ee916087498aklu    EFI_IFR_FLAG_CALLBACK,
5085c08e1173703234cc2913757f237ee916087498aklu    EFI_IFR_NUMERIC_SIZE_1,
50975bf9d0ecca38dfec9b645a6eb1119c025892304lgao    OptionsOpCodeHandle,
51075bf9d0ecca38dfec9b645a6eb1119c025892304lgao    NULL
5115c08e1173703234cc2913757f237ee916087498aklu    );
5125c08e1173703234cc2913757f237ee916087498aklu
51375bf9d0ecca38dfec9b645a6eb1119c025892304lgao  Status = HiiUpdateForm (
5145c08e1173703234cc2913757f237ee916087498aklu             HiiHandle,
515e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao             &gFrontPageFormSetGuid,
5165c08e1173703234cc2913757f237ee916087498aklu             FRONT_PAGE_FORM_ID,
51775bf9d0ecca38dfec9b645a6eb1119c025892304lgao             StartOpCodeHandle, // LABEL_SELECT_LANGUAGE
51875bf9d0ecca38dfec9b645a6eb1119c025892304lgao             EndOpCodeHandle    // LABEL_END
5195c08e1173703234cc2913757f237ee916087498aklu             );
5205c08e1173703234cc2913757f237ee916087498aklu
52175bf9d0ecca38dfec9b645a6eb1119c025892304lgao  HiiFreeOpCodeHandle (StartOpCodeHandle);
52275bf9d0ecca38dfec9b645a6eb1119c025892304lgao  HiiFreeOpCodeHandle (EndOpCodeHandle);
52375bf9d0ecca38dfec9b645a6eb1119c025892304lgao  HiiFreeOpCodeHandle (OptionsOpCodeHandle);
5245c08e1173703234cc2913757f237ee916087498aklu  return Status;
5255c08e1173703234cc2913757f237ee916087498aklu}
5265c08e1173703234cc2913757f237ee916087498aklu
5275c08e1173703234cc2913757f237ee916087498aklu/**
5285c08e1173703234cc2913757f237ee916087498aklu  Call the browser and display the front page
5295c08e1173703234cc2913757f237ee916087498aklu
5305c08e1173703234cc2913757f237ee916087498aklu  @return   Status code that will be returned by
5315c08e1173703234cc2913757f237ee916087498aklu            EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
5325c08e1173703234cc2913757f237ee916087498aklu
5335c08e1173703234cc2913757f237ee916087498aklu**/
5345c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
5355c08e1173703234cc2913757f237ee916087498akluCallFrontPage (
5365c08e1173703234cc2913757f237ee916087498aklu  VOID
5375c08e1173703234cc2913757f237ee916087498aklu  )
5385c08e1173703234cc2913757f237ee916087498aklu{
5395c08e1173703234cc2913757f237ee916087498aklu  EFI_STATUS                  Status;
5405c08e1173703234cc2913757f237ee916087498aklu  EFI_BROWSER_ACTION_REQUEST  ActionRequest;
5415c08e1173703234cc2913757f237ee916087498aklu
5425c08e1173703234cc2913757f237ee916087498aklu  //
5435c08e1173703234cc2913757f237ee916087498aklu  // Begin waiting for USER INPUT
5445c08e1173703234cc2913757f237ee916087498aklu  //
5455c08e1173703234cc2913757f237ee916087498aklu  REPORT_STATUS_CODE (
5465c08e1173703234cc2913757f237ee916087498aklu    EFI_PROGRESS_CODE,
5475c08e1173703234cc2913757f237ee916087498aklu    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
5485c08e1173703234cc2913757f237ee916087498aklu    );
5495c08e1173703234cc2913757f237ee916087498aklu
5505c08e1173703234cc2913757f237ee916087498aklu  ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
5515c08e1173703234cc2913757f237ee916087498aklu  Status = gFormBrowser2->SendForm (
5525c08e1173703234cc2913757f237ee916087498aklu                            gFormBrowser2,
5535c08e1173703234cc2913757f237ee916087498aklu                            &gFrontPagePrivate.HiiHandle,
5545c08e1173703234cc2913757f237ee916087498aklu                            1,
555e24fc1032db5d5d2395260f6d7af94aa5a2a0802lgao                            &gFrontPageFormSetGuid,
5565c08e1173703234cc2913757f237ee916087498aklu                            0,
5575c08e1173703234cc2913757f237ee916087498aklu                            NULL,
5585c08e1173703234cc2913757f237ee916087498aklu                            &ActionRequest
5595c08e1173703234cc2913757f237ee916087498aklu                            );
5605c08e1173703234cc2913757f237ee916087498aklu  //
561baf46e70a58d125b30b62fa24a59dd321b283fdcgikidy  // Check whether user change any option setting which needs a reset to be effective
5625c08e1173703234cc2913757f237ee916087498aklu  //
5635c08e1173703234cc2913757f237ee916087498aklu  if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {
5645c08e1173703234cc2913757f237ee916087498aklu    EnableResetRequired ();
5655c08e1173703234cc2913757f237ee916087498aklu  }
5665c08e1173703234cc2913757f237ee916087498aklu
5675c08e1173703234cc2913757f237ee916087498aklu  return Status;
5685c08e1173703234cc2913757f237ee916087498aklu}
5695c08e1173703234cc2913757f237ee916087498aklu
5705c08e1173703234cc2913757f237ee916087498aklu/**
5715c08e1173703234cc2913757f237ee916087498aklu  Acquire the string associated with the ProducerGuid and return it.
5725c08e1173703234cc2913757f237ee916087498aklu
5735c08e1173703234cc2913757f237ee916087498aklu
5745c08e1173703234cc2913757f237ee916087498aklu  @param ProducerGuid    The Guid to search the HII database for
5755c08e1173703234cc2913757f237ee916087498aklu  @param Token           The token value of the string to extract
5765c08e1173703234cc2913757f237ee916087498aklu  @param String          The string that is extracted
5775c08e1173703234cc2913757f237ee916087498aklu
5785c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCCESS  The function returns EFI_SUCCESS always.
5795c08e1173703234cc2913757f237ee916087498aklu
5805c08e1173703234cc2913757f237ee916087498aklu**/
5815c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
5825c08e1173703234cc2913757f237ee916087498akluGetProducerString (
5835c08e1173703234cc2913757f237ee916087498aklu  IN      EFI_GUID                  *ProducerGuid,
5845c08e1173703234cc2913757f237ee916087498aklu  IN      EFI_STRING_ID             Token,
5855c08e1173703234cc2913757f237ee916087498aklu  OUT     CHAR16                    **String
5865c08e1173703234cc2913757f237ee916087498aklu  )
5875c08e1173703234cc2913757f237ee916087498aklu{
588cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun  EFI_STRING      TmpString;
5895c08e1173703234cc2913757f237ee916087498aklu
590cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun  TmpString = HiiGetPackageString (ProducerGuid, Token, NULL);
591cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun  if (TmpString == NULL) {
5925c08e1173703234cc2913757f237ee916087498aklu    *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
593cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun  } else {
594cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun    *String = TmpString;
5955c08e1173703234cc2913757f237ee916087498aklu  }
5965c08e1173703234cc2913757f237ee916087498aklu
5975c08e1173703234cc2913757f237ee916087498aklu  return EFI_SUCCESS;
5985c08e1173703234cc2913757f237ee916087498aklu}
5995c08e1173703234cc2913757f237ee916087498aklu
6005c08e1173703234cc2913757f237ee916087498aklu/**
60113078b3fadb4aaae2d6975ab96a7ad649017589fklu  Convert Processor Frequency Data to a string.
6025c08e1173703234cc2913757f237ee916087498aklu
6035c08e1173703234cc2913757f237ee916087498aklu  @param ProcessorFrequency The frequency data to process
6046cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @param Base10Exponent     The exponent based on 10
6055c08e1173703234cc2913757f237ee916087498aklu  @param String             The string that is created
6065c08e1173703234cc2913757f237ee916087498aklu
6075c08e1173703234cc2913757f237ee916087498aklu**/
6085c08e1173703234cc2913757f237ee916087498akluVOID
6095c08e1173703234cc2913757f237ee916087498akluConvertProcessorToString (
6106cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  IN  UINT16                               ProcessorFrequency,
6116cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  IN  UINT16                               Base10Exponent,
6126cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  OUT CHAR16                               **String
6135c08e1173703234cc2913757f237ee916087498aklu  )
6145c08e1173703234cc2913757f237ee916087498aklu{
6155c08e1173703234cc2913757f237ee916087498aklu  CHAR16  *StringBuffer;
6165c08e1173703234cc2913757f237ee916087498aklu  UINTN   Index;
6175c08e1173703234cc2913757f237ee916087498aklu  UINT32  FreqMhz;
6185c08e1173703234cc2913757f237ee916087498aklu
6196cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  if (Base10Exponent >= 6) {
6206cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang    FreqMhz = ProcessorFrequency;
6216cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang    for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) {
6225c08e1173703234cc2913757f237ee916087498aklu      FreqMhz *= 10;
6235c08e1173703234cc2913757f237ee916087498aklu    }
6245c08e1173703234cc2913757f237ee916087498aklu  } else {
6255c08e1173703234cc2913757f237ee916087498aklu    FreqMhz = 0;
6265c08e1173703234cc2913757f237ee916087498aklu  }
6275c08e1173703234cc2913757f237ee916087498aklu
6285c08e1173703234cc2913757f237ee916087498aklu  StringBuffer = AllocateZeroPool (0x20);
6295c08e1173703234cc2913757f237ee916087498aklu  ASSERT (StringBuffer != NULL);
6305c08e1173703234cc2913757f237ee916087498aklu  Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
63119d02cc20c6bf888532d3616957eee5bacaf67caHao Wu  StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L".");
6325c08e1173703234cc2913757f237ee916087498aklu  UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
63319d02cc20c6bf888532d3616957eee5bacaf67caHao Wu  StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" GHz");
6345c08e1173703234cc2913757f237ee916087498aklu  *String = (CHAR16 *) StringBuffer;
6355c08e1173703234cc2913757f237ee916087498aklu  return ;
6365c08e1173703234cc2913757f237ee916087498aklu}
6375c08e1173703234cc2913757f237ee916087498aklu
6386cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
6395c08e1173703234cc2913757f237ee916087498aklu/**
6405c08e1173703234cc2913757f237ee916087498aklu  Convert Memory Size to a string.
6415c08e1173703234cc2913757f237ee916087498aklu
6425c08e1173703234cc2913757f237ee916087498aklu  @param MemorySize      The size of the memory to process
6435c08e1173703234cc2913757f237ee916087498aklu  @param String          The string that is created
6445c08e1173703234cc2913757f237ee916087498aklu
6455c08e1173703234cc2913757f237ee916087498aklu**/
6465c08e1173703234cc2913757f237ee916087498akluVOID
6475c08e1173703234cc2913757f237ee916087498akluConvertMemorySizeToString (
6485c08e1173703234cc2913757f237ee916087498aklu  IN  UINT32          MemorySize,
6495c08e1173703234cc2913757f237ee916087498aklu  OUT CHAR16          **String
6505c08e1173703234cc2913757f237ee916087498aklu  )
6515c08e1173703234cc2913757f237ee916087498aklu{
6525c08e1173703234cc2913757f237ee916087498aklu  CHAR16  *StringBuffer;
6535c08e1173703234cc2913757f237ee916087498aklu
6545c08e1173703234cc2913757f237ee916087498aklu  StringBuffer = AllocateZeroPool (0x20);
6555c08e1173703234cc2913757f237ee916087498aklu  ASSERT (StringBuffer != NULL);
6565c08e1173703234cc2913757f237ee916087498aklu  UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
65719d02cc20c6bf888532d3616957eee5bacaf67caHao Wu  StrCatS (StringBuffer, 0x20 / sizeof (CHAR16), L" MB RAM");
6585c08e1173703234cc2913757f237ee916087498aklu
6595c08e1173703234cc2913757f237ee916087498aklu  *String = (CHAR16 *) StringBuffer;
6605c08e1173703234cc2913757f237ee916087498aklu
6615c08e1173703234cc2913757f237ee916087498aklu  return ;
6625c08e1173703234cc2913757f237ee916087498aklu}
6635c08e1173703234cc2913757f237ee916087498aklu
6645c08e1173703234cc2913757f237ee916087498aklu/**
6656cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
6666cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  Acquire the string associated with the Index from smbios structure and return it.
6676cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  The caller is responsible for free the string buffer.
6686cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
6696cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @param    OptionalStrStart  The start position to search the string
6706cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @param    Index             The index of the string to extract
6716cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @param    String            The string that is extracted
6726cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
6736cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @retval   EFI_SUCCESS       The function returns EFI_SUCCESS always.
6746cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
6756cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang**/
6766cfbf7adff681490789ce9c20bf9344aee6a225edavidhuangEFI_STATUS
6776cfbf7adff681490789ce9c20bf9344aee6a225edavidhuangGetOptionalStringByIndex (
6786cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  IN      CHAR8                   *OptionalStrStart,
6796cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  IN      UINT8                   Index,
6806cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  OUT     CHAR16                  **String
6816cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  )
6826cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang{
6832ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu  UINTN          StrSize;
6846cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
6852ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu  if (Index == 0) {
6862ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    *String = AllocateZeroPool (sizeof (CHAR16));
6872ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    return EFI_SUCCESS;
6882ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu  }
6896cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
6902ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu  StrSize = 0;
6912ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu  do {
6922ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    Index--;
6932ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    OptionalStrStart += StrSize;
6942ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    StrSize           = AsciiStrSize (OptionalStrStart);
6952ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu  } while (OptionalStrStart[StrSize] != 0 && Index != 0);
6962ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu
697d69bf66dc1ad8143260dcb8e095d7ed91b211dd7niruiyu  if ((Index != 0) || (StrSize == 1)) {
698d69bf66dc1ad8143260dcb8e095d7ed91b211dd7niruiyu    //
699d69bf66dc1ad8143260dcb8e095d7ed91b211dd7niruiyu    // Meet the end of strings set but Index is non-zero, or
700d69bf66dc1ad8143260dcb8e095d7ed91b211dd7niruiyu    // Find an empty string
701d69bf66dc1ad8143260dcb8e095d7ed91b211dd7niruiyu    //
7022ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
7036cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  } else {
7042ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    *String = AllocatePool (StrSize * sizeof (CHAR16));
7052ca7eca448e914c5c21cac5ba3832e09b4b163e8niruiyu    AsciiStrToUnicodeStr (OptionalStrStart, *String);
7066cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  }
7076cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
7086cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  return EFI_SUCCESS;
7096cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang}
7106cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
7116cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
7126cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang/**
7135c08e1173703234cc2913757f237ee916087498aklu  Update the banner information for the Front Page based on DataHub information.
7145c08e1173703234cc2913757f237ee916087498aklu
7155c08e1173703234cc2913757f237ee916087498aklu**/
7165c08e1173703234cc2913757f237ee916087498akluVOID
7175c08e1173703234cc2913757f237ee916087498akluUpdateFrontPageStrings (
7185c08e1173703234cc2913757f237ee916087498aklu  VOID
7195c08e1173703234cc2913757f237ee916087498aklu  )
7205c08e1173703234cc2913757f237ee916087498aklu{
7216cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  UINT8                             StrIndex;
7225c08e1173703234cc2913757f237ee916087498aklu  CHAR16                            *NewString;
7235c08e1173703234cc2913757f237ee916087498aklu  BOOLEAN                           Find[5];
7246cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_STATUS                        Status;
7256cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_STRING_ID                     TokenToUpdate;
7266cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_SMBIOS_HANDLE                 SmbiosHandle;
7276cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_SMBIOS_PROTOCOL               *Smbios;
7286cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  SMBIOS_TABLE_TYPE0                *Type0Record;
7296cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  SMBIOS_TABLE_TYPE1                *Type1Record;
7306cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  SMBIOS_TABLE_TYPE4                *Type4Record;
7316cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  SMBIOS_TABLE_TYPE19               *Type19Record;
7326cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_SMBIOS_TABLE_HEADER           *Record;
7335c08e1173703234cc2913757f237ee916087498aklu
7345c08e1173703234cc2913757f237ee916087498aklu  ZeroMem (Find, sizeof (Find));
7355c08e1173703234cc2913757f237ee916087498aklu
7365c08e1173703234cc2913757f237ee916087498aklu  //
7375c08e1173703234cc2913757f237ee916087498aklu  // Update Front Page strings
7385c08e1173703234cc2913757f237ee916087498aklu  //
7395c08e1173703234cc2913757f237ee916087498aklu  Status = gBS->LocateProtocol (
7406cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang                  &gEfiSmbiosProtocolGuid,
7415c08e1173703234cc2913757f237ee916087498aklu                  NULL,
7426cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang                  (VOID **) &Smbios
7435c08e1173703234cc2913757f237ee916087498aklu                  );
7446d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin  if (!EFI_ERROR (Status)) {
7456d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin    SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
7466d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin    do {
7476d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
7486d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      if (EFI_ERROR(Status)) {
7496d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        break;
7506d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      }
7515c08e1173703234cc2913757f237ee916087498aklu
7526d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
7536d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
7546d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        StrIndex = Type0Record->BiosVersion;
7556d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);
7566d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
7576d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
7586d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        FreePool (NewString);
7596d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Find[0] = TRUE;
7606d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      }
7615c08e1173703234cc2913757f237ee916087498aklu
7626d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {
7636d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;
7646d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        StrIndex = Type1Record->ProductName;
7656d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);
7666d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
7676d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
7686d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        FreePool (NewString);
7696d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Find[1] = TRUE;
7706d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      }
7716d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin
7726d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
7736d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
7746d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        StrIndex = Type4Record->ProcessorVersion;
7756d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);
7766d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);
7776d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
7786d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        FreePool (NewString);
7796d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Find[2] = TRUE;
7806d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      }
7816d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin
7826d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
7836d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
7846d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);
7856d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);
7866d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
7876d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        FreePool (NewString);
7886d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Find[3] = TRUE;
7896d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      }
7906d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin
7916d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
7926d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
7936d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        ConvertMemorySizeToString (
7946d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin          (UINT32)(RShiftU64((Type19Record->EndingAddress - Type19Record->StartingAddress + 1), 10)),
7956d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin          &NewString
7966d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin          );
7976d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);
7986d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
7996d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        FreePool (NewString);
8006d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin        Find[4] = TRUE;
8016d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin      }
8026d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin    } while ( !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));
8036d5b88f372180dc3a8622fda19ae0ac1fb076ae8Olivier Martin  }
8045c08e1173703234cc2913757f237ee916087498aklu  return ;
8055c08e1173703234cc2913757f237ee916087498aklu}
8065c08e1173703234cc2913757f237ee916087498aklu
8076cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang
8085c08e1173703234cc2913757f237ee916087498aklu/**
8095c08e1173703234cc2913757f237ee916087498aklu  Function waits for a given event to fire, or for an optional timeout to expire.
8105c08e1173703234cc2913757f237ee916087498aklu
8116cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @param   Event              The event to wait for
8126cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @param   Timeout            An optional timeout value in 100 ns units.
8135c08e1173703234cc2913757f237ee916087498aklu
8145c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCCESS      Event fired before Timeout expired.
8155c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_TIME_OUT     Timout expired before Event fired..
8165c08e1173703234cc2913757f237ee916087498aklu
8175c08e1173703234cc2913757f237ee916087498aklu**/
8185c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
8195c08e1173703234cc2913757f237ee916087498akluWaitForSingleEvent (
8205c08e1173703234cc2913757f237ee916087498aklu  IN EFI_EVENT                  Event,
8215c08e1173703234cc2913757f237ee916087498aklu  IN UINT64                     Timeout OPTIONAL
8225c08e1173703234cc2913757f237ee916087498aklu  )
8235c08e1173703234cc2913757f237ee916087498aklu{
8245c08e1173703234cc2913757f237ee916087498aklu  UINTN       Index;
8256cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_STATUS  Status;
8265c08e1173703234cc2913757f237ee916087498aklu  EFI_EVENT   TimerEvent;
8275c08e1173703234cc2913757f237ee916087498aklu  EFI_EVENT   WaitList[2];
8285c08e1173703234cc2913757f237ee916087498aklu
8295c08e1173703234cc2913757f237ee916087498aklu  if (Timeout != 0) {
8305c08e1173703234cc2913757f237ee916087498aklu    //
8315c08e1173703234cc2913757f237ee916087498aklu    // Create a timer event
8325c08e1173703234cc2913757f237ee916087498aklu    //
8335c08e1173703234cc2913757f237ee916087498aklu    Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);
8345c08e1173703234cc2913757f237ee916087498aklu    if (!EFI_ERROR (Status)) {
8355c08e1173703234cc2913757f237ee916087498aklu      //
8365c08e1173703234cc2913757f237ee916087498aklu      // Set the timer event
8375c08e1173703234cc2913757f237ee916087498aklu      //
8385c08e1173703234cc2913757f237ee916087498aklu      gBS->SetTimer (
8396cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang             TimerEvent,
8406cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang             TimerRelative,
8416cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang             Timeout
8426cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang             );
8435c08e1173703234cc2913757f237ee916087498aklu
8445c08e1173703234cc2913757f237ee916087498aklu      //
8455c08e1173703234cc2913757f237ee916087498aklu      // Wait for the original event or the timer
8465c08e1173703234cc2913757f237ee916087498aklu      //
8475c08e1173703234cc2913757f237ee916087498aklu      WaitList[0] = Event;
8485c08e1173703234cc2913757f237ee916087498aklu      WaitList[1] = TimerEvent;
8495c08e1173703234cc2913757f237ee916087498aklu      Status      = gBS->WaitForEvent (2, WaitList, &Index);
8505c08e1173703234cc2913757f237ee916087498aklu      gBS->CloseEvent (TimerEvent);
8515c08e1173703234cc2913757f237ee916087498aklu
8525c08e1173703234cc2913757f237ee916087498aklu      //
8535c08e1173703234cc2913757f237ee916087498aklu      // If the timer expired, change the return to timed out
8545c08e1173703234cc2913757f237ee916087498aklu      //
8555c08e1173703234cc2913757f237ee916087498aklu      if (!EFI_ERROR (Status) && Index == 1) {
8565c08e1173703234cc2913757f237ee916087498aklu        Status = EFI_TIMEOUT;
8575c08e1173703234cc2913757f237ee916087498aklu      }
8585c08e1173703234cc2913757f237ee916087498aklu    }
8595c08e1173703234cc2913757f237ee916087498aklu  } else {
8605c08e1173703234cc2913757f237ee916087498aklu    //
8615c08e1173703234cc2913757f237ee916087498aklu    // No timeout... just wait on the event
8625c08e1173703234cc2913757f237ee916087498aklu    //
8635c08e1173703234cc2913757f237ee916087498aklu    Status = gBS->WaitForEvent (1, &Event, &Index);
8645c08e1173703234cc2913757f237ee916087498aklu    ASSERT (!EFI_ERROR (Status));
8655c08e1173703234cc2913757f237ee916087498aklu    ASSERT (Index == 0);
8665c08e1173703234cc2913757f237ee916087498aklu  }
8675c08e1173703234cc2913757f237ee916087498aklu
8685c08e1173703234cc2913757f237ee916087498aklu  return Status;
8695c08e1173703234cc2913757f237ee916087498aklu}
8705c08e1173703234cc2913757f237ee916087498aklu
8715c08e1173703234cc2913757f237ee916087498aklu/**
8725c08e1173703234cc2913757f237ee916087498aklu  Function show progress bar to wait for user input.
8735c08e1173703234cc2913757f237ee916087498aklu
8745c08e1173703234cc2913757f237ee916087498aklu
8756cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  @param   TimeoutDefault  The fault time out value before the system continue to boot.
8765c08e1173703234cc2913757f237ee916087498aklu
8775c08e1173703234cc2913757f237ee916087498aklu  @retval  EFI_SUCCESS       User pressed some key except "Enter"
878baf46e70a58d125b30b62fa24a59dd321b283fdcgikidy  @retval  EFI_TIME_OUT      Timeout expired or user press "Enter"
8795c08e1173703234cc2913757f237ee916087498aklu
8805c08e1173703234cc2913757f237ee916087498aklu**/
8815c08e1173703234cc2913757f237ee916087498akluEFI_STATUS
8825c08e1173703234cc2913757f237ee916087498akluShowProgress (
8835c08e1173703234cc2913757f237ee916087498aklu  IN UINT16                       TimeoutDefault
8845c08e1173703234cc2913757f237ee916087498aklu  )
8855c08e1173703234cc2913757f237ee916087498aklu{
8865c08e1173703234cc2913757f237ee916087498aklu  CHAR16                        *TmpStr;
8876cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  UINT16                        TimeoutRemain;
8886cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_STATUS                    Status;
8896cfbf7adff681490789ce9c20bf9344aee6a225edavidhuang  EFI_INPUT_KEY                 Key;
8905c08e1173703234cc2913757f237ee916087498aklu  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
8915c08e1173703234cc2913757f237ee916087498aklu  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
8925c08e1173703234cc2913757f237ee916087498aklu  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
8935c08e1173703234cc2913757f237ee916087498aklu
894e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong  if (TimeoutDefault != 0) {
895e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
896128efbbcc2e3e8d4ee3c269563a5e2ee461dc3e3darylm
897e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
898e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
899e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
9002df686c67c7819e01a1487dd703faffef2b59dceczhang
901e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));
902e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong
9032df686c67c7819e01a1487dd703faffef2b59dceczhang    if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
9042df686c67c7819e01a1487dd703faffef2b59dceczhang      //
905e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      // Clear the progress status bar first
9062df686c67c7819e01a1487dd703faffef2b59dceczhang      //
9072df686c67c7819e01a1487dd703faffef2b59dceczhang      if (TmpStr != NULL) {
908e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong        PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);
9092df686c67c7819e01a1487dd703faffef2b59dceczhang      }
9105c08e1173703234cc2913757f237ee916087498aklu    }
911e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong
9125c08e1173703234cc2913757f237ee916087498aklu
913e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    TimeoutRemain = TimeoutDefault;
914e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    while (TimeoutRemain != 0) {
915e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      DEBUG ((EFI_D_INFO, "Showing progress bar...Remaining %d second!\n", TimeoutRemain));
916e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong
917e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      Status = WaitForSingleEvent (gST->ConIn->WaitForKey, ONE_SECOND);
918e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      if (Status != EFI_TIMEOUT) {
919e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong        break;
920e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      }
921e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      TimeoutRemain--;
922e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong
923e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
924e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong        //
925e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong        // Show progress
926e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong        //
927e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong        if (TmpStr != NULL) {
928e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong          PlatformBdsShowProgress (
929e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong            Foreground,
930e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong            Background,
931e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong            TmpStr,
932e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong            Color,
933e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong            ((TimeoutDefault - TimeoutRemain) * 100 / TimeoutDefault),
934e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong            0
935e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong            );
936e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong        }
937e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      }
938e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    }
939e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong
940e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    if (TmpStr != NULL) {
941e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      gBS->FreePool (TmpStr);
942e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    }
943e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong
944e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    //
945e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    // Timeout expired
946e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    //
947e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    if (TimeoutRemain == 0) {
948e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong      return EFI_TIMEOUT;
949e0763f87575cbd58bc38c4220e59010265a620e1Eric Dong    }
9505c08e1173703234cc2913757f237ee916087498aklu  }
9515c08e1173703234cc2913757f237ee916087498aklu
9525c08e1173703234cc2913757f237ee916087498aklu  //
9535c08e1173703234cc2913757f237ee916087498aklu  // User pressed some key
9545c08e1173703234cc2913757f237ee916087498aklu  //
95518cf3950226cb7e279f19978ea441ce6639f7bb3czhang  if (!PcdGetBool (PcdConInConnectOnDemand)) {
95618cf3950226cb7e279f19978ea441ce6639f7bb3czhang    Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
95718cf3950226cb7e279f19978ea441ce6639f7bb3czhang    if (EFI_ERROR (Status)) {
95818cf3950226cb7e279f19978ea441ce6639f7bb3czhang      return Status;
95918cf3950226cb7e279f19978ea441ce6639f7bb3czhang    }
9605c08e1173703234cc2913757f237ee916087498aklu
96118cf3950226cb7e279f19978ea441ce6639f7bb3czhang    if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
96218cf3950226cb7e279f19978ea441ce6639f7bb3czhang      //
96318cf3950226cb7e279f19978ea441ce6639f7bb3czhang      // User pressed enter, equivalent to select "continue"
96418cf3950226cb7e279f19978ea441ce6639f7bb3czhang      //
96518cf3950226cb7e279f19978ea441ce6639f7bb3czhang      return EFI_TIMEOUT;
96618cf3950226cb7e279f19978ea441ce6639f7bb3czhang    }
9675c08e1173703234cc2913757f237ee916087498aklu  }
9685c08e1173703234cc2913757f237ee916087498aklu
9695c08e1173703234cc2913757f237ee916087498aklu  return EFI_SUCCESS;
9705c08e1173703234cc2913757f237ee916087498aklu}
9715c08e1173703234cc2913757f237ee916087498aklu
9725c08e1173703234cc2913757f237ee916087498aklu/**
9735c08e1173703234cc2913757f237ee916087498aklu  This function is the main entry of the platform setup entry.
9745c08e1173703234cc2913757f237ee916087498aklu  The function will present the main menu of the system setup,
9755c08e1173703234cc2913757f237ee916087498aklu  this is the platform reference part and can be customize.
9765c08e1173703234cc2913757f237ee916087498aklu
9775c08e1173703234cc2913757f237ee916087498aklu
9785c08e1173703234cc2913757f237ee916087498aklu  @param TimeoutDefault     The fault time out value before the system
9795c08e1173703234cc2913757f237ee916087498aklu                            continue to boot.
9805c08e1173703234cc2913757f237ee916087498aklu  @param ConnectAllHappened The indicater to check if the connect all have
981baf46e70a58d125b30b62fa24a59dd321b283fdcgikidy                            already happened.
9825c08e1173703234cc2913757f237ee916087498aklu
9835c08e1173703234cc2913757f237ee916087498aklu**/
9845c08e1173703234cc2913757f237ee916087498akluVOID
9855c08e1173703234cc2913757f237ee916087498akluPlatformBdsEnterFrontPage (
9865c08e1173703234cc2913757f237ee916087498aklu  IN UINT16                       TimeoutDefault,
9875c08e1173703234cc2913757f237ee916087498aklu  IN BOOLEAN                      ConnectAllHappened
9885c08e1173703234cc2913757f237ee916087498aklu  )
9895c08e1173703234cc2913757f237ee916087498aklu{
9902df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_STATUS                         Status;
9912df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_STATUS                         StatusHotkey;
9922df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_BOOT_LOGO_PROTOCOL             *BootLogo;
9932df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_GRAPHICS_OUTPUT_PROTOCOL       *GraphicsOutput;
9942df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *SimpleTextOut;
9952df686c67c7819e01a1487dd703faffef2b59dceczhang  UINTN                              BootTextColumn;
9962df686c67c7819e01a1487dd703faffef2b59dceczhang  UINTN                              BootTextRow;
99718cf3950226cb7e279f19978ea441ce6639f7bb3czhang  UINT64                             OsIndication;
99818cf3950226cb7e279f19978ea441ce6639f7bb3czhang  UINTN                              DataSize;
99918cf3950226cb7e279f19978ea441ce6639f7bb3czhang  EFI_INPUT_KEY                      Key;
100018cf3950226cb7e279f19978ea441ce6639f7bb3czhang
10012df686c67c7819e01a1487dd703faffef2b59dceczhang  GraphicsOutput = NULL;
10022df686c67c7819e01a1487dd703faffef2b59dceczhang  SimpleTextOut = NULL;
10035c08e1173703234cc2913757f237ee916087498aklu
1004128efbbcc2e3e8d4ee3c269563a5e2ee461dc3e3darylm  PERF_START (NULL, "BdsTimeOut", "BDS", 0);
10055c08e1173703234cc2913757f237ee916087498aklu  //
10065c08e1173703234cc2913757f237ee916087498aklu  // Indicate if we need connect all in the platform setup
10075c08e1173703234cc2913757f237ee916087498aklu  //
10085c08e1173703234cc2913757f237ee916087498aklu  if (ConnectAllHappened) {
10095c08e1173703234cc2913757f237ee916087498aklu    gConnectAllHappened = TRUE;
10105c08e1173703234cc2913757f237ee916087498aklu  }
101118cf3950226cb7e279f19978ea441ce6639f7bb3czhang
10122df686c67c7819e01a1487dd703faffef2b59dceczhang  if (!mModeInitialized) {
10132df686c67c7819e01a1487dd703faffef2b59dceczhang    //
10142df686c67c7819e01a1487dd703faffef2b59dceczhang    // After the console is ready, get current video resolution
10152df686c67c7819e01a1487dd703faffef2b59dceczhang    // and text mode before launching setup at first time.
10162df686c67c7819e01a1487dd703faffef2b59dceczhang    //
10172df686c67c7819e01a1487dd703faffef2b59dceczhang    Status = gBS->HandleProtocol (
10182df686c67c7819e01a1487dd703faffef2b59dceczhang                    gST->ConsoleOutHandle,
10192df686c67c7819e01a1487dd703faffef2b59dceczhang                    &gEfiGraphicsOutputProtocolGuid,
10202df686c67c7819e01a1487dd703faffef2b59dceczhang                    (VOID**)&GraphicsOutput
10212df686c67c7819e01a1487dd703faffef2b59dceczhang                    );
10222df686c67c7819e01a1487dd703faffef2b59dceczhang    if (EFI_ERROR (Status)) {
10232df686c67c7819e01a1487dd703faffef2b59dceczhang      GraphicsOutput = NULL;
10242df686c67c7819e01a1487dd703faffef2b59dceczhang    }
10252df686c67c7819e01a1487dd703faffef2b59dceczhang
10262df686c67c7819e01a1487dd703faffef2b59dceczhang    Status = gBS->HandleProtocol (
10272df686c67c7819e01a1487dd703faffef2b59dceczhang                    gST->ConsoleOutHandle,
10282df686c67c7819e01a1487dd703faffef2b59dceczhang                    &gEfiSimpleTextOutProtocolGuid,
10292df686c67c7819e01a1487dd703faffef2b59dceczhang                    (VOID**)&SimpleTextOut
10302df686c67c7819e01a1487dd703faffef2b59dceczhang                    );
10312df686c67c7819e01a1487dd703faffef2b59dceczhang    if (EFI_ERROR (Status)) {
10322df686c67c7819e01a1487dd703faffef2b59dceczhang      SimpleTextOut = NULL;
10332df686c67c7819e01a1487dd703faffef2b59dceczhang    }
10342df686c67c7819e01a1487dd703faffef2b59dceczhang
10352df686c67c7819e01a1487dd703faffef2b59dceczhang    if (GraphicsOutput != NULL) {
10362df686c67c7819e01a1487dd703faffef2b59dceczhang      //
10372df686c67c7819e01a1487dd703faffef2b59dceczhang      // Get current video resolution and text mode.
10382df686c67c7819e01a1487dd703faffef2b59dceczhang      //
10392df686c67c7819e01a1487dd703faffef2b59dceczhang      mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
10402df686c67c7819e01a1487dd703faffef2b59dceczhang      mBootVerticalResolution   = GraphicsOutput->Mode->Info->VerticalResolution;
10412df686c67c7819e01a1487dd703faffef2b59dceczhang    }
10422df686c67c7819e01a1487dd703faffef2b59dceczhang
10432df686c67c7819e01a1487dd703faffef2b59dceczhang    if (SimpleTextOut != NULL) {
10442df686c67c7819e01a1487dd703faffef2b59dceczhang      Status = SimpleTextOut->QueryMode (
10452df686c67c7819e01a1487dd703faffef2b59dceczhang                                SimpleTextOut,
10462df686c67c7819e01a1487dd703faffef2b59dceczhang                                SimpleTextOut->Mode->Mode,
10472df686c67c7819e01a1487dd703faffef2b59dceczhang                                &BootTextColumn,
10482df686c67c7819e01a1487dd703faffef2b59dceczhang                                &BootTextRow
10492df686c67c7819e01a1487dd703faffef2b59dceczhang                                );
10502df686c67c7819e01a1487dd703faffef2b59dceczhang      mBootTextModeColumn = (UINT32)BootTextColumn;
10512df686c67c7819e01a1487dd703faffef2b59dceczhang      mBootTextModeRow    = (UINT32)BootTextRow;
10522df686c67c7819e01a1487dd703faffef2b59dceczhang    }
10532df686c67c7819e01a1487dd703faffef2b59dceczhang
10542df686c67c7819e01a1487dd703faffef2b59dceczhang    //
10552df686c67c7819e01a1487dd703faffef2b59dceczhang    // Get user defined text mode for setup.
10562df686c67c7819e01a1487dd703faffef2b59dceczhang    //
10572df686c67c7819e01a1487dd703faffef2b59dceczhang    mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
10582df686c67c7819e01a1487dd703faffef2b59dceczhang    mSetupVerticalResolution   = PcdGet32 (PcdSetupVideoVerticalResolution);
10592df686c67c7819e01a1487dd703faffef2b59dceczhang    mSetupTextModeColumn       = PcdGet32 (PcdSetupConOutColumn);
10602df686c67c7819e01a1487dd703faffef2b59dceczhang    mSetupTextModeRow          = PcdGet32 (PcdSetupConOutRow);
10612df686c67c7819e01a1487dd703faffef2b59dceczhang
10622df686c67c7819e01a1487dd703faffef2b59dceczhang    mModeInitialized           = TRUE;
10632df686c67c7819e01a1487dd703faffef2b59dceczhang  }
10642df686c67c7819e01a1487dd703faffef2b59dceczhang
10655c08e1173703234cc2913757f237ee916087498aklu
106618cf3950226cb7e279f19978ea441ce6639f7bb3czhang  //
106718cf3950226cb7e279f19978ea441ce6639f7bb3czhang  // goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set
106818cf3950226cb7e279f19978ea441ce6639f7bb3czhang  //
106918cf3950226cb7e279f19978ea441ce6639f7bb3czhang  OsIndication = 0;
107018cf3950226cb7e279f19978ea441ce6639f7bb3czhang  DataSize = sizeof(UINT64);
107118cf3950226cb7e279f19978ea441ce6639f7bb3czhang  Status = gRT->GetVariable (
107218cf3950226cb7e279f19978ea441ce6639f7bb3czhang                  L"OsIndications",
107318cf3950226cb7e279f19978ea441ce6639f7bb3czhang                  &gEfiGlobalVariableGuid,
107418cf3950226cb7e279f19978ea441ce6639f7bb3czhang                  NULL,
107518cf3950226cb7e279f19978ea441ce6639f7bb3czhang                  &DataSize,
107618cf3950226cb7e279f19978ea441ce6639f7bb3czhang                  &OsIndication
107718cf3950226cb7e279f19978ea441ce6639f7bb3czhang                  );
10785c08e1173703234cc2913757f237ee916087498aklu
107918cf3950226cb7e279f19978ea441ce6639f7bb3czhang  //
108018cf3950226cb7e279f19978ea441ce6639f7bb3czhang  // goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot
108118cf3950226cb7e279f19978ea441ce6639f7bb3czhang  //
1082e27ad65778e196506ad6ceb22cb05838bdbb2c83czhang  if (!EFI_ERROR(Status) && ((OsIndication & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0)) {
108318cf3950226cb7e279f19978ea441ce6639f7bb3czhang    //
108418cf3950226cb7e279f19978ea441ce6639f7bb3czhang    // Clear EFI_OS_INDICATIONS_BOOT_TO_FW_UI to acknowledge OS
108518cf3950226cb7e279f19978ea441ce6639f7bb3czhang    //
10861a45b15eae48d9bf498daf5b0c0771659d75faa2Jeff Fan    OsIndication &= ~((UINT64)EFI_OS_INDICATIONS_BOOT_TO_FW_UI);
108718cf3950226cb7e279f19978ea441ce6639f7bb3czhang    Status = gRT->SetVariable (
108818cf3950226cb7e279f19978ea441ce6639f7bb3czhang                    L"OsIndications",
108918cf3950226cb7e279f19978ea441ce6639f7bb3czhang                    &gEfiGlobalVariableGuid,
109018cf3950226cb7e279f19978ea441ce6639f7bb3czhang                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
109118cf3950226cb7e279f19978ea441ce6639f7bb3czhang                    sizeof(UINT64),
109218cf3950226cb7e279f19978ea441ce6639f7bb3czhang                    &OsIndication
109318cf3950226cb7e279f19978ea441ce6639f7bb3czhang                    );
109469fc8f080e07ea026e8fbb8610cfb89c099d6db2Ruiyu Ni    //
109569fc8f080e07ea026e8fbb8610cfb89c099d6db2Ruiyu Ni    // Changing the content without increasing its size with current variable implementation shouldn't fail.
109669fc8f080e07ea026e8fbb8610cfb89c099d6db2Ruiyu Ni    //
109718cf3950226cb7e279f19978ea441ce6639f7bb3czhang    ASSERT_EFI_ERROR (Status);
109818cf3950226cb7e279f19978ea441ce6639f7bb3czhang
109918cf3950226cb7e279f19978ea441ce6639f7bb3czhang    //
110018cf3950226cb7e279f19978ea441ce6639f7bb3czhang    // Follow generic rule, Call ReadKeyStroke to connect ConIn before enter UI
110118cf3950226cb7e279f19978ea441ce6639f7bb3czhang    //
110218cf3950226cb7e279f19978ea441ce6639f7bb3czhang    if (PcdGetBool (PcdConInConnectOnDemand)) {
110318cf3950226cb7e279f19978ea441ce6639f7bb3czhang      gST->ConIn->ReadKeyStroke(gST->ConIn, &Key);
11042df686c67c7819e01a1487dd703faffef2b59dceczhang    }
11055c08e1173703234cc2913757f237ee916087498aklu
110618cf3950226cb7e279f19978ea441ce6639f7bb3czhang    //
110718cf3950226cb7e279f19978ea441ce6639f7bb3czhang    // Ensure screen is clear when switch Console from Graphics mode to Text mode
110818cf3950226cb7e279f19978ea441ce6639f7bb3czhang    //
110918cf3950226cb7e279f19978ea441ce6639f7bb3czhang    gST->ConOut->EnableCursor (gST->ConOut, TRUE);
111018cf3950226cb7e279f19978ea441ce6639f7bb3czhang    gST->ConOut->ClearScreen (gST->ConOut);
111118cf3950226cb7e279f19978ea441ce6639f7bb3czhang
111218cf3950226cb7e279f19978ea441ce6639f7bb3czhang  } else {
111318cf3950226cb7e279f19978ea441ce6639f7bb3czhang
111418cf3950226cb7e279f19978ea441ce6639f7bb3czhang    HotkeyBoot ();
111518cf3950226cb7e279f19978ea441ce6639f7bb3czhang    if (TimeoutDefault != 0xffff) {
111618cf3950226cb7e279f19978ea441ce6639f7bb3czhang      Status = ShowProgress (TimeoutDefault);
111718cf3950226cb7e279f19978ea441ce6639f7bb3czhang      StatusHotkey = HotkeyBoot ();
111818cf3950226cb7e279f19978ea441ce6639f7bb3czhang
111918cf3950226cb7e279f19978ea441ce6639f7bb3czhang      if (!FeaturePcdGet(PcdBootlogoOnlyEnable) || !EFI_ERROR(Status) || !EFI_ERROR(StatusHotkey)){
112018cf3950226cb7e279f19978ea441ce6639f7bb3czhang        //
112118cf3950226cb7e279f19978ea441ce6639f7bb3czhang        // Ensure screen is clear when switch Console from Graphics mode to Text mode
112218cf3950226cb7e279f19978ea441ce6639f7bb3czhang        // Skip it in normal boot
112318cf3950226cb7e279f19978ea441ce6639f7bb3czhang        //
112418cf3950226cb7e279f19978ea441ce6639f7bb3czhang        gST->ConOut->EnableCursor (gST->ConOut, TRUE);
112518cf3950226cb7e279f19978ea441ce6639f7bb3czhang        gST->ConOut->ClearScreen (gST->ConOut);
112618cf3950226cb7e279f19978ea441ce6639f7bb3czhang      }
112718cf3950226cb7e279f19978ea441ce6639f7bb3czhang
112818cf3950226cb7e279f19978ea441ce6639f7bb3czhang      if (EFI_ERROR (Status)) {
112918cf3950226cb7e279f19978ea441ce6639f7bb3czhang        //
113018cf3950226cb7e279f19978ea441ce6639f7bb3czhang        // Timeout or user press enter to continue
113118cf3950226cb7e279f19978ea441ce6639f7bb3czhang        //
113218cf3950226cb7e279f19978ea441ce6639f7bb3czhang        goto Exit;
113318cf3950226cb7e279f19978ea441ce6639f7bb3czhang      }
11345c08e1173703234cc2913757f237ee916087498aklu    }
11355c08e1173703234cc2913757f237ee916087498aklu  }
11365c08e1173703234cc2913757f237ee916087498aklu
1137a637802c2f8765549cf41a5694f53860b24601c9xdu  //
1138a637802c2f8765549cf41a5694f53860b24601c9xdu  // Boot Logo is corrupted, report it using Boot Logo protocol.
1139a637802c2f8765549cf41a5694f53860b24601c9xdu  //
1140a637802c2f8765549cf41a5694f53860b24601c9xdu  Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);
1141a637802c2f8765549cf41a5694f53860b24601c9xdu  if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
1142a637802c2f8765549cf41a5694f53860b24601c9xdu    BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
1143a637802c2f8765549cf41a5694f53860b24601c9xdu  }
1144a637802c2f8765549cf41a5694f53860b24601c9xdu
1145be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  //
1146be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  // Install BM HiiPackages.
1147be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  // Keep BootMaint HiiPackage, so that it can be covered by global setting.
1148be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  //
1149be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  InitBMPackage ();
1150be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong
1151847240774030f9da79140a9d515a64ec817eb6ebydong  Status = EFI_SUCCESS;
11525c08e1173703234cc2913757f237ee916087498aklu  do {
115372861c22e50f41572b1f3e682b7126b5c57718c5li-elvin    //
115472861c22e50f41572b1f3e682b7126b5c57718c5li-elvin    // Set proper video resolution and text mode for setup
115572861c22e50f41572b1f3e682b7126b5c57718c5li-elvin    //
11562df686c67c7819e01a1487dd703faffef2b59dceczhang    BdsSetConsoleMode (TRUE);
115772861c22e50f41572b1f3e682b7126b5c57718c5li-elvin
11585c08e1173703234cc2913757f237ee916087498aklu    InitializeFrontPage (FALSE);
11595c08e1173703234cc2913757f237ee916087498aklu
11605c08e1173703234cc2913757f237ee916087498aklu    //
11615c08e1173703234cc2913757f237ee916087498aklu    // Update Front Page strings
11625c08e1173703234cc2913757f237ee916087498aklu    //
11635c08e1173703234cc2913757f237ee916087498aklu    UpdateFrontPageStrings ();
11645c08e1173703234cc2913757f237ee916087498aklu
11655c08e1173703234cc2913757f237ee916087498aklu    gCallbackKey = 0;
1166847240774030f9da79140a9d515a64ec817eb6ebydong    CallFrontPage ();
11675c08e1173703234cc2913757f237ee916087498aklu
11685c08e1173703234cc2913757f237ee916087498aklu    //
11695c08e1173703234cc2913757f237ee916087498aklu    // If gCallbackKey is greater than 1 and less or equal to 5,
1170baf46e70a58d125b30b62fa24a59dd321b283fdcgikidy    // it will launch configuration utilities.
11715c08e1173703234cc2913757f237ee916087498aklu    // 2 = set language
11725c08e1173703234cc2913757f237ee916087498aklu    // 3 = boot manager
11735c08e1173703234cc2913757f237ee916087498aklu    // 4 = device manager
1174baf46e70a58d125b30b62fa24a59dd321b283fdcgikidy    // 5 = boot maintenance manager
11755c08e1173703234cc2913757f237ee916087498aklu    //
11765c08e1173703234cc2913757f237ee916087498aklu    if (gCallbackKey != 0) {
11775c08e1173703234cc2913757f237ee916087498aklu      REPORT_STATUS_CODE (
11785c08e1173703234cc2913757f237ee916087498aklu        EFI_PROGRESS_CODE,
11795c08e1173703234cc2913757f237ee916087498aklu        (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
11805c08e1173703234cc2913757f237ee916087498aklu        );
11815c08e1173703234cc2913757f237ee916087498aklu    }
11825c08e1173703234cc2913757f237ee916087498aklu    //
11835c08e1173703234cc2913757f237ee916087498aklu    // Based on the key that was set, we can determine what to do
11845c08e1173703234cc2913757f237ee916087498aklu    //
11855c08e1173703234cc2913757f237ee916087498aklu    switch (gCallbackKey) {
11865c08e1173703234cc2913757f237ee916087498aklu    //
11875c08e1173703234cc2913757f237ee916087498aklu    // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
11885c08e1173703234cc2913757f237ee916087498aklu    // describe to their customers in documentation how to find their setup information (namely
11895c08e1173703234cc2913757f237ee916087498aklu    // under the device manager and specific buckets)
11905c08e1173703234cc2913757f237ee916087498aklu    //
11915c08e1173703234cc2913757f237ee916087498aklu    // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
11925c08e1173703234cc2913757f237ee916087498aklu    //
11935c08e1173703234cc2913757f237ee916087498aklu    case FRONT_PAGE_KEY_CONTINUE:
11945c08e1173703234cc2913757f237ee916087498aklu      //
11955c08e1173703234cc2913757f237ee916087498aklu      // User hit continue
11965c08e1173703234cc2913757f237ee916087498aklu      //
11975c08e1173703234cc2913757f237ee916087498aklu      break;
11985c08e1173703234cc2913757f237ee916087498aklu
11995c08e1173703234cc2913757f237ee916087498aklu    case FRONT_PAGE_KEY_LANGUAGE:
12005c08e1173703234cc2913757f237ee916087498aklu      //
12015c08e1173703234cc2913757f237ee916087498aklu      // User made a language setting change - display front page again
12025c08e1173703234cc2913757f237ee916087498aklu      //
12035c08e1173703234cc2913757f237ee916087498aklu      break;
12045c08e1173703234cc2913757f237ee916087498aklu
12055c08e1173703234cc2913757f237ee916087498aklu    case FRONT_PAGE_KEY_BOOT_MANAGER:
12065c08e1173703234cc2913757f237ee916087498aklu      //
1207be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      // Remove the installed BootMaint HiiPackages when exit.
1208be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      //
1209be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      FreeBMPackage ();
1210be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong
1211be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      //
12125c08e1173703234cc2913757f237ee916087498aklu      // User chose to run the Boot Manager
12135c08e1173703234cc2913757f237ee916087498aklu      //
1214bd2057a846ee3b65e76b4398129cc02b93c46fbdgikidy      CallBootManager ();
1215be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong
1216be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      //
1217be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      // Reinstall BootMaint HiiPackages after exiting from Boot Manager.
1218be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      //
1219be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong      InitBMPackage ();
12205c08e1173703234cc2913757f237ee916087498aklu      break;
12215c08e1173703234cc2913757f237ee916087498aklu
12225c08e1173703234cc2913757f237ee916087498aklu    case FRONT_PAGE_KEY_DEVICE_MANAGER:
12235c08e1173703234cc2913757f237ee916087498aklu      //
12245c08e1173703234cc2913757f237ee916087498aklu      // Display the Device Manager
12255c08e1173703234cc2913757f237ee916087498aklu      //
12265c08e1173703234cc2913757f237ee916087498aklu      do {
1227bd2057a846ee3b65e76b4398129cc02b93c46fbdgikidy        CallDeviceManager ();
12285c08e1173703234cc2913757f237ee916087498aklu      } while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER);
12295c08e1173703234cc2913757f237ee916087498aklu      break;
12305c08e1173703234cc2913757f237ee916087498aklu
12315c08e1173703234cc2913757f237ee916087498aklu    case FRONT_PAGE_KEY_BOOT_MAINTAIN:
12325c08e1173703234cc2913757f237ee916087498aklu      //
12335c08e1173703234cc2913757f237ee916087498aklu      // Display the Boot Maintenance Manager
12345c08e1173703234cc2913757f237ee916087498aklu      //
12355c08e1173703234cc2913757f237ee916087498aklu      BdsStartBootMaint ();
12365c08e1173703234cc2913757f237ee916087498aklu      break;
12375c08e1173703234cc2913757f237ee916087498aklu    }
12385c08e1173703234cc2913757f237ee916087498aklu
12395c08e1173703234cc2913757f237ee916087498aklu  } while ((Status == EFI_SUCCESS) && (gCallbackKey != FRONT_PAGE_KEY_CONTINUE));
12405c08e1173703234cc2913757f237ee916087498aklu
1241a412ad88e5737735ab54b35392b51d8a210c3b74ydong  if (mLanguageString != NULL) {
1242a412ad88e5737735ab54b35392b51d8a210c3b74ydong    FreePool (mLanguageString);
1243de12ae821ca969dc99665a00ed95b91fa8215429ydong    mLanguageString = NULL;
1244a412ad88e5737735ab54b35392b51d8a210c3b74ydong  }
12455c08e1173703234cc2913757f237ee916087498aklu  //
12465c08e1173703234cc2913757f237ee916087498aklu  //Will leave browser, check any reset required change is applied? if yes, reset system
12475c08e1173703234cc2913757f237ee916087498aklu  //
12485c08e1173703234cc2913757f237ee916087498aklu  SetupResetReminder ();
12495c08e1173703234cc2913757f237ee916087498aklu
1250be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  //
1251be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  // Remove the installed BootMaint HiiPackages when exit.
1252be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  //
1253be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong  FreeBMPackage ();
1254be9304f33f78a645512e76e6d44a69198d5f3c06Eric Dong
12555c08e1173703234cc2913757f237ee916087498akluExit:
12565c08e1173703234cc2913757f237ee916087498aklu  //
12575c08e1173703234cc2913757f237ee916087498aklu  // Automatically load current entry
12585c08e1173703234cc2913757f237ee916087498aklu  // Note: The following lines of code only execute when Auto boot
12595c08e1173703234cc2913757f237ee916087498aklu  // takes affect
12605c08e1173703234cc2913757f237ee916087498aklu  //
1261128efbbcc2e3e8d4ee3c269563a5e2ee461dc3e3darylm  PERF_END (NULL, "BdsTimeOut", "BDS", 0);
12625c08e1173703234cc2913757f237ee916087498aklu}
12632df686c67c7819e01a1487dd703faffef2b59dceczhang
12642df686c67c7819e01a1487dd703faffef2b59dceczhang/**
12652df686c67c7819e01a1487dd703faffef2b59dceczhang  This function will change video resolution and text mode
12662df686c67c7819e01a1487dd703faffef2b59dceczhang  according to defined setup mode or defined boot mode
12672df686c67c7819e01a1487dd703faffef2b59dceczhang
12682df686c67c7819e01a1487dd703faffef2b59dceczhang  @param  IsSetupMode   Indicate mode is changed to setup mode or boot mode.
12692df686c67c7819e01a1487dd703faffef2b59dceczhang
12702df686c67c7819e01a1487dd703faffef2b59dceczhang  @retval  EFI_SUCCESS  Mode is changed successfully.
12712df686c67c7819e01a1487dd703faffef2b59dceczhang  @retval  Others             Mode failed to be changed.
12722df686c67c7819e01a1487dd703faffef2b59dceczhang
12732df686c67c7819e01a1487dd703faffef2b59dceczhang**/
12742df686c67c7819e01a1487dd703faffef2b59dceczhangEFI_STATUS
12752df686c67c7819e01a1487dd703faffef2b59dceczhangEFIAPI
12762df686c67c7819e01a1487dd703faffef2b59dceczhangBdsSetConsoleMode (
12772df686c67c7819e01a1487dd703faffef2b59dceczhang  BOOLEAN  IsSetupMode
12782df686c67c7819e01a1487dd703faffef2b59dceczhang  )
12792df686c67c7819e01a1487dd703faffef2b59dceczhang{
12802df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_GRAPHICS_OUTPUT_PROTOCOL          *GraphicsOutput;
12812df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL       *SimpleTextOut;
12822df686c67c7819e01a1487dd703faffef2b59dceczhang  UINTN                                 SizeOfInfo;
12832df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info;
12842df686c67c7819e01a1487dd703faffef2b59dceczhang  UINT32                                MaxGopMode;
12852df686c67c7819e01a1487dd703faffef2b59dceczhang  UINT32                                MaxTextMode;
12862df686c67c7819e01a1487dd703faffef2b59dceczhang  UINT32                                ModeNumber;
12872df686c67c7819e01a1487dd703faffef2b59dceczhang  UINT32                                NewHorizontalResolution;
12882df686c67c7819e01a1487dd703faffef2b59dceczhang  UINT32                                NewVerticalResolution;
12892df686c67c7819e01a1487dd703faffef2b59dceczhang  UINT32                                NewColumns;
12902df686c67c7819e01a1487dd703faffef2b59dceczhang  UINT32                                NewRows;
12912df686c67c7819e01a1487dd703faffef2b59dceczhang  UINTN                                 HandleCount;
12922df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_HANDLE                            *HandleBuffer;
12932df686c67c7819e01a1487dd703faffef2b59dceczhang  EFI_STATUS                            Status;
12942df686c67c7819e01a1487dd703faffef2b59dceczhang  UINTN                                 Index;
12952df686c67c7819e01a1487dd703faffef2b59dceczhang  UINTN                                 CurrentColumn;
12962df686c67c7819e01a1487dd703faffef2b59dceczhang  UINTN                                 CurrentRow;
12972df686c67c7819e01a1487dd703faffef2b59dceczhang
12982df686c67c7819e01a1487dd703faffef2b59dceczhang  MaxGopMode  = 0;
12992df686c67c7819e01a1487dd703faffef2b59dceczhang  MaxTextMode = 0;
13002df686c67c7819e01a1487dd703faffef2b59dceczhang
13012df686c67c7819e01a1487dd703faffef2b59dceczhang  //
13022df686c67c7819e01a1487dd703faffef2b59dceczhang  // Get current video resolution and text mode
13032df686c67c7819e01a1487dd703faffef2b59dceczhang  //
13042df686c67c7819e01a1487dd703faffef2b59dceczhang  Status = gBS->HandleProtocol (
13052df686c67c7819e01a1487dd703faffef2b59dceczhang                  gST->ConsoleOutHandle,
13062df686c67c7819e01a1487dd703faffef2b59dceczhang                  &gEfiGraphicsOutputProtocolGuid,
13072df686c67c7819e01a1487dd703faffef2b59dceczhang                  (VOID**)&GraphicsOutput
13082df686c67c7819e01a1487dd703faffef2b59dceczhang                  );
13092df686c67c7819e01a1487dd703faffef2b59dceczhang  if (EFI_ERROR (Status)) {
13102df686c67c7819e01a1487dd703faffef2b59dceczhang    GraphicsOutput = NULL;
13112df686c67c7819e01a1487dd703faffef2b59dceczhang  }
13122df686c67c7819e01a1487dd703faffef2b59dceczhang
13132df686c67c7819e01a1487dd703faffef2b59dceczhang  Status = gBS->HandleProtocol (
13142df686c67c7819e01a1487dd703faffef2b59dceczhang                  gST->ConsoleOutHandle,
13152df686c67c7819e01a1487dd703faffef2b59dceczhang                  &gEfiSimpleTextOutProtocolGuid,
13162df686c67c7819e01a1487dd703faffef2b59dceczhang                  (VOID**)&SimpleTextOut
13172df686c67c7819e01a1487dd703faffef2b59dceczhang                  );
13182df686c67c7819e01a1487dd703faffef2b59dceczhang  if (EFI_ERROR (Status)) {
13192df686c67c7819e01a1487dd703faffef2b59dceczhang    SimpleTextOut = NULL;
13202df686c67c7819e01a1487dd703faffef2b59dceczhang  }
13212df686c67c7819e01a1487dd703faffef2b59dceczhang
13222df686c67c7819e01a1487dd703faffef2b59dceczhang  if ((GraphicsOutput == NULL) || (SimpleTextOut == NULL)) {
13232df686c67c7819e01a1487dd703faffef2b59dceczhang    return EFI_UNSUPPORTED;
13242df686c67c7819e01a1487dd703faffef2b59dceczhang  }
13252df686c67c7819e01a1487dd703faffef2b59dceczhang
13262df686c67c7819e01a1487dd703faffef2b59dceczhang  if (IsSetupMode) {
13272df686c67c7819e01a1487dd703faffef2b59dceczhang    //
13282df686c67c7819e01a1487dd703faffef2b59dceczhang    // The requried resolution and text mode is setup mode.
13292df686c67c7819e01a1487dd703faffef2b59dceczhang    //
13302df686c67c7819e01a1487dd703faffef2b59dceczhang    NewHorizontalResolution = mSetupHorizontalResolution;
13312df686c67c7819e01a1487dd703faffef2b59dceczhang    NewVerticalResolution   = mSetupVerticalResolution;
13322df686c67c7819e01a1487dd703faffef2b59dceczhang    NewColumns              = mSetupTextModeColumn;
13332df686c67c7819e01a1487dd703faffef2b59dceczhang    NewRows                 = mSetupTextModeRow;
13342df686c67c7819e01a1487dd703faffef2b59dceczhang  } else {
13352df686c67c7819e01a1487dd703faffef2b59dceczhang    //
13362df686c67c7819e01a1487dd703faffef2b59dceczhang    // The required resolution and text mode is boot mode.
13372df686c67c7819e01a1487dd703faffef2b59dceczhang    //
13382df686c67c7819e01a1487dd703faffef2b59dceczhang    NewHorizontalResolution = mBootHorizontalResolution;
13392df686c67c7819e01a1487dd703faffef2b59dceczhang    NewVerticalResolution   = mBootVerticalResolution;
13402df686c67c7819e01a1487dd703faffef2b59dceczhang    NewColumns              = mBootTextModeColumn;
13412df686c67c7819e01a1487dd703faffef2b59dceczhang    NewRows                 = mBootTextModeRow;
13422df686c67c7819e01a1487dd703faffef2b59dceczhang  }
13432df686c67c7819e01a1487dd703faffef2b59dceczhang
13442df686c67c7819e01a1487dd703faffef2b59dceczhang  if (GraphicsOutput != NULL) {
13452df686c67c7819e01a1487dd703faffef2b59dceczhang    MaxGopMode  = GraphicsOutput->Mode->MaxMode;
13462df686c67c7819e01a1487dd703faffef2b59dceczhang  }
13472df686c67c7819e01a1487dd703faffef2b59dceczhang
13482df686c67c7819e01a1487dd703faffef2b59dceczhang  if (SimpleTextOut != NULL) {
13492df686c67c7819e01a1487dd703faffef2b59dceczhang    MaxTextMode = SimpleTextOut->Mode->MaxMode;
13502df686c67c7819e01a1487dd703faffef2b59dceczhang  }
13512df686c67c7819e01a1487dd703faffef2b59dceczhang
13522df686c67c7819e01a1487dd703faffef2b59dceczhang  //
13532df686c67c7819e01a1487dd703faffef2b59dceczhang  // 1. If current video resolution is same with required video resolution,
13542df686c67c7819e01a1487dd703faffef2b59dceczhang  //    video resolution need not be changed.
13552df686c67c7819e01a1487dd703faffef2b59dceczhang  //    1.1. If current text mode is same with required text mode, text mode need not be changed.
13562df686c67c7819e01a1487dd703faffef2b59dceczhang  //    1.2. If current text mode is different from required text mode, text mode need be changed.
13572df686c67c7819e01a1487dd703faffef2b59dceczhang  // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.
13582df686c67c7819e01a1487dd703faffef2b59dceczhang  //
13592df686c67c7819e01a1487dd703faffef2b59dceczhang  for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
13602df686c67c7819e01a1487dd703faffef2b59dceczhang    Status = GraphicsOutput->QueryMode (
13612df686c67c7819e01a1487dd703faffef2b59dceczhang                       GraphicsOutput,
13622df686c67c7819e01a1487dd703faffef2b59dceczhang                       ModeNumber,
13632df686c67c7819e01a1487dd703faffef2b59dceczhang                       &SizeOfInfo,
13642df686c67c7819e01a1487dd703faffef2b59dceczhang                       &Info
13652df686c67c7819e01a1487dd703faffef2b59dceczhang                       );
13662df686c67c7819e01a1487dd703faffef2b59dceczhang    if (!EFI_ERROR (Status)) {
13672df686c67c7819e01a1487dd703faffef2b59dceczhang      if ((Info->HorizontalResolution == NewHorizontalResolution) &&
13682df686c67c7819e01a1487dd703faffef2b59dceczhang          (Info->VerticalResolution == NewVerticalResolution)) {
13692df686c67c7819e01a1487dd703faffef2b59dceczhang        if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
13702df686c67c7819e01a1487dd703faffef2b59dceczhang            (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {
13712df686c67c7819e01a1487dd703faffef2b59dceczhang          //
13722df686c67c7819e01a1487dd703faffef2b59dceczhang          // Current resolution is same with required resolution, check if text mode need be set
13732df686c67c7819e01a1487dd703faffef2b59dceczhang          //
13742df686c67c7819e01a1487dd703faffef2b59dceczhang          Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
13752df686c67c7819e01a1487dd703faffef2b59dceczhang          ASSERT_EFI_ERROR (Status);
13762df686c67c7819e01a1487dd703faffef2b59dceczhang          if (CurrentColumn == NewColumns && CurrentRow == NewRows) {
13772df686c67c7819e01a1487dd703faffef2b59dceczhang            //
13782df686c67c7819e01a1487dd703faffef2b59dceczhang            // If current text mode is same with required text mode. Do nothing
13792df686c67c7819e01a1487dd703faffef2b59dceczhang            //
13802df686c67c7819e01a1487dd703faffef2b59dceczhang            FreePool (Info);
13812df686c67c7819e01a1487dd703faffef2b59dceczhang            return EFI_SUCCESS;
13822df686c67c7819e01a1487dd703faffef2b59dceczhang          } else {
13832df686c67c7819e01a1487dd703faffef2b59dceczhang            //
13842df686c67c7819e01a1487dd703faffef2b59dceczhang            // If current text mode is different from requried text mode.  Set new video mode
13852df686c67c7819e01a1487dd703faffef2b59dceczhang            //
13862df686c67c7819e01a1487dd703faffef2b59dceczhang            for (Index = 0; Index < MaxTextMode; Index++) {
13872df686c67c7819e01a1487dd703faffef2b59dceczhang              Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
13882df686c67c7819e01a1487dd703faffef2b59dceczhang              if (!EFI_ERROR(Status)) {
13892df686c67c7819e01a1487dd703faffef2b59dceczhang                if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
13902df686c67c7819e01a1487dd703faffef2b59dceczhang                  //
13912df686c67c7819e01a1487dd703faffef2b59dceczhang                  // Required text mode is supported, set it.
13922df686c67c7819e01a1487dd703faffef2b59dceczhang                  //
13932df686c67c7819e01a1487dd703faffef2b59dceczhang                  Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
13942df686c67c7819e01a1487dd703faffef2b59dceczhang                  ASSERT_EFI_ERROR (Status);
13952df686c67c7819e01a1487dd703faffef2b59dceczhang                  //
13962df686c67c7819e01a1487dd703faffef2b59dceczhang                  // Update text mode PCD.
13972df686c67c7819e01a1487dd703faffef2b59dceczhang                  //
139884db9040cc8ba556faec61ad3480c774ca8b984cEric Dong                  Status = PcdSet32S (PcdConOutColumn, mSetupTextModeColumn);
139984db9040cc8ba556faec61ad3480c774ca8b984cEric Dong                  ASSERT_EFI_ERROR (Status);
140084db9040cc8ba556faec61ad3480c774ca8b984cEric Dong                  Status = PcdSet32S (PcdConOutRow, mSetupTextModeRow);
140184db9040cc8ba556faec61ad3480c774ca8b984cEric Dong                  ASSERT_EFI_ERROR (Status);
14022df686c67c7819e01a1487dd703faffef2b59dceczhang                  FreePool (Info);
14032df686c67c7819e01a1487dd703faffef2b59dceczhang                  return EFI_SUCCESS;
14042df686c67c7819e01a1487dd703faffef2b59dceczhang                }
14052df686c67c7819e01a1487dd703faffef2b59dceczhang              }
14062df686c67c7819e01a1487dd703faffef2b59dceczhang            }
14072df686c67c7819e01a1487dd703faffef2b59dceczhang            if (Index == MaxTextMode) {
14082df686c67c7819e01a1487dd703faffef2b59dceczhang              //
14092df686c67c7819e01a1487dd703faffef2b59dceczhang              // If requried text mode is not supported, return error.
14102df686c67c7819e01a1487dd703faffef2b59dceczhang              //
14112df686c67c7819e01a1487dd703faffef2b59dceczhang              FreePool (Info);
14122df686c67c7819e01a1487dd703faffef2b59dceczhang              return EFI_UNSUPPORTED;
14132df686c67c7819e01a1487dd703faffef2b59dceczhang            }
14142df686c67c7819e01a1487dd703faffef2b59dceczhang          }
14152df686c67c7819e01a1487dd703faffef2b59dceczhang        } else {
14162df686c67c7819e01a1487dd703faffef2b59dceczhang          //
14172df686c67c7819e01a1487dd703faffef2b59dceczhang          // If current video resolution is not same with the new one, set new video resolution.
14182df686c67c7819e01a1487dd703faffef2b59dceczhang          // In this case, the driver which produces simple text out need be restarted.
14192df686c67c7819e01a1487dd703faffef2b59dceczhang          //
14202df686c67c7819e01a1487dd703faffef2b59dceczhang          Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
14212df686c67c7819e01a1487dd703faffef2b59dceczhang          if (!EFI_ERROR (Status)) {
14222df686c67c7819e01a1487dd703faffef2b59dceczhang            FreePool (Info);
14232df686c67c7819e01a1487dd703faffef2b59dceczhang            break;
14242df686c67c7819e01a1487dd703faffef2b59dceczhang          }
14252df686c67c7819e01a1487dd703faffef2b59dceczhang        }
14262df686c67c7819e01a1487dd703faffef2b59dceczhang      }
14272df686c67c7819e01a1487dd703faffef2b59dceczhang      FreePool (Info);
14282df686c67c7819e01a1487dd703faffef2b59dceczhang    }
14292df686c67c7819e01a1487dd703faffef2b59dceczhang  }
14302df686c67c7819e01a1487dd703faffef2b59dceczhang
14312df686c67c7819e01a1487dd703faffef2b59dceczhang  if (ModeNumber == MaxGopMode) {
14322df686c67c7819e01a1487dd703faffef2b59dceczhang    //
14332df686c67c7819e01a1487dd703faffef2b59dceczhang    // If the resolution is not supported, return error.
14342df686c67c7819e01a1487dd703faffef2b59dceczhang    //
14352df686c67c7819e01a1487dd703faffef2b59dceczhang    return EFI_UNSUPPORTED;
14362df686c67c7819e01a1487dd703faffef2b59dceczhang  }
14372df686c67c7819e01a1487dd703faffef2b59dceczhang
14382df686c67c7819e01a1487dd703faffef2b59dceczhang  //
14392df686c67c7819e01a1487dd703faffef2b59dceczhang  // Set PCD to Inform GraphicsConsole to change video resolution.
14402df686c67c7819e01a1487dd703faffef2b59dceczhang  // Set PCD to Inform Consplitter to change text mode.
14412df686c67c7819e01a1487dd703faffef2b59dceczhang  //
144284db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  Status = PcdSet32S (PcdVideoHorizontalResolution, NewHorizontalResolution);
144384db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  ASSERT_EFI_ERROR (Status);
144484db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  Status = PcdSet32S (PcdVideoVerticalResolution, NewVerticalResolution);
144584db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  ASSERT_EFI_ERROR (Status);
144684db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  Status = PcdSet32S (PcdConOutColumn, NewColumns);
144784db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  ASSERT_EFI_ERROR (Status);
144884db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  Status = PcdSet32S (PcdConOutRow, NewRows);
144984db9040cc8ba556faec61ad3480c774ca8b984cEric Dong  ASSERT_EFI_ERROR (Status);
14502df686c67c7819e01a1487dd703faffef2b59dceczhang
14512df686c67c7819e01a1487dd703faffef2b59dceczhang
14522df686c67c7819e01a1487dd703faffef2b59dceczhang  //
14532df686c67c7819e01a1487dd703faffef2b59dceczhang  // Video mode is changed, so restart graphics console driver and higher level driver.
14542df686c67c7819e01a1487dd703faffef2b59dceczhang  // Reconnect graphics console driver and higher level driver.
14552df686c67c7819e01a1487dd703faffef2b59dceczhang  // Locate all the handles with GOP protocol and reconnect it.
14562df686c67c7819e01a1487dd703faffef2b59dceczhang  //
14572df686c67c7819e01a1487dd703faffef2b59dceczhang  Status = gBS->LocateHandleBuffer (
14582df686c67c7819e01a1487dd703faffef2b59dceczhang                   ByProtocol,
14592df686c67c7819e01a1487dd703faffef2b59dceczhang                   &gEfiSimpleTextOutProtocolGuid,
14602df686c67c7819e01a1487dd703faffef2b59dceczhang                   NULL,
14612df686c67c7819e01a1487dd703faffef2b59dceczhang                   &HandleCount,
14622df686c67c7819e01a1487dd703faffef2b59dceczhang                   &HandleBuffer
14632df686c67c7819e01a1487dd703faffef2b59dceczhang                   );
14642df686c67c7819e01a1487dd703faffef2b59dceczhang  if (!EFI_ERROR (Status)) {
14652df686c67c7819e01a1487dd703faffef2b59dceczhang    for (Index = 0; Index < HandleCount; Index++) {
14662df686c67c7819e01a1487dd703faffef2b59dceczhang      gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
14672df686c67c7819e01a1487dd703faffef2b59dceczhang    }
14682df686c67c7819e01a1487dd703faffef2b59dceczhang    for (Index = 0; Index < HandleCount; Index++) {
14692df686c67c7819e01a1487dd703faffef2b59dceczhang      gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
14702df686c67c7819e01a1487dd703faffef2b59dceczhang    }
14712df686c67c7819e01a1487dd703faffef2b59dceczhang    if (HandleBuffer != NULL) {
14722df686c67c7819e01a1487dd703faffef2b59dceczhang      FreePool (HandleBuffer);
14732df686c67c7819e01a1487dd703faffef2b59dceczhang    }
14742df686c67c7819e01a1487dd703faffef2b59dceczhang  }
14752df686c67c7819e01a1487dd703faffef2b59dceczhang
14762df686c67c7819e01a1487dd703faffef2b59dceczhang  return EFI_SUCCESS;
14772df686c67c7819e01a1487dd703faffef2b59dceczhang}
14782df686c67c7819e01a1487dd703faffef2b59dceczhang
1479