3 Implements get/set firmware volume attributes.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions
9 of the BSD License which accompanies this distribution. The
10 full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include "FwVolDriver.h"
21 Retrieves attributes, insures positive polarity of attribute bits, returns
22 resulting attributes in output parameter.
24 @param This Calling context
25 @param Attributes output buffer which contains attributes
27 @retval EFI_SUCCESS Successfully got volume attributes
32 FvGetVolumeAttributes (
33 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
34 OUT EFI_FV_ATTRIBUTES
*Attributes
39 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
;
40 EFI_FVB_ATTRIBUTES_2 FvbAttributes
;
42 FvDevice
= FV_DEVICE_FROM_THIS (This
);
46 // First get the Firmware Volume Block Attributes
48 Status
= Fvb
->GetAttributes (Fvb
, &FvbAttributes
);
49 FvbAttributes
&= 0xfffff0ff;
51 *Attributes
= FvbAttributes
;
52 *Attributes
|= EFI_FV2_WRITE_POLICY_RELIABLE
;
57 Sets current attributes for volume.
59 @param This Calling context
60 @param Attributes On input, FvAttributes is a pointer to
61 an EFI_FV_ATTRIBUTES containing the
62 desired firmware volume settings. On
63 successful return, it contains the new
64 settings of the firmware volume. On
65 unsuccessful return, FvAttributes is not
66 modified and the firmware volume
67 settings are not changed.
69 @retval EFI_SUCCESS The requested firmware volume attributes
70 were set and the resulting
71 EFI_FV_ATTRIBUTES is returned in
73 @retval EFI_ACCESS_DENIED Atrribute is locked down.
74 @retval EFI_INVALID_PARAMETER Atrribute is not valid.
79 FvSetVolumeAttributes (
80 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
81 IN OUT EFI_FV_ATTRIBUTES
*Attributes
86 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*Fvb
;
87 EFI_FVB_ATTRIBUTES_2 OldFvbAttributes
;
88 EFI_FVB_ATTRIBUTES_2 NewFvbAttributes
;
92 FvDevice
= FV_DEVICE_FROM_THIS (This
);
96 // First get the current Volume Attributes
98 Status
= Fvb
->GetAttributes (
103 if ((OldFvbAttributes
& EFI_FVB2_LOCK_STATUS
) != 0) {
104 return EFI_ACCESS_DENIED
;
107 // Only status attributes can be updated.
109 Capabilities
= OldFvbAttributes
& EFI_FVB2_CAPABILITIES
;
110 NewStatus
= (*Attributes
) & EFI_FVB2_STATUS
;
115 if ((Capabilities
& EFI_FVB2_READ_DISABLED_CAP
) == 0) {
116 if ((NewStatus
& EFI_FVB2_READ_STATUS
) == 0) {
117 return EFI_INVALID_PARAMETER
;
123 if ((Capabilities
& EFI_FVB2_READ_ENABLED_CAP
) == 0) {
124 if ((NewStatus
& EFI_FVB2_READ_STATUS
) != 0) {
125 return EFI_INVALID_PARAMETER
;
129 // Test write disable
131 if ((Capabilities
& EFI_FVB2_WRITE_DISABLED_CAP
) == 0) {
132 if ((NewStatus
& EFI_FVB2_WRITE_STATUS
) == 0) {
133 return EFI_INVALID_PARAMETER
;
139 if ((Capabilities
& EFI_FVB2_WRITE_ENABLED_CAP
) == 0) {
140 if ((NewStatus
& EFI_FVB2_WRITE_STATUS
) != 0) {
141 return EFI_INVALID_PARAMETER
;
147 if ((Capabilities
& EFI_FVB2_LOCK_CAP
) == 0) {
148 if ((NewStatus
& EFI_FVB2_LOCK_STATUS
) != 0) {
149 return EFI_INVALID_PARAMETER
;
153 NewFvbAttributes
= OldFvbAttributes
& (0xFFFFFFFF & (~EFI_FVB2_STATUS
));
154 NewFvbAttributes
|= NewStatus
;
155 Status
= Fvb
->SetAttributes (
160 if (EFI_ERROR (Status
)) {
166 This
->GetVolumeAttributes (
175 Return information of type InformationType for the requested firmware
178 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
179 @param InformationType InformationType for requested.
180 @param BufferSize On input, size of Buffer.On output, the amount of
181 data returned in Buffer.
182 @param Buffer A poniter to the data buffer to return.
184 @return EFI_UNSUPPORTED Could not get.
190 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
191 IN CONST EFI_GUID
*InformationType
,
192 IN OUT UINTN
*BufferSize
,
196 return EFI_UNSUPPORTED
;
200 Set information with InformationType into the requested firmware volume.
202 @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.
203 @param InformationType InformationType for requested.
204 @param BufferSize Size of Buffer data.
205 @param Buffer A poniter to the data buffer to be set.
207 @retval EFI_UNSUPPORTED Could not set.
213 IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL
*This
,
214 IN CONST EFI_GUID
*InformationType
,
216 IN CONST VOID
*Buffer
219 return EFI_UNSUPPORTED
;