--- /dev/null
+/*++\r
+\r
+Copyright (c) 2006, Intel Corporation \r
+All rights reserved. This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Module Name:\r
+\r
+ UnixSimpleFileSystem.h\r
+\r
+Abstract:\r
+\r
+ Produce Simple File System abstractions for a directory on your PC using Unix APIs.\r
+ The configuration of what devices to mount or emulate comes from \r
+ environment variables.\r
+\r
+--*/\r
+\r
+#ifndef _UNIX_SIMPLE_FILE_SYSTEM_H_\r
+#define _UNIX_SIMPLE_FILE_SYSTEM_H_\r
+\r
+\r
+\r
+#define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('L', 'X', 'f', 's')\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EFI_UNIX_THUNK_PROTOCOL *UnixThunk;\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;\r
+ CHAR8 *FilePath;\r
+ CHAR16 *VolumeLabel;\r
+ EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
+} UNIX_SIMPLE_FILE_SYSTEM_PRIVATE;\r
+\r
+#define UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR (a, \\r
+ UNIX_SIMPLE_FILE_SYSTEM_PRIVATE, \\r
+ SimpleFileSystem, \\r
+ UNIX_SIMPLE_FILE_SYSTEM_PRIVATE_SIGNATURE \\r
+ )\r
+\r
+#define UNIX_EFI_FILE_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('l', 'o', 'f', 's')\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EFI_UNIX_THUNK_PROTOCOL *UnixThunk;\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r
+ EFI_FILE EfiFile;\r
+ INTN fd;
+ DIR *Dir;
+ BOOLEAN IsRootDirectory;\r
+ BOOLEAN IsDirectoryPath;\r
+ BOOLEAN IsOpenedByRead;\r
+ char *FileName;\r
+ struct dirent *Dirent;
+} UNIX_EFI_FILE_PRIVATE;\r
+\r
+#define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \\r
+ CR (a, \\r
+ UNIX_EFI_FILE_PRIVATE, \\r
+ EfiFile, \\r
+ UNIX_EFI_FILE_PRIVATE_SIGNATURE \\r
+ )\r
+\r
+//\r
+// Global Protocol Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gUnixSimpleFileSystemDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gUnixSimpleFileSystemComponentName;\r
+\r
+//\r
+// Driver Binding protocol member functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Check to see if the driver supports a given controller.\r
+\r
+Arguments:\r
+\r
+ This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+ ControllerHandle - EFI handle of the controller to test.\r
+\r
+ RemainingDevicePath - Pointer to remaining portion of a device path.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The device specified by ControllerHandle and RemainingDevicePath is supported by the driver\r
+ specified by This.\r
+\r
+ EFI_ALREADY_STARTED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r
+ the driver specified by This.\r
+\r
+ EFI_ACCESS_DENIED - The device specified by ControllerHandle and RemainingDevicePath is already being managed by\r
+ a different driver or an application that requires exclusive access.\r
+\r
+ EFI_UNSUPPORTED - The device specified by ControllerHandle and RemainingDevicePath is not supported by the\r
+ driver specified by This.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Starts a device controller or a bus controller.\r
+\r
+Arguments:\r
+\r
+ This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+ ControllerHandle - EFI handle of the controller to start.\r
+\r
+ RemainingDevicePath - Pointer to remaining portion of a device path.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The device or bus controller has been started.\r
+\r
+ EFI_DEVICE_ERROR - The device could not be started due to a device failure.\r
+\r
+ EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ TODO: Add function description\r
+\r
+Arguments:\r
+\r
+ This - A pointer to an instance of the EFI_DRIVER_BINDING_PROTOCOL.\r
+\r
+ ControllerHandle - A handle to the device to be stopped.\r
+\r
+ NumberOfChildren - The number of child device handles in ChildHandleBuffer.\r
+\r
+ ChildHandleBuffer - An array of child device handles to be freed.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The device has been stopped.\r
+\r
+ EFI_DEVICE_ERROR - The device could not be stopped due to a device failure.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Simple File System protocol member functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemOpenVolume (\r
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,\r
+ OUT EFI_FILE **Root\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Open the root directory on a volume.\r
+\r
+Arguments:\r
+\r
+ This - A pointer to the volume to open.\r
+\r
+ Root - A pointer to storage for the returned opened file handle of the root directory.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The volume was opened.\r
+\r
+ EFI_UNSUPPORTED - The volume does not support the requested file system type.\r
+\r
+ EFI_NO_MEDIA - The device has no media.\r
+\r
+ EFI_DEVICE_ERROR - The device reported an error.\r
+\r
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted.\r
+\r
+ EFI_ACCESS_DENIED - The service denied access to the file.\r
+\r
+ EFI_OUT_OF_RESOURCES - The file volume could not be opened due to lack of resources.\r
+\r
+ EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemOpen (\r
+ IN EFI_FILE *This,\r
+ OUT EFI_FILE **NewHandle,\r
+ IN CHAR16 *FileName,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Open a file relative to the source file location.\r
+\r
+Arguments:\r
+\r
+ This - A pointer to the source file location.\r
+\r
+ NewHandle - Pointer to storage for the new file handle.\r
+\r
+ FileName - Pointer to the file name to be opened.\r
+\r
+ OpenMode - File open mode information.\r
+\r
+ Attributes - File creation attributes.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file was opened.\r
+\r
+ EFI_NOT_FOUND - The file could not be found in the volume.\r
+\r
+ EFI_NO_MEDIA - The device has no media.\r
+\r
+ EFI_MEDIA_CHANGED - The device has new media or the media is no longer supported.\r
+\r
+ EFI_DEVICE_ERROR - The device reported an error.\r
+\r
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted.\r
+\r
+ EFI_WRITE_PROTECTED - The volume or file is write protected.\r
+\r
+ EFI_ACCESS_DENIED - The service denied access to the file.\r
+\r
+ EFI_OUT_OF_RESOURCES - Not enough resources were available to open the file.\r
+\r
+ EFI_VOLUME_FULL - There is not enough space left to create the new file.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemClose (\r
+ IN EFI_FILE *This\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Close the specified file handle.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to a returned opened file handle.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file handle has been closed.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemDelete (\r
+ IN EFI_FILE *This\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Close and delete a file.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to a returned opened file handle.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file handle was closed and deleted.\r
+\r
+ EFI_WARN_DELETE_FAILURE - The handle was closed but could not be deleted.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemRead (\r
+ IN EFI_FILE *This,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Read data from a file.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to a returned open file handle.\r
+\r
+ BufferSize - On input, the size of the Buffer. On output, the number of bytes stored in the Buffer.\r
+\r
+ Buffer - Pointer to the first byte of the read Buffer.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The data was read.\r
+\r
+ EFI_NO_MEDIA - The device has no media.\r
+\r
+ EFI_DEVICE_ERROR - The device reported an error.\r
+\r
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted.\r
+\r
+ EFI_BUFFER_TOO_SMALL - The supplied buffer size was too small to store the current directory entry.\r
+ *BufferSize has been updated with the size needed to complete the request.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemWrite (\r
+ IN EFI_FILE *This,\r
+ IN OUT UINTN *BufferSize,\r
+ IN VOID *Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Write data to a file.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to an opened file handle.\r
+\r
+ BufferSize - On input, the number of bytes in the Buffer to write to the file. On output, the number of bytes\r
+ of data written to the file.\r
+\r
+ Buffer - Pointer to the first by of data in the buffer to write to the file.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The data was written to the file.\r
+\r
+ EFI_UNSUPPORTED - Writes to an open directory are not supported.\r
+\r
+ EFI_NO_MEDIA - The device has no media.\r
+\r
+ EFI_DEVICE_ERROR - The device reported an error.\r
+\r
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupt.\r
+\r
+ EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.\r
+\r
+ EFI_ACCESS_DENIED - The file was opened read-only.\r
+\r
+ EFI_VOLUME_FULL - The volume is full.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemSetPosition (\r
+ IN EFI_FILE *This,\r
+ IN UINT64 Position\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Set a file's current position.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to an opened file handle.\r
+\r
+ Position - The byte position from the start of the file to set.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file position has been changed.\r
+\r
+ EFI_UNSUPPORTED - The seek request for non-zero is not supported for directories.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemGetPosition (\r
+ IN EFI_FILE *This,\r
+ OUT UINT64 *Position\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Get a file's current position.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to an opened file handle.\r
+\r
+ Position - Pointer to storage for the current position.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file position has been reported.\r
+\r
+ EFI_UNSUPPORTED - Not valid for directories.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemGetInfo (\r
+ IN EFI_FILE *This,\r
+ IN EFI_GUID *InformationType,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Return information about a file or volume.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to an opened file handle.\r
+\r
+ InformationType - GUID describing the type of information to be returned.\r
+\r
+ BufferSize - On input, the size of the information buffer. On output, the number of bytes written to the\r
+ information buffer.\r
+\r
+ Buffer - Pointer to the first byte of the information buffer.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The requested information has been written into the buffer.\r
+\r
+ EFI_UNSUPPORTED - The InformationType is not known.\r
+\r
+ EFI_NO_MEDIA - The device has no media.\r
+\r
+ EFI_DEVICE_ERROR - The device reported an error.\r
+\r
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupt.\r
+\r
+ EFI_BUFFER_TOO_SMALL - The buffer size was too small to contain the requested information. The buffer size has\r
+ been updated with the size needed to complete the requested operation.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemSetInfo (\r
+ IN EFI_FILE *This,\r
+ IN EFI_GUID *InformationType,\r
+ IN UINTN BufferSize,\r
+ IN VOID *Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Set information about a file or volume.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to an opened file handle.\r
+\r
+ InformationType - GUID identifying the type of information to set.\r
+\r
+ BufferSize - Number of bytes of data in the information buffer.\r
+\r
+ Buffer - Pointer to the first byte of data in the information buffer.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The file or volume information has been updated.\r
+\r
+ EFI_UNSUPPORTED - The information identifier is not recognised.\r
+\r
+ EFI_NO_MEDIA - The device has no media.\r
+\r
+ EFI_DEVICE_ERROR - The device reported an error.\r
+\r
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupt.\r
+\r
+ EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.\r
+\r
+ EFI_ACCESS_DENIED - The file was opened read-only.\r
+\r
+ EFI_VOLUME_FULL - The volume is full.\r
+\r
+ EFI_BAD_BUFFER_SIZE - The buffer size is smaller than the type indicated by InformationType.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+UnixSimpleFileSystemFlush (\r
+ IN EFI_FILE *This\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Flush all modified data to the media.\r
+\r
+Arguments:\r
+\r
+ This - Pointer to an opened file handle.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The data has been flushed.\r
+\r
+ EFI_NO_MEDIA - The device has no media.\r
+\r
+ EFI_DEVICE_ERROR - The device reported an error.\r
+\r
+ EFI_VOLUME_CORRUPTED - The file system structures have been corrupted.\r
+\r
+ EFI_WRITE_PROTECTED - The file, directory, volume, or device is write protected.\r
+\r
+ EFI_ACCESS_DENIED - The file was opened read-only.\r
+\r
+ EFI_VOLUME_FULL - The volume is full.\r
+\r
+--*/\r
+;\r
+\r
+#endif /* _UNIX_SIMPLE_FILE_SYSTEM_H_ */\r
+\r
+/* eof - UnixSimpleFileSystem.h */\r