arm64: dts: Revert "specify console via command line"
[linux/fpc-iii.git] / arch / unicore32 / boot / compressed / misc.c
blob450d3355de20809ac0a9cb0be52241a11ffc4b54
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
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
8 */
10 #include <asm/unaligned.h>
11 #include <mach/uncompress.h>
14 * gzip delarations
16 unsigned char *output_data;
17 unsigned long output_ptr;
19 unsigned int free_mem_ptr;
20 unsigned int free_mem_end_ptr;
22 #define STATIC static
23 #define STATIC_RW_DATA /* non-static please */
26 * arch-dependent implementations
28 #ifndef ARCH_HAVE_DECOMP_ERROR
29 #define arch_decomp_error(x)
30 #endif
32 #ifndef ARCH_HAVE_DECOMP_SETUP
33 #define arch_decomp_setup()
34 #endif
36 #ifndef ARCH_HAVE_DECOMP_PUTS
37 #define arch_decomp_puts(p)
38 #endif
40 void *memcpy(void *dest, const void *src, size_t n)
42 int i = 0;
43 unsigned char *d = (unsigned char *)dest, *s = (unsigned char *)src;
45 for (i = n >> 3; i > 0; i--) {
46 *d++ = *s++;
47 *d++ = *s++;
48 *d++ = *s++;
49 *d++ = *s++;
50 *d++ = *s++;
51 *d++ = *s++;
52 *d++ = *s++;
53 *d++ = *s++;
56 if (n & 1 << 2) {
57 *d++ = *s++;
58 *d++ = *s++;
59 *d++ = *s++;
60 *d++ = *s++;
63 if (n & 1 << 1) {
64 *d++ = *s++;
65 *d++ = *s++;
68 if (n & 1)
69 *d++ = *s++;
71 return dest;
74 void error(char *x)
76 arch_decomp_puts("\n\n");
77 arch_decomp_puts(x);
78 arch_decomp_puts("\n\n -- System halted");
80 arch_decomp_error(x);
82 for (;;)
83 ; /* Halt */
86 /* Heap size should be adjusted for different decompress method */
87 #ifdef CONFIG_KERNEL_GZIP
88 #include "../../../../lib/decompress_inflate.c"
89 #endif
91 #ifdef CONFIG_KERNEL_BZIP2
92 #include "../../../../lib/decompress_bunzip2.c"
93 #endif
95 #ifdef CONFIG_KERNEL_LZO
96 #include "../../../../lib/decompress_unlzo.c"
97 #endif
99 #ifdef CONFIG_KERNEL_LZMA
100 #include "../../../../lib/decompress_unlzma.c"
101 #endif
103 unsigned long decompress_kernel(unsigned long output_start,
104 unsigned long free_mem_ptr_p,
105 unsigned long free_mem_ptr_end_p)
107 unsigned char *tmp;
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;
113 arch_decomp_setup();
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");
122 return output_ptr;