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 = YAFFS_TRACE_SCAN | YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL | YAFFS_TRACE_WRITE | YAFFS_TRACE_ERASE | YAFFS_TRACE_TRACING | YAFFS_TRACE_ALLOCATE | YAFFS_TRACE_CHECKPOINT;
19 void yaffsfs_SetError(int err)
21 //Do whatever to set error
25 void yaffsfs_Lock(void)
29 void yaffsfs_Unlock(void)
33 __u32 yaffsfs_CurrentTime(void)
38 void yaffsfs_LocalInitialisation(void)
40 // Define locking semaphore.
45 // /boot 2MB boot disk (flash)
46 // /flash 14MB flash disk (flash)
47 // NB Though /boot and /flash occupy the same physical device they
48 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
49 // using non-overlapping areas in the same device.
52 #include "yaffs_ramdisk.h"
53 #include "yaffs_flashif.h"
54 #include "yaffs_nandemul2k.h"
56 static yaffs_Device ramDev;
57 static yaffs_Device bootDev;
58 static yaffs_Device flashDev;
59 static yaffs_Device ram2kDev;
61 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
65 { "/flash/", &flashDev},
66 { "/ram2k", &ram2kDev},
70 { "/flash/boot", &bootDev},
71 { "/flash/flash", &flashDev},
72 { "/ram2k", &ram2kDev},
73 {(void *)0,(void *)0} /* Null entry to terminate list */
78 int yaffs_StartUp(void)
80 // Stuff to configure YAFFS
81 // Stuff to initialise anything special (eg lock semaphore).
82 yaffsfs_LocalInitialisation();
86 memset(&ramDev,0,sizeof(ramDev));
87 ramDev.nBytesPerChunk = 512;
88 ramDev.nChunksPerBlock = 32;
89 ramDev.nReservedBlocks = 2; // Set this smaller for RAM
90 ramDev.startBlock = 0; // Can use block 0
91 ramDev.endBlock = 127; // Last block in 2MB.
92 //ramDev.useNANDECC = 1;
93 ramDev.nShortOpCaches = 0; // Disable caching on this device.
94 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat.
95 ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
96 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
97 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
98 ramDev.initialiseNAND = yramdisk_InitialiseNAND;
101 memset(&bootDev,0,sizeof(bootDev));
102 bootDev.nBytesPerChunk = 512;
103 bootDev.nChunksPerBlock = 32;
104 bootDev.nReservedBlocks = 5;
105 bootDev.startBlock = 0; // Can use block 0
106 bootDev.endBlock = 63; // Last block
107 //bootDev.useNANDECC = 0; // use YAFFS's ECC
108 bootDev.nShortOpCaches = 10; // Use caches
109 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat.
110 bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
111 bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
112 bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
113 bootDev.initialiseNAND = yflash_InitialiseNAND;
114 bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
115 bootDev.queryNANDBlock = yflash_QueryNANDBlock;
120 // Set this puppy up to use
121 // the file emulation space as
122 // 2kpage/64chunk per block/128MB device
123 memset(&flashDev,0,sizeof(flashDev));
125 flashDev.nBytesPerChunk = 2048;
126 flashDev.nChunksPerBlock = 64;
127 flashDev.nReservedBlocks = 5;
128 //flashDev.checkpointStartBlock = 1;
129 //flashDev.checkpointEndBlock = 20;
130 flashDev.startBlock = 20;
131 //flashDev.endBlock = 127; // Last block in 16MB
132 flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
133 flashDev.isYaffs2 = 1;
134 flashDev.wideTnodesDisabled=0;
135 flashDev.nShortOpCaches = 10; // Use caches
136 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
137 flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
138 flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
139 flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
140 flashDev.initialiseNAND = yflash_InitialiseNAND;
141 flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
142 flashDev.queryNANDBlock = yflash_QueryNANDBlock;
145 // Set this puppy up to use
146 // the file emulation space as
147 // 2kpage/64chunk per block/128MB device
148 memset(&ram2kDev,0,sizeof(ram2kDev));
150 ram2kDev.nBytesPerChunk = nandemul2k_GetBytesPerChunk();
151 ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock();
152 ram2kDev.nReservedBlocks = 5;
153 ram2kDev.startBlock = 0; // First block after /boot
154 //ram2kDev.endBlock = 127; // Last block in 16MB
155 ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB
156 ram2kDev.isYaffs2 = 1;
157 ram2kDev.nShortOpCaches = 10; // Use caches
158 ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat.
159 ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND;
160 ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
161 ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND;
162 ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND;
163 ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad;
164 ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock;
166 yaffs_initialise(yaffsfs_config);