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"
12 #include "yaffs_nandemul2k.h"
16 unsigned yaffs_traceMask =
19 YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL |
20 YAFFS_TRACE_WRITE | YAFFS_TRACE_ERASE |
22 YAFFS_TRACE_ALLOCATE |
23 YAFFS_TRACE_CHECKPOINT |
24 YAFFS_TRACE_BAD_BLOCKS |
31 void yaffsfs_SetError(int err)
33 //Do whatever to set error
37 void yaffsfs_Lock(void)
41 void yaffsfs_Unlock(void)
45 __u32 yaffsfs_CurrentTime(void)
50 void yaffsfs_LocalInitialisation(void)
52 // Define locking semaphore.
57 // /boot 2MB boot disk (flash)
58 // /flash 14MB flash disk (flash)
59 // NB Though /boot and /flash occupy the same physical device they
60 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
61 // using non-overlapping areas in the same device.
64 #include "yaffs_ramdisk.h"
65 #include "yaffs_flashif.h"
66 #include "yaffs_nandemul2k.h"
68 static yaffs_Device ramDev;
69 static yaffs_Device bootDev;
70 static yaffs_Device flashDev;
71 static yaffs_Device ram2kDev;
73 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
77 { "/flash/", &flashDev},
78 { "/ram2k", &ram2kDev},
82 { "/flash/boot", &bootDev},
83 { "/flash/flash", &flashDev},
84 { "/ram2k", &ram2kDev},
85 {(void *)0,(void *)0} /* Null entry to terminate list */
90 int yaffs_StartUp(void)
92 // Stuff to configure YAFFS
93 // Stuff to initialise anything special (eg lock semaphore).
94 yaffsfs_LocalInitialisation();
98 memset(&ramDev,0,sizeof(ramDev));
99 ramDev.nDataBytesPerChunk = 512;
100 ramDev.nChunksPerBlock = 32;
101 ramDev.nReservedBlocks = 2; // Set this smaller for RAM
102 ramDev.startBlock = 0; // Can use block 0
103 ramDev.endBlock = 127; // Last block in 2MB.
104 //ramDev.useNANDECC = 1;
105 ramDev.nShortOpCaches = 0; // Disable caching on this device.
106 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat.
107 ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
108 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
109 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
110 ramDev.initialiseNAND = yramdisk_InitialiseNAND;
113 memset(&bootDev,0,sizeof(bootDev));
114 bootDev.nDataBytesPerChunk = 512;
115 bootDev.nChunksPerBlock = 32;
116 bootDev.nReservedBlocks = 5;
117 bootDev.startBlock = 0; // Can use block 0
118 bootDev.endBlock = 63; // Last block
119 //bootDev.useNANDECC = 0; // use YAFFS's ECC
120 bootDev.nShortOpCaches = 10; // Use caches
121 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat.
122 bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
123 bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
124 bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
125 bootDev.initialiseNAND = yflash_InitialiseNAND;
126 bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
127 bootDev.queryNANDBlock = yflash_QueryNANDBlock;
132 // Set this puppy up to use
133 // the file emulation space as
134 // 2kpage/64chunk per block/128MB device
135 memset(&flashDev,0,sizeof(flashDev));
137 flashDev.nDataBytesPerChunk = 2048;
138 flashDev.nChunksPerBlock = 64;
139 flashDev.nReservedBlocks = 5;
140 flashDev.nCheckpointReservedBlocks = 5;
141 //flashDev.checkpointStartBlock = 1;
142 //flashDev.checkpointEndBlock = 20;
143 flashDev.startBlock = 0;
144 flashDev.endBlock = 200; // Make it smaller
145 //flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
146 flashDev.isYaffs2 = 1;
147 flashDev.wideTnodesDisabled=0;
148 flashDev.nShortOpCaches = 10; // Use caches
149 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
150 flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
151 flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
152 flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
153 flashDev.initialiseNAND = yflash_InitialiseNAND;
154 flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
155 flashDev.queryNANDBlock = yflash_QueryNANDBlock;
158 // Set this puppy up to use
159 // the file emulation space as
160 // 2kpage/64chunk per block/128MB device
161 memset(&ram2kDev,0,sizeof(ram2kDev));
163 ram2kDev.nDataBytesPerChunk = nandemul2k_GetBytesPerChunk();
164 ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock();
165 ram2kDev.nReservedBlocks = 5;
166 ram2kDev.startBlock = 0; // First block after /boot
167 //ram2kDev.endBlock = 127; // Last block in 16MB
168 ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB
169 ram2kDev.isYaffs2 = 1;
170 ram2kDev.nShortOpCaches = 10; // Use caches
171 ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat.
172 ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND;
173 ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
174 ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND;
175 ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND;
176 ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad;
177 ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock;
179 yaffs_initialise(yaffsfs_config);
186 void SetCheckpointReservedBlocks(int n)
188 flashDev.nCheckpointReservedBlocks = n;