xref: /src/sys/contrib/edk2/Include/Protocol/SimpleFileSystem.h (revision f439973d6726c3be929c8fb3b1545b8b1744abc3)
1f439973dSWarner Losh /** @file
2f439973dSWarner Losh   SimpleFileSystem protocol as defined in the UEFI 2.0 specification.
3f439973dSWarner Losh 
4f439973dSWarner Losh   The SimpleFileSystem protocol is the programmatic access to the FAT (12,16,32)
5f439973dSWarner Losh   file system specified in UEFI 2.0. It can also be used to abstract a file
6f439973dSWarner Losh   system other than FAT.
7f439973dSWarner Losh 
8f439973dSWarner Losh   UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem.
9f439973dSWarner Losh 
10f439973dSWarner Losh Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
11f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent
12f439973dSWarner Losh 
13f439973dSWarner Losh **/
14f439973dSWarner Losh 
15f439973dSWarner Losh #ifndef __SIMPLE_FILE_SYSTEM_H__
16f439973dSWarner Losh #define __SIMPLE_FILE_SYSTEM_H__
17f439973dSWarner Losh 
18f439973dSWarner Losh #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
19f439973dSWarner Losh   { \
20f439973dSWarner Losh     0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
21f439973dSWarner Losh   }
22f439973dSWarner Losh 
23f439973dSWarner Losh typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
24f439973dSWarner Losh 
25f439973dSWarner Losh typedef struct _EFI_FILE_PROTOCOL EFI_FILE_PROTOCOL;
26f439973dSWarner Losh typedef struct _EFI_FILE_PROTOCOL *EFI_FILE_HANDLE;
27f439973dSWarner Losh 
28f439973dSWarner Losh ///
29f439973dSWarner Losh /// Protocol GUID name defined in EFI1.1.
30f439973dSWarner Losh ///
31f439973dSWarner Losh #define SIMPLE_FILE_SYSTEM_PROTOCOL  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
32f439973dSWarner Losh 
33f439973dSWarner Losh ///
34f439973dSWarner Losh /// Protocol name defined in EFI1.1.
35f439973dSWarner Losh ///
36f439973dSWarner Losh typedef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_FILE_IO_INTERFACE;
37f439973dSWarner Losh typedef EFI_FILE_PROTOCOL               EFI_FILE;
38f439973dSWarner Losh 
39f439973dSWarner Losh /**
40f439973dSWarner Losh   Open the root directory on a volume.
41f439973dSWarner Losh 
42f439973dSWarner Losh   @param  This A pointer to the volume to open the root directory.
43f439973dSWarner Losh   @param  Root A pointer to the location to return the opened file handle for the
44f439973dSWarner Losh                root directory.
45f439973dSWarner Losh 
46f439973dSWarner Losh   @retval EFI_SUCCESS          The device was opened.
47f439973dSWarner Losh   @retval EFI_UNSUPPORTED      This volume does not support the requested file system type.
48f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
49f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
50f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
51f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    The service denied access to the file.
52f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
53f439973dSWarner Losh   @retval EFI_MEDIA_CHANGED    The device has a different medium in it or the medium is no
54f439973dSWarner Losh                                longer supported. Any existing file handles for this volume are
55f439973dSWarner Losh                                no longer valid. To access the files on the new medium, the
56f439973dSWarner Losh                                volume must be reopened with OpenVolume().
57f439973dSWarner Losh 
58f439973dSWarner Losh **/
59f439973dSWarner Losh typedef
60f439973dSWarner Losh EFI_STATUS
61f439973dSWarner Losh (EFIAPI *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME)(
62f439973dSWarner Losh   IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL    *This,
63f439973dSWarner Losh   OUT EFI_FILE_PROTOCOL                 **Root
64f439973dSWarner Losh   );
65f439973dSWarner Losh 
66f439973dSWarner Losh #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION  0x00010000
67f439973dSWarner Losh 
68f439973dSWarner Losh ///
69f439973dSWarner Losh /// Revision defined in EFI1.1
70f439973dSWarner Losh ///
71f439973dSWarner Losh #define EFI_FILE_IO_INTERFACE_REVISION  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION
72f439973dSWarner Losh 
73f439973dSWarner Losh struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
74f439973dSWarner Losh   ///
75f439973dSWarner Losh   /// The version of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. The version
76f439973dSWarner Losh   /// specified by this specification is 0x00010000. All future revisions
77f439973dSWarner Losh   /// must be backwards compatible.
78f439973dSWarner Losh   ///
79f439973dSWarner Losh   UINT64                                         Revision;
80f439973dSWarner Losh   EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME    OpenVolume;
81f439973dSWarner Losh };
82f439973dSWarner Losh 
83f439973dSWarner Losh /**
84f439973dSWarner Losh   Opens a new file relative to the source file's location.
85f439973dSWarner Losh 
86f439973dSWarner Losh   @param  This       A pointer to the EFI_FILE_PROTOCOL instance that is the file
87f439973dSWarner Losh                      handle to the source location. This would typically be an open
88f439973dSWarner Losh                      handle to a directory.
89f439973dSWarner Losh   @param  NewHandle  A pointer to the location to return the opened handle for the new
90f439973dSWarner Losh                      file.
91f439973dSWarner Losh   @param  FileName   The Null-terminated string of the name of the file to be opened.
92f439973dSWarner Losh                      The file name may contain the following path modifiers: "\", ".",
93f439973dSWarner Losh                      and "..".
94f439973dSWarner Losh   @param  OpenMode   The mode to open the file. The only valid combinations that the
95f439973dSWarner Losh                      file may be opened with are: Read, Read/Write, or Create/Read/Write.
96f439973dSWarner Losh   @param  Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the
97f439973dSWarner Losh                      attribute bits for the newly created file.
98f439973dSWarner Losh 
99f439973dSWarner Losh   @retval EFI_SUCCESS          The file was opened.
100f439973dSWarner Losh   @retval EFI_NOT_FOUND        The specified file could not be found on the device.
101f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
102f439973dSWarner Losh   @retval EFI_MEDIA_CHANGED    The device has a different medium in it or the medium is no
103f439973dSWarner Losh                                longer supported.
104f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
105f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
106f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  An attempt was made to create a file, or open a file for write
107f439973dSWarner Losh                                when the media is write-protected.
108f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    The service denied access to the file.
109f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
110f439973dSWarner Losh   @retval EFI_VOLUME_FULL      The volume is full.
111f439973dSWarner Losh 
112f439973dSWarner Losh **/
113f439973dSWarner Losh typedef
114f439973dSWarner Losh EFI_STATUS
115f439973dSWarner Losh (EFIAPI *EFI_FILE_OPEN)(
116f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
117f439973dSWarner Losh   OUT EFI_FILE_PROTOCOL       **NewHandle,
118f439973dSWarner Losh   IN CHAR16                   *FileName,
119f439973dSWarner Losh   IN UINT64                   OpenMode,
120f439973dSWarner Losh   IN UINT64                   Attributes
121f439973dSWarner Losh   );
122f439973dSWarner Losh 
123f439973dSWarner Losh //
124f439973dSWarner Losh // Open modes
125f439973dSWarner Losh //
126f439973dSWarner Losh #define EFI_FILE_MODE_READ    0x0000000000000001ULL
127f439973dSWarner Losh #define EFI_FILE_MODE_WRITE   0x0000000000000002ULL
128f439973dSWarner Losh #define EFI_FILE_MODE_CREATE  0x8000000000000000ULL
129f439973dSWarner Losh 
130f439973dSWarner Losh //
131f439973dSWarner Losh // File attributes
132f439973dSWarner Losh //
133f439973dSWarner Losh #define EFI_FILE_READ_ONLY   0x0000000000000001ULL
134f439973dSWarner Losh #define EFI_FILE_HIDDEN      0x0000000000000002ULL
135f439973dSWarner Losh #define EFI_FILE_SYSTEM      0x0000000000000004ULL
136f439973dSWarner Losh #define EFI_FILE_RESERVED    0x0000000000000008ULL
137f439973dSWarner Losh #define EFI_FILE_DIRECTORY   0x0000000000000010ULL
138f439973dSWarner Losh #define EFI_FILE_ARCHIVE     0x0000000000000020ULL
139f439973dSWarner Losh #define EFI_FILE_VALID_ATTR  0x0000000000000037ULL
140f439973dSWarner Losh 
141f439973dSWarner Losh /**
142f439973dSWarner Losh   Closes a specified file handle.
143f439973dSWarner Losh 
144f439973dSWarner Losh   @param  This          A pointer to the EFI_FILE_PROTOCOL instance that is the file
145f439973dSWarner Losh                         handle to close.
146f439973dSWarner Losh 
147f439973dSWarner Losh   @retval EFI_SUCCESS   The file was closed.
148f439973dSWarner Losh 
149f439973dSWarner Losh **/
150f439973dSWarner Losh typedef
151f439973dSWarner Losh EFI_STATUS
152f439973dSWarner Losh (EFIAPI *EFI_FILE_CLOSE)(
153f439973dSWarner Losh   IN EFI_FILE_PROTOCOL  *This
154f439973dSWarner Losh   );
155f439973dSWarner Losh 
156f439973dSWarner Losh /**
157f439973dSWarner Losh   Close and delete the file handle.
158f439973dSWarner Losh 
159f439973dSWarner Losh   @param  This                     A pointer to the EFI_FILE_PROTOCOL instance that is the
160f439973dSWarner Losh                                    handle to the file to delete.
161f439973dSWarner Losh 
162f439973dSWarner Losh   @retval EFI_SUCCESS              The file was closed and deleted, and the handle was closed.
163f439973dSWarner Losh   @retval EFI_WARN_DELETE_FAILURE  The handle was closed, but the file was not deleted.
164f439973dSWarner Losh 
165f439973dSWarner Losh **/
166f439973dSWarner Losh typedef
167f439973dSWarner Losh EFI_STATUS
168f439973dSWarner Losh (EFIAPI *EFI_FILE_DELETE)(
169f439973dSWarner Losh   IN EFI_FILE_PROTOCOL  *This
170f439973dSWarner Losh   );
171f439973dSWarner Losh 
172f439973dSWarner Losh /**
173f439973dSWarner Losh   Reads data from a file.
174f439973dSWarner Losh 
175f439973dSWarner Losh   @param  This       A pointer to the EFI_FILE_PROTOCOL instance that is the file
176f439973dSWarner Losh                      handle to read data from.
177f439973dSWarner Losh   @param  BufferSize On input, the size of the Buffer. On output, the amount of data
178f439973dSWarner Losh                      returned in Buffer. In both cases, the size is measured in bytes.
179f439973dSWarner Losh   @param  Buffer     The buffer into which the data is read.
180f439973dSWarner Losh 
181f439973dSWarner Losh   @retval EFI_SUCCESS          Data was read.
182f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
183f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
184f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     An attempt was made to read from a deleted file.
185f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     On entry, the current file position is beyond the end of the file.
186f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
187f439973dSWarner Losh   @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory
188f439973dSWarner Losh                                entry. BufferSize has been updated with the size
189f439973dSWarner Losh                                needed to complete the request.
190f439973dSWarner Losh 
191f439973dSWarner Losh **/
192f439973dSWarner Losh typedef
193f439973dSWarner Losh EFI_STATUS
194f439973dSWarner Losh (EFIAPI *EFI_FILE_READ)(
195f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
196f439973dSWarner Losh   IN OUT UINTN                *BufferSize,
197f439973dSWarner Losh   OUT VOID                    *Buffer
198f439973dSWarner Losh   );
199f439973dSWarner Losh 
200f439973dSWarner Losh /**
201f439973dSWarner Losh   Writes data to a file.
202f439973dSWarner Losh 
203f439973dSWarner Losh   @param  This       A pointer to the EFI_FILE_PROTOCOL instance that is the file
204f439973dSWarner Losh                      handle to write data to.
205f439973dSWarner Losh   @param  BufferSize On input, the size of the Buffer. On output, the amount of data
206f439973dSWarner Losh                      actually written. In both cases, the size is measured in bytes.
207f439973dSWarner Losh   @param  Buffer     The buffer of data to write.
208f439973dSWarner Losh 
209f439973dSWarner Losh   @retval EFI_SUCCESS          Data was written.
210f439973dSWarner Losh   @retval EFI_UNSUPPORTED      Writes to open directory files are not supported.
211f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
212f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
213f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     An attempt was made to write to a deleted file.
214f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
215f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  The file or medium is write-protected.
216f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    The file was opened read only.
217f439973dSWarner Losh   @retval EFI_VOLUME_FULL      The volume is full.
218f439973dSWarner Losh 
219f439973dSWarner Losh **/
220f439973dSWarner Losh typedef
221f439973dSWarner Losh EFI_STATUS
222f439973dSWarner Losh (EFIAPI *EFI_FILE_WRITE)(
223f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
224f439973dSWarner Losh   IN OUT UINTN                *BufferSize,
225f439973dSWarner Losh   IN VOID                     *Buffer
226f439973dSWarner Losh   );
227f439973dSWarner Losh 
228f439973dSWarner Losh /**
229f439973dSWarner Losh   Sets a file's current position.
230f439973dSWarner Losh 
231f439973dSWarner Losh   @param  This            A pointer to the EFI_FILE_PROTOCOL instance that is the
232f439973dSWarner Losh                           file handle to set the requested position on.
233f439973dSWarner Losh   @param  Position        The byte position from the start of the file to set.
234f439973dSWarner Losh 
235f439973dSWarner Losh   @retval EFI_SUCCESS      The position was set.
236f439973dSWarner Losh   @retval EFI_UNSUPPORTED  The seek request for nonzero is not valid on open
237f439973dSWarner Losh                            directories.
238f439973dSWarner Losh   @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted file.
239f439973dSWarner Losh 
240f439973dSWarner Losh **/
241f439973dSWarner Losh typedef
242f439973dSWarner Losh EFI_STATUS
243f439973dSWarner Losh (EFIAPI *EFI_FILE_SET_POSITION)(
244f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
245f439973dSWarner Losh   IN UINT64                   Position
246f439973dSWarner Losh   );
247f439973dSWarner Losh 
248f439973dSWarner Losh /**
249f439973dSWarner Losh   Returns a file's current position.
250f439973dSWarner Losh 
251f439973dSWarner Losh   @param  This            A pointer to the EFI_FILE_PROTOCOL instance that is the file
252f439973dSWarner Losh                           handle to get the current position on.
253f439973dSWarner Losh   @param  Position        The address to return the file's current position value.
254f439973dSWarner Losh 
255f439973dSWarner Losh   @retval EFI_SUCCESS      The position was returned.
256f439973dSWarner Losh   @retval EFI_UNSUPPORTED  The request is not valid on open directories.
257f439973dSWarner Losh   @retval EFI_DEVICE_ERROR An attempt was made to get the position from a deleted file.
258f439973dSWarner Losh 
259f439973dSWarner Losh **/
260f439973dSWarner Losh typedef
261f439973dSWarner Losh EFI_STATUS
262f439973dSWarner Losh (EFIAPI *EFI_FILE_GET_POSITION)(
263f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
264f439973dSWarner Losh   OUT UINT64                  *Position
265f439973dSWarner Losh   );
266f439973dSWarner Losh 
267f439973dSWarner Losh /**
268f439973dSWarner Losh   Returns information about a file.
269f439973dSWarner Losh 
270f439973dSWarner Losh   @param  This            A pointer to the EFI_FILE_PROTOCOL instance that is the file
271f439973dSWarner Losh                           handle the requested information is for.
272f439973dSWarner Losh   @param  InformationType The type identifier for the information being requested.
273f439973dSWarner Losh   @param  BufferSize      On input, the size of Buffer. On output, the amount of data
274f439973dSWarner Losh                           returned in Buffer. In both cases, the size is measured in bytes.
275f439973dSWarner Losh   @param  Buffer          A pointer to the data buffer to return. The buffer's type is
276f439973dSWarner Losh                           indicated by InformationType.
277f439973dSWarner Losh 
278f439973dSWarner Losh   @retval EFI_SUCCESS          The information was returned.
279f439973dSWarner Losh   @retval EFI_UNSUPPORTED      The InformationType is not known.
280f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
281f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
282f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
283f439973dSWarner Losh   @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.
284f439973dSWarner Losh                                BufferSize has been updated with the size needed to complete
285f439973dSWarner Losh                                the request.
286f439973dSWarner Losh **/
287f439973dSWarner Losh typedef
288f439973dSWarner Losh EFI_STATUS
289f439973dSWarner Losh (EFIAPI *EFI_FILE_GET_INFO)(
290f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
291f439973dSWarner Losh   IN EFI_GUID                 *InformationType,
292f439973dSWarner Losh   IN OUT UINTN                *BufferSize,
293f439973dSWarner Losh   OUT VOID                    *Buffer
294f439973dSWarner Losh   );
295f439973dSWarner Losh 
296f439973dSWarner Losh /**
297f439973dSWarner Losh   Sets information about a file.
298f439973dSWarner Losh 
299f439973dSWarner Losh   @param  File            A pointer to the EFI_FILE_PROTOCOL instance that is the file
300f439973dSWarner Losh                           handle the information is for.
301f439973dSWarner Losh   @param  InformationType The type identifier for the information being set.
302f439973dSWarner Losh   @param  BufferSize      The size, in bytes, of Buffer.
303f439973dSWarner Losh   @param  Buffer          A pointer to the data buffer to write. The buffer's type is
304f439973dSWarner Losh                           indicated by InformationType.
305f439973dSWarner Losh 
306f439973dSWarner Losh   @retval EFI_SUCCESS          The information was set.
307f439973dSWarner Losh   @retval EFI_UNSUPPORTED      The InformationType is not known.
308f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
309f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
310f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
311f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  InformationType is EFI_FILE_INFO_ID and the media is
312f439973dSWarner Losh                                read-only.
313f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  InformationType is EFI_FILE_PROTOCOL_SYSTEM_INFO_ID
314f439973dSWarner Losh                                and the media is read only.
315f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  InformationType is EFI_FILE_SYSTEM_VOLUME_LABEL_ID
316f439973dSWarner Losh                                and the media is read-only.
317f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    An attempt is made to change the name of a file to a
318f439973dSWarner Losh                                file that is already present.
319f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    An attempt is being made to change the EFI_FILE_DIRECTORY
320f439973dSWarner Losh                                Attribute.
321f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    An attempt is being made to change the size of a directory.
322f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    InformationType is EFI_FILE_INFO_ID and the file was opened
323f439973dSWarner Losh                                read-only and an attempt is being made to modify a field
324f439973dSWarner Losh                                other than Attribute.
325f439973dSWarner Losh   @retval EFI_VOLUME_FULL      The volume is full.
326f439973dSWarner Losh   @retval EFI_BAD_BUFFER_SIZE  BufferSize is smaller than the size of the type indicated
327f439973dSWarner Losh                                by InformationType.
328f439973dSWarner Losh 
329f439973dSWarner Losh **/
330f439973dSWarner Losh typedef
331f439973dSWarner Losh EFI_STATUS
332f439973dSWarner Losh (EFIAPI *EFI_FILE_SET_INFO)(
333f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
334f439973dSWarner Losh   IN EFI_GUID                 *InformationType,
335f439973dSWarner Losh   IN UINTN                    BufferSize,
336f439973dSWarner Losh   IN VOID                     *Buffer
337f439973dSWarner Losh   );
338f439973dSWarner Losh 
339f439973dSWarner Losh /**
340f439973dSWarner Losh   Flushes all modified data associated with a file to a device.
341f439973dSWarner Losh 
342f439973dSWarner Losh   @param  This A pointer to the EFI_FILE_PROTOCOL instance that is the file
343f439973dSWarner Losh                handle to flush.
344f439973dSWarner Losh 
345f439973dSWarner Losh   @retval EFI_SUCCESS          The data was flushed.
346f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
347f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
348f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
349f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  The file or medium is write-protected.
350f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    The file was opened read-only.
351f439973dSWarner Losh   @retval EFI_VOLUME_FULL      The volume is full.
352f439973dSWarner Losh 
353f439973dSWarner Losh **/
354f439973dSWarner Losh typedef
355f439973dSWarner Losh EFI_STATUS
356f439973dSWarner Losh (EFIAPI *EFI_FILE_FLUSH)(
357f439973dSWarner Losh   IN EFI_FILE_PROTOCOL  *This
358f439973dSWarner Losh   );
359f439973dSWarner Losh 
360f439973dSWarner Losh typedef struct {
361f439973dSWarner Losh   //
362f439973dSWarner Losh   // If Event is NULL, then blocking I/O is performed.
363f439973dSWarner Losh   // If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed,
364f439973dSWarner Losh   // and Event will be signaled when the read request is completed.
365f439973dSWarner Losh   // The caller must be prepared to handle the case where the callback associated with Event
366f439973dSWarner Losh   // occurs before the original asynchronous I/O request call returns.
367f439973dSWarner Losh   //
368f439973dSWarner Losh   EFI_EVENT     Event;
369f439973dSWarner Losh 
370f439973dSWarner Losh   //
371f439973dSWarner Losh   // Defines whether or not the signaled event encountered an error.
372f439973dSWarner Losh   //
373f439973dSWarner Losh   EFI_STATUS    Status;
374f439973dSWarner Losh 
375f439973dSWarner Losh   //
376f439973dSWarner Losh   // For OpenEx():  Not Used, ignored.
377f439973dSWarner Losh   // For ReadEx():  On input, the size of the Buffer. On output, the amount of data returned in Buffer.
378f439973dSWarner Losh   //                In both cases, the size is measured in bytes.
379f439973dSWarner Losh   // For WriteEx(): On input, the size of the Buffer. On output, the amount of data actually written.
380f439973dSWarner Losh   //                In both cases, the size is measured in bytes.
381f439973dSWarner Losh   // For FlushEx(): Not used, ignored.
382f439973dSWarner Losh   //
383f439973dSWarner Losh   UINTN    BufferSize;
384f439973dSWarner Losh 
385f439973dSWarner Losh   //
386f439973dSWarner Losh   // For OpenEx():  Not Used, ignored.
387f439973dSWarner Losh   // For ReadEx():  The buffer into which the data is read.
388f439973dSWarner Losh   // For WriteEx(): The buffer of data to write.
389f439973dSWarner Losh   // For FlushEx(): Not Used, ignored.
390f439973dSWarner Losh   //
391f439973dSWarner Losh   VOID     *Buffer;
392f439973dSWarner Losh } EFI_FILE_IO_TOKEN;
393f439973dSWarner Losh 
394f439973dSWarner Losh /**
395f439973dSWarner Losh   Opens a new file relative to the source directory's location.
396f439973dSWarner Losh 
397f439973dSWarner Losh   @param  This       A pointer to the EFI_FILE_PROTOCOL instance that is the file
398f439973dSWarner Losh                      handle to the source location.
399f439973dSWarner Losh   @param  NewHandle  A pointer to the location to return the opened handle for the new
400f439973dSWarner Losh                      file.
401f439973dSWarner Losh   @param  FileName   The Null-terminated string of the name of the file to be opened.
402f439973dSWarner Losh                      The file name may contain the following path modifiers: "\", ".",
403f439973dSWarner Losh                      and "..".
404f439973dSWarner Losh   @param  OpenMode   The mode to open the file. The only valid combinations that the
405f439973dSWarner Losh                      file may be opened with are: Read, Read/Write, or Create/Read/Write.
406f439973dSWarner Losh   @param  Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the
407f439973dSWarner Losh                      attribute bits for the newly created file.
408f439973dSWarner Losh   @param  Token      A pointer to the token associated with the transaction.
409f439973dSWarner Losh 
410f439973dSWarner Losh   @retval EFI_SUCCESS          If Event is NULL (blocking I/O): The data was read successfully.
411f439973dSWarner Losh                                If Event is not NULL (asynchronous I/O): The request was successfully
412f439973dSWarner Losh                                                                         queued for processing.
413f439973dSWarner Losh   @retval EFI_NOT_FOUND        The specified file could not be found on the device.
414f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
415f439973dSWarner Losh   @retval EFI_MEDIA_CHANGED    The device has a different medium in it or the medium is no
416f439973dSWarner Losh                                longer supported.
417f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
418f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
419f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  An attempt was made to create a file, or open a file for write
420f439973dSWarner Losh                                when the media is write-protected.
421f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    The service denied access to the file.
422f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
423f439973dSWarner Losh   @retval EFI_VOLUME_FULL      The volume is full.
424f439973dSWarner Losh 
425f439973dSWarner Losh **/
426f439973dSWarner Losh typedef
427f439973dSWarner Losh EFI_STATUS
428f439973dSWarner Losh (EFIAPI *EFI_FILE_OPEN_EX)(
429f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
430f439973dSWarner Losh   OUT EFI_FILE_PROTOCOL       **NewHandle,
431f439973dSWarner Losh   IN CHAR16                   *FileName,
432f439973dSWarner Losh   IN UINT64                   OpenMode,
433f439973dSWarner Losh   IN UINT64                   Attributes,
434f439973dSWarner Losh   IN OUT EFI_FILE_IO_TOKEN    *Token
435f439973dSWarner Losh   );
436f439973dSWarner Losh 
437f439973dSWarner Losh /**
438f439973dSWarner Losh   Reads data from a file.
439f439973dSWarner Losh 
440f439973dSWarner Losh   @param  This       A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to read data from.
441f439973dSWarner Losh   @param  Token      A pointer to the token associated with the transaction.
442f439973dSWarner Losh 
443f439973dSWarner Losh   @retval EFI_SUCCESS          If Event is NULL (blocking I/O): The data was read successfully.
444f439973dSWarner Losh                                If Event is not NULL (asynchronous I/O): The request was successfully
445f439973dSWarner Losh                                                                         queued for processing.
446f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
447f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
448f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     An attempt was made to read from a deleted file.
449f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     On entry, the current file position is beyond the end of the file.
450f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
451f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
452f439973dSWarner Losh **/
453f439973dSWarner Losh typedef
454f439973dSWarner Losh EFI_STATUS
455f439973dSWarner Losh (EFIAPI *EFI_FILE_READ_EX)(
456f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
457f439973dSWarner Losh   IN OUT EFI_FILE_IO_TOKEN    *Token
458f439973dSWarner Losh   );
459f439973dSWarner Losh 
460f439973dSWarner Losh /**
461f439973dSWarner Losh   Writes data to a file.
462f439973dSWarner Losh 
463f439973dSWarner Losh   @param  This       A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to write data to.
464f439973dSWarner Losh   @param  Token      A pointer to the token associated with the transaction.
465f439973dSWarner Losh 
466f439973dSWarner Losh   @retval EFI_SUCCESS          If Event is NULL (blocking I/O): The data was read successfully.
467f439973dSWarner Losh                                If Event is not NULL (asynchronous I/O): The request was successfully
468f439973dSWarner Losh                                                                         queued for processing.
469f439973dSWarner Losh   @retval EFI_UNSUPPORTED      Writes to open directory files are not supported.
470f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
471f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
472f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     An attempt was made to write to a deleted file.
473f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
474f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  The file or medium is write-protected.
475f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    The file was opened read only.
476f439973dSWarner Losh   @retval EFI_VOLUME_FULL      The volume is full.
477f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
478f439973dSWarner Losh **/
479f439973dSWarner Losh typedef
480f439973dSWarner Losh EFI_STATUS
481f439973dSWarner Losh (EFIAPI *EFI_FILE_WRITE_EX)(
482f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
483f439973dSWarner Losh   IN OUT EFI_FILE_IO_TOKEN    *Token
484f439973dSWarner Losh   );
485f439973dSWarner Losh 
486f439973dSWarner Losh /**
487f439973dSWarner Losh   Flushes all modified data associated with a file to a device.
488f439973dSWarner Losh 
489f439973dSWarner Losh   @param  This  A pointer to the EFI_FILE_PROTOCOL instance that is the file
490f439973dSWarner Losh                 handle to flush.
491f439973dSWarner Losh   @param  Token A pointer to the token associated with the transaction.
492f439973dSWarner Losh 
493f439973dSWarner Losh   @retval EFI_SUCCESS          If Event is NULL (blocking I/O): The data was read successfully.
494f439973dSWarner Losh                                If Event is not NULL (asynchronous I/O): The request was successfully
495f439973dSWarner Losh                                                                         queued for processing.
496f439973dSWarner Losh   @retval EFI_NO_MEDIA         The device has no medium.
497f439973dSWarner Losh   @retval EFI_DEVICE_ERROR     The device reported an error.
498f439973dSWarner Losh   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
499f439973dSWarner Losh   @retval EFI_WRITE_PROTECTED  The file or medium is write-protected.
500f439973dSWarner Losh   @retval EFI_ACCESS_DENIED    The file was opened read-only.
501f439973dSWarner Losh   @retval EFI_VOLUME_FULL      The volume is full.
502f439973dSWarner Losh   @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
503f439973dSWarner Losh 
504f439973dSWarner Losh **/
505f439973dSWarner Losh typedef
506f439973dSWarner Losh EFI_STATUS
507f439973dSWarner Losh (EFIAPI *EFI_FILE_FLUSH_EX)(
508f439973dSWarner Losh   IN EFI_FILE_PROTOCOL        *This,
509f439973dSWarner Losh   IN OUT EFI_FILE_IO_TOKEN    *Token
510f439973dSWarner Losh   );
511f439973dSWarner Losh 
512f439973dSWarner Losh #define EFI_FILE_PROTOCOL_REVISION         0x00010000
513f439973dSWarner Losh #define EFI_FILE_PROTOCOL_REVISION2        0x00020000
514f439973dSWarner Losh #define EFI_FILE_PROTOCOL_LATEST_REVISION  EFI_FILE_PROTOCOL_REVISION2
515f439973dSWarner Losh 
516f439973dSWarner Losh //
517f439973dSWarner Losh // Revision defined in EFI1.1.
518f439973dSWarner Losh //
519f439973dSWarner Losh #define EFI_FILE_REVISION  EFI_FILE_PROTOCOL_REVISION
520f439973dSWarner Losh 
521f439973dSWarner Losh ///
522f439973dSWarner Losh /// The EFI_FILE_PROTOCOL provides file IO access to supported file systems.
523f439973dSWarner Losh /// An EFI_FILE_PROTOCOL provides access to a file's or directory's contents,
524f439973dSWarner Losh /// and is also a reference to a location in the directory tree of the file system
525f439973dSWarner Losh /// in which the file resides. With any given file handle, other files may be opened
526f439973dSWarner Losh /// relative to this file's location, yielding new file handles.
527f439973dSWarner Losh ///
528f439973dSWarner Losh struct _EFI_FILE_PROTOCOL {
529f439973dSWarner Losh   ///
530f439973dSWarner Losh   /// The version of the EFI_FILE_PROTOCOL interface. The version specified
531f439973dSWarner Losh   /// by this specification is EFI_FILE_PROTOCOL_LATEST_REVISION.
532f439973dSWarner Losh   /// Future versions are required to be backward compatible to version 1.0.
533f439973dSWarner Losh   ///
534f439973dSWarner Losh   UINT64                   Revision;
535f439973dSWarner Losh   EFI_FILE_OPEN            Open;
536f439973dSWarner Losh   EFI_FILE_CLOSE           Close;
537f439973dSWarner Losh   EFI_FILE_DELETE          Delete;
538f439973dSWarner Losh   EFI_FILE_READ            Read;
539f439973dSWarner Losh   EFI_FILE_WRITE           Write;
540f439973dSWarner Losh   EFI_FILE_GET_POSITION    GetPosition;
541f439973dSWarner Losh   EFI_FILE_SET_POSITION    SetPosition;
542f439973dSWarner Losh   EFI_FILE_GET_INFO        GetInfo;
543f439973dSWarner Losh   EFI_FILE_SET_INFO        SetInfo;
544f439973dSWarner Losh   EFI_FILE_FLUSH           Flush;
545f439973dSWarner Losh   EFI_FILE_OPEN_EX         OpenEx;
546f439973dSWarner Losh   EFI_FILE_READ_EX         ReadEx;
547f439973dSWarner Losh   EFI_FILE_WRITE_EX        WriteEx;
548f439973dSWarner Losh   EFI_FILE_FLUSH_EX        FlushEx;
549f439973dSWarner Losh };
550f439973dSWarner Losh 
551f439973dSWarner Losh extern EFI_GUID  gEfiSimpleFileSystemProtocolGuid;
552f439973dSWarner Losh 
553f439973dSWarner Losh #endif
554