2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
4 * Copyright (C) 2002-2007 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Charles Manning <charles@aleph1.co.uk>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
16 * yaffscfg2k.c The configuration for the "direct" use of yaffs.
18 * This file is intended to be modified to your requirements.
19 * There is no need to redistribute this file.
24 #include "yaffs_fileem2k.h"
25 #include "yaffs_nandemul2k.h"
29 unsigned yaffs_traceMask =
32 YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL |
33 YAFFS_TRACE_WRITE | YAFFS_TRACE_ERASE |
35 YAFFS_TRACE_ALLOCATE |
36 YAFFS_TRACE_CHECKPOINT |
37 YAFFS_TRACE_BAD_BLOCKS |
44 void yaffsfs_SetError(int err)
46 //Do whatever to set error
50 void yaffsfs_Lock(void)
54 void yaffsfs_Unlock(void)
58 __u32 yaffsfs_CurrentTime(void)
63 void yaffsfs_LocalInitialisation(void)
65 // Define locking semaphore.
70 // /boot 2MB boot disk (flash)
71 // /flash 14MB flash disk (flash)
72 // NB Though /boot and /flash occupy the same physical device they
73 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
74 // using non-overlapping areas in the same device.
77 #include "yaffs_ramdisk.h"
78 #include "yaffs_flashif.h"
79 #include "yaffs_nandemul2k.h"
81 static yaffs_Device ramDev;
82 static yaffs_Device bootDev;
83 static yaffs_Device flashDev;
84 static yaffs_Device ram2kDev;
86 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
90 { "/flash/", &flashDev},
91 { "/ram2k", &ram2kDev},
95 { "/flash/boot", &bootDev},
96 { "/flash/flash", &flashDev},
97 { "/ram2k", &ram2kDev},
98 {(void *)0,(void *)0} /* Null entry to terminate list */
103 int yaffs_StartUp(void)
105 // Stuff to configure YAFFS
106 // Stuff to initialise anything special (eg lock semaphore).
107 yaffsfs_LocalInitialisation();
111 memset(&ramDev,0,sizeof(ramDev));
112 ramDev.nDataBytesPerChunk = 512;
113 ramDev.nChunksPerBlock = 32;
114 ramDev.nReservedBlocks = 2; // Set this smaller for RAM
115 ramDev.startBlock = 0; // Can use block 0
116 ramDev.endBlock = 127; // Last block in 2MB.
117 //ramDev.useNANDECC = 1;
118 ramDev.nShortOpCaches = 0; // Disable caching on this device.
119 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat.
120 ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
121 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
122 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
123 ramDev.initialiseNAND = yramdisk_InitialiseNAND;
126 memset(&bootDev,0,sizeof(bootDev));
127 bootDev.nDataBytesPerChunk = 512;
128 bootDev.nChunksPerBlock = 32;
129 bootDev.nReservedBlocks = 5;
130 bootDev.startBlock = 0; // Can use block 0
131 bootDev.endBlock = 63; // Last block
132 //bootDev.useNANDECC = 0; // use YAFFS's ECC
133 bootDev.nShortOpCaches = 10; // Use caches
134 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat.
135 bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
136 bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
137 bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
138 bootDev.initialiseNAND = yflash_InitialiseNAND;
139 bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
140 bootDev.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(&flashDev,0,sizeof(flashDev));
150 flashDev.nDataBytesPerChunk = 2048;
151 flashDev.nChunksPerBlock = 64;
152 flashDev.nReservedBlocks = 5;
153 flashDev.nCheckpointReservedBlocks = 5;
154 //flashDev.checkpointStartBlock = 1;
155 //flashDev.checkpointEndBlock = 20;
156 flashDev.startBlock = 0;
157 flashDev.endBlock = 200; // Make it smaller
158 //flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
159 flashDev.isYaffs2 = 1;
160 flashDev.wideTnodesDisabled=0;
161 flashDev.nShortOpCaches = 10; // Use caches
162 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
163 flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
164 flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
165 flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
166 flashDev.initialiseNAND = yflash_InitialiseNAND;
167 flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
168 flashDev.queryNANDBlock = yflash_QueryNANDBlock;
171 // Set this puppy up to use
172 // the file emulation space as
173 // 2kpage/64chunk per block/128MB device
174 memset(&ram2kDev,0,sizeof(ram2kDev));
176 ram2kDev.nDataBytesPerChunk = nandemul2k_GetBytesPerChunk();
177 ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock();
178 ram2kDev.nReservedBlocks = 5;
179 ram2kDev.startBlock = 0; // First block after /boot
180 //ram2kDev.endBlock = 127; // Last block in 16MB
181 ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB
182 ram2kDev.isYaffs2 = 1;
183 ram2kDev.nShortOpCaches = 10; // Use caches
184 ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat.
185 ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND;
186 ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
187 ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND;
188 ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND;
189 ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad;
190 ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock;
192 yaffs_initialise(yaffsfs_config);
199 void SetCheckpointReservedBlocks(int n)
201 flashDev.nCheckpointReservedBlocks = n;