]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
Update the code of processing device path info in browser to follow UEFI spec.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Setup.h
index eaf409b8e6afabd102be3e361633912c466877e2..8e32cb4e4a992bc47b7bfb54852298979e4af2f1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Private MACRO, structure and function definitions for Setup Browser module.\r
 \r
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -30,6 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/HiiDatabase.h>\r
 #include <Protocol/HiiString.h>\r
 #include <Protocol/UserManager.h>\r
+#include <Protocol/DevicePathFromText.h>\r
 \r
 #include <Guid/MdeModuleHii.h>\r
 #include <Guid/HiiPlatformSetupFormset.h>\r
@@ -198,6 +199,8 @@ typedef struct {
 \r
 typedef struct {\r
   UINT8               Type;\r
+  UINT8               *Buffer;\r
+  UINT16              BufferLen;\r
   EFI_IFR_TYPE_VALUE  Value;\r
 } EFI_HII_VALUE;\r
 \r
@@ -297,6 +300,14 @@ typedef struct {
 \r
 #define FORM_EXPRESSION_FROM_LINK(a)  CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)\r
 \r
+#define FORM_EXPRESSION_LIST_SIGNATURE  SIGNATURE_32 ('F', 'E', 'X', 'R')\r
+\r
+typedef struct {\r
+    UINTN               Signature;\r
+    UINTN               Count;\r
+    FORM_EXPRESSION    *Expression[1];   // Array[Count] of expressions\r
+} FORM_EXPRESSION_LIST;\r
+\r
 #define QUESTION_DEFAULT_SIGNATURE  SIGNATURE_32 ('Q', 'D', 'F', 'T')\r
 \r
 typedef struct {\r
@@ -314,19 +325,33 @@ typedef struct {
 #define QUESTION_OPTION_SIGNATURE  SIGNATURE_32 ('Q', 'O', 'P', 'T')\r
 \r
 typedef struct {\r
-  UINTN               Signature;\r
-  LIST_ENTRY          Link;\r
+  UINTN                Signature;\r
+  LIST_ENTRY           Link;\r
 \r
-  EFI_STRING_ID       Text;\r
-  UINT8               Flags;\r
-  EFI_HII_VALUE       Value;\r
-  EFI_IMAGE_ID        ImageId;\r
+  EFI_STRING_ID        Text;\r
+  UINT8                Flags;\r
+  EFI_HII_VALUE        Value;\r
+  EFI_IMAGE_ID         ImageId;\r
 \r
-  FORM_EXPRESSION     *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf\r
+  FORM_EXPRESSION_LIST *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf\r
 } QUESTION_OPTION;\r
 \r
 #define QUESTION_OPTION_FROM_LINK(a)  CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)\r
 \r
+typedef enum {\r
+  ExpressFalse = 0,\r
+  ExpressGrayOut,  \r
+  ExpressSuppress,\r
+  ExpressDisable\r
+} EXPRESS_RESULT;\r
+\r
+typedef enum {\r
+  ExpressNone = 0,\r
+  ExpressForm,  \r
+  ExpressStatement,\r
+  ExpressOption\r
+} EXPRESS_LEVEL;\r
+\r
 #define FORM_BROWSER_STATEMENT_SIGNATURE  SIGNATURE_32 ('F', 'S', 'T', 'A')\r
 \r
 typedef struct {\r
@@ -388,9 +413,7 @@ typedef struct {
 \r
   LIST_ENTRY            InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)\r
   LIST_ENTRY            NoSubmitListHead;    // nested nosubmit expression list (FORM_EXPRESSION)\r
-  FORM_EXPRESSION       *GrayOutExpression;  // nesting inside of GrayOutIf\r
-  FORM_EXPRESSION       *SuppressExpression; // nesting inside of SuppressIf\r
-  FORM_EXPRESSION       *DisableExpression;  // nesting inside of DisableIf\r
+  FORM_EXPRESSION_LIST  *Expression;         // nesting inside of GrayOutIf/DisableIf/SuppressIf\r
 \r
   FORM_EXPRESSION       *ReadExpression;     // nested EFI_IFR_READ, provide this question value by read expression.\r
   FORM_EXPRESSION       *WriteExpression;    // nested EFI_IFR_WRITE, evaluate write expression after this question value is set.\r
@@ -415,24 +438,24 @@ typedef struct {
 #define STANDARD_MAP_FORM_TYPE 0x01\r
 \r
 typedef struct {\r
-  UINTN             Signature;\r
-  LIST_ENTRY        Link;\r
+  UINTN                Signature;\r
+  LIST_ENTRY           Link;\r
 \r
-  UINT16            FormId;               // FormId of normal form or formmap form.\r
-  EFI_STRING_ID     FormTitle;            // FormTile of normal form, or FormMapMethod title of formmap form.\r
-  UINT16            FormType;             // Specific form type for the different form.\r
+  UINT16               FormId;               // FormId of normal form or formmap form.\r
+  EFI_STRING_ID        FormTitle;            // FormTile of normal form, or FormMapMethod title of formmap form.\r
+  UINT16               FormType;             // Specific form type for the different form.\r
 \r
-  EFI_IMAGE_ID      ImageId;\r
+  EFI_IMAGE_ID         ImageId;\r
 \r
-  BOOLEAN           ModalForm;            // Whether this is a modal form.\r
-  BOOLEAN           Locked;               // Whether this form is locked.\r
+  BOOLEAN              ModalForm;            // Whether this is a modal form.\r
+  BOOLEAN              Locked;               // Whether this form is locked.\r
 \r
-  BOOLEAN           NvUpdateRequired;     // Whether this form has NV update request.\r
+  BOOLEAN              NvUpdateRequired;     // Whether this form has NV update request.\r
 \r
-  LIST_ENTRY        ExpressionListHead;   // List of Expressions (FORM_EXPRESSION)\r
-  LIST_ENTRY        StatementListHead;    // List of Statements and Questions (FORM_BROWSER_STATEMENT)\r
-  LIST_ENTRY        ConfigRequestHead;    // List of configreques for all storage.\r
-  FORM_EXPRESSION   *SuppressExpression;  // nesting inside of SuppressIf\r
+  LIST_ENTRY           ExpressionListHead;   // List of Expressions (FORM_EXPRESSION)\r
+  LIST_ENTRY           StatementListHead;    // List of Statements and Questions (FORM_BROWSER_STATEMENT)\r
+  LIST_ENTRY           ConfigRequestHead;    // List of configreques for all storage.\r
+  FORM_EXPRESSION_LIST *SuppressExpression;  // nesting inside of SuppressIf\r
 } FORM_BROWSER_FORM;\r
 \r
 #define FORM_BROWSER_FORM_FROM_LINK(a)  CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)\r
@@ -524,6 +547,7 @@ typedef struct {
   CHAR16                *SaveChanges;\r
   CHAR16                *OptionMismatch;\r
   CHAR16                *FormSuppress;\r
+  CHAR16                *ProtocolNotFound;\r
   CHAR16                PromptBlockWidth;\r
   CHAR16                OptionBlockWidth;\r
   CHAR16                HelpBlockWidth;\r
@@ -552,9 +576,30 @@ typedef struct {
 \r
 #define BROWSER_HOT_KEY_FROM_LINK(a)  CR (a, BROWSER_HOT_KEY, Link, BROWSER_HOT_KEY_SIGNATURE)\r
 \r
+//\r
+// Scope for get defaut value. It may be GetDefaultForNoStorage, GetDefaultForStorage or GetDefaultForAll.\r
+//\r
+typedef enum {\r
+  GetDefaultForNoStorage,       // Get default value for question which not has storage.\r
+  GetDefaultForStorage,         // Get default value for question which has storage.\r
+  GetDefaultForAll,             // Get default value for all questions.\r
+  GetDefaultForMax              // Invalid value.\r
+} BROWSER_GET_DEFAULT_VALUE;\r
+\r
+//\r
+// Get/set question value from/to.\r
+//\r
+typedef enum {\r
+  GetSetValueWithEditBuffer,       // Get/Set question value from/to editbuffer in the storage.\r
+  GetSetValueWithBuffer,           // Get/Set question value from/to buffer in the storage.\r
+  GetSetValueWithHiiDriver,        // Get/Set question value from/to hii driver.\r
+  GetSetValueWithMax               // Invalid value.\r
+} GET_SET_QUESTION_VALUE_WITH;\r
+\r
 extern EFI_HII_DATABASE_PROTOCOL         *mHiiDatabase;\r
 extern EFI_HII_STRING_PROTOCOL           *mHiiString;\r
 extern EFI_HII_CONFIG_ROUTING_PROTOCOL   *mHiiConfigRouting;\r
+extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText;\r
 \r
 extern BANNER_DATA           *gBannerData;\r
 extern EFI_HII_HANDLE        gFrontPageHandle;\r
@@ -605,6 +650,7 @@ extern CHAR16            *gAdjustNumber;
 extern CHAR16            *gSaveChanges;\r
 extern CHAR16            *gOptionMismatch;\r
 extern CHAR16            *gFormSuppress;\r
+extern CHAR16            *gProtocolNotFound;\r
 \r
 extern CHAR16            gPromptBlockWidth;\r
 extern CHAR16            gOptionBlockWidth;\r
@@ -855,6 +901,7 @@ CreateDialog (
   @param  Storage                The NameValue Storage.\r
   @param  Name                   The Name.\r
   @param  Value                  The retured Value.\r
+  @param  GetValueFrom           Where to get source value, from EditValue or Value.\r
 \r
   @retval EFI_SUCCESS            Value found for given Name.\r
   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.\r
@@ -862,9 +909,10 @@ CreateDialog (
 **/\r
 EFI_STATUS\r
 GetValueByName (\r
-  IN FORMSET_STORAGE         *Storage,\r
-  IN CHAR16                  *Name,\r
-  IN OUT CHAR16              **Value\r
+  IN FORMSET_STORAGE             *Storage,\r
+  IN CHAR16                      *Name,\r
+  IN OUT CHAR16                  **Value,\r
+  IN GET_SET_QUESTION_VALUE_WITH GetValueFrom\r
   );\r
 \r
 /**\r
@@ -873,7 +921,7 @@ GetValueByName (
   @param  Storage                The NameValue Storage.\r
   @param  Name                   The Name.\r
   @param  Value                  The Value to set.\r
-  @param  Edit                   Whether update editValue or Value.\r
+  @param  SetValueTo             Whether update editValue or Value.\r
 \r
   @retval EFI_SUCCESS            Value found for given Name.\r
   @retval EFI_NOT_FOUND          No such Name found in NameValue storage.\r
@@ -881,10 +929,10 @@ GetValueByName (
 **/\r
 EFI_STATUS\r
 SetValueByName (\r
-  IN FORMSET_STORAGE         *Storage,\r
-  IN CHAR16                  *Name,\r
-  IN CHAR16                  *Value,\r
-  IN BOOLEAN                 Edit\r
+  IN FORMSET_STORAGE             *Storage,\r
+  IN CHAR16                      *Name,\r
+  IN CHAR16                      *Value,\r
+  IN GET_SET_QUESTION_VALUE_WITH SetValueTo\r
   );\r
 \r
 /**\r
@@ -893,8 +941,7 @@ SetValueByName (
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
   @param  Question               Question to be initialized.\r
-  @param  Cached                 TRUE:  get from Edit copy FALSE: get from original\r
-                                 Storage\r
+  @param  GetValueFrom           Where to get value, may from editbuffer, buffer or hii driver.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
 \r
@@ -904,7 +951,7 @@ GetQuestionValue (
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form,\r
   IN OUT FORM_BROWSER_STATEMENT       *Question,\r
-  IN BOOLEAN                          Cached\r
+  IN GET_SET_QUESTION_VALUE_WITH      GetValueFrom\r
   );\r
 \r
 /**\r
@@ -913,8 +960,7 @@ GetQuestionValue (
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
   @param  Question               Pointer to the Question.\r
-  @param  Cached                 TRUE:  set to Edit copy FALSE: set to original\r
-                                 Storage\r
+  @param  SetValueTo             Update the question value to editbuffer , buffer or hii driver.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
 \r
@@ -924,7 +970,7 @@ SetQuestionValue (
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form,\r
   IN OUT FORM_BROWSER_STATEMENT       *Question,\r
-  IN BOOLEAN                          Cached\r
+  IN GET_SET_QUESTION_VALUE_WITH      SetValueTo\r
   );\r
 \r
 /**\r
@@ -1024,6 +1070,7 @@ InitializeCurrentSetting (
                                  GUID), take the first FormSet found in package\r
                                  list.\r
   @param  FormSet                FormSet data structure.\r
+  @param  UpdateGlobalVar        Whether need to update the global variable.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
   @retval EFI_NOT_FOUND          The specified FormSet could not be found.\r
@@ -1033,16 +1080,25 @@ EFI_STATUS
 InitializeFormSet (\r
   IN  EFI_HII_HANDLE                   Handle,\r
   IN OUT EFI_GUID                      *FormSetGuid,\r
-  OUT FORM_BROWSER_FORMSET             *FormSet\r
+  OUT FORM_BROWSER_FORMSET             *FormSet,\r
+  IN  BOOLEAN                          UpdateGlobalVar                   \r
   );\r
 \r
 /**\r
-  Reset Questions to their default value in a Form, Formset or System.\r
+  Reset Questions to their initial value or default value in a Form, Formset or System.\r
+\r
+  GetDefaultValueScope parameter decides which questions will reset \r
+  to its default value.\r
 \r
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
   @param  DefaultId              The Class of the default.\r
   @param  SettingScope           Setting Scope for Default action.\r
+  @param  GetDefaultValueScope   Get default value scope.\r
+  @param  Storage                Get default value only for this storage.\r
+  @param  RetrieveValueFirst     Whether call the retrieve call back to\r
+                                 get the initial value before get default\r
+                                 value.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
   @retval EFI_UNSUPPORTED        Unsupport SettingScope.\r
@@ -1053,7 +1109,10 @@ ExtractDefault (
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form,\r
   IN UINT16                           DefaultId,\r
-  IN BROWSER_SETTING_SCOPE            SettingScope\r
+  IN BROWSER_SETTING_SCOPE            SettingScope,\r
+  IN BROWSER_GET_DEFAULT_VALUE        GetDefaultValueScope,\r
+  IN FORMSET_STORAGE                  *Storage,\r
+  IN BOOLEAN                          RetrieveValueFirst\r
   );\r
 \r
 /**\r
@@ -1062,6 +1121,7 @@ ExtractDefault (
   @param  Selection              Selection contains the information about \r
                                  the Selection, form and formset to be displayed.\r
                                  Selection action may be updated in retrieve callback.\r
+                                 If Selection is NULL, only initialize Question value.\r
   @param  FormSet                FormSet data structure.\r
   @param  Form                   Form data structure.\r
 \r
@@ -1081,6 +1141,7 @@ LoadFormConfig (
   @param  Selection              Selection contains the information about \r
                                  the Selection, form and formset to be displayed.\r
                                  Selection action may be updated in retrieve callback.\r
+                                 If Selection is NULL, only initialize Question value.\r
   @param  FormSet                FormSet data structure.\r
 \r
   @retval EFI_SUCCESS            The function completed successfully.\r
@@ -1331,6 +1392,24 @@ ProcessCallBackFunction (
   IN     EFI_BROWSER_ACTION              Action,\r
   IN     BOOLEAN                         SkipSaveOrDiscard\r
   );\r
+  \r
+/**\r
+  Call the retrieve type call back function for one question to get the initialize data.\r
+  \r
+  This function only used when in the initialize stage, because in this stage, the \r
+  Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.\r
+\r
+  @param ConfigAccess          The config access protocol produced by the hii driver.\r
+  @param Statement             The Question which need to call.\r
+\r
+  @retval EFI_SUCCESS          The call back function excutes successfully.\r
+  @return Other value if the call back function failed to excute.  \r
+**/\r
+EFI_STATUS \r
+ProcessRetrieveForQuestion (\r
+  IN     EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess,\r
+  IN     FORM_BROWSER_STATEMENT          *Statement\r
+  );\r
 \r
 /**\r
   Find the matched FormSet context in the backup maintain list based on HiiHandle.\r