]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c
edk2: Remove packages moved to edk2-platforms
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformSetupDxe / PlatformSetupDxe.c
diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c
deleted file mode 100644 (file)
index 0bfa3e7..0000000
+++ /dev/null
@@ -1,929 +0,0 @@
-/** @file\r
-\r
-  Copyright (c) 2004  - 2014, Intel Corporation. All rights reserved.<BR>\r
-                                                                                   \r\r
-  SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-                                                                                   \r\r
-\r
-Module Name:\r
-\r
-**/\r
-\r
-#include "PlatformSetupDxe.h"\r
-#include "Guid/SetupVariable.h"\r
-#include <Protocol/FormBrowserEx2.h>\r
-\r
-\r
-#define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')\r
-#define EFI_CALLBACK_INFO_FROM_THIS(a)  CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)\r
-\r
-typedef struct {\r
-  UINTN                           Signature;\r
-  EFI_HANDLE                      DriverHandle;\r
-  EFI_HII_HANDLE                  RegisteredHandle;\r
-  SYSTEM_CONFIGURATION            FakeNvData;\r
-  SYSTEM_CONFIGURATION            BackupNvData;\r
-  EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
-  EFI_HII_CONFIG_ACCESS_PROTOCOL  ConfigAccess;\r
-} EFI_CALLBACK_INFO;\r
-\r
-#pragma pack(1)\r
-\r
-//\r
-// HII specific Vendor Device Path definition.\r
-//\r
-typedef struct {\r
-  VENDOR_DEVICE_PATH             VendorDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL       End;\r
-} HII_VENDOR_DEVICE_PATH;\r
-\r
-#pragma pack()\r
-\r
-//\r
-// uni string and Vfr Binary data.\r
-//\r
-extern UINT8  VfrBin[];\r
-extern UINT8  PlatformSetupDxeStrings[];\r
-\r
-EFI_HANDLE            mImageHandle;\r
-\r
-//\r
-// module global data\r
-//\r
-#define EFI_NORMAL_SETUP_GUID \\r
-  { 0xec87d643, 0xeba4, 0x4bb5, 0xa1, 0xe5, 0x3f, 0x3e, 0x36, 0xb2, 0xd, 0xa9 }\r
-\r
-EFI_GUID                     mNormalSetupGuid = EFI_NORMAL_SETUP_GUID;\r
-\r
-EFI_GUID                     mSystemConfigGuid = SYSTEM_CONFIGURATION_GUID;\r
-CHAR16                       mVariableName[] = L"Setup";\r
-CHAR16                       mSetupName[] = L"Setup";\r
-EFI_CALLBACK_INFO           *mCallbackInfo;\r
-BOOLEAN                      GlobalReset=FALSE;\r
-\r
-HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePath = {\r
-  {\r
-    {\r
-      HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,\r
-      {\r
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
-      }\r
-    },\r
-    EFI_CALLER_ID_GUID\r
-  },\r
-  {\r
-    END_DEVICE_PATH_TYPE,\r
-    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    {\r
-      (UINT8) (END_DEVICE_PATH_LENGTH),\r
-      (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
-    }\r
-  }\r
-};\r
-\r
-/**\r
-  This function allows a caller to extract the current configuration for one\r
-  or more named elements from the target driver.\r
-\r
-  @param  This         Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param  Request      A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param  Progress     On return, points to a character in the Request string.\r
-                       Points to the string's null terminator if request was successful.\r
-                       Points to the most recent '&' before the first failing name/value\r
-                       pair (or the beginning of the string if the failure is in the\r
-                       first name/value pair) if the request was not successful.\r
-  @param  Results      A null-terminated Unicode string in <ConfigAltResp> format which\r
-                       has all values filled in for the names in the Request string.\r
-                       String to be allocated by the called function.\r
-\r
-  @retval EFI_SUCCESS            The Results is filled with the requested values.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough memory to store the results.\r
-  @retval EFI_INVALID_PARAMETER  Request is NULL, illegal syntax, or unknown name.\r
-  @retval EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-\r
-VOID\r
-CheckSystemConfigLoad(SYSTEM_CONFIGURATION *SystemConfigPtr);\r
-\r
-VOID\r
-CheckSystemConfigSave(SYSTEM_CONFIGURATION *SystemConfigPtr);\r
-\r
-VOID\r
-ConfirmSecureBootTest();\r
-\r
-VOID\r
-LoadLpssDefaultValues (\r
-  IN EFI_CALLBACK_INFO                       *Private\r
-  )\r
-{\r
-  //\r
-  // Load LPSS and SCC default configurations for Android\r
-  //\r
-  Private->FakeNvData.LpsseMMCEnabled            = FALSE;\r
-  Private->FakeNvData.LpssSdioEnabled            = TRUE;\r
-  Private->FakeNvData.LpssSdcardEnabled          = TRUE;\r
-  Private->FakeNvData.LpssSdCardSDR25Enabled     = FALSE;\r
-  Private->FakeNvData.LpssSdCardDDR50Enabled     = TRUE;\r
-  Private->FakeNvData.LpssMipiHsi                = FALSE;\r
-  Private->FakeNvData.LpsseMMC45Enabled          = TRUE;\r
-  Private->FakeNvData.LpsseMMC45DDR50Enabled     = TRUE;\r
-  Private->FakeNvData.LpsseMMC45HS200Enabled     = FALSE;\r
-  Private->FakeNvData.LpsseMMC45RetuneTimerValue = 8;\r
-  Private->FakeNvData.eMMCBootMode               = 1;     // Auto Detect\r
-\r
-  Private->FakeNvData.GOPEnable = TRUE;\r
-  Private->FakeNvData.SecureBoot = TRUE;\r
-  Private->FakeNvData.UsbAutoMode = TRUE;\r
-  Private->FakeNvData.UsbXhciSupport = TRUE;\r
-  Private->FakeNvData.PchUsb30Mode = TRUE;\r
-  Private->FakeNvData.LegacyUSBBooting = FALSE;\r
-  Private->FakeNvData.PchUsb20 = FALSE;\r
-}\r
-\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-SystemConfigExtractConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Request,\r
-  OUT EFI_STRING                             *Progress,\r
-  OUT EFI_STRING                             *Results\r
-  )\r
-{\r
-  EFI_STATUS                       Status;\r
-  EFI_CALLBACK_INFO                *Private;\r
-  EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
-  EFI_STRING                       ConfigRequestHdr;\r
-  EFI_STRING                       ConfigRequest;\r
-  BOOLEAN                          AllocatedRequest;\r
-  UINTN                            Size;\r
-  UINTN                            BufferSize;\r
-  VOID                             *SystemConfigPtr;\r
-\r
-\r
-  if (Progress == NULL || Results == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Progress = Request;\r
-  if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mSystemConfigGuid, mVariableName)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  ConfigRequestHdr = NULL;\r
-  ConfigRequest    = NULL;\r
-  Size             = 0;\r
-  AllocatedRequest = FALSE;\r
-\r
-  Private          = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-\r
-  SetupInfo();\r
-\r
-  HiiConfigRouting = Private->HiiConfigRouting;\r
-  ConfigRequest = Request;\r
-  if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
-    //\r
-    // Request has no request element, construct full request string.\r
-    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
-    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
-    //\r
-    ConfigRequestHdr = HiiConstructConfigHdr (&mSystemConfigGuid, mVariableName, Private->DriverHandle);\r
-    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
-    ConfigRequest = AllocateZeroPool (Size);\r
-    ASSERT (ConfigRequest != NULL);\r
-    AllocatedRequest = TRUE;\r
-    BufferSize = sizeof (SYSTEM_CONFIGURATION);\r
-    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
-    FreePool (ConfigRequestHdr);\r
-  }\r
-  SystemConfigPtr = GetVariable(mSetupName, &mNormalSetupGuid);\r
-\r
-\r
-  if (SystemConfigPtr == NULL) {\r
-    ZeroMem(&Private->FakeNvData, sizeof(SYSTEM_CONFIGURATION));\r
-    ZeroMem(&Private->BackupNvData, sizeof(SYSTEM_CONFIGURATION));\r
-  } else {\r
-    CheckSystemConfigLoad(SystemConfigPtr);\r
-    CopyMem(&Private->FakeNvData, SystemConfigPtr, sizeof(SYSTEM_CONFIGURATION));\r
-    CopyMem(&Private->BackupNvData, SystemConfigPtr, sizeof(SYSTEM_CONFIGURATION));\r
-    FreePool(SystemConfigPtr);\r
-  }\r
-\r
-  //\r
-  // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
-  //\r
-  Status = HiiConfigRouting->BlockToConfig (\r
-                               HiiConfigRouting,\r
-                               ConfigRequest,\r
-                               (UINT8 *) &Private->FakeNvData,\r
-                               sizeof (SYSTEM_CONFIGURATION),\r
-                               Results,\r
-                               Progress\r
-                               );\r
-\r
-  //\r
-  // Free the allocated config request string.\r
-  //\r
-  if (AllocatedRequest) {\r
-    FreePool (ConfigRequest);\r
-    ConfigRequest = NULL;\r
-  }\r
-\r
-  //\r
-  // Set Progress string to the original request string.\r
-  //\r
-  if (Request == NULL) {\r
-    *Progress = NULL;\r
-  } else if (StrStr (Request, L"OFFSET") == NULL) {\r
-    *Progress = Request + StrLen (Request);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function processes the results of changes in configuration.\r
-\r
-  @param  This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param  Configuration   A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param  Progress        A pointer to a string filled in with the offset of the most\r
-                          recent '&' before the first failing name/value pair (or the\r
-                          beginning of the string if the failure is in the first\r
-                          name/value pair) or the terminating NULL if all was successful.\r
-\r
-  @retval EFI_SUCCESS            The Results is processed successfully.\r
-  @retval EFI_INVALID_PARAMETER  Configuration is NULL.\r
-  @retval EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SystemConfigRouteConfig (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  CONST EFI_STRING                       Configuration,\r
-  OUT EFI_STRING                             *Progress\r
-  )\r
-{\r
-  EFI_CALLBACK_INFO                         *Private;\r
-  SYSTEM_CONFIGURATION                       *FakeNvData;\r
-\r
-  if (Configuration == NULL || Progress == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  *Progress = Configuration;\r
-\r
-  if (!HiiIsConfigHdrMatch (Configuration, &mSystemConfigGuid, mVariableName)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *Progress = Configuration + StrLen (Configuration);\r
-  Private    = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-  FakeNvData = &Private->FakeNvData;\r
-  if (!HiiGetBrowserData (&mSystemConfigGuid, mVariableName, sizeof (SYSTEM_CONFIGURATION), (UINT8 *) FakeNvData)) {\r
-    //\r
-    // FakeNvData can't be got from SetupBrowser, which doesn't need to be set.\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  if (Private->FakeNvData.ReservedO != Private->BackupNvData.ReservedO) {\r
-    Private->BackupNvData.ReservedO = Private->FakeNvData.ReservedO;\r
-    LoadLpssDefaultValues (Private);\r
-\r
-    //\r
-    // Pass changed uncommitted data back to Form Browser\r
-    //\r
-    HiiSetBrowserData (&mSystemConfigGuid, mVariableName, sizeof (SYSTEM_CONFIGURATION), (UINT8 *) FakeNvData, NULL);\r
-  }\r
-\r
-  gRT->SetVariable(\r
-         mSetupName,\r
-         &mNormalSetupGuid,\r
-         EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-         sizeof(SYSTEM_CONFIGURATION),\r
-         &Private->FakeNvData\r
-         );\r
-\r
-  CheckSystemConfigSave(&Private->FakeNvData);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  This is the function that is called to provide results data to the driver.  This data\r
-  consists of a unique key which is used to identify what data is either being passed back\r
-  or being asked for.\r
-\r
-  @param  This           Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-  @param  Action         A null-terminated Unicode string in <ConfigRequest> format.\r
-  @param  KeyValue       A unique Goto OpCode callback value which record user's selection.\r
-                         0x100 <= KeyValue <0x500 : user select a controller item in the first page;\r
-                         KeyValue == 0x1234       : user select 'Refresh' in first page, or user select 'Go to Previous Menu' in second page\r
-                         KeyValue == 0x1235       : user select 'Pci device filter' in first page\r
-                         KeyValue == 0x1500       : user select 'order ... priority' item in second page\r
-                         KeyValue == 0x1800       : user select 'commint changes' in third page\r
-                         KeyValue == 0x2000       : user select 'Go to Previous Menu' in third page\r
-  @param  Type           The type of value for the question.\r
-  @param  Value          A pointer to the data being sent to the original exporting driver.\r
-  @param  ActionRequest  On return, points to the action requested by the callback function.\r
-\r
-  @retval EFI_SUCCESS    Always returned.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-SystemConfigCallback (\r
-  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,\r
-  IN  EFI_BROWSER_ACTION                     Action,\r
-  IN  EFI_QUESTION_ID                        KeyValue,\r
-  IN  UINT8                                  Type,\r
-  IN  EFI_IFR_TYPE_VALUE                     *Value,\r
-  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest\r
-  )\r
-{\r
-  EFI_CALLBACK_INFO             *Private;\r
-  SYSTEM_CONFIGURATION          *FakeNvData;\r
-  SYSTEM_CONFIGURATION          *SetupData;\r
-  UINTN                         SizeOfNvStore;\r
-  EFI_INPUT_KEY                 Key;\r
-  CHAR16                        *StringBuffer1;\r
-  CHAR16                        *StringBuffer2;\r
-  CHAR16                        *StringBuffer3;\r
-  EFI_STATUS                    Status;\r
-  UINTN                         DataSize;\r
-  UINT8                         OsSelection;\r
-  EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;\r
-\r
-  StringBuffer1 = AllocateZeroPool (200 * sizeof (CHAR16));\r
-  ASSERT (StringBuffer1 != NULL);\r
-  StringBuffer2 = AllocateZeroPool (200 * sizeof (CHAR16));\r
-  ASSERT (StringBuffer2 != NULL);\r
-  StringBuffer3 = AllocateZeroPool (200 * sizeof (CHAR16));\r
-  ASSERT (StringBuffer3 != NULL);\r
-\r
-  switch (Action) {\r
-  case EFI_BROWSER_ACTION_CHANGING:\r
-  {\r
-    if (KeyValue == 0x1235) {\r
-      StrCpy (StringBuffer1, L"Will you disable PTT ? ");\r
-      StrCpy (StringBuffer2, L"Enter (YES)  /   Esc (NO)");\r
-\r
-      //\r
-      // Popup a menu to notice user\r
-      //\r
-      do {\r
-        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
-      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-\r
-      //\r
-      // If the user hits the YES Response key,\r
-      //\r
-      if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
-\r
-      }\r
-    } else if (KeyValue == 0x1236) {\r
-      StrCpy (StringBuffer1, L"Will you revoke trust ? ");\r
-      StrCpy (StringBuffer2, L"Enter (YES)  /   Esc (NO)");\r
-\r
-      //\r
-      // Popup a menu to notice user\r
-      //\r
-      do {\r
-        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
-      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-\r
-      //\r
-      // If the user hits the YES Response key,\r
-      //\r
-      if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
-\r
-      }\r
-        } else if (KeyValue == 0x1239) {\r
-          if (Value->u8 == 0x00) {\r
-       StrCpy (StringBuffer1, L"WARNING: SOC may be damaged due to high temperature");\r
-       StrCpy (StringBuffer2, L"when DPTF is disabled and IGD turbo is enabled.");\r
-       StrCpy (StringBuffer3, L"Press Enter/ESC to continue...");\r
-\r
-        //\r
-        // Popup a menu to notice user\r
-        //\r
-        do {\r
-          CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, StringBuffer3, NULL);\r
-        } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-    }\r
-    } else if (KeyValue == 0x1240) { // secure erase feature of eMMC\r
-           //\r
-      // Popup a menu to notice user\r
-      //\r
-      StrCpy (StringBuffer1, L"WARNING: All your data on the eMMC will be lost");\r
-      StrCpy (StringBuffer2, L"Do you really want to enable secure erase on eMMC?");\r
-      StrCpy (StringBuffer3, L"       Enter (YES)    /    Esc (NO)        ");\r
-\r
-      do {\r
-        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, StringBuffer3,NULL);\r
-      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-\r
-      //\r
-      // If the user hits the ESC Response key,\r
-      //\r
-      if (Key.ScanCode == SCAN_ESC) {\r
-        Private = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-        FakeNvData = &Private->FakeNvData;\r
-\r
-        Status = HiiGetBrowserData (\r
-                              &mSystemConfigGuid,\r
-                                          mVariableName,\r
-                                          sizeof (SYSTEM_CONFIGURATION),\r
-                                          (UINT8 *) FakeNvData\r
-                                          );\r
-        if (!EFI_ERROR (Status)) {\r
-             FakeNvData->SecureErase = 0;\r
-             HiiSetBrowserData (\r
-               &mSystemConfigGuid,\r
-               mVariableName,\r
-               sizeof (SYSTEM_CONFIGURATION),\r
-               (UINT8 *) FakeNvData,\r
-               NULL\r
-               );\r
-        }\r
-        break;\r
-      }\r
-\r
-      //\r
-      // If the user hits the YES Response key\r
-      //\r
-      if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
-        //\r
-        // Save change\r
-        //\r
-        Private = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-        FakeNvData = &Private->FakeNvData;\r
-\r
-        Status = HiiGetBrowserData (\r
-                              &mSystemConfigGuid,\r
-                                          mVariableName,\r
-                                          sizeof (SYSTEM_CONFIGURATION),\r
-                                         (UINT8 *) FakeNvData\r
-                                         );\r
-        if (!EFI_ERROR (Status)) {\r
-          Status = gRT->SetVariable (\r
-                          L"Setup",\r
-                          &mNormalSetupGuid,\r
-                          EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                          sizeof(SYSTEM_CONFIGURATION),\r
-                          &Private->FakeNvData\r
-                          );\r
-        }\r
-\r
-        //\r
-        // Reset system\r
-        //\r
-        gRT->ResetSystem(\r
-                          EfiResetCold,\r
-                                EFI_SUCCESS,\r
-                                0,\r
-                                NULL\r
-                                );\r
-\r
-    }\r
-\r
-\r
-    }\r
-    else if (KeyValue == 0xF001) {\r
-      //\r
-      // Popup a menu to notice user\r
-      //\r
-      StrCpy (StringBuffer1, L"Do you want to Commit Changes and Exit?");\r
-      StrCpy (StringBuffer2, L"         Enter (YES) / Esc (NO)        ");\r
-\r
-      do {\r
-        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
-      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-\r
-      //\r
-      // If the user hits the YES Response key\r
-      //\r
-      if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
-        //\r
-        // Save change\r
-        //\r
-        Private = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-        FakeNvData = &Private->FakeNvData;\r
-\r
-        Status = HiiGetBrowserData (\r
-                          &mSystemConfigGuid,\r
-                                  mVariableName,\r
-                                  sizeof (SYSTEM_CONFIGURATION),\r
-                                  (UINT8 *) FakeNvData\r
-                                  );\r
-        if (!EFI_ERROR (Status)) {\r
-          Status = gRT->SetVariable (\r
-                          L"Setup",\r
-                          &mNormalSetupGuid,\r
-                          EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                          sizeof(SYSTEM_CONFIGURATION),\r
-                          &Private->FakeNvData\r
-                          );\r
-        }\r
-\r
-               //\r
-               // Update Secure Boot configuration changes\r
-               //\r
-        CheckSystemConfigSave(FakeNvData);\r
-\r
-        //\r
-        // Reset system\r
-        //\r
-        if (GlobalReset == TRUE) {\r
-          //\r
-          // Issue full reset\r
-          //\r
-          IoWrite8 (\r
-            (UINTN) 0XCF9,\r
-            (UINT8) 0x02\r
-            );\r
-\r
-          IoWrite8 (\r
-            (UINTN) 0xCF9,\r
-            (UINT8) 0x0E\r
-            );\r
-        } else {\r
-               gRT->ResetSystem(\r
-                              EfiResetCold,\r
-                                  EFI_SUCCESS,\r
-                                  0,\r
-                                  NULL\r
-                                  );\r
-        }\r
-      }\r
-    } else if (KeyValue == 0xF002) {\r
-      //\r
-      // Popup a menu to notice user\r
-      //\r
-      StrCpy (StringBuffer1, L"Do you want to Discard Changes and Exit?");\r
-      StrCpy (StringBuffer2, L"         Enter (YES) / Esc (NO)         ");\r
-\r
-      do {\r
-        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
-      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-\r
-      //\r
-      // If the user hits the YES Response key\r
-      //\r
-      if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
-        //\r
-        // Reset system\r
-        //\r
-        gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);\r
-      }\r
-    } else if (KeyValue == 0xF003) {\r
-      //\r
-      // Popup a menu to notice user\r
-      //\r
-      StrCpy (StringBuffer1, L"Do you want to load setup defaults and Exit?");\r
-      StrCpy (StringBuffer2, L"         Enter (YES) / Esc (NO)             ");\r
-\r
-      do {\r
-        CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
-      } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-\r
-      //\r
-      // If the user hits the YES Response key\r
-      //\r
-      if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
-\r
-        Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **) &FormBrowserEx2);\r
-        FormBrowserEx2->ExecuteAction(BROWSER_ACTION_DEFAULT, EFI_HII_DEFAULT_CLASS_STANDARD);\r
-\r
-        FakeNvData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));\r
-\r
-        if (FakeNvData == NULL) {\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-        \r
-        Status = HiiGetBrowserData (\r
-                          &mSystemConfigGuid,\r
-                                  mVariableName,\r
-                                  sizeof (SYSTEM_CONFIGURATION),\r
-                                  (UINT8 *) FakeNvData\r
-                                  );\r
-        \r
-        if (!EFI_ERROR (Status)) {\r
-          Status = gRT->SetVariable (\r
-                          L"Setup",\r
-                          &mNormalSetupGuid,\r
-                            EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                          sizeof(SYSTEM_CONFIGURATION),\r
-                          FakeNvData\r
-                          );\r
-        }\r
-\r
-        FreePool (FakeNvData);\r
-\r
-        DataSize = sizeof(OsSelection);\r
-        Status = gRT->GetVariable(\r
-                        L"OsSelection",\r
-                        &gOsSelectionVariableGuid,\r
-                        NULL,\r
-                        &DataSize,\r
-                        &OsSelection\r
-                        );\r
-\r
-        if (EFI_ERROR(Status) || (OsSelection != FakeNvData->ReservedO)) {\r
-          OsSelection = FakeNvData->ReservedO;\r
-          Status = gRT->SetVariable (\r
-                          L"OsSelection",\r
-                          &gOsSelectionVariableGuid,\r
-                          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                          sizeof(OsSelection),\r
-                          &OsSelection\r
-                          );\r
-        }\r
-\r
-        //\r
-        // Reset system\r
-        //\r
-        gRT->ResetSystem(\r
-                      EfiResetCold,\r
-                          EFI_SUCCESS,\r
-                          0,\r
-                          NULL\r
-                          );\r
-      }\r
-    } else if ((KeyValue == 0x123A) || (KeyValue == 0x123B) || (KeyValue == 0x123C)) {\r
-        StrCpy (StringBuffer1, L"WARNING: Enable or disable USB Controllers will ");\r
-        StrCpy (StringBuffer2, L"make global reset to restart system.");\r
-        StrCpy (StringBuffer3, L"Press Enter/ESC to continue...");\r
-        //\r
-        // Popup a menu to notice user\r
-        //\r
-        do {\r
-          CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, StringBuffer3, NULL);\r
-        } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
-\r
-        FakeNvData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));\r
-        Status = HiiGetBrowserData (\r
-                          &mSystemConfigGuid,\r
-                                  mVariableName,\r
-                                  sizeof (SYSTEM_CONFIGURATION),\r
-                                  (UINT8 *) FakeNvData\r
-                                  );\r
-        //\r
-        // Get variable data\r
-        //\r
-        SizeOfNvStore = sizeof(SYSTEM_CONFIGURATION);\r
-        SetupData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));\r
-        Status = gRT->GetVariable(\r
-                        L"Setup",\r
-                        &mNormalSetupGuid,\r
-                        NULL,\r
-                        &SizeOfNvStore,\r
-                        SetupData\r
-                        );\r
-        if ((SetupData->UsbAutoMode != FakeNvData->UsbAutoMode) ||\r
-                  (SetupData->UsbXhciSupport != FakeNvData->UsbXhciSupport) ||\r
-                  (SetupData->PchUsb20 != FakeNvData->PchUsb20)) {\r
-          GlobalReset = TRUE;\r
-        } else {\r
-          GlobalReset = FALSE;\r
-        }\r
-\r
-    }\r
-  }\r
-  break;\r
-\r
-  default:\r
-    break;\r
-  }\r
-\r
-  FreePool (StringBuffer1);\r
-  FreePool (StringBuffer2);\r
-  FreePool (StringBuffer3);\r
-\r
-  //\r
-  // Workaround for Load Default for "DPTF Enable"\r
-  //\r
-  if (Action == EFI_BROWSER_ACTION_DEFAULT_STANDARD) {\r
-    if (KeyValue == 0x1239) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
-  }\r
-\r
-  if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {\r
-    //\r
-    // Do nothing for UEFI OPEN/CLOSE Action\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  Private = EFI_CALLBACK_INFO_FROM_THIS (This);\r
-  FakeNvData = &Private->FakeNvData;\r
-  if (!HiiGetBrowserData (&mSystemConfigGuid, mVariableName, sizeof (SYSTEM_CONFIGURATION), (UINT8 *) FakeNvData)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) && (Private->FakeNvData.ReservedO != Private->BackupNvData.ReservedO)) {\r
-    Private->BackupNvData.ReservedO = Private->FakeNvData.ReservedO;\r
-    LoadLpssDefaultValues (Private);\r
-  }\r
-\r
-  //\r
-  // When user selected the secure erase, set it to disable\r
-  //\r
-  if((KeyValue == 0x1240) && (Action == EFI_BROWSER_ACTION_CHANGED)) {\r
-    FakeNvData->SecureErase = 0;\r
-  }\r
-\r
-  if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_CHANGED)) {\r
-    //\r
-    // If function 0 is disabled, function 1 ~ 7 also required to be disabled.\r
-    //\r
-    if (Private->FakeNvData.LpssDma0Enabled == 0) {\r
-      Private->FakeNvData.LpssHsuart0Enabled = 0;\r
-      Private->FakeNvData.LpssHsuart1Enabled = 0;\r
-      Private->FakeNvData.LpssPwm0Enabled    = 0;\r
-      Private->FakeNvData.LpssPwm1Enabled    = 0;\r
-      Private->FakeNvData.LpssSpiEnabled     = 0;\r
-    }\r
-\r
-\r
-    //\r
-    // If function 0 is disabled, function 1 ~ 7 also required to be disabled.\r
-    //\r
-    if (Private->FakeNvData.LpssDma1Enabled == 0) {\r
-      Private->FakeNvData.LpssI2C0Enabled = 0;\r
-      Private->FakeNvData.LpssI2C1Enabled = 0;\r
-      Private->FakeNvData.LpssI2C2Enabled = 0;\r
-      Private->FakeNvData.LpssI2C3Enabled = 0;\r
-      Private->FakeNvData.LpssI2C4Enabled = 0;\r
-      Private->FakeNvData.LpssI2C5Enabled = 0;\r
-      Private->FakeNvData.LpssI2C6Enabled = 0;\r
-    }\r
-  }\r
-\r
-\r
-  //\r
-  // Pass changed uncommitted data back to Form Browser\r
-  //\r
-  HiiSetBrowserData (&mSystemConfigGuid, mVariableName, sizeof (SYSTEM_CONFIGURATION), (UINT8 *) FakeNvData, NULL);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
-  The driver Entry Point. The function will export a disk device class formset and\r
-  its callback function to hii database.\r
-\r
-  @param  ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param  SystemTable    A pointer to the EFI System Table.\r
-\r
-  @retval EFI_SUCCESS    The entry point is executed successfully.\r
-  @retval other          Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PlatformSetupDxeInit (\r
-  IN EFI_HANDLE                   ImageHandle,\r
-  IN EFI_SYSTEM_TABLE             *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_FORM_BROWSER2_PROTOCOL  *FormBrowser2;\r
-\r
-  mImageHandle = ImageHandle;\r
-\r
-  //\r
-  // There should only be one Form Configuration protocol\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                 &gEfiFormBrowser2ProtocolGuid,\r
-                 NULL,\r
-                 (VOID **) &FormBrowser2\r
-                 );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  mCallbackInfo = AllocateZeroPool (sizeof (EFI_CALLBACK_INFO));\r
-  if (mCallbackInfo == NULL) {\r
-    return EFI_BAD_BUFFER_SIZE;\r
-  }\r
-\r
-  mCallbackInfo->Signature = EFI_CALLBACK_INFO_SIGNATURE;\r
-  mCallbackInfo->ConfigAccess.ExtractConfig = SystemConfigExtractConfig;\r
-  mCallbackInfo->ConfigAccess.RouteConfig   = SystemConfigRouteConfig;\r
-  mCallbackInfo->ConfigAccess.Callback      = SystemConfigCallback;\r
-\r
-  //\r
-  // Install Device Path Protocol and Config Access protocol to driver handle\r
-  // Install Platform Driver Override Protocol to driver handle\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &mCallbackInfo->DriverHandle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  &mHiiVendorDevicePath,\r
-                  &gEfiHiiConfigAccessProtocolGuid,\r
-                  &mCallbackInfo->ConfigAccess,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Finish;\r
-  }\r
-\r
-  //\r
-  // Publish our HII data\r
-  //\r
-  mCallbackInfo->RegisteredHandle = HiiAddPackages (\r
-                                      &mSystemConfigGuid,\r
-                                      mCallbackInfo->DriverHandle,\r
-                                      VfrBin,\r
-                                      PlatformSetupDxeStrings,\r
-                                      NULL\r
-                                      );\r
-  if (mCallbackInfo->RegisteredHandle == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Finish;\r
-  }\r
-\r
-  mHiiHandle = mCallbackInfo->RegisteredHandle;\r
-\r
-  //\r
-  // Locate ConfigRouting protocol\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiHiiConfigRoutingProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &mCallbackInfo->HiiConfigRouting\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Finish;\r
-  }\r
-\r
-  //\r
-  // Clear all the globle variable\r
-  //\r
-  return EFI_SUCCESS;\r
-\r
-Finish:\r
-  if (mCallbackInfo->DriverHandle != NULL) {\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           mCallbackInfo->DriverHandle,\r
-           &gEfiDevicePathProtocolGuid,\r
-           &mHiiVendorDevicePath,\r
-           &gEfiHiiConfigAccessProtocolGuid,\r
-           &mCallbackInfo->ConfigAccess,\r
-           NULL\r
-           );\r
-  }\r
-\r
-  if (mCallbackInfo->RegisteredHandle != NULL) {\r
-    HiiRemovePackages (mCallbackInfo->RegisteredHandle);\r
-  }\r
-\r
-  if (mCallbackInfo != NULL) {\r
-    FreePool (mCallbackInfo);\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Unload its installed protocol.\r
-\r
-  @param[in]  ImageHandle       Handle that identifies the image to be unloaded.\r
-\r
-  @retval EFI_SUCCESS           The image has been unloaded.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PlatformSetupDxeUnload (\r
-  IN EFI_HANDLE  ImageHandle\r
-  )\r
-{\r
-  if (mCallbackInfo != NULL) {\r
-    if (mCallbackInfo->DriverHandle != NULL) {\r
-      gBS->UninstallMultipleProtocolInterfaces (\r
-             mCallbackInfo->DriverHandle,\r
-             &gEfiDevicePathProtocolGuid,\r
-             &mHiiVendorDevicePath,\r
-             &gEfiHiiConfigAccessProtocolGuid,\r
-             &mCallbackInfo->ConfigAccess,\r
-             NULL\r
-             );\r
-    }\r
-\r
-    if (mCallbackInfo->RegisteredHandle != NULL) {\r
-      HiiRemovePackages (mCallbackInfo->RegisteredHandle);\r
-    }\r
-\r
-    FreePool (mCallbackInfo);\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r