]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/SimpleFileSystem.h
add a error macro to prevent this file from included for now #error "UEFI 2.1 HII...
[mirror_edk2.git] / MdePkg / Include / Protocol / SimpleFileSystem.h
1 /** @file
2 SimpleFileSystem protocol as defined in the EFI 1.0 specification.
3
4 The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32)
5 file system specified in EFI 1.0. It can also be used to abstract a file
6 system other than FAT.
7
8 EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem
9
10 Copyright (c) 2006, 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
69 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
70 //
71 // Revision defined in EFI1.1
72 //
73 #define EFI_FILE_IO_INTERFACE_REVISION EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION
74
75 struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
76 UINT64 Revision;
77 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume;
78 };
79
80 /**
81 Open the root directory on a volume.
82
83 @param This Protocol instance pointer.
84 @param NewHandle Returns File Handle for FileName
85 @param FileName Null terminated string. "\", ".", and ".." are supported
86 @param OpenMode Open mode for file.
87 @param Attributes Only used for EFI_FILE_MODE_CREATE
88
89 @retval EFI_SUCCESS The device was opened.
90 @retval EFI_NOT_FOUND The specified file could not be found on the device
91 @retval EFI_NO_MEDIA The device has no media.
92 @retval EFI_MEDIA_CHANGED The media has changed
93 @retval EFI_DEVICE_ERROR The device reported an error.
94 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
95 @retval EFI_ACCESS_DENIED The service denied access to the file
96 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources
97 @retval EFI_VOLUME_FULL The volume is full.
98
99 **/
100 typedef
101 EFI_STATUS
102 (EFIAPI *EFI_FILE_OPEN) (
103 IN EFI_FILE_PROTOCOL *This,
104 OUT EFI_FILE_PROTOCOL **NewHandle,
105 IN CHAR16 *FileName,
106 IN UINT64 OpenMode,
107 IN UINT64 Attributes
108 )
109 ;
110
111 //
112 // Open modes
113 //
114 #define EFI_FILE_MODE_READ 0x0000000000000001ULL
115 #define EFI_FILE_MODE_WRITE 0x0000000000000002ULL
116 #define EFI_FILE_MODE_CREATE 0x8000000000000000ULL
117
118 //
119 // File attributes
120 //
121 #define EFI_FILE_READ_ONLY 0x0000000000000001ULL
122 #define EFI_FILE_HIDDEN 0x0000000000000002ULL
123 #define EFI_FILE_SYSTEM 0x0000000000000004ULL
124 #define EFI_FILE_RESERVED 0x0000000000000008ULL
125 #define EFI_FILE_DIRECTORY 0x0000000000000010ULL
126 #define EFI_FILE_ARCHIVE 0x0000000000000020ULL
127 #define EFI_FILE_VALID_ATTR 0x0000000000000037ULL
128
129 /**
130 Close the file handle
131
132 @param This Protocol instance pointer.
133
134 @retval EFI_SUCCESS The device was opened.
135
136 **/
137 typedef
138 EFI_STATUS
139 (EFIAPI *EFI_FILE_CLOSE) (
140 IN EFI_FILE *This
141 )
142 ;
143
144 /**
145 Close and delete the file handle
146
147 @param This Protocol instance pointer.
148
149 @retval EFI_SUCCESS The device was opened.
150 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted
151
152 **/
153 typedef
154 EFI_STATUS
155 (EFIAPI *EFI_FILE_DELETE) (
156 IN EFI_FILE *This
157 )
158 ;
159
160 /**
161 Read data from the file.
162
163 @param This Protocol instance pointer.
164 @param BufferSize On input size of buffer, on output amount of data in buffer.
165 @param Buffer The buffer in which data is read.
166
167 @retval EFI_SUCCESS Data was read.
168 @retval EFI_NO_MEDIA The device has no media
169 @retval EFI_DEVICE_ERROR The device reported an error
170 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
171 @retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size
172
173 **/
174 typedef
175 EFI_STATUS
176 (EFIAPI *EFI_FILE_READ) (
177 IN EFI_FILE_PROTOCOL *This,
178 IN OUT UINTN *BufferSize,
179 OUT VOID *Buffer
180 )
181 ;
182
183 /**
184 Write data from to the file.
185
186 @param This Protocol instance pointer.
187 @param BufferSize On input size of buffer, on output amount of data in buffer.
188 @param Buffer The buffer in which data to write.
189
190 @retval EFI_SUCCESS Data was written.
191 @retval EFI_UNSUPPORT Writes to Open directory are not supported
192 @retval EFI_NO_MEDIA The device has no media
193 @retval EFI_DEVICE_ERROR The device reported an error
194 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
195 @retval EFI_WRITE_PROTECTED The device is write protected
196 @retval EFI_ACCESS_DENIED The file was open for read only
197 @retval EFI_VOLUME_FULL The volume is full
198
199 **/
200 typedef
201 EFI_STATUS
202 (EFIAPI *EFI_FILE_WRITE) (
203 IN EFI_FILE_PROTOCOL *This,
204 IN OUT UINTN *BufferSize,
205 IN VOID *Buffer
206 )
207 ;
208
209 /**
210 Set a files current position
211
212 @param This Protocol instance pointer.
213 @param Position Byte possition from the start of the file
214
215 @retval EFI_SUCCESS Data was written.
216 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
217
218 **/
219 typedef
220 EFI_STATUS
221 (EFIAPI *EFI_FILE_SET_POSITION) (
222 IN EFI_FILE_PROTOCOL *This,
223 IN UINT64 Position
224 )
225 ;
226
227 /**
228 Get a files current position
229
230 @param This Protocol instance pointer.
231 @param Position Byte possition from the start of the file
232
233 @retval EFI_SUCCESS Data was written.
234 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
235
236 **/
237 typedef
238 EFI_STATUS
239 (EFIAPI *EFI_FILE_GET_POSITION) (
240 IN EFI_FILE_PROTOCOL *This,
241 OUT UINT64 *Position
242 )
243 ;
244
245 /**
246 Get information about a file
247
248 @param This Protocol instance pointer.
249 @param InformationType Type of info to return in Buffer
250 @param BufferSize On input size of buffer, on output amount of data in buffer.
251 @param Buffer The buffer to return data.
252
253 @retval EFI_SUCCESS Data was returned.
254 @retval EFI_UNSUPPORT InformationType is not supported
255 @retval EFI_NO_MEDIA The device has no media
256 @retval EFI_DEVICE_ERROR The device reported an error
257 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
258 @retval EFI_WRITE_PROTECTED The device is write protected
259 @retval EFI_ACCESS_DENIED The file was open for read only
260 @retval EFI_BUFFER_TOO_SMALL Buffer was too small, required size returned in BufferSize
261
262 **/
263 typedef
264 EFI_STATUS
265 (EFIAPI *EFI_FILE_GET_INFO) (
266 IN EFI_FILE_PROTOCOL *This,
267 IN EFI_GUID *InformationType,
268 IN OUT UINTN *BufferSize,
269 OUT VOID *Buffer
270 )
271 ;
272
273 /**
274 Set information about a file
275
276 @param File Protocol instance pointer.
277 @param InformationType Type of info in Buffer
278 @param BufferSize Size of buffer.
279 @param Buffer The data to write.
280
281 @retval EFI_SUCCESS Data was returned.
282 @retval EFI_UNSUPPORT InformationType is not supported
283 @retval EFI_NO_MEDIA The device has no media
284 @retval EFI_DEVICE_ERROR The device reported an error
285 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
286 @retval EFI_WRITE_PROTECTED The device is write protected
287 @retval EFI_ACCESS_DENIED The file was open for read only
288
289 **/
290 typedef
291 EFI_STATUS
292 (EFIAPI *EFI_FILE_SET_INFO) (
293 IN EFI_FILE_PROTOCOL *This,
294 IN EFI_GUID *InformationType,
295 IN UINTN BufferSize,
296 IN VOID *Buffer
297 )
298 ;
299
300 /**
301 Flush data back for the file handle
302
303 @param This Protocol instance pointer.
304
305 @retval EFI_SUCCESS Data was written.
306 @retval EFI_UNSUPPORT Writes to Open directory are not supported
307 @retval EFI_NO_MEDIA The device has no media
308 @retval EFI_DEVICE_ERROR The device reported an error
309 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
310 @retval EFI_WRITE_PROTECTED The device is write protected
311 @retval EFI_ACCESS_DENIED The file was open for read only
312 @retval EFI_VOLUME_FULL The volume is full
313
314 **/
315 typedef
316 EFI_STATUS
317 (EFIAPI *EFI_FILE_FLUSH) (
318 IN EFI_FILE *This
319 )
320 ;
321
322 #define EFI_FILE_PROTOCOL_REVISION 0x00010000
323 //
324 // Revision defined in EFI1.1.
325 //
326 #define EFI_FILE_REVISION EFI_FILE_PROTOCOL_REVISION
327
328 struct _EFI_FILE_PROTOCOL {
329 UINT64 Revision;
330 EFI_FILE_OPEN Open;
331 EFI_FILE_CLOSE Close;
332 EFI_FILE_DELETE Delete;
333 EFI_FILE_READ Read;
334 EFI_FILE_WRITE Write;
335 EFI_FILE_GET_POSITION GetPosition;
336 EFI_FILE_SET_POSITION SetPosition;
337 EFI_FILE_GET_INFO GetInfo;
338 EFI_FILE_SET_INFO SetInfo;
339 EFI_FILE_FLUSH Flush;
340 };
341
342
343 extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;
344
345 #endif