]> git.proxmox.com Git - mirror_edk2.git/blob - FmpDevicePkg/Library/CapsuleUpdatePolicyLibOnProtocol/CapsuleUpdatePolicyLibOnProtocol.c
ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / FmpDevicePkg / Library / CapsuleUpdatePolicyLibOnProtocol / CapsuleUpdatePolicyLibOnProtocol.c
1 /** @file
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.
6
7 Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
8 Copyright (c) 2018-2019, Intel Corporation. All rights reserved.<BR>
9
10 SPDX-License-Identifier: BSD-2-Clause-Patent
11
12 **/
13
14 #include <PiDxe.h>
15 #include <Library/CapsuleUpdatePolicyLib.h>
16 #include <Library/DebugLib.h>
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Protocol/CapsuleUpdatePolicy.h>
19
20 ///
21 /// Pointer to the EDK II Capsule Update Policy Protocol instances that is
22 /// optionally installed by a platform.
23 ///
24 EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *mCapsuleUpdatePolicy = NULL;
25
26 /**
27 Lookup the EDK II Capsule Update Policy Protocol.
28 **/
29 BOOLEAN
30 LookupCapsuleUpdatePolicyProtocol (
31 VOID
32 )
33 {
34 EFI_STATUS Status;
35
36 if (mCapsuleUpdatePolicy != NULL) {
37 return TRUE;
38 }
39 Status = gBS->LocateProtocol (
40 &gEdkiiCapsuleUpdatePolicyProtocolGuid,
41 NULL,
42 (VOID **)&mCapsuleUpdatePolicy
43 );
44 if (EFI_ERROR (Status)) {
45 mCapsuleUpdatePolicy = NULL;
46 return FALSE;
47 }
48 return TRUE;
49 }
50
51 /**
52 Determine if the system power state supports a capsule update.
53
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.
58
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.
62
63 **/
64 EFI_STATUS
65 EFIAPI
66 CheckSystemPower (
67 OUT BOOLEAN *Good
68 )
69 {
70 if (LookupCapsuleUpdatePolicyProtocol ()) {
71 return mCapsuleUpdatePolicy->CheckSystemPower (mCapsuleUpdatePolicy, Good);
72 }
73 *Good = TRUE;
74 return EFI_SUCCESS;
75 }
76
77 /**
78 Determines if the system thermal state supports a capsule update.
79
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.
84
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.
88
89 **/
90 EFI_STATUS
91 EFIAPI
92 CheckSystemThermal (
93 OUT BOOLEAN *Good
94 )
95 {
96 if (LookupCapsuleUpdatePolicyProtocol ()) {
97 return mCapsuleUpdatePolicy->CheckSystemThermal (mCapsuleUpdatePolicy, Good);
98 }
99 *Good = TRUE;
100 return EFI_SUCCESS;
101 }
102
103 /**
104 Determines if the system environment state supports a capsule update.
105
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.
110
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.
114
115 **/
116 EFI_STATUS
117 EFIAPI
118 CheckSystemEnvironment (
119 OUT BOOLEAN *Good
120 )
121 {
122 if (LookupCapsuleUpdatePolicyProtocol ()) {
123 return mCapsuleUpdatePolicy->CheckSystemEnvironment (mCapsuleUpdatePolicy, Good);
124 }
125 *Good = TRUE;
126 return EFI_SUCCESS;
127 }
128
129 /**
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.
134
135 @retval TRUE The lowest supported version check is required.
136 @retval FALSE Do not perform lowest support version check.
137
138 **/
139 BOOLEAN
140 EFIAPI
141 IsLowestSupportedVersionCheckRequired (
142 VOID
143 )
144 {
145 if (LookupCapsuleUpdatePolicyProtocol ()) {
146 return mCapsuleUpdatePolicy->IsLowestSupportedVersionCheckRequired (mCapsuleUpdatePolicy);
147 }
148 return TRUE;
149 }
150
151 /**
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.
156
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.
159
160 **/
161 BOOLEAN
162 EFIAPI
163 IsLockFmpDeviceAtLockEventGuidRequired (
164 VOID
165 )
166 {
167 if (LookupCapsuleUpdatePolicyProtocol ()) {
168 return mCapsuleUpdatePolicy->IsLockFmpDeviceAtLockEventGuidRequired (mCapsuleUpdatePolicy);
169 }
170 return TRUE;
171 }