rtems 文件系统(12)-flash jffs2

现在IMFS base file system已经建立起来了。到目前为止还是不了解怎么挂载其他的系统。因此查看rtems的wiki,看是否可以获取一些信息,并且看一下confdefs.h中关于文件系统这一部分。发现可以通过配置,增加jffs2的文件系统到rtems_filesystem_table中。

要使用jffs2需要包含一个库函数。libjffs2.a

在配置中增加#define CONFIGURE_FILESYSTEM_JFFS2。

根据现在的理解,增加到rtems_filesystem_table的文件系统,在初始化base filesystem的时候应该没有主动挂载,这个表只是在里面查询是否有该文件系统。所以还是需要自己挂载。

wiki上面说rtems也提供block device的API.也支持下面的设备,但是这种就像之前说的,是cache的方式,和jffs2相比没有优势

  1. ATA disks supporting IDE disk drives as well as Compact Flash disks configured in IDE mode
  2. RAM disk
  3. Non-volatile disk
  4. Flash disk
看完之后还是没有什么思路啊,突然想起testsuites 在其中的testsuites/fstests/jffs2_support/fs_support.c中找到一些思路。
在jffs2.h中 cpukit/libfs/src/jffs2/include/rtems/jffs2.h 定义了如下结构,这是一个很重要的结构,所有的底层驱动函数,比如read write 都会链接到该结构上面对应读写函数指针上面
/**
 * @brief JFFS2 flash device control.
 */
struct rtems_jffs2_flash_control {
  /**
   * @brief The size in bytes of the erasable unit of the flash device.
   */
  uint32_t block_size;


  /**
   * @brief The size in bytes of the flash device.
   *
   * It must be an integral multiple of the block size.  The flash device must
   * have at least five blocks.
   */
  uint32_t flash_size;


  /**
   * @brief Read from flash operation.
   */
  rtems_jffs2_flash_read read;


  /**
   * @brief Write to flash operation.
   */
  rtems_jffs2_flash_write write;


  /**
   * @brief Flash erase operation.
   */
  rtems_jffs2_flash_erase erase;


  /**
   * @brief Flash destroy operation.
   *
   * This operation is optional and the pointer may be @c NULL.
   */
  rtems_jffs2_flash_destroy destroy;


  /**
   * @brief The device identifier of the flash device.
   *
   * It is used in combination with the inode number to uniquely identify a
   * file system node in the system.
   */
  dev_t device_identifier;
};

比如rtems_jffs2_flash_read就是一个函数指针类型。其他的就不列举了。那么我只需要实现该结构中各个函数就可以了。这是对于底层方向的扩展。那么怎么安装jffs2到系统中呢

  rv = mount(
    NULL,
	FLASH_MOUNT_POINT,  				//if this is NULL,then the root file system will be mount
    RTEMS_FILESYSTEM_TYPE_JFFS2,
    RTEMS_FILESYSTEM_READ_WRITE,
    &mount_data
  );
其中target,自己选择一个挂载点即可。因为jffs2已经在 rtems_filesystem_table中,所以他会自动在表中找到,并调用表中初始化函数初始化该文件系统,最后还会注册到系统中。

rtems_jffs2_initialize中会做很多工作。这部分后续如果有需要再考虑。

剩下的任务就是实现底层的驱动函数,并和该控制结构链接到一起即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值