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