Home | History | Annotate | Download | only in UefiEfiIfrSupportLib
      1 /*++
      2 
      3 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
      4 This program and the accompanying materials
      5 are licensed and made available under the terms and conditions of the BSD License
      6 which accompanies this distribution.  The full text of the license may be found at
      7 http://opensource.org/licenses/bsd-license.php
      8 
      9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 
     12 Module Name:
     13 
     14   UefiIfrLibrary.h
     15 
     16 Abstract:
     17 
     18   The file contain all library function for Ifr Operations.
     19 
     20 --*/
     21 
     22 #ifndef _IFRLIBRARY_H
     23 #define _IFRLIBRARY_H
     24 
     25 #include "Tiano.h"
     26 #include "EfiDriverLib.h"
     27 #include "TianoHii.h"
     28 
     29 #include EFI_PROTOCOL_DEFINITION (HiiFont)
     30 #include EFI_PROTOCOL_DEFINITION (HiiImage)
     31 #include EFI_PROTOCOL_DEFINITION (HiiString)
     32 #include EFI_PROTOCOL_DEFINITION (HiiDatabase)
     33 #include EFI_PROTOCOL_DEFINITION (HiiConfigRouting)
     34 #include EFI_PROTOCOL_DEFINITION (HiiConfigAccess)
     35 #include EFI_PROTOCOL_DEFINITION (FormBrowser2)
     36 #include EFI_PROTOCOL_DEFINITION (SimpleTextOut)
     37 
     38 #include EFI_GUID_DEFINITION (GlobalVariable)
     39 
     40 #define IFR_LIB_DEFAULT_STRING_SIZE     0x200
     41 
     42 //
     43 // The architectural variable "Lang" and "LangCodes" are deprecated in UEFI
     44 // specification. While, UEFI specification also states that these deprecated
     45 // variables may be provided for backwards compatibility.
     46 // If "LANG_SUPPORT" is defined, "Lang" and "LangCodes" will be produced;
     47 // If "LANG_SUPPORT" is undefined, "Lang" and "LangCodes" will not be produced.
     48 //
     49 #define LANG_SUPPORT
     50 
     51 #define EFI_LANGUAGE_VARIABLE           L"Lang"
     52 #define EFI_LANGUAGE_CODES_VARIABLE     L"LangCodes"
     53 
     54 #define UEFI_LANGUAGE_VARIABLE          L"PlatformLang"
     55 #define UEFI_LANGUAGE_CODES_VARIABLE    L"PlatformLangCodes"
     56 
     57 //
     58 // Limited buffer size recommended by RFC4646 (4.3.  Length Considerations)
     59 // (42 characters plus a NULL terminator)
     60 //
     61 #define RFC_3066_ENTRY_SIZE             (42 + 1)
     62 #define ISO_639_2_ENTRY_SIZE            3
     63 
     64 #define INVALID_VARSTORE_ID             0
     65 
     66 #define QUESTION_FLAGS              (EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY)
     67 #define QUESTION_FLAGS_MASK         (~QUESTION_FLAGS)
     68 
     69 extern EFI_GUID                  mIfrVendorGuid;
     70 extern EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
     71 extern EFI_HII_STRING_PROTOCOL   *gIfrLibHiiString;
     72 
     73 #pragma pack(1)
     74 typedef struct {
     75   EFI_STRING_ID       StringToken;
     76   EFI_IFR_TYPE_VALUE  Value;
     77   UINT8               Flags;
     78 } IFR_OPTION;
     79 #pragma pack()
     80 
     81 #pragma pack(1)
     82 typedef struct {
     83   VENDOR_DEVICE_PATH             VendorDevicePath;
     84   UINT32                         Reserved;
     85   UINT64                         UniqueId;
     86 } HII_VENDOR_DEVICE_PATH_NODE;
     87 #pragma pack()
     88 
     89 typedef struct {
     90   HII_VENDOR_DEVICE_PATH_NODE    Node;
     91   EFI_DEVICE_PATH_PROTOCOL       End;
     92 } HII_VENDOR_DEVICE_PATH;
     93 
     94 typedef struct {
     95   //
     96   // Buffer size allocated for Data.
     97   //
     98   UINT32                BufferSize;
     99 
    100   //
    101   // Offset in Data to append the newly created opcode binary.
    102   // It will be adjusted automatically in Create***OpCode(), and should be
    103   // initialized to 0 before invocation of a serial of Create***OpCode()
    104   //
    105   UINT32                Offset;
    106 
    107   //
    108   // The destination buffer for created op-codes
    109   //
    110   UINT8                 *Data;
    111 } EFI_HII_UPDATE_DATA;
    112 
    113 VOID
    114 LocateHiiProtocols (
    115   VOID
    116   )
    117 /*++
    118 
    119 Routine Description:
    120   This function locate Hii relative protocols for later usage.
    121 
    122 Arguments:
    123   None.
    124 
    125 Returns:
    126   None.
    127 
    128 --*/
    129 ;
    130 
    131 //
    132 // Exported Library functions
    133 //
    134 EFI_STATUS
    135 CreateEndOpCode (
    136   IN OUT EFI_HII_UPDATE_DATA *Data
    137   )
    138 /*++
    139 
    140 Routine Description:
    141   Create EFI_IFR_END_OP opcode.
    142 
    143 Arguments:
    144   Data            - Destination for the created opcode binary
    145 
    146 Returns:
    147   EFI_SUCCESS     - Opcode create success
    148 
    149 --*/
    150 ;
    151 
    152 EFI_STATUS
    153 CreateDefaultOpCode (
    154   IN     EFI_IFR_TYPE_VALUE  *Value,
    155   IN     UINT8               Type,
    156   IN OUT EFI_HII_UPDATE_DATA *Data
    157   )
    158 /*++
    159 
    160 Routine Description:
    161   Create EFI_IFR_DEFAULT_OP opcode.
    162 
    163 Arguments:
    164   Value           - Value for the default
    165   Type            - Type for the default
    166   Data            - Destination for the created opcode binary
    167 
    168 Returns:
    169   EFI_SUCCESS     - Opcode create success
    170 
    171 --*/
    172 ;
    173 
    174 EFI_STATUS
    175 CreateActionOpCode (
    176   IN     EFI_QUESTION_ID      QuestionId,
    177   IN     EFI_STRING_ID        Prompt,
    178   IN     EFI_STRING_ID        Help,
    179   IN     UINT8                QuestionFlags,
    180   IN     EFI_STRING_ID        QuestionConfig,
    181   IN OUT EFI_HII_UPDATE_DATA  *Data
    182   )
    183 /*++
    184 
    185 Routine Description:
    186   Create EFI_IFR_ACTION_OP opcode.
    187 
    188 Arguments:
    189   QuestionId      - Question ID
    190   Prompt          - String ID for Prompt
    191   Help            - String ID for Help
    192   QuestionFlags   - Flags in Question Header
    193   QuestionConfig  - String ID for configuration
    194   Data            - Destination for the created opcode binary
    195 
    196 Returns:
    197   EFI_SUCCESS     - Opcode create success
    198 
    199 --*/
    200 ;
    201 
    202 EFI_STATUS
    203 CreateSubTitleOpCode (
    204   IN      EFI_STRING_ID       Prompt,
    205   IN      EFI_STRING_ID       Help,
    206   IN      UINT8               Flags,
    207   IN      UINT8               Scope,
    208   IN OUT EFI_HII_UPDATE_DATA  *Data
    209   )
    210 /*++
    211 
    212 Routine Description:
    213   Create EFI_IFR_SUBTITLE_OP opcode.
    214 
    215 Arguments:
    216   Prompt          - String ID for Prompt
    217   Help            - String ID for Help
    218   Flags           - Subtitle opcode flags
    219   Scope           - Subtitle Scope bit
    220   Data            - Destination for the created opcode binary
    221 
    222 Returns:
    223   EFI_SUCCESS     - Opcode create success
    224 
    225 --*/
    226 ;
    227 
    228 EFI_STATUS
    229 CreateTextOpCode (
    230   IN      EFI_STRING_ID       Prompt,
    231   IN      EFI_STRING_ID       Help,
    232   IN      EFI_STRING_ID       TextTwo,
    233   IN OUT  EFI_HII_UPDATE_DATA *Data
    234   )
    235 /*++
    236 
    237 Routine Description:
    238   Create EFI_IFR_TEXT_OP opcode.
    239 
    240 Arguments:
    241   Prompt          - String ID for Prompt
    242   Help            - String ID for Help
    243   TextTwo         - String ID for text two
    244   Data            - Destination for the created opcode binary
    245 
    246 Returns:
    247   EFI_SUCCESS     - Opcode create success
    248 
    249 --*/
    250 ;
    251 
    252 EFI_STATUS
    253 CreateGotoOpCode (
    254   IN      EFI_FORM_ID         FormId,
    255   IN      EFI_STRING_ID       Prompt,
    256   IN      EFI_STRING_ID       Help,
    257   IN      UINT8               QuestionFlags,
    258   IN      EFI_QUESTION_ID     QuestionId,
    259   IN OUT  EFI_HII_UPDATE_DATA *Data
    260   )
    261 /*++
    262 
    263 Routine Description:
    264   Create EFI_IFR_REF_OP opcode.
    265 
    266 Arguments:
    267   FormId          - Destination Form ID
    268   Prompt          - String ID for Prompt
    269   Help            - String ID for Help
    270   QuestionFlags   - Flags in Question Header
    271   QuestionId      - Question ID
    272   Data            - Destination for the created opcode binary
    273 
    274 Returns:
    275   EFI_SUCCESS     - Opcode create success
    276 
    277 --*/
    278 ;
    279 
    280 EFI_STATUS
    281 CreateOneOfOptionOpCode (
    282   IN     UINTN                OptionCount,
    283   IN     IFR_OPTION           *OptionsList,
    284   IN     UINT8                Type,
    285   IN OUT EFI_HII_UPDATE_DATA  *Data
    286   )
    287 ;
    288 
    289 EFI_STATUS
    290 CreateOneOfOpCode (
    291   IN     EFI_QUESTION_ID      QuestionId,
    292   IN     EFI_VARSTORE_ID      VarStoreId,
    293   IN     UINT16               VarOffset,
    294   IN     EFI_STRING_ID        Prompt,
    295   IN     EFI_STRING_ID        Help,
    296   IN     UINT8                QuestionFlags,
    297   IN     UINT8                OneOfFlags,
    298   IN     IFR_OPTION           *OptionsList,
    299   IN     UINTN                OptionCount,
    300   IN OUT EFI_HII_UPDATE_DATA  *Data
    301   )
    302 /*++
    303 
    304 Routine Description:
    305   Create EFI_IFR_ONE_OF_OP opcode.
    306 
    307 Arguments:
    308   QuestionId      - Question ID
    309   VarStoreId      - Storage ID
    310   VarOffset       - Offset in Storage
    311   Prompt          - String ID for Prompt
    312   Help            - String ID for Help
    313   QuestionFlags   - Flags in Question Header
    314   OneOfFlags      - Flags for oneof opcode
    315   OptionsList     - List of options
    316   OptionCount     - Number of options in option list
    317   Data            - Destination for the created opcode binary
    318 
    319 Returns:
    320   EFI_SUCCESS     - Opcode create success
    321 
    322 --*/
    323 ;
    324 
    325 EFI_STATUS
    326 CreateOrderedListOpCode (
    327   IN      EFI_QUESTION_ID     QuestionId,
    328   IN      EFI_VARSTORE_ID     VarStoreId,
    329   IN      UINT16              VarOffset,
    330   IN      EFI_STRING_ID       Prompt,
    331   IN      EFI_STRING_ID       Help,
    332   IN      UINT8               QuestionFlags,
    333   IN      UINT8               Flags,
    334   IN      UINT8               DataType,
    335   IN      UINT8               MaxContainers,
    336   IN      IFR_OPTION          *OptionsList,
    337   IN     UINTN                OptionCount,
    338   IN OUT EFI_HII_UPDATE_DATA  *Data
    339   )
    340 /*++
    341 
    342 Routine Description:
    343   Create EFI_IFR_ORDERED_LIST_OP opcode.
    344 
    345 Arguments:
    346   QuestionId      - Question ID
    347   VarStoreId      - Storage ID
    348   VarOffset       - Offset in Storage
    349   Prompt          - String ID for Prompt
    350   Help            - String ID for Help
    351   QuestionFlags   - Flags in Question Header
    352   Flags           - Flags for ordered list opcode
    353   DataType        - Type for option value
    354   MaxContainers   - Maximum count for options in this ordered list
    355   OptionsList     - List of options
    356   OptionCount     - Number of options in option list
    357   Data            - Destination for the created opcode binary
    358 
    359 Returns:
    360   EFI_SUCCESS     - Opcode create success
    361 
    362 --*/
    363 ;
    364 
    365 EFI_STATUS
    366 CreateCheckBoxOpCode (
    367   IN      EFI_QUESTION_ID     QuestionId,
    368   IN      EFI_VARSTORE_ID     VarStoreId,
    369   IN      UINT16              VarOffset,
    370   IN      EFI_STRING_ID       Prompt,
    371   IN      EFI_STRING_ID       Help,
    372   IN      UINT8               QuestionFlags,
    373   IN      UINT8               CheckBoxFlags,
    374   IN OUT EFI_HII_UPDATE_DATA  *Data
    375   )
    376 /*++
    377 
    378 Routine Description:
    379   Create EFI_IFR_CHECKBOX_OP opcode.
    380 
    381 Arguments:
    382   QuestionId      - Question ID
    383   VarStoreId      - Storage ID
    384   VarOffset       - Offset in Storage
    385   Prompt          - String ID for Prompt
    386   Help            - String ID for Help
    387   QuestionFlags   - Flags in Question Header
    388   CheckBoxFlags   - Flags for checkbox opcode
    389   Data            - Destination for the created opcode binary
    390 
    391 Returns:
    392   EFI_SUCCESS     - Opcode create success
    393 
    394 --*/
    395 ;
    396 
    397 EFI_STATUS
    398 CreateNumericOpCode (
    399   IN     EFI_QUESTION_ID     QuestionId,
    400   IN     EFI_VARSTORE_ID     VarStoreId,
    401   IN     UINT16              VarOffset,
    402   IN     EFI_STRING_ID       Prompt,
    403   IN     EFI_STRING_ID       Help,
    404   IN     UINT8               QuestionFlags,
    405   IN     UINT8               NumericFlags,
    406   IN     UINT64              Minimum,
    407   IN     UINT64              Maximum,
    408   IN     UINT64              Step,
    409   IN     UINT64              Default,
    410   IN OUT EFI_HII_UPDATE_DATA *Data
    411   )
    412 /*++
    413 
    414 Routine Description:
    415   Create EFI_IFR_NUMERIC_OP opcode.
    416 
    417 Arguments:
    418   QuestionId      - Question ID
    419   VarStoreId      - Storage ID
    420   VarOffset       - Offset in Storage
    421   Prompt          - String ID for Prompt
    422   Help            - String ID for Help
    423   QuestionFlags   - Flags in Question Header
    424   NumericFlags    - Flags for numeric opcode
    425   Minimum         - Numeric minimum value
    426   Maximum         - Numeric maximum value
    427   Step            - Numeric step for edit
    428   Default         - Numeric default value
    429   Data            - Destination for the created opcode binary
    430 
    431 Returns:
    432   EFI_SUCCESS     - Opcode create success
    433 
    434 --*/
    435 ;
    436 
    437 EFI_STATUS
    438 CreateStringOpCode (
    439   IN      EFI_QUESTION_ID     QuestionId,
    440   IN      EFI_VARSTORE_ID     VarStoreId,
    441   IN      UINT16              VarOffset,
    442   IN      EFI_STRING_ID       Prompt,
    443   IN      EFI_STRING_ID       Help,
    444   IN      UINT8               QuestionFlags,
    445   IN      UINT8               StringFlags,
    446   IN      UINT8               MinSize,
    447   IN      UINT8               MaxSize,
    448   IN OUT EFI_HII_UPDATE_DATA  *Data
    449   )
    450 /*++
    451 
    452 Routine Description:
    453   Create EFI_IFR_STRING_OP opcode.
    454 
    455 Arguments:
    456   QuestionId      - Question ID
    457   VarStoreId      - Storage ID
    458   VarOffset       - Offset in Storage
    459   Prompt          - String ID for Prompt
    460   Help            - String ID for Help
    461   QuestionFlags   - Flags in Question Header
    462   StringFlags     - Flags for string opcode
    463   MinSize         - String minimum length
    464   MaxSize         - String maximum length
    465   Data            - Destination for the created opcode binary
    466 
    467 Returns:
    468   EFI_SUCCESS     - Opcode create success
    469 
    470 --*/
    471 ;
    472 
    473 EFI_STATUS
    474 CreateBannerOpCode (
    475   IN      EFI_STRING_ID       Title,
    476   IN      UINT16              LineNumber,
    477   IN      UINT8               Alignment,
    478   IN OUT  EFI_HII_UPDATE_DATA *Data
    479   )
    480 /*++
    481 
    482 Routine Description:
    483   Create GUIDed opcode for banner.
    484 
    485 Arguments:
    486   Title           - String ID for title
    487   LineNumber      - Line number for this banner
    488   Alignment       - Alignment for this banner, left, center or right
    489   Data            - Destination for the created opcode binary
    490 
    491 Returns:
    492   EFI_SUCCESS     - Opcode create success
    493 
    494 --*/
    495 ;
    496 
    497 EFI_HII_PACKAGE_LIST_HEADER *
    498 PreparePackageList (
    499   IN UINTN                    NumberOfPackages,
    500   IN EFI_GUID                 *GuidId,
    501   ...
    502   )
    503 /*++
    504 
    505 Routine Description:
    506   Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
    507 
    508 Arguments:
    509   NumberOfPackages  -  Number of packages.
    510   GuidId            -  Package GUID.
    511 
    512 Returns:
    513   Pointer of EFI_HII_PACKAGE_LIST_HEADER.
    514 
    515 --*/
    516 ;
    517 
    518 EFI_STATUS
    519 CreateHiiDriverHandle (
    520   OUT EFI_HANDLE               *DriverHandle
    521   )
    522 /*++
    523 
    524 Routine Description:
    525   The HII driver handle passed in for HiiDatabase.NewPackageList() requires
    526   that there should be DevicePath Protocol installed on it.
    527   This routine create a virtual Driver Handle by installing a vendor device
    528   path on it, so as to use it to invoke HiiDatabase.NewPackageList().
    529 
    530 Arguments:
    531   DriverHandle - Handle to be returned
    532 
    533 Returns:
    534   EFI_SUCCESS          - Handle destroy success.
    535   EFI_OUT_OF_RESOURCES - Not enough memory.
    536 
    537 --*/
    538 ;
    539 
    540 EFI_STATUS
    541 DestroyHiiDriverHandle (
    542   IN EFI_HANDLE                 DriverHandle
    543   )
    544 /*++
    545 
    546 Routine Description:
    547   Destroy the Driver Handle created by CreateHiiDriverHandle().
    548 
    549 Arguments:
    550   DriverHandle - Handle returned by CreateHiiDriverHandle()
    551 
    552 Returns:
    553   EFI_SUCCESS - Handle destroy success.
    554   other       - Handle destroy fail.
    555 
    556 --*/
    557 ;
    558 
    559 EFI_HII_HANDLE
    560 DevicePathToHiiHandle (
    561   IN EFI_HII_DATABASE_PROTOCOL  *HiiDatabase,
    562   IN EFI_DEVICE_PATH_PROTOCOL   *DevicePath
    563   )
    564 /*++
    565 
    566 Routine Description:
    567   Find HII Handle associated with given Device Path.
    568 
    569 Arguments:
    570   HiiDatabase - Point to EFI_HII_DATABASE_PROTOCOL instance.
    571   DevicePath  - Device Path associated with the HII package list handle.
    572 
    573 Returns:
    574   Handle - HII package list Handle associated with the Device Path.
    575   NULL   - Hii Package list handle is not found.
    576 
    577 --*/
    578 ;
    579 
    580 EFI_STATUS
    581 ExtractDefault(
    582   IN VOID                         *Buffer,
    583   IN UINTN                        *BufferSize,
    584   UINTN                           Number,
    585   ...
    586   )
    587 /*++
    588 
    589   Routine Description:
    590     Configure the buffer accrording to ConfigBody strings.
    591 
    592   Arguments:
    593     DefaultId             - the ID of default.
    594     Buffer                - the start address of buffer.
    595     BufferSize            - the size of buffer.
    596     Number                - the number of the strings.
    597 
    598   Returns:
    599     EFI_BUFFER_TOO_SMALL  - the BufferSize is too small to operate.
    600     EFI_INVALID_PARAMETER - Buffer is NULL or BufferSize is 0.
    601     EFI_SUCCESS           - Operation successful.
    602 
    603 --*/
    604 ;
    605 
    606 EFI_STATUS
    607 ConstructConfigAltResp (
    608   IN  EFI_STRING                  ConfigRequest,  OPTIONAL
    609   OUT EFI_STRING                  *Progress,
    610   OUT EFI_STRING                  *ConfigAltResp,
    611   IN  EFI_GUID                    *Guid,
    612   IN  CHAR16                      *Name,
    613   IN  EFI_HANDLE                  *DriverHandle,
    614   IN  VOID                        *BufferStorage,
    615   IN  UINTN                       BufferStorageSize,
    616   IN  VOID                        *BlockNameArray, OPTIONAL
    617   IN  UINTN                       NumberAltCfg,
    618   ...
    619 //IN  UINT16                      AltCfgId,
    620 //IN  VOID                        *DefaultValueArray,
    621   )
    622 /*++
    623 
    624   Routine Description:
    625 
    626   Construct <ConfigAltResp> for a buffer storage.
    627 
    628   Arguments:
    629     ConfigRequest         - The Config request string. If set to NULL, all the
    630                             configurable elements will be extracted from BlockNameArray.
    631     ConfigAltResp         - The returned <ConfigAltResp>.
    632     Progress              - On return, points to a character in the Request.
    633     Guid                  - GUID of the buffer storage.
    634     Name                  - Name of the buffer storage.
    635     DriverHandle          - The DriverHandle which is used to invoke HiiDatabase
    636                             protocol interface NewPackageList().
    637     BufferStorage         - Content of the buffer storage.
    638     BufferStorageSize     - Length in bytes of the buffer storage.
    639     BlockNameArray        - Array generated by VFR compiler.
    640     NumberAltCfg          - Number of Default value array generated by VFR compiler.
    641                             The sequential input parameters will be number of
    642                             AltCfgId and DefaultValueArray pairs. When set to 0,
    643                             there will be no <AltResp>.
    644 
    645   Returns:
    646     EFI_OUT_OF_RESOURCES  - Run out of memory resource.
    647     EFI_INVALID_PARAMETER - ConfigAltResp is NULL.
    648     EFI_SUCCESS           - Operation successful.
    649 
    650 --*/
    651 ;
    652 
    653 EFI_STATUS
    654 ExtractGuidFromHiiHandle (
    655   IN      EFI_HII_HANDLE      Handle,
    656   OUT     EFI_GUID            *Guid
    657   )
    658 /*++
    659 
    660 Routine Description:
    661   Extract Hii package list GUID for given HII handle.
    662 
    663 Arguments:
    664   HiiHandle     - Hii handle
    665   Guid          - Package list GUID
    666 
    667 Returns:
    668   EFI_SUCCESS   - Successfully extract GUID from Hii database.
    669 
    670 --*/
    671 ;
    672 
    673 EFI_STATUS
    674 ExtractClassFromHiiHandle (
    675   IN      EFI_HII_HANDLE      Handle,
    676   OUT     UINT16              *Class,
    677   OUT     EFI_STRING_ID       *FormSetTitle,
    678   OUT     EFI_STRING_ID       *FormSetHelp
    679   )
    680 /*++
    681 
    682 Routine Description:
    683   Extract formset class for given HII handle.
    684 
    685 Arguments:
    686   HiiHandle       - Hii handle
    687   Class           - Class of the formset
    688   FormSetTitle    - Formset title string
    689   FormSetHelp     - Formset help string
    690 
    691 Returns:
    692   EFI_SUCCESS     - Successfully extract Class for specified Hii handle.
    693 
    694 --*/
    695 ;
    696 
    697 EFI_STATUS
    698 ExtractClassGuidFromHiiHandle (
    699   IN      EFI_HII_HANDLE      Handle,
    700   OUT     UINT8               *NumberOfClassGuid,
    701   OUT     EFI_GUID            **ClassGuid,
    702   OUT     EFI_STRING_ID       *FormSetTitle,
    703   OUT     EFI_STRING_ID       *FormSetHelp
    704   )
    705 /*++
    706 
    707 Routine Description:
    708   Extract formset ClassGuid for given HII handle.
    709 
    710 Arguments:
    711   HiiHandle         - Hii handle
    712   NumberOfClassGuid - Number of ClassGuid
    713   ClassGuid         - Pointer to callee allocated buffer, an array of ClassGuid
    714   FormSetTitle      - Formset title string
    715   FormSetHelp       - Formset help string
    716 
    717 Returns:
    718   EFI_SUCCESS     - Successfully extract Class for specified Hii handle.
    719 
    720 --*/
    721 ;
    722 
    723 VOID
    724 ToLower (
    725   IN OUT CHAR16    *Str
    726   )
    727 /*++
    728 
    729 Routine Description:
    730   Converts the unicode character from uppercase to lowercase.
    731 
    732 Arguments:
    733   Str        -  String to be converted
    734 
    735 Returns:
    736 
    737 --*/
    738 ;
    739 
    740 EFI_STATUS
    741 BufferToHexString (
    742   IN OUT CHAR16    *Str,
    743   IN UINT8         *Buffer,
    744   IN UINTN         BufferSize
    745   )
    746 /*++
    747 
    748 Routine Description:
    749   Converts binary buffer to Unicode string in reversed byte order to BufToHexString().
    750 
    751 Arguments:
    752   Str        -  String for output
    753   Buffer     -  Binary buffer.
    754   BufferSize -  Size of the buffer in bytes.
    755 
    756 Returns:
    757   EFI_SUCCESS    -  The function completed successfully.
    758 
    759 --*/
    760 ;
    761 
    762 EFI_STATUS
    763 HexStringToBuffer (
    764   IN OUT UINT8         *Buffer,
    765   IN OUT UINTN         *BufferSize,
    766   IN CHAR16            *Str
    767   )
    768 /*++
    769 
    770 Routine Description:
    771   Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().
    772 
    773 Arguments:
    774     Buffer     - Pointer to buffer that receives the data.
    775     BufferSize - Length in bytes of the buffer to hold converted data.
    776                  If routine return with EFI_SUCCESS, containing length of converted data.
    777                  If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
    778     Str        - String to be converted from.
    779 
    780 Returns:
    781   EFI_SUCCESS    -  The function completed successfully.
    782 
    783 --*/
    784 ;
    785 
    786 EFI_STATUS
    787 ConfigStringToUnicode (
    788   IN OUT CHAR16                *UnicodeString,
    789   IN OUT UINTN                 *StrBufferLen,
    790   IN CHAR16                    *ConfigString
    791   )
    792 /*++
    793 
    794 Routine Description:
    795   Convert binary representation Config string (e.g. "0041004200430044") to the
    796   original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
    797   "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
    798 
    799 Arguments:
    800   UnicodeString - Original Unicode string.
    801   StrBufferLen  - On input: Length in bytes of buffer to hold the Unicode string.
    802                   Includes tailing '\0' character.
    803                   On output:
    804                     If return EFI_SUCCESS, containing length of Unicode string buffer.
    805                     If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
    806   ConfigString  - Binary representation of Unicode String, <string> := (<HexCh>4)+
    807 
    808 Returns:
    809   EFI_SUCCESS          - Routine success.
    810   EFI_BUFFER_TOO_SMALL - The string buffer is too small.
    811 
    812 --*/
    813 ;
    814 
    815 EFI_STATUS
    816 UnicodeToConfigString (
    817   IN OUT CHAR16                *ConfigString,
    818   IN OUT UINTN                 *StrBufferLen,
    819   IN CHAR16                    *UnicodeString
    820   )
    821 /*++
    822 
    823 Routine Description:
    824   Convert Unicode string to binary representation Config string, e.g.
    825   "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
    826   "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
    827 
    828 Arguments:
    829   ConfigString  - Binary representation of Unicode String, <string> := (<HexCh>4)+
    830   StrBufferLen  - On input: Length in bytes of buffer to hold the Unicode string.
    831                   Includes tailing '\0' character.
    832                   On output:
    833                     If return EFI_SUCCESS, containing length of Unicode string buffer.
    834                     If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
    835   UnicodeString - Original Unicode string.
    836 
    837 Returns:
    838   EFI_SUCCESS          - Routine success.
    839   EFI_BUFFER_TOO_SMALL - The string buffer is too small.
    840 
    841 --*/
    842 ;
    843 
    844 EFI_STATUS
    845 ConstructConfigHdr (
    846   IN OUT CHAR16                *ConfigHdr,
    847   IN OUT UINTN                 *StrBufferLen,
    848   IN EFI_GUID                  *Guid,
    849   IN CHAR16                    *Name, OPTIONAL
    850   IN EFI_HANDLE                *DriverHandle
    851   )
    852 /*++
    853 
    854 Routine Description:
    855   Construct <ConfigHdr> using routing information GUID/NAME/PATH.
    856 
    857 Arguments:
    858   ConfigHdr    - Pointer to the ConfigHdr string.
    859   StrBufferLen - On input: Length in bytes of buffer to hold the ConfigHdr string. Includes tailing '\0' character.
    860                  On output:
    861                     If return EFI_SUCCESS, containing length of ConfigHdr string buffer.
    862                     If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
    863   Guid         - Routing information: GUID.
    864   Name         - Routing information: NAME.
    865   DriverHandle  - Driver handle which contains the routing information: PATH.
    866 
    867 Returns:
    868   EFI_SUCCESS          - Routine success.
    869   EFI_BUFFER_TOO_SMALL - The ConfigHdr string buffer is too small.
    870 
    871 --*/
    872 ;
    873 
    874 BOOLEAN
    875 IsConfigHdrMatch (
    876   IN EFI_STRING                ConfigString,
    877   IN EFI_GUID                  *StorageGuid, OPTIONAL
    878   IN CHAR16                    *StorageName  OPTIONAL
    879   )
    880 /*++
    881 
    882 Routine Description:
    883   Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
    884 
    885 Arguments:
    886   ConfigString - Either <ConfigRequest> or <ConfigResp>.
    887   StorageGuid  - GUID of the storage.
    888   StorageName  - Name of the stoarge.
    889 
    890 Returns:
    891   TRUE         - Routing information is correct in ConfigString.
    892   FALSE        - Routing information is incorrect in ConfigString.
    893 
    894 --*/
    895 ;
    896 
    897 BOOLEAN
    898 FindBlockName (
    899   IN OUT CHAR16                *String,
    900   UINTN                        Offset,
    901   UINTN                        Width
    902   )
    903 /*++
    904 
    905 Routine Description:
    906   Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
    907 
    908 Arguments:
    909   String       - The string to be searched in.
    910   Offset       - Offset in BlockName.
    911   Width        - Width in BlockName.
    912 
    913 Returns:
    914   TRUE         - Block name found.
    915   FALSE        - Block name not found.
    916 
    917 --*/
    918 ;
    919 
    920 EFI_STATUS
    921 GetBrowserData (
    922   EFI_GUID                   *VariableGuid, OPTIONAL
    923   CHAR16                     *VariableName, OPTIONAL
    924   UINTN                      *BufferSize,
    925   UINT8                      *Buffer
    926   )
    927 /*++
    928 
    929 Routine Description:
    930   This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
    931 
    932 Arguments:
    933   VariableGuid  - An optional field to indicate the target variable GUID name to use.
    934   VariableName  - An optional field to indicate the target human-readable variable name.
    935   BufferSize    - On input: Length in bytes of buffer to hold retrived data.
    936                   On output:
    937                     If return EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
    938   Buffer        - Buffer to hold retrived data.
    939 
    940 Returns:
    941   EFI_SUCCESS          - Routine success.
    942   EFI_BUFFER_TOO_SMALL - The intput buffer is too small.
    943 
    944 --*/
    945 ;
    946 
    947 EFI_STATUS
    948 GetHiiHandles (
    949   IN OUT UINTN                     *HandleBufferLength,
    950   OUT    EFI_HII_HANDLE            **HiiHandleBuffer
    951   )
    952 /*++
    953 
    954 Routine Description:
    955   Determines the handles that are currently active in the database.
    956   It's the caller's responsibility to free handle buffer.
    957 
    958 Arguments:
    959   HiiDatabase           - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
    960   HandleBufferLength    - On input, a pointer to the length of the handle buffer. On output,
    961                           the length of the handle buffer that is required for the handles found.
    962   HiiHandleBuffer       - Pointer to an array of Hii Handles returned.
    963 
    964 Returns:
    965   EFI_SUCCESS           - Get an array of Hii Handles successfully.
    966   EFI_INVALID_PARAMETER - Hii is NULL.
    967   EFI_NOT_FOUND         - Database not found.
    968 
    969 --*/
    970 ;
    971 
    972 EFI_STATUS
    973 SetBrowserData (
    974   EFI_GUID                   *VariableGuid, OPTIONAL
    975   CHAR16                     *VariableName, OPTIONAL
    976   UINTN                      BufferSize,
    977   UINT8                      *Buffer,
    978   CHAR16                     *RequestElement  OPTIONAL
    979   )
    980 /*++
    981 
    982 Routine Description:
    983   This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
    984 
    985 Arguments:
    986   VariableGuid   - An optional field to indicate the target variable GUID name to use.
    987   VariableName   - An optional field to indicate the target human-readable variable name.
    988   BufferSize     - Length in bytes of buffer to hold retrived data.
    989   Buffer         - Buffer to hold retrived data.
    990   RequestElement - An optional field to specify which part of the buffer data
    991                    will be send back to Browser. If NULL, the whole buffer of
    992                    data will be committed to Browser.
    993                    <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*
    994 
    995 Returns:
    996   EFI_SUCCESS  - Routine success.
    997   Other        - Updating Browser uncommitted data failed.
    998 
    999 --*/
   1000 ;
   1001 
   1002 EFI_STATUS
   1003 ConvertRfc3066LanguageToIso639Language (
   1004   CHAR8   *LanguageRfc3066,
   1005   CHAR8   *LanguageIso639
   1006   )
   1007 /*++
   1008 
   1009 Routine Description:
   1010   Convert language code from RFC3066 to ISO639-2.
   1011 
   1012 Arguments:
   1013   LanguageRfc3066 - RFC3066 language code.
   1014   LanguageIso639  - ISO639-2 language code.
   1015 
   1016 Returns:
   1017   EFI_SUCCESS   - Language code converted.
   1018   EFI_NOT_FOUND - Language code not found.
   1019 
   1020 --*/
   1021 ;
   1022 
   1023 CHAR8 *
   1024 Rfc3066ToIso639 (
   1025   CHAR8  *SupportedLanguages
   1026   )
   1027 /*++
   1028 
   1029 Routine Description:
   1030   Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
   1031   be converted to "engfra".
   1032 
   1033 Arguments:
   1034   SupportedLanguages - The RFC3066 language list.
   1035 
   1036 Returns:
   1037   The ISO639-2 language list.
   1038 
   1039 --*/
   1040 ;
   1041 
   1042 EFI_STATUS
   1043 GetCurrentLanguage (
   1044   OUT     CHAR8               *Lang
   1045   )
   1046 /*++
   1047 
   1048 Routine Description:
   1049   Determine what is the current language setting
   1050 
   1051 Arguments:
   1052   Lang      - Pointer of system language
   1053 
   1054 Returns:
   1055   Status code
   1056 
   1057 --*/
   1058 ;
   1059 
   1060 VOID
   1061 GetNextLanguage (
   1062   IN OUT CHAR8      **LangCode,
   1063   OUT CHAR8         *Lang
   1064   )
   1065 /*++
   1066 
   1067 Routine Description:
   1068   Get next language from language code list.
   1069 
   1070 Arguments:
   1071   LangCode - The language code.
   1072   Lang     - Returned language.
   1073 
   1074 Returns:
   1075   None.
   1076 
   1077 --*/
   1078 ;
   1079 
   1080 CHAR8 *
   1081 GetSupportedLanguages (
   1082   IN EFI_HII_HANDLE           HiiHandle
   1083   )
   1084 /*++
   1085 
   1086 Routine Description:
   1087   This function returns the list of supported languages, in the format specified
   1088   in UEFI specification Appendix M.
   1089 
   1090 Arguments:
   1091   HiiHandle  - The HII package list handle.
   1092 
   1093 Returns:
   1094   The supported languages.
   1095 
   1096 --*/
   1097 ;
   1098 
   1099 UINT16
   1100 GetSupportedLanguageNumber (
   1101   IN EFI_HII_HANDLE           HiiHandle
   1102   )
   1103 /*++
   1104 
   1105 Routine Description:
   1106   This function returns the number of supported languages
   1107 
   1108 Arguments:
   1109   HiiHandle  - The HII package list handle.
   1110 
   1111 Returns:
   1112   The  number of supported languages.
   1113 
   1114 --*/
   1115 ;
   1116 
   1117 EFI_STATUS
   1118 GetStringFromHandle (
   1119   IN  EFI_HII_HANDLE                  HiiHandle,
   1120   IN  EFI_STRING_ID                   StringId,
   1121   OUT EFI_STRING                      *String
   1122   )
   1123 /*++
   1124 
   1125 Routine Description:
   1126   Get string specified by StringId form the HiiHandle.
   1127 
   1128 Arguments:
   1129   HiiHandle     - The HII handle of package list.
   1130   StringId      - The String ID.
   1131   String        - The output string.
   1132 
   1133 Returns:
   1134   EFI_NOT_FOUND         - String is not found.
   1135   EFI_SUCCESS           - Operation is successful.
   1136   EFI_OUT_OF_RESOURCES  - There is not enought memory in the system.
   1137   EFI_INVALID_PARAMETER - The String is NULL.
   1138 
   1139 --*/
   1140 ;
   1141 
   1142 EFI_STATUS
   1143 GetStringFromToken (
   1144   IN  EFI_GUID                        *ProducerGuid,
   1145   IN  EFI_STRING_ID                   StringId,
   1146   OUT EFI_STRING                      *String
   1147   )
   1148 /*++
   1149 
   1150 Routine Description:
   1151   Get the string given the StringId and String package Producer's Guid.
   1152 
   1153 Arguments:
   1154   ProducerGuid  - The Guid of String package list.
   1155   StringId      - The String ID.
   1156   String        - The output string.
   1157 
   1158 Returns:
   1159   EFI_NOT_FOUND         - String is not found.
   1160   EFI_SUCCESS           - Operation is successful.
   1161   EFI_OUT_OF_RESOURCES  - There is not enought memory in the system.
   1162 
   1163 --*/
   1164 ;
   1165 
   1166 EFI_STATUS
   1167 IfrLibNewString (
   1168   IN  EFI_HII_HANDLE                  PackageList,
   1169   OUT EFI_STRING_ID                   *StringId,
   1170   IN  CONST EFI_STRING                String
   1171   )
   1172 /*++
   1173 
   1174   Routine Description:
   1175     This function adds the string into String Package of each language.
   1176 
   1177   Arguments:
   1178     PackageList       - Handle of the package list where this string will be added.
   1179     StringId          - On return, contains the new strings id, which is unique within PackageList.
   1180     String            - Points to the new null-terminated string.
   1181 
   1182   Returns:
   1183     EFI_SUCCESS            - The new string was added successfully.
   1184     EFI_NOT_FOUND          - The specified PackageList could not be found in database.
   1185     EFI_OUT_OF_RESOURCES   - Could not add the string due to lack of resources.
   1186     EFI_INVALID_PARAMETER  - String is NULL or StringId is NULL is NULL.
   1187 
   1188 --*/
   1189 ;
   1190 
   1191 EFI_STATUS
   1192 IfrLibGetString (
   1193   IN  EFI_HII_HANDLE                  PackageList,
   1194   IN  EFI_STRING_ID                   StringId,
   1195   OUT EFI_STRING                      String,
   1196   IN  OUT UINTN                       *StringSize
   1197   )
   1198 /*++
   1199 
   1200   Routine Description:
   1201     This function try to retrieve string from String package of current language.
   1202     If fail, it try to retrieve string from String package of first language it support.
   1203 
   1204   Arguments:
   1205     PackageList       - The package list in the HII database to search for the specified string.
   1206     StringId          - The string's id, which is unique within PackageList.
   1207     String            - Points to the new null-terminated string.
   1208     StringSize        - On entry, points to the size of the buffer pointed to by String, in bytes. On return,
   1209                         points to the length of the string, in bytes.
   1210 
   1211   Returns:
   1212     EFI_SUCCESS            - The string was returned successfully.
   1213     EFI_NOT_FOUND          - The string specified by StringId is not available.
   1214     EFI_BUFFER_TOO_SMALL   - The buffer specified by StringLength is too small to hold the string.
   1215     EFI_INVALID_PARAMETER  - The String or StringSize was NULL.
   1216 
   1217 --*/
   1218 ;
   1219 
   1220 EFI_STATUS
   1221 IfrLibSetString (
   1222   IN EFI_HII_HANDLE                   PackageList,
   1223   IN EFI_STRING_ID                    StringId,
   1224   IN CONST EFI_STRING                 String
   1225   )
   1226 /*++
   1227 
   1228   Routine Description:
   1229     This function updates the string in String package of current language.
   1230 
   1231   Arguments:
   1232     PackageList       - The package list containing the strings.
   1233     StringId          - The string's id, which is unique within PackageList.
   1234     String            - Points to the new null-terminated string.
   1235 
   1236   Returns:
   1237     EFI_SUCCESS            - The string was updated successfully.
   1238     EFI_NOT_FOUND          - The string specified by StringId is not in the database.
   1239     EFI_INVALID_PARAMETER  - The String was NULL.
   1240     EFI_OUT_OF_RESOURCES   - The system is out of resources to accomplish the task.
   1241 
   1242 --*/
   1243 ;
   1244 
   1245 EFI_STATUS
   1246 IfrLibCreatePopUp (
   1247   IN  UINTN                       NumberOfLines,
   1248   OUT EFI_INPUT_KEY               *KeyValue,
   1249   IN  CHAR16                      *String,
   1250   ...
   1251   )
   1252 /*++
   1253 
   1254 Routine Description:
   1255   Draw a dialog and return the selected key.
   1256 
   1257 Arguments:
   1258   NumberOfLines     - The number of lines for the dialog box
   1259   KeyValue          - The EFI_KEY value returned if HotKey is TRUE..
   1260   String            - Pointer to the first string in the list
   1261   ...               - A series of (quantity == NumberOfLines) text strings which
   1262                       will be used to construct the dialog box
   1263 
   1264 Returns:
   1265   EFI_SUCCESS           - Displayed dialog and received user interaction
   1266   EFI_INVALID_PARAMETER - One of the parameters was invalid.
   1267 
   1268 --*/
   1269 ;
   1270 
   1271 EFI_STATUS
   1272 IfrLibInitUpdateData (
   1273   IN OUT EFI_HII_UPDATE_DATA   *UpdateData,
   1274   IN UINT32                    BufferSize
   1275   )
   1276 /*++
   1277 
   1278 Routine Description:
   1279   This function initialize the data structure for dynamic opcode.
   1280 
   1281 Arguments:
   1282   UpdateData     - The adding data;
   1283   BufferSize     - Length of the buffer to fill dynamic opcodes.
   1284 
   1285 Returns:
   1286   EFI_SUCCESS           - Update data is initialized.
   1287   EFI_INVALID_PARAMETER - UpdateData is NULL.
   1288   EFI_OUT_OF_RESOURCES  - No enough memory to allocate.
   1289 
   1290 --*/
   1291 ;
   1292 
   1293 EFI_STATUS
   1294 IfrLibFreeUpdateData (
   1295   IN EFI_HII_UPDATE_DATA       *UpdateData
   1296   )
   1297 /*++
   1298 
   1299 Routine Description:
   1300   This function free the resource of update data.
   1301 
   1302 Arguments:
   1303   UpdateData     - The adding data;
   1304 
   1305 Returns:
   1306   EFI_SUCCESS           - Resource in UpdateData is released.
   1307   EFI_INVALID_PARAMETER - UpdateData is NULL.
   1308 
   1309 --*/
   1310 ;
   1311 
   1312 EFI_STATUS
   1313 IfrLibUpdateForm (
   1314   IN EFI_HII_HANDLE            Handle,
   1315   IN EFI_GUID                  *FormSetGuid, OPTIONAL
   1316   IN EFI_FORM_ID               FormId,
   1317   IN UINT16                    Label,
   1318   IN BOOLEAN                   Insert,
   1319   IN EFI_HII_UPDATE_DATA       *Data
   1320   )
   1321 /*++
   1322 
   1323 Routine Description:
   1324   This function allows the caller to update a form that has
   1325   previously been registered with the EFI HII database.
   1326 
   1327 Arguments:
   1328   Handle       - Hii Handle
   1329   FormSetGuid  - The formset should be updated.
   1330   FormId       - The form should be updated.
   1331   Label        - Update information starting immediately after this label in the IFR
   1332   Insert       - If TRUE and Data is not NULL, insert data after Label.
   1333                  If FALSE, replace opcodes between two labels with Data.
   1334   Data         - The adding data; If NULL, remove opcodes between two Label.
   1335 
   1336 Returns:
   1337   EFI_SUCCESS  - Update success.
   1338   Other        - Update fail.
   1339 
   1340 --*/
   1341 ;
   1342 #endif
   1343