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 /************************************************************************/
21 /* PROJECT : exFAT & FAT12/16/32 File System */
22 /* FILE : exfat_global.h */
23 /* PURPOSE : Header File for exFAT Global Definitions & Misc Functions */
25 /*----------------------------------------------------------------------*/
28 /*----------------------------------------------------------------------*/
29 /* REVISION HISTORY (Ver 0.9) */
31 /* - 2010.11.15 [Joosun Hahn] : first writing */
33 /************************************************************************/
35 #ifndef _EXFAT_GLOBAL_H
36 #define _EXFAT_GLOBAL_H
38 #include <linux/kernel.h>
40 #include <linux/slab.h>
41 #include <linux/string.h>
44 #include "exfat_config.h"
48 #endif /* __cplusplus */
50 /*======================================================================*/
52 /* CONSTANT & MACRO DEFINITIONS */
54 /*======================================================================*/
56 /*----------------------------------------------------------------------*/
57 /* Well-Known Constants (DO NOT CHANGE THIS PART !!) */
58 /*----------------------------------------------------------------------*/
77 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
78 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
80 /*======================================================================*/
82 /* TYPE DEFINITIONS */
83 /* (CHANGE THIS PART IF REQUIRED) */
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 /*======================================================================*/
106 /* LIBRARY FUNCTION DECLARATIONS -- WELL-KNOWN FUNCTIONS */
107 /* (CHANGE THIS PART IF REQUIRED) */
109 /*======================================================================*/
111 /*----------------------------------------------------------------------*/
112 /* Memory Manipulation Macros & Functions */
113 /*----------------------------------------------------------------------*/
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(...) \
162 printk("[EXFAT] " __VA_ARGS__); \
168 /*======================================================================*/
170 /* LIBRARY FUNCTION DECLARATIONS -- OTHER UTILITY FUNCTIONS */
171 /* (DO NOT CHANGE THIS PART !!) */
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 /*======================================================================*/
196 /* DEFINITIONS FOR DEBUGGING */
197 /* (CHANGE THIS PART IF REQUIRED) */
199 /*======================================================================*/
201 /* debug message ouput macro */
210 #endif /* __cplusplus */
212 #endif /* _EXFAT_GLOBAL_H */
214 /* end of exfat_global.h */