wok-stable diff linux/stuff/linux-freeinitrd-2.6.37.u @ rev 10415
automake: Added cook_tmp_toolchain function to fix tazwok cook-toolchain.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Tue May 24 07:52:52 2011 +0000 (2011-05-24) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/linux/stuff/linux-freeinitrd-2.6.37.u Tue May 24 07:52:52 2011 +0000 1.3 @@ -0,0 +1,129 @@ 1.4 +--- linux-2.6.30.4/arch/x86/mm/init.c 1.5 ++++ linux-2.6.30.4/arch/x86/mm/init.c 1.6 +@@ -366,7 +366,7 @@ 1.7 + */ 1.8 + set_memory_rw(begin, (end - begin) >> PAGE_SHIFT); 1.9 + 1.10 +- printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); 1.11 ++ if (what) printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); 1.12 + 1.13 + for (; addr < end; addr += PAGE_SIZE) { 1.14 + ClearPageReserved(virt_to_page(addr)); 1.15 + 1.16 +--- linux-2.6.30.4/init/initramfs.c 1.17 ++++ linux-2.6.30.4/init/initramfs.c 1.18 +@@ -374,6 +374,52 @@ 1.19 + [Reset] = do_reset, 1.20 + }; 1.21 + 1.22 ++#include <linux/initrd.h> 1.23 ++#define INITRD_PAGE ((PAGE_SIZE > 64*1024) ? PAGE_SIZE : 64*1024) 1.24 ++#define INITRD_DOT (1024*1024) 1.25 ++ 1.26 ++static void free_rootfs_mem(unsigned long start, unsigned long end) 1.27 ++{ 1.28 ++ free_init_pages(NULL, start, end); 1.29 ++} 1.30 ++ 1.31 ++static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end, 1.32 ++ void (*free_initrd_mem)(unsigned long, unsigned long)); 1.33 ++ 1.34 ++static struct { 1.35 ++ int offset, last, inptr, freed; 1.36 ++ char *max; 1.37 ++} fill; 1.38 ++ 1.39 ++static void release_inbuf(unsigned n) 1.40 ++{ 1.41 ++ if (n >= INITRD_PAGE) { 1.42 ++ unsigned rem = n % INITRD_PAGE; 1.43 ++ unsigned end = initrd_start + n - rem; 1.44 ++ _free_initrd(initrd_start, end, free_rootfs_mem); 1.45 ++ fill.freed += n - rem; 1.46 ++ if (fill.freed >= INITRD_DOT) { 1.47 ++ fill.freed -= INITRD_DOT; 1.48 ++ printk("."); 1.49 ++ } 1.50 ++ initrd_start = end; 1.51 ++ fill.offset = rem; 1.52 ++ } 1.53 ++} 1.54 ++ 1.55 ++static int fill_buffer(void *buffer, unsigned size) 1.56 ++{ 1.57 ++ int max = fill.max - (char *) initrd_start - fill.offset; 1.58 ++ if (max > size) max = size; 1.59 ++ if (max > INITRD_PAGE) max = INITRD_PAGE; 1.60 ++ memcpy(buffer, (void *)(initrd_start + fill.offset), max); 1.61 ++ release_inbuf(fill.offset); 1.62 ++ fill.offset += max; 1.63 ++ fill.inptr += fill.last; 1.64 ++ fill.last = max; 1.65 ++ return max; 1.66 ++} 1.67 ++ 1.68 + static int __init write_buffer(char *buf, unsigned len) 1.69 + { 1.70 + count = len; 1.71 +@@ -418,6 +463,7 @@ 1.72 + decompress_fn decompress; 1.73 + const char *compress_name; 1.74 + static __initdata char msg_buf[64]; 1.75 ++ int early_free_initrd = (buf == (char *) initrd_start); 1.76 + 1.77 + header_buf = kmalloc(110, GFP_KERNEL); 1.78 + symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL); 1.79 +@@ -431,11 +478,16 @@ 1.80 + message = NULL; 1.81 + while (!message && len) { 1.82 + loff_t saved_offset = this_header; 1.83 ++ fill.offset = buf - (char *) initrd_start; 1.84 ++ fill.max = buf + len; 1.85 ++ fill.inptr = fill.last = fill.freed = 0; 1.86 + if (*buf == '0' && !(this_header & 3)) { 1.87 + state = Start; 1.88 + written = write_buffer(buf, len); 1.89 + buf += written; 1.90 + len -= written; 1.91 ++ if (early_free_initrd) 1.92 ++ release_inbuf(buf - (char *) initrd_start); 1.93 + continue; 1.94 + } 1.95 + if (!*buf) { 1.96 +@@ -447,7 +497,12 @@ 1.97 + this_header = 0; 1.98 + decompress = decompress_method(buf, len, &compress_name); 1.99 + if (decompress) { 1.100 +- res = decompress(buf, len, NULL, flush_buffer, NULL, 1.101 ++ if (early_free_initrd) { 1.102 ++ res = decompress(NULL, 0, fill_buffer, 1.103 ++ flush_buffer, NULL, &my_inptr, error); 1.104 ++ my_inptr += fill.inptr; 1.105 ++ } 1.106 ++ else res = decompress(buf, len, NULL, flush_buffer, NULL, 1.107 + &my_inptr, error); 1.108 + if (res) 1.109 + error("decompressor failed"); 1.110 +@@ -488,7 +546,8 @@ 1.111 + #include <linux/initrd.h> 1.112 + #include <linux/kexec.h> 1.113 + 1.114 +-static void __init free_initrd(void) 1.115 ++static void _free_initrd(unsigned long initrd_start, unsigned long initrd_end, 1.116 ++ void (*free_initrd_mem)(unsigned long, unsigned long)) 1.117 + { 1.118 + #ifdef CONFIG_KEXEC 1.119 + unsigned long crashk_start = (unsigned long)__va(crashk_res.start); 1.120 +@@ -516,6 +574,12 @@ 1.121 + #endif 1.122 + free_initrd_mem(initrd_start, initrd_end); 1.123 + skip: 1.124 ++ ; 1.125 ++} 1.126 ++ 1.127 ++static void __init free_initrd(void) 1.128 ++{ 1.129 ++ _free_initrd(initrd_start, initrd_end, free_initrd_mem); 1.130 + initrd_start = 0; 1.131 + initrd_end = 0; 1.132 + }