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 = 0xFFFFFFFF;
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},
71 int yaffs_StartUp(void)
73 // Stuff to configure YAFFS
74 // Stuff to initialise anything special (eg lock semaphore).
75 yaffsfs_LocalInitialisation();
79 memset(&ramDev,0,sizeof(ramDev));
80 ramDev.nBytesPerChunk = 512;
81 ramDev.nChunksPerBlock = 32;
82 ramDev.nReservedBlocks = 2; // Set this smaller for RAM
83 ramDev.startBlock = 1; // Can't use block 0
84 ramDev.endBlock = 127; // Last block in 2MB.
85 //ramDev.useNANDECC = 1;
86 ramDev.nShortOpCaches = 0; // Disable caching on this device.
87 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat.
88 ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
89 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
90 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
91 ramDev.initialiseNAND = yramdisk_InitialiseNAND;
94 memset(&bootDev,0,sizeof(bootDev));
95 bootDev.nBytesPerChunk = 512;
96 bootDev.nChunksPerBlock = 32;
97 bootDev.nReservedBlocks = 5;
98 bootDev.startBlock = 1; // Can't use block 0
99 bootDev.endBlock = 63; // Last block
100 //bootDev.useNANDECC = 0; // use YAFFS's ECC
101 bootDev.nShortOpCaches = 10; // Use caches
102 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat.
103 bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
104 bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
105 bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
106 bootDev.initialiseNAND = yflash_InitialiseNAND;
107 bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
108 bootDev.queryNANDBlock = yflash_QueryNANDBlock;
113 // Set this puppy up to use
114 // the file emulation space as
115 // 2kpage/64chunk per block/128MB device
116 memset(&flashDev,0,sizeof(flashDev));
118 flashDev.nBytesPerChunk = 2048;
119 flashDev.nChunksPerBlock = 64;
120 flashDev.nReservedBlocks = 5;
121 flashDev.startBlock = 64; // First block after /boot
122 //flashDev.endBlock = 127; // Last block in 16MB
123 flashDev.endBlock = (512 * 1024 * 1024)/(flashDev.nBytesPerChunk * flashDev.nChunksPerBlock) - 1; // Last block in 512MB
124 flashDev.isYaffs2 = 1;
125 flashDev.nShortOpCaches = 10; // Use caches
126 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
127 flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
128 flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
129 flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
130 flashDev.initialiseNAND = yflash_InitialiseNAND;
131 flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
132 flashDev.queryNANDBlock = yflash_QueryNANDBlock;
135 // Set this puppy up to use
136 // the file emulation space as
137 // 2kpage/64chunk per block/128MB device
138 memset(&ram2kDev,0,sizeof(ram2kDev));
140 ram2kDev.nBytesPerChunk = nandemul2k_GetBytesPerChunk();
141 ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock();
142 ram2kDev.nReservedBlocks = 5;
143 ram2kDev.startBlock = 1; // First block after /boot
144 //ram2kDev.endBlock = 127; // Last block in 16MB
145 ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB
146 ram2kDev.isYaffs2 = 1;
147 ram2kDev.nShortOpCaches = 10; // Use caches
148 ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat.
149 ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND;
150 ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
151 ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND;
152 ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND;
153 ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad;
154 ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock;
156 yaffs_initialise(yaffsfs_config);