add a gpio feature for devices supporting the generic GPIO interface
[openwrt.git] / target / linux / brcm47xx / patches-2.6.23 / 500-lzma_initramfs.patch
1 Index: linux-2.6.23.1/scripts/gen_initramfs_list.sh
2 ===================================================================
3 --- linux-2.6.23.1.orig/scripts/gen_initramfs_list.sh 2007-11-16 02:26:47.821227881 +0100
4 +++ linux-2.6.23.1/scripts/gen_initramfs_list.sh 2007-11-16 02:45:42.753904007 +0100
5 @@ -287,7 +287,7 @@
6 if [ "${is_cpio_compressed}" = "compressed" ]; then
7 cat ${cpio_tfile} > ${output_file}
8 else
9 - cat ${cpio_tfile} | gzip -f -9 - > ${output_file}
10 + lzma e -lc1 -lp2 -pb2 ${cpio_tfile} ${output_file}
11 fi
12 [ -z ${cpio_file} ] && rm ${cpio_tfile}
13 fi
14 Index: linux-2.6.23.1/init/initramfs.c
15 ===================================================================
16 --- linux-2.6.23.1.orig/init/initramfs.c 2007-11-16 02:26:47.829228332 +0100
17 +++ linux-2.6.23.1/init/initramfs.c 2007-11-16 03:03:09.661563882 +0100
18 @@ -441,6 +441,69 @@
19 outcnt = 0;
20 }
21
22 +#include <linux/LzmaDecode.h>
23 +static int __init lzma_unzip(void)
24 +{
25 + unsigned int i; /* temp value */
26 + unsigned int lc; /* literal context bits */
27 + unsigned int lp; /* literal pos state bits */
28 + unsigned int pb; /* pos state bits */
29 + unsigned int osize; /* uncompressed size */
30 + unsigned char *workspace;
31 + unsigned char* outputbuffer;
32 + unsigned int outsizeProcessed = 0;
33 + int workspace_size;
34 + int res;
35 +
36 + // lzma args
37 + i = get_byte();
38 + lc = i % 9, i = i / 9;
39 + lp = i % 5, pb = i / 5;
40 +
41 + // skip dictionary size
42 + for (i = 0; i < 4; i++)
43 + get_byte();
44 +
45 + /* read the lower half of uncompressed size in the header */
46 + osize = ((unsigned int)get_byte()) +
47 + ((unsigned int)get_byte() << 8) +
48 + ((unsigned int)get_byte() << 16) +
49 + ((unsigned int)get_byte() << 24);
50 +
51 + /* skip rest of the header (upper half of uncompressed size) */
52 + for (i = 0; i < 4; i++)
53 + get_byte();
54 +
55 + workspace_size = ((LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp))) * sizeof(CProb)) + 100;
56 + printk( KERN_NOTICE "initramfs: LZMA lc=%d,lp=%d,pb=%d,origSize=%d\n",
57 + lc,lp,pb,osize);
58 + outputbuffer = kmalloc(osize, GFP_KERNEL);
59 + if (outputbuffer == 0) {
60 + printk(KERN_ERR "initramfs: Couldn't allocate lzma output buffer\n");
61 + return -1;
62 + }
63 +
64 + workspace = kmalloc(workspace_size, GFP_KERNEL);
65 + if (workspace == NULL) {
66 + printk(KERN_ERR "initramfs: Couldn't allocate lzma workspace\n");
67 + return -1;
68 + }
69 +
70 + res = LzmaDecode(workspace, workspace_size, lc, lp, pb, inbuf + inptr, insize - inptr, outputbuffer, osize, &outsizeProcessed);
71 + if( res != 0 ) {
72 + panic( KERN_ERR "initramfs: Lzma decode failure\n");
73 + return -1;
74 + }
75 +
76 + flush_buffer(outputbuffer, outsizeProcessed);
77 + inptr = insize;
78 +
79 + kfree(outputbuffer);
80 + kfree(workspace);
81 + state = Reset;
82 + return 0;
83 +}
84 +
85 static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
86 {
87 int written;
88 @@ -475,12 +538,28 @@
89 inptr = 0;
90 outcnt = 0; /* bytes in output buffer */
91 bytes_out = 0;
92 - crc = (ulg)0xffffffffL; /* shift register contents */
93 - makecrc();
94 - gunzip();
95 - if (state != Reset)
96 + if( inbuf[0] == 037 && ((inbuf[1] == 0213) || (inbuf[1] == 0236)))
97 + {
98 + printk( KERN_NOTICE "detected gzip initramfs\n");
99 + crc = (ulg)0xffffffffL; /* shift register contents */
100 + makecrc();
101 + gunzip();
102 + if (state != Reset)
103 error("junk in gzipped archive");
104 - this_header = saved_offset + inptr;
105 + }
106 + else if(!memcmp(inbuf+1, "\x00\x00\x80\x00", 4)) /* FIXME: hardcoded dictionary size */
107 + {
108 + printk( KERN_NOTICE "detected lzma initramfs\n");
109 + lzma_unzip();
110 + }
111 + else
112 + {
113 + // skip forward ?
114 + crc = (ulg)0xffffffffL; /* shift register contents */
115 + makecrc();
116 + gunzip();
117 + }
118 + this_header = saved_offset + inptr;
119 buf += inptr;
120 len -= inptr;
121 }
This page took 0.044883 seconds and 5 git commands to generate.