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/flashio.c

    r78b85286 r3c96bee  
    1616#include "nodelist.h"
    1717
    18 #include <cyg/io/io.h>
    19 #include <cyg/io/config_keys.h>
    20 #include <cyg/io/flash.h>
    21 
    22 cyg_bool jffs2_flash_read(struct jffs2_sb_info * c,
     18int jffs2_flash_read(struct jffs2_sb_info * c,
    2319                          cyg_uint32 read_buffer_offset, const size_t size,
    2420                          size_t * return_size, unsigned char *write_buffer)
    2521{
    26         Cyg_ErrNo err;
    27         cyg_uint32 len = size;
    28         struct super_block *sb = OFNI_BS_2SFFJ(c);
     22        const struct super_block *sb = OFNI_BS_2SFFJ(c);
     23        rtems_jffs2_flash_control *fc = sb->s_flash_control;
    2924
    30         //D2(printf("FLASH READ\n"));
    31         //D2(printf("read address = %x\n", CYGNUM_FS_JFFS2_BASE_ADDRESS + read_buffer_offset));
    32         //D2(printf("write address = %x\n", write_buffer));
    33         //D2(printf("size = %x\n", size));
    34         err = cyg_io_bread(sb->s_dev, write_buffer, &len, read_buffer_offset);
     25        *return_size = size;
    3526
    36         *return_size = (size_t) len;
    37         return ((err == ENOERR) ? ENOERR : -EIO);
     27        return (*fc->read)(fc, read_buffer_offset, write_buffer, size);
    3828}
    3929
    40 cyg_bool jffs2_flash_write(struct jffs2_sb_info * c,
     30int jffs2_flash_write(struct jffs2_sb_info * c,
    4131                           cyg_uint32 write_buffer_offset, const size_t size,
    4232                           size_t * return_size, unsigned char *read_buffer)
    4333{
     34        const struct super_block *sb = OFNI_BS_2SFFJ(c);
     35        rtems_jffs2_flash_control *fc = sb->s_flash_control;
    4436
    45         Cyg_ErrNo err;
    46         cyg_uint32 len = size;
    47         struct super_block *sb = OFNI_BS_2SFFJ(c);
     37        *return_size = size;
    4838
    49         //    D2(printf("FLASH WRITE ENABLED!!!\n"));
    50         //    D2(printf("write address = %x\n", CYGNUM_FS_JFFS2_BASE_ADDRESS + write_buffer_offset));
    51         //    D2(printf("read address = %x\n", read_buffer));
    52         //    D2(printf("size = %x\n", size));
    53 
    54         err = cyg_io_bwrite(sb->s_dev, read_buffer, &len, write_buffer_offset);
    55         *return_size = (size_t) len;
    56 
    57         return ((err == ENOERR) ? ENOERR : -EIO);
     39        return (*fc->write)(fc, write_buffer_offset, read_buffer, size);
    5840}
    5941
     
    141123}
    142124
    143 cyg_bool jffs2_flash_erase(struct jffs2_sb_info * c,
     125int jffs2_flash_erase(struct jffs2_sb_info * c,
    144126                           struct jffs2_eraseblock * jeb)
    145127{
    146         cyg_io_flash_getconfig_erase_t e;
    147         cyg_flashaddr_t err_addr;
    148         Cyg_ErrNo err;
    149         cyg_uint32 len = sizeof (e);
    150         struct super_block *sb = OFNI_BS_2SFFJ(c);
     128        const struct super_block *sb = OFNI_BS_2SFFJ(c);
     129        rtems_jffs2_flash_control *fc = sb->s_flash_control;
    151130
    152         e.offset = jeb->offset;
    153         e.len = c->sector_size;
    154         e.err_address = &err_addr;
    155 
    156         //        D2(printf("FLASH ERASE ENABLED!!!\n"));
    157         //        D2(printf("erase address = %x\n", CYGNUM_FS_JFFS2_BASE_ADDRESS + jeb->offset));
    158         //        D2(printf("size = %x\n", c->sector_size));
    159 
    160         err = cyg_io_get_config(sb->s_dev, CYG_IO_GET_CONFIG_FLASH_ERASE,
    161                                 &e, &len);
    162 
    163         return (err != ENOERR || e.flasherr != 0);
     131        return (*fc->erase)(fc, jeb->offset);
    164132}
    165133
Note: See TracChangeset for help on using the changeset viewer.