NetBurner 3.1
common.h
1 /*NB_REVISION*/
2 
3 #ifndef _COMMON_H_
4 #define _COMMON_H_
5 
6 /****************************************************************************
7  *
8  * Copyright (c) 2003-2006 by HCC Embedded
9  *
10  * This software is copyrighted by and is the sole property of
11  * HCC. All rights, title, ownership, or other interests
12  * in the software remain the property of HCC. This
13  * software may only be used in accordance with the corresponding
14  * license agreement. Any unauthorized use, duplication, transmission,
15  * distribution, or disclosure of this software is expressly forbidden.
16  *
17  * This Copyright notice may not be removed or modified without prior
18  * written consent of HCC.
19  *
20  * HCC reserves the right to modify this software without notice.
21  *
22  * HCC Embedded
23  * Budapest 1132
24  * Victor Hugo Utca 11-15
25  * Hungary
26  *
27  * Tel: +36 (1) 450 1302
28  * Fax: +36 (1) 450 1303
29  * http: www.hcc-embedded.com
30  * email: info@hcc-embedded.com
31  *
32  ***************************************************************************/
33 
34 #include <effs_fat/fat.h>
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 /* retry counter for read and write */
42 #define RDWR_RETRY 3
43 
44  /* EXPORTS */
45 
46  extern unsigned long drvbldnum;
47  extern FN_MUTEX_TYPE fat_gmutex;
48 
49  extern int fn_setlasterror(F_MULTI *fm, int errorcode);
50  extern void fn_setlasterror_noret(F_MULTI *fm, int errorcode);
51  extern int fn_createdriver(F_MULTI *fm, F_DRIVER **driver, F_DRIVERINIT driver_init, unsigned long driver_param);
52  extern int fn_releasedriver(F_MULTI *fm, F_DRIVER *driver);
53  extern int fn_createpartition(F_MULTI *fm, F_DRIVER *driver, int parnum, const F_PARTITION *par);
54  extern int fn_initvolume(F_MULTI *fm, int drvnumber, F_DRIVERINIT driver_init, unsigned long driver_param);
55  extern int fn_initvolumepartition(F_MULTI *fm, int drvnumber, F_DRIVER *driver, int partition);
56  extern int fn_ftruncate(F_MULTI *fm, FN_FILE *filehandle, unsigned long length);
57  extern int fn_getpartition(F_DRIVER *driver, int parnum, F_PARTITION *par);
58 
59  extern int _f_readsector(F_VOLUME *vi, void *data, unsigned long sector, int cnt);
60  extern int _f_writesector(F_VOLUME *vi, void *data, unsigned long sector, int cnt);
61  extern int _f_getclustervalue(F_VOLUME *vi, unsigned long cluster, unsigned long *pvalue);
62  extern void _f_clustertopos(const F_VOLUME *vi, unsigned long cluster, F_POS *pos);
63  extern unsigned long _f_getdecluster(const F_VOLUME *vi, F_DIRENTRY *de);
64  extern int _f_checkstatus(const F_VOLUME *vi, long *pstatus);
65  extern int _f_getvolume(F_MULTI *fm, int drivenum, F_VOLUME **pvi);
66  extern unsigned short _f_get16bitl(void *ptr);
67  extern unsigned long _f_get32bitl(void *ptr);
68  extern void _f_set16bitl(void *ptr, unsigned short num);
69  extern void _f_set32bitl(void *ptr, unsigned long num);
70  extern int _f_checklocked(long drvnum, const F_POS *pos);
71  extern int _f_checkreadlocked(F_VOLUME *vi, long drvnum, F_POS *pos, FN_FILEINT **fapp);
72  extern int _f_checkappendlocked(long drvnum, const F_POS *pos, FN_FILEINT *ofile);
73  extern void _f_initentry(F_DIRENTRY *de, const char *name, const char *ext);
74  extern int _f_alloccluster(F_VOLUME *vi, unsigned long *pcluster);
75  extern int _f_dobadblock(F_VOLUME *vi, FN_FILEINT *f);
76  extern int _f_setclustervalue(F_VOLUME *vi, unsigned long cluster, unsigned long data);
77  extern int _f_writefatsector(F_VOLUME *vi);
78  extern void _f_setdecluster(const F_VOLUME *vi, F_DIRENTRY *de, unsigned long cluster);
79  extern int _f_fseek(F_VOLUME *vi, F_MULTI *fm, FN_FILEINT *f, unsigned long offset);
80  extern int _f_getcurrsector(F_VOLUME *vi, FN_FILEINT *f, char *ptr, unsigned int *cnt);
81  extern int _f_removechain(F_VOLUME *vi, unsigned long cluster);
82  extern FN_FILEINT *_f_check_handle(FN_FILE *filehandle);
83  extern int _f_writedirsector(F_VOLUME *vi);
84  extern unsigned long _f_getmaxcluster(const F_VOLUME *vi);
85  extern int _f_writezeros(F_VOLUME *vi, F_MULTI *fm, FN_FILEINT *f, unsigned long num);
86  extern void _f_syncfiles(F_VOLUME *vi, F_MULTI *fm, const FN_FILEINT *file);
87  int _f_findopensize(unsigned long *ofsize, int drivenum, F_POS *pos);
88 
89 #if F_MAXSEEKPOS
90  extern void _fn_removeseekpos(FN_FILEINT *f);
91  extern void _fn_updateseekpos(FN_FILEINT *f);
92  extern void _fn_initseekdivisor(FN_FILEINT *f, F_VOLUME *vi);
93 #endif
94 
95 #ifdef FATCACHE_ENABLE
96  extern int _f_fatcache_flush(F_VOLUME *vi, int clear);
97 #endif
98 
99  extern int _f_mutex_get(F_MULTI *fm, F_VOLUME *vi);
100  extern void _f_mutex_put(F_MULTI *fm);
101 
102 #if (!FN_CAPI_USED)
103 #ifdef USE_MALLOC
104  extern F_MULTI *g_multi[FN_MAXTASK];
105 #else
106  extern F_MULTI g_multi[FN_MAXTASK];
107 #endif
108 #endif
109 
110  extern int fnGetTask(F_MULTI **fm);
111 
112 #ifdef INTERNAL_MEMFN
113  extern void *_f_memset(void *, int, unsigned long);
114  extern void *_f_memcpy(void *, void *, unsigned long);
115 #endif
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 /****************************************************************************
122  *
123  * end of common.h
124  *
125  ***************************************************************************/
126 
127 #endif /* _COMMON_H_ */