|
2
|
1 /* |
|
|
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. |
|
|
5 * |
|
|
6 * Copyright (C) 2002 Aleph One Ltd. |
|
|
7 * for Toby Churchill Ltd and Brightstar Engineering |
|
|
8 * |
|
|
9 * Created by Charles Manning <charles@aleph1.co.uk> |
|
|
10 * |
|
|
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. |
|
|
14 * |
|
|
15 * |
|
|
16 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. |
|
|
17 * |
|
|
18 * $Id: yportenv.h,v 1.2 2004-11-03 08:35:48 charles Exp $ |
|
|
19 * |
|
|
20 */ |
|
|
21 |
|
|
22 #ifndef __YPORTENV_H__ |
|
|
23 #define __YPORTENV_H__ |
|
|
24 |
|
|
25 |
|
|
26 #if defined CONFIG_YAFFS_WINCE |
|
|
27 |
|
|
28 // CONFIG_YAFFS_WINCE |
|
|
29 #include "stdlib.h" |
|
|
30 #include "stdio.h" |
|
|
31 #include "string.h" |
|
|
32 |
|
|
33 #define Y_INLINE |
|
|
34 |
|
|
35 #define CONFIG_YAFFS_CASE_INSENSITIVE |
|
|
36 #define CONFIG_YAFFS_UNICODE |
|
|
37 |
|
|
38 #define YMALLOC(x) malloc(x) |
|
|
39 #define YFREE(x) free(x) |
|
|
40 |
|
|
41 |
|
|
42 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) |
|
|
43 #define YALERT(s) YINFO(s) |
|
|
44 |
|
|
45 #include <windows.h> |
|
|
46 |
|
|
47 #define YPRINTF(x) RETAILMSG(1,x) |
|
|
48 |
|
|
49 // Always pass the sum compare to overcome the case insensitivity issue |
|
|
50 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
51 |
|
|
52 #ifdef CONFIG_YAFFS_UNICODE |
|
|
53 #define YCHAR WCHAR |
|
|
54 #define YUCHAR WCHAR |
|
|
55 #define _Y(a) L##a |
|
|
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 |
|
|
62 #else |
|
|
63 #define YCHAR CHAR |
|
|
64 #define YUCHAR UCHAR |
|
|
65 #define _Y(a) a |
|
|
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 |
|
|
72 #endif |
|
|
73 |
|
|
74 #define YAFFS_LOSTNFOUND_NAME _Y("Lost Clusters") |
|
|
75 #define YAFFS_LOSTNFOUND_PREFIX _Y("OBJ") |
|
|
76 |
|
|
77 |
|
|
78 #define u_char unsigned char |
|
|
79 #define loff_t int |
|
|
80 #define S_IFDIR 04000 |
|
|
81 |
|
|
82 #define S_ISFIFO(x) 0 |
|
|
83 #define S_ISCHR(x) 0 |
|
|
84 #define S_ISBLK(x) 0 |
|
|
85 #define S_ISSOCK(x) 0 |
|
|
86 |
|
|
87 extern unsigned yfsd_U32FileTimeNow(void); |
|
|
88 |
|
|
89 #define CURRENT_TIME yfsd_U32FileTimeNow() |
|
|
90 #define YAFFS_ROOT_MODE FILE_ATTRIBUTE_ARCHIVE |
|
|
91 #define YAFFS_LOSTNFOUND_MODE FILE_ATTRIBUTE_HIDDEN |
|
|
92 |
|
|
93 |
|
|
94 #define TENDSTR L"\r\n" |
|
|
95 #define TSTR(x) TEXT(x) |
|
|
96 #define TOUT(x) RETAILMSG(1, x) |
|
|
97 |
|
|
98 |
|
|
99 #elif defined __KERNEL__ |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 // Linux kernel |
|
|
104 #include "linux/kernel.h" |
|
|
105 #include "linux/mm.h" |
|
|
106 #include "linux/string.h" |
|
|
107 #include "linux/slab.h" |
|
|
108 |
|
|
109 #define Y_INLINE |
|
|
110 |
|
|
111 |
|
|
112 #define YAFFS_LOSTNFOUND_NAME "lost+found" |
|
|
113 #define YAFFS_LOSTNFOUND_PREFIX "obj" |
|
|
114 |
|
|
115 //#define YPRINTF(x) printk x |
|
|
116 #define YMALLOC(x) kmalloc(x,GFP_KERNEL) |
|
|
117 #define YFREE(x) kfree(x) |
|
|
118 |
|
|
119 #define YAFFS_ROOT_MODE 0666 |
|
|
120 #define YAFFS_LOSTNFOUND_MODE 0666 |
|
|
121 |
|
|
122 |
|
|
123 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
124 #define YCHAR char |
|
|
125 #define YUCHAR unsigned char |
|
|
126 #define _Y(a) a |
|
|
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 |
|
|
133 |
|
|
134 #define TENDSTR "\n" |
|
|
135 #define TSTR(x) KERN_DEBUG x |
|
|
136 #define TOUT(p) printk p |
|
|
137 |
|
|
138 |
|
|
139 #elif defined CONFIG_YAFFS_DIRECT |
|
|
140 |
|
|
141 // Direct interface |
|
|
142 |
|
|
143 #include "stdlib.h" |
|
|
144 #include "stdio.h" |
|
|
145 #include "string.h" |
|
|
146 |
|
|
147 #define Y_INLINE |
|
|
148 |
|
|
149 #define YMALLOC(x) malloc(x) |
|
|
150 #define YFREE(x) free(x) |
|
|
151 |
|
|
152 |
|
|
153 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) |
|
|
154 //#define YALERT(s) YINFO(s) |
|
|
155 |
|
|
156 |
|
|
157 #define TENDSTR "\n" |
|
|
158 #define TSTR(x) x |
|
|
159 #define TOUT(p) printf p |
|
|
160 |
|
|
161 |
|
|
162 #define YAFFS_LOSTNFOUND_NAME "lost+found" |
|
|
163 #define YAFFS_LOSTNFOUND_PREFIX "obj" |
|
|
164 //#define YPRINTF(x) printf x |
|
|
165 |
|
|
166 #include "yaffscfg.h" |
|
|
167 |
|
|
168 #define CURRENT_TIME yaffsfs_CurrentTime() |
|
|
169 #define YAFFS_ROOT_MODE 0666 |
|
|
170 #define YAFFS_LOSTNFOUND_MODE 0666 |
|
|
171 |
|
|
172 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
173 #define YCHAR char |
|
|
174 #define YUCHAR unsigned char |
|
|
175 #define _Y(a) a |
|
|
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 |
|
|
182 |
|
|
183 #elif defined CONFIG_YAFFS_UTIL |
|
|
184 |
|
|
185 // Stuff for YAFFS utilities |
|
|
186 |
|
|
187 #include "stdlib.h" |
|
|
188 #include "stdio.h" |
|
|
189 #include "string.h" |
|
|
190 |
|
|
191 #define YMALLOC(x) malloc(x) |
|
|
192 #define YFREE(x) free(x) |
|
|
193 |
|
|
194 #define Y_INLINE |
|
|
195 |
|
|
196 |
|
|
197 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) |
|
|
198 //#define YALERT(s) YINFO(s) |
|
|
199 |
|
|
200 |
|
|
201 #define TENDSTR "\n" |
|
|
202 #define TSTR(x) x |
|
|
203 #define TOUT(p) printf p |
|
|
204 |
|
|
205 |
|
|
206 #define YAFFS_LOSTNFOUND_NAME "lost+found" |
|
|
207 #define YAFFS_LOSTNFOUND_PREFIX "obj" |
|
|
208 //#define YPRINTF(x) printf x |
|
|
209 |
|
|
210 |
|
|
211 #define CURRENT_TIME 0 |
|
|
212 #define YAFFS_ROOT_MODE 0666 |
|
|
213 #define YAFFS_LOSTNFOUND_MODE 0666 |
|
|
214 |
|
|
215 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
216 #define YCHAR char |
|
|
217 #define YUCHAR unsigned char |
|
|
218 #define _Y(a) a |
|
|
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 |
|
|
225 |
|
|
226 #else |
|
|
227 // Should have specified a configuration type |
|
|
228 #error Unknown configuration |
|
|
229 |
|
|
230 #endif |
|
|
231 |
|
|
232 |
|
|
233 extern unsigned yaffs_traceMask; |
|
|
234 |
|
|
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 |
|
|
251 |
|
|
252 #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0) |
|
|
253 |
|
|
254 //#undef YINFO |
|
|
255 |
|
|
256 |
|
|
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__)) |
|
|
261 #else |
|
|
262 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__)) |
|
|
263 #endif |
|
|
264 |
|
|
265 #ifndef YCHAR |
|
|
266 #define YCHAR char |
|
|
267 #endif |
|
|
268 |
|
|
269 #ifndef YUCHAR |
|
|
270 #define YUCHAR unsigned char |
|
|
271 #endif |
|
|
272 |
|
|
273 #endif |