comparison packages/fs/yaffs/current/src/ecos-yport.h @ 428:a386ed10401a ecos

Drop in eCos bridge work
author Ross Younger <wry@ecoscentric.com>
date Fri, 14 May 2010 17:01:32 +0100
parents
children
comparison
equal deleted inserted replaced
427:d52e3cced121 428:a386ed10401a
1 #ifndef CYGONCE_FS_ECOS_YPORT_H
2 #define CYGONCE_FS_ECOS_YPORT_H
3 //=============================================================================
4 //
5 // ecos-yport.h
6 //
7 // eCos porting layer for YAFFS
8 //
9 //=============================================================================
10 // ####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 2009 eCosCentric Limited.
14 //
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later
18 // version.
19 //
20 // eCos is distributed in the hope that it will be useful, but WITHOUT
21 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 // for more details.
24 //
25 // You should have received a copy of the GNU General Public License
26 // along with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 //
29 // As a special exception, if other files instantiate templates or use
30 // macros or inline functions from this file, or you compile this file
31 // and link it with other works to produce a work based on this file,
32 // this file does not by itself cause the resulting work to be covered by
33 // the GNU General Public License. However the source code for this file
34 // must still be made available in accordance with section (3) of the GNU
35 // General Public License v2.
36 //
37 // This exception does not invalidate any other reasons why a work based
38 // on this file might be covered by the GNU General Public License.
39 // -------------------------------------------
40 // ####ECOSGPLCOPYRIGHTEND####
41 //=============================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s): wry
45 // Date: 2009-05-05
46 //
47 //####DESCRIPTIONEND####
48 //=============================================================================
49
50 #include "ecos-yaffs.h"
51
52 #include "devextras.h"
53
54 #include <stdlib.h>
55 #include <stdio.h>
56 #include <string.h>
57 #include <ctype.h>
58
59 #include <cyg/infra/cyg_ass.h>
60 #include <cyg/infra/diag.h>
61 #include <cyg/infra/cyg_type.h>
62
63 #define YCHAR char
64 #define YUCHAR unsigned char
65 #define _Y(x) x
66 #define yaffs_strcat(a,b) strcat(a,b)
67 #define yaffs_strcpy(a,b) strcpy(a,b)
68 #define yaffs_strncpy(a,b,c) strncpy(a,b,c)
69 #define yaffs_strncmp(a,b,c) strncmp(a,b,c)
70 #define yaffs_strlen(s) strlen(s)
71 #define yaffs_sprintf sprintf
72 #define yaffs_toupper(a) toupper(a)
73
74 #define YAFFS_PATH_DIVIDERS "/"
75
76 #define Y_INLINE inline
77
78 #define YMALLOC(x) malloc(x)
79 #define YFREE(x) free(x)
80 #define YMALLOC_ALT(x) malloc(x)
81 #define YFREE_ALT(x) free(x)
82
83 #define YMALLOC_DMA(x) YMALLOC(x)
84
85 #ifdef CYGFUN_KERNEL_API_C
86 #include <cyg/kernel/kapi.h>
87 #define YYIELD() do { cyg_thread_yield(); } while(0)
88 #else
89 #define YYIELD() do {} while(0)
90 #endif
91
92
93 //#define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))
94 //#define YALERT(s) YINFO(s)
95 #define YBUG() do { cyg_assert_fail(__PRETTY_FUNCTION__, __FILE__, __LINE__, "==>> yaffs bug detected"); } while(0)
96
97 #define TENDSTR "\n"
98 #define TSTR(x) x
99 #define TCONT(x) x
100 #ifdef CYGSEM_FS_YAFFS_TRACEFN
101 externC int CYGSEM_FS_YAFFS_TRACEFN (const char *fmt, ...) CYGBLD_ATTRIB_PRINTF_FORMAT(1,2);
102 #define TOUT(p) CYGSEM_FS_YAFFS_TRACEFN p
103 #else
104 static inline int _yaffs_trace_ignore (const char *fmt, ...) CYGBLD_ATTRIB_PRINTF_FORMAT(1,2);
105 static inline int _yaffs_trace_ignore (const char *fmt, ...) { return 0; }
106 #define TOUT(p) _yaffs_trace_ignore p
107 #endif
108
109
110 #define YAFFS_LOSTNFOUND_NAME "lost+found"
111 #define YAFFS_LOSTNFOUND_PREFIX "obj"
112 //#define YPRINTF(x) printf x
113
114 #ifdef CYGPKG_LIBC_TIME
115 #define Y_CURRENT_TIME time(NULL)
116 #else
117 #define Y_CURRENT_TIME ((time_t)-1)
118 #endif
119 #define Y_TIME_CONVERT(x) (x)
120
121 // eCos defines mode bits differently to POSIX.
122 #define YAFFS_ROOT_MODE ( S_IRUSR | S_IWUSR | S_IXUSR | \
123 S_IRGRP | S_IXGRP | \
124 S_IROTH | S_IXOTH )
125 #define YAFFS_LOSTNFOUND_MODE YAFFS_ROOT_MODE
126
127 #define yaffs_SumCompare(x,y) ((x) == (y))
128 #define yaffs_strcmp(a,b) strcmp(a,b)
129
130 typedef off_t loff_t; /* This will break and should probably be removed
131 if/when we add 64-bit file support generally. */
132
133 #define yaffs_qsort qsort /* provided by eCos stdlib */
134
135 #define yaffs_strnlen(s,l) strnlen(s,l)
136
137 #endif /* CYGONCE_FS_ECOS_YPORT_H */