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