diff options
| author | Bernard Xiong <[email protected]> | 2018-10-29 11:05:33 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2018-10-29 11:05:33 +0800 |
| commit | fbac6c8be7208e5baf2c4333602b5a0a8d37484b (patch) | |
| tree | e7dfc2ef0e1effe9efbb58cb45fdce9205107730 /components/dfs | |
| parent | 98fc1cb4cf0fd20a79f16b72fd72846c207702b5 (diff) | |
Remove lwIP 1.3.2 and yaffs2 from RT-Thread Platform.
Diffstat (limited to 'components/dfs')
| -rw-r--r-- | components/dfs/filesystems/yaffs2/fixwarning.diff | 398 | ||||
| -rw-r--r-- | components/dfs/filesystems/yaffs2/readme.txt | 46 | ||||
| -rw-r--r-- | components/dfs/filesystems/yaffs2/yaffs.diff | 1014 |
3 files changed, 0 insertions, 1458 deletions
diff --git a/components/dfs/filesystems/yaffs2/fixwarning.diff b/components/dfs/filesystems/yaffs2/fixwarning.diff deleted file mode 100644 index d0f9304924..0000000000 --- a/components/dfs/filesystems/yaffs2/fixwarning.diff +++ /dev/null @@ -1,398 +0,0 @@ -diff --git a/dfs_yaffs2.c b/dfs_yaffs2.c -index 4b056ae..e63d5d4 100644 ---- a/dfs_yaffs2.c -+++ b/dfs_yaffs2.c -@@ -39,7 +39,6 @@ static int dfs_yaffs_mount(struct dfs_filesystem* fs, - const void* data) - { - unsigned index; -- ynandif_Geometry *g; - - /*1. find a empty entry in partition table */ - for (index = 0; index < NAND_DEVICE_PART_MAX ; index ++) -diff --git a/yaffs/direct/yaffsfs.c b/yaffs/direct/yaffsfs.c -index 17fc502..1f47ea7 100644 ---- a/yaffs/direct/yaffsfs.c -+++ b/yaffs/direct/yaffsfs.c -@@ -1367,7 +1367,7 @@ off_t yaffs_lseek(int handle, off_t offset, int whence) - if(offset >= 0) - pos = offset; - } else if(whence == SEEK_CUR) { -- if( (fd->position + offset) >= 0) -+ if( ((int)fd->position + offset) >= 0) - pos = (fd->position + offset); - } else if(whence == SEEK_END) { - fSize = yaffs_get_obj_length(obj); -diff --git a/yaffs/direct/yportenv.h b/yaffs/direct/yportenv.h -index f693c16..ac0a737 100644 ---- a/yaffs/direct/yportenv.h -+++ b/yaffs/direct/yportenv.h -@@ -45,7 +45,7 @@ - #endif - - #ifndef loff_t -- typedef unsigned long loff_t; -+ typedef long loff_t; - #endif - - #ifndef dev_t -@@ -66,7 +66,7 @@ - #elif defined (__GNUC__) && !defined(__CC_ARM) - - #ifndef loff_t -- typedef unsigned long loff_t; -+ typedef long loff_t; - #endif - - #ifndef dev_t -diff --git a/yaffs/yaffs_guts.c b/yaffs/yaffs_guts.c -index d72aa5b..08db8c8 100644 ---- a/yaffs/yaffs_guts.c -+++ b/yaffs/yaffs_guts.c -@@ -280,7 +280,7 @@ static void yaffs_handle_chunk_wr_error(struct yaffs_dev *dev, int nand_chunk, - - static inline int yaffs_hash_fn(int n) - { -- n = abs(n); -+ n = n > 0 ? n : -n; - return n % YAFFS_NOBJECT_BUCKETS; - } - -@@ -319,9 +319,9 @@ static int yaffs_check_chunk_erased(struct yaffs_dev *dev, int nand_chunk) - int retval = YAFFS_OK; - u8 *data = yaffs_get_temp_buffer(dev); - struct yaffs_ext_tags tags; -- int result; - -- result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags); -+ -+ yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags); - - if (tags.ecc_result > YAFFS_ECC_RESULT_NO_ERROR) - retval = YAFFS_FAIL; -@@ -347,9 +347,9 @@ static int yaffs_verify_chunk_written(struct yaffs_dev *dev, - int retval = YAFFS_OK; - struct yaffs_ext_tags temp_tags; - u8 *buffer = yaffs_get_temp_buffer(dev); -- int result; - -- result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags); -+ -+ yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags); - if (memcmp(buffer, data, dev->data_bytes_per_chunk) || - temp_tags.obj_id != tags->obj_id || - temp_tags.chunk_id != tags->chunk_id || -@@ -1478,7 +1478,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev) - struct yaffs_obj *the_obj; - int usage; - int i; -- int pushout; -+ /* int pushout; */ - - if (dev->param.n_caches < 1) - return NULL; -@@ -1499,7 +1499,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev) - the_obj = dev->cache[0].object; - usage = -1; - cache = NULL; -- pushout = -1; -+ /* pushout = -1; */ - - for (i = 0; i < dev->param.n_caches; i++) { - if (dev->cache[i].object && -@@ -1509,7 +1509,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev) - usage = dev->cache[i].last_use; - the_obj = dev->cache[i].object; - cache = &dev->cache[i]; -- pushout = i; -+ /* pushout = i; */ - } - } - -@@ -3167,7 +3167,7 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in) - struct yaffs_obj_hdr *oh; - struct yaffs_dev *dev; - struct yaffs_ext_tags tags; -- int result; -+ - int alloc_failed = 0; - - if (!in || !in->lazy_loaded || in->hdr_chunk < 1) -@@ -3177,7 +3177,7 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in) - in->lazy_loaded = 0; - buf = yaffs_get_temp_buffer(dev); - -- result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags); -+ yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags); - oh = (struct yaffs_obj_hdr *)buf; - - in->yst_mode = oh->yst_mode; -@@ -3189,6 +3189,7 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in) - yaffs_clone_str(oh->alias); - if (!in->variant.symlink_variant.alias) - alloc_failed = 1; /* Not returned */ -+ alloc_failed = alloc_failed; - } - yaffs_release_temp_buffer(dev, buf); - } -@@ -3274,7 +3275,7 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, - struct yaffs_dev *dev = in->my_dev; - int prev_chunk_id; - int ret_val = 0; -- int result = 0; -+ - int new_chunk_id; - struct yaffs_ext_tags new_tags; - struct yaffs_ext_tags old_tags; -@@ -3297,7 +3298,7 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, - prev_chunk_id = in->hdr_chunk; - - if (prev_chunk_id > 0) { -- result = yaffs_rd_chunk_tags_nand(dev, prev_chunk_id, -+ yaffs_rd_chunk_tags_nand(dev, prev_chunk_id, - buffer, &old_tags); - - yaffs_verify_oh(in, oh, &old_tags, 0); -@@ -3921,7 +3922,7 @@ int yaffs_del_obj(struct yaffs_obj *obj) - list_del_init(&obj->variant.dir_variant.dirty); - } - return yaffs_del_dir(obj); -- break; -+ //break; - case YAFFS_OBJECT_TYPE_SYMLINK: - ret_val = yaffs_del_symlink(obj); - break; -@@ -3993,17 +3994,17 @@ static int yaffs_unlink_worker(struct yaffs_obj *obj) - switch (obj->variant_type) { - case YAFFS_OBJECT_TYPE_FILE: - return yaffs_del_file(obj); -- break; -+ //break; - case YAFFS_OBJECT_TYPE_DIRECTORY: - list_del_init(&obj->variant.dir_variant.dirty); - return yaffs_del_dir(obj); -- break; -+ //break; - case YAFFS_OBJECT_TYPE_SYMLINK: - return yaffs_del_symlink(obj); -- break; -+ //break; - case YAFFS_OBJECT_TYPE_SPECIAL: - return yaffs_generic_obj_del(obj); -- break; -+ //break; - case YAFFS_OBJECT_TYPE_HARDLINK: - case YAFFS_OBJECT_TYPE_UNKNOWN: - default: -@@ -4421,7 +4422,7 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size) - } else if (obj->short_name[0]) { - strcpy(name, obj->short_name); - } else if (obj->hdr_chunk > 0) { -- int result; -+ - u8 *buffer = yaffs_get_temp_buffer(obj->my_dev); - - struct yaffs_obj_hdr *oh = (struct yaffs_obj_hdr *)buffer; -@@ -4429,7 +4430,7 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size) - memset(buffer, 0, obj->my_dev->data_bytes_per_chunk); - - if (obj->hdr_chunk > 0) { -- result = yaffs_rd_chunk_tags_nand(obj->my_dev, -+ yaffs_rd_chunk_tags_nand(obj->my_dev, - obj->hdr_chunk, - buffer, NULL); - } -@@ -4490,16 +4491,16 @@ unsigned yaffs_get_obj_type(struct yaffs_obj *obj) - switch (obj->variant_type) { - case YAFFS_OBJECT_TYPE_FILE: - return DT_REG; -- break; -+ //break; - case YAFFS_OBJECT_TYPE_DIRECTORY: - return DT_DIR; -- break; -+ //break; - case YAFFS_OBJECT_TYPE_SYMLINK: - return DT_LNK; -- break; -+ //break; - case YAFFS_OBJECT_TYPE_HARDLINK: - return DT_REG; -- break; -+ //break; - case YAFFS_OBJECT_TYPE_SPECIAL: - if (S_ISFIFO(obj->yst_mode)) - return DT_FIFO; -@@ -4510,10 +4511,10 @@ unsigned yaffs_get_obj_type(struct yaffs_obj *obj) - if (S_ISSOCK(obj->yst_mode)) - return DT_SOCK; - return DT_REG; -- break; -+ //break; - default: - return DT_REG; -- break; -+ //break; - } - } - -@@ -4837,7 +4838,7 @@ int yaffs_guts_initialise(struct yaffs_dev *dev) - dev->n_erased_blocks = 0; - dev->n_free_chunks = 0; - dev->alloc_block = -1; -- dev->alloc_page = -1; -+ dev->alloc_page = (u32)(-1); - dev->n_deleted_files = 0; - dev->n_unlinked_files = 0; - dev->n_bg_deletions = 0; -diff --git a/yaffs/yaffs_packedtags2.c b/yaffs/yaffs_packedtags2.c -index 820bc41..9306623 100644 ---- a/yaffs/yaffs_packedtags2.c -+++ b/yaffs/yaffs_packedtags2.c -@@ -35,7 +35,7 @@ - - /* Also, the top 4 bits of the object Id are set to the object type. */ - #define EXTRA_OBJECT_TYPE_SHIFT (28) --#define EXTRA_OBJECT_TYPE_MASK ((0x0f) << EXTRA_OBJECT_TYPE_SHIFT) -+#define EXTRA_OBJECT_TYPE_MASK ((0x0fUL) << EXTRA_OBJECT_TYPE_SHIFT) - - static void yaffs_dump_packed_tags2_tags_only( - const struct yaffs_packed_tags2_tags_only *ptt) -@@ -129,7 +129,7 @@ void yaffs_unpack_tags2_tags_only(struct yaffs_ext_tags *t, - t->extra_parent_id = ptt->chunk_id & (~(ALL_EXTRA_FLAGS)); - t->extra_is_shrink = ptt->chunk_id & EXTRA_SHRINK_FLAG ? 1 : 0; - t->extra_shadows = ptt->chunk_id & EXTRA_SHADOWS_FLAG ? 1 : 0; -- t->extra_obj_type = ptt->obj_id >> EXTRA_OBJECT_TYPE_SHIFT; -+ t->extra_obj_type = (enum yaffs_obj_type)(ptt->obj_id >> EXTRA_OBJECT_TYPE_SHIFT); - t->obj_id &= ~EXTRA_OBJECT_TYPE_MASK; - - if (t->extra_obj_type == YAFFS_OBJECT_TYPE_HARDLINK) -diff --git a/yaffs/yaffs_verify.c b/yaffs/yaffs_verify.c -index b3e540d..1758125 100644 ---- a/yaffs/yaffs_verify.c -+++ b/yaffs/yaffs_verify.c -@@ -223,7 +223,7 @@ void yaffs_verify_oh(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh, - void yaffs_verify_file(struct yaffs_obj *obj) - { - int required_depth; -- int actual_depth; -+ //int actual_depth; - u32 last_chunk; - u32 the_chunk; - u32 x; -@@ -252,7 +252,7 @@ void yaffs_verify_file(struct yaffs_obj *obj) - required_depth++; - } - -- actual_depth = obj->variant.file_variant.top_level; -+ //actual_depth = obj->variant.file_variant.top_level; - - /* Check that the chunks in the tnode tree are all correct. - * We do this by scanning through the tnode tree and -diff --git a/yaffs/yaffs_yaffs1.c b/yaffs/yaffs_yaffs1.c -index da6a40f..8e7f4b2 100644 ---- a/yaffs/yaffs_yaffs1.c -+++ b/yaffs/yaffs_yaffs1.c -@@ -23,7 +23,7 @@ int yaffs1_scan(struct yaffs_dev *dev) - { - struct yaffs_ext_tags tags; - int blk; -- int result; -+ //int result; - int chunk; - int c; - int deleted; -@@ -84,7 +84,7 @@ int yaffs1_scan(struct yaffs_dev *dev) - cond_resched(); - - bi = yaffs_get_block_info(dev, blk); -- state = bi->block_state; -+ state = (enum yaffs_block_state)(bi->block_state); - - deleted = 0; - -@@ -95,7 +95,7 @@ int yaffs1_scan(struct yaffs_dev *dev) - /* Read the tags and decide what to do */ - chunk = blk * dev->param.chunks_per_block + c; - -- result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL, -+ yaffs_rd_chunk_tags_nand(dev, chunk, NULL, - &tags); - - /* Let's have a good look at this chunk... */ -@@ -181,7 +181,7 @@ int yaffs1_scan(struct yaffs_dev *dev) - yaffs_set_chunk_bit(dev, blk, c); - bi->pages_in_use++; - -- result = yaffs_rd_chunk_tags_nand(dev, chunk, -+ yaffs_rd_chunk_tags_nand(dev, chunk, - chunk_data, - NULL); - -diff --git a/yaffs/yaffs_yaffs2.c b/yaffs/yaffs_yaffs2.c -index 5761e96..69acd20 100644 ---- a/yaffs/yaffs_yaffs2.c -+++ b/yaffs/yaffs_yaffs2.c -@@ -946,7 +946,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, - int is_shrink; - int is_unlinked; - struct yaffs_ext_tags tags; -- int result; -+ //int result; - int alloc_failed = 0; - int chunk = blk * dev->param.chunks_per_block + chunk_in_block; - struct yaffs_file_var *file_var; -@@ -954,12 +954,12 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, - struct yaffs_symlink_var *sl_var; - - if (summary_available) { -- result = yaffs_summary_fetch(dev, &tags, chunk_in_block); -+ yaffs_summary_fetch(dev, &tags, chunk_in_block); - tags.seq_number = bi->seq_number; - } - - if (!summary_available || tags.obj_id == 0) { -- result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags); -+ yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags); - dev->tags_used++; - } else { - dev->summary_used++; -@@ -1114,7 +1114,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, - * invalid data until needed. - */ - -- result = yaffs_rd_chunk_tags_nand(dev, -+ yaffs_rd_chunk_tags_nand(dev, - chunk, - chunk_data, - NULL); -@@ -1349,7 +1349,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev) - int n_to_scan = 0; - enum yaffs_block_state state; - int c; -- int deleted; -+ //int deleted; - LIST_HEAD(hard_list); - struct yaffs_block_info *bi; - u32 seq_number; -@@ -1467,7 +1467,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev) - /* get the block to scan in the correct order */ - blk = block_index[block_iter].block; - bi = yaffs_get_block_info(dev, blk); -- deleted = 0; -+ //deleted = 0; - - summary_available = yaffs_summary_read(dev, dev->sum_tags, blk); - -diff --git a/yaffs_osglue.c b/yaffs_osglue.c -index 2c34f99..4f2e5db 100644 ---- a/yaffs_osglue.c -+++ b/yaffs_osglue.c -@@ -58,7 +58,6 @@ void yaffsfs_LockInit(void) - #else - - static rt_mutex_t mutex = RT_NULL; --static rt_sem_t sem = RT_NULL; - void yaffsfs_Lock(void) - { - rt_mutex_take(mutex, RT_WAITING_FOREVER); diff --git a/components/dfs/filesystems/yaffs2/readme.txt b/components/dfs/filesystems/yaffs2/readme.txt deleted file mode 100644 index e6b8d3b976..0000000000 --- a/components/dfs/filesystems/yaffs2/readme.txt +++ /dev/null @@ -1,46 +0,0 @@ -how to use yaffs under rt-thread. - -There are three steps. -1. get yaffs tarball from official repo. - the repo of official repo is here. - http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=summary - then you should find the 2011-6-28's snapshot, download the tarball - http://www.aleph1.co.uk/gitweb?p=yaffs2.git;a=snapshot;h=2df51cdb98e799c4d10b4cc7dd7e8858aa79e7d8;sf=tgz - - decompress the yaffs.tar.gz to rt-thread\components\dfs\filesystems\yaffs2\yaffs - -2. patch yaffs.diff - open an terminal. - (1) on windows - open cmd command prompt, then use [cd] command to come current path - for example - F:\Project\svn\rt-thread\components\dfs\filesystems\yaffs2> - then type command - patch -p1 < yaffs.diff - - you will get some log information as followings - F:\Project\svn\rt-thread\components\dfs\filesystems\yaffs2>patch -p1 < yaffs.diff - patching file `dfs_yaffs2.c' - patching file `yaffs/direct/yaffs_list.h' - patching file `yaffs/direct/yaffs_nandif.c' - patching file `yaffs/direct/ydirectenv.h' - patching file `yaffs/direct/yportenv.h' - patching file `yaffs_nandcfg.c' - patching file `yaffs_osglue.c' - - now you can delete yaffs.diff - there is another patch file, as the name shows, it is to fix compile - warning, so it is not necessary. If you want, you can use the - following command. - patch -p1 < fixwarning.diff - - (2) on linux - Help yourself. Since you have use linux as your os, I believe in you. - -3.add nand driver and compile - In order to use yaffs, you should provide a nand driver which is needed - by yaffs. There is an example file in rt-thread\components\dfs\filesystems\uffs\nand. - you should modify yaffs_nandcfg.c according to your nand driver. - then you can use scons or IDE like MDK or IAR to compile. - - enjoy ! diff --git a/components/dfs/filesystems/yaffs2/yaffs.diff b/components/dfs/filesystems/yaffs2/yaffs.diff deleted file mode 100644 index e487ac6a6d..0000000000 --- a/components/dfs/filesystems/yaffs2/yaffs.diff +++ /dev/null @@ -1,1014 +0,0 @@ -diff --git a/dfs_yaffs2.c b/dfs_yaffs2.c -new file mode 100644 -index 0000000..4b056ae ---- /dev/null -+++ b/dfs_yaffs2.c -@@ -0,0 +1,405 @@ -+/* -+ * File : rtthread.h -+ * This file is part of RT-Thread RTOS -+ * COPYRIGHT (C) 2006-2011, RT-Thread Development Team -+ * -+ * The license and distribution terms for this file may be -+ * found in the file LICENSE in this distribution or at -+ * http://www.rt-thread.org/license/LICENSE. -+ * -+ * Change Logs: -+ * Date Author Notes -+ * 2011-10-22 prife the first version -+ * 2012-04-14 prife use mtd device interface -+*/ -+#include <rtthread.h> -+#include <rtdevice.h> -+ -+#include "yaffsfs.h" -+#include "yaffs_nandif.h" -+ -+#include <dfs_fs.h> -+#include <dfs_def.h> -+ -+#define YAFFS_FILE_PATH_MAX 256 /* the longest file path */ -+ -+#define NAND_DEVICE_PART_MAX 4 /* the max partitions on a nand deivce*/ -+struct device_part -+{ -+ struct rt_mtd_nand_device *dev; -+ ynandif_Geometry g; -+}; -+static struct device_part nand_part[NAND_DEVICE_PART_MAX] = {0}; -+ -+extern int yaffs_start(const char * mountpath, ynandif_Geometry * g); -+extern void yaffs_config(ynandif_Geometry * g, struct rt_mtd_nand_device * dev); -+ -+static int dfs_yaffs_mount(struct dfs_filesystem* fs, -+ unsigned long rwflag, -+ const void* data) -+{ -+ unsigned index; -+ ynandif_Geometry *g; -+ -+ /*1. find a empty entry in partition table */ -+ for (index = 0; index < NAND_DEVICE_PART_MAX ; index ++) -+ { -+ if (nand_part[index].dev == RT_NULL) -+ break; -+ } -+ if (index == NAND_DEVICE_PART_MAX) -+ return -DFS_STATUS_ENOSPC; -+ -+ /*2. fill nand_part*/ -+ nand_part[index].dev = RT_MTD_NAND_DEVICE(fs->dev_id); -+ yaffs_config(&nand_part[index].g, RT_MTD_NAND_DEVICE(fs->dev_id)); -+ -+ /*3. start up yaffs2 */ -+ yaffs_start(fs->path, &nand_part[index].g); -+ if (yaffs_mount(fs->path) < 0) -+ { -+ return yaffsfs_GetLastError(); -+ } -+ return 0; -+} -+ -+static int dfs_yaffs_unmount(struct dfs_filesystem* fs) -+{ -+ unsigned index; -+ if (yaffs_unmount(fs->path) < 0) -+ return yaffsfs_GetLastError(); -+ -+ /* find device index, then umount it */ -+ for (index = 0; index < NAND_DEVICE_PART_MAX; index++) -+ { -+ if (nand_part[index].dev == RT_MTD_NAND_DEVICE(fs->dev_id)) -+ { -+ nand_part[index].dev = RT_NULL; -+ return DFS_STATUS_OK; -+ } -+ } -+ return -DFS_STATUS_ENOENT; -+} -+ -+static int dfs_yaffs_mkfs(const char* device_name) -+{ -+ /* just erase all blocks on this nand partition */ -+ return -DFS_STATUS_ENOSYS; -+} -+ -+static int dfs_yaffs_statfs(struct dfs_filesystem* fs, -+ struct statfs *buf) -+{ -+ struct rt_mtd_nand_device * mtd = RT_MTD_NAND_DEVICE(fs->dev_id); -+ -+ RT_ASSERT(mtd != RT_NULL); -+ -+ buf->f_bsize = mtd->page_size; -+ buf->f_blocks = (mtd->block_size)/(mtd->page_size)* -+ (mtd->block_start - mtd->block_end + 1); -+ buf->f_bfree = yaffs_freespace(fs->path) / mtd->page_size; -+ -+ return 0; -+} -+ -+static int dfs_yaffs_open(struct dfs_fd* file) -+{ -+ int fd; -+ int oflag; -+ int result; -+ -+ oflag = file->flags; -+ if (oflag & DFS_O_DIRECTORY) /* operations about dir */ -+ { -+ yaffs_DIR * dir; -+ if (oflag & DFS_O_CREAT) /* create a dir*/ -+ { -+ result = yaffs_mkdir(file->path, 0x777); /* the second args not supported by rtt */ -+ if (result < 0) -+ return yaffsfs_GetLastError(); -+ } -+ /* open dir */ -+ dir = yaffs_opendir(file->path); -+ if (dir == RT_NULL) -+ return yaffsfs_GetLastError(); -+ /* save this pointer,will used by dfs_yaffs_getdents*/ -+ file->data = dir; -+ return 0; -+ } -+ /* regular file operations */ -+ fd = yaffs_open(file->path, oflag, S_IREAD | S_IWRITE); -+ if (fd < 0) -+ return yaffsfs_GetLastError(); -+ -+ /* save this pointer, it will be used when calling read()��write(), -+ flush(), lessk(), and will be free when calling close()*/ -+ file->data = (void *)fd; -+ file->pos = yaffs_lseek(fd,0,SEEK_CUR); -+ file->size = yaffs_lseek(fd,0,SEEK_END); -+ yaffs_lseek(fd, file->pos, SEEK_SET); -+ -+ if (oflag & DFS_O_APPEND) -+ { -+ file->pos = file->size; -+ file->size = yaffs_lseek(fd,0,SEEK_END); -+ } -+ return 0; -+} -+ -+static int dfs_yaffs_close(struct dfs_fd* file) -+{ -+ int oflag; -+ int fd; -+ -+ oflag = file->flags; -+ if (oflag & DFS_O_DIRECTORY) /* operations about dir */ -+ { -+ if (yaffs_closedir((yaffs_DIR *)(file->data)) < 0) -+ return yaffsfs_GetLastError(); -+ return 0; -+ } -+ /* regular file operations */ -+ fd = (int)(file->data); -+ -+ if (yaffs_close(fd) == 0) -+ return 0; -+ -+ /* release memory */ -+ return yaffsfs_GetLastError(); -+} -+ -+static int dfs_yaffs_ioctl(struct dfs_fd* file, int cmd, void* args) -+{ -+ return -DFS_STATUS_ENOSYS; -+} -+ -+static int dfs_yaffs_read(struct dfs_fd* file, void* buf, rt_size_t len) -+{ -+ int fd; -+ int char_read; -+ -+ fd = (int)(file->data); -+ char_read = yaffs_read(fd, buf, len); -+ if (char_read < 0) -+ return yaffsfs_GetLastError(); -+ -+ /* update position */ -+ file->pos = yaffs_lseek(fd, 0, SEEK_CUR); -+ return char_read; -+} -+ -+static int dfs_yaffs_write(struct dfs_fd* file, -+ const void* buf, -+ rt_size_t len) -+{ -+ int fd; -+ int char_write; -+ -+ fd = (int)(file->data); -+ -+ char_write = yaffs_write(fd, buf, len); -+ if (char_write < 0) -+ return yaffsfs_GetLastError(); -+ -+ /* update position */ -+ file->pos = yaffs_lseek(fd, 0, SEEK_CUR); -+ return char_write; -+} -+ -+static int dfs_yaffs_flush(struct dfs_fd* file) -+{ -+ int fd; -+ int result; -+ -+ fd = (int)(file->data); -+ -+ result = yaffs_flush(fd); -+ if (result < 0) -+ return yaffsfs_GetLastError(); -+ return 0; -+} -+ -+static int dfs_yaffs_lseek(struct dfs_fd* file, -+ rt_off_t offset) -+{ -+ int fd; -+ int result; -+ -+ fd = (int)(file->data); -+ -+ /* set offset as current offset */ -+ result = yaffs_lseek(fd, offset, SEEK_SET); -+ if (result < 0) -+ return yaffsfs_GetLastError(); -+ return result; -+} -+ -+/* return the size of struct dirent*/ -+static int dfs_yaffs_getdents(struct dfs_fd* file, -+ struct dirent* dirp, -+ rt_uint32_t count) -+{ -+ rt_uint32_t index; -+ char * file_path; -+ struct dirent* d; -+ yaffs_DIR* dir; -+ struct yaffs_dirent * yaffs_d; -+ -+ dir = (yaffs_DIR*)(file->data); -+ RT_ASSERT(dir != RT_NULL); -+ -+ /* make integer count, usually count is 1 */ -+ count = (count / sizeof(struct dirent)) * sizeof(struct dirent); -+ if (count == 0) return -DFS_STATUS_EINVAL; -+ -+ /* allocate file name */ -+ file_path = rt_malloc(YAFFS_FILE_PATH_MAX); -+ if (file_path == RT_NULL) -+ return -DFS_STATUS_ENOMEM; -+ -+ index = 0; -+ /* usually, the while loop should only be looped only once! */ -+ while (1) -+ { -+ struct yaffs_stat s; -+ -+ d = dirp + index; -+ -+ yaffs_d = yaffs_readdir(dir); -+ if (yaffs_d == RT_NULL) -+ { -+ if (yaffsfs_GetLastError() == EBADF) -+ return -DFS_STATUS_EBADF; -+ -+ rt_free(file_path); -+ return -1; /* a general error */ -+ } -+ -+ rt_snprintf(file_path, YAFFS_FILE_PATH_MAX, "%s/%s", file->path, yaffs_d->d_name); -+ -+ yaffs_lstat(file_path, &s); -+ switch(s.st_mode & S_IFMT) -+ { -+ case S_IFREG: d->d_type = DFS_DT_REG; break; -+ -+ case S_IFDIR: d->d_type = DFS_DT_DIR; break; -+ -+ case S_IFLNK: -+ default: d->d_type = DFS_DT_UNKNOWN; break; -+ } -+ -+ /* write the rest feilds of struct dirent* dirp */ -+ d->d_namlen = rt_strlen(yaffs_d->d_name); -+ d->d_reclen = (rt_uint16_t)sizeof(struct dirent); -+ rt_strncpy(d->d_name, yaffs_d->d_name, rt_strlen(yaffs_d->d_name) + 1); -+ -+ index ++; -+ if (index * sizeof(struct dirent) >= count) -+ break; -+ } -+ -+ /* free file name buf */ -+ rt_free(file_path); -+ -+ if (index == 0) -+ return yaffsfs_GetLastError(); -+ -+ return index * sizeof(struct dirent); -+} -+ -+static int dfs_yaffs_unlink(struct dfs_filesystem* fs, const char* path) -+{ -+ int result; -+ struct yaffs_stat s; -+ -+ /* judge file type, dir is to be delete by yaffs_rmdir, others by yaffs_unlink */ -+ if (yaffs_lstat(path, &s) < 0) -+ { -+ return yaffsfs_GetLastError(); -+ } -+ -+ switch(s.st_mode & S_IFMT) -+ { -+ case S_IFREG: -+ result = yaffs_unlink(path); -+ break; -+ case S_IFDIR: -+ result = yaffs_rmdir(path); -+ break; -+ default: -+ /* unknown file type */ -+ return -1; -+ } -+ if (result < 0) -+ return yaffsfs_GetLastError(); -+ return 0; -+} -+ -+static int dfs_yaffs_rename(struct dfs_filesystem* fs, -+ const char* oldpath, -+ const char* newpath) -+{ -+ int result; -+ -+ result = yaffs_rename(oldpath, newpath); -+ -+ if (result < 0) -+ return yaffsfs_GetLastError(); -+ return 0; -+} -+ -+static int dfs_yaffs_stat(struct dfs_filesystem* fs, const char *path, struct stat *st) -+{ -+ int result; -+ struct yaffs_stat s; -+ struct rt_mtd_nand_device * mtd; -+ -+ result = yaffs_stat(path, &s); -+ if (result < 0) -+ return yaffsfs_GetLastError(); -+ -+ /* convert to dfs stat structure */ -+ st->st_dev = 0; -+ st->st_mode = s.st_mode; -+ st->st_size = s.st_size; -+ st->st_mtime = s.yst_mtime; -+ -+ mtd = RT_MTD_NAND_DEVICE(fs->dev_id); -+ st->st_blksize = mtd->page_size; -+ -+ return 0; -+} -+ -+static const struct dfs_filesystem_operation dfs_yaffs_ops = -+{ -+ "yaffs2", /* file system type: yaffs2 */ -+#if RTTHREAD_VERSION >= 10100 -+ DFS_FS_FLAG_FULLPATH, -+#else -+#error "yaffs2 can only work with rtthread whose version should >= 1.01\n" -+#endif -+ dfs_yaffs_mount, -+ dfs_yaffs_unmount, -+ dfs_yaffs_mkfs, -+ dfs_yaffs_statfs, -+ -+ dfs_yaffs_open, -+ dfs_yaffs_close, -+ dfs_yaffs_ioctl, -+ dfs_yaffs_read, -+ dfs_yaffs_write, -+ dfs_yaffs_flush, -+ dfs_yaffs_lseek, -+ dfs_yaffs_getdents, -+ dfs_yaffs_unlink, -+ dfs_yaffs_stat, -+ dfs_yaffs_rename, -+}; -+ -+int dfs_yaffs_init(void) -+{ -+ /* register fatfs file system */ -+ dfs_register(&dfs_yaffs_ops); -+ -+ return 0; -+} -diff --git a/yaffs/direct/yaffs_list.h b/yaffs/direct/yaffs_list.h -index f1c5254..17044f5 100644 ---- a/yaffs/direct/yaffs_list.h -+++ b/yaffs/direct/yaffs_list.h -@@ -39,7 +39,7 @@ struct list_head { - - /* Initialise a static list */ - #define LIST_HEAD(name) \ --struct list_head name = { &(name), &(name)} -+static struct list_head name = { &(name), &(name)} - - - -diff --git a/yaffs/direct/yaffs_nandif.c b/yaffs/direct/yaffs_nandif.c -index b93b55a..3fae80e 100644 ---- a/yaffs/direct/yaffs_nandif.c -+++ b/yaffs/direct/yaffs_nandif.c -@@ -18,7 +18,6 @@ - #include "yaffs_nandif.h" - #include "yaffs_packedtags2.h" - --#include "yramsim.h" - - #include "yaffs_trace.h" - #include "yaffsfs.h" -@@ -216,8 +215,8 @@ struct yaffs_dev * - yaffs_add_dev_from_geometry(const YCHAR *name, - const ynandif_Geometry *geometry) - { -- YCHAR *clonedName = malloc(sizeof(YCHAR) * (strnlen(name,YAFFS_MAX_NAME_LENGTH)+1)); -- struct yaffs_dev *dev = malloc(sizeof(struct yaffs_dev)); -+ YCHAR *clonedName = kmalloc(sizeof(YCHAR) * (strnlen(name,YAFFS_MAX_NAME_LENGTH)+1), GFP_NOFS); -+ struct yaffs_dev *dev = kmalloc(sizeof(struct yaffs_dev), GFP_NOFS); - - if(dev && clonedName){ - memset(dev,0,sizeof(struct yaffs_dev)); -@@ -242,16 +241,17 @@ struct yaffs_dev * - dev->param.n_reserved_blocks = 5; - dev->driver_context = (void *)geometry; - -+ /* save rt_mtd_nand_device * dev*/ -+ dev->os_context = (void *)(geometry->privateData); - yaffs_add_device(dev); - - return dev; - } - - if(dev) -- free(dev); -+ kfree(dev); - if(clonedName) -- free(clonedName); -+ kfree(clonedName); - - return NULL; - } -- -diff --git a/yaffs/direct/ydirectenv.h b/yaffs/direct/ydirectenv.h -index 7860b84..5add3ec 100644 ---- a/yaffs/direct/ydirectenv.h -+++ b/yaffs/direct/ydirectenv.h -@@ -22,16 +22,13 @@ - - // Direct interface - --#include "stdlib.h" --#include "stdio.h" -+#include <rtthread.h> - #include "string.h" -+ - #include "yaffs_osglue.h" - #include "yaffs_hweight.h" - --#include "assert.h" --#define BUG() assert(0) --//#define BUG() do { *((int *)0) =1;} while(0) -- -+#define BUG() RT_ASSERT(0) - - #define YCHAR char - #define YUCHAR unsigned char -@@ -47,30 +44,24 @@ void yaffs_qsort(void *aa, size_t n, size_t es, - - #define YAFFS_PATH_DIVIDERS "/" - --#ifdef NO_inline --#define inline --#else --#define inline __inline__ --#endif -- --#define kmalloc(x,flags) yaffsfs_malloc(x) -+#define GFP_NOFS 0 -+#define kmalloc(x, y) yaffsfs_malloc(x) - #define kfree(x) yaffsfs_free(x) - #define vmalloc(x) yaffsfs_malloc(x) --#define vfree(x) yaffsfs_free(x) -+#define vfree(x) yaffsfs_free(x) -+#define printf rt_kprintf - - #define cond_resched() do {} while(0) - - #define yaffs_trace(msk, fmt, ...) do { \ - if(yaffs_trace_mask & (msk)) \ -- printf("yaffs: " fmt "\n", ##__VA_ARGS__); \ -+ rt_kprintf("yaffs: " fmt "\n", ##__VA_ARGS__); \ - } while(0) - - - #define YAFFS_LOSTNFOUND_NAME "lost+found" - #define YAFFS_LOSTNFOUND_PREFIX "obj" - --#include "yaffscfg.h" -- - #define Y_CURRENT_TIME yaffsfs_CurrentTime() - #define Y_TIME_CONVERT(x) x - -@@ -79,8 +70,6 @@ void yaffs_qsort(void *aa, size_t n, size_t es, - - #include "yaffs_list.h" - --#include "yaffsfs.h" -- - #endif - - -diff --git a/yaffs/direct/yportenv.h b/yaffs/direct/yportenv.h -index 939cd3a..f693c16 100644 ---- a/yaffs/direct/yportenv.h -+++ b/yaffs/direct/yportenv.h -@@ -17,36 +17,146 @@ - #ifndef __YPORTENV_H__ - #define __YPORTENV_H__ - -+#include <dfs_posix.h> -+ -+#define CONFIG_YAFFS_DIRECT -+#define CONFIG_YAFFS_PROVIDE_DEFS -+#define CONFIG_YAFFSFS_PROVIDE_VALUES -+ -+#ifdef NO_inline -+ #define inline -+#else -+ #ifdef __CC_ARM -+ #define inline __inline -+ #elif defined (__GNUC__) /* GNU GCC Compiler */ -+ #define inline __inline -+ #else -+ #error "Please set a macro inline with a valid args" -+ #endif -+#endif -+ -+#if defined(__CC_ARM) -+ #ifdef RT_USING_NEWLIB -+ #error "error: when use armcc, please Don't USE NEWLIB!!!" -+ #endif -+ -+ #ifndef off_t -+ typedef long off_t; -+ #endif -+ -+ #ifndef loff_t -+ typedef unsigned long loff_t; -+ #endif -+ -+ #ifndef dev_t -+ typedef long dev_t; -+ #endif -+ -+ #ifndef mode_t -+ typedef int mode_t; -+ #endif -+ -+ /* just like strlen(3), but cap the number of bytes we count */ -+ rt_inline size_t strnlen(const char *s, size_t max) { -+ register const char *p; -+ for(p = s; *p && max--; ++p); -+ return(p - s); -+ } -+ -+#elif defined (__GNUC__) && !defined(__CC_ARM) -+ -+ #ifndef loff_t -+ typedef unsigned long loff_t; -+ #endif -+ -+ #ifndef dev_t -+ typedef long dev_t; -+ #endif -+#endif - - /* Definition of types */ - typedef unsigned char u8; - typedef unsigned short u16; - typedef unsigned u32; -- -- --#ifndef WIN32 --#include <sys/stat.h> --#endif -- -+ -+#ifndef S_ISDIR -+ #ifndef _DEV_T_DEFINED -+ typedef unsigned int _dev_t; /* device code */ -+ #if !__STDC__ -+ /* Non-ANSI name for compatibility */ -+ typedef unsigned int dev_t; -+ #endif -+ -+ #define _DEV_T_DEFINED -+ #endif -+ -+ #define __S_IFMT 0170000 /* These bits determine file type. */ -+ /* File types. */ -+ #define __S_IFDIR 0040000 /* Directory. */ -+ #define __S_IFCHR 0020000 /* Character device. */ -+ #define __S_IFBLK 0060000 /* Block device. */ -+ #define __S_IFREG 0100000 /* Regular file. */ -+ #define __S_IFIFO 0010000 /* FIFO. */ -+ #define __S_IFLNK 0120000 /* Symbolic link. */ -+ #define __S_IFSOCK 0140000 /* Socket. */ -+ -+ /* Protection bits. */ -+ #define __S_ISUID 04000 /* Set user ID on execution. */ -+ #define __S_ISGID 02000 /* Set group ID on execution. */ -+ #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */ -+ #define __S_IREAD 0400 /* Read by owner. */ -+ #define __S_IWRITE 0200 /* Write by owner. */ -+ #define __S_IEXEC 0100 /* Execute by owner. */ -+ #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask)) -+ -+ #define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR) -+ #define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR) -+ #define S_ISBLK(mode) __S_ISTYPE((mode), __S_IFBLK) -+ #define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG) -+ #define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK) -+ #define S_ISFIFO(mode) __S_ISTYPE((mode), __S_IFSOCK) -+ #define S_IRUSR __S_IREAD // Read by owner. -+ #define S_IWUSR __S_IWRITE // Write by owner. -+ #define S_IXUSR __S_IEXEC // Execute by owner. -+ #define S_IREAD S_IRUSR -+ #define S_IWRITE S_IWUSR -+ #define S_IEXEC S_IXUSR -+ #define S_IFDIR __S_IFDIR -+#endif - - #ifdef CONFIG_YAFFS_PROVIDE_DEFS - /* File types */ - -+#ifndef DT_UNKNOWN -+ #define DT_UNKNOWN 0 -+#endif -+#ifndef DT_FIFO -+ #define DT_FIFO 1 -+#endif - --#define DT_UNKNOWN 0 --#define DT_FIFO 1 --#define DT_CHR 2 --#define DT_DIR 4 --#define DT_BLK 6 --#define DT_REG 8 --#define DT_LNK 10 --#define DT_SOCK 12 --#define DT_WHT 14 -- -+#ifndef DT_CHR -+ #define DT_CHR 2 -+#endif - --#ifndef WIN32 --#include <sys/stat.h> -+#ifndef DT_DIR -+ #define DT_DIR 4 -+#endif -+#ifndef DT_BLK -+ #define DT_BLK 6 -+#endif -+#ifndef DT_REG -+ #define DT_REG 8 - #endif -+#ifndef DT_LNK -+ #define DT_LNK 10 -+#endif -+#ifndef DT_SOCK -+ #define DT_SOCK 12 -+#endif -+#ifndef DT_WHT -+ #define DT_WHT 14 -+#endif -+ - - /* - * Attribute flags. -@@ -75,7 +185,6 @@ struct iattr { - #endif - - -- - #if defined CONFIG_YAFFS_WINCE - - #include "ywinceenv.h" -@@ -267,9 +376,17 @@ struct iattr { - #endif - - #else --#include <errno.h> --#include <sys/stat.h> --#include <fcntl.h> -+//#include <errno.h> -+//#include <sys/stat.h> -+//#include <fcntl.h> -+#ifndef XATTR_CREATE -+#define XATTR_CREATE 1 -+#endif -+ -+#ifndef XATTR_REPLACE -+#define XATTR_REPLACE 2 -+#endif -+ - #endif - - #endif -diff --git a/yaffs_nandcfg.c b/yaffs_nandcfg.c -new file mode 100644 -index 0000000..099fa38 ---- /dev/null -+++ b/yaffs_nandcfg.c -@@ -0,0 +1,149 @@ -+#include <rtthread.h> -+#include <rtdevice.h> -+#include <dfs_fs.h> -+#include <dfs_def.h> -+ -+#include "yaffsfs.h" -+#include "yaffs_nandif.h" -+#include "yaffs_trace.h" -+ -+/* -+ * RT-Thread Device Interface for yaffs -+ */ -+static int nand_init(struct yaffs_dev *dev) -+{ -+ return YAFFS_OK; -+} -+ -+static int nand_deinit(struct yaffs_dev *dev) -+{ -+ return YAFFS_OK; -+} -+ -+/* if block is good, return YAFFS_OK, else return YAFFS_FAIL */ -+static int nand_checkblock(struct yaffs_dev *dev, unsigned block) -+{ -+ rt_err_t res; -+ res = rt_mtd_nand_check_block(RT_MTD_NAND_DEVICE(dev->os_context), block); -+ return res == RT_EOK ? YAFFS_OK : YAFFS_FAIL; -+} -+static int nand_markbadblk(struct yaffs_dev *dev, unsigned block) -+{ -+ rt_err_t res; -+ res = rt_mtd_nand_mark_badblock(RT_MTD_NAND_DEVICE(dev->os_context), block); -+ return res == RT_EOK ? YAFFS_OK : YAFFS_FAIL; -+} -+ -+static int nand_eraseblock(struct yaffs_dev *dev, unsigned block) -+{ -+ int res; -+ res = rt_mtd_nand_erase_block(RT_MTD_NAND_DEVICE(dev->os_context), block); -+ return res == RT_EOK ? YAFFS_OK : YAFFS_FAIL; -+} -+ -+static int nand_readpage( -+ struct yaffs_dev *dev, -+ unsigned page, -+ unsigned char *data, unsigned data_len, /* page data */ -+ unsigned char *spare, unsigned spare_len,/* page spare */ -+ int *ecc_status) -+{ -+ int res; -+ unsigned char spare_buf[64]; -+ -+ res = rt_mtd_nand_read(RT_MTD_NAND_DEVICE(dev->os_context), -+ page, data, data_len, spare_buf, spare_len + 5); -+ rt_memcpy(spare, spare_buf + 5, spare_len); -+ if (res == 0) -+ *ecc_status = 0; -+ else if (res == -1) -+ *ecc_status = 1; -+ else -+ *ecc_status = -1; -+ -+ return YAFFS_OK; -+} -+ -+static int nand_writepage( -+ struct yaffs_dev *dev, -+ unsigned page, -+ const unsigned char *data, unsigned data_len, /* page data */ -+ const unsigned char *spare, unsigned spare_len) /* page spare */ -+{ -+ int res; -+ unsigned char spare_buf[64]; //not use malloc, this can be faster -+ rt_memset(spare_buf, 0xFF, sizeof(spare_buf)); -+ rt_memcpy(spare_buf+5, spare, spare_len); -+ -+ res = rt_mtd_nand_write(RT_MTD_NAND_DEVICE(dev->os_context), -+ page, data, data_len, spare_buf, spare_len + 5); -+ if (res != RT_EOK) -+ goto __error; -+ -+ return YAFFS_OK; -+ -+__error: -+ return YAFFS_FAIL; -+} -+ -+ -+/* -+ * yaffs2 configuration -+ */ -+#define CONFIG_YAFFS_ECC_MODE 1 //1 use ecc, 0 no ecc -+#define CONFIG_YAFFS_INBAND_TAGS 0 //1 use in band tags, 0-no in band tags -+#define CONFIG_YAFFS_USE_YAFFS2 1 //1 yaffs2, 0-yaffs1 -+ -+void yaffs_config(ynandif_Geometry * g, struct rt_mtd_nand_device * dev) -+{ -+ rt_memset(g,0,sizeof(ynandif_Geometry)); -+ -+ g->start_block = dev->block_start; -+ g->end_block = dev->block_end; -+ g->dataSize = dev->page_size; -+ g->spareSize = dev->oob_size; -+ g->pagesPerBlock = dev->block_size / dev->page_size; -+ -+ g->hasECC = CONFIG_YAFFS_ECC_MODE; -+ g->inband_tags = CONFIG_YAFFS_INBAND_TAGS; -+ g->useYaffs2 = CONFIG_YAFFS_USE_YAFFS2; -+ -+ g->privateData = dev;//will be copy to dev->os_context. -+ -+ g->initialise = nand_init; -+ g->deinitialise = nand_deinit; -+ g->readChunk = nand_readpage; -+ g->writeChunk = nand_writepage; -+ g->eraseBlock = nand_eraseblock; -+ g->checkBlockOk = nand_checkblock; -+ g->markBlockBad = nand_markbadblk; -+} -+ -+static struct yaffs_dev *ynand_CreatePart(const YCHAR *name, ynandif_Geometry * g) -+{ -+ return yaffs_add_dev_from_geometry(name, g); -+} -+ -+/* configuration for yaffs's log */ -+unsigned yaffs_trace_mask = -+ -+ YAFFS_TRACE_SCAN | -+ YAFFS_TRACE_GC | -+ YAFFS_TRACE_ERASE | -+ YAFFS_TRACE_ERROR | -+ YAFFS_TRACE_TRACING | -+ YAFFS_TRACE_ALLOCATE | -+ YAFFS_TRACE_BAD_BLOCKS | -+ YAFFS_TRACE_VERIFY | -+ -+ 0; -+ -+int yaffs_start(const char * mount_point, ynandif_Geometry * g) -+{ -+ // Stuff to configure YAFFS -+ // Stuff to initialise anything special (eg lock semaphore). -+ yaffsfs_OSInitialisation(); -+ ynand_CreatePart(mount_point, g); -+ -+ return 0; -+} -diff --git a/yaffs_osglue.c b/yaffs_osglue.c -new file mode 100644 -index 0000000..2c34f99 ---- /dev/null -+++ b/yaffs_osglue.c -@@ -0,0 +1,118 @@ -+/* -+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. -+ * -+ * Copyright (C) 2002-2011 Aleph One Ltd. -+ * for Toby Churchill Ltd and Brightstar Engineering -+ * -+ * Created by Charles Manning <[email protected]> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. -+ */ -+ -+ -+#include "yaffscfg.h" -+#include "yaffs_guts.h" -+#include "yaffsfs.h" -+#include "yaffs_trace.h" -+#include <rtthread.h> -+ -+//#include <errno.h> -+ -+ -+static int yaffsfs_lastError; -+ -+void yaffsfs_SetError(int err) -+{ -+ //Do whatever to set error -+ yaffsfs_lastError = err; -+} -+ -+int yaffsfs_GetLastError(void) -+{ -+ return yaffsfs_lastError; -+} -+ -+ -+#ifdef CONFIG_YAFFS_USE_PTHREADS -+#include <pthread.h> -+static pthread_mutex_t mutex1; -+ -+ -+void yaffsfs_Lock(void) -+{ -+ pthread_mutex_lock( &mutex1 ); -+} -+ -+void yaffsfs_Unlock(void) -+{ -+ pthread_mutex_unlock( &mutex1 ); -+} -+ -+void yaffsfs_LockInit(void) -+{ -+ pthread_mutex_init( &mutex1, NULL); -+} -+ -+#else -+ -+static rt_mutex_t mutex = RT_NULL; -+static rt_sem_t sem = RT_NULL; -+void yaffsfs_Lock(void) -+{ -+ rt_mutex_take(mutex, RT_WAITING_FOREVER); -+} -+ -+void yaffsfs_Unlock(void) -+{ -+ rt_mutex_release(mutex); -+} -+ -+void yaffsfs_LockInit(void) -+{ -+ mutex = rt_mutex_create("mutex", RT_IPC_FLAG_FIFO); -+ if (mutex == RT_NULL) -+ { -+ yaffs_trace(YAFFS_TRACE_ERROR, -+ "**>> yaffs error :yaffs_LockInit can't get a mutex!"); -+ } -+ -+} -+#endif -+ -+u32 yaffsfs_CurrentTime(void) -+{ -+ return 0; -+} -+ -+ -+static int yaffs_kill_alloc = 0; -+static size_t total_malloced = 0; -+static size_t malloc_limit = 0 & 6000000; -+ -+void *yaffsfs_malloc(size_t size) -+{ -+ void * this; -+ if(yaffs_kill_alloc) -+ return NULL; -+ if(malloc_limit && malloc_limit <(total_malloced + size) ) -+ return NULL; -+ -+ this = rt_malloc(size); -+ if(this) -+ total_malloced += size; -+ return this; -+} -+ -+void yaffsfs_free(void *ptr) -+{ -+ rt_free(ptr); -+} -+ -+void yaffsfs_OSInitialisation(void) -+{ -+ yaffsfs_LockInit(); -+} -+ -+ |
