diff options
Diffstat (limited to 'cpukit/libfs/src/jffs2/src/os-rtems.h')
-rw-r--r-- | cpukit/libfs/src/jffs2/src/os-rtems.h | 82 |
1 files changed, 66 insertions, 16 deletions
diff --git a/cpukit/libfs/src/jffs2/src/os-rtems.h b/cpukit/libfs/src/jffs2/src/os-rtems.h index db1be61e67..4bc6f5df13 100644 --- a/cpukit/libfs/src/jffs2/src/os-rtems.h +++ b/cpukit/libfs/src/jffs2/src/os-rtems.h @@ -2,11 +2,11 @@ * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright © 2002-2003 Free Software Foundation, Inc. - * Copyright © 2013 embedded brains GmbH <rtems@embedded-brains.de> + * Copyright © 2013 embedded brains GmbH & Co. KG * * Created by David Woodhouse <dwmw2@cambridge.redhat.com> * - * Port to the RTEMS by embedded brains GmbH. + * Port to the RTEMS by embedded brains GmbH & Co. KG * * For licensing information, see the file 'LICENCE' in this directory. * @@ -52,11 +52,10 @@ static inline unsigned int full_name_hash(const void *salt, const unsigned char return hash; } -/* NAND flash not currently supported on RTEMS */ -#define jffs2_can_mark_obsolete(c) (1) +#define container_of(a, b, c) RTEMS_CONTAINER_OF(a, b, c) #define JFFS2_INODE_INFO(i) (&(i)->jffs2_i) -#define OFNI_EDONI_2SFFJ(f) ((struct _inode *) ( ((char *)f) - ((char *)(&((struct _inode *)NULL)->jffs2_i)) ) ) +#define OFNI_EDONI_2SFFJ(f) RTEMS_CONTAINER_OF(f, struct _inode, jffs2_i) #define ITIME(sec) (sec) #define I_SEC(tv) (tv) @@ -101,6 +100,10 @@ struct _inode { struct super_block { struct jffs2_sb_info jffs2_sb; + /* + * If granular locking is ever enabled for JFFS2, the inode cache + * (s_root) needs to be protected due to NAND delayed writes. + */ struct _inode * s_root; rtems_jffs2_flash_control *s_flash_control; rtems_jffs2_compressor_control *s_compressor_control; @@ -108,6 +111,7 @@ struct super_block { unsigned char s_gc_buffer[PAGE_CACHE_SIZE]; // Avoids malloc when user may be under memory pressure rtems_recursive_mutex s_mutex; char s_name_buf[JFFS2_MAX_NAME_LEN]; + uint32_t s_flags; }; #define sleep_on_spinunlock(wq, sl) spin_unlock(sl) @@ -136,9 +140,6 @@ struct _inode *jffs2_iget(struct super_block *sb, cyg_uint32 ino); void jffs2_iput(struct _inode * i); void jffs2_gc_release_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f); struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, int inum, int nlink); -unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, struct jffs2_inode_info *f, - unsigned long offset, unsigned long *priv); -void jffs2_gc_release_page(struct jffs2_sb_info *c, unsigned char *pg, unsigned long *priv); /* Avoid polluting RTEMS namespace with names not starting in jffs2_ */ #define os_to_jffs2_mode(x) jffs2_from_os_mode(x) @@ -154,13 +155,15 @@ static inline uint32_t jffs2_to_os_mode (uint32_t jmode) /* flashio.c */ -int jffs2_flash_read(struct jffs2_sb_info *c, cyg_uint32 read_buffer_offset, - const size_t size, size_t * return_size, unsigned char * write_buffer); -int jffs2_flash_write(struct jffs2_sb_info *c, cyg_uint32 write_buffer_offset, - const size_t size, size_t * return_size, unsigned char * read_buffer); +int jffs2_flash_read(struct jffs2_sb_info *c, loff_t read_buffer_offset, + size_t size, size_t * return_size, unsigned char * write_buffer); +int jffs2_flash_write(struct jffs2_sb_info *c, loff_t write_buffer_offset, + size_t size, size_t * return_size, const unsigned char * read_buffer); int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct iovec *vecs, unsigned long count, loff_t to, size_t *retlen); int jffs2_flash_erase(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); +int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, const u_char *buf); +int jffs2_flash_direct_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *retlen, u_char *buf); // dir-rtems.c struct _inode *jffs2_lookup(struct _inode *dir_i, const unsigned char *name, size_t namelen); @@ -176,8 +179,9 @@ int jffs2_rename (struct _inode *old_dir_i, struct _inode *d_inode, const unsign static inline void jffs2_erase_pending_trigger(struct jffs2_sb_info *c) { } -#ifndef CONFIG_JFFS2_FS_WRITEBUFFER #define SECTOR_ADDR(x) ( ((unsigned long)(x) & ~(c->sector_size-1)) ) +#ifndef CONFIG_JFFS2_FS_WRITEBUFFER + #define jffs2_can_mark_obsolete(c) (1) #define jffs2_is_writebuffered(c) (0) #define jffs2_cleanmarker_oob(c) (0) @@ -194,9 +198,55 @@ static inline void jffs2_erase_pending_trigger(struct jffs2_sb_info *c) #define jffs2_wbuf_timeout NULL #define jffs2_wbuf_process NULL #define jffs2_nor_ecc(c) (0) -#else -#error no nand yet -#endif +#else /* CONFIG_JFFS2_FS_WRITEBUFFER */ +/* dirty_writeback_interval is in centiseconds, 500cs == 5s */ +#define dirty_writeback_interval 500 +#define MTD_BIT_WRITEABLE 0x800 +#define jffs2_is_writebuffered(c) (c->wbuf != NULL) + +#define jffs2_can_mark_obsolete(c) (OFNI_BS_2SFFJ(c)->s_flash_control->block_is_bad == NULL) + +#define jffs2_cleanmarker_oob(c) (OFNI_BS_2SFFJ(c)->s_flash_control->block_is_bad != NULL) + +#define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len) + +/* wbuf.c */ +int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen, uint32_t ino); +int jffs2_check_oob_empty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,int mode); +int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); +int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); +int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, uint32_t bad_offset); +void jffs2_wbuf_timeout(unsigned long data); +void jffs2_wbuf_process(void *data); +int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino); +int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c); +int jffs2_nand_flash_setup(struct jffs2_sb_info *c); +void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c); +int jffs2_flash_block_is_bad(struct jffs2_sb_info * c, + cyg_uint32 block_offset, + bool *bad); +int jffs2_flash_block_mark_bad(struct jffs2_sb_info * c, + cyg_uint32 block_offset); +int jffs2_flash_oob_write(struct jffs2_sb_info * c, + cyg_uint32 block_offset, + uint8_t *oobbuf, + uint32_t ooblen); +int jffs2_flash_oob_read(struct jffs2_sb_info * c, + cyg_uint32 block_offset, + uint8_t *oobbuf, + uint32_t ooblen); +int jffs2_flash_get_oob_size(struct jffs2_sb_info * c); + +int jffs2_dataflash_setup(struct jffs2_sb_info *c); +void jffs2_dataflash_cleanup(struct jffs2_sb_info *c); +int jffs2_ubivol_setup(struct jffs2_sb_info *c); +void jffs2_ubivol_cleanup(struct jffs2_sb_info *c); + +int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c); +void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); +void jffs2_dirty_trigger(struct jffs2_sb_info *c); + +#endif /* CONFIG_JFFS2_FS_WRITEBUFFER */ #ifndef BUG_ON #define BUG_ON(x) do { if (unlikely(x)) BUG(); } while(0) |