3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 WinNtSimpleFileSystem.h
18 Produce Simple File System abstractions for a directory on your PC using Win32 APIs.
19 The configuration of what devices to mount or emulate comes from NT
20 environment variables. The variables must be visible to the Microsoft*
21 Developer Studio for them to work.
23 * Other names and brands may be claimed as the property of others.
27 #ifndef _WIN_NT_SIMPLE_FILE_SYSTEM_H_
28 #define _WIN_NT_SIMPLE_FILE_SYSTEM_H_
32 #define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'f', 's')
36 EFI_WIN_NT_THUNK_PROTOCOL
*WinNtThunk
;
37 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem
;
40 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
41 } WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE
;
43 #define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
45 WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE, \
47 WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
50 #define WIN_NT_EFI_FILE_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'f', 's')
54 EFI_WIN_NT_THUNK_PROTOCOL
*WinNtThunk
;
55 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
59 BOOLEAN IsRootDirectory
;
60 BOOLEAN IsDirectoryPath
;
61 BOOLEAN IsOpenedByRead
;
64 BOOLEAN IsValidFindBuf
;
65 WIN32_FIND_DATA FindBuf
;
66 } WIN_NT_EFI_FILE_PRIVATE
;
68 #define WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
70 WIN_NT_EFI_FILE_PRIVATE, \
72 WIN_NT_EFI_FILE_PRIVATE_SIGNATURE \
76 // Global Protocol Variables
78 extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSimpleFileSystemDriverBinding
;
79 extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName
;
82 // Driver Binding protocol member functions
86 WinNtSimpleFileSystemDriverBindingSupported (
87 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
88 IN EFI_HANDLE ControllerHandle
,
89 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
95 Check to see if the driver supports a given controller.
99 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
101 ControllerHandle - EFI handle of the controller to test.
103 RemainingDevicePath - Pointer to remaining portion of a device path.
107 EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver
110 EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
111 the driver specified by This.
113 EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
114 a different driver or an application that requires exclusive access.
116 EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the
117 driver specified by This.
124 WinNtSimpleFileSystemDriverBindingStart (
125 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
126 IN EFI_HANDLE ControllerHandle
,
127 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
133 Starts a device controller or a bus controller.
137 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
139 ControllerHandle - EFI handle of the controller to start.
141 RemainingDevicePath - Pointer to remaining portion of a device path.
145 EFI_SUCCESS - The device or bus controller has been started.
147 EFI_DEVICE_ERROR - The device could not be started due to a device failure.
149 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
156 WinNtSimpleFileSystemDriverBindingStop (
157 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
158 IN EFI_HANDLE ControllerHandle
,
159 IN UINTN NumberOfChildren
,
160 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
166 TODO: Add function description
170 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
172 ControllerHandle - A handle to the device to be stopped.
174 NumberOfChildren - The number of child device handles in ChildHandleBuffer.
176 ChildHandleBuffer - An array of child device handles to be freed.
180 EFI_SUCCESS - The device has been stopped.
182 EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.
188 // Simple File System protocol member functions
192 WinNtSimpleFileSystemOpenVolume (
193 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
200 Open the root directory on a volume.
204 This - A pointer to the volume to open.
206 Root - A pointer to storage for the returned opened file handle of the root directory.
210 EFI_SUCCESS - The volume was opened.
212 EFI_UNSUPPORTED - The volume does not support the requested file system type.
214 EFI_NO_MEDIA - The device has no media.
216 EFI_DEVICE_ERROR - The device reported an error.
218 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
220 EFI_ACCESS_DENIED - The service denied access to the file.
222 EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.
224 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
231 WinNtSimpleFileSystemOpen (
233 OUT EFI_FILE
**NewHandle
,
242 Open a file relative to the source file location.
246 This - A pointer to the source file location.
248 NewHandle - Pointer to storage for the new file handle.
250 FileName - Pointer to the file name to be opened.
252 OpenMode - File open mode information.
254 Attributes - File creation attributes.
258 EFI_SUCCESS - The file was opened.
260 EFI_NOT_FOUND - The file could not be found in the volume.
262 EFI_NO_MEDIA - The device has no media.
264 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
266 EFI_DEVICE_ERROR - The device reported an error.
268 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
270 EFI_WRITE_PROTECTED - The volume or file is write protected.
272 EFI_ACCESS_DENIED - The service denied access to the file.
274 EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.
276 EFI_VOLUME_FULL - There is not enough space left to create the new file.
283 WinNtSimpleFileSystemClose (
290 Close the specified file handle.
294 This - Pointer to a returned opened file handle.
298 EFI_SUCCESS - The file handle has been closed.
305 WinNtSimpleFileSystemDelete (
312 Close and delete a file.
316 This - Pointer to a returned opened file handle.
320 EFI_SUCCESS - The file handle was closed and deleted.
322 EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.
329 WinNtSimpleFileSystemRead (
331 IN OUT UINTN
*BufferSize
,
338 Read data from a file.
342 This - Pointer to a returned open file handle.
344 BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.
346 Buffer - Pointer to the first byte of the read Buffer.
350 EFI_SUCCESS - The data was read.
352 EFI_NO_MEDIA - The device has no media.
354 EFI_DEVICE_ERROR - The device reported an error.
356 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
358 EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry.
359 *BufferSize has been updated with the size needed to complete the request.
366 WinNtSimpleFileSystemWrite (
368 IN OUT UINTN
*BufferSize
,
375 Write data to a file.
379 This - Pointer to an opened file handle.
381 BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes
382 of data written to the file.
384 Buffer - Pointer to the first by of data in the buffer to write to the file.
388 EFI_SUCCESS - The data was written to the file.
390 EFI_UNSUPPORTED - Writes to an open directory are not supported.
392 EFI_NO_MEDIA - The device has no media.
394 EFI_DEVICE_ERROR - The device reported an error.
396 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
398 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
400 EFI_ACCESS_DENIED - The file was opened read-only.
402 EFI_VOLUME_FULL - The volume is full.
409 WinNtSimpleFileSystemSetPosition (
417 Set a file's current position.
421 This - Pointer to an opened file handle.
423 Position - The byte position from the start of the file to set.
427 EFI_SUCCESS - The file position has been changed.
429 EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.
436 WinNtSimpleFileSystemGetPosition (
444 Get a file's current position.
448 This - Pointer to an opened file handle.
450 Position - Pointer to storage for the current position.
454 EFI_SUCCESS - The file position has been reported.
456 EFI_UNSUPPORTED - Not valid for directories.
463 WinNtSimpleFileSystemGetInfo (
465 IN EFI_GUID
*InformationType
,
466 IN OUT UINTN
*BufferSize
,
473 Return information about a file or volume.
477 This - Pointer to an opened file handle.
479 InformationType - GUID describing the type of information to be returned.
481 BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the
484 Buffer - Pointer to the first byte of the information buffer.
488 EFI_SUCCESS - The requested information has been written into the buffer.
490 EFI_UNSUPPORTED - The InformationType is not known.
492 EFI_NO_MEDIA - The device has no media.
494 EFI_DEVICE_ERROR - The device reported an error.
496 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
498 EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has
499 been updated with the size needed to complete the requested operation.
506 WinNtSimpleFileSystemSetInfo (
508 IN EFI_GUID
*InformationType
,
516 Set information about a file or volume.
520 This - Pointer to an opened file handle.
522 InformationType - GUID identifying the type of information to set.
524 BufferSize - Number of bytes of data in the information buffer.
526 Buffer - Pointer to the first byte of data in the information buffer.
530 EFI_SUCCESS - The file or volume information has been updated.
532 EFI_UNSUPPORTED - The information identifier is not recognised.
534 EFI_NO_MEDIA - The device has no media.
536 EFI_DEVICE_ERROR - The device reported an error.
538 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
540 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
542 EFI_ACCESS_DENIED - The file was opened read-only.
544 EFI_VOLUME_FULL - The volume is full.
546 EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.
553 WinNtSimpleFileSystemFlush (
560 Flush all modified data to the media.
564 This - Pointer to an opened file handle.
568 EFI_SUCCESS - The data has been flushed.
570 EFI_NO_MEDIA - The device has no media.
572 EFI_DEVICE_ERROR - The device reported an error.
574 EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.
576 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
578 EFI_ACCESS_DENIED - The file was opened read-only.
580 EFI_VOLUME_FULL - The volume is full.
585 #endif /* _WIN_NT_SIMPLE_FILE_SYSTEM_H_ */
587 /* eof - WinNtSimpleFileSystem.h */