wok annotate linux/stuff/linux-lzma-loram-2.6.24.2.u @ rev 1816

Up: gftp 2.0.19
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Fri Dec 05 15:05:12 2008 +0100 (2008-12-05)
parents
children
rev   line source
pascal@881 1 --- linux-2.6.24.2/init/initramfs.c
pascal@881 2 +++ linux-2.6.24.2/init/initramfs.c
pascal@881 3 @@ -468,6 +468,29 @@
pascal@881 4 }
pascal@881 5 #endif
pascal@881 6
pascal@881 7 +#include <linux/initrd.h>
pascal@881 8 +#ifdef CONFIG_RD_LZMA
pascal@881 9 +#define INITRD_PAGE ((PAGE_SIZE > 1024*1024) ? PAGE_SIZE : 1024*1024)
pascal@881 10 +static int fill_offset, fill_total;
pascal@881 11 +static int fill_buffer(void *buffer, unsigned size)
pascal@881 12 +{
pascal@881 13 + int max = initrd_end - initrd_start - fill_offset;
pascal@881 14 + if (size < max) max = size;
pascal@881 15 + memcpy(buffer, (void *)(initrd_start + fill_offset), max);
pascal@881 16 + fill_offset += max;
pascal@881 17 + fill_total += max;
pascal@881 18 + if (fill_offset >= INITRD_PAGE) {
pascal@881 19 + unsigned rem = fill_offset % INITRD_PAGE;
pascal@881 20 + unsigned end = initrd_start + fill_offset - rem;
pascal@881 21 + free_initrd_mem(initrd_start, end);
pascal@881 22 + printk(".");
pascal@881 23 + initrd_start = end;
pascal@881 24 + fill_offset = rem;
pascal@881 25 + }
pascal@881 26 + return max;
pascal@881 27 +}
pascal@881 28 +#endif
pascal@881 29 +
pascal@881 30 static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
pascal@881 31 {
pascal@881 32 int written;
pascal@881 33 @@ -484,6 +507,9 @@
pascal@881 34 this_header = 0;
pascal@881 35 message = NULL;
pascal@881 36 while (!message && len) {
pascal@881 37 +#ifdef CONFIG_RD_LZMA
pascal@881 38 + int status;
pascal@881 39 +#endif
pascal@881 40 loff_t saved_offset = this_header;
pascal@881 41 if (*buf == '0' && !(this_header & 3)) {
pascal@881 42 state = Start;
pascal@881 43 @@ -523,8 +549,20 @@
pascal@881 44 #ifdef CONFIG_RD_LZMA
pascal@881 45 message = NULL; /* Zero out message, or else cpio will
pascal@881 46 think an error has already occured */
pascal@881 47 - if(!unlzma(buf, len, NULL, flush_buffer, &inptr) < 0 &&
pascal@881 48 - message == NULL) {
pascal@881 49 + status = -1;
pascal@881 50 + if(buf == (char *) initrd_start) {
pascal@881 51 + char *work_buffer = malloc(LZMA_IOBUF_SIZE);
pascal@881 52 + if (work_buffer) {
pascal@881 53 + fill_total = fill_offset = 0;
pascal@881 54 + fill_buffer(work_buffer, LZMA_IOBUF_SIZE);
pascal@881 55 + status = unlzma(work_buffer, LZMA_IOBUF_SIZE,
pascal@881 56 + fill_buffer, flush_buffer, NULL);
pascal@881 57 + inptr = fill_total;
pascal@881 58 + free(work_buffer);
pascal@881 59 + }
pascal@881 60 + }
pascal@881 61 + else status = unlzma(buf,len, NULL, flush_buffer, &inptr);
pascal@881 62 + if (status == 0 && message == NULL) {
pascal@881 63 goto ok;
pascal@881 64 }
pascal@881 65 #endif
pascal@881 66
pascal@881 67 --- linux-2.6.24.2/arch/x86/mm/init_32.c
pascal@881 68 +++ linux-2.6.24.2/arch/x86/mm/init_32.c
pascal@881 69 @@ -834,7 +834,8 @@
pascal@881 70 free_page(addr);
pascal@881 71 totalram_pages++;
pascal@881 72 }
pascal@881 73 - printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
pascal@881 74 + if (what)
pascal@881 75 + printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
pascal@881 76 }
pascal@881 77
pascal@881 78 void free_initmem(void)
pascal@881 79 @@ -847,7 +848,7 @@
pascal@881 80 #ifdef CONFIG_BLK_DEV_INITRD
pascal@881 81 void free_initrd_mem(unsigned long start, unsigned long end)
pascal@881 82 {
pascal@881 83 - free_init_pages("initrd memory", start, end);
pascal@881 84 + free_init_pages(NULL, start, end);
pascal@881 85 }
pascal@881 86 #endif
pascal@881 87
pascal@881 88
pascal@881 89 --- linux-2.6.24.2/lib/decompress_unlzma.c
pascal@881 90 +++ linux-2.6.24.2/lib/decompress_unlzma.c
pascal@881 91 @@ -366,7 +366,8 @@
pascal@881 92 header.dict_size = 1;
pascal@881 93
pascal@881 94 bufsize = MIN(header.dst_size, header.dict_size);
pascal@881 95 - buffer = large_malloc(bufsize);
pascal@881 96 + buffer = (uint8_t *) posp;
pascal@881 97 + if (writebb) buffer = large_malloc(bufsize);
pascal@881 98 if(buffer == NULL)
pascal@881 99 return -1;
pascal@881 100
pascal@881 101 @@ -394,10 +395,12 @@
pascal@881 102 int match_byte;
pascal@881 103
pascal@881 104 pos = buffer_pos - rep0;
pascal@881 105 - while (pos >= header.dict_size)
pascal@881 106 - pos += header.dict_size;
pascal@881 107 - if(pos >= bufsize) {
pascal@881 108 - goto fail;
pascal@881 109 + if (writebb) {
pascal@881 110 + while (pos >= header.dict_size)
pascal@881 111 + pos += header.dict_size;
pascal@881 112 + if(pos >= bufsize) {
pascal@881 113 + goto fail;
pascal@881 114 + }
pascal@881 115 }
pascal@881 116 match_byte = buffer[pos];
pascal@881 117 do {
pascal@881 118 @@ -419,20 +422,14 @@
pascal@881 119 prob_lit = prob + mi;
pascal@881 120 rc_get_bit(&rc, prob_lit, &mi);
pascal@881 121 }
pascal@881 122 + previous_byte = (uint8_t) mi;
pascal@881 123 if (state < 4)
pascal@881 124 state = 0;
pascal@881 125 else if (state < 10)
pascal@881 126 state -= 3;
pascal@881 127 else
pascal@881 128 state -= 6;
pascal@881 129 - previous_byte = (uint8_t) mi;
pascal@881 130 - one_byte:
pascal@881 131 - buffer[buffer_pos++] = previous_byte;
pascal@881 132 - if (buffer_pos == header.dict_size) {
pascal@881 133 - buffer_pos = 0;
pascal@881 134 - global_pos += header.dict_size;
pascal@881 135 - writebb((char*)buffer, header.dict_size);
pascal@881 136 - }
pascal@881 137 + goto store_previous_byte;
pascal@881 138 } else {
pascal@881 139 int offset;
pascal@881 140 uint16_t *prob_len;
pascal@881 141 @@ -457,14 +454,23 @@
pascal@881 142 rc_update_bit_0(&rc, prob);
pascal@881 143
pascal@881 144 state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
pascal@881 145 - pos = buffer_pos - rep0;
pascal@881 146 - while (pos >= header.dict_size)
pascal@881 147 - pos += header.dict_size;
pascal@881 148 - if(pos >= bufsize) {
pascal@881 149 - goto fail;
pascal@881 150 + pos = buffer_pos - rep0;
pascal@881 151 + if (writebb) {
pascal@881 152 + while (pos >= header.dict_size)
pascal@881 153 + pos += header.dict_size;
pascal@881 154 + if(pos >= bufsize) {
pascal@881 155 + goto fail;
pascal@881 156 + }
pascal@881 157 }
pascal@881 158 previous_byte = buffer[pos];
pascal@881 159 - goto one_byte;
pascal@881 160 + store_previous_byte:
pascal@881 161 + buffer[buffer_pos++] = previous_byte;
pascal@881 162 + if (writebb && buffer_pos == header.dict_size) {
pascal@881 163 + buffer_pos = 0;
pascal@881 164 + global_pos += header.dict_size;
pascal@881 165 + writebb((char*)buffer, header.dict_size);
pascal@881 166 + }
pascal@881 167 + continue;
pascal@881 168 } else {
pascal@881 169 rc_update_bit_1(&rc, prob);
pascal@881 170 }
pascal@881 171 @@ -566,14 +572,16 @@
pascal@881 172
pascal@881 173 do {
pascal@881 174 pos = buffer_pos - rep0;
pascal@881 175 - while (pos >= header.dict_size)
pascal@881 176 - pos += header.dict_size;
pascal@881 177 - if(pos >= bufsize) {
pascal@881 178 - goto fail;
pascal@881 179 + if (writebb) {
pascal@881 180 + while (pos >= header.dict_size)
pascal@881 181 + pos += header.dict_size;
pascal@881 182 + if(pos >= bufsize) {
pascal@881 183 + goto fail;
pascal@881 184 + }
pascal@881 185 }
pascal@881 186 previous_byte = buffer[pos];
pascal@881 187 buffer[buffer_pos++] = previous_byte;
pascal@881 188 - if (buffer_pos == header.dict_size) {
pascal@881 189 + if (writebb && buffer_pos == header.dict_size) {
pascal@881 190 buffer_pos = 0;
pascal@881 191 global_pos += header.dict_size;
pascal@881 192 writebb((char*)buffer, header.dict_size);
pascal@881 193 @@ -583,15 +591,17 @@
pascal@881 194 }
pascal@881 195 }
pascal@881 196
pascal@881 197 - writebb((char*)buffer, buffer_pos);
pascal@881 198 - if(posp) {
pascal@881 199 - *posp = rc.ptr-rc.buffer;
pascal@881 200 + if (writebb) {
pascal@881 201 + writebb((char*)buffer, buffer_pos);
pascal@881 202 + if(posp) {
pascal@881 203 + *posp = rc.ptr-rc.buffer;
pascal@881 204 + }
pascal@881 205 + large_free(buffer);
pascal@881 206 }
pascal@881 207 - large_free(buffer);
pascal@881 208 large_free(p);
pascal@881 209 return 0;
pascal@881 210 fail:
pascal@881 211 - large_free(buffer);
pascal@881 212 + if (writebb) large_free(buffer);
pascal@881 213 large_free(p);
pascal@881 214 return -1;
pascal@881 215 }
pascal@881 216
pascal@881 217 --- linux-2.6.24.2/arch/x86/boot/compressed/misc_32.c
pascal@881 218 +++ linux-2.6.24.2/arch/x86/boot/compressed/misc_32.c
pascal@881 219 @@ -444,7 +444,7 @@
pascal@881 220
pascal@881 221 #ifdef CONFIG_KERNEL_LZMA
pascal@881 222 putstr("Unlzmaing Linux... ");
pascal@881 223 - unlzma(input_data, input_len-4, NULL, compr_flush, NULL);
pascal@881 224 + unlzma(input_data, input_len-4, NULL, NULL, window);
pascal@881 225 #endif
pascal@881 226
pascal@881 227 #ifdef CONFIG_KERNEL_GZIP