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.
15 * yaffscfg2k.c The configuration for the "direct" use of yaffs.
17 * This file is intended to be modified to your requirements.
18 * There is no need to redistribute this file.
23 #include "yaffs_fileem2k.h"
24 #include "yaffs_nandemul2k.h"
28 unsigned yaffs_traceMask =
31 YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL |
32 YAFFS_TRACE_WRITE | YAFFS_TRACE_ERASE |
34 YAFFS_TRACE_ALLOCATE |
35 YAFFS_TRACE_CHECKPOINT |
36 YAFFS_TRACE_BAD_BLOCKS |
43 void yaffsfs_SetError(int err)
45 //Do whatever to set error
49 void yaffsfs_Lock(void)
53 void yaffsfs_Unlock(void)
57 __u32 yaffsfs_CurrentTime(void)
62 void yaffsfs_LocalInitialisation(void)
64 // Define locking semaphore.
69 // /boot 2MB boot disk (flash)
70 // /flash 14MB flash disk (flash)
71 // NB Though /boot and /flash occupy the same physical device they
72 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
73 // using non-overlapping areas in the same device.
76 #include "yaffs_ramdisk.h"
77 #include "yaffs_flashif.h"
78 #include "yaffs_nandemul2k.h"
80 static yaffs_Device ramDev;
81 static yaffs_Device bootDev;
82 static yaffs_Device flashDev;
83 static yaffs_Device ram2kDev;
85 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
89 { "/flash/", &flashDev},
90 { "/ram2k", &ram2kDev},
94 { "/flash/boot", &bootDev},
95 { "/flash/flash", &flashDev},
96 { "/ram2k", &ram2kDev},
97 {(void *)0,(void *)0} /* Null entry to terminate list */
102 int yaffs_StartUp(void)
104 // Stuff to configure YAFFS
105 // Stuff to initialise anything special (eg lock semaphore).
106 yaffsfs_LocalInitialisation();
110 memset(&ramDev,0,sizeof(ramDev));
111 ramDev.nDataBytesPerChunk = 512;
112 ramDev.nChunksPerBlock = 32;
113 ramDev.nReservedBlocks = 2; // Set this smaller for RAM
114 ramDev.startBlock = 0; // Can use block 0
115 ramDev.endBlock = 127; // Last block in 2MB.
116 //ramDev.useNANDECC = 1;
117 ramDev.nShortOpCaches = 0; // Disable caching on this device.
118 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat.
119 ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
120 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
121 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
122 ramDev.initialiseNAND = yramdisk_InitialiseNAND;
125 memset(&bootDev,0,sizeof(bootDev));
126 bootDev.nDataBytesPerChunk = 512;
127 bootDev.nChunksPerBlock = 32;
128 bootDev.nReservedBlocks = 5;
129 bootDev.startBlock = 0; // Can use block 0
130 bootDev.endBlock = 63; // Last block
131 //bootDev.useNANDECC = 0; // use YAFFS's ECC
132 bootDev.nShortOpCaches = 10; // Use caches
133 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat.
134 bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
135 bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
136 bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
137 bootDev.initialiseNAND = yflash_InitialiseNAND;
138 bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
139 bootDev.queryNANDBlock = yflash_QueryNANDBlock;
144 // Set this puppy up to use
145 // the file emulation space as
146 // 2kpage/64chunk per block/128MB device
147 memset(&flashDev,0,sizeof(flashDev));
149 flashDev.nDataBytesPerChunk = 2048;
150 flashDev.nChunksPerBlock = 64;
151 flashDev.nReservedBlocks = 5;
152 flashDev.nCheckpointReservedBlocks = 5;
153 //flashDev.checkpointStartBlock = 1;
154 //flashDev.checkpointEndBlock = 20;
155 flashDev.startBlock = 0;
156 flashDev.endBlock = 200; // Make it smaller
157 //flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
158 flashDev.isYaffs2 = 1;
159 flashDev.wideTnodesDisabled=0;
160 flashDev.nShortOpCaches = 10; // Use caches
161 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
162 flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND;
163 flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND;
164 flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND;
165 flashDev.initialiseNAND = yflash_InitialiseNAND;
166 flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad;
167 flashDev.queryNANDBlock = yflash_QueryNANDBlock;
170 // Set this puppy up to use
171 // the file emulation space as
172 // 2kpage/64chunk per block/128MB device
173 memset(&ram2kDev,0,sizeof(ram2kDev));
175 ram2kDev.nDataBytesPerChunk = nandemul2k_GetBytesPerChunk();
176 ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock();
177 ram2kDev.nReservedBlocks = 5;
178 ram2kDev.startBlock = 0; // First block after /boot
179 //ram2kDev.endBlock = 127; // Last block in 16MB
180 ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB
181 ram2kDev.isYaffs2 = 1;
182 ram2kDev.nShortOpCaches = 10; // Use caches
183 ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat.
184 ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND;
185 ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
186 ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND;
187 ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND;
188 ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad;
189 ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock;
191 yaffs_initialise(yaffsfs_config);
198 void SetCheckpointReservedBlocks(int n)
200 flashDev.nCheckpointReservedBlocks = n;