Milos RTOS v0.3.4a
Real Time Operating System
fat.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  * fat.h
00003  * (C) 2010 Ivan Meleca
00004  * Based on original code written by Ruben Meleca
00005  * www.milos.it
00006  *
00007  * Interface between ChaN FatFS and Milos
00008  *
00009 
00010 #   This program is free software; you can redistribute it and/or modify
00011 #   it under the terms of the GNU General Public License as published by
00012 #   the Free Software Foundation; either version 2 of the License, or
00013 #   (at your option) any later version.
00014 #
00015 #   This program is distributed in the hope that it will be useful,
00016 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 #   GNU General Public License for more details.
00019 #
00020 #   You should have received a copy of the GNU General Public License
00021 #   along with this program; if not, write to the Free Software
00022 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023 
00024 ***************************************************************************/
00025 #ifndef __FAT_H__
00026 #define __FAT_H__
00027 
00028 #include <core/system.h>
00029 #include <core/device.h>
00030 #include <core/terminal.h>
00031 #include "fatfs/src/ff.h"
00032 #include "fatfs/src/diskio.h"
00033 
00034 #if __CONFIG_COMPILE_FAT
00035 
00040 /*
00041  * Own types based on FatFS types
00042  */
00043 typedef DSTATUS     __FATFS_STATUS;
00044 typedef DRESULT     __FATFS_RES;
00045 typedef FRESULT     __FILE_RES;
00046 typedef FATFS       __FAT_FATFS;
00047 typedef FATFS*      __PFAT_FATFS;
00048 typedef FIL         __FILE;
00049 typedef FIL*        __PFILE;
00050 typedef DIR         __DIR;
00051 typedef DIR*        __PDIR;
00052 typedef FILINFO     __FILEINFO;
00053 typedef FILINFO*    __PFILEINFO;
00054 
00055 #define __FILE_READ             FA_READ
00056 #define __FILE_OPEN_EXISTING    FA_OPEN_EXISTING
00057 
00058 #if !_FS_READONLY
00059 #define __FILE_WRITE            FA_WRITE
00060 #define __FILE_CREATE_NEW       FA_CREATE_NEW
00061 #define __FILE_CREATE_ALWAYS    FA_CREATE_ALWAYS
00062 #define __FILE_OPEN_ALWAYS      FA_OPEN_ALWAYS
00063 #endif
00064 
00065 
00072 typedef struct __fatvolumeTag {
00073     u32                     num;        
00074     __PDEVICE               dv;         
00075     __PFAT_FATFS            fat;        
00076     __PLOCK                 lock;       
00077     struct __fatvolumeTag*  next;       
00078 } __FAT_VOLUME, *__PFAT_VOLUME;
00079 
00080 /*
00081  * FAT functions.
00082  */
00083 __PFAT_VOLUME   __fatMount(u8 num, __PDEVICE dv);
00084 __VOID          __fatUnmount(__PFAT_VOLUME vol);
00085 u32             __fatGetFreeClusters(__CONST __PSTRING part, __PFAT_VOLUME* vol);
00086 
00087 /*
00088  * File functions.
00089  */
00090 __PFILE     __fileOpen(__CONST __PSTRING file, u8 mode);
00091 u32         __fileRead(__PFILE file, __PVOID buf, u32 qty);
00092 __FILE_RES  __fileSeek(__PFILE file, u32 offs);
00093 __FILE_RES  __fileClose(__PFILE file);
00094 __FILE_RES  __fileGetStatus(__CONST __PSTRING file, __PFILEINFO fi);
00095 u32         __fileWriteLine(__PFILE file, __PSTRING str);
00096 u32         __fileWrite(__PFILE file, __PVOID buf, u32 qty);
00097 __FILE_RES  __fileFlush(__PFILE file);
00098 __FILE_RES  __fileTruncate(__PFILE file);
00099 __FILE_RES  __fileSync(__PFILE file);
00100 __FILE_RES  __fileDelete(__CONST __PSTRING file);
00101 __FILE_RES  __fileChmod(__CONST __PSTRING file, u8 value, u8 mask);
00102 __FILE_RES  __fileChangeTime(__CONST __PSTRING file, __CONST __PFILEINFO fi);
00103 __FILE_RES  __fileRename(__CONST __PSTRING name1, __CONST __PSTRING name2);
00104 
00105 /*
00106  * Directory functions
00107  */
00108 __FILE_RES  __dirCreate(__CONST __PSTRING name);
00109 __FILE_RES  __dirOpen(__PDIR dir, __CONST __PSTRING name);
00110 __FILE_RES  __dirRead(__PDIR dir, __PFILEINFO fi);
00111 
00112 /*
00113  * Misc Functions
00114  */
00115 __VOID __fatDirCmd(__PTERMINAL term);
00116 
00117 
00122 #endif // __CONFIG_COMPILE_FAT
00123 
00124 #endif // __FAT_H__
 All Data Structures Files Functions Variables Typedefs Defines