3 Implements get/set firmware volume attributes.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "FwVolDriver.h"
14 Retrieves attributes, insures positive polarity of attribute bits, returns
15 resulting attributes in output parameter.
17 @param This Calling context
18 @param Attributes output buffer which contains attributes
20 @retval EFI_SUCCESS Successfully got volume attributes
25 FvGetVolumeAttributes (
26 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
27 OUT EFI_FV_ATTRIBUTES
*Attributes
32 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
;
33 EFI_FVB_ATTRIBUTES_2 FvbAttributes
;
35 FvDevice
= FV_DEVICE_FROM_THIS (This
);
39 // First get the Firmware Volume Block Attributes
41 Status
= Fvb
->GetAttributes (Fvb
, &FvbAttributes
);
42 FvbAttributes
&= 0xfffff0ff;
44 *Attributes
= FvbAttributes
;
45 *Attributes
|= EFI_FV2_WRITE_POLICY_RELIABLE
;
50 Sets current attributes for volume.
52 @param This Calling context
53 @param Attributes On input, FvAttributes is a pointer to
54 an EFI_FV_ATTRIBUTES containing the
55 desired firmware volume settings. On
56 successful return, it contains the new
57 settings of the firmware volume. On
58 unsuccessful return, FvAttributes is not
59 modified and the firmware volume
60 settings are not changed.
62 @retval EFI_SUCCESS The requested firmware volume attributes
63 were set and the resulting
64 EFI_FV_ATTRIBUTES is returned in
66 @retval EFI_ACCESS_DENIED Atrribute is locked down.
67 @retval EFI_INVALID_PARAMETER Atrribute is not valid.
72 FvSetVolumeAttributes (
73 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
74 IN OUT EFI_FV_ATTRIBUTES
*Attributes
79 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
;
80 EFI_FVB_ATTRIBUTES_2 OldFvbAttributes
;
81 EFI_FVB_ATTRIBUTES_2 NewFvbAttributes
;
85 FvDevice
= FV_DEVICE_FROM_THIS (This
);
89 // First get the current Volume Attributes
91 Status
= Fvb
->GetAttributes (
96 if ((OldFvbAttributes
& EFI_FVB2_LOCK_STATUS
) != 0) {
97 return EFI_ACCESS_DENIED
;
100 // Only status attributes can be updated.
102 Capabilities
= OldFvbAttributes
& EFI_FVB2_CAPABILITIES
;
103 NewStatus
= (*Attributes
) & EFI_FVB2_STATUS
;
108 if ((Capabilities
& EFI_FVB2_READ_DISABLED_CAP
) == 0) {
109 if ((NewStatus
& EFI_FVB2_READ_STATUS
) == 0) {
110 return EFI_INVALID_PARAMETER
;
116 if ((Capabilities
& EFI_FVB2_READ_ENABLED_CAP
) == 0) {
117 if ((NewStatus
& EFI_FVB2_READ_STATUS
) != 0) {
118 return EFI_INVALID_PARAMETER
;
122 // Test write disable
124 if ((Capabilities
& EFI_FVB2_WRITE_DISABLED_CAP
) == 0) {
125 if ((NewStatus
& EFI_FVB2_WRITE_STATUS
) == 0) {
126 return EFI_INVALID_PARAMETER
;
132 if ((Capabilities
& EFI_FVB2_WRITE_ENABLED_CAP
) == 0) {
133 if ((NewStatus
& EFI_FVB2_WRITE_STATUS
) != 0) {
134 return EFI_INVALID_PARAMETER
;
140 if ((Capabilities
& EFI_FVB2_LOCK_CAP
) == 0) {
141 if ((NewStatus
& EFI_FVB2_LOCK_STATUS
) != 0) {
142 return EFI_INVALID_PARAMETER
;
146 NewFvbAttributes
= OldFvbAttributes
& (0xFFFFFFFF & (~EFI_FVB2_STATUS
));
147 NewFvbAttributes
|= NewStatus
;
148 Status
= Fvb
->SetAttributes (
153 if (EFI_ERROR (Status
)) {
159 This
->GetVolumeAttributes (
168 Return information of type InformationType for the requested firmware
171 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
172 @param InformationType InformationType for requested.
173 @param BufferSize On input, size of Buffer.On output, the amount of
174 data returned in Buffer.
175 @param Buffer A poniter to the data buffer to return.
177 @return EFI_UNSUPPORTED Could not get.
183 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
184 IN CONST EFI_GUID
*InformationType
,
185 IN OUT UINTN
*BufferSize
,
189 return EFI_UNSUPPORTED
;
193 Set information with InformationType into the requested firmware volume.
195 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
196 @param InformationType InformationType for requested.
197 @param BufferSize Size of Buffer data.
198 @param Buffer A poniter to the data buffer to be set.
200 @retval EFI_UNSUPPORTED Could not set.
206 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
207 IN CONST EFI_GUID
*InformationType
,
209 IN CONST VOID
*Buffer
212 return EFI_UNSUPPORTED
;