VariableSupport.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /** @file
  2. UEFI variable support functions for Firmware Management Protocol based
  3. firmware updates.
  4. Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
  5. Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #ifndef __VARIABLE_SUPPORT_H__
  9. #define __VARIABLE_SUPPORT_H__
  10. #define DEFAULT_VERSION 0x1
  11. #define DEFAULT_LOWESTSUPPORTEDVERSION 0x0
  12. #define DEFAULT_LASTATTEMPT 0x0
  13. #define VARNAME_VERSION L"FmpVersion"
  14. #define VARNAME_LSV L"FmpLsv"
  15. #define VARNAME_LASTATTEMPTSTATUS L"LastAttemptStatus"
  16. #define VARNAME_LASTATTEMPTVERSION L"LastAttemptVersion"
  17. /**
  18. Returns the value used to fill in the Version field of the
  19. EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
  20. service of the Firmware Management Protocol. The value is read from a UEFI
  21. variable. If the UEFI variables does not exist, then a default version value
  22. is returned.
  23. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
  24. @return The version of the firmware image in the firmware device.
  25. **/
  26. UINT32
  27. GetVersionFromVariable (
  28. VOID
  29. );
  30. /**
  31. Returns the value used to fill in the LowestSupportedVersion field of the
  32. EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
  33. service of the Firmware Management Protocol. The value is read from a UEFI
  34. variable. If the UEFI variables does not exist, then a default lowest
  35. supported version value is returned.
  36. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
  37. @return The lowest supported version of the firmware image in the firmware
  38. device.
  39. **/
  40. UINT32
  41. GetLowestSupportedVersionFromVariable (
  42. VOID
  43. );
  44. /**
  45. Returns the value used to fill in the LastAttemptStatus field of the
  46. EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
  47. service of the Firmware Management Protocol. The value is read from a UEFI
  48. variable. If the UEFI variables does not exist, then a default last attempt
  49. status value is returned.
  50. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
  51. @return The last attempt status value for the most recent capsule update.
  52. **/
  53. UINT32
  54. GetLastAttemptStatusFromVariable (
  55. VOID
  56. );
  57. /**
  58. Returns the value used to fill in the LastAttemptVersion field of the
  59. EFI_FIRMWARE_IMAGE_DESCRIPTOR structure that is returned by the GetImageInfo()
  60. service of the Firmware Management Protocol. The value is read from a UEFI
  61. variable. If the UEFI variables does not exist, then a default last attempt
  62. version value is returned.
  63. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
  64. @return The last attempt version value for the most recent capsule update.
  65. **/
  66. UINT32
  67. GetLastAttemptVersionFromVariable (
  68. VOID
  69. );
  70. /**
  71. Saves the version current of the firmware image in the firmware device to a
  72. UEFI variable.
  73. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpVersion"
  74. @param[in] Version The version of the firmware image in the firmware device.
  75. **/
  76. VOID
  77. SetVersionInVariable (
  78. UINT32 Version
  79. );
  80. /**
  81. Saves the lowest supported version current of the firmware image in the
  82. firmware device to a UEFI variable.
  83. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"FmpLsv"
  84. @param[in] LowestSupportedVersion The lowest supported version of the firmware image
  85. in the firmware device.
  86. **/
  87. VOID
  88. SetLowestSupportedVersionInVariable (
  89. UINT32 LowestSupportedVersion
  90. );
  91. /**
  92. Saves the last attempt status value of the most recent FMP capsule update to a
  93. UEFI variable.
  94. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptStatus"
  95. @param[in] LastAttemptStatus The last attempt status of the most recent FMP
  96. capsule update.
  97. **/
  98. VOID
  99. SetLastAttemptStatusInVariable (
  100. UINT32 LastAttemptStatus
  101. );
  102. /**
  103. Saves the last attempt version value of the most recent FMP capsule update to
  104. a UEFI variable.
  105. UEFI Variable accessed: GUID = gEfiCallerIdGuid, Name = L"LastAttemptVersion"
  106. @param[in] LastAttemptVersion The last attempt version value of the most
  107. recent FMP capsule update.
  108. **/
  109. VOID
  110. SetLastAttemptVersionInVariable (
  111. UINT32 LastAttemptVersion
  112. );
  113. /**
  114. Locks all the UEFI Variables that use gEfiCallerIdGuid of the currently
  115. executing module.
  116. **/
  117. EFI_STATUS
  118. LockAllFmpVariables (
  119. VOID
  120. );
  121. #endif