]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | Fvb.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Light weight lib to support Tiano Firmware Volume Block \r | |
19 | protocol abstraction at runtime.\r | |
20 | \r | |
21 | All these functions convert EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID\r | |
22 | class function to the Runtime Lib function. There is a 1 to 1 mapping.\r | |
23 | \r | |
24 | If you are using any of these lib functions.you must first call FvbInitialize ().\r | |
25 | \r | |
26 | --*/\r | |
27 | \r | |
28 | EFI_STATUS\r | |
29 | FvbLibInitialize (\r | |
30 | IN EFI_HANDLE ImageHandle,\r | |
31 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
32 | )\r | |
33 | /*++\r | |
34 | \r | |
35 | Routine Description:\r | |
36 | Initialize globals and register Fvb Protocol notification function.\r | |
37 | \r | |
38 | Arguments:\r | |
39 | None\r | |
40 | \r | |
41 | Returns: \r | |
42 | EFI_SUCCESS\r | |
43 | \r | |
44 | --*/\r | |
45 | {\r | |
46 | return EFI_SUCCESS;\r | |
47 | }\r | |
48 | //\r | |
49 | // The following functions wrap Fvb protocol in the Runtime Lib functions.\r | |
50 | // The Instance translates into Fvb instance. The Fvb order defined by HOBs and\r | |
51 | // thus the sequence of FVB protocol addition define Instance.\r | |
52 | //\r | |
53 | // EfiFvbInitialize () must be called before any of the following functions\r | |
54 | // must be called.\r | |
55 | //\r | |
56 | EFI_STATUS\r | |
57 | EfiFvbReadBlock (\r | |
58 | IN UINTN Instance,\r | |
59 | IN EFI_LBA Lba,\r | |
60 | IN UINTN Offset,\r | |
61 | IN OUT UINTN *NumBytes,\r | |
62 | IN UINT8 *Buffer\r | |
63 | )\r | |
64 | /*++\r | |
65 | \r | |
66 | Routine Description:\r | |
67 | Reads specified number of bytes into a buffer from the specified block\r | |
68 | \r | |
69 | Arguments:\r | |
70 | Instance - The FV instance to be read from\r | |
71 | Lba - The logical block address to be read from\r | |
72 | Offset - Offset into the block at which to begin reading\r | |
73 | NumBytes - Pointer that on input contains the total size of\r | |
74 | the buffer. On output, it contains the total number\r | |
75 | of bytes read\r | |
76 | Buffer - Pointer to a caller allocated buffer that will be\r | |
77 | used to hold the data read\r | |
78 | \r | |
79 | Returns:\r | |
80 | Status code\r | |
81 | \r | |
82 | --*/\r | |
83 | {\r | |
84 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
85 | \r | |
86 | return EfiCallEsalService (&Guid, Read, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;\r | |
87 | }\r | |
88 | \r | |
89 | EFI_STATUS\r | |
90 | EfiFvbWriteBlock (\r | |
91 | IN UINTN Instance,\r | |
92 | IN EFI_LBA Lba,\r | |
93 | IN UINTN Offset,\r | |
94 | IN OUT UINTN *NumBytes,\r | |
95 | IN UINT8 *Buffer\r | |
96 | )\r | |
97 | /*++\r | |
98 | \r | |
99 | Routine Description:\r | |
100 | Writes specified number of bytes from the input buffer to the block\r | |
101 | \r | |
102 | Arguments:\r | |
103 | Instance - The FV instance to be written to\r | |
104 | Lba - The starting logical block index to write to\r | |
105 | Offset - Offset into the block at which to begin writing\r | |
106 | NumBytes - Pointer that on input contains the total size of\r | |
107 | the buffer. On output, it contains the total number\r | |
108 | of bytes actually written\r | |
109 | Buffer - Pointer to a caller allocated buffer that contains\r | |
110 | the source for the write\r | |
111 | \r | |
112 | Returns:\r | |
113 | Status code\r | |
114 | \r | |
115 | --*/\r | |
116 | {\r | |
117 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
118 | \r | |
119 | return EfiCallEsalService (&Guid, Write, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;\r | |
120 | }\r | |
121 | \r | |
122 | EFI_STATUS\r | |
123 | EfiFvbEraseBlock (\r | |
124 | IN UINTN Instance,\r | |
125 | IN UINTN Lba\r | |
126 | )\r | |
127 | /*++\r | |
128 | \r | |
129 | Routine Description:\r | |
130 | Erases and initializes a firmware volume block\r | |
131 | \r | |
132 | Arguments:\r | |
133 | Instance - The FV instance to be erased\r | |
134 | Lba - The logical block index to be erased\r | |
135 | \r | |
136 | Returns:\r | |
137 | Status code\r | |
138 | \r | |
139 | --*/\r | |
140 | {\r | |
141 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
142 | \r | |
143 | return EfiCallEsalService (&Guid, EraseBlock, Instance, Lba, 0, 0, 0, 0, 0).Status;\r | |
144 | }\r | |
145 | \r | |
146 | EFI_STATUS\r | |
147 | EfiFvbGetVolumeAttributes (\r | |
148 | IN UINTN Instance,\r | |
149 | OUT EFI_FVB_ATTRIBUTES *Attributes\r | |
150 | )\r | |
151 | /*++\r | |
152 | \r | |
153 | Routine Description:\r | |
154 | Retrieves attributes, insures positive polarity of attribute bits, returns\r | |
155 | resulting attributes in output parameter\r | |
156 | \r | |
157 | Arguments:\r | |
158 | Instance - The FV instance whose attributes is going to be \r | |
159 | returned\r | |
160 | Attributes - Output buffer which contains attributes\r | |
161 | \r | |
162 | Returns:\r | |
163 | Status code\r | |
164 | \r | |
165 | --*/\r | |
166 | {\r | |
167 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
168 | \r | |
169 | return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status;\r | |
170 | }\r | |
171 | \r | |
172 | EFI_STATUS\r | |
173 | EfiFvbSetVolumeAttributes (\r | |
174 | IN UINTN Instance,\r | |
175 | IN EFI_FVB_ATTRIBUTES Attributes\r | |
176 | )\r | |
177 | /*++\r | |
178 | \r | |
179 | Routine Description:\r | |
180 | Modifies the current settings of the firmware volume according to the \r | |
181 | input parameter, and returns the new setting of the volume\r | |
182 | \r | |
183 | Arguments:\r | |
184 | Instance - The FV instance whose attributes is going to be \r | |
185 | modified\r | |
186 | Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES \r | |
187 | containing the desired firmware volume settings.\r | |
188 | On successful return, it contains the new settings\r | |
189 | of the firmware volume\r | |
190 | \r | |
191 | Returns:\r | |
192 | Status code\r | |
193 | \r | |
194 | --*/\r | |
195 | {\r | |
196 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
197 | \r | |
198 | return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status;\r | |
199 | }\r | |
200 | \r | |
201 | EFI_STATUS\r | |
202 | EfiFvbGetPhysicalAddress (\r | |
203 | IN UINTN Instance,\r | |
204 | OUT EFI_PHYSICAL_ADDRESS *BaseAddress\r | |
205 | )\r | |
206 | /*++\r | |
207 | \r | |
208 | Routine Description:\r | |
209 | Retrieves the physical address of a memory mapped FV\r | |
210 | \r | |
211 | Arguments:\r | |
212 | Instance - The FV instance whose base address is going to be\r | |
213 | returned\r | |
214 | BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r | |
215 | that on successful return, contains the base address\r | |
216 | of the firmware volume. \r | |
217 | \r | |
218 | Returns:\r | |
219 | Status code\r | |
220 | \r | |
221 | --*/\r | |
222 | {\r | |
223 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
224 | \r | |
225 | return EfiCallEsalService (&Guid, GetPhysicalAddress, Instance, (UINT64) BaseAddress, 0, 0, 0, 0, 0).Status;\r | |
226 | }\r | |
227 | \r | |
228 | EFI_STATUS\r | |
229 | EfiFvbGetBlockSize (\r | |
230 | IN UINTN Instance,\r | |
231 | IN EFI_LBA Lba,\r | |
232 | OUT UINTN *BlockSize,\r | |
233 | OUT UINTN *NumOfBlocks\r | |
234 | )\r | |
235 | /*++\r | |
236 | \r | |
237 | Routine Description:\r | |
238 | Retrieve the size of a logical block\r | |
239 | \r | |
240 | Arguments:\r | |
241 | Instance - The FV instance whose block size is going to be\r | |
242 | returned\r | |
243 | Lba - Indicates which block to return the size for.\r | |
244 | BlockSize - A pointer to a caller allocated UINTN in which\r | |
245 | the size of the block is returned\r | |
246 | NumOfBlocks - a pointer to a caller allocated UINTN in which the\r | |
247 | number of consecutive blocks starting with Lba is\r | |
248 | returned. All blocks in this range have a size of\r | |
249 | BlockSize\r | |
250 | \r | |
251 | Returns:\r | |
252 | EFI_SUCCESS - The firmware volume was read successfully and \r | |
253 | contents are in Buffer\r | |
254 | \r | |
255 | --*/\r | |
256 | {\r | |
257 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
258 | \r | |
259 | return EfiCallEsalService (\r | |
260 | &Guid,\r | |
261 | GetBlockSize,\r | |
262 | Instance,\r | |
263 | Lba,\r | |
264 | (UINT64) BlockSize,\r | |
265 | (UINT64) NumOfBlocks,\r | |
266 | 0,\r | |
267 | 0,\r | |
268 | 0\r | |
269 | ).Status;\r | |
270 | }\r | |
271 | \r | |
272 | EFI_STATUS\r | |
273 | EfiFvbEraseCustomBlockRange (\r | |
274 | IN UINTN Instance,\r | |
275 | IN EFI_LBA StartLba,\r | |
276 | IN UINTN OffsetStartLba,\r | |
277 | IN EFI_LBA LastLba,\r | |
278 | IN UINTN OffsetLastLba\r | |
279 | )\r | |
280 | /*++\r | |
281 | \r | |
282 | Routine Description:\r | |
283 | Erases and initializes a specified range of a firmware volume\r | |
284 | \r | |
285 | Arguments:\r | |
286 | Instance - The FV instance to be erased\r | |
287 | StartLba - The starting logical block index to be erased\r | |
288 | OffsetStartLba - Offset into the starting block at which to \r | |
289 | begin erasing\r | |
290 | LastLba - The last logical block index to be erased\r | |
291 | OffsetLastLba - Offset into the last block at which to end erasing\r | |
292 | \r | |
293 | Returns:\r | |
294 | Status code\r | |
295 | \r | |
296 | --*/\r | |
297 | {\r | |
298 | EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;\r | |
299 | \r | |
300 | return EfiCallEsalService (\r | |
301 | &Guid,\r | |
302 | EraseCustomBlockRange,\r | |
303 | Instance,\r | |
304 | StartLba,\r | |
305 | OffsetStartLba,\r | |
306 | LastLba,\r | |
307 | OffsetLastLba,\r | |
308 | 0,\r | |
309 | 0\r | |
310 | ).Status;\r | |
311 | }\r | |
312 | \r | |
313 | \r | |
314 | /**\r | |
315 | BugBug: Can't turn this off in the current MSA so we need a stub\r | |
316 | **/\r | |
317 | VOID\r | |
318 | EFIAPI\r | |
319 | FvbVirtualAddressChangeNotifyEvent (\r | |
320 | IN EFI_EVENT Event,\r | |
321 | IN VOID *Context\r | |
322 | )\r | |
323 | {\r | |
324 | }\r |