]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | *\r | |
3 | * Copyright (c) 2012-2014, ARM Limited. All rights reserved.\r | |
4 | *\r | |
5 | * This program and the accompanying materials\r | |
6 | * are licensed and made available under the terms and conditions of the BSD License\r | |
7 | * which accompanies this distribution. The full text of the license may be found at\r | |
8 | * http://opensource.org/licenses/bsd-license.php\r | |
9 | *\r | |
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | *\r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef __BOOTMON_FS_API_H\r | |
16 | #define __BOOTMON_FS_API_H\r | |
17 | \r | |
18 | #include <Protocol/SimpleFileSystem.h>\r | |
19 | \r | |
20 | EFI_STATUS\r | |
21 | BootMonFsInitialize (\r | |
22 | IN BOOTMON_FS_INSTANCE *Instance\r | |
23 | );\r | |
24 | \r | |
25 | UINT32\r | |
26 | BootMonFsChecksum (\r | |
27 | IN VOID *Data,\r | |
28 | IN UINT32 Size\r | |
29 | );\r | |
30 | \r | |
31 | EFI_STATUS\r | |
32 | BootMonFsComputeFooterChecksum (\r | |
33 | IN OUT HW_IMAGE_DESCRIPTION *Footer\r | |
34 | );\r | |
35 | \r | |
36 | EFIAPI\r | |
37 | EFI_STATUS\r | |
38 | OpenBootMonFsOpenVolume (\r | |
39 | IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,\r | |
40 | OUT EFI_FILE_PROTOCOL **Root\r | |
41 | );\r | |
42 | \r | |
43 | UINT32\r | |
44 | BootMonFsGetImageLength (\r | |
45 | IN BOOTMON_FS_FILE *File\r | |
46 | );\r | |
47 | \r | |
48 | UINTN\r | |
49 | BootMonFsGetPhysicalSize (\r | |
50 | IN BOOTMON_FS_FILE* File\r | |
51 | );\r | |
52 | \r | |
53 | EFI_STATUS\r | |
54 | BootMonFsCreateFile (\r | |
55 | IN BOOTMON_FS_INSTANCE *Instance,\r | |
56 | OUT BOOTMON_FS_FILE **File\r | |
57 | );\r | |
58 | \r | |
59 | EFIAPI\r | |
60 | EFI_STATUS\r | |
61 | BootMonFsGetInfo (\r | |
62 | IN EFI_FILE_PROTOCOL *This,\r | |
63 | IN EFI_GUID *InformationType,\r | |
64 | IN OUT UINTN *BufferSize,\r | |
65 | OUT VOID *Buffer\r | |
66 | );\r | |
67 | \r | |
68 | EFIAPI\r | |
69 | EFI_STATUS\r | |
70 | BootMonFsReadDirectory (\r | |
71 | IN EFI_FILE_PROTOCOL *This,\r | |
72 | IN OUT UINTN *BufferSize,\r | |
73 | OUT VOID *Buffer\r | |
74 | );\r | |
75 | \r | |
76 | EFIAPI\r | |
77 | EFI_STATUS\r | |
78 | BootMonFsFlushDirectory (\r | |
79 | IN EFI_FILE_PROTOCOL *This\r | |
80 | );\r | |
81 | \r | |
82 | /**\r | |
83 | Flush all modified data associated with a file to a device.\r | |
84 | \r | |
85 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the\r | |
86 | file handle to flush.\r | |
87 | \r | |
88 | @retval EFI_SUCCESS The data was flushed.\r | |
89 | @retval EFI_ACCESS_DENIED The file was opened read-only.\r | |
90 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
91 | @retval EFI_VOLUME_FULL The volume is full.\r | |
92 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to flush the data.\r | |
93 | @retval EFI_INVALID_PARAMETER At least one of the parameters is invalid.\r | |
94 | \r | |
95 | **/\r | |
96 | EFIAPI\r | |
97 | EFI_STATUS\r | |
98 | BootMonFsFlushFile (\r | |
99 | IN EFI_FILE_PROTOCOL *This\r | |
100 | );\r | |
101 | \r | |
102 | /**\r | |
103 | Close a specified file handle.\r | |
104 | \r | |
105 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file\r | |
106 | handle to close.\r | |
107 | \r | |
108 | @retval EFI_SUCCESS The file was closed.\r | |
109 | @retval EFI_INVALID_PARAMETER The parameter "This" is NULL or is not an open\r | |
110 | file handle.\r | |
111 | \r | |
112 | **/\r | |
113 | EFIAPI\r | |
114 | EFI_STATUS\r | |
115 | BootMonFsCloseFile (\r | |
116 | IN EFI_FILE_PROTOCOL *This\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Open a file on the boot monitor file system.\r | |
121 | \r | |
122 | The boot monitor file system does not allow for sub-directories. There is only\r | |
123 | one directory, the root one. On any attempt to create a directory, the function\r | |
124 | returns in error with the EFI_WRITE_PROTECTED error code.\r | |
125 | \r | |
126 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is\r | |
127 | the file handle to source location.\r | |
128 | @param[out] NewHandle A pointer to the location to return the opened\r | |
129 | handle for the new file.\r | |
130 | @param[in] FileName The Null-terminated string of the name of the file\r | |
131 | to be opened.\r | |
132 | @param[in] OpenMode The mode to open the file : Read or Read/Write or\r | |
133 | Read/Write/Create\r | |
134 | @param[in] Attributes Attributes of the file in case of a file creation\r | |
135 | \r | |
136 | @retval EFI_SUCCESS The file was open.\r | |
137 | @retval EFI_NOT_FOUND The specified file could not be found or the specified\r | |
138 | directory in which to create a file could not be found.\r | |
139 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
140 | @retval EFI_WRITE_PROTECTED Attempt to create a directory. This is not possible\r | |
141 | with the Boot Monitor file system.\r | |
142 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.\r | |
143 | @retval EFI_INVALID_PARAMETER At least one of the parameters is invalid.\r | |
144 | \r | |
145 | **/\r | |
146 | EFIAPI\r | |
147 | EFI_STATUS\r | |
148 | BootMonFsOpenFile (\r | |
149 | IN EFI_FILE_PROTOCOL *This,\r | |
150 | OUT EFI_FILE_PROTOCOL **NewHandle,\r | |
151 | IN CHAR16 *FileName,\r | |
152 | IN UINT64 OpenMode,\r | |
153 | IN UINT64 Attributes\r | |
154 | );\r | |
155 | \r | |
156 | /**\r | |
157 | Read data from an open file.\r | |
158 | \r | |
159 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that\r | |
160 | is the file handle to read data from.\r | |
161 | @param[in out] BufferSize On input, the size of the Buffer. On output, the\r | |
162 | amount of data returned in Buffer. In both cases,\r | |
163 | the size is measured in bytes.\r | |
164 | @param[out] Buffer The buffer into which the data is read.\r | |
165 | \r | |
166 | @retval EFI_SUCCESS The data was read.\r | |
167 | @retval EFI_DEVICE_ERROR On entry, the current file position is\r | |
168 | beyond the end of the file, or the device\r | |
169 | reported an error while performing the read\r | |
170 | operation.\r | |
171 | @retval EFI_INVALID_PARAMETER At least one of the parameters is invalid.\r | |
172 | \r | |
173 | **/\r | |
174 | EFIAPI\r | |
175 | EFI_STATUS\r | |
176 | BootMonFsReadFile (\r | |
177 | IN EFI_FILE_PROTOCOL *This,\r | |
178 | IN OUT UINTN *BufferSize,\r | |
179 | OUT VOID *Buffer\r | |
180 | );\r | |
181 | \r | |
182 | EFIAPI\r | |
183 | EFI_STATUS\r | |
184 | BootMonFsSetDirPosition (\r | |
185 | IN EFI_FILE_PROTOCOL *This,\r | |
186 | IN UINT64 Position\r | |
187 | );\r | |
188 | \r | |
189 | EFIAPI\r | |
190 | EFI_STATUS\r | |
191 | BootMonFsGetPosition (\r | |
192 | IN EFI_FILE_PROTOCOL *This,\r | |
193 | OUT UINT64 *Position\r | |
194 | );\r | |
195 | \r | |
196 | /**\r | |
197 | Write data to an open file.\r | |
198 | \r | |
199 | The data is not written to the flash yet. It will be written when the file\r | |
200 | will be either read, closed or flushed.\r | |
201 | \r | |
202 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that\r | |
203 | is the file handle to write data to.\r | |
204 | @param[in out] BufferSize On input, the size of the Buffer. On output, the\r | |
205 | size of the data actually written. In both cases,\r | |
206 | the size is measured in bytes.\r | |
207 | @param[in] Buffer The buffer of data to write.\r | |
208 | \r | |
209 | @retval EFI_SUCCESS The data was written.\r | |
210 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
211 | @retval EFI_OUT_OF_RESOURCES Unable to allocate the buffer to store the\r | |
212 | data to write.\r | |
213 | @retval EFI_INVALID_PARAMETER At least one of the parameters is invalid.\r | |
214 | \r | |
215 | **/\r | |
216 | EFIAPI\r | |
217 | EFI_STATUS\r | |
218 | BootMonFsWriteFile (\r | |
219 | IN EFI_FILE_PROTOCOL *This,\r | |
220 | IN OUT UINTN *BufferSize,\r | |
221 | IN VOID *Buffer\r | |
222 | );\r | |
223 | \r | |
224 | EFIAPI\r | |
225 | EFI_STATUS\r | |
226 | BootMonFsDeleteFail (\r | |
227 | IN EFI_FILE_PROTOCOL *This\r | |
228 | );\r | |
229 | \r | |
230 | /**\r | |
231 | Close and delete a file from the boot monitor file system.\r | |
232 | \r | |
233 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file\r | |
234 | handle to delete.\r | |
235 | \r | |
236 | @retval EFI_SUCCESS The file was closed and deleted.\r | |
237 | @retval EFI_INVALID_PARAMETER The parameter "This" is NULL or is not an open\r | |
238 | file handle.\r | |
239 | @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not deleted.\r | |
240 | \r | |
241 | **/\r | |
242 | EFIAPI\r | |
243 | EFI_STATUS\r | |
244 | BootMonFsDelete (\r | |
245 | IN EFI_FILE_PROTOCOL *This\r | |
246 | );\r | |
247 | \r | |
248 | /**\r | |
249 | Set a file's current position.\r | |
250 | \r | |
251 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is\r | |
252 | the file handle to set the requested position on.\r | |
253 | @param[in] Position The byte position from the start of the file to set.\r | |
254 | \r | |
255 | @retval EFI_SUCCESS The position was set.\r | |
256 | @retval EFI_INVALID_PARAMETER At least one of the parameters is invalid.\r | |
257 | \r | |
258 | **/\r | |
259 | EFIAPI\r | |
260 | EFI_STATUS\r | |
261 | BootMonFsSetPosition (\r | |
262 | IN EFI_FILE_PROTOCOL *This,\r | |
263 | IN UINT64 Position\r | |
264 | );\r | |
265 | \r | |
266 | /**\r | |
267 | Return a file's current position.\r | |
268 | \r | |
269 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is\r | |
270 | the file handle to get the current position on.\r | |
271 | @param[out] Position The address to return the file's current position value.\r | |
272 | \r | |
273 | @retval EFI_SUCCESS The position was returned.\r | |
274 | @retval EFI_INVALID_PARAMETER At least one of the parameters is invalid.\r | |
275 | \r | |
276 | **/\r | |
277 | EFIAPI\r | |
278 | EFI_STATUS\r | |
279 | BootMonFsGetPosition(\r | |
280 | IN EFI_FILE_PROTOCOL *This,\r | |
281 | OUT UINT64 *Position\r | |
282 | );\r | |
283 | \r | |
284 | //\r | |
285 | // UNSUPPORTED OPERATIONS\r | |
286 | //\r | |
287 | \r | |
288 | EFIAPI\r | |
289 | EFI_STATUS\r | |
290 | BootMonFsGetPositionUnsupported (\r | |
291 | IN EFI_FILE_PROTOCOL *This,\r | |
292 | OUT UINT64 *Position\r | |
293 | );\r | |
294 | \r | |
295 | /**\r | |
296 | Set information about a file or a volume.\r | |
297 | \r | |
298 | @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that\r | |
299 | is the file handle the information is for.\r | |
300 | @param[in] InformationType The type identifier for the information being set :\r | |
301 | EFI_FILE_INFO_ID or EFI_FILE_SYSTEM_INFO_ID or\r | |
302 | EFI_FILE_SYSTEM_VOLUME_LABEL_ID\r | |
303 | @param[in] BufferSize The size, in bytes, of Buffer.\r | |
304 | @param[in] Buffer A pointer to the data buffer to write. The type of the\r | |
305 | data inside the buffer is indicated by InformationType.\r | |
306 | \r | |
307 | @retval EFI_SUCCESS The information was set.\r | |
308 | @retval EFI_UNSUPPORTED The InformationType is not known.\r | |
309 | @retval EFI_DEVICE_ERROR The last issued semi-hosting operation failed.\r | |
310 | @retval EFI_ACCESS_DENIED An attempt is made to change the name of a file\r | |
311 | to a file that is already present.\r | |
312 | @retval EFI_ACCESS_DENIED An attempt is being made to change the\r | |
313 | EFI_FILE_DIRECTORY Attribute.\r | |
314 | @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and\r | |
315 | the file was opened in read-only mode and an\r | |
316 | attempt is being made to modify a field other\r | |
317 | than Attribute.\r | |
318 | @retval EFI_WRITE_PROTECTED An attempt is being made to modify a read-only\r | |
319 | attribute.\r | |
320 | @retval EFI_BAD_BUFFER_SIZE The size of the buffer is lower than that indicated by\r | |
321 | the data inside the buffer.\r | |
322 | @retval EFI_OUT_OF_RESOURCES A allocation needed to process the request failed.\r | |
323 | @retval EFI_INVALID_PARAMETER At least one of the parameters is invalid.\r | |
324 | \r | |
325 | **/\r | |
326 | EFIAPI\r | |
327 | EFI_STATUS\r | |
328 | BootMonFsSetInfo (\r | |
329 | IN EFI_FILE_PROTOCOL *This,\r | |
330 | IN EFI_GUID *InformationType,\r | |
331 | IN UINTN BufferSize,\r | |
332 | IN VOID *Buffer\r | |
333 | );\r | |
334 | \r | |
335 | //\r | |
336 | // Directory API\r | |
337 | //\r | |
338 | \r | |
339 | EFI_STATUS\r | |
340 | BootMonFsOpenDirectory (\r | |
341 | OUT EFI_FILE_PROTOCOL **NewHandle,\r | |
342 | IN CHAR16 *FileName,\r | |
343 | IN BOOTMON_FS_INSTANCE *Volume\r | |
344 | );\r | |
345 | \r | |
346 | //\r | |
347 | // Internal API\r | |
348 | //\r | |
349 | \r | |
350 | /**\r | |
351 | Search for a file given its name coded in Ascii.\r | |
352 | \r | |
353 | When searching through the files of the volume, if a file is currently not\r | |
354 | open, its name was written on the media and is kept in RAM in the\r | |
355 | "HwDescription.Footer.Filename[]" field of the file's description.\r | |
356 | \r | |
357 | If a file is currently open, its name might not have been written on the\r | |
358 | media yet, and as the "HwDescription" is a mirror in RAM of what is on the\r | |
359 | media the "HwDescription.Footer.Filename[]" might be outdated. In that case,\r | |
360 | the up to date name of the file is stored in the "Info" field of the file's\r | |
361 | description.\r | |
362 | \r | |
363 | @param[in] Instance Pointer to the description of the volume in which\r | |
364 | the file has to be search for.\r | |
365 | @param[in] AsciiFileName Name of the file.\r | |
366 | \r | |
367 | @param[out] File Pointer to the description of the file if the\r | |
368 | file was found.\r | |
369 | \r | |
370 | @retval EFI_SUCCESS The file was found.\r | |
371 | @retval EFI_NOT_FOUND The file was not found.\r | |
372 | \r | |
373 | **/\r | |
374 | EFI_STATUS\r | |
375 | BootMonGetFileFromAsciiFileName (\r | |
376 | IN BOOTMON_FS_INSTANCE *Instance,\r | |
377 | IN CHAR8* AsciiFileName,\r | |
378 | OUT BOOTMON_FS_FILE **File\r | |
379 | );\r | |
380 | \r | |
381 | EFI_STATUS\r | |
382 | BootMonGetFileFromPosition (\r | |
383 | IN BOOTMON_FS_INSTANCE *Instance,\r | |
384 | IN UINTN Position,\r | |
385 | OUT BOOTMON_FS_FILE **File\r | |
386 | );\r | |
387 | \r | |
388 | #endif\r |