2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 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.
22 #include "yaffs_guts.h"
24 #include "yaffs_fileem2k.h"
25 #include "yaffs_nandemul2k.h"
26 #include "yaffs_norif1.h"
27 #include "yaffs_trace.h"
32 unsigned yaffs_trace_mask =
39 YAFFS_TRACE_ALLOCATE |
40 YAFFS_TRACE_BAD_BLOCKS |
46 static int yaffsfs_lastError;
48 void yaffsfs_SetError(int err)
50 //Do whatever to set error
51 yaffsfs_lastError = err;
55 int yaffsfs_GetLastError(void)
57 return yaffsfs_lastError;
60 void yaffsfs_Lock(void)
64 void yaffsfs_Unlock(void)
68 __u32 yaffsfs_CurrentTime(void)
74 static int yaffs_kill_alloc = 0;
75 static size_t total_malloced = 0;
76 static size_t malloc_limit = 0 & 6000000;
78 void *yaffs_malloc(size_t size)
83 if(malloc_limit && malloc_limit <(total_malloced + size) )
88 total_malloced += size;
92 void yaffs_free(void *ptr)
97 void yaffsfs_LocalInitialisation(void)
99 // Define locking semaphore.
104 #include "yaffs_ramdisk.h"
105 #include "yaffs_flashif.h"
106 #include "yaffs_flashif2.h"
107 #include "yaffs_nandemul2k.h"
109 struct yaffs_dev_s ram1Dev;
110 struct yaffs_dev_s flashDev;
111 struct yaffs_dev_s m18_1Dev;
113 int yaffs_start_up(void)
115 // Stuff to configure YAFFS
116 // Stuff to initialise anything special (eg lock semaphore).
117 yaffsfs_LocalInitialisation();
121 memset(&ram1Dev,0,sizeof(ram1Dev));
122 ram1Dev.param.name = "ram1";
123 ram1Dev.param.total_bytes_per_chunk = 512;
124 ram1Dev.param.chunks_per_block = 32;
125 ram1Dev.param.n_reserved_blocks = 2; // Set this smaller for RAM
126 ram1Dev.param.start_block = 0; // Can use block 0
127 ram1Dev.param.end_block = 127; // Last block in 2MB.
128 //ram1Dev.param.use_nand_ecc = 1;
129 ram1Dev.param.n_caches = 0; // Disable caching on this device.
130 ram1Dev.driver_context = (void *) 0; // Used to identify the device in fstat.
131 ram1Dev.param.write_chunk_tags_fn = yramdisk_wr_chunk;
132 ram1Dev.param.read_chunk_tags_fn = yramdisk_rd_chunk;
133 ram1Dev.param.erase_fn = yramdisk_erase;
134 ram1Dev.param.initialise_flash_fn = yramdisk_initialise;
136 yaffs_add_device(&ram1Dev);
138 // /M18-1 yaffs1 on M18 nor sim
139 memset(&m18_1Dev,0,sizeof(m18_1Dev));
140 m18_1Dev.param.name = "M18-1";
141 m18_1Dev.param.total_bytes_per_chunk = 1024;
142 m18_1Dev.param.chunks_per_block =248;
143 m18_1Dev.param.n_reserved_blocks = 2;
144 m18_1Dev.param.start_block = 0; // Can use block 0
145 m18_1Dev.param.end_block = 31; // Last block
146 m18_1Dev.param.use_nand_ecc = 0; // use YAFFS's ECC
147 m18_1Dev.param.n_caches = 10; // Use caches
148 m18_1Dev.driver_context = (void *) 1; // Used to identify the device in fstat.
149 m18_1Dev.param.write_chunk_fn = ynorif1_WriteChunkToNAND;
150 m18_1Dev.param.read_chunk_fn = ynorif1_ReadChunkFromNAND;
151 m18_1Dev.param.erase_fn = ynorif1_EraseBlockInNAND;
152 m18_1Dev.param.initialise_flash_fn = ynorif1_InitialiseNAND;
153 m18_1Dev.param.deinitialise_flash_fn = ynorif1_Deinitialise_flash_fn;
155 // m18_1Dev.param.disable_soft_del = 1;
157 yaffs_add_device(&m18_1Dev);
159 // /yaffs2 yaffs2 file emulation
160 // 2kpage/64chunk per block
162 memset(&flashDev,0,sizeof(flashDev));
163 flashDev.param.name = "yaffs2";
164 flashDev.param.total_bytes_per_chunk = 2048;
165 flashDev.param.chunks_per_block = 64;
166 flashDev.param.n_reserved_blocks = 5;
167 flashDev.param.inband_tags = 0;
168 flashDev.param.start_block = 0;
169 flashDev.param.end_block = yflash2_GetNumberOfBlocks()-1;
170 flashDev.param.is_yaffs2 = 1;
171 flashDev.param.use_nand_ecc=1;
172 flashDev.param.wide_tnodes_disabled=0;
173 flashDev.param.refresh_period = 1000;
174 flashDev.param.n_caches = 10; // Use caches
175 flashDev.driver_context = (void *) 2; // Used to identify the device in fstat.
176 flashDev.param.write_chunk_tags_fn = yflash2_WriteChunkWithTagsToNAND;
177 flashDev.param.read_chunk_tags_fn = yflash2_ReadChunkWithTagsFromNAND;
178 flashDev.param.erase_fn = yflash2_EraseBlockInNAND;
179 flashDev.param.initialise_flash_fn = yflash2_InitialiseNAND;
180 flashDev.param.bad_block_fn = yflash2_MarkNANDBlockBad;
181 flashDev.param.query_block_fn = yflash2_QueryNANDBlock;
182 flashDev.param.enable_xattr = 1;
184 yaffs_add_device(&flashDev);
186 // todo yaffs_initialise(yaffsfs_config);