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"
25 #include "yaffs_norif1.h"
26 #include "yaffs_trace.h"
30 unsigned yaffs_traceMask =
37 YAFFS_TRACE_ALLOCATE |
38 YAFFS_TRACE_BAD_BLOCKS |
44 static int yaffsfs_lastError;
46 void yaffsfs_SetError(int err)
48 //Do whatever to set error
49 yaffsfs_lastError = err;
53 int yaffsfs_GetLastError(void)
55 return yaffsfs_lastError;
58 void yaffsfs_Lock(void)
62 void yaffsfs_Unlock(void)
66 __u32 yaffsfs_CurrentTime(void)
72 static int yaffs_kill_alloc = 0;
73 static size_t total_malloced = 0;
74 static size_t malloc_limit = 0 & 6000000;
76 void *yaffs_malloc(size_t size)
81 if(malloc_limit && malloc_limit <(total_malloced + size) )
86 total_malloced += size;
90 void yaffs_free(void *ptr)
95 void yaffsfs_LocalInitialisation(void)
97 // Define locking semaphore.
100 // Configuration for:
102 // /boot 2MB boot disk (flash)
103 // /flash 14MB flash disk (flash)
104 // NB Though /boot and /flash occupy the same physical device they
105 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
106 // using non-overlapping areas in the same device.
109 #include "yaffs_ramdisk.h"
110 #include "yaffs_flashif.h"
111 #include "yaffs_flashif2.h"
112 #include "yaffs_nandemul2k.h"
114 static yaffs_Device ram1Dev;
115 static yaffs_Device nand2;
116 static yaffs_Device flashDev;
117 static yaffs_Device ram2kDev;
118 static yaffs_Device m18_1Dev;
120 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
122 { "/ram1", &ram1Dev},
123 { "/M18-1", &m18_1Dev},
124 { "/yaffs2", &flashDev},
125 { "/ram2k", &ram2kDev},
126 {(void *)0,(void *)0} /* Null entry to terminate list */
130 int yaffs_StartUp(void)
132 // Stuff to configure YAFFS
133 // Stuff to initialise anything special (eg lock semaphore).
134 yaffsfs_LocalInitialisation();
138 memset(&ram1Dev,0,sizeof(ram1Dev));
139 ram1Dev.param.totalBytesPerChunk = 512;
140 ram1Dev.param.nChunksPerBlock = 32;
141 ram1Dev.param.nReservedBlocks = 2; // Set this smaller for RAM
142 ram1Dev.param.startBlock = 0; // Can use block 0
143 ram1Dev.param.endBlock = 127; // Last block in 2MB.
144 //ram1Dev.param.useNANDECC = 1;
145 ram1Dev.param.nShortOpCaches = 0; // Disable caching on this device.
146 ram1Dev.context = (void *) 0; // Used to identify the device in fstat.
147 ram1Dev.param.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
148 ram1Dev.param.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
149 ram1Dev.param.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
150 ram1Dev.param.initialiseNAND = yramdisk_InitialiseNAND;
152 // /M18-1 yaffs1 on M18 nor sim
153 memset(&m18_1Dev,0,sizeof(m18_1Dev));
154 m18_1Dev.param.totalBytesPerChunk = 1024;
155 m18_1Dev.param.nChunksPerBlock =248;
156 m18_1Dev.param.nReservedBlocks = 2;
157 m18_1Dev.param.startBlock = 0; // Can use block 0
158 m18_1Dev.param.endBlock = 31; // Last block
159 m18_1Dev.param.useNANDECC = 0; // use YAFFS's ECC
160 m18_1Dev.param.nShortOpCaches = 10; // Use caches
161 m18_1Dev.context = (void *) 1; // Used to identify the device in fstat.
162 m18_1Dev.param.writeChunkToNAND = ynorif1_WriteChunkToNAND;
163 m18_1Dev.param.readChunkFromNAND = ynorif1_ReadChunkFromNAND;
164 m18_1Dev.param.eraseBlockInNAND = ynorif1_EraseBlockInNAND;
165 m18_1Dev.param.initialiseNAND = ynorif1_InitialiseNAND;
166 m18_1Dev.param.deinitialiseNAND = ynorif1_DeinitialiseNAND;
170 // Set this puppy up to use
171 // the file emulation space as
172 // 2kpage/64chunk per block
174 memset(&flashDev,0,sizeof(flashDev));
176 flashDev.param.totalBytesPerChunk = 2048;
177 flashDev.param.nChunksPerBlock = 64;
178 flashDev.param.nReservedBlocks = 5;
179 flashDev.param.inbandTags = 0;
180 flashDev.param.startBlock = 0;
181 flashDev.param.endBlock = yflash2_GetNumberOfBlocks()-1;
182 flashDev.param.isYaffs2 = 1;
183 flashDev.param.useNANDECC=1;
184 flashDev.param.wideTnodesDisabled=0;
185 flashDev.param.refreshPeriod = 10000;
186 flashDev.param.nShortOpCaches = 10; // Use caches
187 flashDev.context = (void *) 2; // Used to identify the device in fstat.
188 flashDev.param.writeChunkWithTagsToNAND = yflash2_WriteChunkWithTagsToNAND;
189 flashDev.param.readChunkWithTagsFromNAND = yflash2_ReadChunkWithTagsFromNAND;
190 flashDev.param.eraseBlockInNAND = yflash2_EraseBlockInNAND;
191 flashDev.param.initialiseNAND = yflash2_InitialiseNAND;
192 flashDev.param.markNANDBlockBad = yflash2_MarkNANDBlockBad;
193 flashDev.param.queryNANDBlock = yflash2_QueryNANDBlock;
196 yaffs_initialise(yaffsfs_config);