Can somebody please explain the functions below. I am using yaffs/direct,
ECC turned off.
When scanning the emfile during a mount there are ecc errors.
void yaffs_CalcTagsECC(yaffs_Tags *tags)
{
// Calculate an ecc
unsigned char *b = ((yaffs_TagsUnion *)tags)->asBytes;
unsigned i,j;
unsigned ecc = 0;
unsigned bit = 0;
tags->ecc = 0;
for(i = 0; i < 8; i++)
{
for(j = 1; j &0xff; j<<=1)
{
bit++;
if(b[i] & j)
{
ecc ^= bit;
}
}
}
tags->ecc = ecc; %%%I always
get a high value on ecc approx 64
}
int yaffs_CheckECCOnTags(yaffs_Tags *tags)
{
unsigned ecc = tags->ecc;
yaffs_CalcTagsECC(tags);
ecc ^= tags->ecc; %% Now my
ecc increases to approx 4096.
if(ecc && ecc <= 64)
{
// TODO: Handle the failure better. Retire?
unsigned char *b = ((yaffs_TagsUnion *)tags)->asBytes;
ecc--;
b[ecc / 8] ^= (1 << (ecc & 7));
// Now recvalc the ecc
yaffs_CalcTagsECC(tags);
return 1; // recovered error
}
else if(ecc)
{
// Wierd ecc failure value
%%%% I always end up here.
// TODO Need to do somethiong here
return -1; //unrecovered error
}
return 0;
}
//Daniel