Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / unicore32 / boot / compressed / misc.c
blob176d5bda3559de3ffc23bdc667c0ee7be3f6d5bb
1 /*
2 * linux/arch/unicore32/boot/compressed/misc.c
4 * Code specific to PKUnity SoC and UniCore ISA
6 * Copyright (C) 2001-2010 GUAN Xue-tao
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <asm/unaligned.h>
14 #include <mach/uncompress.h>
17 * gzip delarations
19 unsigned char *output_data;
20 unsigned long output_ptr;
22 unsigned int free_mem_ptr;
23 unsigned int free_mem_end_ptr;
25 #define STATIC static
26 #define STATIC_RW_DATA /* non-static please */
29 * arch-dependent implementations
31 #ifndef ARCH_HAVE_DECOMP_ERROR
32 #define arch_decomp_error(x)
33 #endif
35 #ifndef ARCH_HAVE_DECOMP_SETUP
36 #define arch_decomp_setup()
37 #endif
39 #ifndef ARCH_HAVE_DECOMP_PUTS
40 #define arch_decomp_puts(p)
41 #endif
43 void *memcpy(void *dest, const void *src, size_t n)
45 int i = 0;
46 unsigned char *d = (unsigned char *)dest, *s = (unsigned char *)src;
48 for (i = n >> 3; i > 0; i--) {
49 *d++ = *s++;
50 *d++ = *s++;
51 *d++ = *s++;
52 *d++ = *s++;
53 *d++ = *s++;
54 *d++ = *s++;
55 *d++ = *s++;
56 *d++ = *s++;
59 if (n & 1 << 2) {
60 *d++ = *s++;
61 *d++ = *s++;
62 *d++ = *s++;
63 *d++ = *s++;
66 if (n & 1 << 1) {
67 *d++ = *s++;
68 *d++ = *s++;
71 if (n & 1)
72 *d++ = *s++;
74 return dest;
77 void error(char *x)
79 arch_decomp_puts("\n\n");
80 arch_decomp_puts(x);
81 arch_decomp_puts("\n\n -- System halted");
83 arch_decomp_error(x);
85 for (;;)
86 ; /* Halt */
89 /* Heap size should be adjusted for different decompress method */
90 #ifdef CONFIG_KERNEL_GZIP
91 #include "../../../../lib/decompress_inflate.c"
92 #endif
94 #ifdef CONFIG_KERNEL_BZIP2
95 #include "../../../../lib/decompress_bunzip2.c"
96 #endif
98 #ifdef CONFIG_KERNEL_LZO
99 #include "../../../../lib/decompress_unlzo.c"
100 #endif
102 #ifdef CONFIG_KERNEL_LZMA
103 #include "../../../../lib/decompress_unlzma.c"
104 #endif
106 unsigned long decompress_kernel(unsigned long output_start,
107 unsigned long free_mem_ptr_p,
108 unsigned long free_mem_ptr_end_p)
110 unsigned char *tmp;
112 output_data = (unsigned char *)output_start;
113 free_mem_ptr = free_mem_ptr_p;
114 free_mem_end_ptr = free_mem_ptr_end_p;
116 arch_decomp_setup();
118 tmp = (unsigned char *) (((unsigned long)input_data_end) - 4);
119 output_ptr = get_unaligned_le32(tmp);
121 arch_decomp_puts("Uncompressing Linux...");
122 decompress(input_data, input_data_end - input_data, NULL, NULL,
123 output_data, NULL, error);
124 arch_decomp_puts(" done, booting the kernel.\n");
125 return output_ptr;