]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/IfrSupportLib.h
Add FvbServiceLib, HiiLib & IfrSupportLib.h
[mirror_edk2.git] / MdePkg / Include / Library / IfrSupportLib.h
index 9efd88d5b7548cc51c4dd5d02dffa4c78d440e12..3f686bd49c297169dd5ee2eec4f0c9d6e2d68d63 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
-  The file contain all library functions and definitions for IFR opcode creation and \r
-  related Form Browser utility Operations.\r
+  This library contains functions to do IFR opcode creation and utility functions \r
+  to help module to interact with a UEFI Form Browser.\r
 \r
   Copyright (c) 2007 - 2008, Intel Corporation\r
   All rights reserved. This program and the accompanying materials\r
 #define UEFI_LANGUAGE_VARIABLE          L"PlatformLang"\r
 #define UEFI_LANGUAGE_CODES_VARIABLE    L"PlatformLangCodes"\r
 \r
-//\r
-// Limited buffer size recommended by RFC4646 (4.3.  Length Considerations)\r
-// (42 characters plus a NULL terminator)\r
-//\r
-#define RFC_3066_ENTRY_SIZE             (42 + 1)\r
-#define ISO_639_2_ENTRY_SIZE            3\r
-\r
 #define INVALID_VARSTORE_ID             0\r
 \r
 #define QUESTION_FLAGS              (EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY)\r
 #define QUESTION_FLAGS_MASK         (~QUESTION_FLAGS)\r
 \r
-extern EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;\r
-extern EFI_HII_STRING_PROTOCOL   *gIfrLibHiiString;\r
-\r
 #pragma pack(1)\r
 typedef struct {\r
   EFI_STRING_ID       StringToken;\r
@@ -89,7 +79,7 @@ typedef struct {
 \r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
 \r
 **/\r
@@ -103,11 +93,13 @@ CreateEndOpCode (
 /**\r
   Create EFI_IFR_DEFAULT_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  Value                  Value for the default\r
   @param  Type                   Type for the default\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER The type is not valid.\r
 \r
@@ -124,6 +116,8 @@ CreateDefaultOpCode (
 /**\r
   Create EFI_IFR_ACTION_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  QuestionId             Question ID\r
   @param  Prompt                 String ID for Prompt\r
   @param  Help                   String ID for Help\r
@@ -131,7 +125,7 @@ CreateDefaultOpCode (
   @param  QuestionConfig         String ID for configuration\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
 \r
@@ -151,13 +145,15 @@ CreateActionOpCode (
 /**\r
   Create EFI_IFR_SUBTITLE_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  Prompt                 String ID for Prompt\r
   @param  Help                   String ID for Help\r
   @param  Flags                  Subtitle opcode flags\r
   @param  Scope                  Subtitle Scope bit\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   \r
 **/\r
@@ -175,12 +171,14 @@ CreateSubTitleOpCode (
 /**\r
   Create EFI_IFR_TEXT_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  Prompt                 String ID for Prompt\r
   @param  Help                   String ID for Help\r
   @param  TextTwo                String ID for text two\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
 \r
 **/\r
@@ -197,6 +195,8 @@ CreateTextOpCode (
 /**\r
   Create EFI_IFR_REF_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  FormId                 Destination Form ID\r
   @param  Prompt                 String ID for Prompt\r
   @param  Help                   String ID for Help\r
@@ -204,7 +204,7 @@ CreateTextOpCode (
   @param  QuestionId             Question ID\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
 \r
@@ -224,13 +224,16 @@ CreateGotoOpCode (
 /**\r
   Create EFI_IFR_ONE_OF_OPTION_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  OptionCount            The number of options.\r
   @param  OptionsList            The list of Options.\r
   @param  Type                   The data type.\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
+  @retval EFI_INVALID_PARAMETER If OptionCount is not zero but OptionsList is NULL.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -246,6 +249,8 @@ CreateOneOfOptionOpCode (
 /**\r
   Create EFI_IFR_ONE_OF_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  QuestionId             Question ID\r
   @param  VarStoreId             Storage ID\r
   @param  VarOffset              Offset in Storage\r
@@ -257,7 +262,7 @@ CreateOneOfOptionOpCode (
   @param  OptionCount            Number of options in option list\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
 \r
@@ -281,6 +286,8 @@ CreateOneOfOpCode (
 /**\r
   Create EFI_IFR_ORDERED_LIST_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  QuestionId             Question ID\r
   @param  VarStoreId             Storage ID\r
   @param  VarOffset              Offset in Storage\r
@@ -294,7 +301,7 @@ CreateOneOfOpCode (
   @param  OptionCount            Number of options in option list\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
 \r
@@ -312,14 +319,16 @@ CreateOrderedListOpCode (
   IN      UINT8               DataType,\r
   IN      UINT8               MaxContainers,\r
   IN      IFR_OPTION          *OptionsList,\r
-  IN     UINTN                OptionCount,\r
-  IN OUT EFI_HII_UPDATE_DATA  *Data\r
+  IN      UINTN               OptionCount,\r
+  IN OUT  EFI_HII_UPDATE_DATA *Data\r
   )\r
 ;\r
 \r
 /**\r
   Create EFI_IFR_CHECKBOX_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  QuestionId             Question ID\r
   @param  VarStoreId             Storage ID\r
   @param  VarOffset              Offset in Storage\r
@@ -329,7 +338,7 @@ CreateOrderedListOpCode (
   @param  CheckBoxFlags          Flags for checkbox opcode\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
 \r
@@ -351,6 +360,8 @@ CreateCheckBoxOpCode (
 /**\r
   Create EFI_IFR_NUMERIC_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  QuestionId             Question ID\r
   @param  VarStoreId             Storage ID\r
   @param  VarOffset              Offset in Storage\r
@@ -364,7 +375,7 @@ CreateCheckBoxOpCode (
   @param  Default                Numeric default value\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
 \r
@@ -390,6 +401,8 @@ CreateNumericOpCode (
 /**\r
   Create EFI_IFR_STRING_OP opcode.\r
 \r
+  If Data is NULL or Data->Data is NULL, then ASSERT.\r
+\r
   @param  QuestionId             Question ID\r
   @param  VarStoreId             Storage ID\r
   @param  VarOffset              Offset in Storage\r
@@ -401,7 +414,7 @@ CreateNumericOpCode (
   @param  MaxSize                String maximum length\r
   @param  Data                   Destination for the created opcode binary\r
 \r
-  @retval EFI_SUCCESS            Opcode create success\r
+  @retval EFI_SUCCESS            Opcode is created successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.\r
   @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.\r
 \r
@@ -421,6 +434,47 @@ CreateStringOpCode (
   IN OUT EFI_HII_UPDATE_DATA  *Data\r
   )\r
 ;\r
+/**\r
+    Construct <ConfigAltResp> for a buffer storage.\r
+\r
+    @param ConfigRequest           The Config request string. If set to NULL, all the\r
+                                   configurable elements will be extracted from BlockNameArray.\r
+    @param ConfigAltResp           The returned <ConfigAltResp>.\r
+    @param Progress                On return, points to a character in the Request.\r
+    @param Guid                    GUID of the buffer storage.\r
+    @param Name                    Name of the buffer storage.\r
+    @param DriverHandle            The DriverHandle which is used to invoke HiiDatabase\r
+                                   protocol interface NewPackageList().\r
+    @param BufferStorage           Content of the buffer storage.\r
+    @param BufferStorageSize       Length in bytes of the buffer storage.\r
+    @param BlockNameArray          Array generated by VFR compiler.\r
+    @param NumberAltCfg            Number of Default value array generated by VFR compiler.\r
+                                   The sequential input parameters will be number of\r
+                                   AltCfgId and DefaultValueArray pairs. When set to 0,\r
+                                   there will be no <AltResp>.\r
+\r
+    retval EFI_OUT_OF_RESOURCES  Run out of memory resource.\r
+    retval EFI_INVALID_PARAMETER ConfigAltResp is NULL.\r
+    retval EFI_SUCCESS           Operation successful.\r
+\r
+**/\r
+EFI_STATUS\r
+ConstructConfigAltResp (\r
+  IN  EFI_STRING                  ConfigRequest,  OPTIONAL\r
+  OUT EFI_STRING                  *Progress,\r
+  OUT EFI_STRING                  *ConfigAltResp,\r
+  IN  EFI_GUID                    *Guid,\r
+  IN  CHAR16                      *Name,\r
+  IN  EFI_HANDLE                  *DriverHandle,\r
+  IN  VOID                        *BufferStorage,\r
+  IN  UINTN                       BufferStorageSize,\r
+  IN  VOID                        *BlockNameArray, OPTIONAL\r
+  IN  UINTN                       NumberAltCfg,\r
+  ...\r
+//IN  UINT16                      AltCfgId,\r
+//IN  VOID                        *DefaultValueArray,\r
+  )\r
+;\r
 \r
 /**\r
   Converts the unicode character of the string from uppercase to lowercase.\r
@@ -437,18 +491,20 @@ ToLower (
 ;\r
 \r
 /**\r
-  Converts binary buffer to Unicode string in reversed byte order to BufToHexString().\r
+  Converts binary buffer to a Unicode string. The byte buffer is in a reversed byte order \r
+  compared with the byte order defined in BufToHexString().\r
 \r
   @param  Str                    String for output\r
   @param  Buffer                 Binary buffer.\r
   @param  BufferSize             Size of the buffer in bytes.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES   There is no enough available memory space.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-BufferToHexString (\r
+BufInReverseOrderToHexString (\r
   IN OUT CHAR16    *Str,\r
   IN UINT8         *Buffer,\r
   IN UINTN         BufferSize\r
@@ -467,11 +523,13 @@ BufferToHexString (
   @param  Str                    String to be converted from.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval RETURN_BUFFER_TOO_SMALL   The input BufferSize is too small to hold the output. BufferSize\r
+                                   will be updated to the size required for the converstion.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-HexStringToBuffer (\r
+HexStringToBufInReverseOrder (\r
   IN OUT UINT8         *Buffer,\r
   IN OUT UINTN         *BufferSize,\r
   IN CHAR16            *Str\r
@@ -487,11 +545,11 @@ HexStringToBuffer (
   @param StrBufferLen   On input: Length in bytes of buffer to hold the Unicode string.\r
                                     Includes tailing '\0' character.\r
                                     On output:\r
-                                      If return EFI_SUCCESS, containing length of Unicode string buffer.\r
-                                      If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.\r
+                                      containing length of Unicode string buffer when returning EFI_SUCCESS;\r
+                                      containg length of string buffer desired when returning EFI_BUFFER_TOO_SMALL.\r
   @param ConfigString   Binary representation of Unicode String, <string> := (<HexCh>4)+\r
 \r
-  @retval EFI_SUCCESS          Routine success.\r
+  @retval EFI_SUCCESS          Operation completes successfully.\r
   @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.\r
 \r
 **/\r
@@ -517,7 +575,7 @@ ConfigStringToUnicode (
                                       If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.\r
   @param  UnicodeString  Original Unicode string.\r
 \r
-  @retval EFI_SUCCESS           Routine success.\r
+  @retval EFI_SUCCESS           Operation completes successfully.\r
   @retval EFI_BUFFER_TOO_SMALL  The string buffer is too small.\r
 \r
 **/\r
@@ -545,7 +603,7 @@ UnicodeToConfigString (
   @param  DriverHandle           Driver handle which contains the routing\r
                                  information: PATH.\r
 \r
-  @retval EFI_SUCCESS            Routine success.\r
+  @retval EFI_SUCCESS            Operation completes successfully.\r
   @retval EFI_BUFFER_TOO_SMALL   The ConfigHdr string buffer is too small.\r
 \r
 **/\r
@@ -554,13 +612,32 @@ EFIAPI
 ConstructConfigHdr (\r
   IN OUT CHAR16                *ConfigHdr,\r
   IN OUT UINTN                 *StrBufferLen,\r
-  IN EFI_GUID                  *Guid,\r
+  IN CONST EFI_GUID            *Guid,\r
   IN CHAR16                    *Name, OPTIONAL\r
   IN EFI_HANDLE                *DriverHandle\r
   )\r
 \r
 ;\r
 \r
+/**\r
+  Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.\r
+\r
+  @param ConfigString  Either <ConfigRequest> or <ConfigResp>.\r
+  @param StorageGuid   GUID of the storage.\r
+  @param StorageName   Name of the stoarge.\r
+\r
+  @retval TRUE         Routing information is correct in ConfigString.\r
+  @retval FALSE        Routing information is incorrect in ConfigString.\r
+\r
+**/\r
+BOOLEAN\r
+IsConfigHdrMatch (\r
+  IN EFI_STRING                ConfigString,\r
+  IN EFI_GUID                  *StorageGuid, OPTIONAL\r
+  IN CHAR16                    *StorageName  OPTIONAL\r
+  )\r
+;\r
+\r
 /**\r
   Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.\r
 \r
@@ -576,8 +653,8 @@ BOOLEAN
 EFIAPI\r
 FindBlockName (\r
   IN OUT CHAR16                *String,\r
-  UINTN                        Offset,\r
-  UINTN                        Width\r
+  IN UINTN                     Offset,\r
+  IN UINTN                     Width\r
   )\r
 ;\r
 \r
@@ -594,17 +671,17 @@ FindBlockName (
                                  desired.\r
   @param  Buffer                 Buffer to hold retrived data.\r
 \r
-  @retval EFI_SUCCESS            Routine success.\r
+  @retval EFI_SUCCESS            Operation completes successfully.\r
   @retval EFI_BUFFER_TOO_SMALL   The intput buffer is too small.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 GetBrowserData (\r
-  EFI_GUID                   *VariableGuid, OPTIONAL\r
-  CHAR16                     *VariableName, OPTIONAL\r
-  UINTN                      *BufferSize,\r
-  UINT8                      *Buffer\r
+  IN CONST EFI_GUID          *VariableGuid, OPTIONAL\r
+  IN CONST CHAR16            *VariableName, OPTIONAL\r
+  IN OUT UINTN               *BufferSize,\r
+  IN OUT UINT8               *Buffer\r
   )\r
 ;\r
 \r
@@ -623,18 +700,18 @@ GetBrowserData (
                                  Browser. <RequestElement> ::=\r
                                  &OFFSET=<Number>&WIDTH=<Number>*\r
 \r
-  @retval EFI_SUCCESS            Routine success.\r
+  @retval EFI_SUCCESS            Operation completes successfully.\r
   @retval Other                  Updating Browser uncommitted data failed.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 SetBrowserData (\r
-  EFI_GUID                   *VariableGuid, OPTIONAL\r
-  CHAR16                     *VariableName, OPTIONAL\r
-  UINTN                      BufferSize,\r
-  UINT8                      *Buffer,\r
-  CHAR16                     *RequestElement  OPTIONAL\r
+  IN CONST EFI_GUID          *VariableGuid, OPTIONAL\r
+  IN CONST CHAR16            *VariableName, OPTIONAL\r
+  IN UINTN                   BufferSize,\r
+  IN CONST UINT8             *Buffer,\r
+  IN CONST CHAR16            *RequestElement  OPTIONAL\r
   )\r
 ;\r
 \r
@@ -662,4 +739,27 @@ IfrLibCreatePopUp (
   )\r
 ;\r
 \r
+/**\r
+  Draw a dialog and return the selected key using Variable Argument List.\r
+\r
+  @param  NumberOfLines          The number of lines for the dialog box\r
+  @param  KeyValue               The EFI_KEY value returned if HotKey is TRUE..\r
+  @param  Args                   VA_LIST marker for the variable argument list.\r
+                                 A series of (quantity == NumberOfLines - 1) text\r
+                                 strings which will be used to construct the dialog\r
+                                 box\r
+\r
+  @retval EFI_SUCCESS            Displayed dialog and received user interaction\r
+  @retval EFI_INVALID_PARAMETER  One of the parameters was invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IfrLibCreatePopUp2 (\r
+  IN  UINTN                       NumberOfLines,\r
+  OUT EFI_INPUT_KEY               *KeyValue,\r
+  IN  VA_LIST                     Args\r
+  )\r
+;\r
+\r
 #endif\r