Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / m32r / boot / compressed / misc.c
blob43e36705566926a5c3534c0431d3af3ba3a5b916
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * arch/m32r/boot/compressed/misc.c
5 * This is a collection of several routines from gzip-1.0.3
6 * adapted for Linux.
8 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
10 * Adapted for SH by Stuart Menefy, Aug 1999
12 * 2003-02-12: Support M32R by Takeo Takahashi
16 * gzip declarations
18 #define STATIC static
20 #undef memset
21 #undef memcpy
22 #define memzero(s, n) memset ((s), 0, (n))
24 static void error(char *m);
26 #include "m32r_sio.c"
28 static unsigned long free_mem_ptr;
29 static unsigned long free_mem_end_ptr;
31 #ifdef CONFIG_KERNEL_BZIP2
32 void *memset(void *s, int c, size_t n)
34 char *ss = s;
36 while (n--)
37 *ss++ = c;
38 return s;
40 #endif
42 #ifdef CONFIG_KERNEL_GZIP
43 void *memcpy(void *dest, const void *src, size_t n)
45 char *d = dest;
46 const char *s = src;
47 while (n--)
48 *d++ = *s++;
50 return dest;
53 #define BOOT_HEAP_SIZE 0x10000
54 #include "../../../../lib/decompress_inflate.c"
55 #endif
57 #ifdef CONFIG_KERNEL_BZIP2
58 #define BOOT_HEAP_SIZE 0x400000
59 #include "../../../../lib/decompress_bunzip2.c"
60 #endif
62 #ifdef CONFIG_KERNEL_LZMA
63 #define BOOT_HEAP_SIZE 0x10000
64 #include "../../../../lib/decompress_unlzma.c"
65 #endif
67 static void error(char *x)
69 puts("\n\n");
70 puts(x);
71 puts("\n\n -- System halted");
73 while(1); /* Halt */
76 void
77 decompress_kernel(int mmu_on, unsigned char *zimage_data,
78 unsigned int zimage_len, unsigned long heap)
80 unsigned char *input_data = zimage_data;
81 int input_len = zimage_len;
82 unsigned char *output_data;
84 output_data = (unsigned char *)CONFIG_MEMORY_START + 0x2000
85 + (mmu_on ? 0x80000000 : 0);
86 free_mem_ptr = heap;
87 free_mem_end_ptr = free_mem_ptr + BOOT_HEAP_SIZE;
89 puts("\nDecompressing Linux... ");
90 __decompress(input_data, input_len, NULL, NULL, output_data, 0,
91 NULL, error);
92 puts("done.\nBooting the kernel.\n");