wok diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/linux/stuff/linux-lzma-loram-2.6.24.2.u Fri Dec 05 15:05:12 2008 +0100 1.3 @@ -0,0 +1,227 @@ 1.4 +--- linux-2.6.24.2/init/initramfs.c 1.5 ++++ linux-2.6.24.2/init/initramfs.c 1.6 +@@ -468,6 +468,29 @@ 1.7 + } 1.8 + #endif 1.9 + 1.10 ++#include <linux/initrd.h> 1.11 ++#ifdef CONFIG_RD_LZMA 1.12 ++#define INITRD_PAGE ((PAGE_SIZE > 1024*1024) ? PAGE_SIZE : 1024*1024) 1.13 ++static int fill_offset, fill_total; 1.14 ++static int fill_buffer(void *buffer, unsigned size) 1.15 ++{ 1.16 ++ int max = initrd_end - initrd_start - fill_offset; 1.17 ++ if (size < max) max = size; 1.18 ++ memcpy(buffer, (void *)(initrd_start + fill_offset), max); 1.19 ++ fill_offset += max; 1.20 ++ fill_total += max; 1.21 ++ if (fill_offset >= INITRD_PAGE) { 1.22 ++ unsigned rem = fill_offset % INITRD_PAGE; 1.23 ++ unsigned end = initrd_start + fill_offset - rem; 1.24 ++ free_initrd_mem(initrd_start, end); 1.25 ++ printk("."); 1.26 ++ initrd_start = end; 1.27 ++ fill_offset = rem; 1.28 ++ } 1.29 ++ return max; 1.30 ++} 1.31 ++#endif 1.32 ++ 1.33 + static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) 1.34 + { 1.35 + int written; 1.36 +@@ -484,6 +507,9 @@ 1.37 + this_header = 0; 1.38 + message = NULL; 1.39 + while (!message && len) { 1.40 ++#ifdef CONFIG_RD_LZMA 1.41 ++ int status; 1.42 ++#endif 1.43 + loff_t saved_offset = this_header; 1.44 + if (*buf == '0' && !(this_header & 3)) { 1.45 + state = Start; 1.46 +@@ -523,8 +549,20 @@ 1.47 + #ifdef CONFIG_RD_LZMA 1.48 + message = NULL; /* Zero out message, or else cpio will 1.49 + think an error has already occured */ 1.50 +- if(!unlzma(buf, len, NULL, flush_buffer, &inptr) < 0 && 1.51 +- message == NULL) { 1.52 ++ status = -1; 1.53 ++ if(buf == (char *) initrd_start) { 1.54 ++ char *work_buffer = malloc(LZMA_IOBUF_SIZE); 1.55 ++ if (work_buffer) { 1.56 ++ fill_total = fill_offset = 0; 1.57 ++ fill_buffer(work_buffer, LZMA_IOBUF_SIZE); 1.58 ++ status = unlzma(work_buffer, LZMA_IOBUF_SIZE, 1.59 ++ fill_buffer, flush_buffer, NULL); 1.60 ++ inptr = fill_total; 1.61 ++ free(work_buffer); 1.62 ++ } 1.63 ++ } 1.64 ++ else status = unlzma(buf,len, NULL, flush_buffer, &inptr); 1.65 ++ if (status == 0 && message == NULL) { 1.66 + goto ok; 1.67 + } 1.68 + #endif 1.69 + 1.70 +--- linux-2.6.24.2/arch/x86/mm/init_32.c 1.71 ++++ linux-2.6.24.2/arch/x86/mm/init_32.c 1.72 +@@ -834,7 +834,8 @@ 1.73 + free_page(addr); 1.74 + totalram_pages++; 1.75 + } 1.76 +- printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); 1.77 ++ if (what) 1.78 ++ printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); 1.79 + } 1.80 + 1.81 + void free_initmem(void) 1.82 +@@ -847,7 +848,7 @@ 1.83 + #ifdef CONFIG_BLK_DEV_INITRD 1.84 + void free_initrd_mem(unsigned long start, unsigned long end) 1.85 + { 1.86 +- free_init_pages("initrd memory", start, end); 1.87 ++ free_init_pages(NULL, start, end); 1.88 + } 1.89 + #endif 1.90 + 1.91 + 1.92 +--- linux-2.6.24.2/lib/decompress_unlzma.c 1.93 ++++ linux-2.6.24.2/lib/decompress_unlzma.c 1.94 +@@ -366,7 +366,8 @@ 1.95 + header.dict_size = 1; 1.96 + 1.97 + bufsize = MIN(header.dst_size, header.dict_size); 1.98 +- buffer = large_malloc(bufsize); 1.99 ++ buffer = (uint8_t *) posp; 1.100 ++ if (writebb) buffer = large_malloc(bufsize); 1.101 + if(buffer == NULL) 1.102 + return -1; 1.103 + 1.104 +@@ -394,10 +395,12 @@ 1.105 + int match_byte; 1.106 + 1.107 + pos = buffer_pos - rep0; 1.108 +- while (pos >= header.dict_size) 1.109 +- pos += header.dict_size; 1.110 +- if(pos >= bufsize) { 1.111 +- goto fail; 1.112 ++ if (writebb) { 1.113 ++ while (pos >= header.dict_size) 1.114 ++ pos += header.dict_size; 1.115 ++ if(pos >= bufsize) { 1.116 ++ goto fail; 1.117 ++ } 1.118 + } 1.119 + match_byte = buffer[pos]; 1.120 + do { 1.121 +@@ -419,20 +422,14 @@ 1.122 + prob_lit = prob + mi; 1.123 + rc_get_bit(&rc, prob_lit, &mi); 1.124 + } 1.125 ++ previous_byte = (uint8_t) mi; 1.126 + if (state < 4) 1.127 + state = 0; 1.128 + else if (state < 10) 1.129 + state -= 3; 1.130 + else 1.131 + state -= 6; 1.132 +- previous_byte = (uint8_t) mi; 1.133 +- one_byte: 1.134 +- buffer[buffer_pos++] = previous_byte; 1.135 +- if (buffer_pos == header.dict_size) { 1.136 +- buffer_pos = 0; 1.137 +- global_pos += header.dict_size; 1.138 +- writebb((char*)buffer, header.dict_size); 1.139 +- } 1.140 ++ goto store_previous_byte; 1.141 + } else { 1.142 + int offset; 1.143 + uint16_t *prob_len; 1.144 +@@ -457,14 +454,23 @@ 1.145 + rc_update_bit_0(&rc, prob); 1.146 + 1.147 + state = state < LZMA_NUM_LIT_STATES ? 9 : 11; 1.148 +- pos = buffer_pos - rep0; 1.149 +- while (pos >= header.dict_size) 1.150 +- pos += header.dict_size; 1.151 +- if(pos >= bufsize) { 1.152 +- goto fail; 1.153 ++ pos = buffer_pos - rep0; 1.154 ++ if (writebb) { 1.155 ++ while (pos >= header.dict_size) 1.156 ++ pos += header.dict_size; 1.157 ++ if(pos >= bufsize) { 1.158 ++ goto fail; 1.159 ++ } 1.160 + } 1.161 + previous_byte = buffer[pos]; 1.162 +- goto one_byte; 1.163 ++ store_previous_byte: 1.164 ++ buffer[buffer_pos++] = previous_byte; 1.165 ++ if (writebb && buffer_pos == header.dict_size) { 1.166 ++ buffer_pos = 0; 1.167 ++ global_pos += header.dict_size; 1.168 ++ writebb((char*)buffer, header.dict_size); 1.169 ++ } 1.170 ++ continue; 1.171 + } else { 1.172 + rc_update_bit_1(&rc, prob); 1.173 + } 1.174 +@@ -566,14 +572,16 @@ 1.175 + 1.176 + do { 1.177 + pos = buffer_pos - rep0; 1.178 +- while (pos >= header.dict_size) 1.179 +- pos += header.dict_size; 1.180 +- if(pos >= bufsize) { 1.181 +- goto fail; 1.182 ++ if (writebb) { 1.183 ++ while (pos >= header.dict_size) 1.184 ++ pos += header.dict_size; 1.185 ++ if(pos >= bufsize) { 1.186 ++ goto fail; 1.187 ++ } 1.188 + } 1.189 + previous_byte = buffer[pos]; 1.190 + buffer[buffer_pos++] = previous_byte; 1.191 +- if (buffer_pos == header.dict_size) { 1.192 ++ if (writebb && buffer_pos == header.dict_size) { 1.193 + buffer_pos = 0; 1.194 + global_pos += header.dict_size; 1.195 + writebb((char*)buffer, header.dict_size); 1.196 +@@ -583,15 +591,17 @@ 1.197 + } 1.198 + } 1.199 + 1.200 +- writebb((char*)buffer, buffer_pos); 1.201 +- if(posp) { 1.202 +- *posp = rc.ptr-rc.buffer; 1.203 ++ if (writebb) { 1.204 ++ writebb((char*)buffer, buffer_pos); 1.205 ++ if(posp) { 1.206 ++ *posp = rc.ptr-rc.buffer; 1.207 ++ } 1.208 ++ large_free(buffer); 1.209 + } 1.210 +- large_free(buffer); 1.211 + large_free(p); 1.212 + return 0; 1.213 + fail: 1.214 +- large_free(buffer); 1.215 ++ if (writebb) large_free(buffer); 1.216 + large_free(p); 1.217 + return -1; 1.218 + } 1.219 + 1.220 +--- linux-2.6.24.2/arch/x86/boot/compressed/misc_32.c 1.221 ++++ linux-2.6.24.2/arch/x86/boot/compressed/misc_32.c 1.222 +@@ -444,7 +444,7 @@ 1.223 + 1.224 + #ifdef CONFIG_KERNEL_LZMA 1.225 + putstr("Unlzmaing Linux... "); 1.226 +- unlzma(input_data, input_len-4, NULL, compr_flush, NULL); 1.227 ++ unlzma(input_data, input_len-4, NULL, NULL, window); 1.228 + #endif 1.229 + 1.230 + #ifdef CONFIG_KERNEL_GZIP