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_
31 #define WIN_NT_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_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 EFI_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
;
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
;
87 // Driver Binding protocol member functions
91 WinNtSimpleFileSystemDriverBindingSupported (
92 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
93 IN EFI_HANDLE ControllerHandle
,
94 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
100 Check to see if the driver supports a given controller.
104 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
106 ControllerHandle - EFI handle of the controller to test.
108 RemainingDevicePath - Pointer to remaining portion of a device path.
112 EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver
115 EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
116 the driver specified by This.
118 EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by
119 a different driver or an application that requires exclusive access.
121 EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the
122 driver specified by This.
129 WinNtSimpleFileSystemDriverBindingStart (
130 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
131 IN EFI_HANDLE ControllerHandle
,
132 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
138 Starts a device controller or a bus controller.
142 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
144 ControllerHandle - EFI handle of the controller to start.
146 RemainingDevicePath - Pointer to remaining portion of a device path.
150 EFI_SUCCESS - The device or bus controller has been started.
152 EFI_DEVICE_ERROR - The device could not be started due to a device failure.
154 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
161 WinNtSimpleFileSystemDriverBindingStop (
162 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
163 IN EFI_HANDLE ControllerHandle
,
164 IN UINTN NumberOfChildren
,
165 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
171 TODO: Add function description
175 This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.
177 ControllerHandle - A handle to the device to be stopped.
179 NumberOfChildren - The number of child device handles in ChildHandleBuffer.
181 ChildHandleBuffer - An array of child device handles to be freed.
185 EFI_SUCCESS - The device has been stopped.
187 EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.
193 // Simple File System protocol member functions
197 WinNtSimpleFileSystemOpenVolume (
198 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*This
,
205 Open the root directory on a volume.
209 This - A pointer to the volume to open.
211 Root - A pointer to storage for the returned opened file handle of the root directory.
215 EFI_SUCCESS - The volume was opened.
217 EFI_UNSUPPORTED - The volume does not support the requested file system type.
219 EFI_NO_MEDIA - The device has no media.
221 EFI_DEVICE_ERROR - The device reported an error.
223 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
225 EFI_ACCESS_DENIED - The service denied access to the file.
227 EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.
229 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
236 WinNtSimpleFileSystemOpen (
238 OUT EFI_FILE
**NewHandle
,
247 Open a file relative to the source file location.
251 This - A pointer to the source file location.
253 NewHandle - Pointer to storage for the new file handle.
255 FileName - Pointer to the file name to be opened.
257 OpenMode - File open mode information.
259 Attributes - File creation attributes.
263 EFI_SUCCESS - The file was opened.
265 EFI_NOT_FOUND - The file could not be found in the volume.
267 EFI_NO_MEDIA - The device has no media.
269 EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.
271 EFI_DEVICE_ERROR - The device reported an error.
273 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
275 EFI_WRITE_PROTECTED - The volume or file is write protected.
277 EFI_ACCESS_DENIED - The service denied access to the file.
279 EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.
281 EFI_VOLUME_FULL - There is not enough space left to create the new file.
288 WinNtSimpleFileSystemClose (
295 Close the specified file handle.
299 This - Pointer to a returned opened file handle.
303 EFI_SUCCESS - The file handle has been closed.
310 WinNtSimpleFileSystemDelete (
317 Close and delete a file.
321 This - Pointer to a returned opened file handle.
325 EFI_SUCCESS - The file handle was closed and deleted.
327 EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.
334 WinNtSimpleFileSystemRead (
336 IN OUT UINTN
*BufferSize
,
343 Read data from a file.
347 This - Pointer to a returned open file handle.
349 BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.
351 Buffer - Pointer to the first byte of the read Buffer.
355 EFI_SUCCESS - The data was read.
357 EFI_NO_MEDIA - The device has no media.
359 EFI_DEVICE_ERROR - The device reported an error.
361 EFI_VOLUME_CORRUPTED - The file system structures are corrupted.
363 EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry.
364 *BufferSize has been updated with the size needed to complete the request.
371 WinNtSimpleFileSystemWrite (
373 IN OUT UINTN
*BufferSize
,
380 Write data to a file.
384 This - Pointer to an opened file handle.
386 BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes
387 of data written to the file.
389 Buffer - Pointer to the first by of data in the buffer to write to the file.
393 EFI_SUCCESS - The data was written to the file.
395 EFI_UNSUPPORTED - Writes to an open directory are not supported.
397 EFI_NO_MEDIA - The device has no media.
399 EFI_DEVICE_ERROR - The device reported an error.
401 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
403 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
405 EFI_ACCESS_DENIED - The file was opened read-only.
407 EFI_VOLUME_FULL - The volume is full.
414 WinNtSimpleFileSystemSetPosition (
422 Set a file's current position.
426 This - Pointer to an opened file handle.
428 Position - The byte position from the start of the file to set.
432 EFI_SUCCESS - The file position has been changed.
434 EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.
441 WinNtSimpleFileSystemGetPosition (
449 Get a file's current position.
453 This - Pointer to an opened file handle.
455 Position - Pointer to storage for the current position.
459 EFI_SUCCESS - The file position has been reported.
461 EFI_UNSUPPORTED - Not valid for directories.
468 WinNtSimpleFileSystemGetInfo (
470 IN EFI_GUID
*InformationType
,
471 IN OUT UINTN
*BufferSize
,
478 Return information about a file or volume.
482 This - Pointer to an opened file handle.
484 InformationType - GUID describing the type of information to be returned.
486 BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the
489 Buffer - Pointer to the first byte of the information buffer.
493 EFI_SUCCESS - The requested information has been written into the buffer.
495 EFI_UNSUPPORTED - The InformationType is not known.
497 EFI_NO_MEDIA - The device has no media.
499 EFI_DEVICE_ERROR - The device reported an error.
501 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
503 EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has
504 been updated with the size needed to complete the requested operation.
511 WinNtSimpleFileSystemSetInfo (
513 IN EFI_GUID
*InformationType
,
521 Set information about a file or volume.
525 This - Pointer to an opened file handle.
527 InformationType - GUID identifying the type of information to set.
529 BufferSize - Number of bytes of data in the information buffer.
531 Buffer - Pointer to the first byte of data in the information buffer.
535 EFI_SUCCESS - The file or volume information has been updated.
537 EFI_UNSUPPORTED - The information identifier is not recognised.
539 EFI_NO_MEDIA - The device has no media.
541 EFI_DEVICE_ERROR - The device reported an error.
543 EFI_VOLUME_CORRUPTED - The file system structures are corrupt.
545 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
547 EFI_ACCESS_DENIED - The file was opened read-only.
549 EFI_VOLUME_FULL - The volume is full.
551 EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.
558 WinNtSimpleFileSystemFlush (
565 Flush all modified data to the media.
569 This - Pointer to an opened file handle.
573 EFI_SUCCESS - The data has been flushed.
575 EFI_NO_MEDIA - The device has no media.
577 EFI_DEVICE_ERROR - The device reported an error.
579 EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.
581 EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.
583 EFI_ACCESS_DENIED - The file was opened read-only.
585 EFI_VOLUME_FULL - The volume is full.
590 #endif /* _WIN_NT_SIMPLE_FILE_SYSTEM_H_ */
592 /* eof - WinNtSimpleFileSystem.h */