⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yaffscfg.cpp

📁 文件系统在DSP上的实现
💻 CPP
字号:
/* * YAFFS: Yet another FFS. A NAND-flash specific file system. * yaffscfg.c  The configuration for the "direct" use of yaffs. * * This file is intended to be modified to your requirements. * There is no need to redistribute this file. */#ifdef _WIN32	// 如果是win32系统	#include "stdafx.h"#endif //_WIN32#include "yaffscfg.h"#include "yaffsfs.h"#include <errno.h>#include "sysarch.h"unsigned yaffs_traceMask = 0xFFFFFFFF;TSem  g_semYAFFS;//int errno = 0;void yaffsfs_SetError(int err){	//Do whatever to set error	errno = err;}void yaffsfs_Lock(void){	WaitSemaphore(g_semYAFFS);}void yaffsfs_Unlock(void){	SignalSemaphore(g_semYAFFS);}__u32 yaffsfs_CurrentTime(void){	return 0;}void yaffsfs_LocalInitialisation(void){	// Define locking semaphore.	g_semYAFFS = NewSemaphore(1);}// Configuration for:// /ram  2MB ramdisk// /boot 2MB boot disk (flash)// /flash 14MB flash disk (flash)// NB Though /boot and /flash occupy the same physical device they// are still disticnt "yaffs_Devices. You may think of these as "partitions"// using non-overlapping areas in the same device.// #include "yaffs_ramdisk.h"#include "yaffs_flashif.h"static yaffs_Device ramDev;static yaffs_Device bootDev;static yaffs_Device flashDev;static yaffsfs_DeviceConfiguration yaffsfs_config[] = {	//{ "/ram", &ramDev},	//{ "/boot", &bootDev},	//{ "/flash", &flashDev},	{ "/root", &bootDev},	{(const char *)0,(struct yaffs_DeviceStruct *)0}};int yaffs_StartUpFormate(void){	// /boot	bootDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;	bootDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;	bootDev.nReservedBlocks = 5;	bootDev.startBlock = 1; // Can't use block 0	bootDev.endBlock = 510; // Last block in 2MB.		bootDev.useNANDECC = 0; // use YAFFS's ECC	bootDev.nShortOpCaches = 0; //10 Use caches	bootDev.genericDevice = (void *) 1;	// Used to identify the device in fstat.	bootDev.writeChunkToNAND = yflash_WriteChunkToNAND;	bootDev.readChunkFromNAND = yflash_ReadChunkFromNAND;	bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;	bootDev.initialiseNAND = yflash_InitialiseNAND;	bootDev.writeSpare = yflash_WriteSpare;		bootDev.repairWriteChunkError = yflash_RepairWriteChunkError;	yaffs_initialise(yaffsfs_config);		return 0;}int yaffs_StartUp(void){	// Stuff to configure YAFFS	// Stuff to initialise anything special (eg lock semaphore).	yaffsfs_LocalInitialisation();		// Set up devices/*	// /ram	ramDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;	ramDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;	ramDev.nReservedBlocks = 2; // Set this smaller for RAM	ramDev.startBlock = 1; // Can't use block 0	ramDev.endBlock = 127; // Last block in 2MB.		ramDev.useNANDECC = 0;    //1;	ramDev.nShortOpCaches = 0;	// Disable caching on this device.	ramDev.genericDevice = (void *) 0;	// Used to identify the device in fstat.	ramDev.writeChunkToNAND = yramdisk_WriteChunkToNAND;	ramDev.readChunkFromNAND = yramdisk_ReadChunkFromNAND;	ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;	ramDev.initialiseNAND = yramdisk_InitialiseNAND;	// /boot	bootDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;	bootDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;	bootDev.nReservedBlocks = 5;	bootDev.startBlock = 1; // Can't use block 0	bootDev.endBlock = 127; // Last block in 2MB.		bootDev.useNANDECC = 0; // use YAFFS's ECC	bootDev.nShortOpCaches = 10; // Use caches	bootDev.genericDevice = (void *) 1;	// Used to identify the device in fstat.	bootDev.writeChunkToNAND = yflash_WriteChunkToNAND;	bootDev.readChunkFromNAND = yflash_ReadChunkFromNAND;	bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;	bootDev.initialiseNAND = yflash_InitialiseNAND;	// /flash	flashDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;	flashDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;	flashDev.nReservedBlocks = 5;	flashDev.startBlock = 128; // First block after 2MB	flashDev.endBlock = 1023; // Last block in 16MB	flashDev.useNANDECC = 0; // use YAFFS's ECC	flashDev.nShortOpCaches = 10; // Use caches	flashDev.genericDevice = (void *) 2;	// Used to identify the device in fstat.	flashDev.writeChunkToNAND = yflash_WriteChunkToNAND;	flashDev.readChunkFromNAND = yflash_ReadChunkFromNAND;	flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;	flashDev.initialiseNAND = yflash_InitialiseNAND;*/	// /boot	bootDev.nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;	bootDev.nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;	bootDev.nReservedBlocks = 5;	bootDev.startBlock = 1; // Can't use block 0	bootDev.endBlock = 510; // Last block in 2MB.		bootDev.useNANDECC = 0; // use YAFFS's ECC	bootDev.nShortOpCaches = 0; //10 Use caches	bootDev.genericDevice = (void *) 1;	// Used to identify the device in fstat.	bootDev.writeChunkToNAND = yflash_WriteChunkToNAND;	bootDev.readChunkFromNAND = yflash_ReadChunkFromNAND;	bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;	bootDev.initialiseNAND = yflash_InitialiseNAND;	bootDev.writeSpare = yflash_WriteSpare;		bootDev.repairWriteChunkError = yflash_RepairWriteChunkError;	yaffs_initialise(yaffsfs_config);		return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -