2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
3 * yportenv.h: Portable services used by yaffs. This is done to allow
4 * simple migration from kernel space into app space for testing.
6 * Copyright (C) 2002 Aleph One Ltd.
7 * for Toby Churchill Ltd and Brightstar Engineering
9 * Created by Charles Manning <charles@aleph1.co.uk>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 2.1 as
13 * published by the Free Software Foundation.
16 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
18 * $Id: yportenv.h,v 1.2 2004-11-03 08:35:48 charles Exp $
22 #ifndef __YPORTENV_H__
23 #define __YPORTENV_H__
26 #if defined CONFIG_YAFFS_WINCE
35 #define CONFIG_YAFFS_CASE_INSENSITIVE
36 #define CONFIG_YAFFS_UNICODE
38 #define YMALLOC(x) malloc(x)
39 #define YFREE(x) free(x)
42 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
43 #define YALERT(s) YINFO(s)
47 #define YPRINTF(x) RETAILMSG(1,x)
49 // Always pass the sum compare to overcome the case insensitivity issue
50 #define yaffs_SumCompare(x,y) ((x) == (y))
52 #ifdef CONFIG_YAFFS_UNICODE
56 #define yaffs_toupper(a) towupper(a)
57 #define yaffs_strcmp(a,b) _wcsicmp(a,b)
58 #define yaffs_strcpy(a,b) wcscpy(a,b)
59 #define yaffs_strncpy(a,b,c) wcsncpy(a,b,c)
60 #define yaffs_strlen(s) wcslen(s)
61 #define yaffs_sprintf swprintf
66 #define yaffs_toupper(a) toupper(a)
67 #define yaffs_strcmp(a,b) _stricmp(a,b)
68 #define yaffs_strcpy(a,b) strcpy(a,b)
69 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
70 #define yaffs_strlen(s) strlen(s)
71 #define yaffs_sprintf sprintf
74 #define YAFFS_LOSTNFOUND_NAME _Y("Lost Clusters")
75 #define YAFFS_LOSTNFOUND_PREFIX _Y("OBJ")
78 #define u_char unsigned char
87 extern unsigned yfsd_U32FileTimeNow(void);
89 #define CURRENT_TIME yfsd_U32FileTimeNow()
90 #define YAFFS_ROOT_MODE FILE_ATTRIBUTE_ARCHIVE
91 #define YAFFS_LOSTNFOUND_MODE FILE_ATTRIBUTE_HIDDEN
94 #define TENDSTR L"\r\n"
95 #define TSTR(x) TEXT(x)
96 #define TOUT(x) RETAILMSG(1, x)
99 #elif defined __KERNEL__
104 #include "linux/kernel.h"
105 #include "linux/mm.h"
106 #include "linux/string.h"
107 #include "linux/slab.h"
112 #define YAFFS_LOSTNFOUND_NAME "lost+found"
113 #define YAFFS_LOSTNFOUND_PREFIX "obj"
115 //#define YPRINTF(x) printk x
116 #define YMALLOC(x) kmalloc(x,GFP_KERNEL)
117 #define YFREE(x) kfree(x)
119 #define YAFFS_ROOT_MODE 0666
120 #define YAFFS_LOSTNFOUND_MODE 0666
123 #define yaffs_SumCompare(x,y) ((x) == (y))
125 #define YUCHAR unsigned char
127 #define yaffs_toupper(a) toupper(a)
128 #define yaffs_strcmp(a,b) strcmp(a,b)
129 #define yaffs_strcpy(a,b) strcpy(a,b)
130 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
131 #define yaffs_strlen(s) strlen(s)
132 #define yaffs_sprintf sprintf
135 #define TSTR(x) KERN_DEBUG x
136 #define TOUT(p) printk p
139 #elif defined CONFIG_YAFFS_DIRECT
149 #define YMALLOC(x) malloc(x)
150 #define YFREE(x) free(x)
153 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
154 //#define YALERT(s) YINFO(s)
159 #define TOUT(p) printf p
162 #define YAFFS_LOSTNFOUND_NAME "lost+found"
163 #define YAFFS_LOSTNFOUND_PREFIX "obj"
164 //#define YPRINTF(x) printf x
166 #include "yaffscfg.h"
168 #define CURRENT_TIME yaffsfs_CurrentTime()
169 #define YAFFS_ROOT_MODE 0666
170 #define YAFFS_LOSTNFOUND_MODE 0666
172 #define yaffs_SumCompare(x,y) ((x) == (y))
174 #define YUCHAR unsigned char
176 #define yaffs_toupper(a) toupper(a)
177 #define yaffs_strcmp(a,b) strcmp(a,b)
178 #define yaffs_strcpy(a,b) strcpy(a,b)
179 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
180 #define yaffs_strlen(s) strlen(s)
181 #define yaffs_sprintf sprintf
183 #elif defined CONFIG_YAFFS_UTIL
185 // Stuff for YAFFS utilities
191 #define YMALLOC(x) malloc(x)
192 #define YFREE(x) free(x)
197 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
198 //#define YALERT(s) YINFO(s)
203 #define TOUT(p) printf p
206 #define YAFFS_LOSTNFOUND_NAME "lost+found"
207 #define YAFFS_LOSTNFOUND_PREFIX "obj"
208 //#define YPRINTF(x) printf x
211 #define CURRENT_TIME 0
212 #define YAFFS_ROOT_MODE 0666
213 #define YAFFS_LOSTNFOUND_MODE 0666
215 #define yaffs_SumCompare(x,y) ((x) == (y))
217 #define YUCHAR unsigned char
219 #define yaffs_toupper(a) toupper(a)
220 #define yaffs_strcmp(a,b) strcmp(a,b)
221 #define yaffs_strcpy(a,b) strcpy(a,b)
222 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
223 #define yaffs_strlen(s) strlen(s)
224 #define yaffs_sprintf sprintf
227 // Should have specified a configuration type
228 #error Unknown configuration
233 extern unsigned yaffs_traceMask;
235 #define YAFFS_TRACE_ERROR 0x0001
236 #define YAFFS_TRACE_OS 0x0002
237 #define YAFFS_TRACE_ALLOCATE 0x0004
238 #define YAFFS_TRACE_SCAN 0x0008
239 #define YAFFS_TRACE_BAD_BLOCKS 0x0010
240 #define YAFFS_TRACE_ERASE 0x0020
241 #define YAFFS_TRACE_GC 0x0040
242 #define YAFFS_TRACE_DELETION 0x0080
243 #define YAFFS_TRACE_TRACING 0x0100
244 #define YAFFS_TRACE_ALWAYS 0x0200
245 #define YAFFS_TRACE_WRITE 0x0400
246 #define YAFFS_TRACE_BUFFERS 0x0800
247 #define YAFFS_TRACE_NANDACCESS 0x1000
248 #define YAFFS_TRACE_DELETE 0x2000
249 #define YAFFS_TRACE_GC_DETAIL 0x4000
250 #define YAFFS_TRACE_BUG 0x800000
252 #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0)
257 //#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s))
258 //#define YALERT(s) YINFO(s)
259 #ifdef CONFIG_YAFFS_WINCE
260 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: %s %d" TENDSTR),TEXT(__FILE__),__LINE__))
262 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))
270 #define YUCHAR unsigned char