|
1
|
1 /* |
|
|
2 * YAFFS: Yet another FFS. A NAND-flash specific file system. |
|
|
3 * yaffscfg.c The configuration for the "direct" use of yaffs. |
|
|
4 * |
|
|
5 * This file is intended to be modified to your requirements. |
|
|
6 * There is no need to redistribute this file. |
|
|
7 */ |
|
|
8 |
|
|
9 #include "yaffscfg.h" |
|
|
10 #include "yaffsfs.h" |
|
|
11 #include "yaffs_fileem2k.h" |
|
6
|
12 #include "yaffs_nandemul2k.h" |
|
1
|
13 |
|
|
14 #include <errno.h> |
|
|
15 |
|
138
|
16 unsigned yaffs_traceMask = YAFFS_TRACE_SCAN | YAFFS_TRACE_GC /*| YAFFS_TRACE_GC_DETAIL | YAFFS_TRACE_WRITE */ | YAFFS_TRACE_ERASE | YAFFS_TRACE_TRACING | YAFFS_TRACE_ALLOCATE | YAFFS_TRACE_CHECKPOINT; |
|
1
|
17 |
|
|
18 |
|
|
19 void yaffsfs_SetError(int err) |
|
|
20 { |
|
|
21 //Do whatever to set error |
|
|
22 errno = err; |
|
|
23 } |
|
|
24 |
|
|
25 void yaffsfs_Lock(void) |
|
|
26 { |
|
|
27 } |
|
|
28 |
|
|
29 void yaffsfs_Unlock(void) |
|
|
30 { |
|
|
31 } |
|
|
32 |
|
|
33 __u32 yaffsfs_CurrentTime(void) |
|
|
34 { |
|
|
35 return 0; |
|
|
36 } |
|
|
37 |
|
|
38 void yaffsfs_LocalInitialisation(void) |
|
|
39 { |
|
|
40 // Define locking semaphore. |
|
|
41 } |
|
|
42 |
|
|
43 // Configuration for: |
|
|
44 // /ram 2MB ramdisk |
|
|
45 // /boot 2MB boot disk (flash) |
|
|
46 // /flash 14MB flash disk (flash) |
|
|
47 // NB Though /boot and /flash occupy the same physical device they |
|
|
48 // are still disticnt "yaffs_Devices. You may think of these as "partitions" |
|
|
49 // using non-overlapping areas in the same device. |
|
|
50 // |
|
|
51 |
|
|
52 #include "yaffs_ramdisk.h" |
|
|
53 #include "yaffs_flashif.h" |
|
6
|
54 #include "yaffs_nandemul2k.h" |
|
1
|
55 |
|
|
56 static yaffs_Device ramDev; |
|
|
57 static yaffs_Device bootDev; |
|
|
58 static yaffs_Device flashDev; |
|
6
|
59 static yaffs_Device ram2kDev; |
|
1
|
60 |
|
|
61 static yaffsfs_DeviceConfiguration yaffsfs_config[] = { |
|
94
|
62 #if 0 |
|
1
|
63 { "/ram", &ramDev}, |
|
|
64 { "/boot", &bootDev}, |
|
94
|
65 { "/flash/", &flashDev}, |
|
6
|
66 { "/ram2k", &ram2kDev}, |
|
1
|
67 {(void *)0,(void *)0} |
|
94
|
68 #else |
|
|
69 { "/", &ramDev}, |
|
|
70 { "/flash/boot", &bootDev}, |
|
105
|
71 { "/flash/flash", &flashDev}, |
|
94
|
72 { "/ram2k", &ram2kDev}, |
|
105
|
73 {(void *)0,(void *)0} /* Null entry to terminate list */ |
|
94
|
74 #endif |
|
1
|
75 }; |
|
|
76 |
|
|
77 |
|
|
78 int yaffs_StartUp(void) |
|
|
79 { |
|
|
80 // Stuff to configure YAFFS |
|
|
81 // Stuff to initialise anything special (eg lock semaphore). |
|
|
82 yaffsfs_LocalInitialisation(); |
|
|
83 |
|
|
84 // Set up devices |
|
|
85 // /ram |
|
|
86 memset(&ramDev,0,sizeof(ramDev)); |
|
|
87 ramDev.nBytesPerChunk = 512; |
|
|
88 ramDev.nChunksPerBlock = 32; |
|
|
89 ramDev.nReservedBlocks = 2; // Set this smaller for RAM |
|
21
|
90 ramDev.startBlock = 0; // Can use block 0 |
|
1
|
91 ramDev.endBlock = 127; // Last block in 2MB. |
|
|
92 //ramDev.useNANDECC = 1; |
|
|
93 ramDev.nShortOpCaches = 0; // Disable caching on this device. |
|
|
94 ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat. |
|
|
95 ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND; |
|
|
96 ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND; |
|
|
97 ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND; |
|
|
98 ramDev.initialiseNAND = yramdisk_InitialiseNAND; |
|
|
99 |
|
|
100 // /boot |
|
|
101 memset(&bootDev,0,sizeof(bootDev)); |
|
|
102 bootDev.nBytesPerChunk = 512; |
|
|
103 bootDev.nChunksPerBlock = 32; |
|
|
104 bootDev.nReservedBlocks = 5; |
|
21
|
105 bootDev.startBlock = 0; // Can use block 0 |
|
1
|
106 bootDev.endBlock = 63; // Last block |
|
|
107 //bootDev.useNANDECC = 0; // use YAFFS's ECC |
|
|
108 bootDev.nShortOpCaches = 10; // Use caches |
|
|
109 bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat. |
|
|
110 bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND; |
|
|
111 bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND; |
|
|
112 bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND; |
|
|
113 bootDev.initialiseNAND = yflash_InitialiseNAND; |
|
|
114 bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad; |
|
|
115 bootDev.queryNANDBlock = yflash_QueryNANDBlock; |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 // /flash |
|
|
120 // Set this puppy up to use |
|
|
121 // the file emulation space as |
|
|
122 // 2kpage/64chunk per block/128MB device |
|
|
123 memset(&flashDev,0,sizeof(flashDev)); |
|
|
124 |
|
|
125 flashDev.nBytesPerChunk = 2048; |
|
|
126 flashDev.nChunksPerBlock = 64; |
|
|
127 flashDev.nReservedBlocks = 5; |
|
137
|
128 flashDev.nCheckpointReservedBlocks = 5; |
|
133
|
129 //flashDev.checkpointStartBlock = 1; |
|
|
130 //flashDev.checkpointEndBlock = 20; |
|
|
131 flashDev.startBlock = 20; |
|
137
|
132 flashDev.endBlock = 127; // Make it smaller |
|
|
133 //flashDev.endBlock = yflash_GetNumberOfBlocks()-1; |
|
1
|
134 flashDev.isYaffs2 = 1; |
|
105
|
135 flashDev.wideTnodesDisabled=0; |
|
1
|
136 flashDev.nShortOpCaches = 10; // Use caches |
|
|
137 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat. |
|
|
138 flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND; |
|
|
139 flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND; |
|
|
140 flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND; |
|
|
141 flashDev.initialiseNAND = yflash_InitialiseNAND; |
|
|
142 flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad; |
|
|
143 flashDev.queryNANDBlock = yflash_QueryNANDBlock; |
|
|
144 |
|
6
|
145 // /ram2k |
|
|
146 // Set this puppy up to use |
|
|
147 // the file emulation space as |
|
|
148 // 2kpage/64chunk per block/128MB device |
|
|
149 memset(&ram2kDev,0,sizeof(ram2kDev)); |
|
|
150 |
|
|
151 ram2kDev.nBytesPerChunk = nandemul2k_GetBytesPerChunk(); |
|
|
152 ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock(); |
|
|
153 ram2kDev.nReservedBlocks = 5; |
|
21
|
154 ram2kDev.startBlock = 0; // First block after /boot |
|
6
|
155 //ram2kDev.endBlock = 127; // Last block in 16MB |
|
|
156 ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB |
|
|
157 ram2kDev.isYaffs2 = 1; |
|
|
158 ram2kDev.nShortOpCaches = 10; // Use caches |
|
|
159 ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat. |
|
|
160 ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND; |
|
|
161 ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND; |
|
|
162 ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND; |
|
|
163 ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND; |
|
|
164 ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad; |
|
|
165 ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock; |
|
|
166 |
|
1
|
167 yaffs_initialise(yaffsfs_config); |
|
|
168 |
|
|
169 return 0; |
|
|
170 } |
|
|
171 |
|
|
172 |
|
|
173 |
|
138
|
174 void SetCheckpointReservedBlocks(int n) |
|
|
175 { |
|
|
176 flashDev.nCheckpointReservedBlocks = n; |
|
|
177 } |
|
1
|
178 |