CD exfat support for Tomato. https://github.com/dorimanx/exfat-nofuse.
[tomato.git] / release / src-rt / linux / linux-2.6 / fs / exfat / exfat_global.h
blob890bd390de35061e583c6005b7e46de27ce6123a
1 /*
2 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 /************************************************************************/
20 /* */
21 /* PROJECT : exFAT & FAT12/16/32 File System */
22 /* FILE : exfat_global.h */
23 /* PURPOSE : Header File for exFAT Global Definitions & Misc Functions */
24 /* */
25 /*----------------------------------------------------------------------*/
26 /* NOTES */
27 /* */
28 /*----------------------------------------------------------------------*/
29 /* REVISION HISTORY (Ver 0.9) */
30 /* */
31 /* - 2010.11.15 [Joosun Hahn] : first writing */
32 /* */
33 /************************************************************************/
35 #ifndef _EXFAT_GLOBAL_H
36 #define _EXFAT_GLOBAL_H
38 #include <linux/kernel.h>
39 #include <linux/mm.h>
40 #include <linux/slab.h>
41 #include <linux/string.h>
42 #include <linux/fs.h>
44 #include "exfat_config.h"
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
50 /*======================================================================*/
51 /* */
52 /* CONSTANT & MACRO DEFINITIONS */
53 /* */
54 /*======================================================================*/
56 /*----------------------------------------------------------------------*/
57 /* Well-Known Constants (DO NOT CHANGE THIS PART !!) */
58 /*----------------------------------------------------------------------*/
60 #ifndef TRUE
61 #define TRUE 1
62 #endif
63 #ifndef FALSE
64 #define FALSE 0
65 #endif
66 #ifndef OK
67 #define OK 0
68 #endif
69 #ifndef FAIL
70 #define FAIL 1
71 #endif
72 #ifndef NULL
73 #define NULL 0
74 #endif
76 /* Min/Max macro */
77 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
78 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
80 /*======================================================================*/
81 /* */
82 /* TYPE DEFINITIONS */
83 /* (CHANGE THIS PART IF REQUIRED) */
84 /* */
85 /*======================================================================*/
87 /* type definitions for primitive types;
88 these should be re-defined to meet its size for each OS platform;
89 these should be used instead of primitive types for portability. */
91 typedef char INT8; // 1 byte signed integer
92 typedef short INT16; // 2 byte signed integer
93 typedef int INT32; // 4 byte signed integer
94 typedef long long INT64; // 8 byte signed integer
96 typedef unsigned char UINT8; // 1 byte unsigned integer
97 typedef unsigned short UINT16; // 2 byte unsigned integer
98 typedef unsigned int UINT32; // 4 byte unsigned integer
99 typedef unsigned long long UINT64; // 8 byte ussigned integer
101 typedef unsigned char BOOL;
104 /*======================================================================*/
105 /* */
106 /* LIBRARY FUNCTION DECLARATIONS -- WELL-KNOWN FUNCTIONS */
107 /* (CHANGE THIS PART IF REQUIRED) */
108 /* */
109 /*======================================================================*/
111 /*----------------------------------------------------------------------*/
112 /* Memory Manipulation Macros & Functions */
113 /*----------------------------------------------------------------------*/
115 #ifdef MALLOC
116 #undef MALLOC
117 #endif
118 #ifdef FREE
119 #undef FREE
120 #endif
121 #ifdef MEMSET
122 #undef MEMSET
123 #endif
124 #ifdef MEMCPY
125 #undef MEMCPY
126 #endif
127 #ifdef MEMCMP
128 #undef MEMCMP
129 #endif
131 #define MALLOC(size) kmalloc(size, GFP_KERNEL)
132 #define FREE(mem) if (mem) kfree(mem)
133 #define MEMSET(mem, value, size) memset(mem, value, size)
134 #define MEMCPY(dest, src, size) memcpy(dest, src, size)
135 #define MEMCMP(mem1, mem2, size) memcmp(mem1, mem2, size)
136 #define COPY_DENTRY(dest, src) memcpy(dest, src, sizeof(DENTRY_T))
138 /*----------------------------------------------------------------------*/
139 /* String Manipulation Macros & Functions */
140 /*----------------------------------------------------------------------*/
142 #define STRCPY(dest, src) strcpy(dest, src)
143 #define STRNCPY(dest, src, n) strncpy(dest, src, n)
144 #define STRCAT(str1, str2) strcat(str1, str2)
145 #define STRCMP(str1, str2) strcmp(str1, str2)
146 #define STRNCMP(str1, str2, n) strncmp(str1, str2, n)
147 #define STRLEN(str) strlen(str)
149 INT32 __wstrchr(UINT16 *str, UINT16 wchar);
150 INT32 __wstrlen(UINT16 *str);
152 #define WSTRCHR(str, wchar) __wstrchr(str, wchar)
153 #define WSTRLEN(str) __wstrlen(str)
155 /*----------------------------------------------------------------------*/
156 /* Debugging Macros & Functions */
157 /* EXFAT_CONFIG_DEBUG_MSG is configured in exfat_config.h */
158 /*----------------------------------------------------------------------*/
159 #if EXFAT_CONFIG_DEBUG_MSG
160 #define PRINTK(...) \
161 do { \
162 printk("[EXFAT] " __VA_ARGS__); \
163 } while(0)
164 #else
165 #define PRINTK(...)
166 #endif
168 /*======================================================================*/
169 /* */
170 /* LIBRARY FUNCTION DECLARATIONS -- OTHER UTILITY FUNCTIONS */
171 /* (DO NOT CHANGE THIS PART !!) */
172 /* */
173 /*======================================================================*/
175 /*----------------------------------------------------------------------*/
176 /* Bitmap Manipulation Functions */
177 /*----------------------------------------------------------------------*/
179 void Bitmap_set_all(UINT8 *bitmap, INT32 mapsize);
180 void Bitmap_clear_all(UINT8 *bitmap, INT32 mapsize);
181 INT32 Bitmap_test(UINT8 *bitmap, INT32 i);
182 void Bitmap_set(UINT8 *bitmap, INT32 i);
183 void Bitmap_clear(UINT8 *bitmpa, INT32 i);
184 void Bitmap_nbits_set(UINT8 *bitmap, INT32 offset, INT32 nbits);
185 void Bitmap_nbits_clear(UINT8 *bitmap, INT32 offset, INT32 nbits);
187 /*----------------------------------------------------------------------*/
188 /* Miscellaneous Library Functions */
189 /*----------------------------------------------------------------------*/
191 void my_itoa(INT8 *buf, INT32 v);
192 INT32 my_log2(UINT32 v);
194 /*======================================================================*/
195 /* */
196 /* DEFINITIONS FOR DEBUGGING */
197 /* (CHANGE THIS PART IF REQUIRED) */
198 /* */
199 /*======================================================================*/
201 /* debug message ouput macro */
202 #ifdef PRINT
203 #undef PRINT
204 #endif
206 #define PRINT printk
208 #ifdef __cplusplus
210 #endif /* __cplusplus */
212 #endif /* _EXFAT_GLOBAL_H */
214 /* end of exfat_global.h */