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