]>
Commit | Line | Data |
---|---|---|
c2df8e13 | 1 | /** @file\r |
2 | \r | |
3 | Implements get/set firmware volume attributes.\r | |
4 | \r | |
0a6f4824 | 5 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
c2df8e13 | 6 | \r |
c0a00b14 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
c2df8e13 | 8 | \r |
9 | **/\r | |
10 | \r | |
11 | #include "FwVolDriver.h"\r | |
12 | \r | |
13 | /**\r | |
14 | Retrieves attributes, insures positive polarity of attribute bits, returns\r | |
15 | resulting attributes in output parameter.\r | |
16 | \r | |
17 | @param This Calling context\r | |
18 | @param Attributes output buffer which contains attributes\r | |
19 | \r | |
20 | @retval EFI_SUCCESS Successfully got volume attributes\r | |
21 | \r | |
22 | **/\r | |
23 | EFI_STATUS\r | |
24 | EFIAPI\r | |
25 | FvGetVolumeAttributes (\r | |
26 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
27 | OUT EFI_FV_ATTRIBUTES *Attributes\r | |
28 | )\r | |
29 | {\r | |
30 | EFI_STATUS Status;\r | |
31 | FV_DEVICE *FvDevice;\r | |
32 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r | |
33 | EFI_FVB_ATTRIBUTES_2 FvbAttributes;\r | |
34 | \r | |
35 | FvDevice = FV_DEVICE_FROM_THIS (This);\r | |
36 | Fvb = FvDevice->Fvb;\r | |
37 | \r | |
38 | //\r | |
39 | // First get the Firmware Volume Block Attributes\r | |
40 | //\r | |
41 | Status = Fvb->GetAttributes (Fvb, &FvbAttributes);\r | |
42 | FvbAttributes &= 0xfffff0ff;\r | |
43 | \r | |
44 | *Attributes = FvbAttributes;\r | |
45 | *Attributes |= EFI_FV2_WRITE_POLICY_RELIABLE;\r | |
46 | return Status;\r | |
47 | }\r | |
48 | \r | |
49 | /**\r | |
50 | Sets current attributes for volume.\r | |
51 | \r | |
52 | @param This Calling context\r | |
53 | @param Attributes On input, FvAttributes is a pointer to\r | |
54 | an EFI_FV_ATTRIBUTES containing the\r | |
55 | desired firmware volume settings. On\r | |
56 | successful return, it contains the new\r | |
57 | settings of the firmware volume. On\r | |
58 | unsuccessful return, FvAttributes is not\r | |
59 | modified and the firmware volume\r | |
60 | settings are not changed.\r | |
0a6f4824 | 61 | \r |
c2df8e13 | 62 | @retval EFI_SUCCESS The requested firmware volume attributes\r |
63 | were set and the resulting\r | |
64 | EFI_FV_ATTRIBUTES is returned in\r | |
65 | FvAttributes.\r | |
66 | @retval EFI_ACCESS_DENIED Atrribute is locked down.\r | |
67 | @retval EFI_INVALID_PARAMETER Atrribute is not valid.\r | |
68 | \r | |
69 | **/\r | |
70 | EFI_STATUS\r | |
71 | EFIAPI\r | |
72 | FvSetVolumeAttributes (\r | |
73 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
74 | IN OUT EFI_FV_ATTRIBUTES *Attributes\r | |
75 | )\r | |
76 | {\r | |
77 | EFI_STATUS Status;\r | |
78 | FV_DEVICE *FvDevice;\r | |
79 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;\r | |
80 | EFI_FVB_ATTRIBUTES_2 OldFvbAttributes;\r | |
81 | EFI_FVB_ATTRIBUTES_2 NewFvbAttributes;\r | |
82 | UINT64 NewStatus;\r | |
83 | UINT32 Capabilities;\r | |
84 | \r | |
85 | FvDevice = FV_DEVICE_FROM_THIS (This);\r | |
86 | Fvb = FvDevice->Fvb;\r | |
87 | \r | |
88 | //\r | |
89 | // First get the current Volume Attributes\r | |
90 | //\r | |
91 | Status = Fvb->GetAttributes (\r | |
92 | Fvb,\r | |
93 | &OldFvbAttributes\r | |
94 | );\r | |
95 | \r | |
96 | if ((OldFvbAttributes & EFI_FVB2_LOCK_STATUS) != 0) {\r | |
97 | return EFI_ACCESS_DENIED;\r | |
98 | }\r | |
99 | //\r | |
100 | // Only status attributes can be updated.\r | |
101 | //\r | |
102 | Capabilities = OldFvbAttributes & EFI_FVB2_CAPABILITIES;\r | |
103 | NewStatus = (*Attributes) & EFI_FVB2_STATUS;\r | |
104 | \r | |
105 | //\r | |
106 | // Test read disable\r | |
107 | //\r | |
108 | if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) {\r | |
109 | if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) {\r | |
110 | return EFI_INVALID_PARAMETER;\r | |
111 | }\r | |
112 | }\r | |
113 | //\r | |
114 | // Test read enable\r | |
115 | //\r | |
116 | if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) {\r | |
117 | if ((NewStatus & EFI_FVB2_READ_STATUS) != 0) {\r | |
118 | return EFI_INVALID_PARAMETER;\r | |
119 | }\r | |
120 | }\r | |
121 | //\r | |
122 | // Test write disable\r | |
123 | //\r | |
124 | if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) {\r | |
125 | if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) {\r | |
126 | return EFI_INVALID_PARAMETER;\r | |
127 | }\r | |
128 | }\r | |
129 | //\r | |
130 | // Test write enable\r | |
131 | //\r | |
132 | if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) {\r | |
133 | if ((NewStatus & EFI_FVB2_WRITE_STATUS) != 0) {\r | |
134 | return EFI_INVALID_PARAMETER;\r | |
135 | }\r | |
136 | }\r | |
137 | //\r | |
138 | // Test lock\r | |
139 | //\r | |
140 | if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) {\r | |
141 | if ((NewStatus & EFI_FVB2_LOCK_STATUS) != 0) {\r | |
142 | return EFI_INVALID_PARAMETER;\r | |
143 | }\r | |
144 | }\r | |
145 | \r | |
146 | NewFvbAttributes = OldFvbAttributes & (0xFFFFFFFF & (~EFI_FVB2_STATUS));\r | |
147 | NewFvbAttributes |= NewStatus;\r | |
148 | Status = Fvb->SetAttributes (\r | |
149 | Fvb,\r | |
150 | &NewFvbAttributes\r | |
151 | );\r | |
152 | \r | |
153 | if (EFI_ERROR (Status)) {\r | |
154 | return Status;\r | |
155 | }\r | |
156 | \r | |
157 | *Attributes = 0;\r | |
158 | \r | |
159 | This->GetVolumeAttributes (\r | |
160 | This,\r | |
161 | Attributes\r | |
162 | );\r | |
163 | \r | |
164 | return EFI_SUCCESS;\r | |
165 | }\r | |
166 | \r | |
167 | /**\r | |
168 | Return information of type InformationType for the requested firmware\r | |
169 | volume.\r | |
170 | \r | |
171 | @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r | |
172 | @param InformationType InformationType for requested.\r | |
173 | @param BufferSize On input, size of Buffer.On output, the amount of\r | |
174 | data returned in Buffer.\r | |
175 | @param Buffer A poniter to the data buffer to return.\r | |
176 | \r | |
177 | @return EFI_UNSUPPORTED Could not get.\r | |
178 | \r | |
179 | **/\r | |
180 | EFI_STATUS\r | |
181 | EFIAPI\r | |
182 | FvGetVolumeInfo (\r | |
183 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
184 | IN CONST EFI_GUID *InformationType,\r | |
185 | IN OUT UINTN *BufferSize,\r | |
186 | OUT VOID *Buffer\r | |
187 | )\r | |
188 | {\r | |
189 | return EFI_UNSUPPORTED;\r | |
190 | }\r | |
191 | \r | |
192 | /**\r | |
193 | Set information with InformationType into the requested firmware volume.\r | |
194 | \r | |
195 | @param This Pointer to EFI_FIRMWARE_VOLUME2_PROTOCOL.\r | |
196 | @param InformationType InformationType for requested.\r | |
197 | @param BufferSize Size of Buffer data.\r | |
198 | @param Buffer A poniter to the data buffer to be set.\r | |
199 | \r | |
200 | @retval EFI_UNSUPPORTED Could not set.\r | |
201 | \r | |
202 | **/\r | |
203 | EFI_STATUS\r | |
204 | EFIAPI\r | |
205 | FvSetVolumeInfo (\r | |
206 | IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r | |
207 | IN CONST EFI_GUID *InformationType,\r | |
208 | IN UINTN BufferSize,\r | |
209 | IN CONST VOID *Buffer\r | |
210 | )\r | |
211 | {\r | |
212 | return EFI_UNSUPPORTED;\r | |
213 | }\r |