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.6 2002-11-08 07:19:42 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 YMALLOC(x) malloc(x)
\r
34 #define YFREE(x) free(x)
\r
37 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
\r
38 #define YALERT(s) YINFO(s)
\r
40 #include <windows.h>
\r
42 #define YAFFS_LOSTNFOUND_NAME "Lost Clusters"
\r
43 #define YAFFS_LOSTNFOUND_PREFIX "OBJ"
\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
52 #define u_char unsigned char
\r
54 #define S_IFDIR 04000
\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
61 extern unsigned yfsd_U32FileTimeNow(void);
\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
68 #define TENDSTR L"\r\n"
\r
69 #define TSTR(x) TEXT(x)
\r
70 #define TOUT(x) RETAILMSG(1, x)
\r
73 #elif defined __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
84 #define YAFFS_LOSTNFOUND_NAME "lost+found"
\r
85 #define YAFFS_LOSTNFOUND_PREFIX "obj"
\r
87 //#define YPRINTF(x) printk x
\r
88 #define YMALLOC(x) kmalloc(x,GFP_KERNEL)
\r
89 #define YFREE(x) kfree(x)
\r
91 #define YAFFS_ROOT_MODE 0666
\r
92 #define YAFFS_LOSTNFOUND_MODE 0666
\r
95 #define yaffs_SumCompare(x,y) ((x) == (y))
\r
96 #define yaffs_strcmp(a,b) strcmp(a,b)
\r
98 #define TENDSTR "\n"
\r
99 #define TSTR(x) KERN_DEBUG x
\r
100 #define TOUT(p) printk p
\r
105 // Linux application
\r
106 #include "stdlib.h"
\r
108 #include "string.h"
\r
110 #define YMALLOC(x) malloc(x)
\r
111 #define YFREE(x) free(x)
\r
114 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
\r
115 //#define YALERT(s) YINFO(s)
\r
118 #define TENDSTR "\n"
\r
120 #define TOUT(p) printf p
\r
123 #define YAFFS_LOSTNFOUND_NAME "lost+found"
\r
124 #define YAFFS_LOSTNFOUND_PREFIX "obj"
\r
125 //#define YPRINTF(x) printf x
\r
127 #define CURRENT_TIME 0
\r
128 #define YAFFS_ROOT_MODE 0666
\r
129 #define YAFFS_LOSTNFOUND_MODE 0666
\r
131 #define yaffs_SumCompare(x,y) ((x) == (y))
\r
132 #define yaffs_strcmp(a,b) strcmp(a,b)
\r
137 extern unsigned yaffs_traceMask;
\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
149 #define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ERROR)) TOUT(p);} while(0)
\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
159 #define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))
\r