MityDSP Documentation Index

e:/hudson/workspace/MityDSP MDK Release/trunk/sw/inc/fatfs/fatfs.h File Reference

FAT filesystem top level header file. More...

#include <stdint.h>

Classes

struct  tsDevInfo
 This structure provides the FAT drivers with the necessary information to interface to the physical media. More...
struct  FAT_DIRENT
 This structure describes a directory entry from FAT_readdir(). More...

Defines

#define FATFS_OK   0
 The following are the error codes used by the FAT driver.
#define FATFS_INVALID_PATH   -1
 Path was not valid 8.3.
#define FATFS_FILE_NOT_FOUND   -2
 File was not found.
#define FATFS_FAT_TYPE_NOT_SUPPORTED   -3
 FAT type not supported.
#define FATFS_DEVICE_READ_FAILED   -4
 Read from device failed.
#define FATFS_DEVICE_WRITE_FAILED   -5
 Write to device failed.
#define FATFS_DIR_NOT_FOUND   -6
 Sub-directory not found.
#define FATFS_FILE_CREATE_FAILED   -7
 File creation failed.
#define FATFS_FILEID_OUT_OF_RANGE   -8
 File ID out of range.
#define FATFS_DIRECTORY_FULL   -9
 Directory is full.
#define FATFS_DISK_FULL   -10
 Device is full.
#define FATFS_FILEID_NOT_OPENED   -11
 Specified file ID not opened.
#define FATFS_BAD_SEEK_ORIGIN   -12
 Bad origin provided for seek cmd.
#define FATFS_INVALID_PARTITION   -13
 Invalid partition data.
#define FATFS_FILE_ALREADY_EXISTS   -14
 Attempt to overwrite an existing file failed.
#define FATFS_DIRECTORY_NOT_EMPTY   -15
 Directory must be empty prior to deletion.
#define FAT_ATTRIB_READONLY   0x01
 The following are the valid FAT file attributes.
#define FAT_ATTRIB_HIDDEN   0x02
#define FAT_ATTRIB_SYSTEM   0x04
#define FAT_ATTRIB_VOLUMELABEL   0x08
#define FAT_ATTRIB_SUBDIR   0x10
#define FAT_ATTRIB_ARCHIVE   0x20
#define FAT_ATTRIB_DEVICE   0x40
#define FATIONOATIME   0x89F0
 Device private ioctl calls (From GNU C headers.

Typedefs

typedef int(* RAWREAD )(uint32_t start_sector, uint32_t offset, char *buffer, uint32_t length, void *apDriverData)
 Template function for Device Read Request used by FAT driver software.
typedef int(* RAWWRITE )(uint32_t start_sector, uint32_t offset, char *buffer, uint32_t length, void *apDriverData)
 Template function for Device Write Request used by FAT driver software.
typedef int(* GETTIME )(unsigned int *apYear, unsigned int *apMonth, unsigned int *apDay, unsigned int *apHour, unsigned int *apMinutes, unsigned int *apSeconds, unsigned int *apHundredths)
 Template function for the Real-Time Clock access used by FAT driver software.
typedef int(* DEBUGHANDLER )(const char *apErrorString, int aeSeverity)
 Debugging string for FAT development.
typedef struct FAT_DIRENT FAT_dirent
 This structure describes a directory entry from FAT_readdir().
typedef void FAT_DIR

Functions

int RegisterFATDriver (RAWREAD apRawReadFunc, RAWWRITE apRawWriteFunc, GETTIME apGetTimeFunc, tsDevInfo *apRawInfo, char *apDeviceName, void *apDriverData)
 Register a FAT device/driver with BIOS CIO utilities.
int RemoveFATDriver (char *name)
 REMOVE a FAT device/driver with BIOS CIO utilities.
int RegisterFATDebugHandler (DEBUGHANDLER apDebugFunc, void *apUserData)
int FAT_format (tsDevInfo *apRawInfo, RAWWRITE apRawWriteFunc, char *apFATType, void *apDriverData)
 FORMAT a device with a FAT filesystem.
int FAT_mkdir (const char *path)
 Create directory on a FAT FileSystem.
int FAT_rmdir (const char *path)
 Remove an empty directory on a FAT FileSystem.
double FAT_getdiskfree (const char *apDrive)
 Computes the free space on a device based upon the free cluster count.
int FAT_ioctl (const char *apDevName, int cmd, void *argp)
 IOCTL for FAT filasystem Supported IOCTLs are

  • FATIONOATIME - set arg to a uint32 pointer.

FAT_DIRFAT_opendir (const char *dirname)
 Open directory for reading (listing).
int FAT_closedir (FAT_DIR *dirp)
 Close / Free resources associated with FAT_DIR structure initialized with FAT_opendir().
int FAT_readdir (FAT_DIR *dirp, FAT_dirent *direntp)
 Read next directory entry of FAT directory structure.
int FAT_rewinddir (FAT_DIR *dirp)
 Resets directory listing pointer to beginning of list for a valid FAT_DIR entry as initalized by FAT_opendir.

Detailed Description

FAT filesystem top level header file.

This file contains the header information necessary for intializing a FAT filesystem device.

Author:
Critical Link LLC
      o  0
      | /       Copyright (c) 2007-2008
     (CL)---o   Critical Link, LLC
       \
        O
   

Define Documentation

#define FATFS_OK   0

The following are the error codes used by the FAT driver.

No error

#define FATFS_INVALID_PATH   -1

Path was not valid 8.3.

#define FATFS_FILE_NOT_FOUND   -2

File was not found.

#define FATFS_FAT_TYPE_NOT_SUPPORTED   -3

FAT type not supported.

#define FATFS_DEVICE_READ_FAILED   -4

Read from device failed.

#define FATFS_DEVICE_WRITE_FAILED   -5

Write to device failed.

#define FATFS_DIR_NOT_FOUND   -6

Sub-directory not found.

#define FATFS_FILE_CREATE_FAILED   -7

File creation failed.

#define FATFS_FILEID_OUT_OF_RANGE   -8

File ID out of range.

#define FATFS_DIRECTORY_FULL   -9

Directory is full.

#define FATFS_DISK_FULL   -10

Device is full.

#define FATFS_FILEID_NOT_OPENED   -11

Specified file ID not opened.

#define FATFS_BAD_SEEK_ORIGIN   -12

Bad origin provided for seek cmd.

#define FATFS_INVALID_PARTITION   -13

Invalid partition data.

#define FATFS_FILE_ALREADY_EXISTS   -14

Attempt to overwrite an existing file failed.

#define FATFS_DIRECTORY_NOT_EMPTY   -15

Directory must be empty prior to deletion.

#define FAT_ATTRIB_READONLY   0x01

The following are the valid FAT file attributes.

#define FAT_ATTRIB_HIDDEN   0x02
#define FAT_ATTRIB_SYSTEM   0x04
#define FAT_ATTRIB_VOLUMELABEL   0x08
#define FAT_ATTRIB_SUBDIR   0x10
#define FAT_ATTRIB_ARCHIVE   0x20
#define FAT_ATTRIB_DEVICE   0x40
#define FATIONOATIME   0x89F0

Device private ioctl calls (From GNU C headers.

..)


Typedef Documentation

typedef int(* RAWREAD)(uint32_t start_sector, uint32_t offset, char *buffer, uint32_t length, void *apDriverData)

Template function for Device Read Request used by FAT driver software.

Parameters:
[in] start_sector starting sector to read from
[in] offset numbet of bytes from beginning of sector
[in,out] buffer buffer to store requested data from device
[in] length number of bytes to retrieve
[in] apDriverData Drive Data Info, see RegisterFATDriver
Returns:
number of bytes read, or -1 on error.
typedef int(* RAWWRITE)(uint32_t start_sector, uint32_t offset, char *buffer, uint32_t length, void *apDriverData)

Template function for Device Write Request used by FAT driver software.

Parameters:
[in] start_sector starting sector to read from
[in] offset numbet of bytes from beginning of sector
[in] buffer buffer to copy requested data to device
[in] length number of bytes to write
[in] apDriverData Drive Data Info, see RegisterFATDriver
Returns:
number of bytes written, or -1 on error.
typedef int(* GETTIME)(unsigned int *apYear, unsigned int *apMonth, unsigned int *apDay, unsigned int *apHour, unsigned int *apMinutes, unsigned int *apSeconds, unsigned int *apHundredths)

Template function for the Real-Time Clock access used by FAT driver software.

Parameters:
[out] apYear Year (1900-20??).
[out] apMonth Month (1-12).
[out] apDay Day of the month (1-31).
[out] apHour Hours since midnight (0-23).
[out] apMinutes Minutes (0-59).
[out] apSeconds Seconds (0-59).
[out] apHundredths Hundredths of a second (0-99), always zero if not supported by RTC.
Returns:
Zero if successful, or -1 on error.
typedef int(* DEBUGHANDLER)(const char *apErrorString, int aeSeverity)

Debugging string for FAT development.

Parameters:
[in] apErrorString string describing error condition
[in] aeSeverity range 0-3 (debug, status, warning, error)
Returns:
0
typedef struct FAT_DIRENT FAT_dirent

This structure describes a directory entry from FAT_readdir().

typedef void FAT_DIR

Function Documentation

int RegisterFATDriver ( RAWREAD  apRawReadFunc,
RAWWRITE  apRawWriteFunc,
GETTIME  apGetTimeFunc,
tsDevInfo apRawInfo,
char *  apDeviceName,
void *  apDriverData 
)

Register a FAT device/driver with BIOS CIO utilities.

This routine will load/interrogate the FAT tables on the provided device and register the device driver with the TI stdio lookup table.

Note:
the current implementation supports up to 5 separate FAT devices to be "mounted" or configured on the MityDSP platform at any one time.
Once a system is registered, files may be accessed using fopen, etc., with "apDeviceName:" (minus the quotes) prepended to the path. There is no notion of a "current working directory" other than the "root" directory. So paths must always be fully qualified to open files in subdirectories.
A maximum of 5 FAT devices is currently supported.
Parameters:
[in] apRawReadFunc Pointer to RawRead Function used by Driver.
[in] apRawWriteFunc Pointer to RawWrite function used by Driver.
[in] apGetTimeFunc Pointer to RTC function used by Driver (if no RTC available, should be NULL to use tick timer).
[in] apRawInfo Raw Device Info, required by FAT Driver.
[in] apDeviceName Name of device, e.g. "RAMDISK". Must be less than 32 characters. This name is used to specify a path to fopen() from BIOS, e.g., "RAMDISK:\my\home\directory".
[in] apDriverData Driver Data passed to RawRead and RawWrite Routines.
Returns:
FATFS_OK (0) on success, else an error occurred.
int RemoveFATDriver ( char *  apDeviceName  ) 

REMOVE a FAT device/driver with BIOS CIO utilities.

This routine will remove a FAT device.

Parameters:
[in] apDeviceName Name of device, e.g. "RAMDISK". Must be less than 32 characters. This name is used to specify a path to fopen() from BIOS, e.g., "RAMDISK:\my\home\directory".
Returns:
FATFS_OK (0) on success, else an error occurred.
int RegisterFATDebugHandler ( DEBUGHANDLER  apDebugFunc,
void *  apUserData 
)
int FAT_format ( tsDevInfo apRawInfo,
RAWWRITE  apRawWriteFunc,
char *  apFATType,
void *  apDriverData 
)

FORMAT a device with a FAT filesystem.

This routine is useful for non-volatile devices requiring a FAT filesystem.

Note:
Currently, this routine will only support devices with 512 byte sector sizes.
Parameters:
[in] apRawInfo Device Info Structure required by FAT formatting logic.
[in] apRawWriteFunc Raw Write routine called during format operation.
[in] apFATType "FAT16" (FAT32 and FAT 12 are currently not supported)
[in] apDriverData device drive info passwd to apRawWriteFunc.
Returns:
FATFS_OK (0) on success, or non-zero on error.
int FAT_mkdir ( const char *  apPath  ) 

Create directory on a FAT FileSystem.

Parameters:
[in] apPath Fully qualified path of directory to create
Returns:
FATFS_OK (0) on success, FATFS_INVALID_PATH (-1) if the path was not valid, or another negative number upon error.
int FAT_rmdir ( const char *  apPath  ) 

Remove an empty directory on a FAT FileSystem.

Parameters:
[in] apPath Fully qualified path of directory to create
Returns:
FATFS_OK (0) on success, FATFS_INVALID_PATH (-1) if the path was not valid, FATFS_DIRECTORY_NOT_EMPTY if the directory still has files in it, FATFS_FILE_NOT_FOUND if the path does not point to a valid file, or another negative number upon error.
double FAT_getdiskfree ( const char *  apDrive  ) 

Computes the free space on a device based upon the free cluster count.

Parameters:
[in] apDrive Path name (including at least the device identifier) of the device to compute free space for.
Returns:
Free space remaining, in bytes (double precision).
int FAT_ioctl ( const char *  apDevName,
int  cmd,
void *  argp 
)

IOCTL for FAT filasystem Supported IOCTLs are

  • FATIONOATIME - set arg to a uint32 pointer.

Value of 1 to disable accesstime on readonly files

Parameters:
[in] apDevName - Device name to perform IOCTL on
[in] cmd - IOCTL command to implement
[in] argp - cmd specific data
Returns:
Zero on success, -1 if an error occurred.
FAT_DIR* FAT_opendir ( const char *  apDirName  ) 

Open directory for reading (listing).

Use this call in combination with FAT_readdir, FAT_closedir, and FAT_rewinddir in order to gather contents of a specified directory.

Parameters:
[in] apDirName Fully qualified path of interest
Returns:
Pointer to FAT directory control structure, if the path was not found, NULL is returned.
int FAT_closedir ( FAT_DIR ahDir  ) 

Close / Free resources associated with FAT_DIR structure initialized with FAT_opendir().

Parameters:
[in] ahDir Pointer to successfully opened FAT_DIR structure
Returns:
FATFS_OK on success.
int FAT_readdir ( FAT_DIR ahDir,
FAT_dirent apDirent 
)

Read next directory entry of FAT directory structure.

Parameters:
[in] ahDir Pointer to a valid FAT_DIR from FAT_opendir
[out] apDirent Pointer to a valid buffer to populate with listing contents.
Returns:
FATFS_OK (0) on success, FATFS_FILE_NOT_FOUND (-2) at end of directory, or another negative number upon error.
int FAT_rewinddir ( FAT_DIR ahDir  ) 

Resets directory listing pointer to beginning of list for a valid FAT_DIR entry as initalized by FAT_opendir.

Parameters:
[in] ahDir Pointer to a valid FAT_DIR from FAT_opendir
Returns:
FATFS_OK (0) on success, negative number upon failure.

  
Generated on Wed Mar 28 15:13:58 2012 for FAT File System Library by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.