应用层代码:source\lib\libnvram\nvram_env.c
mtd层代码:source\linux-2.6.36.x\arch\mips\ralink\nvram.c
数据结构
typedef struct block_s {
char *name;
env_t env; //env block
cache_t cache[MAX_CACHE_ENTRY]; //env cache entry by entry
unsigned long flash_offset;
unsigned long flash_max_len; //ENV_BLK_SIZE
char valid;
char dirty;
} block_t;
typedef struct cache_environment_s {
char *name;
char *value;
} cache_t;
typedef struct environment_s {
unsigned long crc; //CRC32 over data bytes
char *data;
} env_t;
流程
应用 -----------------------------------------内核 -----------------------flash
ralink_init.c-----nvram_env.c----------------nvram.c--------------------flash
内核函数:
ioctl
int ralink_nvram_ioctl(struct inode *inode, struct file *file, unsigned int req,
unsigned long arg)
{
switch (req) {
case RALINK_NVRAM_IO