1 // Program to generate a column parity table for yaffs_ecc.c
5 // Generate a column parity byte for a byte.
6 // This byte is already aligned for the ecc.
7 // The output byte has the form:
15 // bit 0 of the output byte holds the line parity.
16 unsigned char entry(unsigned char x)
18 unsigned char b0, b1, b2, b3, b4, b5, b6, b7;
19 unsigned char p4, p2, p1, p4p, p2p, p1p;
23 b0 = (x & 0x01) ? 1 : 0;
24 b1 = (x & 0x02) ? 1 : 0;
25 b2 = (x & 0x04) ? 1 : 0;
26 b3 = (x & 0x08) ? 1 : 0;
27 b4 = (x & 0x10) ? 1 : 0;
28 b5 = (x & 0x20) ? 1 : 0;
29 b6 = (x & 0x40) ? 1 : 0;
30 b7 = (x & 0x80) ? 1 : 0;
32 p4 = b7 ^ b6 ^ b5 ^ b4; p4p = b3 ^ b2 ^ b1 ^ b0;
33 p2 = b7 ^ b6 ^ b3 ^ b2; p2p = b5 ^ b4 ^ b1 ^ b0;
34 p1 = b7 ^ b5 ^ b3 ^ b1; p1p = b6 ^ b4 ^ b2 ^ b0;
39 if(p4) result |= 0x80;
40 if(p4p) result |= 0x40;
41 if(p2) result |= 0x20;
42 if(p2p) result |= 0x10;
43 if(p1) result |= 0x08;
44 if(p1p) result |= 0x04;
45 if(linep) result |= 0x01;
48 //if(linep) result |= 0x40;
55 int main(int argc, char *argv[])
59 printf("const unsigned char column_parity_table[] = {");
60 for(i = 0; i < 256; i++)
62 if((i & 0xf) == 0) printf("\n");
63 printf("0x%02x, ",entry((unsigned char) i));