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