iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support
[linux/fpc-iii.git] / arch / sh / boot / compressed / misc.c
blobc15cac9251b91fadb307e50dbb114fb2e46aa1ed
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * arch/sh/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 * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
15 #include <linux/uaccess.h>
16 #include <asm/addrspace.h>
17 #include <asm/page.h>
20 * gzip declarations
23 #define STATIC static
25 #undef memset
26 #undef memcpy
27 #define memzero(s, n) memset ((s), 0, (n))
29 /* cache.c */
30 #define CACHE_ENABLE 0
31 #define CACHE_DISABLE 1
32 int cache_control(unsigned int command);
34 extern char input_data[];
35 extern int input_len;
36 static unsigned char *output;
38 static void error(char *m);
40 int puts(const char *);
42 extern int _text; /* Defined in vmlinux.lds.S */
43 extern int _end;
44 static unsigned long free_mem_ptr;
45 static unsigned long free_mem_end_ptr;
47 #ifdef CONFIG_HAVE_KERNEL_BZIP2
48 #define HEAP_SIZE 0x400000
49 #else
50 #define HEAP_SIZE 0x10000
51 #endif
53 #ifdef CONFIG_KERNEL_GZIP
54 #include "../../../../lib/decompress_inflate.c"
55 #endif
57 #ifdef CONFIG_KERNEL_BZIP2
58 #include "../../../../lib/decompress_bunzip2.c"
59 #endif
61 #ifdef CONFIG_KERNEL_LZMA
62 #include "../../../../lib/decompress_unlzma.c"
63 #endif
65 #ifdef CONFIG_KERNEL_XZ
66 #include "../../../../lib/decompress_unxz.c"
67 #endif
69 #ifdef CONFIG_KERNEL_LZO
70 #include "../../../../lib/decompress_unlzo.c"
71 #endif
73 int puts(const char *s)
75 /* This should be updated to use the sh-sci routines */
76 return 0;
79 void* memset(void* s, int c, size_t n)
81 int i;
82 char *ss = (char*)s;
84 for (i=0;i<n;i++) ss[i] = c;
85 return s;
88 void* memcpy(void* __dest, __const void* __src,
89 size_t __n)
91 int i;
92 char *d = (char *)__dest, *s = (char *)__src;
94 for (i=0;i<__n;i++) d[i] = s[i];
95 return __dest;
98 static void error(char *x)
100 puts("\n\n");
101 puts(x);
102 puts("\n\n -- System halted");
104 while(1); /* Halt */
107 const unsigned long __stack_chk_guard = 0x000a0dff;
109 void __stack_chk_fail(void)
111 error("stack-protector: Kernel stack is corrupted\n");
114 #ifdef CONFIG_SUPERH64
115 #define stackalign 8
116 #else
117 #define stackalign 4
118 #endif
120 #define STACK_SIZE (4096)
121 long __attribute__ ((aligned(stackalign))) user_stack[STACK_SIZE];
122 long *stack_start = &user_stack[STACK_SIZE];
124 void decompress_kernel(void)
126 unsigned long output_addr;
128 #ifdef CONFIG_SUPERH64
129 output_addr = (CONFIG_MEMORY_START + 0x2000);
130 #else
131 output_addr = __pa((unsigned long)&_text+PAGE_SIZE);
132 #if defined(CONFIG_29BIT)
133 output_addr |= P2SEG;
134 #endif
135 #endif
137 output = (unsigned char *)output_addr;
138 free_mem_ptr = (unsigned long)&_end;
139 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
141 puts("Uncompressing Linux... ");
142 cache_control(CACHE_ENABLE);
143 __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
144 cache_control(CACHE_DISABLE);
145 puts("Ok, booting the kernel.\n");