2 Provides platform policy services used during a capsule update that uses the
3 services of the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL. If the
4 EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL is not available, then assume the
5 platform is in a state that supports a firmware update.
7 Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
8 Copyright (c) 2018-2019, Intel Corporation. All rights reserved.<BR>
10 SPDX-License-Identifier: BSD-2-Clause-Patent
15 #include <Library/CapsuleUpdatePolicyLib.h>
16 #include <Library/DebugLib.h>
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Protocol/CapsuleUpdatePolicy.h>
21 /// Pointer to the EDK II Capsule Update Policy Protocol instances that is
22 /// optionally installed by a platform.
24 EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL
*mCapsuleUpdatePolicy
= NULL
;
27 Lookup the EDK II Capsule Update Policy Protocol.
30 LookupCapsuleUpdatePolicyProtocol (
36 if (mCapsuleUpdatePolicy
!= NULL
) {
39 Status
= gBS
->LocateProtocol (
40 &gEdkiiCapsuleUpdatePolicyProtocolGuid
,
42 (VOID
**)&mCapsuleUpdatePolicy
44 if (EFI_ERROR (Status
)) {
45 mCapsuleUpdatePolicy
= NULL
;
52 Determine if the system power state supports a capsule update.
54 @param[out] Good Returns TRUE if system power state supports a capsule
55 update. Returns FALSE if system power state does not
56 support a capsule update. Return value is only valid if
57 return status is EFI_SUCCESS.
59 @retval EFI_SUCCESS Good parameter has been updated with result.
60 @retval EFI_INVALID_PARAMETER Good is NULL.
61 @retval EFI_DEVICE_ERROR System power state can not be determined.
70 if (LookupCapsuleUpdatePolicyProtocol ()) {
71 return mCapsuleUpdatePolicy
->CheckSystemPower (mCapsuleUpdatePolicy
, Good
);
78 Determines if the system thermal state supports a capsule update.
80 @param[out] Good Returns TRUE if system thermal state supports a capsule
81 update. Returns FALSE if system thermal state does not
82 support a capsule update. Return value is only valid if
83 return status is EFI_SUCCESS.
85 @retval EFI_SUCCESS Good parameter has been updated with result.
86 @retval EFI_INVALID_PARAMETER Good is NULL.
87 @retval EFI_DEVICE_ERROR System thermal state can not be determined.
96 if (LookupCapsuleUpdatePolicyProtocol ()) {
97 return mCapsuleUpdatePolicy
->CheckSystemThermal (mCapsuleUpdatePolicy
, Good
);
104 Determines if the system environment state supports a capsule update.
106 @param[out] Good Returns TRUE if system environment state supports a capsule
107 update. Returns FALSE if system environment state does not
108 support a capsule update. Return value is only valid if
109 return status is EFI_SUCCESS.
111 @retval EFI_SUCCESS Good parameter has been updated with result.
112 @retval EFI_INVALID_PARAMETER Good is NULL.
113 @retval EFI_DEVICE_ERROR System environment state can not be determined.
118 CheckSystemEnvironment (
122 if (LookupCapsuleUpdatePolicyProtocol ()) {
123 return mCapsuleUpdatePolicy
->CheckSystemEnvironment (mCapsuleUpdatePolicy
, Good
);
130 Determines if the Lowest Supported Version checks should be performed. The
131 expected result from this function is TRUE. A platform can choose to return
132 FALSE (e.g. during manufacturing or servicing) to allow a capsule update to a
133 version below the current Lowest Supported Version.
135 @retval TRUE The lowest supported version check is required.
136 @retval FALSE Do not perform lowest support version check.
141 IsLowestSupportedVersionCheckRequired (
145 if (LookupCapsuleUpdatePolicyProtocol ()) {
146 return mCapsuleUpdatePolicy
->IsLowestSupportedVersionCheckRequired (mCapsuleUpdatePolicy
);
152 Determines if the FMP device should be locked when the event specified by
153 PcdFmpDeviceLockEventGuid is signaled. The expected result from this function
154 is TRUE so the FMP device is always locked. A platform can choose to return
155 FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.
157 @retval TRUE The FMP device lock action is required at lock event guid.
158 @retval FALSE Do not perform FMP device lock at lock event guid.
163 IsLockFmpDeviceAtLockEventGuidRequired (
167 if (LookupCapsuleUpdatePolicyProtocol ()) {
168 return mCapsuleUpdatePolicy
->IsLockFmpDeviceAtLockEventGuidRequired (mCapsuleUpdatePolicy
);