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