X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fyaffscfg2k.c;h=6d5f542fc4b0d0754a959a86b523fcde770a0453;hp=2bf5f33218a52720e1ed32f39791a26e70704432;hb=ea4200a7a79a0b43509f9267292aadbf16fba2a9;hpb=40b1e54e4e59aaeb6bafabcda5df47bddc5ecfee diff --git a/direct/yaffscfg2k.c b/direct/yaffscfg2k.c index 2bf5f33..6d5f542 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. @@ -13,7 +25,22 @@ #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_GC_DETAIL | + YAFFS_TRACE_ERASE | + YAFFS_TRACE_TRACING | + YAFFS_TRACE_ALLOCATE | + YAFFS_TRACE_CHECKPOINT | + YAFFS_TRACE_BAD_BLOCKS | + YAFFS_TRACE_VERIFY | + YAFFS_TRACE_VERIFY_NAND | + YAFFS_TRACE_VERIFY_FULL | +// (~0) | + + 0; + void yaffsfs_SetError(int err) @@ -35,6 +62,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) +{ + size_t 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. @@ -59,12 +110,19 @@ static yaffs_Device flashDev; static yaffs_Device ram2kDev; static yaffsfs_DeviceConfiguration yaffsfs_config[] = { - +#if 0 { "/ram", &ramDev}, { "/boot", &bootDev}, - { "/flash", &flashDev}, + { "/flash/", &flashDev}, { "/ram2k", &ram2kDev}, {(void *)0,(void *)0} +#else + { "/", &ramDev}, + { "/flash/boot", &bootDev}, + { "/flash/flash", &flashDev}, + { "/ram2k", &ram2kDev}, + {(void *)0,(void *)0} /* Null entry to terminate list */ +#endif }; @@ -77,10 +135,10 @@ int yaffs_StartUp(void) // Set up devices // /ram memset(&ramDev,0,sizeof(ramDev)); - ramDev.nBytesPerChunk = 512; + ramDev.nDataBytesPerChunk = 512; ramDev.nChunksPerBlock = 32; ramDev.nReservedBlocks = 2; // Set this smaller for RAM - ramDev.startBlock = 1; // Can't use block 0 + 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. @@ -92,10 +150,10 @@ int yaffs_StartUp(void) // /boot memset(&bootDev,0,sizeof(bootDev)); - bootDev.nBytesPerChunk = 512; + bootDev.nDataBytesPerChunk = 512; bootDev.nChunksPerBlock = 32; bootDev.nReservedBlocks = 5; - bootDev.startBlock = 1; // Can't use block 0 + bootDev.startBlock = 0; // Can use block 0 bootDev.endBlock = 63; // Last block //bootDev.useNANDECC = 0; // use YAFFS's ECC bootDev.nShortOpCaches = 10; // Use caches @@ -115,13 +173,17 @@ int yaffs_StartUp(void) // 2kpage/64chunk per block/128MB device memset(&flashDev,0,sizeof(flashDev)); - flashDev.nBytesPerChunk = 2048; + flashDev.nDataBytesPerChunk = 2048; flashDev.nChunksPerBlock = 64; flashDev.nReservedBlocks = 5; - flashDev.startBlock = 64; // First block after /boot - //flashDev.endBlock = 127; // Last block in 16MB - flashDev.endBlock = (32 * 1024 * 1024)/(flashDev.nBytesPerChunk * flashDev.nChunksPerBlock) - 1; // Last block in 512MB + flashDev.nCheckpointReservedBlocks = 5; + //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; @@ -137,10 +199,10 @@ int yaffs_StartUp(void) // 2kpage/64chunk per block/128MB device memset(&ram2kDev,0,sizeof(ram2kDev)); - ram2kDev.nBytesPerChunk = nandemul2k_GetBytesPerChunk(); + ram2kDev.nDataBytesPerChunk = nandemul2k_GetBytesPerChunk(); ram2kDev.nChunksPerBlock = nandemul2k_GetChunksPerBlock(); ram2kDev.nReservedBlocks = 5; - ram2kDev.startBlock = 1; // First block after /boot + ram2kDev.startBlock = 0; // First block after /boot //ram2kDev.endBlock = 127; // Last block in 16MB ram2kDev.endBlock = nandemul2k_GetNumberOfBlocks() - 1; // Last block in 512MB ram2kDev.isYaffs2 = 1; @@ -160,4 +222,8 @@ int yaffs_StartUp(void) +void SetCheckpointReservedBlocks(int n) +{ + flashDev.nCheckpointReservedBlocks = n; +}