comparison packages/fs/yaffs/current/src/direct/yaffscfg2k.c @ 298:07c18ca96388

Move upstream sources to packages/fs/yaffs/current/src/
author Ross Younger <wry@ecoscentric.com>
date Tue, 03 Nov 2009 15:21:23 +0000
parents direct/yaffscfg2k.c@3bd2a4e3262f
children
comparison
equal deleted inserted replaced
297:22f72a12de73 298:07c18ca96388
1 /*
2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3 *
4 * Copyright (C) 2002-2007 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
6 *
7 * Created by Charles Manning <charles@aleph1.co.uk>
8 *
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.
12 */
13
14 /*
15 * yaffscfg2k.c The configuration for the "direct" use of yaffs.
16 *
17 * This file is intended to be modified to your requirements.
18 * There is no need to redistribute this file.
19 */
20
21 #include "yaffscfg.h"
22 #include "yaffsfs.h"
23 #include "yaffs_fileem2k.h"
24 #include "yaffs_nandemul2k.h"
25 #include "yaffs_norif1.h"
26
27 #include <errno.h>
28
29 unsigned yaffs_traceMask =
30
31 YAFFS_TRACE_SCAN |
32 YAFFS_TRACE_GC |
33 YAFFS_TRACE_ERASE |
34 YAFFS_TRACE_ERROR |
35 YAFFS_TRACE_TRACING |
36 YAFFS_TRACE_ALLOCATE |
37 YAFFS_TRACE_BAD_BLOCKS |
38 YAFFS_TRACE_VERIFY |
39
40 0;
41
42
43 static int yaffsfs_lastError;
44
45 void yaffsfs_SetError(int err)
46 {
47 //Do whatever to set error
48 yaffsfs_lastError = err;
49 }
50
51
52 int yaffsfs_GetLastError(void)
53 {
54 return yaffsfs_lastError;
55 }
56
57 void yaffsfs_Lock(void)
58 {
59 }
60
61 void yaffsfs_Unlock(void)
62 {
63 }
64
65 __u32 yaffsfs_CurrentTime(void)
66 {
67 return 0;
68 }
69
70
71 static int yaffs_kill_alloc = 0;
72 static size_t total_malloced = 0;
73 static size_t malloc_limit = 0 & 6000000;
74
75 void *yaffs_malloc(size_t size)
76 {
77 void * this;
78 if(yaffs_kill_alloc)
79 return NULL;
80 if(malloc_limit && malloc_limit <(total_malloced + size) )
81 return NULL;
82
83 this = malloc(size);
84 if(this)
85 total_malloced += size;
86 return this;
87 }
88
89 void yaffs_free(void *ptr)
90 {
91 free(ptr);
92 }
93
94 void yaffsfs_LocalInitialisation(void)
95 {
96 // Define locking semaphore.
97 }
98
99 // Configuration for:
100 // /ram 2MB ramdisk
101 // /boot 2MB boot disk (flash)
102 // /flash 14MB flash disk (flash)
103 // NB Though /boot and /flash occupy the same physical device they
104 // are still disticnt "yaffs_Devices. You may think of these as "partitions"
105 // using non-overlapping areas in the same device.
106 //
107
108 #include "yaffs_ramdisk.h"
109 #include "yaffs_flashif.h"
110 #include "yaffs_flashif2.h"
111 #include "yaffs_nandemul2k.h"
112
113 static yaffs_Device ram1Dev;
114 static yaffs_Device nand2;
115 static yaffs_Device flashDev;
116 static yaffs_Device ram2kDev;
117 static yaffs_Device m18_1Dev;
118
119 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
120
121 { "/ram1", &ram1Dev},
122 { "/M18-1", &m18_1Dev},
123 { "/yaffs2", &flashDev},
124 { "/ram2k", &ram2kDev},
125 {(void *)0,(void *)0} /* Null entry to terminate list */
126 };
127
128
129 int yaffs_StartUp(void)
130 {
131 // Stuff to configure YAFFS
132 // Stuff to initialise anything special (eg lock semaphore).
133 yaffsfs_LocalInitialisation();
134
135 // Set up devices
136 // /ram1 ram, yaffs1
137 memset(&ram1Dev,0,sizeof(ram1Dev));
138 ram1Dev.totalBytesPerChunk = 512;
139 ram1Dev.nChunksPerBlock = 32;
140 ram1Dev.nReservedBlocks = 2; // Set this smaller for RAM
141 ram1Dev.startBlock = 0; // Can use block 0
142 ram1Dev.endBlock = 127; // Last block in 2MB.
143 //ram1Dev.useNANDECC = 1;
144 ram1Dev.nShortOpCaches = 0; // Disable caching on this device.
145 ram1Dev.genericDevice = (void *) 0; // Used to identify the device in fstat.
146 ram1Dev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND;
147 ram1Dev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND;
148 ram1Dev.eraseBlockInNAND = yramdisk_EraseBlockInNAND;
149 ram1Dev.initialiseNAND = yramdisk_InitialiseNAND;
150
151 // /M18-1 yaffs1 on M18 nor sim
152 memset(&m18_1Dev,0,sizeof(m18_1Dev));
153 m18_1Dev.totalBytesPerChunk = 1024;
154 m18_1Dev.nChunksPerBlock =248;
155 m18_1Dev.nReservedBlocks = 2;
156 m18_1Dev.startBlock = 0; // Can use block 0
157 m18_1Dev.endBlock = 31; // Last block
158 m18_1Dev.useNANDECC = 0; // use YAFFS's ECC
159 m18_1Dev.nShortOpCaches = 10; // Use caches
160 m18_1Dev.genericDevice = (void *) 1; // Used to identify the device in fstat.
161 m18_1Dev.writeChunkToNAND = ynorif1_WriteChunkToNAND;
162 m18_1Dev.readChunkFromNAND = ynorif1_ReadChunkFromNAND;
163 m18_1Dev.eraseBlockInNAND = ynorif1_EraseBlockInNAND;
164 m18_1Dev.initialiseNAND = ynorif1_InitialiseNAND;
165 m18_1Dev.deinitialiseNAND = ynorif1_DeinitialiseNAND;
166
167
168 // /yaffs2
169 // Set this puppy up to use
170 // the file emulation space as
171 // 2kpage/64chunk per block
172 //
173 memset(&flashDev,0,sizeof(flashDev));
174
175 flashDev.totalBytesPerChunk = 2048;
176 flashDev.nChunksPerBlock = 64;
177 flashDev.nReservedBlocks = 5;
178 flashDev.inbandTags = 0;
179 flashDev.startBlock = 0;
180 flashDev.endBlock = yflash2_GetNumberOfBlocks()-1;
181 flashDev.isYaffs2 = 1;
182 flashDev.wideTnodesDisabled=0;
183 flashDev.nShortOpCaches = 10; // Use caches
184 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat.
185 flashDev.writeChunkWithTagsToNAND = yflash2_WriteChunkWithTagsToNAND;
186 flashDev.readChunkWithTagsFromNAND = yflash2_ReadChunkWithTagsFromNAND;
187 flashDev.eraseBlockInNAND = yflash2_EraseBlockInNAND;
188 flashDev.initialiseNAND = yflash2_InitialiseNAND;
189 flashDev.markNANDBlockBad = yflash2_MarkNANDBlockBad;
190 flashDev.queryNANDBlock = yflash2_QueryNANDBlock;
191
192
193 yaffs_initialise(yaffsfs_config);
194
195 return 0;
196 }
197
198
199
200 void SetCheckpointReservedBlocks(int n)
201 {
202 // flashDev.nCheckpointReservedBlocks = n;
203 }
204