Make RNDISHost demo validate the set Packet Filter to ensure that it is being sent...
[pub/lufa.git] / Projects / Incomplete / StandaloneProgrammer / Lib / PetiteFATFs / pff.h
diff --git a/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/pff.h b/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/pff.h
new file mode 100644 (file)
index 0000000..b24339c
--- /dev/null
@@ -0,0 +1,237 @@
+/*---------------------------------------------------------------------------/\r
+/  Petit FatFs - FAT file system module include file  R0.01a   (C)ChaN, 2009\r
+/----------------------------------------------------------------------------/\r
+/ Petit FatFs module is an open source software to implement FAT file system to\r
+/ small embedded systems. This is a free software and is opened for education,\r
+/ research and commercial developments under license policy of following trems.\r
+/\r
+/  Copyright (C) 2009, ChaN, all right reserved.\r
+/\r
+/ * The Petit FatFs module is a free software and there is NO WARRANTY.\r
+/ * No restriction on use. You can use, modify and redistribute it for\r
+/   personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY.\r
+/ * Redistributions of source code must retain the above copyright notice.\r
+/----------------------------------------------------------------------------*/\r
+\r
+#include "integer.h"\r
+\r
+/*---------------------------------------------------------------------------/\r
+/ Petit FatFs Configuration Options\r
+/\r
+/ CAUTION! Do not forget to make clean the project after any changes to\r
+/ the configuration options.\r
+/\r
+/----------------------------------------------------------------------------*/\r
+#ifndef _FATFS\r
+#define _FATFS\r
+\r
+#define _WORD_ACCESS   0\r
+/* The _WORD_ACCESS option defines which access method is used to the word\r
+/  data in the FAT structure.\r
+/\r
+/   0: Byte-by-byte access. Always compatible with all platforms.\r
+/   1: Word access. Do not choose this unless following condition is met.\r
+/\r
+/  When the byte order on the memory is big-endian or address miss-aligned\r
+/  word access results incorrect behavior, the _WORD_ACCESS must be set to 0.\r
+/  If it is not the case, the value can also be set to 1 to improve the\r
+/  performance and code efficiency. */\r
+\r
+\r
+#define        _USE_DIR        0\r
+/* To enable pf_opendir and pf_readdir function, set _USE_DIR to 1. */\r
+\r
+\r
+#define        _USE_LSEEK      0\r
+/* To enable pf_lseek function, set _USE_LSEEK to 1. */\r
+\r
+\r
+#define _FS_FAT32      0\r
+/* To enable FAT32 support, set _FS_FAT32 to 1. */\r
+\r
+\r
+/* End of configuration options. Do not change followings without care.     */\r
+/*--------------------------------------------------------------------------*/\r
+\r
+\r
+#if _FS_FAT32\r
+#define        CLUST   DWORD\r
+#else\r
+#define        CLUST   WORD\r
+#endif\r
+\r
+\r
+/* File system object structure */\r
+\r
+typedef struct _FATFS_ {\r
+       BYTE    fs_type;        /* FAT sub type */\r
+       BYTE    csize;          /* Number of sectors per cluster */\r
+       BYTE    flag;           /* File status flags */\r
+       BYTE    csect;          /* File sector address in the cluster */\r
+       WORD    n_rootdir;      /* Number of root directory entries (0 on FAT32) */\r
+       BYTE*   buf;            /* Pointer to the disk access buffer */\r
+       CLUST   max_clust;      /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */\r
+       DWORD   fatbase;        /* FAT start sector */\r
+       DWORD   dirbase;        /* Root directory start sector (Cluster# on FAT32) */\r
+       DWORD   database;       /* Data start sector */\r
+       DWORD   fptr;           /* File R/W pointer */\r
+       DWORD   fsize;          /* File size */\r
+       CLUST   org_clust;      /* File start cluster */\r
+       CLUST   curr_clust;     /* File current cluster */\r
+       DWORD   dsect;          /* File current data sector */\r
+} FATFS;\r
+\r
+\r
+\r
+/* Directory object structure */\r
+\r
+typedef struct _DIR_ {\r
+       WORD    index;          /* Current read/write index number */\r
+       BYTE*   fn;                     /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */\r
+       CLUST   sclust;         /* Table start cluster (0:Static table) */\r
+       CLUST   clust;          /* Current cluster */\r
+       DWORD   sect;           /* Current sector */\r
+} DIR;\r
+\r
+\r
+\r
+/* File status structure */\r
+\r
+typedef struct _FILINFO_ {\r
+       DWORD   fsize;          /* File size */\r
+       WORD    fdate;          /* Last modified date */\r
+       WORD    ftime;          /* Last modified time */\r
+       BYTE    fattrib;        /* Attribute */\r
+       char    fname[13];      /* File name */\r
+} FILINFO;\r
+\r
+\r
+\r
+/* File function return code (FRESULT) */\r
+\r
+typedef enum {\r
+       FR_OK = 0,                      /* 0 */\r
+       FR_DISK_ERR,            /* 1 */\r
+       FR_NOT_READY,           /* 2 */\r
+       FR_NO_FILE,                     /* 3 */\r
+       FR_NO_PATH,                     /* 4 */\r
+       FR_INVALID_NAME,        /* 5 */\r
+       FR_STREAM_ERR,          /* 6 */\r
+       FR_INVALID_OBJECT,      /* 7 */\r
+       FR_NOT_ENABLED,         /* 8 */\r
+       FR_NO_FILESYSTEM        /* 9 */\r
+} FRESULT;\r
+\r
+\r
+\r
+/*--------------------------------------------------------------*/\r
+/* Petit FatFs module application interface                     */\r
+\r
+FRESULT pf_mount (FATFS*);                             /* Mount/Unmount a logical drive */\r
+FRESULT pf_open (const char*);                 /* Open a file */\r
+FRESULT pf_read (void*, WORD, WORD*);  /* Read data from a file */\r
+FRESULT pf_lseek (DWORD);                              /* Move file pointer of a file object */\r
+FRESULT pf_opendir (DIR*, const char*);        /* Open an existing directory */\r
+FRESULT pf_readdir (DIR*, FILINFO*);   /* Read a directory item */\r
+\r
+\r
+\r
+/*--------------------------------------------------------------*/\r
+/* Flags and offset address                                     */\r
+\r
+/* File status flag (FATFS.flag) */\r
+\r
+#define        FA_READ         0x01\r
+#define        FA_STREAM       0x40\r
+#define        FA__ERROR       0x80\r
+\r
+\r
+/* FAT sub type (FATFS.fs_type) */\r
+\r
+#define FS_FAT12       1\r
+#define FS_FAT16       2\r
+#define FS_FAT32       3\r
+\r
+\r
+/* File attribute bits for directory entry */\r
+\r
+#define        AM_RDO  0x01    /* Read only */\r
+#define        AM_HID  0x02    /* Hidden */\r
+#define        AM_SYS  0x04    /* System */\r
+#define        AM_VOL  0x08    /* Volume label */\r
+#define AM_LFN 0x0F    /* LFN entry */\r
+#define AM_DIR 0x10    /* Directory */\r
+#define AM_ARC 0x20    /* Archive */\r
+#define AM_MASK        0x3F    /* Mask of defined bits */\r
+\r
+\r
+/* FatFs refers the members in the FAT structures with byte offset instead\r
+/ of structure member because there are incompatibility of the packing option\r
+/ between various compilers. */\r
+\r
+#define BS_jmpBoot                     0\r
+#define BS_OEMName                     3\r
+#define BPB_BytsPerSec         11\r
+#define BPB_SecPerClus         13\r
+#define BPB_RsvdSecCnt         14\r
+#define BPB_NumFATs                    16\r
+#define BPB_RootEntCnt         17\r
+#define BPB_TotSec16           19\r
+#define BPB_Media                      21\r
+#define BPB_FATSz16                    22\r
+#define BPB_SecPerTrk          24\r
+#define BPB_NumHeads           26\r
+#define BPB_HiddSec                    28\r
+#define BPB_TotSec32           32\r
+#define BS_55AA                                510\r
+\r
+#define BS_DrvNum                      36\r
+#define BS_BootSig                     38\r
+#define BS_VolID                       39\r
+#define BS_VolLab                      43\r
+#define BS_FilSysType          54\r
+\r
+#define BPB_FATSz32                    36\r
+#define BPB_ExtFlags           40\r
+#define BPB_FSVer                      42\r
+#define BPB_RootClus           44\r
+#define BPB_FSInfo                     48\r
+#define BPB_BkBootSec          50\r
+#define BS_DrvNum32                    64\r
+#define BS_BootSig32           66\r
+#define BS_VolID32                     67\r
+#define BS_VolLab32                    71\r
+#define BS_FilSysType32                82\r
+\r
+#define MBR_Table                      446\r
+\r
+#define        DIR_Name                        0\r
+#define        DIR_Attr                        11\r
+#define        DIR_NTres                       12\r
+#define        DIR_CrtTime                     14\r
+#define        DIR_CrtDate                     16\r
+#define        DIR_FstClusHI           20\r
+#define        DIR_WrtTime                     22\r
+#define        DIR_WrtDate                     24\r
+#define        DIR_FstClusLO           26\r
+#define        DIR_FileSize            28\r
+\r
+\r
+\r
+/*--------------------------------*/\r
+/* Multi-byte word access macros  */\r
+\r
+#if _WORD_ACCESS == 1  /* Enable word access to the FAT structure */\r
+#define        LD_WORD(ptr)            (WORD)(*(WORD*)(BYTE*)(ptr))\r
+#define        LD_DWORD(ptr)           (DWORD)(*(DWORD*)(BYTE*)(ptr))\r
+#define        ST_WORD(ptr,val)        *(WORD*)(BYTE*)(ptr)=(WORD)(val)\r
+#define        ST_DWORD(ptr,val)       *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)\r
+#else                                  /* Use byte-by-byte access to the FAT structure */\r
+#define        LD_WORD(ptr)            (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))\r
+#define        LD_DWORD(ptr)           (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))\r
+#define        ST_WORD(ptr,val)        *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)\r
+#define        ST_DWORD(ptr,val)       *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)\r
+#endif\r
+\r
+\r
+#endif /* _FATFS */\r