Home | History | Annotate | Download | only in SetupBrowserDxe
      1 /** @file
      2 Private MACRO, structure and function definitions for Setup Browser module.
      3 
      4 Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
      5 This program and the accompanying materials
      6 are licensed and made available under the terms and conditions of the BSD License
      7 which accompanies this distribution.  The full text of the license may be found at
      8 http://opensource.org/licenses/bsd-license.php
      9 
     10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 
     14 **/
     15 
     16 #ifndef _SETUP_H_
     17 #define _SETUP_H_
     18 
     19 
     20 #include <PiDxe.h>
     21 
     22 #include <Protocol/SimpleTextOut.h>
     23 #include <Protocol/SimpleTextIn.h>
     24 #include <Protocol/FormBrowser2.h>
     25 #include <Protocol/FormBrowserEx2.h>
     26 #include <Protocol/DisplayProtocol.h>
     27 #include <Protocol/DevicePath.h>
     28 #include <Protocol/UnicodeCollation.h>
     29 #include <Protocol/HiiConfigAccess.h>
     30 #include <Protocol/HiiConfigRouting.h>
     31 #include <Protocol/HiiDatabase.h>
     32 #include <Protocol/HiiString.h>
     33 #include <Protocol/UserManager.h>
     34 #include <Protocol/DevicePathFromText.h>
     35 #include <Protocol/RegularExpressionProtocol.h>
     36 
     37 #include <Guid/MdeModuleHii.h>
     38 #include <Guid/HiiPlatformSetupFormset.h>
     39 #include <Guid/HiiFormMapMethodGuid.h>
     40 #include <Guid/ZeroGuid.h>
     41 
     42 #include <Library/PrintLib.h>
     43 #include <Library/DebugLib.h>
     44 #include <Library/BaseMemoryLib.h>
     45 #include <Library/UefiRuntimeServicesTableLib.h>
     46 #include <Library/UefiDriverEntryPoint.h>
     47 #include <Library/UefiBootServicesTableLib.h>
     48 #include <Library/BaseLib.h>
     49 #include <Library/MemoryAllocationLib.h>
     50 #include <Library/HiiLib.h>
     51 #include <Library/PcdLib.h>
     52 #include <Library/DevicePathLib.h>
     53 #include <Library/UefiLib.h>
     54 
     55 
     56 //
     57 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
     58 //
     59 
     60 #define UI_ACTION_NONE               0
     61 #define UI_ACTION_REFRESH_FORM       1
     62 #define UI_ACTION_REFRESH_FORMSET    2
     63 #define UI_ACTION_EXIT               3
     64 
     65 //
     66 //
     67 // Time definitions
     68 //
     69 #define ONE_SECOND  10000000
     70 
     71 // Incremental string lenght of ConfigRequest
     72 //
     73 #define CONFIG_REQUEST_STRING_INCREMENTAL  1024
     74 
     75 //
     76 // Incremental size of stack for expression
     77 //
     78 #define EXPRESSION_STACK_SIZE_INCREMENT    0x100
     79 
     80 #define EFI_IFR_SPECIFICATION_VERSION  (UINT16) (((EFI_SYSTEM_TABLE_REVISION >> 16) << 8) | (((EFI_SYSTEM_TABLE_REVISION & 0xFFFF) / 10) << 4) | ((EFI_SYSTEM_TABLE_REVISION & 0xFFFF) % 10))
     81 
     82 
     83 #define SETUP_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'B', 'D', 'V')
     84 typedef struct {
     85   UINT32                             Signature;
     86 
     87   EFI_HANDLE                         Handle;
     88 
     89   //
     90   // Produced protocol
     91   //
     92   EFI_FORM_BROWSER2_PROTOCOL            FormBrowser2;
     93   EDKII_FORM_BROWSER_EXTENSION_PROTOCOL FormBrowserEx;
     94 
     95   EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL FormBrowserEx2;
     96 
     97 } SETUP_DRIVER_PRIVATE_DATA;
     98 
     99 //
    100 // IFR relative definition
    101 //
    102 #define EFI_HII_EXPRESSION_INCONSISTENT_IF   0
    103 #define EFI_HII_EXPRESSION_NO_SUBMIT_IF      1
    104 #define EFI_HII_EXPRESSION_GRAY_OUT_IF       2
    105 #define EFI_HII_EXPRESSION_SUPPRESS_IF       3
    106 #define EFI_HII_EXPRESSION_DISABLE_IF        4
    107 #define EFI_HII_EXPRESSION_VALUE             5
    108 #define EFI_HII_EXPRESSION_RULE              6
    109 #define EFI_HII_EXPRESSION_READ              7
    110 #define EFI_HII_EXPRESSION_WRITE             8
    111 #define EFI_HII_EXPRESSION_WARNING_IF        9
    112 
    113 #define EFI_HII_VARSTORE_BUFFER              0
    114 #define EFI_HII_VARSTORE_NAME_VALUE          1
    115 #define EFI_HII_VARSTORE_EFI_VARIABLE        2    // EFI Varstore type follow UEFI spec before 2.3.1.
    116 #define EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER 3    // EFI varstore type follow UEFI spec 2.3.1 and later.
    117 
    118 #define FORM_INCONSISTENT_VALIDATION         0
    119 #define FORM_NO_SUBMIT_VALIDATION            1
    120 
    121 #define NAME_VALUE_NODE_SIGNATURE  SIGNATURE_32 ('N', 'V', 'S', 'T')
    122 
    123 typedef struct {
    124   UINTN            Signature;
    125   LIST_ENTRY       Link;
    126   CHAR16           *Name;
    127   CHAR16           *Value;
    128   CHAR16           *EditValue;
    129 } NAME_VALUE_NODE;
    130 
    131 #define NAME_VALUE_NODE_FROM_LINK(a)  CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
    132 
    133 #define BROWSER_STORAGE_SIGNATURE  SIGNATURE_32 ('B', 'S', 'T', 'G')
    134 
    135 typedef struct {
    136   UINTN            Signature;
    137   LIST_ENTRY       Link;
    138 
    139   UINT8            Type;           // Storage type
    140 
    141   BOOLEAN          Initialized;    // Whether this varstore is initialized, efi varstore not used.
    142 
    143   EFI_HII_HANDLE   HiiHandle;      // HiiHandle for this varstore, efi varstore not used.
    144   EFI_GUID         Guid;
    145 
    146   CHAR16           *Name;          // For EFI_IFR_VARSTORE
    147   UINT16           Size;
    148   UINT8            *Buffer;
    149   UINT8            *EditBuffer;    // Edit copy for Buffer Storage
    150 
    151   LIST_ENTRY       NameValueListHead; // List of NAME_VALUE_NODE
    152 
    153   UINT32           Attributes;     // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
    154 
    155   CHAR16           *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
    156                                    // <RequestElement> includes all fields which is used by current form sets.
    157   UINTN            SpareStrLen;    // Spare length of ConfigRequest string buffer
    158 } BROWSER_STORAGE;
    159 
    160 #define BROWSER_STORAGE_FROM_LINK(a)  CR (a, BROWSER_STORAGE, Link, BROWSER_STORAGE_SIGNATURE)
    161 
    162 #define FORMSET_STORAGE_SIGNATURE  SIGNATURE_32 ('F', 'S', 'T', 'G')
    163 
    164 typedef struct {
    165   UINTN            Signature;
    166   LIST_ENTRY       Link;
    167 
    168   LIST_ENTRY       SaveFailLink;
    169 
    170   UINT16           VarStoreId;
    171 
    172   BROWSER_STORAGE  *BrowserStorage;
    173 
    174   CHAR16           *ConfigHdr;     // <ConfigHdr>
    175 
    176   CHAR16           *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
    177   CHAR16           *ConfigAltResp; // Alt config response string for this ConfigRequest.
    178   BOOLEAN          HasCallAltCfg;  // Flag to show whether browser has call ExtractConfig to get Altcfg string.
    179   UINTN            ElementCount;   // Number of <RequestElement> in the <ConfigRequest>
    180   UINTN            SpareStrLen;    // Spare length of ConfigRequest string buffer
    181   CHAR16           *RestoreConfigRequest; // When submit formset fail, the element need to be restored
    182   CHAR16           *SyncConfigRequest;    // When submit formset fail, the element need to be synced
    183 } FORMSET_STORAGE;
    184 
    185 #define FORMSET_STORAGE_FROM_LINK(a)  CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
    186 #define FORMSET_STORAGE_FROM_SAVE_FAIL_LINK(a)  CR (a, FORMSET_STORAGE, SaveFailLink, FORMSET_STORAGE_SIGNATURE)
    187 
    188 typedef union {
    189   EFI_STRING_ID         VarName;
    190   UINT16                VarOffset;
    191 } VAR_STORE_INFO;
    192 
    193 #define EXPRESSION_OPCODE_SIGNATURE  SIGNATURE_32 ('E', 'X', 'O', 'P')
    194 
    195 typedef struct {
    196   UINTN             Signature;
    197   LIST_ENTRY        Link;
    198 
    199   UINT8             Operand;
    200 
    201   UINT8             Format;      // For EFI_IFR_TO_STRING, EFI_IFR_FIND
    202   UINT8             Flags;       // For EFI_IFR_SPAN
    203   UINT8             RuleId;      // For EFI_IFR_RULE_REF
    204 
    205   EFI_HII_VALUE     Value;       // For EFI_IFR_EQ_ID_VAL, EFI_IFR_UINT64, EFI_IFR_UINT32, EFI_IFR_UINT16, EFI_IFR_UINT8, EFI_IFR_STRING_REF1
    206 
    207   EFI_QUESTION_ID   QuestionId;  // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_VAL_LIST, EFI_IFR_QUESTION_REF1
    208   EFI_QUESTION_ID   QuestionId2;
    209 
    210   UINT16            ListLength;  // For EFI_IFR_EQ_ID_VAL_LIST
    211   UINT16            *ValueList;
    212 
    213   EFI_STRING_ID     DevicePath;  // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3
    214   EFI_GUID          Guid;
    215 
    216   BROWSER_STORAGE   *VarStorage; // For EFI_IFR_SET, EFI_IFR_GET
    217   VAR_STORE_INFO    VarStoreInfo;// For EFI_IFR_SET, EFI_IFR_GET
    218   UINT8             ValueType;   // For EFI_IFR_SET, EFI_IFR_GET
    219   UINT8             ValueWidth;  // For EFI_IFR_SET, EFI_IFR_GET
    220   CHAR16            *ValueName;  // For EFI_IFR_SET, EFI_IFR_GET
    221   LIST_ENTRY        MapExpressionList;   // nested expressions inside of Map opcode.
    222 } EXPRESSION_OPCODE;
    223 
    224 #define EXPRESSION_OPCODE_FROM_LINK(a)  CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)
    225 
    226 #define FORM_EXPRESSION_SIGNATURE  SIGNATURE_32 ('F', 'E', 'X', 'P')
    227 
    228 typedef struct {
    229   UINTN             Signature;
    230   LIST_ENTRY        Link;
    231 
    232   UINT8             Type;            // Type for this expression
    233 
    234   UINT8             RuleId;          // For EFI_IFR_RULE only
    235   EFI_STRING_ID     Error;           // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only
    236 
    237   EFI_HII_VALUE     Result;          // Expression evaluation result
    238 
    239   UINT8             TimeOut;         // For EFI_IFR_WARNING_IF
    240   EFI_IFR_OP_HEADER *OpCode;         // Save the opcode buffer.
    241 
    242   LIST_ENTRY        OpCodeListHead;  // OpCodes consist of this expression (EXPRESSION_OPCODE)
    243 } FORM_EXPRESSION;
    244 
    245 #define FORM_EXPRESSION_FROM_LINK(a)  CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
    246 
    247 #define FORM_EXPRESSION_LIST_SIGNATURE  SIGNATURE_32 ('F', 'E', 'X', 'R')
    248 
    249 typedef struct {
    250     UINTN               Signature;
    251     UINTN               Count;
    252     FORM_EXPRESSION    *Expression[1];   // Array[Count] of expressions
    253 } FORM_EXPRESSION_LIST;
    254 
    255 #define QUESTION_DEFAULT_SIGNATURE  SIGNATURE_32 ('Q', 'D', 'F', 'T')
    256 
    257 typedef struct {
    258   UINTN               Signature;
    259   LIST_ENTRY          Link;
    260 
    261   UINT16              DefaultId;
    262   EFI_HII_VALUE       Value;              // Default value
    263 
    264   FORM_EXPRESSION     *ValueExpression;   // Not-NULL indicates default value is provided by EFI_IFR_VALUE
    265 } QUESTION_DEFAULT;
    266 
    267 #define QUESTION_DEFAULT_FROM_LINK(a)  CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
    268 
    269 #define QUESTION_OPTION_SIGNATURE  SIGNATURE_32 ('Q', 'O', 'P', 'T')
    270 
    271 typedef struct {
    272   UINTN                Signature;
    273   LIST_ENTRY           Link;
    274 
    275   EFI_IFR_ONE_OF_OPTION  *OpCode;   // OneOfOption Data
    276 
    277   EFI_STRING_ID        Text;
    278   UINT8                Flags;
    279   EFI_HII_VALUE        Value;
    280   EFI_IMAGE_ID         ImageId;
    281 
    282   FORM_EXPRESSION_LIST *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf
    283 } QUESTION_OPTION;
    284 
    285 #define QUESTION_OPTION_FROM_LINK(a)  CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
    286 
    287 typedef enum {
    288   ExpressFalse = 0,
    289   ExpressGrayOut,
    290   ExpressSuppress,
    291   ExpressDisable
    292 } EXPRESS_RESULT;
    293 
    294 typedef enum {
    295   ExpressNone = 0,
    296   ExpressForm,
    297   ExpressStatement,
    298   ExpressOption
    299 } EXPRESS_LEVEL;
    300 
    301 typedef struct _FORM_BROWSER_STATEMENT FORM_BROWSER_STATEMENT;
    302 
    303 #define FORM_BROWSER_STATEMENT_SIGNATURE  SIGNATURE_32 ('F', 'S', 'T', 'A')
    304 
    305 struct _FORM_BROWSER_STATEMENT{
    306   UINTN                 Signature;
    307   LIST_ENTRY            Link;
    308 
    309   UINT8                 Operand;          // The operand (first byte) of this Statement or Question
    310   EFI_IFR_OP_HEADER     *OpCode;
    311 
    312   //
    313   // Statement Header
    314   //
    315   EFI_STRING_ID         Prompt;
    316   EFI_STRING_ID         Help;
    317   EFI_STRING_ID         TextTwo;          // For EFI_IFR_TEXT
    318 
    319   //
    320   // Fake Question Id, used for statement not has true QuestionId.
    321   //
    322   EFI_QUESTION_ID       FakeQuestionId;
    323 
    324   //
    325   // Question Header
    326   //
    327   EFI_QUESTION_ID       QuestionId;       // The value of zero is reserved
    328   EFI_VARSTORE_ID       VarStoreId;       // A value of zero indicates no variable storage
    329   BROWSER_STORAGE       *Storage;
    330   VAR_STORE_INFO        VarStoreInfo;
    331   UINT16                StorageWidth;
    332   UINT8                 QuestionFlags;
    333   CHAR16                *VariableName;    // Name/Value or EFI Variable name
    334   CHAR16                *BlockName;       // Buffer storage block name: "OFFSET=...WIDTH=..."
    335 
    336   EFI_HII_VALUE         HiiValue;         // Edit copy for checkbox, numberic, oneof
    337   UINT8                 *BufferValue;     // Edit copy for string, password, orderedlist
    338   UINT8                 ValueType;        // Data type for orderedlist value array
    339 
    340   //
    341   // OpCode specific members
    342   //
    343   UINT8                 Flags;            // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,
    344                                           // EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER
    345   UINT8                 MaxContainers;    // for EFI_IFR_ORDERED_LIST
    346 
    347   UINT16                BannerLineNumber; // for EFI_IFR_BANNER, 1-based line number
    348   EFI_STRING_ID         QuestionConfig;   // for EFI_IFR_ACTION, if 0 then no configuration string will be processed
    349 
    350   UINT64                Minimum;          // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value
    351   UINT64                Maximum;          // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
    352   UINT64                Step;
    353 
    354   EFI_DEFAULT_ID        DefaultId;        // for EFI_IFR_RESET_BUTTON
    355   EFI_GUID              RefreshGuid;      // for EFI_IFR_REFRESH_ID
    356   BOOLEAN               Locked;           // Whether this statement is locked.
    357   BOOLEAN               ValueChanged;     // Whether this statement's value is changed.
    358   //
    359   // Get from IFR parsing
    360   //
    361   FORM_EXPRESSION       *ValueExpression;    // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
    362   LIST_ENTRY            DefaultListHead;     // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
    363   LIST_ENTRY            OptionListHead;      // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
    364 
    365   EFI_IMAGE_ID          ImageId;             // nested EFI_IFR_IMAGE
    366   UINT8                 RefreshInterval;     // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
    367 
    368   FORM_BROWSER_STATEMENT *ParentStatement;
    369 
    370   LIST_ENTRY            InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)
    371   LIST_ENTRY            NoSubmitListHead;    // nested nosubmit expression list (FORM_EXPRESSION)
    372   LIST_ENTRY            WarningListHead;     // nested warning expression list (FORM_EXPRESSION)
    373   FORM_EXPRESSION_LIST  *Expression;         // nesting inside of GrayOutIf/DisableIf/SuppressIf
    374 
    375   FORM_EXPRESSION       *ReadExpression;     // nested EFI_IFR_READ, provide this question value by read expression.
    376   FORM_EXPRESSION       *WriteExpression;    // nested EFI_IFR_WRITE, evaluate write expression after this question value is set.
    377 };
    378 
    379 #define FORM_BROWSER_STATEMENT_FROM_LINK(a)  CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)
    380 
    381 #define FORM_BROWSER_CONFIG_REQUEST_SIGNATURE  SIGNATURE_32 ('F', 'C', 'R', 'S')
    382 typedef struct {
    383   UINTN                 Signature;
    384   LIST_ENTRY            Link;
    385 
    386   LIST_ENTRY            SaveFailLink;
    387 
    388   CHAR16                *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
    389   CHAR16                *ConfigAltResp; // Alt config response string for this ConfigRequest.
    390   UINTN                 ElementCount;   // Number of <RequestElement> in the <ConfigRequest>
    391   UINTN                 SpareStrLen;
    392   CHAR16                *RestoreConfigRequest; // When submit form fail, the element need to be restored
    393   CHAR16                *SyncConfigRequest;    // When submit form fail, the element need to be synced
    394 
    395   BROWSER_STORAGE       *Storage;
    396 } FORM_BROWSER_CONFIG_REQUEST;
    397 #define FORM_BROWSER_CONFIG_REQUEST_FROM_LINK(a)  CR (a, FORM_BROWSER_CONFIG_REQUEST, Link, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
    398 #define FORM_BROWSER_CONFIG_REQUEST_FROM_SAVE_FAIL_LINK(a)  CR (a, FORM_BROWSER_CONFIG_REQUEST, SaveFailLink, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
    399 
    400 #define FORM_BROWSER_FORM_SIGNATURE  SIGNATURE_32 ('F', 'F', 'R', 'M')
    401 #define STANDARD_MAP_FORM_TYPE 0x01
    402 
    403 typedef struct {
    404   UINTN                Signature;
    405   LIST_ENTRY           Link;
    406 
    407   UINT16               FormId;               // FormId of normal form or formmap form.
    408   EFI_STRING_ID        FormTitle;            // FormTile of normal form, or FormMapMethod title of formmap form.
    409   UINT16               FormType;             // Specific form type for the different form.
    410 
    411   EFI_IMAGE_ID         ImageId;
    412 
    413   BOOLEAN              ModalForm;            // Whether this is a modal form.
    414   BOOLEAN              Locked;               // Whether this form is locked.
    415   EFI_GUID             RefreshGuid;          // Form refresh event guid.
    416 
    417   LIST_ENTRY           FormViewListHead;     // List of type FORMID_INFO is Browser View Form History List.
    418   LIST_ENTRY           ExpressionListHead;   // List of Expressions (FORM_EXPRESSION)
    419   LIST_ENTRY           StatementListHead;    // List of Statements and Questions (FORM_BROWSER_STATEMENT)
    420   LIST_ENTRY           ConfigRequestHead;    // List of configreques for all storage.
    421   FORM_EXPRESSION_LIST *SuppressExpression;  // nesting inside of SuppressIf
    422 } FORM_BROWSER_FORM;
    423 
    424 #define FORM_BROWSER_FORM_FROM_LINK(a)  CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)
    425 
    426 #define FORMSET_DEFAULTSTORE_SIGNATURE  SIGNATURE_32 ('F', 'D', 'F', 'S')
    427 
    428 typedef struct {
    429   UINTN            Signature;
    430   LIST_ENTRY       Link;
    431 
    432   UINT16           DefaultId;
    433   EFI_STRING_ID    DefaultName;
    434 } FORMSET_DEFAULTSTORE;
    435 
    436 #define FORMSET_DEFAULTSTORE_FROM_LINK(a)  CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)
    437 
    438 #define FORM_BROWSER_FORMSET_SIGNATURE  SIGNATURE_32 ('F', 'B', 'F', 'S')
    439 
    440 typedef struct {
    441   UINTN                           Signature;
    442   LIST_ENTRY                      Link;
    443   LIST_ENTRY                      SaveFailLink;
    444 
    445   EFI_HII_HANDLE                  HiiHandle;      // unique id for formset.
    446   EFI_HANDLE                      DriverHandle;
    447   EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess;
    448   EFI_DEVICE_PATH_PROTOCOL        *DevicePath;
    449 
    450   UINTN                           IfrBinaryLength;
    451   UINT8                           *IfrBinaryData;
    452 
    453   BOOLEAN                         QuestionInited;   // Have finished question initilization?
    454   EFI_GUID                        Guid;
    455   EFI_STRING_ID                   FormSetTitle;
    456   EFI_STRING_ID                   Help;
    457   UINT8                           NumberOfClassGuid;
    458   EFI_GUID                        ClassGuid[3];         // Up to three ClassGuid
    459   UINT16                          Class;                // Tiano extended Class code
    460   UINT16                          SubClass;             // Tiano extended Subclass code
    461   EFI_IMAGE_ID                    ImageId;
    462   EFI_IFR_OP_HEADER               *OpCode;              //mainly for formset op to get ClassGuid
    463 
    464   FORM_BROWSER_STATEMENT          *StatementBuffer;     // Buffer for all Statements and Questions
    465   EXPRESSION_OPCODE               *ExpressionBuffer;    // Buffer for all Expression OpCode
    466   FORM_BROWSER_FORM               *SaveFailForm;        // The form which failed to save.
    467   FORM_BROWSER_STATEMENT          *SaveFailStatement;   // The Statement which failed to save.
    468 
    469   LIST_ENTRY                      StatementListOSF;     // Statement list out side of the form.
    470   LIST_ENTRY                      StorageListHead;      // Storage list (FORMSET_STORAGE)
    471   LIST_ENTRY                      SaveFailStorageListHead; // Storage list for the save fail storage.
    472   LIST_ENTRY                      DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
    473   LIST_ENTRY                      FormListHead;         // Form list (FORM_BROWSER_FORM)
    474   LIST_ENTRY                      ExpressionListHead;   // List of Expressions (FORM_EXPRESSION)
    475 } FORM_BROWSER_FORMSET;
    476 #define FORM_BROWSER_FORMSET_FROM_LINK(a)  CR (a, FORM_BROWSER_FORMSET, Link, FORM_BROWSER_FORMSET_SIGNATURE)
    477 
    478 #define FORM_BROWSER_FORMSET_FROM_SAVE_FAIL_LINK(a)  CR (a, FORM_BROWSER_FORMSET, SaveFailLink, FORM_BROWSER_FORMSET_SIGNATURE)
    479 
    480 typedef struct {
    481   LIST_ENTRY   Link;
    482   EFI_EVENT    RefreshEvent;
    483 } FORM_BROWSER_REFRESH_EVENT_NODE;
    484 
    485 #define FORM_BROWSER_REFRESH_EVENT_FROM_LINK(a) BASE_CR (a, FORM_BROWSER_REFRESH_EVENT_NODE, Link)
    486 
    487 
    488 typedef struct {
    489   EFI_HII_HANDLE  Handle;
    490 
    491   //
    492   // Target formset/form/Question information
    493   //
    494   EFI_GUID        FormSetGuid;
    495   UINT16          FormId;
    496   UINT16          QuestionId;
    497   UINTN           Sequence;  // used for time/date only.
    498 
    499   UINTN           TopRow;
    500   UINTN           BottomRow;
    501   UINTN           PromptCol;
    502   UINTN           OptionCol;
    503   UINTN           CurrentRow;
    504 
    505   //
    506   // Ation for Browser to taken:
    507   //   UI_ACTION_NONE            - navigation inside a form
    508   //   UI_ACTION_REFRESH_FORM    - re-evaluate expressions and repaint form
    509   //   UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary
    510   //
    511   UINTN           Action;
    512 
    513   //
    514   // Current selected fomset/form/Question
    515   //
    516   FORM_BROWSER_FORMSET    *FormSet;
    517   FORM_BROWSER_FORM       *Form;
    518   FORM_BROWSER_STATEMENT  *Statement;
    519 
    520   //
    521   // Whether the Form is editable
    522   //
    523   BOOLEAN                 FormEditable;
    524 
    525   FORM_ENTRY_INFO            *CurrentMenu;
    526 } UI_MENU_SELECTION;
    527 
    528 #define BROWSER_CONTEXT_SIGNATURE  SIGNATURE_32 ('B', 'C', 'T', 'X')
    529 
    530 typedef struct {
    531   UINTN                 Signature;
    532   LIST_ENTRY            Link;
    533 
    534   //
    535   // Globals defined in Setup.c
    536   //
    537   BOOLEAN                  FlagReconnect;
    538   BOOLEAN                  CallbackReconnect;
    539   BOOLEAN                  ResetRequired;
    540   BOOLEAN                  ExitRequired;
    541   EFI_HII_HANDLE           HiiHandle;
    542   EFI_GUID                 FormSetGuid;
    543   EFI_FORM_ID              FormId;
    544   UI_MENU_SELECTION        *Selection;
    545   FORM_BROWSER_FORMSET     *SystemLevelFormSet;
    546   EFI_QUESTION_ID          CurFakeQestId;
    547   BOOLEAN                  HiiPackageListUpdated;
    548   BOOLEAN                  FinishRetrieveCall;
    549   LIST_ENTRY               FormHistoryList;
    550   LIST_ENTRY               FormSetList;
    551 } BROWSER_CONTEXT;
    552 
    553 #define BROWSER_CONTEXT_FROM_LINK(a)  CR (a, BROWSER_CONTEXT, Link, BROWSER_CONTEXT_SIGNATURE)
    554 
    555 //
    556 // Scope for get defaut value. It may be GetDefaultForNoStorage, GetDefaultForStorage or GetDefaultForAll.
    557 //
    558 typedef enum {
    559   GetDefaultForNoStorage,       // Get default value for question which not has storage.
    560   GetDefaultForStorage,         // Get default value for question which has storage.
    561   GetDefaultForAll,             // Get default value for all questions.
    562   GetDefaultForMax              // Invalid value.
    563 } BROWSER_GET_DEFAULT_VALUE;
    564 
    565 //
    566 // Get/set question value from/to.
    567 //
    568 typedef enum {
    569   GetSetValueWithEditBuffer = 0,   // Get/Set question value from/to editbuffer in the storage.
    570   GetSetValueWithBuffer,           // Get/Set question value from/to buffer in the storage.
    571   GetSetValueWithHiiDriver,        // Get/Set question value from/to hii driver.
    572   GetSetValueWithBothBuffer,       // Compare the editbuffer with buffer for this question, not use the question value.
    573   GetSetValueWithMax               // Invalid value.
    574 } GET_SET_QUESTION_VALUE_WITH;
    575 
    576 extern EFI_HII_DATABASE_PROTOCOL         *mHiiDatabase;
    577 extern EFI_HII_CONFIG_ROUTING_PROTOCOL   *mHiiConfigRouting;
    578 extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText;
    579 extern EDKII_FORM_DISPLAY_ENGINE_PROTOCOL *mFormDisplay;
    580 
    581 extern BOOLEAN               gCallbackReconnect;
    582 extern BOOLEAN               gFlagReconnect;
    583 extern BOOLEAN               gResetRequired;
    584 extern BOOLEAN               gExitRequired;
    585 extern LIST_ENTRY            gBrowserFormSetList;
    586 extern LIST_ENTRY            gBrowserHotKeyList;
    587 extern BROWSER_SETTING_SCOPE gBrowserSettingScope;
    588 extern EXIT_HANDLER          ExitHandlerFunction;
    589 extern EFI_HII_HANDLE        mCurrentHiiHandle;
    590 extern SETUP_DRIVER_PRIVATE_DATA mPrivateData;
    591 //
    592 // Browser Global Strings
    593 //
    594 extern CHAR16            *gEmptyString;
    595 
    596 extern UI_MENU_SELECTION  *gCurrentSelection;
    597 extern BOOLEAN            mHiiPackageListUpdated;
    598 extern UINT16             mCurFakeQestId;
    599 extern BOOLEAN            mFinishRetrieveCall;
    600 
    601 //
    602 // Global Procedure Defines
    603 //
    604 #include "Expression.h"
    605 
    606 /**
    607   Initialize the HII String Token to the correct values.
    608 
    609 **/
    610 VOID
    611 InitializeBrowserStrings (
    612   VOID
    613   );
    614 
    615 /**
    616   Parse opcodes in the formset IFR binary.
    617 
    618   @param  FormSet                Pointer of the FormSet data structure.
    619 
    620   @retval EFI_SUCCESS            Opcode parse success.
    621   @retval Other                  Opcode parse fail.
    622 
    623 **/
    624 EFI_STATUS
    625 ParseOpCodes (
    626   IN FORM_BROWSER_FORMSET              *FormSet
    627   );
    628 
    629 /**
    630   Free resources allocated for a FormSet.
    631 
    632   @param  FormSet                Pointer of the FormSet
    633 
    634 **/
    635 VOID
    636 DestroyFormSet (
    637   IN OUT FORM_BROWSER_FORMSET  *FormSet
    638   );
    639 
    640 
    641 /**
    642   Create a new string in HII Package List.
    643 
    644   @param  String                 The String to be added
    645   @param  HiiHandle              The package list in the HII database to insert the
    646                                  specified string.
    647 
    648   @return The output string.
    649 
    650 **/
    651 EFI_STRING_ID
    652 NewString (
    653   IN  CHAR16                   *String,
    654   IN  EFI_HII_HANDLE           HiiHandle
    655   );
    656 
    657 /**
    658   Delete a string from HII Package List.
    659 
    660   @param  StringId               Id of the string in HII database.
    661   @param  HiiHandle              The HII package list handle.
    662 
    663   @retval EFI_SUCCESS            The string was deleted successfully.
    664 
    665 **/
    666 EFI_STATUS
    667 DeleteString (
    668   IN  EFI_STRING_ID            StringId,
    669   IN  EFI_HII_HANDLE           HiiHandle
    670   );
    671 
    672 /**
    673   Get the string based on the StringId and HII Package List Handle.
    674 
    675   @param  Token                  The String's ID.
    676   @param  HiiHandle              The package list in the HII database to search for
    677                                  the specified string.
    678 
    679   @return The output string.
    680 
    681 **/
    682 CHAR16 *
    683 GetToken (
    684   IN  EFI_STRING_ID                Token,
    685   IN  EFI_HII_HANDLE               HiiHandle
    686   );
    687 
    688 /**
    689   Get Value for given Name from a NameValue Storage.
    690 
    691   @param  Storage                The NameValue Storage.
    692   @param  Name                   The Name.
    693   @param  Value                  The retured Value.
    694   @param  GetValueFrom           Where to get source value, from EditValue or Value.
    695 
    696   @retval EFI_SUCCESS            Value found for given Name.
    697   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.
    698 
    699 **/
    700 EFI_STATUS
    701 GetValueByName (
    702   IN BROWSER_STORAGE             *Storage,
    703   IN CHAR16                      *Name,
    704   IN OUT CHAR16                  **Value,
    705   IN GET_SET_QUESTION_VALUE_WITH GetValueFrom
    706   );
    707 
    708 /**
    709   Set Value of given Name in a NameValue Storage.
    710 
    711   @param  Storage                The NameValue Storage.
    712   @param  Name                   The Name.
    713   @param  Value                  The Value to set.
    714   @param  SetValueTo             Whether update editValue or Value.
    715   @param  ReturnNode             The node use the input name.
    716 
    717   @retval EFI_SUCCESS            Value found for given Name.
    718   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.
    719 
    720 **/
    721 EFI_STATUS
    722 SetValueByName (
    723   IN  BROWSER_STORAGE             *Storage,
    724   IN  CHAR16                      *Name,
    725   IN  CHAR16                      *Value,
    726   IN  GET_SET_QUESTION_VALUE_WITH SetValueTo,
    727   OUT NAME_VALUE_NODE             **ReturnNode
    728   );
    729 
    730 /**
    731   Validate whether this question's value has changed.
    732 
    733   @param  FormSet                FormSet data structure.
    734   @param  Form                   Form data structure.
    735   @param  Question               Question to be initialized.
    736   @param  GetValueFrom           Where to get value, may from editbuffer, buffer or hii driver.
    737 
    738   @retval TRUE                   Question's value has changed.
    739   @retval FALSE                  Question's value has not changed
    740 
    741 **/
    742 BOOLEAN
    743 IsQuestionValueChanged (
    744   IN FORM_BROWSER_FORMSET             *FormSet,
    745   IN FORM_BROWSER_FORM                *Form,
    746   IN OUT FORM_BROWSER_STATEMENT       *Question,
    747   IN GET_SET_QUESTION_VALUE_WITH      GetValueFrom
    748   );
    749 
    750 /**
    751   Validate the FormSet. If the formset is not validate, remove it from the list.
    752 
    753   @param  FormSet                The input FormSet which need to validate.
    754 
    755   @retval TRUE                   The handle is validate.
    756   @retval FALSE                  The handle is invalidate.
    757 
    758 **/
    759 BOOLEAN
    760 ValidateFormSet (
    761   FORM_BROWSER_FORMSET    *FormSet
    762   );
    763 
    764 /**
    765   Update the ValueChanged status for questions.
    766 
    767   @param  FormSet                FormSet data structure.
    768   @param  Form                   Form data structure.
    769   @param  SettingScope           Setting Scope for Default action.
    770 
    771 **/
    772 VOID
    773 UpdateStatementStatus (
    774   IN FORM_BROWSER_FORMSET             *FormSet,
    775   IN FORM_BROWSER_FORM                *Form,
    776   IN BROWSER_SETTING_SCOPE            SettingScope
    777   );
    778 
    779 /**
    780   Get Question's current Value.
    781 
    782   @param  FormSet                FormSet data structure.
    783   @param  Form                   Form data structure.
    784   @param  Question               Question to be initialized.
    785   @param  GetValueFrom           Where to get value, may from editbuffer, buffer or hii driver.
    786 
    787   @retval EFI_SUCCESS            The function completed successfully.
    788 
    789 **/
    790 EFI_STATUS
    791 GetQuestionValue (
    792   IN FORM_BROWSER_FORMSET             *FormSet,
    793   IN FORM_BROWSER_FORM                *Form,
    794   IN OUT FORM_BROWSER_STATEMENT       *Question,
    795   IN GET_SET_QUESTION_VALUE_WITH      GetValueFrom
    796   );
    797 
    798 /**
    799   Save Question Value to edit copy(cached) or Storage(uncached).
    800 
    801   @param  FormSet                FormSet data structure.
    802   @param  Form                   Form data structure.
    803   @param  Question               Pointer to the Question.
    804   @param  SetValueTo             Update the question value to editbuffer , buffer or hii driver.
    805 
    806   @retval EFI_SUCCESS            The function completed successfully.
    807 
    808 **/
    809 EFI_STATUS
    810 SetQuestionValue (
    811   IN FORM_BROWSER_FORMSET             *FormSet,
    812   IN FORM_BROWSER_FORM                *Form,
    813   IN OUT FORM_BROWSER_STATEMENT       *Question,
    814   IN GET_SET_QUESTION_VALUE_WITH      SetValueTo
    815   );
    816 
    817 /**
    818   Perform inconsistent check for a Form.
    819 
    820   @param  FormSet                FormSet data structure.
    821   @param  Form                   Form data structure.
    822   @param  Question               The Question to be validated.
    823   @param  Type                   Validation type: InConsistent or NoSubmit
    824 
    825   @retval EFI_SUCCESS            Form validation pass.
    826   @retval other                  Form validation failed.
    827 
    828 **/
    829 EFI_STATUS
    830 ValidateQuestion (
    831   IN  FORM_BROWSER_FORMSET            *FormSet,
    832   IN  FORM_BROWSER_FORM               *Form,
    833   IN  FORM_BROWSER_STATEMENT          *Question,
    834   IN  UINTN                           Type
    835   );
    836 
    837 
    838 /**
    839   Discard data based on the input setting scope (Form, FormSet or System).
    840 
    841   @param  FormSet                FormSet data structure.
    842   @param  Form                   Form data structure.
    843   @param  SettingScope           Setting Scope for Discard action.
    844 
    845   @retval EFI_SUCCESS            The function completed successfully.
    846   @retval EFI_UNSUPPORTED        Unsupport SettingScope.
    847 
    848 **/
    849 EFI_STATUS
    850 DiscardForm (
    851   IN FORM_BROWSER_FORMSET             *FormSet,
    852   IN FORM_BROWSER_FORM                *Form,
    853   IN BROWSER_SETTING_SCOPE            SettingScope
    854   );
    855 
    856 /**
    857   Submit data based on the input Setting level (Form, FormSet or System).
    858 
    859   @param  FormSet                FormSet data structure.
    860   @param  Form                   Form data structure.
    861   @param  SettingScope           Setting Scope for Submit action.
    862 
    863   @retval EFI_SUCCESS            The function completed successfully.
    864   @retval EFI_UNSUPPORTED        Unsupport SettingScope.
    865 
    866 **/
    867 EFI_STATUS
    868 SubmitForm (
    869   IN FORM_BROWSER_FORMSET             *FormSet,
    870   IN FORM_BROWSER_FORM                *Form,
    871   IN BROWSER_SETTING_SCOPE            SettingScope
    872   );
    873 
    874 /**
    875   Reset Question to its default value.
    876 
    877   @param  FormSet                The form set.
    878   @param  Form                   The form.
    879   @param  Question               The question.
    880   @param  DefaultId              The Class of the default.
    881 
    882   @retval EFI_SUCCESS            Question is reset to default value.
    883 
    884 **/
    885 EFI_STATUS
    886 GetQuestionDefault (
    887   IN FORM_BROWSER_FORMSET             *FormSet,
    888   IN FORM_BROWSER_FORM                *Form,
    889   IN FORM_BROWSER_STATEMENT           *Question,
    890   IN UINT16                           DefaultId
    891   );
    892 
    893 /**
    894   Get current setting of Questions.
    895 
    896   @param  FormSet                FormSet data structure.
    897 
    898 **/
    899 VOID
    900 InitializeCurrentSetting (
    901   IN OUT FORM_BROWSER_FORMSET             *FormSet
    902   );
    903 
    904 /**
    905   Initialize the internal data structure of a FormSet.
    906 
    907   @param  Handle                 PackageList Handle
    908   @param  FormSetGuid            GUID of a formset. If not specified (NULL or zero
    909                                  GUID), take the first FormSet found in package
    910                                  list.
    911   @param  FormSet                FormSet data structure.
    912 
    913   @retval EFI_SUCCESS            The function completed successfully.
    914   @retval EFI_NOT_FOUND          The specified FormSet could not be found.
    915 
    916 **/
    917 EFI_STATUS
    918 InitializeFormSet (
    919   IN  EFI_HII_HANDLE                   Handle,
    920   IN OUT EFI_GUID                      *FormSetGuid,
    921   OUT FORM_BROWSER_FORMSET             *FormSet
    922   );
    923 
    924 /**
    925   Reset Questions to their initial value or default value in a Form, Formset or System.
    926 
    927   GetDefaultValueScope parameter decides which questions will reset
    928   to its default value.
    929 
    930   @param  FormSet                FormSet data structure.
    931   @param  Form                   Form data structure.
    932   @param  DefaultId              The Class of the default.
    933   @param  SettingScope           Setting Scope for Default action.
    934   @param  GetDefaultValueScope   Get default value scope.
    935   @param  Storage                Get default value only for this storage.
    936   @param  RetrieveValueFirst     Whether call the retrieve call back to
    937                                  get the initial value before get default
    938                                  value.
    939   @param  SkipGetAltCfg          Whether skip the get altcfg string process.
    940 
    941   @retval EFI_SUCCESS            The function completed successfully.
    942   @retval EFI_UNSUPPORTED        Unsupport SettingScope.
    943 
    944 **/
    945 EFI_STATUS
    946 ExtractDefault (
    947   IN FORM_BROWSER_FORMSET             *FormSet,
    948   IN FORM_BROWSER_FORM                *Form,
    949   IN UINT16                           DefaultId,
    950   IN BROWSER_SETTING_SCOPE            SettingScope,
    951   IN BROWSER_GET_DEFAULT_VALUE        GetDefaultValueScope,
    952   IN BROWSER_STORAGE                  *Storage,
    953   IN BOOLEAN                          RetrieveValueFirst,
    954   IN BOOLEAN                          SkipGetAltCfg
    955   );
    956 
    957 /**
    958   Initialize Question's Edit copy from Storage.
    959 
    960   @param  Selection              Selection contains the information about
    961                                  the Selection, form and formset to be displayed.
    962                                  Selection action may be updated in retrieve callback.
    963                                  If Selection is NULL, only initialize Question value.
    964   @param  FormSet                FormSet data structure.
    965   @param  Form                   Form data structure.
    966 
    967   @retval EFI_SUCCESS            The function completed successfully.
    968 
    969 **/
    970 EFI_STATUS
    971 LoadFormConfig (
    972   IN OUT UI_MENU_SELECTION    *Selection,
    973   IN FORM_BROWSER_FORMSET     *FormSet,
    974   IN FORM_BROWSER_FORM        *Form
    975   );
    976 
    977 /**
    978   Initialize Question's Edit copy from Storage for the whole Formset.
    979 
    980   @param  Selection              Selection contains the information about
    981                                  the Selection, form and formset to be displayed.
    982                                  Selection action may be updated in retrieve callback.
    983                                  If Selection is NULL, only initialize Question value.
    984   @param  FormSet                FormSet data structure.
    985 
    986   @retval EFI_SUCCESS            The function completed successfully.
    987 
    988 **/
    989 EFI_STATUS
    990 LoadFormSetConfig (
    991   IN OUT UI_MENU_SELECTION    *Selection,
    992   IN     FORM_BROWSER_FORMSET *FormSet
    993   );
    994 
    995 /**
    996   Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
    997 
    998   @param  Storage                The Storage to be conveted.
    999   @param  ConfigResp             The returned <ConfigResp>.
   1000   @param  ConfigRequest          The ConfigRequest string.
   1001   @param  GetEditBuf             Get the data from editbuffer or buffer.
   1002 
   1003   @retval EFI_SUCCESS            Convert success.
   1004   @retval EFI_INVALID_PARAMETER  Incorrect storage type.
   1005 
   1006 **/
   1007 EFI_STATUS
   1008 StorageToConfigResp (
   1009   IN BROWSER_STORAGE         *Storage,
   1010   IN CHAR16                  **ConfigResp,
   1011   IN CHAR16                  *ConfigRequest,
   1012   IN BOOLEAN                 GetEditBuf
   1013   );
   1014 
   1015 /**
   1016   Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
   1017 
   1018   @param  Storage                The Storage to receive the settings.
   1019   @param  ConfigResp             The <ConfigResp> to be converted.
   1020 
   1021   @retval EFI_SUCCESS            Convert success.
   1022   @retval EFI_INVALID_PARAMETER  Incorrect storage type.
   1023 
   1024 **/
   1025 EFI_STATUS
   1026 ConfigRespToStorage (
   1027   IN BROWSER_STORAGE         *Storage,
   1028   IN CHAR16                  *ConfigResp
   1029   );
   1030 
   1031 /**
   1032   Fill storage's edit copy with settings requested from Configuration Driver.
   1033 
   1034   @param  FormSet                FormSet data structure.
   1035   @param  Storage                Buffer Storage.
   1036 
   1037 **/
   1038 VOID
   1039 LoadStorage (
   1040   IN FORM_BROWSER_FORMSET    *FormSet,
   1041   IN FORMSET_STORAGE         *Storage
   1042   );
   1043 
   1044 /**
   1045   Fetch the Ifr binary data of a FormSet.
   1046 
   1047   @param  Handle                 PackageList Handle
   1048   @param  FormSetGuid            GUID of a formset. If not specified (NULL or zero
   1049                                  GUID), take the first FormSet found in package
   1050                                  list.
   1051   @param  BinaryLength           The length of the FormSet IFR binary.
   1052   @param  BinaryData             The buffer designed to receive the FormSet.
   1053 
   1054   @retval EFI_SUCCESS            Buffer filled with the requested FormSet.
   1055                                  BufferLength was updated.
   1056   @retval EFI_INVALID_PARAMETER  The handle is unknown.
   1057   @retval EFI_NOT_FOUND          A form or FormSet on the requested handle cannot
   1058                                  be found with the requested FormId.
   1059 
   1060 **/
   1061 EFI_STATUS
   1062 GetIfrBinaryData (
   1063   IN  EFI_HII_HANDLE   Handle,
   1064   IN OUT EFI_GUID      *FormSetGuid,
   1065   OUT UINTN            *BinaryLength,
   1066   OUT UINT8            **BinaryData
   1067   );
   1068 
   1069 /**
   1070   Save globals used by previous call to SendForm(). SendForm() may be called from
   1071   HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
   1072   So, save globals of previous call to SendForm() and restore them upon exit.
   1073 
   1074 **/
   1075 VOID
   1076 SaveBrowserContext (
   1077   VOID
   1078   );
   1079 
   1080 /**
   1081   Restore globals used by previous call to SendForm().
   1082 
   1083 **/
   1084 VOID
   1085 RestoreBrowserContext (
   1086   VOID
   1087   );
   1088 
   1089 /**
   1090   This is the routine which an external caller uses to direct the browser
   1091   where to obtain it's information.
   1092 
   1093 
   1094   @param This            The Form Browser protocol instanse.
   1095   @param Handles         A pointer to an array of Handles.  If HandleCount > 1 we
   1096                          display a list of the formsets for the handles specified.
   1097   @param HandleCount     The number of Handles specified in Handle.
   1098   @param FormSetGuid     This field points to the EFI_GUID which must match the Guid
   1099                          field in the EFI_IFR_FORM_SET op-code for the specified
   1100                          forms-based package. If FormSetGuid is NULL, then this
   1101                          function will display the first found forms package.
   1102   @param FormId          This field specifies which EFI_IFR_FORM to render as the first
   1103                          displayable page. If this field has a value of 0x0000, then
   1104                          the forms browser will render the specified forms in their encoded order.
   1105                          ScreenDimenions - This allows the browser to be called so that it occupies a
   1106                          portion of the physical screen instead of dynamically determining the screen dimensions.
   1107                          ActionRequest   - Points to the action recommended by the form.
   1108   @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
   1109                           characters.
   1110   @param ActionRequest       Points to the action recommended by the form.
   1111 
   1112   @retval  EFI_SUCCESS            The function completed successfully.
   1113   @retval  EFI_INVALID_PARAMETER  One of the parameters has an invalid value.
   1114   @retval  EFI_NOT_FOUND          No valid forms could be found to display.
   1115 
   1116 **/
   1117 EFI_STATUS
   1118 EFIAPI
   1119 SendForm (
   1120   IN  CONST EFI_FORM_BROWSER2_PROTOCOL *This,
   1121   IN  EFI_HII_HANDLE                   *Handles,
   1122   IN  UINTN                            HandleCount,
   1123   IN  EFI_GUID                         *FormSetGuid, OPTIONAL
   1124   IN  UINT16                           FormId, OPTIONAL
   1125   IN  CONST EFI_SCREEN_DESCRIPTOR      *ScreenDimensions, OPTIONAL
   1126   OUT EFI_BROWSER_ACTION_REQUEST       *ActionRequest  OPTIONAL
   1127   );
   1128 
   1129 /**
   1130   This function is called by a callback handler to retrieve uncommitted state
   1131   data from the browser.
   1132 
   1133   @param  This                   A pointer to the EFI_FORM_BROWSER2_PROTOCOL
   1134                                  instance.
   1135   @param  ResultsDataSize        A pointer to the size of the buffer associated
   1136                                  with ResultsData.
   1137   @param  ResultsData            A string returned from an IFR browser or
   1138                                  equivalent. The results string will have no
   1139                                  routing information in them.
   1140   @param  RetrieveData           A BOOLEAN field which allows an agent to retrieve
   1141                                  (if RetrieveData = TRUE) data from the uncommitted
   1142                                  browser state information or set (if RetrieveData
   1143                                  = FALSE) data in the uncommitted browser state
   1144                                  information.
   1145   @param  VariableGuid           An optional field to indicate the target variable
   1146                                  GUID name to use.
   1147   @param  VariableName           An optional field to indicate the target
   1148                                  human-readable variable name.
   1149 
   1150   @retval EFI_SUCCESS            The results have been distributed or are awaiting
   1151                                  distribution.
   1152   @retval EFI_BUFFER_TOO_SMALL   The ResultsDataSize specified was too small to
   1153                                  contain the results data.
   1154 
   1155 **/
   1156 EFI_STATUS
   1157 EFIAPI
   1158 BrowserCallback (
   1159   IN CONST EFI_FORM_BROWSER2_PROTOCOL  *This,
   1160   IN OUT UINTN                         *ResultsDataSize,
   1161   IN OUT EFI_STRING                    ResultsData,
   1162   IN BOOLEAN                           RetrieveData,
   1163   IN CONST EFI_GUID                    *VariableGuid, OPTIONAL
   1164   IN CONST CHAR16                      *VariableName  OPTIONAL
   1165   );
   1166 
   1167 /**
   1168   Find menu which will show next time.
   1169 
   1170   @param Selection       On input, Selection tell setup browser the information
   1171                          about the Selection, form and formset to be displayed.
   1172                          On output, Selection return the screen item that is selected
   1173                          by user.
   1174   @param SettingLevel    Input Settting level, if it is FormLevel, just exit current form.
   1175                          else, we need to exit current formset.
   1176 
   1177   @retval TRUE           Exit current form.
   1178   @retval FALSE          User press ESC and keep in current form.
   1179 **/
   1180 BOOLEAN
   1181 FindNextMenu (
   1182   IN OUT UI_MENU_SELECTION        *Selection,
   1183   IN       BROWSER_SETTING_SCOPE  SettingLevel
   1184   );
   1185 
   1186 /**
   1187   check whether the form need to update the NV.
   1188 
   1189   @param  Form                Form data structure.
   1190 
   1191   @retval TRUE                   Need to update the NV.
   1192   @retval FALSE                  No need to update the NV.
   1193 **/
   1194 BOOLEAN
   1195 IsNvUpdateRequiredForForm (
   1196   IN FORM_BROWSER_FORM    *Form
   1197   );
   1198 
   1199 /**
   1200   check whether the formset need to update the NV.
   1201 
   1202   @param  FormSet                FormSet data structure.
   1203 
   1204   @retval TRUE                   Need to update the NV.
   1205   @retval FALSE                  No need to update the NV.
   1206 **/
   1207 BOOLEAN
   1208 IsNvUpdateRequiredForFormSet (
   1209   IN FORM_BROWSER_FORMSET  *FormSet
   1210   );
   1211 
   1212 /**
   1213   Call the call back function for the question and process the return action.
   1214 
   1215   @param Selection             On input, Selection tell setup browser the information
   1216                                about the Selection, form and formset to be displayed.
   1217                                On output, Selection return the screen item that is selected
   1218                                by user.
   1219   @param FormSet               The formset this question belong to.
   1220   @param Form                  The form this question belong to.
   1221   @param Question              The Question which need to call.
   1222   @param Action                The action request.
   1223   @param SkipSaveOrDiscard     Whether skip save or discard action.
   1224 
   1225   @retval EFI_SUCCESS          The call back function executes successfully.
   1226   @return Other value if the call back function failed to execute.
   1227 **/
   1228 EFI_STATUS
   1229 ProcessCallBackFunction (
   1230   IN OUT UI_MENU_SELECTION               *Selection,
   1231   IN     FORM_BROWSER_FORMSET            *FormSet,
   1232   IN     FORM_BROWSER_FORM               *Form,
   1233   IN     FORM_BROWSER_STATEMENT          *Question,
   1234   IN     EFI_BROWSER_ACTION              Action,
   1235   IN     BOOLEAN                         SkipSaveOrDiscard
   1236   );
   1237 
   1238 /**
   1239   Call the retrieve type call back function for one question to get the initialize data.
   1240 
   1241   This function only used when in the initialize stage, because in this stage, the
   1242   Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
   1243 
   1244   @param ConfigAccess          The config access protocol produced by the hii driver.
   1245   @param Statement             The Question which need to call.
   1246   @param FormSet               The formset this question belong to.
   1247 
   1248   @retval EFI_SUCCESS          The call back function executes successfully.
   1249   @return Other value if the call back function failed to execute.
   1250 **/
   1251 EFI_STATUS
   1252 ProcessRetrieveForQuestion (
   1253   IN     EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess,
   1254   IN     FORM_BROWSER_STATEMENT          *Statement,
   1255   IN     FORM_BROWSER_FORMSET            *FormSet
   1256   );
   1257 
   1258 /**
   1259   Find the matched FormSet context in the backup maintain list based on HiiHandle.
   1260 
   1261   @param Handle  The Hii Handle.
   1262 
   1263   @return the found FormSet context. If no found, NULL will return.
   1264 
   1265 **/
   1266 FORM_BROWSER_FORMSET *
   1267 GetFormSetFromHiiHandle (
   1268   EFI_HII_HANDLE Handle
   1269   );
   1270 
   1271 /**
   1272   Check whether the input HII handle is the FormSet that is being used.
   1273 
   1274   @param Handle  The Hii Handle.
   1275 
   1276   @retval TRUE   HII handle is being used.
   1277   @retval FALSE  HII handle is not being used.
   1278 
   1279 **/
   1280 BOOLEAN
   1281 IsHiiHandleInBrowserContext (
   1282   EFI_HII_HANDLE Handle
   1283   );
   1284 
   1285 /**
   1286   Configure what scope the hot key will impact.
   1287   All hot keys have the same scope. The mixed hot keys with the different level are not supported.
   1288   If no scope is set, the default scope will be FormSet level.
   1289   After all registered hot keys are removed, previous Scope can reset to another level.
   1290 
   1291   @param[in] Scope               Scope level to be set.
   1292 
   1293   @retval EFI_SUCCESS            Scope is set correctly.
   1294   @retval EFI_INVALID_PARAMETER  Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
   1295   @retval EFI_UNSPPORTED         Scope level is different from current one that the registered hot keys have.
   1296 
   1297 **/
   1298 EFI_STATUS
   1299 EFIAPI
   1300 SetScope (
   1301   IN BROWSER_SETTING_SCOPE Scope
   1302   );
   1303 
   1304 /**
   1305   Register the hot key with its browser action, or unregistered the hot key.
   1306   Only support hot key that is not printable character (control key, function key, etc.).
   1307   If the action value is zero, the hot key will be unregistered if it has been registered.
   1308   If the same hot key has been registered, the new action and help string will override the previous ones.
   1309 
   1310   @param[in] KeyData     A pointer to a buffer that describes the keystroke
   1311                          information for the hot key. Its type is EFI_INPUT_KEY to
   1312                          be supported by all ConsoleIn devices.
   1313   @param[in] Action      Action value that describes what action will be trigged when the hot key is pressed.
   1314   @param[in] DefaultId   Specifies the type of defaults to retrieve, which is only for DEFAULT action.
   1315   @param[in] HelpString  Help string that describes the hot key information.
   1316                          Its value may be NULL for the unregistered hot key.
   1317 
   1318   @retval EFI_SUCCESS            Hot key is registered or unregistered.
   1319   @retval EFI_INVALID_PARAMETER  KeyData is NULL.
   1320   @retval EFI_NOT_FOUND          KeyData is not found to be unregistered.
   1321   @retval EFI_UNSUPPORTED        Key represents a printable character. It is conflicted with Browser.
   1322   @retval EFI_ALREADY_STARTED    Key already been registered for one hot key.
   1323 **/
   1324 EFI_STATUS
   1325 EFIAPI
   1326 RegisterHotKey (
   1327   IN EFI_INPUT_KEY *KeyData,
   1328   IN UINT32        Action,
   1329   IN UINT16        DefaultId,
   1330   IN EFI_STRING    HelpString OPTIONAL
   1331   );
   1332 
   1333 /**
   1334   Register Exit handler function.
   1335   When more than one handler function is registered, the latter one will override the previous one.
   1336   When NULL handler is specified, the previous Exit handler will be unregistered.
   1337 
   1338   @param[in] Handler      Pointer to handler function.
   1339 
   1340 **/
   1341 VOID
   1342 EFIAPI
   1343 RegiserExitHandler (
   1344   IN EXIT_HANDLER Handler
   1345   );
   1346 
   1347 /**
   1348 
   1349   Check whether the browser data has been modified.
   1350 
   1351   @retval TRUE        Browser data is changed.
   1352   @retval FALSE       No browser data is changed.
   1353 
   1354 **/
   1355 BOOLEAN
   1356 EFIAPI
   1357 IsBrowserDataModified (
   1358   VOID
   1359   );
   1360 
   1361 /**
   1362 
   1363   Execute the action requested by the Action parameter.
   1364 
   1365   @param[in] Action     Execute the request action.
   1366   @param[in] DefaultId  The default Id info when need to load default value.
   1367 
   1368   @retval EFI_SUCCESS              Execute the request action succss.
   1369   @retval EFI_INVALID_PARAMETER    The input action value is invalid.
   1370 
   1371 **/
   1372 EFI_STATUS
   1373 EFIAPI
   1374 ExecuteAction (
   1375   IN UINT32        Action,
   1376   IN UINT16        DefaultId
   1377   );
   1378 
   1379 /**
   1380   Create reminder to let user to choose save or discard the changed browser data.
   1381   Caller can use it to actively check the changed browser data.
   1382 
   1383   @retval BROWSER_NO_CHANGES       No browser data is changed.
   1384   @retval BROWSER_SAVE_CHANGES     The changed browser data is saved.
   1385   @retval BROWSER_DISCARD_CHANGES  The changed browser data is discard.
   1386   @retval BROWSER_KEEP_CURRENT     Browser keep current changes.
   1387 
   1388 **/
   1389 UINT32
   1390 EFIAPI
   1391 SaveReminder (
   1392   VOID
   1393   );
   1394 
   1395 /**
   1396   Check whether the Reset Required for the browser
   1397 
   1398   @retval TRUE      Browser required to reset after exit.
   1399   @retval FALSE     Browser not need to reset after exit.
   1400 
   1401 **/
   1402 BOOLEAN
   1403 EFIAPI
   1404 IsResetRequired (
   1405   VOID
   1406   );
   1407 
   1408 /**
   1409   Find the registered HotKey based on KeyData.
   1410 
   1411   @param[in] KeyData     A pointer to a buffer that describes the keystroke
   1412                          information for the hot key.
   1413 
   1414   @return The registered HotKey context. If no found, NULL will return.
   1415 **/
   1416 BROWSER_HOT_KEY *
   1417 GetHotKeyFromRegisterList (
   1418   IN EFI_INPUT_KEY *KeyData
   1419   );
   1420 
   1421 /**
   1422 
   1423   Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
   1424 
   1425   @param DisplayStatement        The input FORM_DISPLAY_ENGINE_STATEMENT.
   1426 
   1427   @retval FORM_BROWSER_STATEMENT  The return FORM_BROWSER_STATEMENT info.
   1428 
   1429 **/
   1430 FORM_BROWSER_STATEMENT *
   1431 GetBrowserStatement (
   1432   IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
   1433   );
   1434 
   1435 /**
   1436   Password may be stored as encrypted by Configuration Driver. When change a
   1437   password, user will be challenged with old password. To validate user input old
   1438   password, we will send the clear text to Configuration Driver via Callback().
   1439   Configuration driver is responsible to check the passed in password and return
   1440   the validation result. If validation pass, state machine in password Callback()
   1441   will transit from BROWSER_STATE_VALIDATE_PASSWORD to BROWSER_STATE_SET_PASSWORD.
   1442   After user type in new password twice, Callback() will be invoked to send the
   1443   new password to Configuration Driver.
   1444 
   1445   @param  Selection              Pointer to UI_MENU_SELECTION.
   1446   @param  MenuOption             The MenuOption for this password Question.
   1447   @param  String                 The clear text of password.
   1448 
   1449   @retval EFI_NOT_AVAILABLE_YET  Callback() request to terminate password input.
   1450   @return In state of BROWSER_STATE_VALIDATE_PASSWORD:
   1451   @retval EFI_SUCCESS            Password correct, Browser will prompt for new
   1452                                  password.
   1453   @retval EFI_NOT_READY          Password incorrect, Browser will show error
   1454                                  message.
   1455   @retval Other                  Browser will do nothing.
   1456   @return In state of BROWSER_STATE_SET_PASSWORD:
   1457   @retval EFI_SUCCESS            Set password success.
   1458   @retval Other                  Set password failed.
   1459 
   1460 **/
   1461 EFI_STATUS
   1462 PasswordCallback (
   1463   IN  UI_MENU_SELECTION           *Selection,
   1464   IN  FORM_BROWSER_STATEMENT      *Question,
   1465   IN  CHAR16                      *String
   1466   );
   1467 
   1468 /**
   1469   Display error message for invalid password.
   1470 
   1471 **/
   1472 VOID
   1473 PasswordInvalid (
   1474   VOID
   1475   );
   1476 
   1477 /**
   1478   The worker function that send the displays to the screen. On output,
   1479   the selection made by user is returned.
   1480 
   1481   @param Selection       On input, Selection tell setup browser the information
   1482                          about the Selection, form and formset to be displayed.
   1483                          On output, Selection return the screen item that is selected
   1484                          by user.
   1485 
   1486   @retval EFI_SUCCESS    The page is displayed successfully.
   1487   @return Other value if the page failed to be diplayed.
   1488 
   1489 **/
   1490 EFI_STATUS
   1491 SetupBrowser (
   1492   IN OUT UI_MENU_SELECTION    *Selection
   1493   );
   1494 
   1495 /**
   1496   Free up the resource allocated for all strings required
   1497   by Setup Browser.
   1498 
   1499 **/
   1500 VOID
   1501 FreeBrowserStrings (
   1502   VOID
   1503   );
   1504 
   1505 /**
   1506   Create a menu with specified formset GUID and form ID, and add it as a child
   1507   of the given parent menu.
   1508 
   1509   @param  HiiHandle              Hii handle related to this formset.
   1510   @param  FormSetGuid            The Formset Guid of menu to be added.
   1511   @param  FormId                 The Form ID of menu to be added.
   1512   @param  QuestionId             The question id of this menu to be added.
   1513 
   1514   @return A pointer to the newly added menu or NULL if memory is insufficient.
   1515 
   1516 **/
   1517 FORM_ENTRY_INFO *
   1518 UiAddMenuList (
   1519   IN EFI_HII_HANDLE       HiiHandle,
   1520   IN EFI_GUID             *FormSetGuid,
   1521   IN UINT16               FormId,
   1522   IN UINT16               QuestionId
   1523   );
   1524 
   1525 /**
   1526   Search Menu with given FormSetGuid and FormId in all cached menu list.
   1527 
   1528   @param  HiiHandle              HiiHandle for FormSet.
   1529   @param  FormSetGuid            The Formset GUID of the menu to search.
   1530   @param  FormId                 The Form ID of menu to search.
   1531 
   1532   @return A pointer to menu found or NULL if not found.
   1533 
   1534 **/
   1535 FORM_ENTRY_INFO *
   1536 UiFindMenuList (
   1537   IN EFI_HII_HANDLE       HiiHandle,
   1538   IN EFI_GUID             *FormSetGuid,
   1539   IN UINT16               FormId
   1540   );
   1541 
   1542 /**
   1543   Free Menu list linked list.
   1544 
   1545   @param  MenuListHead    One Menu list point in the menu list.
   1546 
   1547 **/
   1548 VOID
   1549 UiFreeMenuList (
   1550   LIST_ENTRY   *MenuListHead
   1551   );
   1552 
   1553 /**
   1554   Find parent menu for current menu.
   1555 
   1556   @param  CurrentMenu    Current Menu
   1557   @param  SettingLevel   Whether find parent menu in Form Level or Formset level.
   1558                          In form level, just find the parent menu;
   1559                          In formset level, find the parent menu which has different
   1560                          formset guid value.
   1561 
   1562   @retval   The parent menu for current menu.
   1563 **/
   1564 FORM_ENTRY_INFO *
   1565 UiFindParentMenu (
   1566   IN FORM_ENTRY_INFO          *CurrentMenu,
   1567   IN BROWSER_SETTING_SCOPE    SettingLevel
   1568   );
   1569 
   1570 /**
   1571   Validate the HiiHandle.
   1572 
   1573   @param  HiiHandle              The input HiiHandle which need to validate.
   1574 
   1575   @retval TRUE                   The handle is validate.
   1576   @retval FALSE                  The handle is invalidate.
   1577 
   1578 **/
   1579 BOOLEAN
   1580 ValidateHiiHandle (
   1581   EFI_HII_HANDLE          HiiHandle
   1582   );
   1583 
   1584 /**
   1585   Copy current Menu list to the new menu list.
   1586 
   1587   @param  NewMenuListHead        New create Menu list.
   1588   @param  CurrentMenuListHead    Current Menu list.
   1589 
   1590 **/
   1591 VOID
   1592 UiCopyMenuList (
   1593   OUT LIST_ENTRY   *NewMenuListHead,
   1594   IN  LIST_ENTRY   *CurrentMenuListHead
   1595   );
   1596 
   1597 /**
   1598   Search an Option of a Question by its value.
   1599 
   1600   @param  Question               The Question
   1601   @param  OptionValue            Value for Option to be searched.
   1602 
   1603   @retval Pointer                Pointer to the found Option.
   1604   @retval NULL                   Option not found.
   1605 
   1606 **/
   1607 QUESTION_OPTION *
   1608 ValueToOption (
   1609   IN FORM_BROWSER_STATEMENT   *Question,
   1610   IN EFI_HII_VALUE            *OptionValue
   1611   );
   1612 /**
   1613   Return data element in an Array by its Index.
   1614 
   1615   @param  Array                  The data array.
   1616   @param  Type                   Type of the data in this array.
   1617   @param  Index                  Zero based index for data in this array.
   1618 
   1619   @retval Value                  The data to be returned
   1620 
   1621 **/
   1622 UINT64
   1623 GetArrayData (
   1624   IN VOID                     *Array,
   1625   IN UINT8                    Type,
   1626   IN UINTN                    Index
   1627   );
   1628 
   1629 /**
   1630   Set value of a data element in an Array by its Index.
   1631 
   1632   @param  Array                  The data array.
   1633   @param  Type                   Type of the data in this array.
   1634   @param  Index                  Zero based index for data in this array.
   1635   @param  Value                  The value to be set.
   1636 
   1637 **/
   1638 VOID
   1639 SetArrayData (
   1640   IN VOID                     *Array,
   1641   IN UINT8                    Type,
   1642   IN UINTN                    Index,
   1643   IN UINT64                   Value
   1644   );
   1645 
   1646 /**
   1647    Compare two Hii value.
   1648 
   1649    @param  Value1                 Expression value to compare on left-hand.
   1650    @param  Value2                 Expression value to compare on right-hand.
   1651    @param  Result                 Return value after compare.
   1652                                   retval 0                      Two operators equal.
   1653                                   return Positive value if Value1 is greater than Value2.
   1654                                   retval Negative value if Value1 is less than Value2.
   1655    @param  HiiHandle              Only required for string compare.
   1656 
   1657    @retval other                  Could not perform compare on two values.
   1658    @retval EFI_SUCCESS            Compare the value success.
   1659 
   1660 **/
   1661 EFI_STATUS
   1662 CompareHiiValue (
   1663   IN  EFI_HII_VALUE   *Value1,
   1664   IN  EFI_HII_VALUE   *Value2,
   1665   OUT INTN            *Result,
   1666   IN  EFI_HII_HANDLE  HiiHandle OPTIONAL
   1667   );
   1668 
   1669 /**
   1670   Perform Password check.
   1671   Passwork may be encrypted by driver that requires the specific check.
   1672 
   1673   @param  Form             Form where Password Statement is in.
   1674   @param  Statement        Password statement
   1675   @param  PasswordString   Password string to be checked. It may be NULL.
   1676                            NULL means to restore password.
   1677                            "" string can be used to checked whether old password does exist.
   1678 
   1679   @return Status     Status of Password check.
   1680 **/
   1681 EFI_STATUS
   1682 EFIAPI
   1683 PasswordCheck (
   1684   IN FORM_DISPLAY_ENGINE_FORM      *Form,
   1685   IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
   1686   IN EFI_STRING                    PasswordString  OPTIONAL
   1687   );
   1688 
   1689 /**
   1690 
   1691   Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
   1692 
   1693   @param DisplayStatement        The input FORM_DISPLAY_ENGINE_STATEMENT.
   1694 
   1695   @retval FORM_BROWSER_STATEMENT  The return FORM_BROWSER_STATEMENT info.
   1696 
   1697 **/
   1698 FORM_BROWSER_STATEMENT *
   1699 GetBrowserStatement (
   1700   IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
   1701   );
   1702 
   1703 /**
   1704 
   1705   Initialize the Display form structure data.
   1706 
   1707 **/
   1708 VOID
   1709 InitializeDisplayFormData (
   1710   VOID
   1711   );
   1712 
   1713 
   1714 /**
   1715   Base on the current formset info, clean the ConfigRequest string in browser storage.
   1716 
   1717   @param  FormSet                Pointer of the FormSet
   1718 
   1719 **/
   1720 VOID
   1721 CleanBrowserStorage (
   1722   IN OUT FORM_BROWSER_FORMSET  *FormSet
   1723   );
   1724 
   1725 /**
   1726   Find HII Handle in the HII database associated with given Device Path.
   1727 
   1728   If DevicePath is NULL, then ASSERT.
   1729 
   1730   @param  DevicePath             Device Path associated with the HII package list
   1731                                  handle.
   1732   @param  FormsetGuid            The formset guid for this formset.
   1733 
   1734   @retval Handle                 HII package list Handle associated with the Device
   1735                                         Path.
   1736   @retval NULL                   Hii Package list handle is not found.
   1737 
   1738 **/
   1739 EFI_HII_HANDLE
   1740 DevicePathToHiiHandle (
   1741   IN EFI_DEVICE_PATH_PROTOCOL   *DevicePath,
   1742   IN EFI_GUID                   *FormsetGuid
   1743   );
   1744 
   1745 /**
   1746   Adjust the config request info, remove the request elements which already in AllConfigRequest string.
   1747 
   1748   @param  Storage                Form set Storage.
   1749   @param  Request                The input request string.
   1750   @param  RespString             Whether the input is ConfigRequest or ConfigResp format.
   1751 
   1752   @retval TRUE                   Has element not covered by current used elements, need to continue to call ExtractConfig
   1753   @retval FALSE                  All elements covered by current used elements.
   1754 
   1755 **/
   1756 BOOLEAN
   1757 ConfigRequestAdjust (
   1758   IN  BROWSER_STORAGE         *Storage,
   1759   IN  CHAR16                  *Request,
   1760   IN  BOOLEAN                 RespString
   1761   );
   1762 
   1763 /**
   1764   Perform question check.
   1765 
   1766   If one question has more than one check, process form high priority to low.
   1767 
   1768   @param  FormSet                FormSet data structure.
   1769   @param  Form                   Form data structure.
   1770   @param  Question               The Question to be validated.
   1771 
   1772   @retval EFI_SUCCESS            Form validation pass.
   1773   @retval other                  Form validation failed.
   1774 
   1775 **/
   1776 EFI_STATUS
   1777 ValueChangedValidation (
   1778   IN  FORM_BROWSER_FORMSET            *FormSet,
   1779   IN  FORM_BROWSER_FORM               *Form,
   1780   IN  FORM_BROWSER_STATEMENT          *Question
   1781   );
   1782 
   1783 /**
   1784   Pop up the error info.
   1785 
   1786   @param      BrowserStatus    The input browser status.
   1787   @param      HiiHandle        The HiiHandle for this error opcode.
   1788   @param      OpCode           The opcode use to get the erro info and timeout value.
   1789   @param      ErrorString      Error string used by BROWSER_NO_SUBMIT_IF.
   1790 
   1791 **/
   1792 UINT32
   1793 PopupErrorMessage (
   1794   IN UINT32                BrowserStatus,
   1795   IN EFI_HII_HANDLE        HiiHandle,
   1796   IN EFI_IFR_OP_HEADER     *OpCode, OPTIONAL
   1797   IN CHAR16                *ErrorString
   1798   );
   1799 
   1800 /**
   1801   Check whether the result is TRUE or FALSE.
   1802 
   1803   For the EFI_HII_VALUE value type is numeric, return TRUE if the
   1804   value is not 0.
   1805 
   1806   @param  Result             Input the result data.
   1807 
   1808   @retval TRUE               The result is TRUE.
   1809   @retval FALSE              The result is FALSE.
   1810 
   1811 **/
   1812 BOOLEAN
   1813 IsTrue (
   1814   IN EFI_HII_VALUE     *Result
   1815   );
   1816 
   1817 /**
   1818   Get Formset_storage base on the input varstoreid info.
   1819 
   1820   @param  FormSet                Pointer of the current FormSet.
   1821   @param  VarStoreId             Varstore ID info.
   1822 
   1823   @return Pointer to a FORMSET_STORAGE data structure.
   1824 
   1825 **/
   1826 FORMSET_STORAGE *
   1827 GetFstStgFromVarId (
   1828   IN FORM_BROWSER_FORMSET  *FormSet,
   1829   IN EFI_VARSTORE_ID       VarStoreId
   1830   );
   1831 
   1832 /**
   1833   Get Formset_storage base on the input browser storage.
   1834 
   1835   More than one formsets may share the same browser storage,
   1836   this function just get the first formset storage which
   1837   share the browser storage.
   1838 
   1839   @param  Storage              browser storage info.
   1840 
   1841   @return Pointer to a FORMSET_STORAGE data structure.
   1842 
   1843 
   1844 **/
   1845 FORMSET_STORAGE *
   1846 GetFstStgFromBrsStg (
   1847   IN BROWSER_STORAGE       *Storage
   1848   );
   1849 
   1850 /**
   1851   Reconnect the controller.
   1852 
   1853   @param DriverHandle          The controller handle which need to be reconnect.
   1854 
   1855   @retval   TRUE     do the reconnect behavior success.
   1856   @retval   FALSE    do the reconnect behavior failed.
   1857 
   1858 **/
   1859 BOOLEAN
   1860 ReconnectController (
   1861   IN EFI_HANDLE   DriverHandle
   1862   );
   1863 
   1864 /**
   1865   Converts the unicode character of the string from uppercase to lowercase.
   1866   This is a internal function.
   1867 
   1868   @param ConfigString  String to be converted
   1869 
   1870 **/
   1871 VOID
   1872 EFIAPI
   1873 HiiToLower (
   1874   IN EFI_STRING  ConfigString
   1875   );
   1876 
   1877 #endif
   1878