Avoid beyond bounds copy while caching ACL
[zen-stable.git] / arch / m32r / boot / compressed / misc.c
blob370d60881977db4370f1686bee5d3b59a19eba69
1 /*
2 * arch/m32r/boot/compressed/misc.c
4 * This is a collection of several routines from gzip-1.0.3
5 * adapted for Linux.
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
9 * Adapted for SH by Stuart Menefy, Aug 1999
11 * 2003-02-12: Support M32R by Takeo Takahashi
15 * gzip declarations
17 #define STATIC static
19 #undef memset
20 #undef memcpy
21 #define memzero(s, n) memset ((s), 0, (n))
23 static void error(char *m);
25 #include "m32r_sio.c"
27 static unsigned long free_mem_ptr;
28 static unsigned long free_mem_end_ptr;
30 #ifdef CONFIG_KERNEL_BZIP2
31 static void *memset(void *s, int c, size_t n)
33 char *ss = s;
35 while (n--)
36 *ss++ = c;
37 return s;
39 #endif
41 #ifdef CONFIG_KERNEL_GZIP
42 #define BOOT_HEAP_SIZE 0x10000
43 #include "../../../../lib/decompress_inflate.c"
44 #endif
46 #ifdef CONFIG_KERNEL_BZIP2
47 #define BOOT_HEAP_SIZE 0x400000
48 #include "../../../../lib/decompress_bunzip2.c"
49 #endif
51 #ifdef CONFIG_KERNEL_LZMA
52 #define BOOT_HEAP_SIZE 0x10000
53 #include "../../../../lib/decompress_unlzma.c"
54 #endif
56 static void error(char *x)
58 puts("\n\n");
59 puts(x);
60 puts("\n\n -- System halted");
62 while(1); /* Halt */
65 void
66 decompress_kernel(int mmu_on, unsigned char *zimage_data,
67 unsigned int zimage_len, unsigned long heap)
69 unsigned char *input_data = zimage_data;
70 int input_len = zimage_len;
71 unsigned char *output_data;
73 output_data = (unsigned char *)CONFIG_MEMORY_START + 0x2000
74 + (mmu_on ? 0x80000000 : 0);
75 free_mem_ptr = heap;
76 free_mem_end_ptr = free_mem_ptr + BOOT_HEAP_SIZE;
78 puts("\nDecompressing Linux... ");
79 decompress(input_data, input_len, NULL, NULL, output_data, NULL, error);
80 puts("done.\nBooting the kernel.\n");