|
0
|
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.1 2004-11-03 08:14:07 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 CONFIG_YAFFS_CASE_INSENSITIVE |
|
|
34 #define CONFIG_YAFFS_UNICODE |
|
|
35 |
|
|
36 #define YMALLOC(x) malloc(x) |
|
|
37 #define YFREE(x) free(x) |
|
|
38 |
|
|
39 |
|
|
40 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) |
|
|
41 #define YALERT(s) YINFO(s) |
|
|
42 |
|
|
43 #include <windows.h> |
|
|
44 |
|
|
45 #define YPRINTF(x) RETAILMSG(1,x) |
|
|
46 |
|
|
47 // Always pass the sum compare to overcome the case insensitivity issue |
|
|
48 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
49 |
|
|
50 #ifdef CONFIG_YAFFS_UNICODE |
|
|
51 #define YCHAR WCHAR |
|
|
52 #define YUCHAR WCHAR |
|
|
53 #define _Y(a) L##a |
|
|
54 #define yaffs_toupper(a) towupper(a) |
|
|
55 #define yaffs_strcmp(a,b) _wcsicmp(a,b) |
|
|
56 #define yaffs_strcpy(a,b) wcscpy(a,b) |
|
|
57 #define yaffs_strncpy(a,b,c) wcsncpy(a,b,c) |
|
|
58 #define yaffs_strlen(s) wcslen(s) |
|
|
59 #define yaffs_sprintf swprintf |
|
|
60 #else |
|
|
61 #define YCHAR CHAR |
|
|
62 #define YUCHAR UCHAR |
|
|
63 #define _Y(a) a |
|
|
64 #define yaffs_toupper(a) toupper(a) |
|
|
65 #define yaffs_strcmp(a,b) _stricmp(a,b) |
|
|
66 #define yaffs_strcpy(a,b) strcpy(a,b) |
|
|
67 #define yaffs_strncpy(a,b,c) strncpy(a,b,c) |
|
|
68 #define yaffs_strlen(s) strlen(s) |
|
|
69 #define yaffs_sprintf sprintf |
|
|
70 #endif |
|
|
71 |
|
|
72 #define YAFFS_LOSTNFOUND_NAME _Y("Lost Clusters") |
|
|
73 #define YAFFS_LOSTNFOUND_PREFIX _Y("OBJ") |
|
|
74 |
|
|
75 |
|
|
76 #define u_char unsigned char |
|
|
77 #define loff_t int |
|
|
78 #define S_IFDIR 04000 |
|
|
79 |
|
|
80 #define S_ISFIFO(x) 0 |
|
|
81 #define S_ISCHR(x) 0 |
|
|
82 #define S_ISBLK(x) 0 |
|
|
83 #define S_ISSOCK(x) 0 |
|
|
84 |
|
|
85 extern unsigned yfsd_U32FileTimeNow(void); |
|
|
86 |
|
|
87 #define CURRENT_TIME yfsd_U32FileTimeNow() |
|
|
88 #define YAFFS_ROOT_MODE FILE_ATTRIBUTE_ARCHIVE |
|
|
89 #define YAFFS_LOSTNFOUND_MODE FILE_ATTRIBUTE_HIDDEN |
|
|
90 |
|
|
91 |
|
|
92 #define TENDSTR L"\r\n" |
|
|
93 #define TSTR(x) TEXT(x) |
|
|
94 #define TOUT(x) RETAILMSG(1, x) |
|
|
95 |
|
|
96 |
|
|
97 #elif defined __KERNEL__ |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 // Linux kernel |
|
|
102 #include "linux/kernel.h" |
|
|
103 #include "linux/mm.h" |
|
|
104 #include "linux/string.h" |
|
|
105 #include "linux/slab.h" |
|
|
106 |
|
|
107 |
|
|
108 #define YAFFS_LOSTNFOUND_NAME "lost+found" |
|
|
109 #define YAFFS_LOSTNFOUND_PREFIX "obj" |
|
|
110 |
|
|
111 //#define YPRINTF(x) printk x |
|
|
112 #define YMALLOC(x) kmalloc(x,GFP_KERNEL) |
|
|
113 #define YFREE(x) kfree(x) |
|
|
114 |
|
|
115 #define YAFFS_ROOT_MODE 0666 |
|
|
116 #define YAFFS_LOSTNFOUND_MODE 0666 |
|
|
117 |
|
|
118 |
|
|
119 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
120 #define YCHAR char |
|
|
121 #define YUCHAR unsigned char |
|
|
122 #define _Y(a) a |
|
|
123 #define yaffs_toupper(a) toupper(a) |
|
|
124 #define yaffs_strcmp(a,b) strcmp(a,b) |
|
|
125 #define yaffs_strcpy(a,b) strcpy(a,b) |
|
|
126 #define yaffs_strncpy(a,b,c) strncpy(a,b,c) |
|
|
127 #define yaffs_strlen(s) strlen(s) |
|
|
128 #define yaffs_sprintf sprintf |
|
|
129 |
|
|
130 #define TENDSTR "\n" |
|
|
131 #define TSTR(x) KERN_DEBUG x |
|
|
132 #define TOUT(p) printk p |
|
|
133 |
|
|
134 |
|
|
135 #elif defined CONFIG_YAFFS_DIRECT |
|
|
136 |
|
|
137 // Direct interface |
|
|
138 |
|
|
139 #include "stdlib.h" |
|
|
140 #include "stdio.h" |
|
|
141 #include "string.h" |
|
|
142 |
|
|
143 #define YMALLOC(x) malloc(x) |
|
|
144 #define YFREE(x) free(x) |
|
|
145 |
|
|
146 |
|
|
147 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) |
|
|
148 //#define YALERT(s) YINFO(s) |
|
|
149 |
|
|
150 |
|
|
151 #define TENDSTR "\n" |
|
|
152 #define TSTR(x) x |
|
|
153 #define TOUT(p) printf p |
|
|
154 |
|
|
155 |
|
|
156 #define YAFFS_LOSTNFOUND_NAME "lost+found" |
|
|
157 #define YAFFS_LOSTNFOUND_PREFIX "obj" |
|
|
158 //#define YPRINTF(x) printf x |
|
|
159 |
|
|
160 #include "yaffscfg.h" |
|
|
161 |
|
|
162 #define CURRENT_TIME yaffsfs_CurrentTime() |
|
|
163 #define YAFFS_ROOT_MODE 0666 |
|
|
164 #define YAFFS_LOSTNFOUND_MODE 0666 |
|
|
165 |
|
|
166 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
167 #define YCHAR char |
|
|
168 #define YUCHAR unsigned char |
|
|
169 #define _Y(a) a |
|
|
170 #define yaffs_toupper(a) toupper(a) |
|
|
171 #define yaffs_strcmp(a,b) strcmp(a,b) |
|
|
172 #define yaffs_strcpy(a,b) strcpy(a,b) |
|
|
173 #define yaffs_strncpy(a,b,c) strncpy(a,b,c) |
|
|
174 #define yaffs_strlen(s) strlen(s) |
|
|
175 #define yaffs_sprintf sprintf |
|
|
176 |
|
|
177 #elif defined CONFIG_YAFFS_UTIL |
|
|
178 |
|
|
179 // Stuff for YAFFS utilities |
|
|
180 |
|
|
181 #include "stdlib.h" |
|
|
182 #include "stdio.h" |
|
|
183 #include "string.h" |
|
|
184 |
|
|
185 #define YMALLOC(x) malloc(x) |
|
|
186 #define YFREE(x) free(x) |
|
|
187 |
|
|
188 |
|
|
189 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) |
|
|
190 //#define YALERT(s) YINFO(s) |
|
|
191 |
|
|
192 |
|
|
193 #define TENDSTR "\n" |
|
|
194 #define TSTR(x) x |
|
|
195 #define TOUT(p) printf p |
|
|
196 |
|
|
197 |
|
|
198 #define YAFFS_LOSTNFOUND_NAME "lost+found" |
|
|
199 #define YAFFS_LOSTNFOUND_PREFIX "obj" |
|
|
200 //#define YPRINTF(x) printf x |
|
|
201 |
|
|
202 |
|
|
203 #define CURRENT_TIME 0 |
|
|
204 #define YAFFS_ROOT_MODE 0666 |
|
|
205 #define YAFFS_LOSTNFOUND_MODE 0666 |
|
|
206 |
|
|
207 #define yaffs_SumCompare(x,y) ((x) == (y)) |
|
|
208 #define YCHAR char |
|
|
209 #define YUCHAR unsigned char |
|
|
210 #define _Y(a) a |
|
|
211 #define yaffs_toupper(a) toupper(a) |
|
|
212 #define yaffs_strcmp(a,b) strcmp(a,b) |
|
|
213 #define yaffs_strcpy(a,b) strcpy(a,b) |
|
|
214 #define yaffs_strncpy(a,b,c) strncpy(a,b,c) |
|
|
215 #define yaffs_strlen(s) strlen(s) |
|
|
216 #define yaffs_sprintf sprintf |
|
|
217 |
|
|
218 #else |
|
|
219 // Should have specified a configuration type |
|
|
220 #error Unknown configuration |
|
|
221 |
|
|
222 #endif |
|
|
223 |
|
|
224 |
|
|
225 extern unsigned yaffs_traceMask; |
|
|
226 |
|
|
227 #define YAFFS_TRACE_ERROR 0x0001 |
|
|
228 #define YAFFS_TRACE_OS 0x0002 |
|
|
229 #define YAFFS_TRACE_ALLOCATE 0x0004 |
|
|
230 #define YAFFS_TRACE_SCAN 0x0008 |
|
|
231 #define YAFFS_TRACE_BAD_BLOCKS 0x0010 |
|
|
232 #define YAFFS_TRACE_ERASE 0x0020 |
|
|
233 #define YAFFS_TRACE_GC 0x0040 |
|
|
234 #define YAFFS_TRACE_DELETION 0x0080 |
|
|
235 #define YAFFS_TRACE_TRACING 0x0100 |
|
|
236 #define YAFFS_TRACE_ALWAYS 0x0200 |
|
|
237 #define YAFFS_TRACE_WRITE 0x0400 |
|
|
238 #define YAFFS_TRACE_BUG 0x8000 |
|
|
239 |
|
|
240 #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0) |
|
|
241 |
|
|
242 //#undef YINFO |
|
|
243 |
|
|
244 |
|
|
245 //#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s)) |
|
|
246 //#define YALERT(s) YINFO(s) |
|
|
247 #ifdef CONFIG_YAFFS_WINCE |
|
|
248 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: %s %d" TENDSTR),TEXT(__FILE__),__LINE__)) |
|
|
249 #else |
|
|
250 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__)) |
|
|
251 #endif |
|
|
252 #endif |