--- /dev/null
+/** @file\r
+ UEFI variable support functions for Firmware Management Protocol based\r
+ firmware updates.\r
+\r
+ Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>\r
+\r
+ Redistribution and use in source and binary forms, with or without\r
+ modification, are permitted provided that the following conditions are met:\r
+ 1. Redistributions of source code must retain the above copyright notice,\r
+ this list of conditions and the following disclaimer.\r
+ 2. Redistributions in binary form must reproduce the above copyright notice,\r
+ this list of conditions and the following disclaimer in the documentation\r
+ and/or other materials provided with the distribution.\r
+\r
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\r
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\r
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+**/\r
+\r
+#ifndef __VARIABLE_SUPPORT_H__\r
+#define __VARIABLE_SUPPORT_H__\r
+\r
+#define DEFAULT_VERSION 0x1\r
+#define DEFAULT_LOWESTSUPPORTEDVERSION 0x0\r
+#define DEFAULT_LASTATTEMPT 0x0\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
+/**\r
+ Returns the value used to fill in the Version field of the\r
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
+ service of the Firmware Management Protocol. The value is read from a UEFI\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
+\r
+ @return The version of the firmware image in the firmware device.\r
+\r
+**/\r
+UINT32\r
+GetVersionFromVariable (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Returns the value used to fill in the LowestSupportedVersion field of the\r
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
+ service of the Firmware Management Protocol. The value is read from a UEFI\r
+ 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
+\r
+ @return The lowest supported version of the firmware image in the firmware\r
+ device.\r
+\r
+**/\r
+UINT32\r
+GetLowestSupportedVersionFromVariable (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Returns the value used to fill in the LastAttemptStatus field of the\r
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
+ service of the Firmware Management Protocol. The value is read from a UEFI\r
+ 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
+\r
+ @return The last attempt status value for the most recent capsule update.\r
+\r
+**/\r
+UINT32\r
+GetLastAttemptStatusFromVariable (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Returns the value used to fill in the LastAttemptVersion field of the\r
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()\r
+ service of the Firmware Management Protocol. The value is read from a UEFI\r
+ 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
+\r
+ @return The last attempt version value for the most recent capsule update.\r
+\r
+**/\r
+UINT32\r
+GetLastAttemptVersionFromVariable (\r
+ VOID\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
+\r
+ @param[in] Version The version of the firmware image in the firmware device.\r
+\r
+**/\r
+VOID\r
+SetVersionInVariable (\r
+ 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] LowestSupported The lowest supported version of the firmware image\r
+ in the firmware device.\r
+\r
+**/\r
+VOID\r
+SetLowestSupportedVersionInVariable (\r
+ 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
+\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
+ );\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
+\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
+ );\r
+\r
+/**\r
+ Locks all the UEFI Variables that use gEfiCallerIdGuid of the currently\r
+ executing module.\r
+\r
+**/\r
+EFI_STATUS\r
+LockAllFmpVariables (\r
+ VOID\r
+ );\r
+\r
+#endif\r