mtd/nand: Fix the comment and remove the uneeded inclusion
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
25a1191763
commit
3c54e66683
@ -437,8 +437,8 @@ static int nand_rawwrite(struct nand_raw_s *raw, off_t block,
|
|||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
DEBUGASSERT(raw);
|
DEBUGASSERT(raw);
|
||||||
finfo("block=%d page=%d data=%p spare=%p\n",
|
finfo("block=%" PRIdOFF " page=%d data=%p spare=%p\n",
|
||||||
(int)block, page, data, spare);
|
block, page, data, spare);
|
||||||
|
|
||||||
/* Get page and spare sizes */
|
/* Get page and spare sizes */
|
||||||
|
|
||||||
|
@ -1945,8 +1945,8 @@ static int nand_readpage_noecc(struct sam_nandcs_s *priv, off_t block,
|
|||||||
off_t coladdr;
|
off_t coladdr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
finfo("block=%d page=%d data=%p spare=%p\n",
|
finfo("block=%" PRIdOFF " page=%d data=%p spare=%p\n",
|
||||||
(int)block, page, data, spare);
|
block, page, data, spare);
|
||||||
DEBUGASSERT(priv && (data || spare));
|
DEBUGASSERT(priv && (data || spare));
|
||||||
|
|
||||||
/* Get page and spare sizes */
|
/* Get page and spare sizes */
|
||||||
@ -2190,8 +2190,8 @@ static int nand_writepage_noecc(struct sam_nandcs_s *priv, off_t block,
|
|||||||
off_t rowaddr;
|
off_t rowaddr;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
finfo("block=%d page=%d data=%p spare=%p\n",
|
finfo("block=%" PRIdOFF " page=%d data=%p spare=%p\n",
|
||||||
(int)block, page, data, spare);
|
block, page, data, spare);
|
||||||
|
|
||||||
/* Get page and spare sizes */
|
/* Get page and spare sizes */
|
||||||
|
|
||||||
|
@ -37,9 +37,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
@ -372,7 +370,8 @@ static int hamming_verify256(FAR uint8_t *data, FAR const uint8_t *original)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void hamming_compute256x(FAR const uint8_t *data, size_t size, uint8_t *code)
|
void hamming_compute256x(FAR const uint8_t *data, size_t size,
|
||||||
|
FAR uint8_t *code)
|
||||||
{
|
{
|
||||||
ssize_t remaining = (ssize_t)size;
|
ssize_t remaining = (ssize_t)size;
|
||||||
DEBUGASSERT((size & 0xff) == 0);
|
DEBUGASSERT((size & 0xff) == 0);
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
|
||||||
|
|
||||||
#include <nuttx/mtd/nand_scheme.h>
|
#include <nuttx/mtd/nand_scheme.h>
|
||||||
#include <nuttx/mtd/nand_model.h>
|
#include <nuttx/mtd/nand_model.h>
|
||||||
@ -49,8 +48,8 @@
|
|||||||
/* List of NandFlash models which can be recognized by the software */
|
/* List of NandFlash models which can be recognized by the software */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ID OPTIONS PAGE SPARE DEV BLOCK | SCHEME
|
* ID OPTIONS PAGE SPARE DEV BLOCK | SCHEME
|
||||||
* SIZE SIZE SIZE SIZE |
|
* SIZE SIZE SIZE SIZE |
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
const struct nand_model_s g_nandmodels[NAND_NMODELS] =
|
const struct nand_model_s g_nandmodels[NAND_NMODELS] =
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
#include <nuttx/mtd/nand_config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -48,12 +46,9 @@
|
|||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/ioctl.h>
|
#include <nuttx/fs/ioctl.h>
|
||||||
#include <nuttx/mtd/mtd.h>
|
|
||||||
#include <nuttx/mtd/nand.h>
|
#include <nuttx/mtd/nand.h>
|
||||||
#include <nuttx/mtd/onfi.h>
|
#include <nuttx/mtd/onfi.h>
|
||||||
#include <nuttx/mtd/nand_raw.h>
|
|
||||||
#include <nuttx/mtd/nand_scheme.h>
|
#include <nuttx/mtd/nand_scheme.h>
|
||||||
#include <nuttx/mtd/nand_model.h>
|
|
||||||
#include <nuttx/mtd/nand_ecc.h>
|
#include <nuttx/mtd/nand_ecc.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -88,24 +83,24 @@ static int nand_devscan(FAR struct nand_dev_s *nand);
|
|||||||
|
|
||||||
/* Misc. NAND helpers */
|
/* Misc. NAND helpers */
|
||||||
|
|
||||||
static uint32_t nand_chipid(struct nand_raw_s *raw);
|
static uint32_t nand_chipid(FAR struct nand_raw_s *raw);
|
||||||
static int nand_eraseblock(FAR struct nand_dev_s *nand,
|
static int nand_eraseblock(FAR struct nand_dev_s *nand,
|
||||||
off_t block, bool scrub);
|
off_t block, bool scrub);
|
||||||
static int nand_readpage(FAR struct nand_dev_s *nand, off_t block,
|
static int nand_readpage(FAR struct nand_dev_s *nand, off_t block,
|
||||||
unsigned int page, FAR uint8_t *data);
|
unsigned int page, FAR uint8_t *data);
|
||||||
static int nand_writepage(FAR struct nand_dev_s *nand, off_t block,
|
static int nand_writepage(FAR struct nand_dev_s *nand, off_t block,
|
||||||
unsigned int page, FAR const void *data);
|
unsigned int page, FAR const void *data);
|
||||||
|
|
||||||
/* MTD driver methods */
|
/* MTD driver methods */
|
||||||
|
|
||||||
static int nand_erase(struct mtd_dev_s *dev, off_t startblock,
|
static int nand_erase(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||||
size_t nblocks);
|
size_t nblocks);
|
||||||
static ssize_t nand_bread(struct mtd_dev_s *dev, off_t startblock,
|
static ssize_t nand_bread(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||||
size_t nblocks, uint8_t *buffer);
|
size_t nblocks, uint8_t *buffer);
|
||||||
static ssize_t nand_bwrite(struct mtd_dev_s *dev, off_t startblock,
|
static ssize_t nand_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||||
size_t nblocks, const uint8_t *buffer);
|
size_t nblocks, const uint8_t *buffer);
|
||||||
static int nand_ioctl(struct mtd_dev_s *dev, int cmd,
|
static int nand_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
||||||
unsigned long arg);
|
unsigned long arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@ -214,8 +209,8 @@ static int nand_devscan(FAR struct nand_dev_s *nand)
|
|||||||
off_t nblocks;
|
off_t nblocks;
|
||||||
off_t block;
|
off_t block;
|
||||||
#if defined(CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS)
|
#if defined(CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS)
|
||||||
off_t good;
|
off_t good = 0;
|
||||||
unsigned int ngood;
|
unsigned int ngood = 0;
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -234,10 +229,6 @@ static int nand_devscan(FAR struct nand_dev_s *nand)
|
|||||||
|
|
||||||
/* Retrieve block status from their first page spare area */
|
/* Retrieve block status from their first page spare area */
|
||||||
|
|
||||||
#if defined(CONFIG_DEBUG_INFO) && defined(CONFIG_DEBUG_FS)
|
|
||||||
ngood = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (block = 0; block < nblocks; block++)
|
for (block = 0; block < nblocks; block++)
|
||||||
{
|
{
|
||||||
/* Read spare of first page */
|
/* Read spare of first page */
|
||||||
@ -301,7 +292,7 @@ static int nand_devscan(FAR struct nand_dev_s *nand)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static uint32_t nand_chipid(struct nand_raw_s *raw)
|
static uint32_t nand_chipid(FAR struct nand_raw_s *raw)
|
||||||
{
|
{
|
||||||
uint8_t id[5];
|
uint8_t id[5];
|
||||||
|
|
||||||
@ -512,7 +503,7 @@ static int nand_writepage(FAR struct nand_dev_s *nand, off_t block,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int nand_erase(struct mtd_dev_s *dev, off_t startblock,
|
static int nand_erase(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||||
size_t nblocks)
|
size_t nblocks)
|
||||||
{
|
{
|
||||||
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
||||||
@ -552,7 +543,7 @@ static int nand_erase(struct mtd_dev_s *dev, off_t startblock,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t nand_bread(struct mtd_dev_s *dev, off_t startpage,
|
static ssize_t nand_bread(FAR struct mtd_dev_s *dev, off_t startpage,
|
||||||
size_t npages, FAR uint8_t *buffer)
|
size_t npages, FAR uint8_t *buffer)
|
||||||
{
|
{
|
||||||
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
||||||
@ -571,8 +562,8 @@ static ssize_t nand_bread(struct mtd_dev_s *dev, off_t startpage,
|
|||||||
|
|
||||||
/* Retrieve the model */
|
/* Retrieve the model */
|
||||||
|
|
||||||
raw = nand->raw;
|
raw = nand->raw;
|
||||||
model = &raw->model;
|
model = &raw->model;
|
||||||
|
|
||||||
/* Get the number of pages in one block, the size of one page, and
|
/* Get the number of pages in one block, the size of one page, and
|
||||||
* the number of blocks on the device.
|
* the number of blocks on the device.
|
||||||
@ -648,7 +639,7 @@ errout_with_lock:
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t nand_bwrite(struct mtd_dev_s *dev, off_t startpage,
|
static ssize_t nand_bwrite(FAR struct mtd_dev_s *dev, off_t startpage,
|
||||||
size_t npages, const uint8_t *buffer)
|
size_t npages, const uint8_t *buffer)
|
||||||
{
|
{
|
||||||
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
||||||
@ -667,8 +658,8 @@ static ssize_t nand_bwrite(struct mtd_dev_s *dev, off_t startpage,
|
|||||||
|
|
||||||
/* Retrieve the model */
|
/* Retrieve the model */
|
||||||
|
|
||||||
raw = nand->raw;
|
raw = nand->raw;
|
||||||
model = &raw->model;
|
model = &raw->model;
|
||||||
|
|
||||||
/* Get the number of pages in one block, the size of one page, and
|
/* Get the number of pages in one block, the size of one page, and
|
||||||
* the number of blocks on the device.
|
* the number of blocks on the device.
|
||||||
@ -740,7 +731,7 @@ errout_with_lock:
|
|||||||
* Name: nand_ioctl
|
* Name: nand_ioctl
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int nand_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
static int nand_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
FAR struct nand_dev_s *nand = (FAR struct nand_dev_s *)dev;
|
||||||
FAR struct nand_raw_s *raw;
|
FAR struct nand_raw_s *raw;
|
||||||
@ -755,7 +746,7 @@ static int nand_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
{
|
{
|
||||||
case MTDIOC_GEOMETRY:
|
case MTDIOC_GEOMETRY:
|
||||||
{
|
{
|
||||||
FAR struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
|
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
|
||||||
if (geo)
|
if (geo)
|
||||||
{
|
{
|
||||||
memset(geo, 0, sizeof(*geo));
|
memset(geo, 0, sizeof(*geo));
|
||||||
@ -819,11 +810,6 @@ static int nand_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* raw - Lower-half, raw NAND FLASH interface
|
* raw - Lower-half, raw NAND FLASH interface
|
||||||
* cmdaddr - NAND command address base
|
|
||||||
* addraddr - NAND address address base
|
|
||||||
* dataaddr - NAND data address
|
|
||||||
* model - A pointer to the model data (probably in the raw MTD
|
|
||||||
* driver instance.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* A non-NULL MTD driver instance is returned on success. NULL is
|
* A non-NULL MTD driver instance is returned on success. NULL is
|
||||||
@ -919,7 +905,7 @@ FAR struct mtd_dev_s *nand_initialize(FAR struct nand_raw_s *raw)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable any internal, embedded ECC function */
|
/* Enable any internal, embedded ECC function */
|
||||||
|
|
||||||
onfi_embeddedecc(&onfi, raw->cmdaddr, raw->addraddr, raw->dataaddr,
|
onfi_embeddedecc(&onfi, raw->cmdaddr, raw->addraddr, raw->dataaddr,
|
||||||
true);
|
true);
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
#include <nuttx/mtd/nand_config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -90,11 +88,8 @@ int nandecc_readpage(FAR struct nand_dev_s *nand, off_t block,
|
|||||||
unsigned int sparesize;
|
unsigned int sparesize;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
finfo("block=%d page=%d data=%p spare=%d\n",
|
finfo("block=%" PRIdOFF " page=%d data=%p spare=%p\n",
|
||||||
(int)block,
|
block, page, data, spare);
|
||||||
page,
|
|
||||||
data,
|
|
||||||
spare);
|
|
||||||
|
|
||||||
/* Get convenience pointers */
|
/* Get convenience pointers */
|
||||||
|
|
||||||
@ -122,7 +117,7 @@ int nandecc_readpage(FAR struct nand_dev_s *nand, off_t block,
|
|||||||
ret = NAND_RAWREAD(raw, block, page, 0, spare);
|
ret = NAND_RAWREAD(raw, block, page, 0, spare);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to read page:d\n", ret);
|
ferr("ERROR: Failed to read page:%d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +126,7 @@ int nandecc_readpage(FAR struct nand_dev_s *nand, off_t block,
|
|||||||
ret = NAND_RAWREAD(nand->raw, block, page, data, 0);
|
ret = NAND_RAWREAD(nand->raw, block, page, data, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to read page:d\n", ret);
|
ferr("ERROR: Failed to read page:%d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,11 +181,8 @@ int nandecc_writepage(FAR struct nand_dev_s *nand, off_t block,
|
|||||||
unsigned int sparesize;
|
unsigned int sparesize;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
finfo("block=%d page=%d data=%p spare=%d\n",
|
finfo("block=%" PRIdOFF " page=%d data=%p spare=%p\n",
|
||||||
(int)block,
|
block, page, data, spare);
|
||||||
page,
|
|
||||||
data,
|
|
||||||
spare);
|
|
||||||
|
|
||||||
/* Get convenience pointers */
|
/* Get convenience pointers */
|
||||||
|
|
||||||
@ -236,7 +228,7 @@ int nandecc_writepage(FAR struct nand_dev_s *nand, off_t block,
|
|||||||
ret = NAND_RAWWRITE(nand->raw, block, page, data, spare);
|
ret = NAND_RAWWRITE(nand->raw, block, page, data, spare);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to write page:d\n", ret);
|
ferr("ERROR: Failed to write page:%d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -37,15 +37,11 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/mtd/nand.h>
|
|
||||||
#include <nuttx/mtd/nand_model.h>
|
#include <nuttx/mtd/nand_model.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -155,6 +151,7 @@ int nandmodel_find(FAR const struct nand_model_s *modeltab, size_t size,
|
|||||||
finfo(" pagesize: %d (B)\n", model->pagesize);
|
finfo(" pagesize: %d (B)\n", model->pagesize);
|
||||||
finfo(" options: 0x%02x\n", model->options);
|
finfo(" options: 0x%02x\n", model->options);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,13 +178,13 @@ int nandmodel_find(FAR const struct nand_model_s *modeltab, size_t size,
|
|||||||
* offset Stores the byte offset inside the first accessed page.
|
* offset Stores the byte offset inside the first accessed page.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; -EPIPE on failure.
|
* OK on success; -ESPIPE on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nandmodel_translate(FAR const struct nand_model_s *model, off_t address,
|
int nandmodel_translate(FAR const struct nand_model_s *model, off_t address,
|
||||||
size_t size, FAR off_t *block, off_t *page,
|
size_t size, FAR off_t *block, FAR off_t *page,
|
||||||
off_t *offset)
|
FAR off_t *offset)
|
||||||
{
|
{
|
||||||
size_t blocksize;
|
size_t blocksize;
|
||||||
size_t pagesize;
|
size_t pagesize;
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -46,7 +45,7 @@
|
|||||||
#include <nuttx/mtd/nand_scheme.h>
|
#include <nuttx/mtd/nand_scheme.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Spare area placement scheme for 256 byte pages */
|
/* Spare area placement scheme for 256 byte pages */
|
||||||
@ -134,7 +133,7 @@ void nandscheme_readbadblockmarker(FAR const struct nand_scheme_s *scheme,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nandscheme_readbadblockmarker
|
* Name: nandscheme_writebadblockmarker
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Modifies the bad block marker inside a spare area, using the given
|
* Modifies the bad block marker inside a spare area, using the given
|
||||||
@ -233,18 +232,18 @@ void nandscheme_readextra(FAR const struct nand_scheme_s *scheme,
|
|||||||
FAR const uint8_t *spare, FAR void *extra,
|
FAR const uint8_t *spare, FAR void *extra,
|
||||||
unsigned int size, unsigned int offset)
|
unsigned int size, unsigned int offset)
|
||||||
{
|
{
|
||||||
DEBUGASSERT((size + offset) < scheme->nxbytes);
|
DEBUGASSERT((size + offset) <= scheme->nxbytes);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
((uint8_t *)extra)[i] = spare[scheme->xbytepos[i + offset]];
|
((FAR uint8_t *)extra)[i] = spare[scheme->xbytepos[i + offset]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nandscheme_readextra
|
* Name: nandscheme_writeextra
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Write extra bytes of information inside a spare area, using the provided
|
* Write extra bytes of information inside a spare area, using the provided
|
||||||
@ -266,17 +265,17 @@ void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme,
|
|||||||
FAR uint8_t *spare, FAR const void *extra,
|
FAR uint8_t *spare, FAR const void *extra,
|
||||||
unsigned int size, unsigned int offset)
|
unsigned int size, unsigned int offset)
|
||||||
{
|
{
|
||||||
DEBUGASSERT((size + offset) < scheme->nxbytes);
|
DEBUGASSERT((size + offset) <= scheme->nxbytes);
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
spare[scheme->xbytepos[i + offset]] = ((uint8_t *) extra)[i];
|
spare[scheme->xbytepos[i + offset]] = ((FAR uint8_t *) extra)[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nandscheme_readextra
|
* Name: nandscheme_build4096
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Build a scheme instance for 4096 page size nand flash
|
* Build a scheme instance for 4096 page size nand flash
|
||||||
@ -284,16 +283,14 @@ void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme,
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* scheme Pointer to a nand_scheme_s instance.
|
* scheme Pointer to a nand_scheme_s instance.
|
||||||
* sparesize Size of spare area.
|
* sparesize Size of spare area.
|
||||||
* offset Index where to write the first extra byte.
|
* eccoffset Index where to write the first extra byte.
|
||||||
* size Number of extra bytes to write.
|
|
||||||
* offset Index where to write the first extra byte.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; a negated errno value on failure.
|
* OK on success; a negated errno value on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nandscheme_build4086(FAR struct nand_scheme_s *scheme,
|
int nandscheme_build4096(FAR struct nand_scheme_s *scheme,
|
||||||
unsigned int sparesize, unsigned int eccoffset)
|
unsigned int sparesize, unsigned int eccoffset)
|
||||||
{
|
{
|
||||||
uint8_t eccsize = g_nand_sparescheme4096.eccsize;
|
uint8_t eccsize = g_nand_sparescheme4096.eccsize;
|
||||||
|
@ -37,13 +37,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -95,7 +89,7 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define READ_NAND(a) \
|
#define READ_NAND(a) \
|
||||||
((*(volatile uint8_t *)(uint32_t)a))
|
((*(volatile uint8_t *)(uintptr_t)a))
|
||||||
|
|
||||||
#define WRITE_NAND(d,a) \
|
#define WRITE_NAND(d,a) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -44,9 +44,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <nuttx/mtd/mtd.h>
|
|
||||||
#include <nuttx/mtd/nand_raw.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -108,7 +105,7 @@ extern "C"
|
|||||||
|
|
||||||
void hamming_compute256x(FAR const uint8_t *data,
|
void hamming_compute256x(FAR const uint8_t *data,
|
||||||
size_t size,
|
size_t size,
|
||||||
uint8_t *code);
|
FAR uint8_t *code);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: hamming_verify256x
|
* Name: hamming_verify256x
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/mtd/nand_config.h>
|
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -141,13 +141,13 @@ int nandmodel_find(FAR const struct nand_model_s *modeltab, size_t size,
|
|||||||
* offset Stores the byte offset inside the first accessed page.
|
* offset Stores the byte offset inside the first accessed page.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; -EPIPE on failure.
|
* OK on success; -ESPIPE on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nandmodel_translate(FAR const struct nand_model_s *model, off_t address,
|
int nandmodel_translate(FAR const struct nand_model_s *model, off_t address,
|
||||||
size_t size, FAR off_t *block, off_t *page,
|
size_t size, FAR off_t *block, FAR off_t *page,
|
||||||
off_t *offset);
|
FAR off_t *offset);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nandmodel_getscheme
|
* Name: nandmodel_getscheme
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include <nuttx/mtd/mtd.h>
|
|
||||||
#include <nuttx/mtd/nand_model.h>
|
#include <nuttx/mtd/nand_model.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -112,7 +112,7 @@ void nandscheme_readbadblockmarker(FAR const struct nand_scheme_s *scheme,
|
|||||||
FAR uint8_t *marker);
|
FAR uint8_t *marker);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nandscheme_readbadblockmarker
|
* Name: nandscheme_writebadblockmarker
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Modifies the bad block marker inside a spare area, using the given
|
* Modifies the bad block marker inside a spare area, using the given
|
||||||
@ -263,7 +263,7 @@ void nandscheme_readextra(FAR const struct nand_scheme_s *scheme,
|
|||||||
unsigned int size, unsigned int offset);
|
unsigned int size, unsigned int offset);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nandscheme_readextra
|
* Name: nandscheme_writeextra
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Write extra bytes of information inside a spare area, using the provided
|
* Write extra bytes of information inside a spare area, using the provided
|
||||||
@ -286,7 +286,7 @@ void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme,
|
|||||||
unsigned int size, unsigned int offset);
|
unsigned int size, unsigned int offset);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nandscheme_readextra
|
* Name: nandscheme_build4096
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Build a scheme instance for 4096 page size nand flash
|
* Build a scheme instance for 4096 page size nand flash
|
||||||
@ -294,16 +294,14 @@ void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme,
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* scheme Pointer to a nand_scheme_s instance.
|
* scheme Pointer to a nand_scheme_s instance.
|
||||||
* sparesize Size of spare area.
|
* sparesize Size of spare area.
|
||||||
* offset Index where to write the first extra byte.
|
* eccoffset Index where to write the first ecc byte.
|
||||||
* size Number of extra bytes to write.
|
|
||||||
* offset Index where to write the first extra byte.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; a negated errno value on failure.
|
* OK on success; a negated errno value on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nandscheme_build4086(FAR struct nand_scheme_s *scheme,
|
int nandscheme_build4096(FAR struct nand_scheme_s *scheme,
|
||||||
unsigned int sparesize, unsigned int eccoffset);
|
unsigned int sparesize, unsigned int eccoffset);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
Loading…
Reference in New Issue
Block a user