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