forked from dorimanx/exfat-nofuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exfat_global.h
203 lines (169 loc) · 8.07 KB
/
exfat_global.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/************************************************************************/
/* */
/* PROJECT : exFAT & FAT12/16/32 File System */
/* FILE : exfat_global.h */
/* PURPOSE : Header File for exFAT Global Definitions & Misc Functions */
/* */
/*----------------------------------------------------------------------*/
/* NOTES */
/* */
/*----------------------------------------------------------------------*/
/* REVISION HISTORY (Ver 0.9) */
/* */
/* - 2010.11.15 [Joosun Hahn] : first writing */
/* */
/************************************************************************/
#ifndef _EXFAT_GLOBAL_H
#define _EXFAT_GLOBAL_H
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/fs.h>
#include "exfat_config.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*======================================================================*/
/* */
/* CONSTANT & MACRO DEFINITIONS */
/* */
/*======================================================================*/
/*----------------------------------------------------------------------*/
/* Well-Known Constants (DO NOT CHANGE THIS PART !!) */
/*----------------------------------------------------------------------*/
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef OK
#define OK 0
#endif
#ifndef FAIL
#define FAIL 1
#endif
#ifndef NULL
#define NULL 0
#endif
/* Min/Max macro */
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
/*======================================================================*/
/* */
/* TYPE DEFINITIONS */
/* (CHANGE THIS PART IF REQUIRED) */
/* */
/*======================================================================*/
/* type definitions for primitive types;
these should be re-defined to meet its size for each OS platform;
these should be used instead of primitive types for portability. */
typedef char INT8; // 1 byte signed integer
typedef short INT16; // 2 byte signed integer
typedef int INT32; // 4 byte signed integer
typedef long long INT64; // 8 byte signed integer
typedef unsigned char UINT8; // 1 byte unsigned integer
typedef unsigned short UINT16; // 2 byte unsigned integer
typedef unsigned int UINT32; // 4 byte unsigned integer
typedef unsigned long long UINT64; // 8 byte ussigned integer
typedef unsigned char BOOL;
/*======================================================================*/
/* */
/* LIBRARY FUNCTION DECLARATIONS -- WELL-KNOWN FUNCTIONS */
/* (CHANGE THIS PART IF REQUIRED) */
/* */
/*======================================================================*/
/*----------------------------------------------------------------------*/
/* Memory Manipulation Macros & Functions */
/*----------------------------------------------------------------------*/
#ifdef MALLOC
#undef MALLOC
#endif
#ifdef FREE
#undef FREE
#endif
#ifdef MEMSET
#undef MEMSET
#endif
#ifdef MEMCPY
#undef MEMCPY
#endif
#ifdef MEMCMP
#undef MEMCMP
#endif
#define MALLOC(size) kmalloc(size, GFP_KERNEL)
#define FREE(mem) if (mem) kfree(mem)
#define MEMSET(mem, value, size) memset(mem, value, size)
#define MEMCPY(dest, src, size) memcpy(dest, src, size)
#define MEMCMP(mem1, mem2, size) memcmp(mem1, mem2, size)
#define COPY_DENTRY(dest, src) memcpy(dest, src, sizeof(DENTRY_T))
/*----------------------------------------------------------------------*/
/* String Manipulation Macros & Functions */
/*----------------------------------------------------------------------*/
#define STRCPY(dest, src) strcpy(dest, src)
#define STRNCPY(dest, src, n) strncpy(dest, src, n)
#define STRCAT(str1, str2) strcat(str1, str2)
#define STRCMP(str1, str2) strcmp(str1, str2)
#define STRNCMP(str1, str2, n) strncmp(str1, str2, n)
#define STRLEN(str) strlen(str)
INT32 __wstrchr(UINT16 *str, UINT16 wchar);
INT32 __wstrlen(UINT16 *str);
#define WSTRCHR(str, wchar) __wstrchr(str, wchar)
#define WSTRLEN(str) __wstrlen(str)
/*----------------------------------------------------------------------*/
/* Debugging Macros & Functions */
/* EXFAT_CONFIG_DEBUG_MSG is configured in exfat_config.h */
/*----------------------------------------------------------------------*/
#if EXFAT_CONFIG_DEBUG_MSG
#if 0
#define PRINTK(...) \
do { \
printk ("%u: ", dbg_count); \
printk(__VA_ARGS__); \
} while(0)
#endif
#define PRINTK(...) \
do { \
printk(__VA_ARGS__); \
} while(0)
#else
#define PRINTK(...)
#endif
/*======================================================================*/
/* */
/* LIBRARY FUNCTION DECLARATIONS -- OTHER UTILITY FUNCTIONS */
/* (DO NOT CHANGE THIS PART !!) */
/* */
/*======================================================================*/
/*----------------------------------------------------------------------*/
/* Bitmap Manipulation Functions */
/*----------------------------------------------------------------------*/
void Bitmap_set_all(UINT8 *bitmap, INT32 mapsize);
void Bitmap_clear_all(UINT8 *bitmap, INT32 mapsize);
INT32 Bitmap_test(UINT8 *bitmap, INT32 i);
void Bitmap_set(UINT8 *bitmap, INT32 i);
void Bitmap_clear(UINT8 *bitmpa, INT32 i);
void Bitmap_nbits_set(UINT8 *bitmap, INT32 offset, INT32 nbits);
void Bitmap_nbits_clear(UINT8 *bitmap, INT32 offset, INT32 nbits);
/*----------------------------------------------------------------------*/
/* Miscellaneous Library Functions */
/*----------------------------------------------------------------------*/
void my_itoa(INT8 *buf, INT32 v);
INT32 my_log2(UINT32 v);
/*======================================================================*/
/* */
/* DEFINITIONS FOR DEBUGGING */
/* (CHANGE THIS PART IF REQUIRED) */
/* */
/*======================================================================*/
/* debug message ouput macro */
#ifdef PRINT
#undef PRINT
#endif
#define PRINT printk
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _EXFAT_GLOBAL_H */
/* end of exfat_global.h */