*** empty log message ***
[yaffs/.git] / yportenv.h
1 /*\r
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
5  *\r
6  * Copyright (C) 2002 Aleph One Ltd.\r
7  *   for Toby Churchill Ltd and Brightstar Engineering\r
8  *\r
9  * Created by Charles Manning <charles@aleph1.co.uk>\r
10  *\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
14  *\r
15  *\r
16  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.\r
17  *\r
18  * $Id: yportenv.h,v 1.6 2002-11-08 07:19:42 charles Exp $\r
19  *\r
20  */\r
21  \r
22 #ifndef __YPORTENV_H__\r
23 #define __YPORTENV_H__\r
24 \r
25 \r
26 #if defined CONFIG_YAFFS_WINCE\r
27 \r
28 // CONFIG_YAFFS_WINCE\r
29 #include "stdlib.h"\r
30 #include "stdio.h"\r
31 #include "string.h"\r
32 \r
33 #define YMALLOC(x) malloc(x)\r
34 #define YFREE(x)   free(x)\r
35 \r
36 \r
37 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))\r
38 #define YALERT(s) YINFO(s)\r
39 \r
40 #include <windows.h>\r
41 \r
42 #define YAFFS_LOSTNFOUND_NAME           "Lost Clusters"\r
43 #define YAFFS_LOSTNFOUND_PREFIX         "OBJ"\r
44 \r
45 #define YPRINTF(x)\r
46 \r
47 // Always pass the sum compare to overcome the case insensitivity issue\r
48 #define yaffs_SumCompare(x,y) ((x) == (y))\r
49 #define yaffs_strcmp(a,b) _stricmp(a,b)\r
50 \r
51 \r
52 #define u_char unsigned char\r
53 #define loff_t int\r
54 #define S_IFDIR                                         04000\r
55 \r
56 #define S_ISFIFO(x) 0\r
57 #define S_ISCHR(x) 0\r
58 #define S_ISBLK(x) 0\r
59 #define S_ISSOCK(x) 0\r
60 \r
61 extern unsigned yfsd_U32FileTimeNow(void);\r
62 \r
63 #define CURRENT_TIME                             yfsd_U32FileTimeNow()\r
64 #define YAFFS_ROOT_MODE                         FILE_ATTRIBUTE_ARCHIVE\r
65 #define YAFFS_LOSTNFOUND_MODE           FILE_ATTRIBUTE_HIDDEN\r
66 \r
67 \r
68 #define TENDSTR L"\r\n"\r
69 #define TSTR(x) TEXT(x)\r
70 #define TOUT(x) RETAILMSG(1, x)\r
71 \r
72 \r
73 #elif  defined __KERNEL__\r
74 \r
75 \r
76 \r
77 // Linux kernel\r
78 #include "linux/kernel.h"\r
79 #include "linux/mm.h"\r
80 #include "linux/string.h"\r
81 #include "linux/slab.h"\r
82 \r
83 \r
84 #define YAFFS_LOSTNFOUND_NAME           "lost+found"\r
85 #define YAFFS_LOSTNFOUND_PREFIX         "obj"\r
86 \r
87 //#define YPRINTF(x) printk x\r
88 #define YMALLOC(x) kmalloc(x,GFP_KERNEL)\r
89 #define YFREE(x)   kfree(x)\r
90 \r
91 #define YAFFS_ROOT_MODE                         0666\r
92 #define YAFFS_LOSTNFOUND_MODE           0666\r
93 \r
94 \r
95 #define yaffs_SumCompare(x,y) ((x) == (y))\r
96 #define yaffs_strcmp(a,b) strcmp(a,b)\r
97 \r
98 #define TENDSTR "\n"\r
99 #define TSTR(x) KERN_DEBUG x\r
100 #define TOUT(p) printk p\r
101 \r
102 \r
103 #else\r
104 \r
105 // Linux application\r
106 #include "stdlib.h"\r
107 #include "stdio.h"\r
108 #include "string.h"\r
109 \r
110 #define YMALLOC(x) malloc(x)\r
111 #define YFREE(x)   free(x)\r
112 \r
113 \r
114 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))\r
115 //#define YALERT(s) YINFO(s)\r
116 \r
117 \r
118 #define TENDSTR "\n"\r
119 #define TSTR(x) x\r
120 #define TOUT(p) printf p\r
121 \r
122 \r
123 #define YAFFS_LOSTNFOUND_NAME           "lost+found"\r
124 #define YAFFS_LOSTNFOUND_PREFIX         "obj"\r
125 //#define YPRINTF(x) printf x\r
126 \r
127 #define CURRENT_TIME 0\r
128 #define YAFFS_ROOT_MODE                         0666\r
129 #define YAFFS_LOSTNFOUND_MODE           0666\r
130 \r
131 #define yaffs_SumCompare(x,y) ((x) == (y))\r
132 #define yaffs_strcmp(a,b) strcmp(a,b)\r
133 \r
134 #endif \r
135 \r
136 \r
137 extern unsigned yaffs_traceMask;\r
138 \r
139 #define YAFFS_TRACE_ERROR               0x0001\r
140 #define YAFFS_TRACE_OS                  0x0002\r
141 #define YAFFS_TRACE_ALLOCATE    0x0004\r
142 #define YAFFS_TRACE_SCAN                0x0008\r
143 #define YAFFS_TRACE_BAD_BLOCKS  0x0010\r
144 #define YAFFS_TRACE_ERASE               0x0020\r
145 #define YAFFS_TRACE_TRACING             0x0100\r
146 #define YAFFS_TRACE_ALWAYS              0x0200\r
147 #define YAFFS_TRACE_BUG                 0x8000\r
148 \r
149 #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0) \r
150 \r
151 //#undef YINFO\r
152 \r
153 \r
154 //#define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s))\r
155 //#define YALERT(s) YINFO(s)\r
156 #ifdef CONFIG_YAFFS_WINCE\r
157 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: %s %d" TENDSTR),TEXT(__FILE__),__LINE__))\r
158 #else\r
159 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))\r
160 #endif\r
161 #endif\r