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