]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Presentation.c
index 08d46cf5542334ebc91eb47f20cb5d0886e93147..d7927725b231cc46e65dbd7739a42baf2946b7e1 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
 Utility functions for UI presentation.\r
 \r
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -74,7 +68,7 @@ EvaluateFormExpressions (
   Base on the opcode buffer info to get the display statement.\r
 \r
   @param OpCode    The input opcode buffer for this statement.\r
-  \r
+\r
   @retval Statement  The statement use this opcode buffer.\r
 \r
 **/\r
@@ -103,7 +97,7 @@ GetDisplayStatement (
   Free the refresh event list.\r
 \r
 **/\r
-VOID \r
+VOID\r
 FreeRefreshEvent (\r
   VOID\r
   )\r
@@ -123,7 +117,7 @@ FreeRefreshEvent (
 }\r
 \r
 /**\r
-  Check whether this statement value is changed. If yes, update the statement value and return TRUE; \r
+  Check whether this statement value is changed. If yes, update the statement value and return TRUE;\r
   else return FALSE.\r
 \r
   @param Statement           The statement need to check.\r
@@ -145,7 +139,7 @@ UpdateStatement (
   // Question value may be changed, need invoke its Callback()\r
   //\r
   ProcessCallBackFunction (gCurrentSelection, gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, EFI_BROWSER_ACTION_RETRIEVE, FALSE);\r
-  \r
+\r
   if (mHiiPackageListUpdated) {\r
     //\r
     // Package list is updated, force to reparse IFR binary of target Formset\r
@@ -157,8 +151,8 @@ UpdateStatement (
 \r
 /**\r
   Refresh the question which has refresh guid event attribute.\r
-  \r
-  @param Event    The event which has this function related.     \r
+\r
+  @param Event    The event which has this function related.\r
   @param Context  The input context info related to this event or the status code return to the caller.\r
 **/\r
 VOID\r
@@ -177,7 +171,7 @@ RefreshEventNotifyForStatement(
 \r
 /**\r
   Refresh the questions within this form.\r
-  \r
+\r
   @param Event    The event which has this function related.\r
   @param Context  The input context info related to this event or the status code return to the caller.\r
 **/\r
@@ -450,11 +444,11 @@ UpdateHotkeyList (
 \r
   @param    QuestionId    The question id for this request question.\r
 \r
-  @retval   The attribute for this question or NULL if not found this \r
+  @retval   The attribute for this question or NULL if not found this\r
             question in the list.\r
 \r
 **/\r
-UINT32 \r
+UINT32\r
 ProcessQuestionExtraAttr (\r
   IN   EFI_QUESTION_ID  QuestionId\r
   )\r
@@ -588,7 +582,7 @@ AddStatementToDisplayForm (
     //\r
     // Get the minimal refresh interval value for later use.\r
     //\r
-    if ((Statement->RefreshInterval != 0) && \r
+    if ((Statement->RefreshInterval != 0) &&\r
       (MinRefreshInterval == 0 || Statement->RefreshInterval < MinRefreshInterval)) {\r
       MinRefreshInterval = Statement->RefreshInterval;\r
     }\r
@@ -649,7 +643,7 @@ UpdateDataChangedFlag (
 \r
   //\r
   // Base on the system level to check whether need to show the NV flag.\r
-  // \r
+  //\r
   switch (gBrowserSettingScope) {\r
   case SystemLevel:\r
     //\r
@@ -700,13 +694,13 @@ InitializeDisplayFormData (
   InitializeListHead (&gDisplayFormData.HotKeyListHead);\r
 \r
   Status = gBS->CreateEvent (\r
-        EVT_NOTIFY_WAIT, \r
+        EVT_NOTIFY_WAIT,\r
         TPL_CALLBACK,\r
         EfiEventEmptyFunction,\r
         NULL,\r
         &mValueChangedEvent\r
         );\r
-  ASSERT_EFI_ERROR (Status); \r
+  ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
 /**\r
@@ -863,7 +857,7 @@ GetBrowserStatement (
   @param  Form                   Form data structure.\r
 \r
 **/\r
-VOID \r
+VOID\r
 UpdateStatementStatusForForm (\r
   IN FORM_BROWSER_FORMSET             *FormSet,\r
   IN FORM_BROWSER_FORM                *Form\r
@@ -894,7 +888,7 @@ UpdateStatementStatusForForm (
   @param  FormSet                FormSet data structure.\r
 \r
 **/\r
-VOID \r
+VOID\r
 UpdateStatementStatusForFormSet (\r
   IN FORM_BROWSER_FORMSET                *FormSet\r
   )\r
@@ -919,10 +913,10 @@ UpdateStatementStatusForFormSet (
   @param  SettingScope           Setting Scope for Default action.\r
 \r
 **/\r
-VOID \r
+VOID\r
 UpdateStatementStatus (\r
   IN FORM_BROWSER_FORMSET             *FormSet,\r
-  IN FORM_BROWSER_FORM                *Form, \r
+  IN FORM_BROWSER_FORM                *Form,\r
   IN BROWSER_SETTING_SCOPE            SettingScope\r
   )\r
 {\r
@@ -966,7 +960,7 @@ UpdateStatementStatus (
   @retval EFI_SUCESSS            This function always return successfully for now.\r
 \r
 **/\r
-EFI_STATUS \r
+EFI_STATUS\r
 ProcessAction (\r
   IN UINT32        Action,\r
   IN UINT16        DefaultId\r
@@ -997,7 +991,8 @@ ProcessAction (
   }\r
 \r
   if ((Action & BROWSER_ACTION_RESET) == BROWSER_ACTION_RESET) {\r
-    gResetRequired = TRUE;\r
+    gResetRequiredFormLevel = TRUE;\r
+    gResetRequiredSystemLevel = TRUE;\r
   }\r
 \r
   if ((Action & BROWSER_ACTION_EXIT) == BROWSER_ACTION_EXIT) {\r
@@ -1050,7 +1045,7 @@ GetFormsetGuidFromHiiHandle (
   BufferSize     = 0;\r
   HiiPackageList = NULL;\r
   FindGuid       = FALSE;\r
-  \r
+\r
   Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, HiiHandle, &BufferSize, HiiPackageList);\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     HiiPackageList = AllocatePool (BufferSize);\r
@@ -1067,7 +1062,7 @@ GetFormsetGuidFromHiiHandle (
   //\r
   Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
   Offset2 = 0;\r
-  CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32)); \r
+  CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));\r
 \r
   while (Offset < PackageListLength) {\r
     Package = ((UINT8 *) HiiPackageList) + Offset;\r
@@ -1256,7 +1251,7 @@ ProcessChangedData (
     case BROWSER_ACTION_DISCARD:\r
       DiscardForm (Selection->FormSet, Selection->Form, Scope);\r
       break;\r
-  \r
+\r
     case BROWSER_ACTION_SUBMIT:\r
       Status = SubmitForm (Selection->FormSet, Selection->Form, Scope);\r
       if (EFI_ERROR (Status)) {\r
@@ -1330,7 +1325,7 @@ ProcessGotoOpCode (
   FORM_BROWSER_FORM               *RefForm;\r
   EFI_STATUS                      Status;\r
   EFI_HII_HANDLE                  HiiHandle;\r
-  \r
+\r
   Status    = EFI_SUCCESS;\r
   StringPtr = NULL;\r
   HiiHandle = NULL;\r
@@ -1439,7 +1434,7 @@ ProcessGotoOpCode (
     if ((RefForm != NULL) && (RefForm->SuppressExpression != NULL)) {\r
       if (EvaluateExpressionList(RefForm->SuppressExpression, TRUE, Selection->FormSet, RefForm) != ExpressFalse) {\r
         //\r
-        // Form is suppressed. \r
+        // Form is suppressed.\r
         //\r
         PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL, NULL);\r
         return EFI_SUCCESS;\r
@@ -1564,14 +1559,14 @@ ProcessUserInput (
     case EFI_IFR_REF_OP:\r
       Status = ProcessGotoOpCode(Statement, gCurrentSelection);\r
       break;\r
-    \r
+\r
     case EFI_IFR_ACTION_OP:\r
       //\r
       // Process the Config string <ConfigResp>\r
       //\r
       Status = ProcessQuestionConfig (gCurrentSelection, Statement);\r
       break;\r
-    \r
+\r
     case EFI_IFR_RESET_BUTTON_OP:\r
       //\r
       // Reset Question to default value specified by DefaultId\r
@@ -1811,9 +1806,9 @@ IsNvUpdateRequiredForForm (
                          about the Selection, form and formset to be displayed.\r
                          On output, Selection return the screen item that is selected\r
                          by user.\r
-  @param SettingLevel    Input Settting level, if it is FormLevel, just exit current form. \r
+  @param SettingLevel    Input Settting level, if it is FormLevel, just exit current form.\r
                          else, we need to exit current formset.\r
-  \r
+\r
   @retval TRUE           Exit current form.\r
   @retval FALSE          User press ESC and keep in current form.\r
 **/\r
@@ -1826,7 +1821,7 @@ FindNextMenu (
   FORM_ENTRY_INFO            *CurrentMenu;\r
   FORM_ENTRY_INFO            *ParentMenu;\r
   BROWSER_SETTING_SCOPE      Scope;\r
-  \r
+\r
   CurrentMenu = Selection->CurrentMenu;\r
   Scope       = FormSetLevel;\r
 \r
@@ -1892,7 +1887,7 @@ FindNextMenu (
 \r
   @retval   TRUE     do the reconnect behavior success.\r
   @retval   FALSE    do the reconnect behavior failed.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 ReconnectController (\r
@@ -1925,7 +1920,7 @@ ReconnectController (
   @retval EFI_SUCCESS          The call back function executes successfully.\r
   @return Other value if the call back function failed to execute.\r
 **/\r
-EFI_STATUS \r
+EFI_STATUS\r
 ProcessCallBackFunction (\r
   IN OUT UI_MENU_SELECTION               *Selection,\r
   IN     FORM_BROWSER_FORMSET            *FormSet,\r
@@ -1975,7 +1970,7 @@ ProcessCallBackFunction (
     if ((Question != NULL) && (Statement != Question)) {\r
       continue;\r
     }\r
-    \r
+\r
     if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {\r
       continue;\r
     }\r
@@ -2003,7 +1998,7 @@ ProcessCallBackFunction (
     //\r
     if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
       if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
-        BackUpBuffer = AllocateCopyPool(Statement->StorageWidth + sizeof(CHAR16), Statement->BufferValue);\r
+        BackUpBuffer = AllocateCopyPool(Statement->StorageWidth, Statement->BufferValue);\r
         ASSERT (BackUpBuffer != NULL);\r
       } else {\r
         CopyMem (&BackUpValue, &HiiValue->Value, sizeof (EFI_IFR_TYPE_VALUE));\r
@@ -2045,7 +2040,8 @@ ProcessCallBackFunction (
         switch (ActionRequest) {\r
         case EFI_BROWSER_ACTION_REQUEST_RESET:\r
           DiscardFormIsRequired = TRUE;\r
-          gResetRequired = TRUE;\r
+          gResetRequiredFormLevel = TRUE;\r
+          gResetRequiredSystemLevel = TRUE;\r
           NeedExit              = TRUE;\r
           break;\r
 \r
@@ -2102,7 +2098,7 @@ ProcessCallBackFunction (
           //\r
           IsQuestionValueChanged(gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer);\r
           //\r
-          // According the spec, return value from call back of "changing" and \r
+          // According the spec, return value from call back of "changing" and\r
           // "retrieve" should update to the question's temp buffer.\r
           //\r
           SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer);\r
@@ -2111,7 +2107,7 @@ ProcessCallBackFunction (
 \r
       case EFI_BROWSER_ACTION_RETRIEVE:\r
         //\r
-        // According the spec, return value from call back of "changing" and \r
+        // According the spec, return value from call back of "changing" and\r
         // "retrieve" should update to the question's temp buffer.\r
         //\r
         SetQuestionValue(FormSet, Form, Statement, GetSetValueWithEditBuffer);\r
@@ -2122,17 +2118,17 @@ ProcessCallBackFunction (
       }\r
     } else {\r
       //\r
-      // If the callback returns EFI_UNSUPPORTED for EFI_BROWSER_ACTION_CHANGING, \r
-      // then the browser will use the value passed to Callback() and ignore the \r
-      // value returned by Callback(). \r
+      // If the callback returns EFI_UNSUPPORTED for EFI_BROWSER_ACTION_CHANGING,\r
+      // then the browser will use the value passed to Callback() and ignore the\r
+      // value returned by Callback().\r
       //\r
       if (Action  == EFI_BROWSER_ACTION_CHANGING && Status == EFI_UNSUPPORTED) {\r
         if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
-          CopyMem (Statement->BufferValue, BackUpBuffer, Statement->StorageWidth + sizeof(CHAR16));\r
+          CopyMem (Statement->BufferValue, BackUpBuffer, Statement->StorageWidth);\r
         } else {\r
           CopyMem (&HiiValue->Value, &BackUpValue, sizeof (EFI_IFR_TYPE_VALUE));\r
         }\r
-        \r
+\r
         //\r
         // Do the question validation.\r
         //\r
@@ -2148,7 +2144,7 @@ ProcessCallBackFunction (
       }\r
 \r
       //\r
-      // According the spec, return fail from call back of "changing" and \r
+      // According the spec, return fail from call back of "changing" and\r
       // "retrieve", should restore the question's value.\r
       //\r
       if (Action == EFI_BROWSER_ACTION_CHANGING && Status != EFI_UNSUPPORTED) {\r
@@ -2224,8 +2220,8 @@ ProcessCallBackFunction (
 \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
+\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
@@ -2235,7 +2231,7 @@ ProcessCallBackFunction (
   @retval EFI_SUCCESS          The call back function executes successfully.\r
   @return Other value if the call back function failed to execute.\r
 **/\r
-EFI_STATUS \r
+EFI_STATUS\r
 ProcessRetrieveForQuestion (\r
   IN     EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess,\r
   IN     FORM_BROWSER_STATEMENT          *Statement,\r
@@ -2263,7 +2259,7 @@ ProcessRetrieveForQuestion (
     //\r
     TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue;\r
   }\r
-    \r
+\r
   ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
   Status = ConfigAccess->Callback (\r
                            ConfigAccess,\r
@@ -2355,7 +2351,7 @@ SetupBrowser (
 \r
     //\r
     // IFR is updated, force to reparse the IFR binary\r
-    // This check is shared by EFI_BROWSER_ACTION_FORM_CLOSE and \r
+    // This check is shared by EFI_BROWSER_ACTION_FORM_CLOSE and\r
     // EFI_BROWSER_ACTION_RETRIEVE, so code place here.\r
     //\r
     if (mHiiPackageListUpdated) {\r
@@ -2393,7 +2389,7 @@ SetupBrowser (
     if (Selection->Form->SuppressExpression != NULL) {\r
       if (EvaluateExpressionList(Selection->Form->SuppressExpression, TRUE, Selection->FormSet, Selection->Form) == ExpressSuppress) {\r
         //\r
-        // Form is suppressed. \r
+        // Form is suppressed.\r
         //\r
         PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL, NULL);\r
         Status = EFI_NOT_FOUND;\r
@@ -2482,8 +2478,8 @@ SetupBrowser (
     //\r
     Statement = Selection->Statement;\r
     if (Statement != NULL) {\r
-      if ((ConfigAccess != NULL) && \r
-          ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) && \r
+      if ((ConfigAccess != NULL) &&\r
+          ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) &&\r
           (Statement->Operand != EFI_IFR_PASSWORD_OP)) {\r
         Status = ProcessCallBackFunction(Selection, Selection->FormSet, Selection->Form, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE);\r
         if (Statement->Operand == EFI_IFR_REF_OP) {\r
@@ -2493,7 +2489,7 @@ SetupBrowser (
           if (!EFI_ERROR (Status)) {\r
             Status = ProcessGotoOpCode(Statement, Selection);\r
           }\r
-          \r
+\r
           //\r
           // Callback return error status or status return from process goto opcode.\r
           //\r
@@ -2510,8 +2506,8 @@ SetupBrowser (
         }\r
 \r
 \r
-        if (!EFI_ERROR (Status) && \r
-            (Statement->Operand != EFI_IFR_REF_OP) && \r
+        if (!EFI_ERROR (Status) &&\r
+            (Statement->Operand != EFI_IFR_REF_OP) &&\r
             ((Statement->Storage == NULL) || (Statement->Storage != NULL && Statement->ValueChanged))) {\r
           //\r
           // Only question value has been changed, browser will trig CHANGED callback.\r
@@ -2538,13 +2534,14 @@ SetupBrowser (
       }\r
 \r
       //\r
-      // If question has EFI_IFR_FLAG_RESET_REQUIRED/EFI_IFR_FLAG_RECONNECT_REQUIRED flag and without storage \r
+      // If question has EFI_IFR_FLAG_RESET_REQUIRED/EFI_IFR_FLAG_RECONNECT_REQUIRED flag and without storage\r
       // and process question success till here, trig the gResetFlag/gFlagReconnect.\r
       //\r
-      if ((Status == EFI_SUCCESS) && \r
-          (Statement->Storage == NULL)) { \r
+      if ((Status == EFI_SUCCESS) &&\r
+          (Statement->Storage == NULL)) {\r
         if ((Statement->QuestionFlags & EFI_IFR_FLAG_RESET_REQUIRED) != 0) {\r
-          gResetRequired = TRUE;\r
+          gResetRequiredFormLevel = TRUE;\r
+          gResetRequiredSystemLevel = TRUE;\r
         }\r
 \r
         if ((Statement->QuestionFlags & EFI_IFR_FLAG_RECONNECT_REQUIRED) != 0) {\r
@@ -2578,8 +2575,8 @@ SetupBrowser (
     // Before exit the form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE\r
     // for each question with callback flag.\r
     //\r
-    if ((ConfigAccess != NULL) && \r
-        ((Selection->Action == UI_ACTION_EXIT) || \r
+    if ((ConfigAccess != NULL) &&\r
+        ((Selection->Action == UI_ACTION_EXIT) ||\r
          (Selection->Handle != mCurrentHiiHandle) ||\r
          (!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid)) ||\r
          (Selection->FormId != mCurrentFormId))) {\r