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