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