]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FmpDevicePkg/FmpDxe/VariableSupport.h
OvmfPkg/PlatformPei: set the Hypervisor Features PCD
[mirror_edk2.git] / FmpDevicePkg / FmpDxe / VariableSupport.h
index b5079a9900978502c371289cd8348d4225e8f10a..f23ab11d695420d95eaff068661251380ce26efa 100644 (file)
@@ -3,7 +3,7 @@
   firmware updates.\r
 \r
   Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>\r
-  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 #ifndef __VARIABLE_SUPPORT_H__\r
 #define __VARIABLE_SUPPORT_H__\r
 \r
+///\r
+/// Default values for FMP Controller State information\r
+///\r
 #define DEFAULT_VERSION                 0x1\r
 #define DEFAULT_LOWESTSUPPORTEDVERSION  0x0\r
-#define DEFAULT_LASTATTEMPT             0x0\r
+#define DEFAULT_LASTATTEMPTSTATUS       0x0\r
+#define DEFAULT_LASTATTEMPTVERSION      0x0\r
+\r
+///\r
+/// Base UEFI Variable names for FMP Controller State information stored in\r
+/// separate variables.\r
+///\r
+#define VARNAME_VERSION             L"FmpVersion"\r
+#define VARNAME_LSV                 L"FmpLsv"\r
+#define VARNAME_LASTATTEMPTSTATUS   L"LastAttemptStatus"\r
+#define VARNAME_LASTATTEMPTVERSION  L"LastAttemptVersion"\r
+\r
+///\r
+/// Base UEFI Variable name for FMP Controller State information stored in a\r
+/// merged UEFI Variable.  If the separate UEFI Variables above are detected,\r
+/// then they are merged into a single variable and the separate variables are\r
+/// deleted.\r
+///\r
+#define VARNAME_FMPSTATE  L"FmpState"\r
+\r
+///\r
+/// FMP Controller State structure that is used to store the state of\r
+/// a controller in one combined UEFI Variable.\r
+///\r
+typedef struct {\r
+  BOOLEAN    VersionValid;\r
+  BOOLEAN    LsvValid;\r
+  BOOLEAN    LastAttemptStatusValid;\r
+  BOOLEAN    LastAttemptVersionValid;\r
+  UINT32     Version;\r
+  UINT32     Lsv;\r
+  UINT32     LastAttemptStatus;\r
+  UINT32     LastAttemptVersion;\r
+} FMP_CONTROLLER_STATE;\r
 \r
-#define VARNAME_VERSION                 L"FmpVersion"\r
-#define VARNAME_LSV                     L"FmpLsv"\r
-\r
-#define VARNAME_LASTATTEMPTSTATUS       L"LastAttemptStatus"\r
-#define VARNAME_LASTATTEMPTVERSION      L"LastAttemptVersion"\r
+/**\r
+  Generate the names of the UEFI Variables used to store state information for\r
+  a managed controller.  The UEFI Variables names are a combination of a base\r
+  name and an optional hardware instance value as a 16 character hex value.  If\r
+  the hardware instance value is 0, then the 16 character hex value is not\r
+  included.  These storage for the UEFI Variable names are allocated using the\r
+  UEFI Boot Service AllocatePool() and the pointers are stored in the Private.\r
+  The following are examples of variable names produces for hardware instance\r
+  value 0 and value 0x1234567812345678.\r
+\r
+    FmpVersion\r
+    FmpLsv\r
+    LastAttemptStatus\r
+    LastAttemptVersion\r
+    FmpDxe\r
+\r
+    FmpVersion1234567812345678\r
+    FmpLsv1234567812345678\r
+    LastAttemptStatus1234567812345678\r
+    LastAttemptVersion1234567812345678\r
+    FmpDxe1234567812345678\r
+\r
+  @param[in,out] Private  Private context structure for the managed controller.\r
+**/\r
+VOID\r
+GenerateFmpVariableNames (\r
+  IN OUT FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private\r
+  );\r
 \r
 /**\r
   Returns the value used to fill in the Version field of the\r
   variable.  If the UEFI variables does not exist, then a default version value\r
   is returned.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
 \r
-  @return  The version of the firmware image in the firmware device.\r
+  @param[in] Private  Private context structure for the managed controller.\r
 \r
+  @return  The version of the firmware image in the firmware device.\r
 **/\r
 UINT32\r
 GetVersionFromVariable (\r
-  VOID\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private\r
   );\r
 \r
 /**\r
@@ -46,15 +106,16 @@ GetVersionFromVariable (
   variable.  If the UEFI variables does not exist, then a default lowest\r
   supported version value is returned.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
+\r
+  @param[in] Private  Private context structure for the managed controller.\r
 \r
   @return  The lowest supported version of the firmware image in the firmware\r
            device.\r
-\r
 **/\r
 UINT32\r
 GetLowestSupportedVersionFromVariable (\r
-  VOID\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private\r
   );\r
 \r
 /**\r
@@ -64,14 +125,15 @@ GetLowestSupportedVersionFromVariable (
   variable.  If the UEFI variables does not exist, then a default last attempt\r
   status value is returned.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
 \r
-  @return  The last attempt status value for the most recent capsule update.\r
+  @param[in] Private  Private context structure for the managed controller.\r
 \r
+  @return  The last attempt status value for the most recent capsule update.\r
 **/\r
 UINT32\r
 GetLastAttemptStatusFromVariable (\r
-  VOID\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private\r
   );\r
 \r
 /**\r
@@ -81,83 +143,96 @@ GetLastAttemptStatusFromVariable (
   variable.  If the UEFI variables does not exist, then a default last attempt\r
   version value is returned.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
 \r
-  @return  The last attempt version value for the most recent capsule update.\r
+  @param[in] Private  Private context structure for the managed controller.\r
 \r
+  @return  The last attempt version value for the most recent capsule update.\r
 **/\r
 UINT32\r
 GetLastAttemptVersionFromVariable (\r
-  VOID\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private\r
   );\r
 \r
 /**\r
   Saves the version current of the firmware image in the firmware device to a\r
   UEFI variable.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
 \r
+  @param[in] Private  Private context structure for the managed controller.\r
   @param[in] Version  The version of the firmware image in the firmware device.\r
-\r
 **/\r
 VOID\r
 SetVersionInVariable (\r
-   UINT32  Version\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private,\r
+  IN UINT32                            Version\r
   );\r
 \r
 /**\r
   Saves the lowest supported version current of the firmware image in the\r
   firmware device to a UEFI variable.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"\r
-\r
-  @param[in] LowestSupportedVersion The lowest supported version of the firmware image\r
-                                    in the firmware device.\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
 \r
+  @param[in] Private                 Private context structure for the managed\r
+                                     controller.\r
+  @param[in] LowestSupportedVersion  The lowest supported version of the\r
+                                     firmware image in the firmware device.\r
 **/\r
 VOID\r
 SetLowestSupportedVersionInVariable (\r
-   UINT32  LowestSupportedVersion\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private,\r
+  IN UINT32                            LowestSupportedVersion\r
   );\r
 \r
 /**\r
   Saves the last attempt status value of the most recent FMP capsule update to a\r
   UEFI variable.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
 \r
+  @param[in] Private            Private context structure for the managed\r
+                                controller.\r
   @param[in] LastAttemptStatus  The last attempt status of the most recent FMP\r
                                 capsule update.\r
-\r
 **/\r
 VOID\r
 SetLastAttemptStatusInVariable (\r
-   UINT32  LastAttemptStatus\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private,\r
+  IN UINT32                            LastAttemptStatus\r
   );\r
 \r
 /**\r
   Saves the last attempt version value of the most recent FMP capsule update to\r
   a UEFI variable.\r
 \r
-  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"\r
+  UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpDxe"\r
 \r
+  @param[in] Private             Private context structure for the managed\r
+                                 controller.\r
   @param[in] LastAttemptVersion  The last attempt version value of the most\r
                                  recent FMP capsule update.\r
-\r
 **/\r
 VOID\r
 SetLastAttemptVersionInVariable (\r
-   UINT32  LastAttemptVersion\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private,\r
+  IN UINT32                            LastAttemptVersion\r
   );\r
 \r
 /**\r
   Locks all the UEFI Variables that use gEfiCallerIdGuid of the currently\r
   executing module.\r
 \r
+  @param[in] Private  Private context structure for the managed controller.\r
+\r
+  @retval  EFI_SUCCESS      All UEFI variables are locked.\r
+  @retval  EFI_UNSUPPORTED  Variable Lock Protocol not found.\r
+  @retval  Other            One of the UEFI variables could not be locked.\r
 **/\r
 EFI_STATUS\r
 LockAllFmpVariables (\r
-  VOID\r
+  IN FIRMWARE_MANAGEMENT_PRIVATE_DATA  *Private\r
   );\r
 \r
 #endif\r