]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Protocol/SimpleFileSystem.h
Resolve GCC build error, where #pragma pack(push[, id], <n>) is not supported.
[mirror_edk2.git] / MdePkg / Include / Protocol / SimpleFileSystem.h
... / ...
CommitLineData
1/** @file\r
2 SimpleFileSystem protocol as defined in the UEFI 2.0 specification.\r
3\r
4 The SimpleFileSystem protocol is the programmatic access to the FAT (12,16,32) \r
5 file system specified in UEFI 2.0. It can also be used to abstract a file \r
6 system other than FAT.\r
7\r
8 UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem.\r
9\r
10Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
11This program and the accompanying materials are licensed and made available under \r
12the terms and conditions of the BSD License that accompanies this distribution. \r
13The full text of the license may be found at\r
14http://opensource.org/licenses/bsd-license.php. \r
15 \r
16THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
17WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
18\r
19**/\r
20\r
21#ifndef __SIMPLE_FILE_SYSTEM_H__\r
22#define __SIMPLE_FILE_SYSTEM_H__\r
23\r
24#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \\r
25 { \\r
26 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
27 }\r
28\r
29typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;\r
30\r
31typedef struct _EFI_FILE_PROTOCOL EFI_FILE_PROTOCOL;\r
32typedef struct _EFI_FILE_PROTOCOL *EFI_FILE_HANDLE;\r
33\r
34///\r
35/// Protocol GUID name defined in EFI1.1.\r
36/// \r
37#define SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID\r
38\r
39///\r
40/// Protocol name defined in EFI1.1.\r
41/// \r
42typedef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_FILE_IO_INTERFACE;\r
43typedef EFI_FILE_PROTOCOL EFI_FILE;\r
44\r
45/**\r
46 Open the root directory on a volume.\r
47\r
48 @param This A pointer to the volume to open the root directory.\r
49 @param Root A pointer to the location to return the opened file handle for the\r
50 root directory.\r
51\r
52 @retval EFI_SUCCESS The device was opened.\r
53 @retval EFI_UNSUPPORTED This volume does not support the requested file system type.\r
54 @retval EFI_NO_MEDIA The device has no medium.\r
55 @retval EFI_DEVICE_ERROR The device reported an error.\r
56 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
57 @retval EFI_ACCESS_DENIED The service denied access to the file.\r
58 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.\r
59 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
60 longer supported. Any existing file handles for this volume are\r
61 no longer valid. To access the files on the new medium, the\r
62 volume must be reopened with OpenVolume().\r
63\r
64**/\r
65typedef\r
66EFI_STATUS\r
67(EFIAPI *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME)(\r
68 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,\r
69 OUT EFI_FILE_PROTOCOL **Root\r
70 );\r
71\r
72#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000\r
73\r
74///\r
75/// Revision defined in EFI1.1\r
76/// \r
77#define EFI_FILE_IO_INTERFACE_REVISION EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION\r
78\r
79struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {\r
80 ///\r
81 /// The version of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. The version\r
82 /// specified by this specification is 0x00010000. All future revisions\r
83 /// must be backwards compatible.\r
84 ///\r
85 UINT64 Revision;\r
86 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume;\r
87};\r
88\r
89/**\r
90 Opens a new file relative to the source file's location.\r
91\r
92 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file\r
93 handle to the source location. This would typically be an open\r
94 handle to a directory.\r
95 @param NewHandle A pointer to the location to return the opened handle for the new\r
96 file.\r
97 @param FileName The Null-terminated string of the name of the file to be opened.\r
98 The file name may contain the following path modifiers: "\", ".",\r
99 and "..".\r
100 @param OpenMode The mode to open the file. The only valid combinations that the\r
101 file may be opened with are: Read, Read/Write, or Create/Read/Write.\r
102 @param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the \r
103 attribute bits for the newly created file.\r
104\r
105 @retval EFI_SUCCESS The file was opened.\r
106 @retval EFI_NOT_FOUND The specified file could not be found on the device.\r
107 @retval EFI_NO_MEDIA The device has no medium.\r
108 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
109 longer supported.\r
110 @retval EFI_DEVICE_ERROR The device reported an error.\r
111 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
112 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r
113 when the media is write-protected.\r
114 @retval EFI_ACCESS_DENIED The service denied access to the file.\r
115 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.\r
116 @retval EFI_VOLUME_FULL The volume is full.\r
117\r
118**/\r
119typedef\r
120EFI_STATUS\r
121(EFIAPI *EFI_FILE_OPEN)(\r
122 IN EFI_FILE_PROTOCOL *This,\r
123 OUT EFI_FILE_PROTOCOL **NewHandle,\r
124 IN CHAR16 *FileName,\r
125 IN UINT64 OpenMode,\r
126 IN UINT64 Attributes\r
127 );\r
128\r
129//\r
130// Open modes\r
131//\r
132#define EFI_FILE_MODE_READ 0x0000000000000001ULL\r
133#define EFI_FILE_MODE_WRITE 0x0000000000000002ULL\r
134#define EFI_FILE_MODE_CREATE 0x8000000000000000ULL\r
135\r
136//\r
137// File attributes\r
138//\r
139#define EFI_FILE_READ_ONLY 0x0000000000000001ULL\r
140#define EFI_FILE_HIDDEN 0x0000000000000002ULL\r
141#define EFI_FILE_SYSTEM 0x0000000000000004ULL\r
142#define EFI_FILE_RESERVED 0x0000000000000008ULL\r
143#define EFI_FILE_DIRECTORY 0x0000000000000010ULL\r
144#define EFI_FILE_ARCHIVE 0x0000000000000020ULL\r
145#define EFI_FILE_VALID_ATTR 0x0000000000000037ULL\r
146\r
147/**\r
148 Closes a specified file handle.\r
149\r
150 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file \r
151 handle to close.\r
152\r
153 @retval EFI_SUCCESS The file was closed.\r
154\r
155**/\r
156typedef\r
157EFI_STATUS\r
158(EFIAPI *EFI_FILE_CLOSE)(\r
159 IN EFI_FILE_PROTOCOL *This\r
160 );\r
161\r
162/**\r
163 Close and delete the file handle.\r
164\r
165 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the\r
166 handle to the file to delete.\r
167\r
168 @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.\r
169 @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not deleted.\r
170\r
171**/\r
172typedef\r
173EFI_STATUS\r
174(EFIAPI *EFI_FILE_DELETE)(\r
175 IN EFI_FILE_PROTOCOL *This\r
176 );\r
177\r
178/**\r
179 Reads data from a file.\r
180\r
181 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file\r
182 handle to read data from.\r
183 @param BufferSize On input, the size of the Buffer. On output, the amount of data\r
184 returned in Buffer. In both cases, the size is measured in bytes.\r
185 @param Buffer The buffer into which the data is read.\r
186\r
187 @retval EFI_SUCCESS Data was read.\r
188 @retval EFI_NO_MEDIA The device has no medium.\r
189 @retval EFI_DEVICE_ERROR The device reported an error.\r
190 @retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file.\r
191 @retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file.\r
192 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
193 @retval EFI_BUFFER_TO_SMALL The BufferSize is too small to read the current directory\r
194 entry. BufferSize has been updated with the size\r
195 needed to complete the request.\r
196\r
197**/\r
198typedef\r
199EFI_STATUS\r
200(EFIAPI *EFI_FILE_READ)(\r
201 IN EFI_FILE_PROTOCOL *This,\r
202 IN OUT UINTN *BufferSize,\r
203 OUT VOID *Buffer\r
204 );\r
205\r
206/**\r
207 Writes data to a file.\r
208\r
209 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file\r
210 handle to write data to.\r
211 @param BufferSize On input, the size of the Buffer. On output, the amount of data\r
212 actually written. In both cases, the size is measured in bytes.\r
213 @param Buffer The buffer of data to write.\r
214\r
215 @retval EFI_SUCCESS Data was written.\r
216 @retval EFI_UNSUPPORTED Writes to open directory files are not supported.\r
217 @retval EFI_NO_MEDIA The device has no medium.\r
218 @retval EFI_DEVICE_ERROR The device reported an error.\r
219 @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.\r
220 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
221 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.\r
222 @retval EFI_ACCESS_DENIED The file was opened read only.\r
223 @retval EFI_VOLUME_FULL The volume is full.\r
224\r
225**/\r
226typedef\r
227EFI_STATUS\r
228(EFIAPI *EFI_FILE_WRITE)(\r
229 IN EFI_FILE_PROTOCOL *This,\r
230 IN OUT UINTN *BufferSize,\r
231 IN VOID *Buffer\r
232 );\r
233\r
234/**\r
235 Sets a file's current position.\r
236\r
237 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the\r
238 file handle to set the requested position on.\r
239 @param Position The byte position from the start of the file to set.\r
240\r
241 @retval EFI_SUCCESS The position was set.\r
242 @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open\r
243 directories.\r
244 @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted file.\r
245\r
246**/\r
247typedef\r
248EFI_STATUS\r
249(EFIAPI *EFI_FILE_SET_POSITION)(\r
250 IN EFI_FILE_PROTOCOL *This,\r
251 IN UINT64 Position\r
252 );\r
253\r
254/**\r
255 Returns a file's current position.\r
256\r
257 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file\r
258 handle to get the current position on.\r
259 @param Position The address to return the file's current position value.\r
260\r
261 @retval EFI_SUCCESS The position was returned.\r
262 @retval EFI_UNSUPPORTED The request is not valid on open directories.\r
263 @retval EFI_DEVICE_ERROR An attempt was made to get the position from a deleted file.\r
264\r
265**/\r
266typedef\r
267EFI_STATUS\r
268(EFIAPI *EFI_FILE_GET_POSITION)(\r
269 IN EFI_FILE_PROTOCOL *This,\r
270 OUT UINT64 *Position\r
271 );\r
272\r
273/**\r
274 Returns information about a file.\r
275\r
276 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file\r
277 handle the requested information is for.\r
278 @param InformationType The type identifier for the information being requested.\r
279 @param BufferSize On input, the size of Buffer. On output, the amount of data\r
280 returned in Buffer. In both cases, the size is measured in bytes.\r
281 @param Buffer A pointer to the data buffer to return. The buffer's type is\r
282 indicated by InformationType.\r
283\r
284 @retval EFI_SUCCESS The information was returned.\r
285 @retval EFI_UNSUPPORTED The InformationType is not known.\r
286 @retval EFI_NO_MEDIA The device has no medium.\r
287 @retval EFI_DEVICE_ERROR The device reported an error.\r
288 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
289 @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.\r
290 BufferSize has been updated with the size needed to complete\r
291 the request.\r
292**/\r
293typedef\r
294EFI_STATUS\r
295(EFIAPI *EFI_FILE_GET_INFO)(\r
296 IN EFI_FILE_PROTOCOL *This,\r
297 IN EFI_GUID *InformationType,\r
298 IN OUT UINTN *BufferSize,\r
299 OUT VOID *Buffer\r
300 );\r
301\r
302/**\r
303 Sets information about a file.\r
304\r
305 @param File A pointer to the EFI_FILE_PROTOCOL instance that is the file\r
306 handle the information is for.\r
307 @param InformationType The type identifier for the information being set.\r
308 @param BufferSize The size, in bytes, of Buffer.\r
309 @param Buffer A pointer to the data buffer to write. The buffer's type is\r
310 indicated by InformationType.\r
311\r
312 @retval EFI_SUCCESS The information was set.\r
313 @retval EFI_UNSUPPORTED The InformationType is not known.\r
314 @retval EFI_NO_MEDIA The device has no medium.\r
315 @retval EFI_DEVICE_ERROR The device reported an error.\r
316 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
317 @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the media is\r
318 read-only.\r
319 @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_PROTOCOL_SYSTEM_INFO_ID\r
320 and the media is read only.\r
321 @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_SYSTEM_VOLUME_LABEL_ID\r
322 and the media is read-only.\r
323 @retval EFI_ACCESS_DENIED An attempt is made to change the name of a file to a\r
324 file that is already present.\r
325 @retval EFI_ACCESS_DENIED An attempt is being made to change the EFI_FILE_DIRECTORY\r
326 Attribute.\r
327 @retval EFI_ACCESS_DENIED An attempt is being made to change the size of a directory.\r
328 @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the file was opened\r
329 read-only and an attempt is being made to modify a field\r
330 other than Attribute.\r
331 @retval EFI_VOLUME_FULL The volume is full.\r
332 @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the type indicated\r
333 by InformationType.\r
334\r
335**/\r
336typedef\r
337EFI_STATUS\r
338(EFIAPI *EFI_FILE_SET_INFO)(\r
339 IN EFI_FILE_PROTOCOL *This,\r
340 IN EFI_GUID *InformationType,\r
341 IN UINTN BufferSize,\r
342 IN VOID *Buffer\r
343 );\r
344\r
345/**\r
346 Flushes all modified data associated with a file to a device.\r
347\r
348 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file \r
349 handle to flush.\r
350\r
351 @retval EFI_SUCCESS The data was flushed.\r
352 @retval EFI_NO_MEDIA The device has no medium.\r
353 @retval EFI_DEVICE_ERROR The device reported an error.\r
354 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
355 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.\r
356 @retval EFI_ACCESS_DENIED The file was opened read-only.\r
357 @retval EFI_VOLUME_FULL The volume is full.\r
358\r
359**/\r
360typedef\r
361EFI_STATUS\r
362(EFIAPI *EFI_FILE_FLUSH)(\r
363 IN EFI_FILE_PROTOCOL *This\r
364 );\r
365\r
366#define EFI_FILE_PROTOCOL_REVISION 0x00010000\r
367//\r
368// Revision defined in EFI1.1.\r
369// \r
370#define EFI_FILE_REVISION EFI_FILE_PROTOCOL_REVISION\r
371\r
372///\r
373/// The EFI_FILE_PROTOCOL provides file IO access to supported file systems.\r
374/// An EFI_FILE_PROTOCOL provides access to a file's or directory's contents, \r
375/// and is also a reference to a location in the directory tree of the file system \r
376/// in which the file resides. With any given file handle, other files may be opened \r
377/// relative to this file's location, yielding new file handles.\r
378///\r
379struct _EFI_FILE_PROTOCOL {\r
380 ///\r
381 /// The version of the EFI_FILE_PROTOCOL interface. The version specified \r
382 /// by this specification is 0x00010000. Future versions are required \r
383 /// to be backward compatible to version 1.0.\r
384 ///\r
385 UINT64 Revision;\r
386 EFI_FILE_OPEN Open;\r
387 EFI_FILE_CLOSE Close;\r
388 EFI_FILE_DELETE Delete;\r
389 EFI_FILE_READ Read;\r
390 EFI_FILE_WRITE Write;\r
391 EFI_FILE_GET_POSITION GetPosition;\r
392 EFI_FILE_SET_POSITION SetPosition;\r
393 EFI_FILE_GET_INFO GetInfo;\r
394 EFI_FILE_SET_INFO SetInfo;\r
395 EFI_FILE_FLUSH Flush;\r
396};\r
397\r
398\r
399extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;\r
400\r
401#endif\r