]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/SimpleFileSystem.h
Import Pal.h and Sal.h.
[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 Module Name: SimpleFileSystem.h
20
21 **/
22
23 #ifndef __SIMPLE_FILE_SYSTEM_H__
24 #define __SIMPLE_FILE_SYSTEM_H__
25
26 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
27 { \
28 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
29 }
30
31 typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
32
33 typedef struct _EFI_FILE_PROTOCOL EFI_FILE_PROTOCOL;
34 typedef struct _EFI_FILE_PROTOCOL *EFI_FILE_HANDLE;
35
36
37 //
38 // Protocol GUID defined in EFI1.1.
39 //
40 #define SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
41
42 //
43 // Protocol defined in EFI1.1.
44 //
45 typedef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_FILE_IO_INTERFACE;
46 typedef struct _EFI_FILE_PROTOCOL EFI_FILE;
47
48 /**
49 Open the root directory on a volume.
50
51 @param This Protocol instance pointer.
52 @param Root Returns an Open file handle for the root directory
53
54 @retval EFI_SUCCESS The device was opened.
55 @retval EFI_UNSUPPORTED This volume does not suppor the file system.
56 @retval EFI_NO_MEDIA The device has no media.
57 @retval EFI_DEVICE_ERROR The device reported an error.
58 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
59 @retval EFI_ACCESS_DENIED The service denied access to the file
60 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources
61
62 **/
63 typedef
64 EFI_STATUS
65 (EFIAPI *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME) (
66 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
67 OUT EFI_FILE_PROTOCOL **Root
68 )
69 ;
70
71 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
72 //
73 // Revision defined in EFI1.1
74 //
75 #define EFI_FILE_IO_INTERFACE_REVISION EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION
76
77 struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
78 UINT64 Revision;
79 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume;
80 };
81
82 /**
83 Open the root directory on a volume.
84
85 @param This Protocol instance pointer.
86 @param NewHandle Returns File Handle for FileName
87 @param FileName Null terminated string. "\", ".", and ".." are supported
88 @param OpenMode Open mode for file.
89 @param Attributes Only used for EFI_FILE_MODE_CREATE
90
91 @retval EFI_SUCCESS The device was opened.
92 @retval EFI_NOT_FOUND The specified file could not be found on the device
93 @retval EFI_NO_MEDIA The device has no media.
94 @retval EFI_MEDIA_CHANGED The media has changed
95 @retval EFI_DEVICE_ERROR The device reported an error.
96 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
97 @retval EFI_ACCESS_DENIED The service denied access to the file
98 @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources
99 @retval EFI_VOLUME_FULL The volume is full.
100
101 **/
102 typedef
103 EFI_STATUS
104 (EFIAPI *EFI_FILE_OPEN) (
105 IN EFI_FILE_PROTOCOL *This,
106 OUT EFI_FILE_PROTOCOL **NewHandle,
107 IN CHAR16 *FileName,
108 IN UINT64 OpenMode,
109 IN UINT64 Attributes
110 )
111 ;
112
113 //
114 // Open modes
115 //
116 #define EFI_FILE_MODE_READ 0x0000000000000001ULL
117 #define EFI_FILE_MODE_WRITE 0x0000000000000002ULL
118 #define EFI_FILE_MODE_CREATE 0x8000000000000000ULL
119
120 //
121 // File attributes
122 //
123 #define EFI_FILE_READ_ONLY 0x0000000000000001ULL
124 #define EFI_FILE_HIDDEN 0x0000000000000002ULL
125 #define EFI_FILE_SYSTEM 0x0000000000000004ULL
126 #define EFI_FILE_RESERVED 0x0000000000000008ULL
127 #define EFI_FILE_DIRECTORY 0x0000000000000010ULL
128 #define EFI_FILE_ARCHIVE 0x0000000000000020ULL
129 #define EFI_FILE_VALID_ATTR 0x0000000000000037ULL
130
131 /**
132 Close the file handle
133
134 @param This Protocol instance pointer.
135
136 @retval EFI_SUCCESS The device was opened.
137
138 **/
139 typedef
140 EFI_STATUS
141 (EFIAPI *EFI_FILE_CLOSE) (
142 IN EFI_FILE *This
143 )
144 ;
145
146 /**
147 Close and delete the file handle
148
149 @param This Protocol instance pointer.
150
151 @retval EFI_SUCCESS The device was opened.
152 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted
153
154 **/
155 typedef
156 EFI_STATUS
157 (EFIAPI *EFI_FILE_DELETE) (
158 IN EFI_FILE *This
159 )
160 ;
161
162 /**
163 Read data from the file.
164
165 @param This Protocol instance pointer.
166 @param BufferSize On input size of buffer, on output amount of data in buffer.
167 @param Buffer The buffer in which data is read.
168
169 @retval EFI_SUCCESS Data was read.
170 @retval EFI_NO_MEDIA The device has no media
171 @retval EFI_DEVICE_ERROR The device reported an error
172 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
173 @retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size
174
175 **/
176 typedef
177 EFI_STATUS
178 (EFIAPI *EFI_FILE_READ) (
179 IN EFI_FILE_PROTOCOL *This,
180 IN OUT UINTN *BufferSize,
181 OUT VOID *Buffer
182 )
183 ;
184
185 /**
186 Write data from to the file.
187
188 @param This Protocol instance pointer.
189 @param BufferSize On input size of buffer, on output amount of data in buffer.
190 @param Buffer The buffer in which data to write.
191
192 @retval EFI_SUCCESS Data was written.
193 @retval EFI_UNSUPPORT Writes to Open directory are not supported
194 @retval EFI_NO_MEDIA The device has no media
195 @retval EFI_DEVICE_ERROR The device reported an error
196 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
197 @retval EFI_WRITE_PROTECTED The device is write protected
198 @retval EFI_ACCESS_DENIED The file was open for read only
199 @retval EFI_VOLUME_FULL The volume is full
200
201 **/
202 typedef
203 EFI_STATUS
204 (EFIAPI *EFI_FILE_WRITE) (
205 IN EFI_FILE_PROTOCOL *This,
206 IN OUT UINTN *BufferSize,
207 IN VOID *Buffer
208 )
209 ;
210
211 /**
212 Set a files current position
213
214 @param This Protocol instance pointer.
215 @param Position Byte possition from the start of the file
216
217 @retval EFI_SUCCESS Data was written.
218 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
219
220 **/
221 typedef
222 EFI_STATUS
223 (EFIAPI *EFI_FILE_SET_POSITION) (
224 IN EFI_FILE_PROTOCOL *This,
225 IN UINT64 Position
226 )
227 ;
228
229 /**
230 Get a files current position
231
232 @param This Protocol instance pointer.
233 @param Position Byte possition from the start of the file
234
235 @retval EFI_SUCCESS Data was written.
236 @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.
237
238 **/
239 typedef
240 EFI_STATUS
241 (EFIAPI *EFI_FILE_GET_POSITION) (
242 IN EFI_FILE_PROTOCOL *This,
243 OUT UINT64 *Position
244 )
245 ;
246
247 /**
248 Get information about a file
249
250 @param This Protocol instance pointer.
251 @param InformationType Type of info to return in Buffer
252 @param BufferSize On input size of buffer, on output amount of data in buffer.
253 @param Buffer The buffer to return data.
254
255 @retval EFI_SUCCESS Data was returned.
256 @retval EFI_UNSUPPORT InformationType is not supported
257 @retval EFI_NO_MEDIA The device has no media
258 @retval EFI_DEVICE_ERROR The device reported an error
259 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
260 @retval EFI_WRITE_PROTECTED The device is write protected
261 @retval EFI_ACCESS_DENIED The file was open for read only
262 @retval EFI_BUFFER_TOO_SMALL Buffer was too small, required size returned in BufferSize
263
264 **/
265 typedef
266 EFI_STATUS
267 (EFIAPI *EFI_FILE_GET_INFO) (
268 IN EFI_FILE_PROTOCOL *This,
269 IN EFI_GUID *InformationType,
270 IN OUT UINTN *BufferSize,
271 OUT VOID *Buffer
272 )
273 ;
274
275 /**
276 Set information about a file
277
278 @param File Protocol instance pointer.
279 @param InformationType Type of info in Buffer
280 @param BufferSize Size of buffer.
281 @param Buffer The data to write.
282
283 @retval EFI_SUCCESS Data was returned.
284 @retval EFI_UNSUPPORT InformationType is not supported
285 @retval EFI_NO_MEDIA The device has no media
286 @retval EFI_DEVICE_ERROR The device reported an error
287 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
288 @retval EFI_WRITE_PROTECTED The device is write protected
289 @retval EFI_ACCESS_DENIED The file was open for read only
290
291 **/
292 typedef
293 EFI_STATUS
294 (EFIAPI *EFI_FILE_SET_INFO) (
295 IN EFI_FILE_PROTOCOL *This,
296 IN EFI_GUID *InformationType,
297 IN UINTN BufferSize,
298 IN VOID *Buffer
299 )
300 ;
301
302 /**
303 Flush data back for the file handle
304
305 @param This Protocol instance pointer.
306
307 @retval EFI_SUCCESS Data was written.
308 @retval EFI_UNSUPPORT Writes to Open directory are not supported
309 @retval EFI_NO_MEDIA The device has no media
310 @retval EFI_DEVICE_ERROR The device reported an error
311 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
312 @retval EFI_WRITE_PROTECTED The device is write protected
313 @retval EFI_ACCESS_DENIED The file was open for read only
314 @retval EFI_VOLUME_FULL The volume is full
315
316 **/
317 typedef
318 EFI_STATUS
319 (EFIAPI *EFI_FILE_FLUSH) (
320 IN EFI_FILE *This
321 )
322 ;
323
324 #define EFI_FILE_PROTOCOL_REVISION 0x00010000
325 //
326 // Revision defined in EFI1.1.
327 //
328 #define EFI_FILE_REVISION EFI_FILE_PROTOCOL_REVISION
329
330 struct _EFI_FILE_PROTOCOL {
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