Path: blob/master/arch/m32r/boot/compressed/misc.c
10818 views
/*1* arch/m32r/boot/compressed/misc.c2*3* This is a collection of several routines from gzip-1.0.34* adapted for Linux.5*6* malloc by Hannu Savolainen 1993 and Matthias Urlichs 19947*8* Adapted for SH by Stuart Menefy, Aug 19999*10* 2003-02-12: Support M32R by Takeo Takahashi11*/1213/*14* gzip declarations15*/16#define STATIC static1718#undef memset19#undef memcpy20#define memzero(s, n) memset ((s), 0, (n))2122static void error(char *m);2324#include "m32r_sio.c"2526static unsigned long free_mem_ptr;27static unsigned long free_mem_end_ptr;2829#ifdef CONFIG_KERNEL_BZIP230static void *memset(void *s, int c, size_t n)31{32char *ss = s;3334while (n--)35*ss++ = c;36return s;37}38#endif3940#ifdef CONFIG_KERNEL_GZIP41#define BOOT_HEAP_SIZE 0x1000042#include "../../../../lib/decompress_inflate.c"43#endif4445#ifdef CONFIG_KERNEL_BZIP246#define BOOT_HEAP_SIZE 0x40000047#include "../../../../lib/decompress_bunzip2.c"48#endif4950#ifdef CONFIG_KERNEL_LZMA51#define BOOT_HEAP_SIZE 0x1000052#include "../../../../lib/decompress_unlzma.c"53#endif5455static void error(char *x)56{57puts("\n\n");58puts(x);59puts("\n\n -- System halted");6061while(1); /* Halt */62}6364void65decompress_kernel(int mmu_on, unsigned char *zimage_data,66unsigned int zimage_len, unsigned long heap)67{68unsigned char *input_data = zimage_data;69int input_len = zimage_len;70unsigned char *output_data;7172output_data = (unsigned char *)CONFIG_MEMORY_START + 0x200073+ (mmu_on ? 0x80000000 : 0);74free_mem_ptr = heap;75free_mem_end_ptr = free_mem_ptr + BOOT_HEAP_SIZE;7677puts("\nDecompressing Linux... ");78decompress(input_data, input_len, NULL, NULL, output_data, NULL, error);79puts("done.\nBooting the kernel.\n");80}818283