2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
\r
3 * yportenv.h: Portable services used by yaffs. This is done to allow
\r
4 * simple migration from kernel space into app space for testing.
\r
6 * Copyright (C) 2002 Aleph One Ltd.
\r
7 * for Toby Churchill Ltd and Brightstar Engineering
\r
9 * Created by Charles Manning <charles@aleph1.co.uk>
\r
11 * This program is free software; you can redistribute it and/or modify
\r
12 * it under the terms of the GNU Lesser General Public License version 2.1 as
\r
13 * published by the Free Software Foundation.
\r
16 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
\r
18 * $Id: yportenv.h,v 1.1 2004-11-03 08:14:07 charles Exp $
\r
22 #ifndef __YPORTENV_H__
\r
23 #define __YPORTENV_H__
\r
26 #if defined CONFIG_YAFFS_WINCE
\r
28 // CONFIG_YAFFS_WINCE
\r
33 #define CONFIG_YAFFS_CASE_INSENSITIVE
\r
34 #define CONFIG_YAFFS_UNICODE
\r
36 #define YMALLOC(x) malloc(x)
\r
37 #define YFREE(x) free(x)
\r
40 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
\r
41 #define YALERT(s) YINFO(s)
\r
43 #include <windows.h>
\r
45 #define YPRINTF(x) RETAILMSG(1,x)
\r
47 // Always pass the sum compare to overcome the case insensitivity issue
\r
48 #define yaffs_SumCompare(x,y) ((x) == (y))
\r
50 #ifdef CONFIG_YAFFS_UNICODE
\r
52 #define YUCHAR WCHAR
\r
54 #define yaffs_toupper(a) towupper(a)
\r
55 #define yaffs_strcmp(a,b) _wcsicmp(a,b)
\r
56 #define yaffs_strcpy(a,b) wcscpy(a,b)
\r
57 #define yaffs_strncpy(a,b,c) wcsncpy(a,b,c)
\r
58 #define yaffs_strlen(s) wcslen(s)
\r
59 #define yaffs_sprintf swprintf
\r
62 #define YUCHAR UCHAR
\r
64 #define yaffs_toupper(a) toupper(a)
\r
65 #define yaffs_strcmp(a,b) _stricmp(a,b)
\r
66 #define yaffs_strcpy(a,b) strcpy(a,b)
\r
67 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
\r
68 #define yaffs_strlen(s) strlen(s)
\r
69 #define yaffs_sprintf sprintf
\r
72 #define YAFFS_LOSTNFOUND_NAME _Y("Lost Clusters")
\r
73 #define YAFFS_LOSTNFOUND_PREFIX _Y("OBJ")
\r
76 #define u_char unsigned char
\r
78 #define S_IFDIR 04000
\r
80 #define S_ISFIFO(x) 0
\r
81 #define S_ISCHR(x) 0
\r
82 #define S_ISBLK(x) 0
\r
83 #define S_ISSOCK(x) 0
\r
85 extern unsigned yfsd_U32FileTimeNow(void);
\r
87 #define CURRENT_TIME yfsd_U32FileTimeNow()
\r
88 #define YAFFS_ROOT_MODE FILE_ATTRIBUTE_ARCHIVE
\r
89 #define YAFFS_LOSTNFOUND_MODE FILE_ATTRIBUTE_HIDDEN
\r
92 #define TENDSTR L"\r\n"
\r
93 #define TSTR(x) TEXT(x)
\r
94 #define TOUT(x) RETAILMSG(1, x)
\r
97 #elif defined __KERNEL__
\r
102 #include "linux/kernel.h"
\r
103 #include "linux/mm.h"
\r
104 #include "linux/string.h"
\r
105 #include "linux/slab.h"
\r
108 #define YAFFS_LOSTNFOUND_NAME "lost+found"
\r
109 #define YAFFS_LOSTNFOUND_PREFIX "obj"
\r
111 //#define YPRINTF(x) printk x
\r
112 #define YMALLOC(x) kmalloc(x,GFP_KERNEL)
\r
113 #define YFREE(x) kfree(x)
\r
115 #define YAFFS_ROOT_MODE 0666
\r
116 #define YAFFS_LOSTNFOUND_MODE 0666
\r
119 #define yaffs_SumCompare(x,y) ((x) == (y))
\r
121 #define YUCHAR unsigned char
\r
123 #define yaffs_toupper(a) toupper(a)
\r
124 #define yaffs_strcmp(a,b) strcmp(a,b)
\r
125 #define yaffs_strcpy(a,b) strcpy(a,b)
\r
126 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
\r
127 #define yaffs_strlen(s) strlen(s)
\r
128 #define yaffs_sprintf sprintf
\r
130 #define TENDSTR "\n"
\r
131 #define TSTR(x) KERN_DEBUG x
\r
132 #define TOUT(p) printk p
\r
135 #elif defined CONFIG_YAFFS_DIRECT
\r
137 // Direct interface
\r
139 #include "stdlib.h"
\r
141 #include "string.h"
\r
143 #define YMALLOC(x) malloc(x)
\r
144 #define YFREE(x) free(x)
\r
147 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
\r
148 //#define YALERT(s) YINFO(s)
\r
151 #define TENDSTR "\n"
\r
153 #define TOUT(p) printf p
\r
156 #define YAFFS_LOSTNFOUND_NAME "lost+found"
\r
157 #define YAFFS_LOSTNFOUND_PREFIX "obj"
\r
158 //#define YPRINTF(x) printf x
\r
160 #include "yaffscfg.h"
\r
162 #define CURRENT_TIME yaffsfs_CurrentTime()
\r
163 #define YAFFS_ROOT_MODE 0666
\r
164 #define YAFFS_LOSTNFOUND_MODE 0666
\r
166 #define yaffs_SumCompare(x,y) ((x) == (y))
\r
168 #define YUCHAR unsigned char
\r
170 #define yaffs_toupper(a) toupper(a)
\r
171 #define yaffs_strcmp(a,b) strcmp(a,b)
\r
172 #define yaffs_strcpy(a,b) strcpy(a,b)
\r
173 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
\r
174 #define yaffs_strlen(s) strlen(s)
\r
175 #define yaffs_sprintf sprintf
\r
177 #elif defined CONFIG_YAFFS_UTIL
\r
179 // Stuff for YAFFS utilities
\r
181 #include "stdlib.h"
\r
183 #include "string.h"
\r
185 #define YMALLOC(x) malloc(x)
\r
186 #define YFREE(x) free(x)
\r
189 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
\r
190 //#define YALERT(s) YINFO(s)
\r
193 #define TENDSTR "\n"
\r
195 #define TOUT(p) printf p
\r
198 #define YAFFS_LOSTNFOUND_NAME "lost+found"
\r
199 #define YAFFS_LOSTNFOUND_PREFIX "obj"
\r
200 //#define YPRINTF(x) printf x
\r
203 #define CURRENT_TIME 0
\r
204 #define YAFFS_ROOT_MODE 0666
\r
205 #define YAFFS_LOSTNFOUND_MODE 0666
\r
207 #define yaffs_SumCompare(x,y) ((x) == (y))
\r
209 #define YUCHAR unsigned char
\r
211 #define yaffs_toupper(a) toupper(a)
\r
212 #define yaffs_strcmp(a,b) strcmp(a,b)
\r
213 #define yaffs_strcpy(a,b) strcpy(a,b)
\r
214 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
\r
215 #define yaffs_strlen(s) strlen(s)
\r
216 #define yaffs_sprintf sprintf
\r
219 // Should have specified a configuration type
\r
220 #error Unknown configuration
\r
225 extern unsigned yaffs_traceMask;
\r
227 #define YAFFS_TRACE_ERROR 0x0001
\r
228 #define YAFFS_TRACE_OS 0x0002
\r
229 #define YAFFS_TRACE_ALLOCATE 0x0004
\r
230 #define YAFFS_TRACE_SCAN 0x0008
\r
231 #define YAFFS_TRACE_BAD_BLOCKS 0x0010
\r
232 #define YAFFS_TRACE_ERASE 0x0020
\r
233 #define YAFFS_TRACE_GC 0x0040
\r
234 #define YAFFS_TRACE_DELETION 0x0080
\r
235 #define YAFFS_TRACE_TRACING 0x0100
\r
236 #define YAFFS_TRACE_ALWAYS 0x0200
\r
237 #define YAFFS_TRACE_WRITE 0x0400
\r
238 #define YAFFS_TRACE_BUG 0x8000
\r
240 #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0)
\r
245 //#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s))
\r
246 //#define YALERT(s) YINFO(s)
\r
247 #ifdef CONFIG_YAFFS_WINCE
\r
248 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: %s %d" TENDSTR),TEXT(__FILE__),__LINE__))
\r
250 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))
\r