]>
Commit | Line | Data |
---|---|---|
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 | |
24 | EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *mCapsuleUpdatePolicy = NULL;\r | |
25 | \r | |
26 | /**\r | |
27 | Lookup the EDK II Capsule Update Policy Protocol.\r | |
28 | **/\r | |
29 | BOOLEAN\r | |
30 | LookupCapsuleUpdatePolicyProtocol (\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 | |
45ce0a67 | 39 | \r |
c40f7cc7 | 40 | Status = gBS->LocateProtocol (\r |
95d28836 | 41 | &gEdkiiCapsuleUpdatePolicyProtocolGuid,\r |
c40f7cc7 EJ |
42 | NULL,\r |
43 | (VOID **)&mCapsuleUpdatePolicy\r | |
44 | );\r | |
45 | if (EFI_ERROR (Status)) {\r | |
46 | mCapsuleUpdatePolicy = NULL;\r | |
47 | return FALSE;\r | |
48 | }\r | |
45ce0a67 | 49 | \r |
c40f7cc7 EJ |
50 | return TRUE;\r |
51 | }\r | |
52 | \r | |
53 | /**\r | |
54 | Determine if the system power state supports a capsule update.\r | |
55 | \r | |
56 | @param[out] Good Returns TRUE if system power state supports a capsule\r | |
57 | update. Returns FALSE if system power state does not\r | |
58 | support a capsule update. Return value is only valid if\r | |
59 | return status is EFI_SUCCESS.\r | |
60 | \r | |
61 | @retval EFI_SUCCESS Good parameter has been updated with result.\r | |
62 | @retval EFI_INVALID_PARAMETER Good is NULL.\r | |
63 | @retval EFI_DEVICE_ERROR System power state can not be determined.\r | |
64 | \r | |
65 | **/\r | |
66 | EFI_STATUS\r | |
67 | EFIAPI\r | |
68 | CheckSystemPower (\r | |
69 | OUT BOOLEAN *Good\r | |
70 | )\r | |
71 | {\r | |
72 | if (LookupCapsuleUpdatePolicyProtocol ()) {\r | |
73 | return mCapsuleUpdatePolicy->CheckSystemPower (mCapsuleUpdatePolicy, Good);\r | |
74 | }\r | |
45ce0a67 | 75 | \r |
c40f7cc7 EJ |
76 | *Good = TRUE;\r |
77 | return EFI_SUCCESS;\r | |
78 | }\r | |
79 | \r | |
80 | /**\r | |
81 | Determines if the system thermal state supports a capsule update.\r | |
82 | \r | |
83 | @param[out] Good Returns TRUE if system thermal state supports a capsule\r | |
84 | update. Returns FALSE if system thermal state does not\r | |
85 | support a capsule update. Return value is only valid if\r | |
86 | return status is EFI_SUCCESS.\r | |
87 | \r | |
88 | @retval EFI_SUCCESS Good parameter has been updated with result.\r | |
89 | @retval EFI_INVALID_PARAMETER Good is NULL.\r | |
90 | @retval EFI_DEVICE_ERROR System thermal state can not be determined.\r | |
91 | \r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | CheckSystemThermal (\r | |
45ce0a67 | 96 | OUT BOOLEAN *Good\r |
c40f7cc7 EJ |
97 | )\r |
98 | {\r | |
99 | if (LookupCapsuleUpdatePolicyProtocol ()) {\r | |
100 | return mCapsuleUpdatePolicy->CheckSystemThermal (mCapsuleUpdatePolicy, Good);\r | |
101 | }\r | |
45ce0a67 | 102 | \r |
c40f7cc7 EJ |
103 | *Good = TRUE;\r |
104 | return EFI_SUCCESS;\r | |
105 | }\r | |
106 | \r | |
107 | /**\r | |
108 | Determines if the system environment state supports a capsule update.\r | |
109 | \r | |
110 | @param[out] Good Returns TRUE if system environment state supports a capsule\r | |
111 | update. Returns FALSE if system environment state does not\r | |
112 | support a capsule update. Return value is only valid if\r | |
113 | return status is EFI_SUCCESS.\r | |
114 | \r | |
115 | @retval EFI_SUCCESS Good parameter has been updated with result.\r | |
116 | @retval EFI_INVALID_PARAMETER Good is NULL.\r | |
117 | @retval EFI_DEVICE_ERROR System environment state can not be determined.\r | |
118 | \r | |
119 | **/\r | |
120 | EFI_STATUS\r | |
121 | EFIAPI\r | |
122 | CheckSystemEnvironment (\r | |
45ce0a67 | 123 | OUT BOOLEAN *Good\r |
c40f7cc7 EJ |
124 | )\r |
125 | {\r | |
126 | if (LookupCapsuleUpdatePolicyProtocol ()) {\r | |
127 | return mCapsuleUpdatePolicy->CheckSystemEnvironment (mCapsuleUpdatePolicy, Good);\r | |
128 | }\r | |
45ce0a67 | 129 | \r |
c40f7cc7 EJ |
130 | *Good = TRUE;\r |
131 | return EFI_SUCCESS;\r | |
132 | }\r | |
133 | \r | |
134 | /**\r | |
135 | Determines if the Lowest Supported Version checks should be performed. The\r | |
136 | expected result from this function is TRUE. A platform can choose to return\r | |
137 | FALSE (e.g. during manufacturing or servicing) to allow a capsule update to a\r | |
138 | version below the current Lowest Supported Version.\r | |
139 | \r | |
140 | @retval TRUE The lowest supported version check is required.\r | |
141 | @retval FALSE Do not perform lowest support version check.\r | |
142 | \r | |
143 | **/\r | |
144 | BOOLEAN\r | |
145 | EFIAPI\r | |
146 | IsLowestSupportedVersionCheckRequired (\r | |
147 | VOID\r | |
148 | )\r | |
149 | {\r | |
150 | if (LookupCapsuleUpdatePolicyProtocol ()) {\r | |
151 | return mCapsuleUpdatePolicy->IsLowestSupportedVersionCheckRequired (mCapsuleUpdatePolicy);\r | |
152 | }\r | |
45ce0a67 | 153 | \r |
c40f7cc7 EJ |
154 | return TRUE;\r |
155 | }\r | |
156 | \r | |
157 | /**\r | |
158 | Determines if the FMP device should be locked when the event specified by\r | |
159 | PcdFmpDeviceLockEventGuid is signaled. The expected result from this function\r | |
160 | is TRUE so the FMP device is always locked. A platform can choose to return\r | |
161 | FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.\r | |
162 | \r | |
163 | @retval TRUE The FMP device lock action is required at lock event guid.\r | |
164 | @retval FALSE Do not perform FMP device lock at lock event guid.\r | |
165 | \r | |
166 | **/\r | |
167 | BOOLEAN\r | |
168 | EFIAPI\r | |
169 | IsLockFmpDeviceAtLockEventGuidRequired (\r | |
170 | VOID\r | |
171 | )\r | |
172 | {\r | |
173 | if (LookupCapsuleUpdatePolicyProtocol ()) {\r | |
174 | return mCapsuleUpdatePolicy->IsLockFmpDeviceAtLockEventGuidRequired (mCapsuleUpdatePolicy);\r | |
175 | }\r | |
45ce0a67 | 176 | \r |
c40f7cc7 EJ |
177 | return TRUE;\r |
178 | }\r |