2 SimpleFileSystem protocol as defined in the UEFI 2.0 specification.
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
8 UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem.
10 Copyright (c) 2006 - 2014, 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.
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.
21 #ifndef __SIMPLE_FILE_SYSTEM_H__
22 #define __SIMPLE_FILE_SYSTEM_H__
24 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
26 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
29 typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
;
31 typedef struct _EFI_FILE_PROTOCOL EFI_FILE_PROTOCOL
;
32 typedef struct _EFI_FILE_PROTOCOL
*EFI_FILE_HANDLE
;
35 /// Protocol GUID name defined in EFI1.1.
37 #define SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
40 /// Protocol name defined in EFI1.1.
42 typedef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_FILE_IO_INTERFACE
;
43 typedef EFI_FILE_PROTOCOL EFI_FILE
;
46 Open the root directory on a volume.
48 @param This A pointer to the volume to open the root directory.
49 @param Root A pointer to the location to return the opened file handle for the
52 @retval EFI_SUCCESS The device was opened.
53 @retval EFI_UNSUPPORTED This volume does not support the requested file system type.
54 @retval EFI_NO_MEDIA The device has no medium.
55 @retval EFI_DEVICE_ERROR The device reported an error.
56 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
57 @retval EFI_ACCESS_DENIED The service denied access to the file.
58 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
59 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
60 longer supported. Any existing file handles for this volume are
61 no longer valid. To access the files on the new medium, the
62 volume must be reopened with OpenVolume().
67 (EFIAPI
*EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME
)(
68 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
69 OUT EFI_FILE_PROTOCOL
**Root
72 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
75 /// Revision defined in EFI1.1
77 #define EFI_FILE_IO_INTERFACE_REVISION EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION
79 struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
{
81 /// The version of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. The version
82 /// specified by this specification is 0x00010000. All future revisions
83 /// must be backwards compatible.
86 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume
;
90 Opens a new file relative to the source file's location.
92 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
93 handle to the source location. This would typically be an open
94 handle to a directory.
95 @param NewHandle A pointer to the location to return the opened handle for the new
97 @param FileName The Null-terminated string of the name of the file to be opened.
98 The file name may contain the following path modifiers: "\", ".",
100 @param OpenMode The mode to open the file. The only valid combinations that the
101 file may be opened with are: Read, Read/Write, or Create/Read/Write.
102 @param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the
103 attribute bits for the newly created file.
105 @retval EFI_SUCCESS The file was opened.
106 @retval EFI_NOT_FOUND The specified file could not be found on the device.
107 @retval EFI_NO_MEDIA The device has no medium.
108 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
110 @retval EFI_DEVICE_ERROR The device reported an error.
111 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
112 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
113 when the media is write-protected.
114 @retval EFI_ACCESS_DENIED The service denied access to the file.
115 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
116 @retval EFI_VOLUME_FULL The volume is full.
121 (EFIAPI
*EFI_FILE_OPEN
)(
122 IN EFI_FILE_PROTOCOL
*This
,
123 OUT EFI_FILE_PROTOCOL
**NewHandle
,
132 #define EFI_FILE_MODE_READ 0x0000000000000001ULL
133 #define EFI_FILE_MODE_WRITE 0x0000000000000002ULL
134 #define EFI_FILE_MODE_CREATE 0x8000000000000000ULL
139 #define EFI_FILE_READ_ONLY 0x0000000000000001ULL
140 #define EFI_FILE_HIDDEN 0x0000000000000002ULL
141 #define EFI_FILE_SYSTEM 0x0000000000000004ULL
142 #define EFI_FILE_RESERVED 0x0000000000000008ULL
143 #define EFI_FILE_DIRECTORY 0x0000000000000010ULL
144 #define EFI_FILE_ARCHIVE 0x0000000000000020ULL
145 #define EFI_FILE_VALID_ATTR 0x0000000000000037ULL
148 Closes a specified file handle.
150 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
153 @retval EFI_SUCCESS The file was closed.
158 (EFIAPI
*EFI_FILE_CLOSE
)(
159 IN EFI_FILE_PROTOCOL
*This
163 Close and delete the file handle.
165 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the
166 handle to the file to delete.
168 @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
169 @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not deleted.
174 (EFIAPI
*EFI_FILE_DELETE
)(
175 IN EFI_FILE_PROTOCOL
*This
179 Reads data from a file.
181 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
182 handle to read data from.
183 @param BufferSize On input, the size of the Buffer. On output, the amount of data
184 returned in Buffer. In both cases, the size is measured in bytes.
185 @param Buffer The buffer into which the data is read.
187 @retval EFI_SUCCESS Data was read.
188 @retval EFI_NO_MEDIA The device has no medium.
189 @retval EFI_DEVICE_ERROR The device reported an error.
190 @retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file.
191 @retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file.
192 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
193 @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory
194 entry. BufferSize has been updated with the size
195 needed to complete the request.
200 (EFIAPI
*EFI_FILE_READ
)(
201 IN EFI_FILE_PROTOCOL
*This
,
202 IN OUT UINTN
*BufferSize
,
207 Writes data to a file.
209 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
210 handle to write data to.
211 @param BufferSize On input, the size of the Buffer. On output, the amount of data
212 actually written. In both cases, the size is measured in bytes.
213 @param Buffer The buffer of data to write.
215 @retval EFI_SUCCESS Data was written.
216 @retval EFI_UNSUPPORTED Writes to open directory files are not supported.
217 @retval EFI_NO_MEDIA The device has no medium.
218 @retval EFI_DEVICE_ERROR The device reported an error.
219 @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
220 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
221 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
222 @retval EFI_ACCESS_DENIED The file was opened read only.
223 @retval EFI_VOLUME_FULL The volume is full.
228 (EFIAPI
*EFI_FILE_WRITE
)(
229 IN EFI_FILE_PROTOCOL
*This
,
230 IN OUT UINTN
*BufferSize
,
235 Sets a file's current position.
237 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the
238 file handle to set the requested position on.
239 @param Position The byte position from the start of the file to set.
241 @retval EFI_SUCCESS The position was set.
242 @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open
244 @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted file.
249 (EFIAPI
*EFI_FILE_SET_POSITION
)(
250 IN EFI_FILE_PROTOCOL
*This
,
255 Returns a file's current position.
257 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
258 handle to get the current position on.
259 @param Position The address to return the file's current position value.
261 @retval EFI_SUCCESS The position was returned.
262 @retval EFI_UNSUPPORTED The request is not valid on open directories.
263 @retval EFI_DEVICE_ERROR An attempt was made to get the position from a deleted file.
268 (EFIAPI
*EFI_FILE_GET_POSITION
)(
269 IN EFI_FILE_PROTOCOL
*This
,
274 Returns information about a file.
276 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
277 handle the requested information is for.
278 @param InformationType The type identifier for the information being requested.
279 @param BufferSize On input, the size of Buffer. On output, the amount of data
280 returned in Buffer. In both cases, the size is measured in bytes.
281 @param Buffer A pointer to the data buffer to return. The buffer's type is
282 indicated by InformationType.
284 @retval EFI_SUCCESS The information was returned.
285 @retval EFI_UNSUPPORTED The InformationType is not known.
286 @retval EFI_NO_MEDIA The device has no medium.
287 @retval EFI_DEVICE_ERROR The device reported an error.
288 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
289 @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.
290 BufferSize has been updated with the size needed to complete
295 (EFIAPI
*EFI_FILE_GET_INFO
)(
296 IN EFI_FILE_PROTOCOL
*This
,
297 IN EFI_GUID
*InformationType
,
298 IN OUT UINTN
*BufferSize
,
303 Sets information about a file.
305 @param File A pointer to the EFI_FILE_PROTOCOL instance that is the file
306 handle the information is for.
307 @param InformationType The type identifier for the information being set.
308 @param BufferSize The size, in bytes, of Buffer.
309 @param Buffer A pointer to the data buffer to write. The buffer's type is
310 indicated by InformationType.
312 @retval EFI_SUCCESS The information was set.
313 @retval EFI_UNSUPPORTED The InformationType is not known.
314 @retval EFI_NO_MEDIA The device has no medium.
315 @retval EFI_DEVICE_ERROR The device reported an error.
316 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
317 @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the media is
319 @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_PROTOCOL_SYSTEM_INFO_ID
320 and the media is read only.
321 @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_SYSTEM_VOLUME_LABEL_ID
322 and the media is read-only.
323 @retval EFI_ACCESS_DENIED An attempt is made to change the name of a file to a
324 file that is already present.
325 @retval EFI_ACCESS_DENIED An attempt is being made to change the EFI_FILE_DIRECTORY
327 @retval EFI_ACCESS_DENIED An attempt is being made to change the size of a directory.
328 @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the file was opened
329 read-only and an attempt is being made to modify a field
330 other than Attribute.
331 @retval EFI_VOLUME_FULL The volume is full.
332 @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the type indicated
338 (EFIAPI
*EFI_FILE_SET_INFO
)(
339 IN EFI_FILE_PROTOCOL
*This
,
340 IN EFI_GUID
*InformationType
,
346 Flushes all modified data associated with a file to a device.
348 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
351 @retval EFI_SUCCESS The data was flushed.
352 @retval EFI_NO_MEDIA The device has no medium.
353 @retval EFI_DEVICE_ERROR The device reported an error.
354 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
355 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
356 @retval EFI_ACCESS_DENIED The file was opened read-only.
357 @retval EFI_VOLUME_FULL The volume is full.
362 (EFIAPI
*EFI_FILE_FLUSH
)(
363 IN EFI_FILE_PROTOCOL
*This
368 // If Event is NULL, then blocking I/O is performed.
369 // If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed,
370 // and Event will be signaled when the read request is completed.
371 // The caller must be prepared to handle the case where the callback associated with Event
372 // occurs before the original asynchronous I/O request call returns.
377 // Defines whether or not the signaled event encountered an error.
382 // For OpenEx(): Not Used, ignored.
383 // For ReadEx(): On input, the size of the Buffer. On output, the amount of data returned in Buffer.
384 // In both cases, the size is measured in bytes.
385 // For WriteEx(): On input, the size of the Buffer. On output, the amount of data actually written.
386 // In both cases, the size is measured in bytes.
387 // For FlushEx(): Not used, ignored.
392 // For OpenEx(): Not Used, ignored.
393 // For ReadEx(): The buffer into which the data is read.
394 // For WriteEx(): The buffer of data to write.
395 // For FlushEx(): Not Used, ignored.
401 Opens a new file relative to the source directory's location.
403 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
404 handle to the source location.
405 @param NewHandle A pointer to the location to return the opened handle for the new
407 @param FileName The Null-terminated string of the name of the file to be opened.
408 The file name may contain the following path modifiers: "\", ".",
410 @param OpenMode The mode to open the file. The only valid combinations that the
411 file may be opened with are: Read, Read/Write, or Create/Read/Write.
412 @param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the
413 attribute bits for the newly created file.
414 @param Token A pointer to the token associated with the transaction.
416 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
417 If Event is not NULL (asynchronous I/O): The request was successfully
418 queued for processing.
419 @retval EFI_NOT_FOUND The specified file could not be found on the device.
420 @retval EFI_NO_MEDIA The device has no medium.
421 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
423 @retval EFI_DEVICE_ERROR The device reported an error.
424 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
425 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
426 when the media is write-protected.
427 @retval EFI_ACCESS_DENIED The service denied access to the file.
428 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
429 @retval EFI_VOLUME_FULL The volume is full.
434 (EFIAPI
*EFI_FILE_OPEN_EX
)(
435 IN EFI_FILE_PROTOCOL
*This
,
436 OUT EFI_FILE_PROTOCOL
**NewHandle
,
439 IN UINT64 Attributes
,
440 IN OUT EFI_FILE_IO_TOKEN
*Token
445 Reads data from a file.
447 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to read data from.
448 @param Token A pointer to the token associated with the transaction.
450 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
451 If Event is not NULL (asynchronous I/O): The request was successfully
452 queued for processing.
453 @retval EFI_NO_MEDIA The device has no medium.
454 @retval EFI_DEVICE_ERROR The device reported an error.
455 @retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file.
456 @retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file.
457 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
458 @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
462 (EFIAPI
*EFI_FILE_READ_EX
) (
463 IN EFI_FILE_PROTOCOL
*This
,
464 IN OUT EFI_FILE_IO_TOKEN
*Token
469 Writes data to a file.
471 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to write data to.
472 @param Token A pointer to the token associated with the transaction.
474 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
475 If Event is not NULL (asynchronous I/O): The request was successfully
476 queued for processing.
477 @retval EFI_UNSUPPORTED Writes to open directory files are not supported.
478 @retval EFI_NO_MEDIA The device has no medium.
479 @retval EFI_DEVICE_ERROR The device reported an error.
480 @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
481 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
482 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
483 @retval EFI_ACCESS_DENIED The file was opened read only.
484 @retval EFI_VOLUME_FULL The volume is full.
485 @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
489 (EFIAPI
*EFI_FILE_WRITE_EX
) (
490 IN EFI_FILE_PROTOCOL
*This
,
491 IN OUT EFI_FILE_IO_TOKEN
*Token
495 Flushes all modified data associated with a file to a device.
497 @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
499 @param Token A pointer to the token associated with the transaction.
501 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
502 If Event is not NULL (asynchronous I/O): The request was successfully
503 queued for processing.
504 @retval EFI_NO_MEDIA The device has no medium.
505 @retval EFI_DEVICE_ERROR The device reported an error.
506 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
507 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
508 @retval EFI_ACCESS_DENIED The file was opened read-only.
509 @retval EFI_VOLUME_FULL The volume is full.
510 @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
515 (EFIAPI
*EFI_FILE_FLUSH_EX
) (
516 IN EFI_FILE_PROTOCOL
*This
,
517 IN OUT EFI_FILE_IO_TOKEN
*Token
520 #define EFI_FILE_PROTOCOL_REVISION 0x00010000
521 #define EFI_FILE_PROTOCOL_REVISION2 0x00020000
522 #define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2
525 // Revision defined in EFI1.1.
527 #define EFI_FILE_REVISION EFI_FILE_PROTOCOL_REVISION
530 /// The EFI_FILE_PROTOCOL provides file IO access to supported file systems.
531 /// An EFI_FILE_PROTOCOL provides access to a file's or directory's contents,
532 /// and is also a reference to a location in the directory tree of the file system
533 /// in which the file resides. With any given file handle, other files may be opened
534 /// relative to this file's location, yielding new file handles.
536 struct _EFI_FILE_PROTOCOL
{
538 /// The version of the EFI_FILE_PROTOCOL interface. The version specified
539 /// by this specification is EFI_FILE_PROTOCOL_LATEST_REVISION.
540 /// Future versions are required to be backward compatible to version 1.0.
544 EFI_FILE_CLOSE Close
;
545 EFI_FILE_DELETE Delete
;
547 EFI_FILE_WRITE Write
;
548 EFI_FILE_GET_POSITION GetPosition
;
549 EFI_FILE_SET_POSITION SetPosition
;
550 EFI_FILE_GET_INFO GetInfo
;
551 EFI_FILE_SET_INFO SetInfo
;
552 EFI_FILE_FLUSH Flush
;
553 EFI_FILE_OPEN_EX OpenEx
;
554 EFI_FILE_READ_EX ReadEx
;
555 EFI_FILE_WRITE_EX WriteEx
;
556 EFI_FILE_FLUSH_EX FlushEx
;
560 extern EFI_GUID gEfiSimpleFileSystemProtocolGuid
;