]> git.proxmox.com Git - mirror_edk2.git/blame - FmpDevicePkg/Library/CapsuleUpdatePolicyLibOnProtocol/CapsuleUpdatePolicyLibOnProtocol.c
ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / FmpDevicePkg / Library / CapsuleUpdatePolicyLibOnProtocol / CapsuleUpdatePolicyLibOnProtocol.c
CommitLineData
c40f7cc7
EJ
1/** @file\r
2 Provides platform policy services used during a capsule update that uses the\r
3 services of the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL. If the\r
4 EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL is not available, then assume the\r
5 platform is in a state that supports a firmware update.\r
6\r
7 Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>\r
8 Copyright (c) 2018-2019, Intel Corporation. All rights reserved.<BR>\r
9\r
10 SPDX-License-Identifier: BSD-2-Clause-Patent\r
11\r
12**/\r
13\r
14#include <PiDxe.h>\r
15#include <Library/CapsuleUpdatePolicyLib.h>\r
16#include <Library/DebugLib.h>\r
17#include <Library/UefiBootServicesTableLib.h>\r
18#include <Protocol/CapsuleUpdatePolicy.h>\r
19\r
20///\r
21/// Pointer to the EDK II Capsule Update Policy Protocol instances that is\r
22/// optionally installed by a platform.\r
23///\r
24EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *mCapsuleUpdatePolicy = NULL;\r
25\r
26/**\r
27 Lookup the EDK II Capsule Update Policy Protocol.\r
28**/\r
29BOOLEAN\r
30LookupCapsuleUpdatePolicyProtocol (\r
31 VOID\r
32 )\r
33{\r
34 EFI_STATUS Status;\r
35\r
36 if (mCapsuleUpdatePolicy != NULL) {\r
37 return TRUE;\r
38 }\r
39 Status = gBS->LocateProtocol (\r
95d28836 40 &gEdkiiCapsuleUpdatePolicyProtocolGuid,\r
c40f7cc7
EJ
41 NULL,\r
42 (VOID **)&mCapsuleUpdatePolicy\r
43 );\r
44 if (EFI_ERROR (Status)) {\r
45 mCapsuleUpdatePolicy = NULL;\r
46 return FALSE;\r
47 }\r
48 return TRUE;\r
49}\r
50\r
51/**\r
52 Determine if the system power state supports a capsule update.\r
53\r
54 @param[out] Good Returns TRUE if system power state supports a capsule\r
55 update. Returns FALSE if system power state does not\r
56 support a capsule update. Return value is only valid if\r
57 return status is EFI_SUCCESS.\r
58\r
59 @retval EFI_SUCCESS Good parameter has been updated with result.\r
60 @retval EFI_INVALID_PARAMETER Good is NULL.\r
61 @retval EFI_DEVICE_ERROR System power state can not be determined.\r
62\r
63**/\r
64EFI_STATUS\r
65EFIAPI\r
66CheckSystemPower (\r
67 OUT BOOLEAN *Good\r
68 )\r
69{\r
70 if (LookupCapsuleUpdatePolicyProtocol ()) {\r
71 return mCapsuleUpdatePolicy->CheckSystemPower (mCapsuleUpdatePolicy, Good);\r
72 }\r
73 *Good = TRUE;\r
74 return EFI_SUCCESS;\r
75}\r
76\r
77/**\r
78 Determines if the system thermal state supports a capsule update.\r
79\r
80 @param[out] Good Returns TRUE if system thermal state supports a capsule\r
81 update. Returns FALSE if system thermal state does not\r
82 support a capsule update. Return value is only valid if\r
83 return status is EFI_SUCCESS.\r
84\r
85 @retval EFI_SUCCESS Good parameter has been updated with result.\r
86 @retval EFI_INVALID_PARAMETER Good is NULL.\r
87 @retval EFI_DEVICE_ERROR System thermal state can not be determined.\r
88\r
89**/\r
90EFI_STATUS\r
91EFIAPI\r
92CheckSystemThermal (\r
93 OUT BOOLEAN *Good\r
94 )\r
95{\r
96 if (LookupCapsuleUpdatePolicyProtocol ()) {\r
97 return mCapsuleUpdatePolicy->CheckSystemThermal (mCapsuleUpdatePolicy, Good);\r
98 }\r
99 *Good = TRUE;\r
100 return EFI_SUCCESS;\r
101}\r
102\r
103/**\r
104 Determines if the system environment state supports a capsule update.\r
105\r
106 @param[out] Good Returns TRUE if system environment state supports a capsule\r
107 update. Returns FALSE if system environment state does not\r
108 support a capsule update. Return value is only valid if\r
109 return status is EFI_SUCCESS.\r
110\r
111 @retval EFI_SUCCESS Good parameter has been updated with result.\r
112 @retval EFI_INVALID_PARAMETER Good is NULL.\r
113 @retval EFI_DEVICE_ERROR System environment state can not be determined.\r
114\r
115**/\r
116EFI_STATUS\r
117EFIAPI\r
118CheckSystemEnvironment (\r
119 OUT BOOLEAN *Good\r
120 )\r
121{\r
122 if (LookupCapsuleUpdatePolicyProtocol ()) {\r
123 return mCapsuleUpdatePolicy->CheckSystemEnvironment (mCapsuleUpdatePolicy, Good);\r
124 }\r
125 *Good = TRUE;\r
126 return EFI_SUCCESS;\r
127}\r
128\r
129/**\r
130 Determines if the Lowest Supported Version checks should be performed. The\r
131 expected result from this function is TRUE. A platform can choose to return\r
132 FALSE (e.g. during manufacturing or servicing) to allow a capsule update to a\r
133 version below the current Lowest Supported Version.\r
134\r
135 @retval TRUE The lowest supported version check is required.\r
136 @retval FALSE Do not perform lowest support version check.\r
137\r
138**/\r
139BOOLEAN\r
140EFIAPI\r
141IsLowestSupportedVersionCheckRequired (\r
142 VOID\r
143 )\r
144{\r
145 if (LookupCapsuleUpdatePolicyProtocol ()) {\r
146 return mCapsuleUpdatePolicy->IsLowestSupportedVersionCheckRequired (mCapsuleUpdatePolicy);\r
147 }\r
148 return TRUE;\r
149}\r
150\r
151/**\r
152 Determines if the FMP device should be locked when the event specified by\r
153 PcdFmpDeviceLockEventGuid is signaled. The expected result from this function\r
154 is TRUE so the FMP device is always locked. A platform can choose to return\r
155 FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.\r
156\r
157 @retval TRUE The FMP device lock action is required at lock event guid.\r
158 @retval FALSE Do not perform FMP device lock at lock event guid.\r
159\r
160**/\r
161BOOLEAN\r
162EFIAPI\r
163IsLockFmpDeviceAtLockEventGuidRequired (\r
164 VOID\r
165 )\r
166{\r
167 if (LookupCapsuleUpdatePolicyProtocol ()) {\r
168 return mCapsuleUpdatePolicy->IsLockFmpDeviceAtLockEventGuidRequired (mCapsuleUpdatePolicy);\r
169 }\r
170 return TRUE;\r
171}\r