Ignore:
Timestamp:
Sep 12, 2013, 1:32:07 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
0282e83
Parents:
78b85286
git-author:
Sebastian Huber <sebastian.huber@…> (09/12/13 13:32:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/19/13 11:16:06)
Message:

JFFS2: Add RTEMS support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/jffs2/src/os-rtems.h

    r78b85286 r3c96bee  
    22 * JFFS2 -- Journalling Flash File System, Version 2.
    33 *
    4  * Copyright (C) 2002-2003 Free Software Foundation, Inc.
     4 * Copyright © 2002-2003 Free Software Foundation, Inc.
     5 * Copyright © 2013 embedded brains GmbH <rtems@embedded-brains.de>
    56 *
    67 * Created by David Woodhouse <dwmw2@cambridge.redhat.com>
    78 *
     9 * Port to the RTEMS by embedded brains GmbH.
     10 *
    811 * For licensing information, see the file 'LICENCE' in this directory.
    912 *
     
    1215 */
    1316
    14 #ifndef __JFFS2_OS_ECOS_H__
    15 #define __JFFS2_OS_ECOS_H__
    16 
    17 #include <pkgconf/fs_jffs2.h>
    18 #include <cyg/io/io.h>
    19 #include <sys/types.h>
     17#ifndef __JFFS2_OS_RTEMS_H__
     18#define __JFFS2_OS_RTEMS_H__
     19
    2020#include <asm/atomic.h>
     21#include <asm/bug.h>
     22#include <linux/compiler.h>
     23#include <linux/list.h>
     24#include <linux/pagemap.h>
    2125#include <linux/stat.h>
    22 #include <linux/compiler.h>
    23 
    24 #include <pkgconf/system.h>
    25 #include <pkgconf/hal.h>
    26 #include <pkgconf/io_fileio.h>
    27 
    28 #include <cyg/infra/cyg_trac.h>        // tracing macros
    29 #include <cyg/infra/cyg_ass.h>         // assertion macros
    30 
    31 #include <unistd.h>
    32 #include <sys/types.h>
     26#include <linux/types.h>
     27#include <dirent.h>
     28#include <errno.h>
    3329#include <fcntl.h>
    34 #include <sys/stat.h>
    35 #include <errno.h>
    36 #include <dirent.h>
    37 
    38 #include <stdlib.h>
    3930#include <string.h>
    40 
    41 #include <cyg/fileio/fileio.h>
    42 
    43 #include <cyg/hal/drv_api.h>
    44 #include <cyg/infra/diag.h>
    45 
    46 #include <cyg/io/flash.h>
    47 
    48 #include <linux/types.h>
    49 #include <linux/list.h>
    50 #include <asm/bug.h>
    51 
    52 #define printf diag_printf
     31#include <time.h>
     32
     33#include <rtems/jffs2.h>
     34
     35#define CONFIG_JFFS2_RTIME
     36
     37#define CONFIG_JFFS2_ZLIB
    5338
    5439struct _inode;
     
    6045};
    6146
    62 static inline unsigned int full_name_hash(const unsigned char * name, unsigned int len) {
     47static inline unsigned int full_name_hash(const unsigned char * name, size_t len) {
    6348
    6449        unsigned hash = 0;
     
    7055}
    7156
    72 #ifdef CYGOPT_FS_JFFS2_WRITE
    73 #define jffs2_is_readonly(c) (0)
    74 #else
    75 #define jffs2_is_readonly(c) (1)
    76 #endif
    77 
    78 /* NAND flash not currently supported on eCos */
     57/* NAND flash not currently supported on RTEMS */
    7958#define jffs2_can_mark_obsolete(c) (1)
    8059
    8160#define JFFS2_INODE_INFO(i) (&(i)->jffs2_i)
    8261#define OFNI_EDONI_2SFFJ(f)  ((struct _inode *) ( ((char *)f) - ((char *)(&((struct _inode *)NULL)->jffs2_i)) ) )
     62
     63#define ITIME(sec) (sec)
     64#define I_SEC(tv) (tv)
    8365 
    8466#define JFFS2_F_I_SIZE(f) (OFNI_EDONI_2SFFJ(f)->i_size)
     
    9072#define JFFS2_F_I_ATIME(f) (OFNI_EDONI_2SFFJ(f)->i_atime)
    9173
    92 /* FIXME: eCos doesn't hav a concept of device major/minor numbers */
    93 #define JFFS2_F_I_RDEV_MIN(f) ((OFNI_EDONI_2SFFJ(f)->i_rdev)&0xff)
    94 #define JFFS2_F_I_RDEV_MAJ(f) ((OFNI_EDONI_2SFFJ(f)->i_rdev)>>8)
    95 
    96 #define get_seconds cyg_timestamp
     74#define get_seconds() time(NULL)
    9775
    9876struct _inode {
     
    11391//      };
    11492        struct super_block *    i_sb;
     93        struct jffs2_full_dirent * i_fd;
    11594
    11695        struct jffs2_inode_info jffs2_i;
     
    126105        struct jffs2_sb_info    jffs2_sb;
    127106        struct _inode *         s_root;
    128         unsigned long           s_mount_count;
    129         cyg_io_handle_t         s_dev;
    130 
    131 #ifdef CYGOPT_FS_JFFS2_GCTHREAD
    132         cyg_mutex_t s_lock;             // Lock the inode cache
    133         cyg_flag_t  s_gc_thread_flags;  // Communication with the gcthread
    134         cyg_handle_t s_gc_thread_handle;
    135         cyg_thread s_gc_thread;
    136 #if (CYGNUM_JFFS2_GC_THREAD_STACK_SIZE >= CYGNUM_HAL_STACK_SIZE_MINIMUM)
    137         char s_gc_thread_stack[CYGNUM_JFFS2_GC_THREAD_STACK_SIZE];
    138 #else
    139         char s_gc_thread_stack[CYGNUM_HAL_STACK_SIZE_MINIMUM];
    140 #endif
    141        cyg_mtab_entry *mte;
    142 #endif
     107        rtems_jffs2_flash_control       *s_flash_control;
     108        rtems_jffs2_compressor_control  *s_compressor_control;
     109        bool                    s_is_readonly;
     110        unsigned char           s_gc_buffer[PAGE_CACHE_SIZE]; // Avoids malloc when user may be under memory pressure
     111        rtems_id                s_mutex;
     112        char                    s_name_buf[JFFS2_MAX_NAME_LEN];
    143113};
    144114
     
    146116#define EBADFD 32767
    147117
    148 /* background.c */
    149 #ifdef CYGOPT_FS_JFFS2_GCTHREAD
    150 void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c);
    151 void jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c);
    152 void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c);
    153 #else
     118static inline bool jffs2_is_readonly(struct jffs2_sb_info *c)
     119{
     120        struct super_block *sb = OFNI_BS_2SFFJ(c);
     121
     122        return sb->s_is_readonly;
     123}
     124
    154125static inline void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c)
    155126{
    156         /* We don't have a GC thread in eCos (yet) */
    157 }
    158 #endif
    159 
    160 /* fs-ecos.c */
     127       /* We don't have a GC thread in RTEMS (yet) */
     128}
     129
     130/* fs-rtems.c */
    161131struct _inode *jffs2_new_inode (struct _inode *dir_i, int mode, struct jffs2_raw_inode *ri);
    162132struct _inode *jffs2_iget(struct super_block *sb, cyg_uint32 ino);
     
    168138void jffs2_gc_release_page(struct jffs2_sb_info *c, unsigned char *pg, unsigned long *priv);
    169139
    170 /* Avoid polluting eCos namespace with names not starting in jffs2_ */
     140/* Avoid polluting RTEMS namespace with names not starting in jffs2_ */
    171141#define os_to_jffs2_mode(x) jffs2_from_os_mode(x)
    172 uint32_t jffs2_from_os_mode(uint32_t osmode);
    173 uint32_t jffs2_to_os_mode (uint32_t jmode);
     142static inline uint32_t jffs2_from_os_mode(uint32_t osmode)
     143{
     144  return osmode & (S_IFMT | S_IRWXU | S_IRWXG | S_IRWXO);
     145}
     146
     147static inline uint32_t jffs2_to_os_mode (uint32_t jmode)
     148{
     149  return jmode & (S_IFMT | S_IRWXU | S_IRWXG | S_IRWXO);
     150}
    174151
    175152
    176153/* flashio.c */
    177 cyg_bool jffs2_flash_read(struct jffs2_sb_info *c, cyg_uint32 read_buffer_offset,
     154int jffs2_flash_read(struct jffs2_sb_info *c, cyg_uint32 read_buffer_offset,
    178155                          const size_t size, size_t * return_size, unsigned char * write_buffer);
    179 cyg_bool jffs2_flash_write(struct jffs2_sb_info *c, cyg_uint32 write_buffer_offset,
     156int jffs2_flash_write(struct jffs2_sb_info *c, cyg_uint32 write_buffer_offset,
    180157                           const size_t size, size_t * return_size, unsigned char * read_buffer);
    181158int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct iovec *vecs,
    182159                              unsigned long count, loff_t to, size_t *retlen);
    183 cyg_bool jffs2_flash_erase(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
    184 
    185 // dir-ecos.c
    186 struct _inode *jffs2_lookup(struct _inode *dir_i, const unsigned char *name, int namelen);
    187 int jffs2_create(struct _inode *dir_i, const unsigned char *d_name, int mode, struct _inode **new_i);
    188 int jffs2_mkdir (struct _inode *dir_i, const unsigned char *d_name, int mode);
    189 int jffs2_link (struct _inode *old_d_inode, struct _inode *dir_i, const unsigned char *d_name);
    190 int jffs2_unlink(struct _inode *dir_i, struct _inode *d_inode, const unsigned char *d_name);
    191 int jffs2_rmdir (struct _inode *dir_i, struct _inode *d_inode, const unsigned char *d_name);
    192 int jffs2_rename (struct _inode *old_dir_i, struct _inode *d_inode, const unsigned char *old_d_name,
    193                   struct _inode *new_dir_i, const unsigned char *new_d_name);
     160int jffs2_flash_erase(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
     161
     162// dir-rtems.c
     163struct _inode *jffs2_lookup(struct _inode *dir_i, const unsigned char *name, size_t namelen);
     164int jffs2_create(struct _inode *dir_i, const char *d_name, size_t d_namelen, int mode);
     165int jffs2_mknod(struct _inode *dir_i, const unsigned char *d_name, size_t d_namelen, int mode, const unsigned char *data, size_t datalen);
     166int jffs2_link (struct _inode *old_d_inode, struct _inode *dir_i, const unsigned char *d_name, size_t d_namelen);
     167int jffs2_unlink(struct _inode *dir_i, struct _inode *d_inode, const unsigned char *d_name, size_t d_namelen);
     168int jffs2_rmdir (struct _inode *dir_i, struct _inode *d_inode, const unsigned char *d_name, size_t d_namelen);
     169int jffs2_rename (struct _inode *old_dir_i, struct _inode *d_inode, const unsigned char *old_d_name, size_t old_d_namelen,
     170                  struct _inode *new_dir_i, const unsigned char *new_d_name, size_t new_d_namelen);
    194171
    195172/* erase.c */
     
    200177#define SECTOR_ADDR(x) ( ((unsigned long)(x) & ~(c->sector_size-1)) )
    201178#define jffs2_can_mark_obsolete(c) (1)
     179#define jffs2_is_writebuffered(c) (0)
    202180#define jffs2_cleanmarker_oob(c) (0)
    203181#define jffs2_write_nand_cleanmarker(c,jeb) (-EIO)
     
    224202#define __init
    225203
    226 #endif /* __JFFS2_OS_ECOS_H__ */
     204#endif /* __JFFS2_OS_RTEMS_H__ */
Note: See TracChangeset for help on using the changeset viewer.