modify the line break character of yaffs.diff
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2075 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
4fef27fbbc
commit
ff350c4ebc
|
@ -735,73 +735,158 @@ index 939cd3a..f693c16 100644
|
|||
#endif
|
||||
diff --git a/yaffs_nandcfg.c b/yaffs_nandcfg.c
|
||||
new file mode 100644
|
||||
index 0000000..4720aa2
|
||||
index 0000000..099fa38
|
||||
--- /dev/null
|
||||
+++ b/yaffs_nandcfg.c
|
||||
@@ -0,0 +1,64 @@
|
||||
+#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;
}
|
||||
@@ -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;
|
||||
+/*
|
||||
+ * 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
|
||||
|
|
Loading…
Reference in New Issue