3 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
4 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_
31 #define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'f', 's')
35 EFI_WIN_NT_THUNK_PROTOCOL
*WinNtThunk
;
36 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem
;
39 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
40 } WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE
;
42 #define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \
44 WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE, \
46 WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \
49 #define WIN_NT_EFI_FILE_PRIVATE_SIGNATURE SIGNATURE_32 ('l', 'o', 'f', 's')
52 // Bit definitions for EFI_TIME.Daylight
54 #define EFI_TIME_ADJUST_DAYLIGHT 0x01
55 #define EFI_TIME_IN_DAYLIGHT 0x02
59 EFI_WIN_NT_THUNK_PROTOCOL
*WinNtThunk
;
60 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
61 EFI_FILE_PROTOCOL EfiFile
;
64 BOOLEAN IsRootDirectory
;
65 BOOLEAN IsDirectoryPath
;
66 BOOLEAN IsOpenedByRead
;
69 BOOLEAN IsValidFindBuf
;
70 WIN32_FIND_DATA FindBuf
;
71 } WIN_NT_EFI_FILE_PRIVATE
;
73 #define WIN_NT_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \
75 WIN_NT_EFI_FILE_PRIVATE, \
77 WIN_NT_EFI_FILE_PRIVATE_SIGNATURE \
81 // Global Protocol Variables
83 extern EFI_DRIVER_BINDING_PROTOCOL gWinNtSimpleFileSystemDriverBinding
;
84 extern EFI_COMPONENT_NAME_PROTOCOL gWinNtSimpleFileSystemComponentName
;
85 extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtSimpleFileSystemComponentName2
;
88 // Driver Binding protocol member functions
92 WinNtSimpleFileSystemDriverBindingSupported (
93 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
94 IN EFI_HANDLE ControllerHandle
,
95 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
101 Check to see if the driver supports a given controller.
105 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
107 ControllerHandle - EFI handle of the controller to test.
109 RemainingDevicePath - Pointer to remaining portion of a device path.
113 EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver
116 EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
117 the driver specified by This.
119 EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
120 a different driver or an application that requires exclusive access.
122 EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the
123 driver specified by This.
130 WinNtSimpleFileSystemDriverBindingStart (
131 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
132 IN EFI_HANDLE ControllerHandle
,
133 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
139 Starts a device controller or a bus controller.
143 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
145 ControllerHandle - EFI handle of the controller to start.
147 RemainingDevicePath - Pointer to remaining portion of a device path.
151 EFI_SUCCESS - The device or bus controller has been started.
153 EFI_DEVICE_ERROR - The device could not be started due to a device failure.
155 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
162 WinNtSimpleFileSystemDriverBindingStop (
163 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
164 IN EFI_HANDLE ControllerHandle
,
165 IN UINTN NumberOfChildren
,
166 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
172 TODO: Add function description
176 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
178 ControllerHandle - A handle to the device to be stopped.
180 NumberOfChildren - The number of child device handles in ChildHandleBuffer.
182 ChildHandleBuffer - An array of child device handles to be freed.
186 EFI_SUCCESS - The device has been stopped.
188 EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.
194 // Simple File System protocol member functions
198 WinNtSimpleFileSystemOpenVolume (
199 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
200 OUT EFI_FILE_PROTOCOL
**Root
206 Open the root directory on a volume.
210 This - A pointer to the volume to open.
212 Root - A pointer to storage for the returned opened file handle of the root directory.
216 EFI_SUCCESS - The volume was opened.
218 EFI_UNSUPPORTED - The volume does not support the requested file system type.
220 EFI_NO_MEDIA - The device has no media.
222 EFI_DEVICE_ERROR - The device reported an error.
224 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
226 EFI_ACCESS_DENIED - The service denied access to the file.
228 EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.
230 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
237 WinNtSimpleFileSystemOpen (
238 IN EFI_FILE_PROTOCOL
*This
,
239 OUT EFI_FILE_PROTOCOL
**NewHandle
,
248 Open a file relative to the source file location.
252 This - A pointer to the source file location.
254 NewHandle - Pointer to storage for the new file handle.
256 FileName - Pointer to the file name to be opened.
258 OpenMode - File open mode information.
260 Attributes - File creation attributes.
264 EFI_SUCCESS - The file was opened.
266 EFI_NOT_FOUND - The file could not be found in the volume.
268 EFI_NO_MEDIA - The device has no media.
270 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
272 EFI_DEVICE_ERROR - The device reported an error.
274 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
276 EFI_WRITE_PROTECTED - The volume or file is write protected.
278 EFI_ACCESS_DENIED - The service denied access to the file.
280 EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.
282 EFI_VOLUME_FULL - There is not enough space left to create the new file.
289 WinNtSimpleFileSystemClose (
290 IN EFI_FILE_PROTOCOL
*This
296 Close the specified file handle.
300 This - Pointer to a returned opened file handle.
304 EFI_SUCCESS - The file handle has been closed.
311 WinNtSimpleFileSystemDelete (
312 IN EFI_FILE_PROTOCOL
*This
318 Close and delete a file.
322 This - Pointer to a returned opened file handle.
326 EFI_SUCCESS - The file handle was closed and deleted.
328 EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.
335 WinNtSimpleFileSystemRead (
336 IN EFI_FILE_PROTOCOL
*This
,
337 IN OUT UINTN
*BufferSize
,
344 Read data from a file.
348 This - Pointer to a returned open file handle.
350 BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.
352 Buffer - Pointer to the first byte of the read Buffer.
356 EFI_SUCCESS - The data was read.
358 EFI_NO_MEDIA - The device has no media.
360 EFI_DEVICE_ERROR - The device reported an error.
362 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
364 EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry.
365 *BufferSize has been updated with the size needed to complete the request.
372 WinNtSimpleFileSystemWrite (
373 IN EFI_FILE_PROTOCOL
*This
,
374 IN OUT UINTN
*BufferSize
,
381 Write data to a file.
385 This - Pointer to an opened file handle.
387 BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes
388 of data written to the file.
390 Buffer - Pointer to the first by of data in the buffer to write to the file.
394 EFI_SUCCESS - The data was written to the file.
396 EFI_UNSUPPORTED - Writes to an open directory are not supported.
398 EFI_NO_MEDIA - The device has no media.
400 EFI_DEVICE_ERROR - The device reported an error.
402 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
404 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
406 EFI_ACCESS_DENIED - The file was opened read-only.
408 EFI_VOLUME_FULL - The volume is full.
415 WinNtSimpleFileSystemSetPosition (
416 IN EFI_FILE_PROTOCOL
*This
,
423 Set a file's current position.
427 This - Pointer to an opened file handle.
429 Position - The byte position from the start of the file to set.
433 EFI_SUCCESS - The file position has been changed.
435 EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.
442 WinNtSimpleFileSystemGetPosition (
443 IN EFI_FILE_PROTOCOL
*This
,
450 Get a file's current position.
454 This - Pointer to an opened file handle.
456 Position - Pointer to storage for the current position.
460 EFI_SUCCESS - The file position has been reported.
462 EFI_UNSUPPORTED - Not valid for directories.
469 WinNtSimpleFileSystemGetInfo (
470 IN EFI_FILE_PROTOCOL
*This
,
471 IN EFI_GUID
*InformationType
,
472 IN OUT UINTN
*BufferSize
,
479 Return information about a file or volume.
483 This - Pointer to an opened file handle.
485 InformationType - GUID describing the type of information to be returned.
487 BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the
490 Buffer - Pointer to the first byte of the information buffer.
494 EFI_SUCCESS - The requested information has been written into the buffer.
496 EFI_UNSUPPORTED - The InformationType is not known.
498 EFI_NO_MEDIA - The device has no media.
500 EFI_DEVICE_ERROR - The device reported an error.
502 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
504 EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has
505 been updated with the size needed to complete the requested operation.
512 WinNtSimpleFileSystemSetInfo (
513 IN EFI_FILE_PROTOCOL
*This
,
514 IN EFI_GUID
*InformationType
,
522 Set information about a file or volume.
526 This - Pointer to an opened file handle.
528 InformationType - GUID identifying the type of information to set.
530 BufferSize - Number of bytes of data in the information buffer.
532 Buffer - Pointer to the first byte of data in the information buffer.
536 EFI_SUCCESS - The file or volume information has been updated.
538 EFI_UNSUPPORTED - The information identifier is not recognised.
540 EFI_NO_MEDIA - The device has no media.
542 EFI_DEVICE_ERROR - The device reported an error.
544 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
546 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
548 EFI_ACCESS_DENIED - The file was opened read-only.
550 EFI_VOLUME_FULL - The volume is full.
552 EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.
559 WinNtSimpleFileSystemFlush (
560 IN EFI_FILE_PROTOCOL
*This
566 Flush all modified data to the media.
570 This - Pointer to an opened file handle.
574 EFI_SUCCESS - The data has been flushed.
576 EFI_NO_MEDIA - The device has no media.
578 EFI_DEVICE_ERROR - The device reported an error.
580 EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.
582 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
584 EFI_ACCESS_DENIED - The file was opened read-only.
586 EFI_VOLUME_FULL - The volume is full.
591 #endif /* _WIN_NT_SIMPLE_FILE_SYSTEM_H_ */
593 /* eof - WinNtSimpleFileSystem.h */