Mercurial > yaffs-ecoscentric
annotate 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 |
| 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_BAD_BLOCKS | | |
| 248 | 38 YAFFS_TRACE_VERIFY | |
| 160 | 39 |
| 40 0; | |
| 41 | |
| 1 | 42 |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
43 static int yaffsfs_lastError; |
| 1 | 44 |
| 45 void yaffsfs_SetError(int err) | |
| 46 { | |
| 47 //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
|
48 yaffsfs_lastError = err; |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
49 } |
|
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
50 |
|
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 int yaffsfs_GetLastError(void) |
|
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 return yaffsfs_lastError; |
| 1 | 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 | |
| 182 | 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 { | |
|
211
fad21fd1971d
Check in inband tags, some extra yaffs direct functions and some other changes
charles
parents:
203
diff
changeset
|
77 void * this; |
| 182 | 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 | |
| 1 | 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" | |
| 215 | 110 #include "yaffs_flashif2.h" |
| 6 | 111 #include "yaffs_nandemul2k.h" |
| 1 | 112 |
| 231 | 113 static yaffs_Device ram1Dev; |
| 114 static yaffs_Device nand2; | |
| 1 | 115 static yaffs_Device flashDev; |
| 6 | 116 static yaffs_Device ram2kDev; |
| 231 | 117 static yaffs_Device m18_1Dev; |
| 1 | 118 |
| 119 static yaffsfs_DeviceConfiguration yaffsfs_config[] = { | |
| 231 | 120 |
| 121 { "/ram1", &ram1Dev}, | |
| 122 { "/M18-1", &m18_1Dev}, | |
| 123 { "/yaffs2", &flashDev}, | |
| 94 | 124 { "/ram2k", &ram2kDev}, |
| 105 | 125 {(void *)0,(void *)0} /* Null entry to terminate list */ |
| 1 | 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 | |
| 231 | 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; | |
| 1 | 150 |
| 231 | 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 | |
|
236
d74a9a8c1f49
Reduce size for nor simulation testing to try force errors
charles
parents:
231
diff
changeset
|
157 m18_1Dev.endBlock = 31; // Last block |
| 231 | 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; | |
| 1 | 166 |
| 167 | |
| 256 | 168 // /yaffs2 |
| 1 | 169 // Set this puppy up to use |
| 170 // the file emulation space as | |
| 256 | 171 // 2kpage/64chunk per block |
| 172 // | |
| 1 | 173 memset(&flashDev,0,sizeof(flashDev)); |
| 174 | |
| 256 | 175 flashDev.totalBytesPerChunk = 2048; |
| 1 | 176 flashDev.nChunksPerBlock = 64; |
| 177 flashDev.nReservedBlocks = 5; | |
| 256 | 178 flashDev.inbandTags = 0; |
| 160 | 179 flashDev.startBlock = 0; |
| 256 | 180 flashDev.endBlock = yflash2_GetNumberOfBlocks()-1; |
| 1 | 181 flashDev.isYaffs2 = 1; |
| 105 | 182 flashDev.wideTnodesDisabled=0; |
| 1 | 183 flashDev.nShortOpCaches = 10; // Use caches |
| 184 flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat. | |
| 215 | 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; | |
| 1 | 191 |
| 6 | 192 |
| 1 | 193 yaffs_initialise(yaffsfs_config); |
| 194 | |
| 195 return 0; | |
| 196 } | |
| 197 | |
| 198 | |
| 199 | |
| 138 | 200 void SetCheckpointReservedBlocks(int n) |
| 201 { | |
|
203
88a05fb266f0
Change checkpoint to calculate number of blocks required instead of using a hardcoded value
charles
parents:
182
diff
changeset
|
202 // flashDev.nCheckpointReservedBlocks = n; |
| 138 | 203 } |
| 1 | 204 |
