2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
3 * yaffscfg.c The configuration for the "direct" use of yaffs.
5 * This file is intended to be modified to your requirements.
6 * There is no need to redistribute this file.
11 #include "yaffs_fileem2k.h"
15 unsigned yaffs_traceMask = 0xFFFFFFFF;
18 void yaffsfs_SetError(int err)
20 //Do whatever to set error
24 void yaffsfs_Lock(void)
28 void yaffsfs_Unlock(void)
32 __u32 yaffsfs_CurrentTime(void)
37 void yaffsfs_LocalInitialisation(void)
39 // Define locking semaphore.
44 // /boot 2MB boot disk (flash)
45 // /flash 14MB flash disk (flash)
46 // NB Though /boot and /flash occupy the same physical device they
47 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
48 // using non-overlapping areas in the same device.
51 #include "yaffs_ramdisk.h"
52 #include "yaffs_flashif.h"
54 static yaffs_Device ramDev;
55 static yaffs_Device bootDev;
56 static yaffs_Device flashDev;
58 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
62 { "/flash", &flashDev},
67 int yaffs_StartUp(void)
69 // Stuff to configure YAFFS
70 // Stuff to initialise anything special (eg lock semaphore).
71 yaffsfs_LocalInitialisation();
75 memset(&ramDev,0,sizeof(ramDev));
76 ramDev.nBytesPerChunk = 512;
77 ramDev.nChunksPerBlock = 32;
78 ramDev.nReservedBlocks = 2; // Set this smaller for RAM
79 ramDev.startBlock = 1; // Can't use block 0
80 ramDev.endBlock = 127; // Last block in 2MB.
81 //ramDev.useNANDECC = 1;
82 ramDev.nShortOpCaches = 0; // Disable caching on this device.
83 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat.
84 ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
85 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
86 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
87 ramDev.initialiseNAND = yramdisk_InitialiseNAND;
90 memset(&bootDev,0,sizeof(bootDev));
91 bootDev.nBytesPerChunk = 512;
92 bootDev.nChunksPerBlock = 32;
93 bootDev.nReservedBlocks = 5;
94 bootDev.startBlock = 1; // Can't use block 0
95 bootDev.endBlock = 63; // Last block
96 //bootDev.useNANDECC = 0; // use YAFFS's ECC
97 bootDev.nShortOpCaches = 10; // Use caches
98 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat.
99 bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
100 bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
101 bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
102 bootDev.initialiseNAND = yflash_InitialiseNAND;
103 bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
104 bootDev.queryNANDBlock = yflash_QueryNANDBlock;
109 // Set this puppy up to use
110 // the file emulation space as
111 // 2kpage/64chunk per block/128MB device
112 memset(&flashDev,0,sizeof(flashDev));
114 flashDev.nBytesPerChunk = 2048;
115 flashDev.nChunksPerBlock = 64;
116 flashDev.nReservedBlocks = 5;
117 flashDev.startBlock = 64; // First block after /boot
118 //flashDev.endBlock = 127; // Last block in 16MB
119 flashDev.endBlock = (512 * 1024 * 1024)/(flashDev.nBytesPerChunk * flashDev.nChunksPerBlock) - 1; // Last block in 512MB
120 flashDev.isYaffs2 = 1;
121 flashDev.nShortOpCaches = 10; // Use caches
122 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
123 flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
124 flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
125 flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
126 flashDev.initialiseNAND = yflash_InitialiseNAND;
127 flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
128 flashDev.queryNANDBlock = yflash_QueryNANDBlock;
130 yaffs_initialise(yaffsfs_config);