]> git.proxmox.com Git - mirror_edk2.git/blob - FmpDevicePkg/CapsuleUpdatePolicyDxe/CapsuleUpdatePolicyDxe.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 /**
55 Determines if the system thermal state supports a capsule update.
56
57 @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
58 @param[out] Good Returns TRUE if system thermal state supports a capsule
59 update. Returns FALSE if system thermal state does not
60 support a capsule update. Return value is only valid if
61 return status is EFI_SUCCESS.
62
63 @retval EFI_SUCCESS Good parameter has been updated with result.
64 @retval EFI_INVALID_PARAMETER Good is NULL.
65 @retval EFI_DEVICE_ERROR System thermal state can not be determined.
66
67 **/
68 EFI_STATUS
69 EFIAPI
70 CapsuleUpdatePolicyCheckSystemThermal (
71 IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
72 OUT BOOLEAN *Good
73 )
74 {
75 return CheckSystemThermal (Good);
76 }
77
78 /**
79 Determines if the system environment state supports a capsule update.
80
81 @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
82 @param[out] Good Returns TRUE if system environment state supports a capsule
83 update. Returns FALSE if system environment state does not
84 support a capsule update. Return value is only valid if
85 return status is EFI_SUCCESS.
86
87 @retval EFI_SUCCESS Good parameter has been updated with result.
88 @retval EFI_INVALID_PARAMETER Good is NULL.
89 @retval EFI_DEVICE_ERROR System environment state can not be determined.
90
91 **/
92 EFI_STATUS
93 EFIAPI
94 CapsuleUpdatePolicyCheckSystemEnvironment (
95 IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
96 OUT BOOLEAN *Good
97 )
98 {
99 return CheckSystemEnvironment (Good);
100 }
101
102 /**
103 Determines if the Lowest Supported Version checks should be performed. The
104 expected result from this function is TRUE. A platform can choose to return
105 FALSE (e.g. during manufacturing or servicing) to allow a capsule update to a
106 version below the current Lowest Supported Version.
107
108 @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
109
110 @retval TRUE The lowest supported version check is required.
111 @retval FALSE Do not perform lowest support version check.
112
113 **/
114 BOOLEAN
115 EFIAPI
116 CapsuleUpdatePolicyIsLowestSupportedVersionCheckRequired (
117 IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This
118 )
119 {
120 return IsLowestSupportedVersionCheckRequired ();
121 }
122
123 /**
124 Determines if the FMP device should be locked when the event specified by
125 PcdFmpDeviceLockEventGuid is signaled. The expected result from this function
126 is TRUE so the FMP device is always locked. A platform can choose to return
127 FALSE (e.g. during manufacturing) to allow FMP devices to remain unlocked.
128
129 @param[in] This A pointer to the EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL instance.
130
131 @retval TRUE The FMP device lock action is required at lock event guid.
132 @retval FALSE Do not perform FMP device lock at lock event guid.
133
134 **/
135 BOOLEAN
136 EFIAPI
137 CapsuleUpdatePolicyIsLockFmpDeviceAtLockEventGuidRequired (
138 IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This
139 )
140 {
141 return IsLockFmpDeviceAtLockEventGuidRequired ();
142 }
143
144 /**
145 The user Entry Point for module CapsuleUpdatePolicyDxe. The user code starts
146 with this function.
147
148 @param[in] ImageHandle The firmware allocated handle for the EFI image.
149 @param[in] SystemTable A pointer to the EFI System Table.
150
151 @retval EFI_SUCCESS The entry point is executed successfully.
152 @retval other Some error occurs when executing this entry point.
153
154 **/
155 EFI_STATUS
156 EFIAPI
157 CapsuleUpdatePolicyInitialize (
158 IN EFI_HANDLE ImageHandle,
159 IN EFI_SYSTEM_TABLE *SystemTable
160 )
161 {
162 EFI_STATUS Status;
163
164 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEdkiiCapsuleUpdatePolicyProtocolGuid);
165 Status = gBS->InstallMultipleProtocolInterfaces (
166 &mHandle,
167 &gEdkiiCapsuleUpdatePolicyProtocolGuid, &mCapsuleUpdatePolicy,
168 NULL
169 );
170 ASSERT_EFI_ERROR (Status);
171
172 return Status;
173 }