This library class defines a set of interfaces to customize Ui module\r
\r
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available under\r
-the terms and conditions of the BSD License that accompanies this distribution.\r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
#include <Uefi.h>\r
#define FRONT_PAGE_KEY_CONTINUE 0x1000\r
#define FRONT_PAGE_KEY_RESET 0x1001\r
#define FRONT_PAGE_KEY_LANGUAGE 0x1002\r
+#define FRONT_PAGE_KEY_DRIVER 0x2000\r
\r
typedef struct {\r
EFI_STRING_ID PromptId;\r
CHAR8 *gLanguageString;\r
EFI_STRING_ID *gLanguageToken;\r
UI_HII_DRIVER_INSTANCE *gHiiDriverList;\r
-EFI_HII_HANDLE gHiiHandle;\r
+extern EFI_HII_HANDLE gStringPackHandle;\r
+UINT8 gCurrentLanguageIndex;\r
\r
\r
/**\r
GetNextLanguage (&LangCode, Lang);\r
\r
if (Index == Value->u8) {\r
+ gCurrentLanguageIndex = Value->u8;\r
break;\r
}\r
\r
return FALSE;\r
}\r
\r
+ if (Action == EFI_BROWSER_ACTION_RETRIEVE) {\r
+ if (QuestionId == FRONT_PAGE_KEY_LANGUAGE) {\r
+ Value->u8 = gCurrentLanguageIndex;\r
+ *Status = EFI_SUCCESS;\r
+ } else {\r
+ *Status = EFI_UNSUPPORTED;\r
+ }\r
+ return TRUE;\r
+ }\r
+\r
if (Action != EFI_BROWSER_ACTION_CHANGED) {\r
//\r
// Do nothing for other UEFI Action. Only do call back when data is changed.\r
//\r
*Status = EFI_UNSUPPORTED;\r
+ return TRUE;\r
}\r
\r
if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
if ((Value == NULL) || (ActionRequest == NULL)) {\r
*Status = EFI_INVALID_PARAMETER;\r
+ return TRUE;\r
}\r
\r
*Status = EFI_SUCCESS;\r
Create Select language menu in the front page with oneof opcode.\r
\r
@param[in] HiiHandle The hii handle for the Uiapp driver.\r
- @param[in] QuestionId Question ID\r
@param[in] StartOpCodeHandle The opcode handle to save the new opcode.\r
\r
- @retval EFI_SUCCESS Search the driver success\r
-\r
**/\r
VOID\r
UiCreateLanguageMenu (\r
{\r
CHAR8 *LangCode;\r
CHAR8 *Lang;\r
+ UINTN LangSize;\r
CHAR8 *CurrentLang;\r
UINTN OptionCount;\r
CHAR16 *StringBuffer;\r
}\r
\r
if (EFI_ERROR (Status)) {\r
- StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16));\r
+ LangSize = AsciiStrSize (Lang);\r
+ StringBuffer = AllocatePool (LangSize * sizeof (CHAR16));\r
ASSERT (StringBuffer != NULL);\r
- AsciiStrToUnicodeStr (Lang, StringBuffer);\r
+ AsciiStrToUnicodeStrS (Lang, StringBuffer, LangSize);\r
}\r
\r
ASSERT (StringBuffer != NULL);\r
EFI_IFR_NUMERIC_SIZE_1,\r
(UINT8) OptionCount\r
);\r
+ gCurrentLanguageIndex = (UINT8) OptionCount;\r
} else {\r
HiiCreateOneOfOptionOpCode (\r
OptionsOpCodeHandle,\r
\r
@param HiiHandle The hii handle for the Uiapp driver.\r
@param ClassGuid The class guid for the driver which is the target.\r
+ @param SpecialHandlerFn The pointer to the specail handler function, if any.\r
@param StartOpCodeHandle The opcode handle to save the new opcode.\r
- @param SpecialHandler The pointer to the specail handler function, if any.\r
\r
@retval EFI_SUCCESS Search the driver success\r
\r
\r
String = HiiGetString (HiiHandles[Index], Token, NULL);\r
if (String == NULL) {\r
- String = HiiGetString (gHiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);\r
+ String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);\r
ASSERT (String != NULL);\r
} else if (SpecialHandlerFn != NULL) {\r
//\r
\r
String = HiiGetString (HiiHandles[Index], TokenHelp, NULL);\r
if (String == NULL) {\r
- String = HiiGetString (gHiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);\r
+ String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);\r
ASSERT (String != NULL);\r
}\r
DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL);\r
\r
Count++;\r
if (Count >= CurrentSize) {\r
- DriverListPtr = AllocateCopyPool ((Count + UI_HII_DRIVER_LIST_SIZE) * sizeof (UI_HII_DRIVER_INSTANCE), gHiiDriverList);\r
+ DriverListPtr = ReallocatePool (\r
+ CurrentSize * sizeof (UI_HII_DRIVER_INSTANCE),\r
+ (Count + UI_HII_DRIVER_LIST_SIZE)\r
+ * sizeof (UI_HII_DRIVER_INSTANCE),\r
+ gHiiDriverList\r
+ );\r
ASSERT (DriverListPtr != NULL);\r
- FreePool (gHiiDriverList);\r
gHiiDriverList = DriverListPtr;\r
CurrentSize += UI_HII_DRIVER_LIST_SIZE;\r
}\r
gHiiDriverList[Index].PromptId,\r
gHiiDriverList[Index].HelpId,\r
0,\r
- 0,\r
+ (EFI_QUESTION_ID) (Index + FRONT_PAGE_KEY_DRIVER),\r
0,\r
&gHiiDriverList[Index].FormSetGuid,\r
gHiiDriverList[Index].DevicePathId\r