bfsAddNandVol()
PROTOTYPE
#include <bfs.h>
void bfsAddNandVol(BfsNandCfg *bfs_cfg);
DESCRIPTION
bfsAddNandVol() registers a NAND flash volume with TargetBFS. bfs_cfg points to a BfsNandCfg structure that defines the volume to TargetBFS. This structure is defined in “bfs.h” and reproduced below:
typedef struct
{
int (*write_page)(ui32 pn, const ui8 *data, int user_data, void *vol);
int (*read_page)(ui32 pn, ui8 *data, void *vol);
int (*erase_block)(ui32 pn, void *vol);
int (*is_metadata)(ui32 pn, void *vol);
int (*is_block_bad)(ui32 pn, void *vol);
void *dev;
} BfsNandCfg;
This structure must be initialized before calling bfsAddNandVol(). write_page, read_page, erase_block, is_metadata, and is_block_bad are pointers to five driver callback functions. These functions are documented elsewhere on this site.
dev is a driver-specific data pointer. The value assigned by the driver is passed back as the last parameter of each driver callback function. It can be used in any way that is convenient for the driver implementation.
EXAMPLE
/***********************************************************************/
/* bfsDriver: TargetBFS-NAND driver */
/* */
/***********************************************************************/
void bfsDriver(void)
{
BfsNandCfg bfs_cfg;
/*-------------------------------------------------------------------*/
/* Initialize driver structure. */
/*-------------------------------------------------------------------*/
bfs_cfg.write_page = write_page;
bfs_cfg.read_page = read_page;
bfs_cfg.erase_block = erase_block;
bfs_cfg.is_metadata = is_metadata;
bfs_cfg.is_block_bad = is_block_bad;
bfs_cfg.dev = NULL;
/*-------------------------------------------------------------------*/
/* Register the volume with the boot file system. */
/*-------------------------------------------------------------------*/
bfsAddNandVol(&bfs_cfg);
}