Mercurial > yaffs-ecoscentric
annotate direct/yaffscfg2k.c @ 236:d74a9a8c1f49
Reduce size for nor simulation testing to try force errors
| author | charles |
|---|---|
| date | Tue, 11 Nov 2008 01:48:47 +0000 |
| parents | 66bdb92cfbde |
| children | a8738fee77c1 |
| rev | line source |
|---|---|
| 1 | 1 /* |
| 173 | 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. | |
| 1 | 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" | |
| 6 | 24 #include "yaffs_nandemul2k.h" |
| 231 | 25 #include "yaffs_norif1.h" |
| 1 | 26 |
| 27 #include <errno.h> | |
| 28 | |
| 160 | 29 unsigned yaffs_traceMask = |
| 30 | |
| 31 YAFFS_TRACE_SCAN | | |
| 231 | 32 YAFFS_TRACE_GC | |
| 182 | 33 YAFFS_TRACE_ERASE | |
| 231 | 34 YAFFS_TRACE_ERROR | |
| 160 | 35 YAFFS_TRACE_TRACING | |
| 36 YAFFS_TRACE_ALLOCATE | | |
| 37 YAFFS_TRACE_CHECKPOINT | | |
| 38 YAFFS_TRACE_BAD_BLOCKS | | |
| 231 | 39 |
| 40 /* YAFFS_TRACE_VERIFY | */ | |
| 160 | 41 |
| 42 0; | |
| 43 | |
| 1 | 44 |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
45 static int yaffsfs_lastError; |
| 1 | 46 |
| 47 void yaffsfs_SetError(int err) | |
| 48 { | |
| 49 //Do whatever to set error | |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
50 yaffsfs_lastError = err; |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
51 } |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
52 |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
53 |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
54 int yaffsfs_GetLastError(void) |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
55 { |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
56 return yaffsfs_lastError; |
| 1 | 57 } |
| 58 | |
| 59 void yaffsfs_Lock(void) | |
| 60 { | |
| 61 } | |
| 62 | |
| 63 void yaffsfs_Unlock(void) | |
| 64 { | |
| 65 } | |
| 66 | |
| 67 __u32 yaffsfs_CurrentTime(void) | |
| 68 { | |
| 69 return 0; | |
| 70 } | |
| 71 | |
| 182 | 72 |
| 73 static int yaffs_kill_alloc = 0; | |
| 74 static size_t total_malloced = 0; | |
| 75 static size_t malloc_limit = 0 & 6000000; | |
| 76 | |
| 77 void *yaffs_malloc(size_t size) | |
| 78 { | |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
79 void * this; |
| 182 | 80 if(yaffs_kill_alloc) |
| 81 return NULL; | |
| 82 if(malloc_limit && malloc_limit <(total_malloced + size) ) | |
| 83 return NULL; | |
| 84 | |
| 85 this = malloc(size); | |
| 86 if(this) | |
| 87 total_malloced += size; | |
| 88 return this; | |
| 89 } | |
| 90 | |
| 91 void yaffs_free(void *ptr) | |
| 92 { | |
| 93 free(ptr); | |
| 94 } | |
| 95 | |
| 1 | 96 void yaffsfs_LocalInitialisation(void) |
| 97 { | |
| 98 // Define locking semaphore. | |
| 99 } | |
| 100 | |
| 101 // Configuration for: | |
| 102 // /ram 2MB ramdisk | |
| 103 // /boot 2MB boot disk (flash) | |
| 104 // /flash 14MB flash disk (flash) | |
| 105 // NB Though /boot and /flash occupy the same physical device they | |
| 106 // are still disticnt "yaffs_Devices. You may think of these as "partitions" | |
| 107 // using non-overlapping areas in the same device. | |
| 108 // | |
| 109 | |
| 110 #include "yaffs_ramdisk.h" | |
| 111 #include "yaffs_flashif.h" | |
| 215 | 112 #include "yaffs_flashif2.h" |
| 6 | 113 #include "yaffs_nandemul2k.h" |
| 1 | 114 |
| 231 | 115 static yaffs_Device ram1Dev; |
| 116 static yaffs_Device nand2; | |
| 1 | 117 static yaffs_Device flashDev; |
| 6 | 118 static yaffs_Device ram2kDev; |
| 231 | 119 static yaffs_Device m18_1Dev; |
| 1 | 120 |
| 121 static yaffsfs_DeviceConfiguration yaffsfs_config[] = { | |
| 231 | 122 |
| 123 { "/ram1", &ram1Dev}, | |
| 124 { "/M18-1", &m18_1Dev}, | |
| 125 { "/yaffs2", &flashDev}, | |
| 94 | 126 { "/ram2k", &ram2kDev}, |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
127 { "/flash/bigblock", &flashDev}, |
| 105 | 128 {(void *)0,(void *)0} /* Null entry to terminate list */ |
| 1 | 129 }; |
| 130 | |
| 131 | |
| 132 int yaffs_StartUp(void) | |
| 133 { | |
| 134 // Stuff to configure YAFFS | |
| 135 // Stuff to initialise anything special (eg lock semaphore). | |
| 136 yaffsfs_LocalInitialisation(); | |
| 137 | |
| 138 // Set up devices | |
| 231 | 139 // /ram1 ram, yaffs1 |
| 140 memset(&ram1Dev,0,sizeof(ram1Dev)); | |
| 141 ram1Dev.totalBytesPerChunk = 512; | |
| 142 ram1Dev.nChunksPerBlock = 32; | |
| 143 ram1Dev.nReservedBlocks = 2; // Set this smaller for RAM | |
| 144 ram1Dev.startBlock = 0; // Can use block 0 | |
| 145 ram1Dev.endBlock = 127; // Last block in 2MB. | |
| 146 //ram1Dev.useNANDECC = 1; | |
| 147 ram1Dev.nShortOpCaches = 0; // Disable caching on this device. | |
| 148 ram1Dev.genericDevice = (void *) 0; // Used to identify the device in fstat. | |
| 149 ram1Dev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND; | |
| 150 ram1Dev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND; | |
| 151 ram1Dev.eraseBlockInNAND = yramdisk_EraseBlockInNAND; | |
| 152 ram1Dev.initialiseNAND = yramdisk_InitialiseNAND; | |
| 1 | 153 |
| 231 | 154 // /M18-1 yaffs1 on M18 nor sim |
| 155 memset(&m18_1Dev,0,sizeof(m18_1Dev)); | |
| 156 m18_1Dev.totalBytesPerChunk = 1024; | |
| 157 m18_1Dev.nChunksPerBlock =248; | |
| 158 m18_1Dev.nReservedBlocks = 2; | |
| 159 m18_1Dev.startBlock = 0; // Can use block 0 | |
|
236
d74a9a8c1f49
Reduce size for nor simulation testing to try force errors
charles
parents:
231
diff
changeset
|
160 m18_1Dev.endBlock = 31; // Last block |
| 231 | 161 m18_1Dev.useNANDECC = 0; // use YAFFS's ECC |
| 162 m18_1Dev.nShortOpCaches = 10; // Use caches | |
| 163 m18_1Dev.genericDevice = (void *) 1; // Used to identify the device in fstat. | |
| 164 m18_1Dev.writeChunkToNAND = ynorif1_WriteChunkToNAND; | |
| 165 m18_1Dev.readChunkFromNAND = ynorif1_ReadChunkFromNAND; | |
| 166 m18_1Dev.eraseBlockInNAND = ynorif1_EraseBlockInNAND; | |
| 167 m18_1Dev.initialiseNAND = ynorif1_InitialiseNAND; | |
| 168 m18_1Dev.deinitialiseNAND = ynorif1_DeinitialiseNAND; | |
| 1 | 169 |
| 170 | |
| 215 | 171 // /flash (yaffs2) |
| 1 | 172 // Set this puppy up to use |
| 173 // the file emulation space as | |
| 174 // 2kpage/64chunk per block/128MB device | |
| 175 memset(&flashDev,0,sizeof(flashDev)); | |
| 176 | |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
177 flashDev.totalBytesPerChunk = 512; |
| 1 | 178 flashDev.nChunksPerBlock = 64; |
| 179 flashDev.nReservedBlocks = 5; | |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
180 flashDev.inbandTags = 1; |
| 133 | 181 //flashDev.checkpointStartBlock = 1; |
| 182 //flashDev.checkpointEndBlock = 20; | |
| 160 | 183 flashDev.startBlock = 0; |
| 184 flashDev.endBlock = 200; // Make it smaller | |
| 185 //flashDev.endBlock = yflash_GetNumberOfBlocks()-1; | |
| 1 | 186 flashDev.isYaffs2 = 1; |
| 105 | 187 flashDev.wideTnodesDisabled=0; |
| 1 | 188 flashDev.nShortOpCaches = 10; // Use caches |
| 189 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat. | |
| 215 | 190 flashDev.writeChunkWithTagsToNAND = yflash2_WriteChunkWithTagsToNAND; |
| 191 flashDev.readChunkWithTagsFromNAND = yflash2_ReadChunkWithTagsFromNAND; | |
| 192 flashDev.eraseBlockInNAND = yflash2_EraseBlockInNAND; | |
| 193 flashDev.initialiseNAND = yflash2_InitialiseNAND; | |
| 194 flashDev.markNANDBlockBad = yflash2_MarkNANDBlockBad; | |
| 195 flashDev.queryNANDBlock = yflash2_QueryNANDBlock; | |
| 1 | 196 |
| 6 | 197 // /ram2k |
| 198 // Set this puppy up to use | |
| 199 // the file emulation space as | |
| 200 // 2kpage/64chunk per block/128MB device | |
| 201 memset(&ram2kDev,0,sizeof(ram2kDev)); | |
| 202 | |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
203 ram2kDev.totalBytesPerChunk = nandemul2k_GetBytesPerChunk(); |
| 6 | 204 ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock(); |
| 205 ram2kDev.nReservedBlocks = 5; | |
| 21 | 206 ram2kDev.startBlock = 0; // First block after /boot |
| 6 | 207 //ram2kDev.endBlock = 127; // Last block in 16MB |
| 208 ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB | |
| 209 ram2kDev.isYaffs2 = 1; | |
| 210 ram2kDev.nShortOpCaches = 10; // Use caches | |
| 211 ram2kDev.genericDevice = (void *) 3; // Used to identify the device in fstat. | |
| 212 ram2kDev.writeChunkWithTagsToNAND = nandemul2k_WriteChunkWithTagsToNAND; | |
| 213 ram2kDev.readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND; | |
| 214 ram2kDev.eraseBlockInNAND = nandemul2k_EraseBlockInNAND; | |
| 215 ram2kDev.initialiseNAND = nandemul2k_InitialiseNAND; | |
| 216 ram2kDev.markNANDBlockBad = nandemul2k_MarkNANDBlockBad; | |
| 217 ram2kDev.queryNANDBlock = nandemul2k_QueryNANDBlock; | |
| 218 | |
| 1 | 219 yaffs_initialise(yaffsfs_config); |
| 220 | |
| 221 return 0; | |
| 222 } | |
| 223 | |
| 224 | |
| 225 | |
| 138 | 226 void SetCheckpointReservedBlocks(int n) |
| 227 { | |
|
203
88a05fb266f0
Change checkpoint to calculate number of blocks required instead of using a hardcoded value
charles
parents:
182
diff
changeset
|
228 // flashDev.nCheckpointReservedBlocks = n; |
| 138 | 229 } |
| 1 | 230 |
