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