X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_tagscompat.c;h=f6c40535088c05a9317c19a8324980ef6d5fa028;hp=d594d6193245ff7ae2f09c5ea063906c56bf7225;hb=a6328592d74d696a9c8fbeb222e69c81e26fa78d;hpb=e1ac494e05a5dc7ab61d799af815d103a11d318c diff --git a/yaffs_tagscompat.c b/yaffs_tagscompat.c index d594d61..f6c4053 100644 --- a/yaffs_tagscompat.c +++ b/yaffs_tagscompat.c @@ -14,6 +14,7 @@ #include "yaffs_guts.h" #include "yaffs_tagscompat.h" #include "yaffs_ecc.h" +#include "yaffs_getblockinfo.h" static void yaffs_HandleReadDataError(yaffs_Device * dev, int chunkInNAND); #ifdef NOTYET @@ -45,7 +46,7 @@ static const char yaffs_countBitsTable[256] = { 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }; -static int yaffs_CountBits(__u8 x) +int yaffs_CountBits(__u8 x) { int retVal; retVal = yaffs_countBitsTable[x]; @@ -252,6 +253,9 @@ static int yaffs_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev, /* Must allocate enough memory for spare+2*sizeof(int) */ /* for ecc results from device. */ struct yaffs_NANDSpare nspare; + + memset(&nspare,0,sizeof(nspare)); + retVal = dev->readChunkFromNAND(dev, chunkInNAND, data, (yaffs_Spare *) & nspare); @@ -336,7 +340,7 @@ static void yaffs_HandleReadDataError(yaffs_Device * dev, int chunkInNAND) int blockInNAND = chunkInNAND / dev->nChunksPerBlock; /* Mark the block for retirement */ - yaffs_GetBlockInfo(dev, blockInNAND)->needsRetiring = 1; + yaffs_GetBlockInfo(dev, blockInNAND + dev->blockOffset)->needsRetiring = 1; T(YAFFS_TRACE_ERROR | YAFFS_TRACE_BAD_BLOCKS, (TSTR("**>>Block %d marked for retirement" TENDSTR), blockInNAND)); @@ -414,7 +418,16 @@ int yaffs_TagsCompatabilityWriteChunkWithTagsToNAND(yaffs_Device * dev, } else { tags.objectId = eTags->objectId; tags.chunkId = eTags->chunkId; - tags.byteCount = eTags->byteCount; + + tags.byteCountLSB = eTags->byteCount & 0x3ff; + + if(dev->nDataBytesPerChunk >= 1024){ + tags.byteCountMSB = (eTags->byteCount >> 10) & 3; + } else { + tags.byteCountMSB = 3; + } + + tags.serialNumber = eTags->serialNumber; if (!dev->useNANDECC && data) { @@ -435,10 +448,10 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev, yaffs_Spare spare; yaffs_Tags tags; - yaffs_ECCResult eccResult; + yaffs_ECCResult eccResult = YAFFS_ECC_RESULT_UNKNOWN; static yaffs_Spare spareFF; - static int init; + static int init = 0; if (!init) { memset(&spareFF, 0xFF, sizeof(spareFF)); @@ -466,7 +479,11 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev, eTags->objectId = tags.objectId; eTags->chunkId = tags.chunkId; - eTags->byteCount = tags.byteCount; + eTags->byteCount = tags.byteCountLSB; + + if(dev->nDataBytesPerChunk >= 1024) + eTags->byteCount |= (((unsigned) tags.byteCountMSB) << 10); + eTags->serialNumber = tags.serialNumber; } } @@ -497,9 +514,9 @@ int yaffs_TagsCompatabilityMarkNANDBlockBad(struct yaffs_DeviceStruct *dev, } int yaffs_TagsCompatabilityQueryNANDBlock(struct yaffs_DeviceStruct *dev, - int blockNo, yaffs_BlockState * - state, - int *sequenceNumber) + int blockNo, + yaffs_BlockState *state, + __u32 *sequenceNumber) { yaffs_Spare spare0, spare1;