X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fyaffscfg2k.c;h=6cc8e75cde4ca8bfc4a686679c95e287e9152a04;hp=c2cd1c92987c1b9ea2df067192a71436c3dc3c47;hb=6ce07c3f6215ce6a4f4b7fe520ef48e8cf71c7cb;hpb=e1b8e63260986ab7afec3c379e7a320677c95846 diff --git a/direct/yaffscfg2k.c b/direct/yaffscfg2k.c index c2cd1c9..6cc8e75 100644 --- a/direct/yaffscfg2k.c +++ b/direct/yaffscfg2k.c @@ -1,6 +1,18 @@ /* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * yaffscfg.c The configuration for the "direct" use of yaffs. + * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. + * + * Copyright (C) 2002-2007 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Charles Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * yaffscfg2k.c The configuration for the "direct" use of yaffs. * * This file is intended to be modified to your requirements. * There is no need to redistribute this file. @@ -10,16 +22,38 @@ #include "yaffsfs.h" #include "yaffs_fileem2k.h" #include "yaffs_nandemul2k.h" +#include "yaffs_norif1.h" #include -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; +unsigned yaffs_traceMask = + YAFFS_TRACE_SCAN | + YAFFS_TRACE_GC | + YAFFS_TRACE_ERASE | + YAFFS_TRACE_ERROR | + YAFFS_TRACE_TRACING | + YAFFS_TRACE_ALLOCATE | + YAFFS_TRACE_CHECKPOINT | + YAFFS_TRACE_BAD_BLOCKS | + + YAFFS_TRACE_VERIFY | + + 0; + + +static int yaffsfs_lastError; void yaffsfs_SetError(int err) { //Do whatever to set error - errno = err; + yaffsfs_lastError = err; +} + + +int yaffsfs_GetLastError(void) +{ + return yaffsfs_lastError; } void yaffsfs_Lock(void) @@ -35,6 +69,30 @@ __u32 yaffsfs_CurrentTime(void) return 0; } + +static int yaffs_kill_alloc = 0; +static size_t total_malloced = 0; +static size_t malloc_limit = 0 & 6000000; + +void *yaffs_malloc(size_t size) +{ + void * this; + if(yaffs_kill_alloc) + return NULL; + if(malloc_limit && malloc_limit <(total_malloced + size) ) + return NULL; + + this = malloc(size); + if(this) + total_malloced += size; + return this; +} + +void yaffs_free(void *ptr) +{ + free(ptr); +} + void yaffsfs_LocalInitialisation(void) { // Define locking semaphore. @@ -51,27 +109,22 @@ void yaffsfs_LocalInitialisation(void) #include "yaffs_ramdisk.h" #include "yaffs_flashif.h" +#include "yaffs_flashif2.h" #include "yaffs_nandemul2k.h" -static yaffs_Device ramDev; -static yaffs_Device bootDev; +static yaffs_Device ram1Dev; +static yaffs_Device nand2; static yaffs_Device flashDev; static yaffs_Device ram2kDev; +static yaffs_Device m18_1Dev; static yaffsfs_DeviceConfiguration yaffsfs_config[] = { -#if 0 - { "/ram", &ramDev}, - { "/boot", &bootDev}, - { "/flash/", &flashDev}, - { "/ram2k", &ram2kDev}, - {(void *)0,(void *)0} -#else - { "/", &ramDev}, - { "/flash/boot", &bootDev}, - { "/flash/flash", &flashDev}, + + { "/ram1", &ram1Dev}, + { "/M18-1", &m18_1Dev}, + { "/yaffs2", &flashDev}, { "/ram2k", &ram2kDev}, {(void *)0,(void *)0} /* Null entry to terminate list */ -#endif }; @@ -82,64 +135,63 @@ int yaffs_StartUp(void) yaffsfs_LocalInitialisation(); // Set up devices - // /ram - memset(&ramDev,0,sizeof(ramDev)); - ramDev.nBytesPerChunk = 512; - ramDev.nChunksPerBlock = 32; - ramDev.nReservedBlocks = 2; // Set this smaller for RAM - ramDev.startBlock = 0; // Can use block 0 - ramDev.endBlock = 127; // Last block in 2MB. - //ramDev.useNANDECC = 1; - ramDev.nShortOpCaches = 0; // Disable caching on this device. - ramDev.genericDevice = (void *) 0; // Used to identify the device in fstat. - ramDev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND; - ramDev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND; - ramDev.eraseBlockInNAND = yramdisk_EraseBlockInNAND; - ramDev.initialiseNAND = yramdisk_InitialiseNAND; - - // /boot - memset(&bootDev,0,sizeof(bootDev)); - bootDev.nBytesPerChunk = 512; - bootDev.nChunksPerBlock = 32; - bootDev.nReservedBlocks = 5; - bootDev.startBlock = 0; // Can use block 0 - bootDev.endBlock = 63; // Last block - //bootDev.useNANDECC = 0; // use YAFFS's ECC - bootDev.nShortOpCaches = 10; // Use caches - bootDev.genericDevice = (void *) 1; // Used to identify the device in fstat. - bootDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND; - bootDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND; - bootDev.eraseBlockInNAND = yflash_EraseBlockInNAND; - bootDev.initialiseNAND = yflash_InitialiseNAND; - bootDev.markNANDBlockBad = yflash_MarkNANDBlockBad; - bootDev.queryNANDBlock = yflash_QueryNANDBlock; - - - - // /flash + // /ram1 ram, yaffs1 + memset(&ram1Dev,0,sizeof(ram1Dev)); + ram1Dev.totalBytesPerChunk = 512; + ram1Dev.nChunksPerBlock = 32; + ram1Dev.nReservedBlocks = 2; // Set this smaller for RAM + ram1Dev.startBlock = 0; // Can use block 0 + ram1Dev.endBlock = 127; // Last block in 2MB. + //ram1Dev.useNANDECC = 1; + ram1Dev.nShortOpCaches = 0; // Disable caching on this device. + ram1Dev.genericDevice = (void *) 0; // Used to identify the device in fstat. + ram1Dev.writeChunkWithTagsToNAND = yramdisk_WriteChunkWithTagsToNAND; + ram1Dev.readChunkWithTagsFromNAND = yramdisk_ReadChunkWithTagsFromNAND; + ram1Dev.eraseBlockInNAND = yramdisk_EraseBlockInNAND; + ram1Dev.initialiseNAND = yramdisk_InitialiseNAND; + + // /M18-1 yaffs1 on M18 nor sim + memset(&m18_1Dev,0,sizeof(m18_1Dev)); + m18_1Dev.totalBytesPerChunk = 1024; + m18_1Dev.nChunksPerBlock =248; + m18_1Dev.nReservedBlocks = 2; + m18_1Dev.startBlock = 0; // Can use block 0 + m18_1Dev.endBlock = 31; // Last block + m18_1Dev.useNANDECC = 0; // use YAFFS's ECC + m18_1Dev.nShortOpCaches = 10; // Use caches + m18_1Dev.genericDevice = (void *) 1; // Used to identify the device in fstat. + m18_1Dev.writeChunkToNAND = ynorif1_WriteChunkToNAND; + m18_1Dev.readChunkFromNAND = ynorif1_ReadChunkFromNAND; + m18_1Dev.eraseBlockInNAND = ynorif1_EraseBlockInNAND; + m18_1Dev.initialiseNAND = ynorif1_InitialiseNAND; + m18_1Dev.deinitialiseNAND = ynorif1_DeinitialiseNAND; + + + // /flash (yaffs2) // Set this puppy up to use // the file emulation space as // 2kpage/64chunk per block/128MB device memset(&flashDev,0,sizeof(flashDev)); - flashDev.nBytesPerChunk = 2048; + flashDev.totalBytesPerChunk = 512; flashDev.nChunksPerBlock = 64; flashDev.nReservedBlocks = 5; - flashDev.checkpointStartBlock = 1; - flashDev.checkpointEndBlock = 20; - flashDev.startBlock = 21; - //flashDev.endBlock = 127; // Last block in 16MB - flashDev.endBlock = yflash_GetNumberOfBlocks()-1; + flashDev.inbandTags = 1; + //flashDev.checkpointStartBlock = 1; + //flashDev.checkpointEndBlock = 20; + flashDev.startBlock = 0; + flashDev.endBlock = 200; // Make it smaller + //flashDev.endBlock = yflash_GetNumberOfBlocks()-1; flashDev.isYaffs2 = 1; flashDev.wideTnodesDisabled=0; flashDev.nShortOpCaches = 10; // Use caches flashDev.genericDevice = (void *) 2; // Used to identify the device in fstat. - flashDev.writeChunkWithTagsToNAND = yflash_WriteChunkWithTagsToNAND; - flashDev.readChunkWithTagsFromNAND = yflash_ReadChunkWithTagsFromNAND; - flashDev.eraseBlockInNAND = yflash_EraseBlockInNAND; - flashDev.initialiseNAND = yflash_InitialiseNAND; - flashDev.markNANDBlockBad = yflash_MarkNANDBlockBad; - flashDev.queryNANDBlock = yflash_QueryNANDBlock; + flashDev.writeChunkWithTagsToNAND = yflash2_WriteChunkWithTagsToNAND; + flashDev.readChunkWithTagsFromNAND = yflash2_ReadChunkWithTagsFromNAND; + flashDev.eraseBlockInNAND = yflash2_EraseBlockInNAND; + flashDev.initialiseNAND = yflash2_InitialiseNAND; + flashDev.markNANDBlockBad = yflash2_MarkNANDBlockBad; + flashDev.queryNANDBlock = yflash2_QueryNANDBlock; // /ram2k // Set this puppy up to use @@ -147,7 +199,7 @@ int yaffs_StartUp(void) // 2kpage/64chunk per block/128MB device memset(&ram2kDev,0,sizeof(ram2kDev)); - ram2kDev.nBytesPerChunk = nandemul2k_GetBytesPerChunk(); + ram2kDev.totalBytesPerChunk = nandemul2k_GetBytesPerChunk(); ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock(); ram2kDev.nReservedBlocks = 5; ram2kDev.startBlock = 0; // First block after /boot @@ -170,4 +222,8 @@ int yaffs_StartUp(void) +void SetCheckpointReservedBlocks(int n) +{ +// flashDev.nCheckpointReservedBlocks = n; +}