add redboot parsing and rtl8169 fixes, enable r8169 and add the free ixp4xx ethernet...
[openwrt/svn-archive/archive.git] / target / linux / generic-2.6 / patches / 050-mtdpart_redboot_byteswap_partition_truncate.patch
1 --- linux-2.6.18/drivers/mtd/redboot.c.orig 2006-10-23 11:41:56.000000000 -0400
2 +++ linux-2.6.18/drivers/mtd/redboot.c 2006-10-23 11:42:09.000000000 -0400
3 @@ -92,22 +92,47 @@
4 * swab32(erasesize) then we know we are looking at
5 * a byte swapped FIS directory - swap all the entries!
6 * (NOTE: this is 'size' not 'data_length'; size is
7 - * the full size of the entry.)
8 + * the full size of the entry.)
9 + *
10 + * Handle cases where the FIS directory is less than
11 + * a full erase block (like combine FIS directory
12 + * and RedBoot config).
13 + *
14 + * IMHO the best solution would be to compute the
15 + * flash address of the RedBoot FIS directory and
16 + * compare that with the entry in the FIS directory
17 + * entry swabbed. However, I haven't yet figured out
18 + * how to compute that.
19 */
20 - if (swab32(buf[i].size) == master->erasesize) {
21 +
22 + unsigned long erasesize_mask = master->erasesize -1;
23 + unsigned long eraseaddr_mask = 0xFFFFFFFF ^ erasesize_mask;
24 +
25 + if (((swab32(buf[i].size)+erasesize_mask)
26 + & eraseaddr_mask) == master->erasesize) {
27 int j;
28 - for (j = 0; j < numslots && buf[j].name[0] != 0xff; ++j) {
29 +
30 + /* N.B. The full table being processed so adjust size now */
31 + numslots = swab32(buf[i].size) / sizeof (struct fis_image_desc);
32 + for (j = 0; j < numslots; ++j) {
33 /* The unsigned long fields were written with the
34 * wrong byte sex, name and pad have no byte sex.
35 - */
36 - swab32s(&buf[j].flash_base);
37 - swab32s(&buf[j].mem_base);
38 - swab32s(&buf[j].size);
39 - swab32s(&buf[j].entry_point);
40 - swab32s(&buf[j].data_length);
41 - swab32s(&buf[j].desc_cksum);
42 - swab32s(&buf[j].file_cksum);
43 + *
44 + * Only process non-deleted entries. Don't exit early.
45 + */
46 + if (buf[j].name[0] != 0xff) {
47 + swab32s(&buf[j].flash_base);
48 + swab32s(&buf[j].mem_base);
49 + swab32s(&buf[j].size);
50 + swab32s(&buf[j].entry_point);
51 + swab32s(&buf[j].data_length);
52 + swab32s(&buf[j].desc_cksum);
53 + swab32s(&buf[j].file_cksum);
54 + }
55 }
56 + } else {
57 + /* Update numslots based on actual FIS directory size */
58 + numslots = buf[i].size / sizeof (struct fis_image_desc);
59 }
60 break;
61 }