From a1519350a4caa3b5d081f254398cf9a2655c6f85 Mon Sep 17 00:00:00 2001 From: "sc943313837@gmail.com" Date: Sat, 15 Sep 2012 12:23:04 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3move=5Fpage?= =?UTF-8?q?,=E6=B7=BB=E5=8A=A0mtd=5Fnand=E6=88=90=E5=91=98oob=5Ffree?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=94=B9=E6=88=90=E5=91=98block=5Fsize?= =?UTF-8?q?=E4=B8=BApages=5Fper=5Fblock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2288 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/drivers/include/drivers/mtd_nand.h | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/components/drivers/include/drivers/mtd_nand.h b/components/drivers/include/drivers/mtd_nand.h index 320bede8fb..d9d17194e4 100644 --- a/components/drivers/include/drivers/mtd_nand.h +++ b/components/drivers/include/drivers/mtd_nand.h @@ -25,15 +25,22 @@ struct rt_mtd_nand_driver_ops; #define RT_MTD_NAND_DEVICE(device) ((struct rt_mtd_nand_device*)(device)) +#define RT_MTD_EOK 0 +#define RT_MTD_EECC 1 +#define RT_MTD_EBUSY 2 +#define RT_MTD_EIO 3 +#define RT_MTD_ENOMEM 4 + struct rt_mtd_nand_device { struct rt_device parent; rt_uint32_t page_size; /* The Page size in the flash */ - rt_uint32_t block_size; /* The Block size in the flash */ - - rt_uint16_t oob_size; /* Out of bank size */ - rt_uint16_t reserve; + rt_uint16_t oob_size; /* Out of bank size */ + rt_uint16_t oob_free; /* the free area in oob that flash driver not use */ + + rt_uint32_t pages_per_block; /* The number of page a block */ + rt_uint16_t block_total; rt_uint32_t block_start; /* The start of available block*/ rt_uint32_t block_end; /* The end of available block */ @@ -55,6 +62,7 @@ struct rt_mtd_nand_driver_ops rt_off_t page, const rt_uint8_t * data, rt_uint32_t data_len, const rt_uint8_t * spare, rt_uint32_t spare_len); + rt_err_t (*move_page) (struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page); rt_err_t (*erase_block)(struct rt_mtd_nand_device* device, rt_uint32_t block); rt_err_t (*check_block)(struct rt_mtd_nand_device* device, rt_uint32_t block); @@ -86,6 +94,12 @@ rt_inline rt_err_t rt_mtd_nand_write( return device->ops->write_page(device, page, data, data_len, spare, spare_len); } +rt_inline rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device* device, + rt_off_t src_page, rt_off_t dst_page) +{ + return device->ops->move_page(device, src_page, dst_page); +} + rt_inline rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device* device, rt_uint32_t block) { return device->ops->erase_block(device, block);