CapsuleUpdatePolicyDxe.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /** @file
  2. Provides platform policy services used during a capsule update that uses the
  3. services of the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL.
  4. Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include "CapsuleUpdatePolicyDxe.h"
  8. ///
  9. /// Handle for the Capsule Update Policy Protocol
  10. ///
  11. EFI_HANDLE mHandle = NULL;
  12. ///
  13. /// Capsule Update Policy Protocol instance
  14. ///
  15. EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL mCapsuleUpdatePolicy = {
  16. CapsuleUpdatePolicyCheckSystemPower,
  17. CapsuleUpdatePolicyCheckSystemThermal,
  18. CapsuleUpdatePolicyCheckSystemEnvironment,
  19. CapsuleUpdatePolicyIsLowestSupportedVersionCheckRequired,
  20. CapsuleUpdatePolicyIsLockFmpDeviceAtLockEventGuidRequired
  21. };
  22. /**
  23. Determine if the system power state supports a capsule update.
  24. @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
  25. @param[out] Good Returns TRUE if system power state supports a capsule
  26. update. Returns FALSE if system power state does not
  27. support a capsule update. Return value is only valid if
  28. return status is EFI_SUCCESS.
  29. @retval EFI_SUCCESS Good parameter has been updated with result.
  30. @retval EFI_INVALID_PARAMETER Good is NULL.
  31. @retval EFI_DEVICE_ERROR System power state can not be determined.
  32. **/
  33. EFI_STATUS
  34. EFIAPI
  35. CapsuleUpdatePolicyCheckSystemPower (
  36. IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
  37. OUT BOOLEAN *Good
  38. )
  39. {
  40. return CheckSystemPower (Good);
  41. }
  42. /**
  43. Determines if the system thermal state supports a capsule update.
  44. @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
  45. @param[out] Good Returns TRUE if system thermal state supports a capsule
  46. update. Returns FALSE if system thermal state does not
  47. support a capsule update. Return value is only valid if
  48. return status is EFI_SUCCESS.
  49. @retval EFI_SUCCESS Good parameter has been updated with result.
  50. @retval EFI_INVALID_PARAMETER Good is NULL.
  51. @retval EFI_DEVICE_ERROR System thermal state can not be determined.
  52. **/
  53. EFI_STATUS
  54. EFIAPI
  55. CapsuleUpdatePolicyCheckSystemThermal (
  56. IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
  57. OUT BOOLEAN *Good
  58. )
  59. {
  60. return CheckSystemThermal (Good);
  61. }
  62. /**
  63. Determines if the system environment state supports a capsule update.
  64. @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
  65. @param[out] Good Returns TRUE if system environment state supports a capsule
  66. update. Returns FALSE if system environment state does not
  67. support a capsule update. Return value is only valid if
  68. return status is EFI_SUCCESS.
  69. @retval EFI_SUCCESS Good parameter has been updated with result.
  70. @retval EFI_INVALID_PARAMETER Good is NULL.
  71. @retval EFI_DEVICE_ERROR System environment state can not be determined.
  72. **/
  73. EFI_STATUS
  74. EFIAPI
  75. CapsuleUpdatePolicyCheckSystemEnvironment (
  76. IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
  77. OUT BOOLEAN *Good
  78. )
  79. {
  80. return CheckSystemEnvironment (Good);
  81. }
  82. /**
  83. Determines if the Lowest Supported Version checks should be performed. The
  84. expected result from this function is TRUE. A platform can choose to return
  85. FALSE (e.g. during manufacturing or servicing) to allow a capsule update to a
  86. version below the current Lowest Supported Version.
  87. @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
  88. @retval TRUE The lowest supported version check is required.
  89. @retval FALSE Do not perform lowest support version check.
  90. **/
  91. BOOLEAN
  92. EFIAPI
  93. CapsuleUpdatePolicyIsLowestSupportedVersionCheckRequired (
  94. IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This
  95. )
  96. {
  97. return IsLowestSupportedVersionCheckRequired ();
  98. }
  99. /**
  100. Determines if the FMP device should be locked when the event specified by
  101. PcdFmpDeviceLockEventGuid is signaled. The expected result from this function
  102. is TRUE so the FMP device is always locked. A platform can choose to return
  103. FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.
  104. @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
  105. @retval TRUE The FMP device lock action is required at lock event guid.
  106. @retval FALSE Do not perform FMP device lock at lock event guid.
  107. **/
  108. BOOLEAN
  109. EFIAPI
  110. CapsuleUpdatePolicyIsLockFmpDeviceAtLockEventGuidRequired (
  111. IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This
  112. )
  113. {
  114. return IsLockFmpDeviceAtLockEventGuidRequired ();
  115. }
  116. /**
  117. The user Entry Point for module CapsuleUpdatePolicyDxe. The user code starts
  118. with this function.
  119. @param[in] ImageHandle The firmware allocated handle for the EFI image.
  120. @param[in] SystemTable A pointer to the EFI System Table.
  121. @retval EFI_SUCCESS The entry point is executed successfully.
  122. @retval other Some error occurs when executing this entry point.
  123. **/
  124. EFI_STATUS
  125. EFIAPI
  126. CapsuleUpdatePolicyInitialize (
  127. IN EFI_HANDLE ImageHandle,
  128. IN EFI_SYSTEM_TABLE *SystemTable
  129. )
  130. {
  131. EFI_STATUS Status;
  132. ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEdkiiCapsuleUpdatePolicyProtocolGuid);
  133. Status = gBS->InstallMultipleProtocolInterfaces (
  134. &mHandle,
  135. &gEdkiiCapsuleUpdatePolicyProtocolGuid,
  136. &mCapsuleUpdatePolicy,
  137. NULL
  138. );
  139. ASSERT_EFI_ERROR (Status);
  140. return Status;
  141. }