00001 #ifndef _FS_FLASHFS_H_
00002 #define _FS_FLASHFS_H_
00003
00004 #include <avr/pgmspace.h>
00005 #include <sys/types.h>
00006 #include <dev/flash.h>
00007
00025 #define TYPE_DIRECTORY 1
00026
00030 #define TYPE_FILE 2
00031
00035 #define TYPE_NULL 0
00036
00040 #define MAX_FILE_NAME 50
00041
00045 #define NUMBER_OF_FILES 50
00046
00047
00048
00049
00050 #define NUMBER_OF_ROOT_PAGE ((sizeof(FILENODEINFS)*NUMBER_OF_FILES+sizeof(FLASHFS))/PAGE_SIZE + 1)
00051
00052
00053
00054
00055 #define ROOT_PAGE 0
00056
00057
00058
00059
00060 #define MAGIC "edunetFS"
00061
00062
00063
00064
00065 #define ROOT_CATALOG "/"
00066
00067
00068
00069
00070 #define MAX_PAGE_NUMBER 8000
00071
00072
00073
00074
00075 #define NUMBER_OF_FAT_PAGE (MAX_PAGE_NUMBER/(PAGE_SIZE*8) + 1)
00076
00077
00078
00079
00080 #define NUMBER_OF_PACK_UNIT ((MAX_PAGE_NUMBER/(PAGE_SIZE*8) + 1) * PAGE_SIZE)
00081
00082
00083
00084
00085
00086 #define FIRST_FILE_PAGE \
00087 (ROOT_PAGE \
00088 + ((sizeof(FILENODEINFS)*NUMBER_OF_FILES+sizeof(FLASHFS))/PAGE_SIZE + 1) \
00089 + MAX_PAGE_NUMBER/(PAGE_SIZE*8) + 1 \
00090 + 1)
00091
00092
00093
00094
00095 #define NOT_CLEAR 1
00096
00097
00098
00099
00100 #define CLEAR 0
00101
00102
00103
00104
00105 #define NEXT_PAGE PAGE_SIZE - sizeof(u_short)
00106
00110 #define EOF 0
00111
00112 typedef struct _FLASHFS FLASHFS;
00113 typedef struct _FILENODE FILENODE;
00114 typedef struct _FILENODEINFS FILENODEINFS;
00119 typedef struct _FILE FILE;
00120 typedef struct _FATINMEMORY FATINMEMORY;
00121
00122
00123
00124
00125 struct _FILENODE {
00126
00127
00128
00129 FILENODE* fileNodeNext;
00130
00131
00132
00133 u_char fileName[MAX_FILE_NAME];
00134
00135
00136
00137 u_long fileSize;
00138
00139
00140
00141 u_short firstPage;
00142
00143
00144
00145 u_char operationType;
00146 };
00147
00148
00149
00150
00151
00152 struct _FILENODEINFS {
00153
00154
00155
00156 u_char fileName[MAX_FILE_NAME];
00157
00158
00159
00160 u_long fileSize;
00161
00162
00163
00164 u_short firstPage;
00165 };
00166
00167
00168
00169
00170
00171 struct _FILE {
00172
00173
00174
00175 FILENODE *fileNode;
00176
00177
00178
00179 u_short positionOnPage;
00180
00181
00182
00183 u_short pageNumber;
00184 };
00185
00186
00187
00188
00189 struct _FLASHFS {
00190
00191
00192
00193 char magic[sizeof(MAGIC)];
00194
00195
00196
00197 u_short numberOfPage;
00198 };
00199
00200
00201
00202
00203
00204 struct _FATINMEMORY {
00205
00206
00207
00208
00209 u_char packUnit[NUMBER_OF_PACK_UNIT];
00210 };
00211
00218 extern int InitFlashFs(void);
00219
00231 extern FILE* fileOpen(char* name, char type);
00232
00244 extern int fileWrite(FILE *file, void *data, u_int size);
00245
00253 extern int fileClose(FILE *file);
00254
00266 extern int fileRead(FILE *file, void *data, u_int size);
00267
00275 extern u_long fileSize(FILE *file);
00276
00286 extern int fileSeek(FILE *file, u_long pos);
00287
00296 extern int remove(char* name);
00297
00309 extern char* ls(char* dir, char* ret, char* param);
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 extern int cd(char* dir);
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 extern char* pwd(char* ret);
00330
00337 extern int format(void);
00338
00339 #endif