1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/unicore32/boot/compressed/misc.c
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
10 #include <asm/unaligned.h>
11 #include <mach/uncompress.h>
16 unsigned char *output_data
;
17 unsigned long output_ptr
;
19 unsigned int free_mem_ptr
;
20 unsigned int free_mem_end_ptr
;
23 #define STATIC_RW_DATA /* non-static please */
26 * arch-dependent implementations
28 #ifndef ARCH_HAVE_DECOMP_ERROR
29 #define arch_decomp_error(x)
32 #ifndef ARCH_HAVE_DECOMP_SETUP
33 #define arch_decomp_setup()
36 #ifndef ARCH_HAVE_DECOMP_PUTS
37 #define arch_decomp_puts(p)
40 void *memcpy(void *dest
, const void *src
, size_t n
)
43 unsigned char *d
= (unsigned char *)dest
, *s
= (unsigned char *)src
;
45 for (i
= n
>> 3; i
> 0; i
--) {
76 arch_decomp_puts("\n\n");
78 arch_decomp_puts("\n\n -- System halted");
86 /* Heap size should be adjusted for different decompress method */
87 #ifdef CONFIG_KERNEL_GZIP
88 #include "../../../../lib/decompress_inflate.c"
91 #ifdef CONFIG_KERNEL_BZIP2
92 #include "../../../../lib/decompress_bunzip2.c"
95 #ifdef CONFIG_KERNEL_LZO
96 #include "../../../../lib/decompress_unlzo.c"
99 #ifdef CONFIG_KERNEL_LZMA
100 #include "../../../../lib/decompress_unlzma.c"
103 unsigned long decompress_kernel(unsigned long output_start
,
104 unsigned long free_mem_ptr_p
,
105 unsigned long free_mem_ptr_end_p
)
109 output_data
= (unsigned char *)output_start
;
110 free_mem_ptr
= free_mem_ptr_p
;
111 free_mem_end_ptr
= free_mem_ptr_end_p
;
115 tmp
= (unsigned char *) (((unsigned long)input_data_end
) - 4);
116 output_ptr
= get_unaligned_le32(tmp
);
118 arch_decomp_puts("Uncompressing Linux...");
119 __decompress(input_data
, input_data_end
- input_data
, NULL
, NULL
,
120 output_data
, 0, NULL
, error
);
121 arch_decomp_puts(" done, booting the kernel.\n");