OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [fs/] [jffs2/] [v2_0/] [src/] [os-ecos.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
/*
2
 * JFFS2 -- Journalling Flash File System, Version 2.
3
 *
4
 * Copyright (C) 2002 Red Hat, Inc.
5
 *
6
 * Created by David Woodhouse <dwmw2@cambridge.redhat.com>
7
 *
8
 * For licensing information, see the file 'LICENCE' in this directory.
9
 *
10
 * $Id: os-ecos.h,v 1.1.1.1 2004-02-14 13:29:18 phoenix Exp $
11
 *
12
 */
13
 
14
#ifndef __JFFS2_OS_ECOS_H__
15
#define __JFFS2_OS_ECOS_H__
16
 
17
#include <cyg/io/io.h>
18
#include <sys/types.h>
19
#include <asm/atomic.h>
20
#include <linux/stat.h>
21
#include "jffs2port.h"
22
 
23
#define CONFIG_JFFS2_FS_DEBUG 0
24
 
25
static inline uint32_t os_to_jffs2_mode(uint32_t osmode)
26
{
27
        uint32_t jmode = ((osmode & S_IRUSR)?00400:0) |
28
                ((osmode & S_IWUSR)?00200:0) |
29
                ((osmode & S_IXUSR)?00100:0) |
30
                ((osmode & S_IRGRP)?00040:0) |
31
                ((osmode & S_IWGRP)?00020:0) |
32
                ((osmode & S_IXGRP)?00010:0) |
33
                ((osmode & S_IROTH)?00004:0) |
34
                ((osmode & S_IWOTH)?00002:0) |
35
                ((osmode & S_IXOTH)?00001:0);
36
 
37
        switch (osmode & S_IFMT) {
38
        case S_IFSOCK:
39
                return jmode | 0140000;
40
        case S_IFLNK:
41
                return jmode | 0120000;
42
        case S_IFREG:
43
                return jmode | 0100000;
44
        case S_IFBLK:
45
                return jmode | 0060000;
46
        case S_IFDIR:
47
                return jmode | 0040000;
48
        case S_IFCHR:
49
                return jmode | 0020000;
50
        case S_IFIFO:
51
                return jmode | 0010000;
52
        case S_ISUID:
53
                return jmode | 0004000;
54
        case S_ISGID:
55
                return jmode | 0002000;
56
#ifdef S_ISVTX
57
        case S_ISVTX:
58
                return jmode | 0001000;
59
#endif
60
        }
61
        printf("os_to_jffs2_mode() cannot convert 0x%x\n", osmode);
62
        BUG();
63
        return 0;
64
}
65
 
66
static inline uint32_t jffs2_to_os_mode (uint32_t jmode)
67
{
68
        uint32_t osmode = ((jmode & 00400)?S_IRUSR:0) |
69
                ((jmode & 00200)?S_IWUSR:0) |
70
                ((jmode & 00100)?S_IXUSR:0) |
71
                ((jmode & 00040)?S_IRGRP:0) |
72
                ((jmode & 00020)?S_IWGRP:0) |
73
                ((jmode & 00010)?S_IXGRP:0) |
74
                ((jmode & 00004)?S_IROTH:0) |
75
                ((jmode & 00002)?S_IWOTH:0) |
76
                ((jmode & 00001)?S_IXOTH:0);
77
 
78
        switch(jmode & 00170000) {
79
        case 0140000:
80
                return osmode | S_IFSOCK;
81
        case 0120000:
82
                return osmode | S_IFLNK;
83
        case 0100000:
84
                return osmode | S_IFREG;
85
        case 0060000:
86
                return osmode | S_IFBLK;
87
        case 0040000:
88
                return osmode | S_IFDIR;
89
        case 0020000:
90
                return osmode | S_IFCHR;
91
        case 0010000:
92
                return osmode | S_IFIFO;
93
        case 0004000:
94
                return osmode | S_ISUID;
95
        case 0002000:
96
                return osmode | S_ISGID;
97
#ifdef S_ISVTX
98
        case 0001000:
99
                return osmode | S_ISVTX;
100
#endif
101
        }
102
        printf("jffs2_to_os_mode() cannot convert 0x%x\n", osmode);
103
        BUG();
104
        return 0;
105
}
106
 
107
 /* Read-only operation not currently implemented on eCos */
108
#define jffs2_is_readonly(c) (0)
109
 
110
/* NAND flash not currently supported on eCos */
111
#define jffs2_can_mark_obsolete(c) (1)
112
 
113
#define JFFS2_INODE_INFO(i) (&(i)->jffs2_i)
114
#define OFNI_EDONI_2SFFJ(f)  ((struct inode *) ( ((char *)f) - ((char *)(&((struct inode *)NULL)->jffs2_i)) ) )
115
 
116
#define JFFS2_F_I_SIZE(f) (OFNI_EDONI_2SFFJ(f)->i_size)
117
#define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode)
118
#define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid)
119
#define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid)
120
#define JFFS2_F_I_CTIME(f) (OFNI_EDONI_2SFFJ(f)->i_ctime)
121
#define JFFS2_F_I_MTIME(f) (OFNI_EDONI_2SFFJ(f)->i_mtime)
122
#define JFFS2_F_I_ATIME(f) (OFNI_EDONI_2SFFJ(f)->i_atime)
123
 
124
/* FIXME: eCos doesn't hav a concept of device major/minor numbers */
125
#define JFFS2_F_I_RDEV_MIN(f) (MINOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
126
#define JFFS2_F_I_RDEV_MAJ(f) (MAJOR(to_kdev_t(OFNI_EDONI_2SFFJ(f)->i_rdev)))
127
 
128
 
129
//#define ITIME(sec) (sec)
130
//#define I_SEC(x) (x)
131
#define get_seconds cyg_timestamp
132
 
133
struct inode {
134
        //struct list_head      i_hash;
135
        //struct list_head      i_list;
136
        struct list_head        i_dentry;
137
 
138
        cyg_uint32              i_ino;
139
        atomic_t                i_count;
140
        //kdev_t                        i_dev;
141
        mode_t                  i_mode;
142
        nlink_t                 i_nlink;
143
        uid_t                   i_uid;
144
        gid_t                   i_gid;
145
        kdev_t                  i_rdev;
146
        off_t                   i_size;
147
        time_t                  i_atime;
148
        time_t                  i_mtime;
149
        time_t                  i_ctime;
150
        unsigned long           i_blksize;
151
        unsigned long           i_blocks;
152
        //unsigned long         i_version;
153
        //struct semaphore      i_sem;
154
        //struct semaphore      i_zombie;
155
        struct inode_operations *i_op;
156
        struct file_operations  *i_fop; // former ->i_op->default_file_ops 
157
        struct super_block      *i_sb;
158
        //wait_queue_head_t     i_wait;
159
        //struct file_lock      *i_flock;
160
        //struct address_space  *i_mapping;
161
        //struct address_space  i_data; 
162
        //struct dquot          *i_dquot[MAXQUOTAS];
163
        //struct pipe_inode_info        *i_pipe;
164
        //struct block_device   *i_bdev;
165
 
166
        //unsigned long         i_state;
167
 
168
        unsigned int            i_flags;
169
        //unsigned char         i_sock;
170
 
171
        atomic_t                i_writecount;
172
        //unsigned int          i_attr_flags;
173
        //uint32_t                      i_generation;
174
        struct jffs2_inode_info jffs2_i;
175
 
176
        struct inode *i_parent;
177
 
178
        struct inode *i_cache_prev;
179
        struct inode *i_cache_next;
180
};
181
 
182
#define JFFS2_SB_INFO(sb) (&(sb)->jffs2_sb)
183
 
184
#define OFNI_BS_2SFFJ(c)  ((struct super_block *) ( ((char *)c) - ((char *)(&((struct super_block *)NULL)->jffs2_sb)) ) )
185
 
186
struct super_block {
187
        unsigned long           s_blocksize;
188
        unsigned char           s_blocksize_bits;
189
        unsigned char           s_dirt;
190
        //struct super_operations       *s_op;
191
        unsigned long           s_flags;
192
        unsigned long           s_magic;
193
        //struct dentry         *s_root;
194
        struct inode            *s_root;
195
        struct jffs2_sb_info jffs2_sb;
196
        unsigned long       s_mount_count;
197
    cyg_io_handle_t     s_dev;
198
};
199
 
200
#define sleep_on_spinunlock(wq, sl) do { ; } while(0)
201
#define EBADFD 32767
202
 
203
/* background.c */
204
static inline void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c)
205
{
206
        /* We don't have a GC thread in eCos (yet) */
207
}
208
 
209
/* dir.c */
210
extern struct file_operations jffs2_dir_operations;
211
extern struct inode_operations jffs2_dir_inode_operations;
212
 
213
/* file.c */
214
extern struct file_operations jffs2_file_operations;
215
extern struct inode_operations jffs2_file_inode_operations;
216
extern struct address_space_operations jffs2_file_address_operations;
217
int jffs2_null_fsync(struct file *, struct dentry *, int);
218
int jffs2_setattr (struct dentry *dentry, struct iattr *iattr);
219
int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg);
220
int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg);
221
//int jffs2_readpage (struct file *, struct page *);
222
int jffs2_readpage (struct inode *d_inode, struct page *pg);
223
//int jffs2_prepare_write (struct file *, struct page *, unsigned, unsigned);
224
int jffs2_prepare_write (struct inode *d_inode, struct page *pg, unsigned start, unsigned end);
225
//int jffs2_commit_write (struct file *, struct page *, unsigned, unsigned);
226
int jffs2_commit_write (struct inode *d_inode, struct page *pg, unsigned start, unsigned end);
227
 
228
#ifndef CONFIG_JFFS2_FS_NAND
229
#define jffs2_can_mark_obsolete(c) (1)
230
#define jffs2_cleanmarker_oob(c) (0)
231
#define jffs2_write_nand_cleanmarker(c,jeb) (-EIO)
232
 
233
#define jffs2_flush_wbuf(c, flag) do { ; } while(0)
234
#define jffs2_nand_read_failcnt(c,jeb) do { ; } while(0)
235
#define jffs2_write_nand_badblock(c,jeb) do { ; } while(0)
236
#define jffs2_flash_writev jffs2_flash_writev
237
#define jffs2_wbuf_timeout NULL
238
#define jffs2_wbuf_process NULL
239
#else
240
#error no nand yet
241
#endif
242
struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri);
243
void jffs2_clear_inode (struct inode *inode);
244
void jffs2_read_inode (struct inode *inode);
245
 
246
static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
247
{
248
        memset(f, 0, sizeof(*f));
249
        init_MUTEX_LOCKED(&f->sem);
250
}
251
 
252
#endif /* __JFFS2_OS_ECOS_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.