~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sh/boot/compressed/misc.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * arch/sh/boot/compressed/misc.c
  4  *
  5  * This is a collection of several routines from gzip-1.0.3
  6  * adapted for Linux.
  7  *
  8  * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
  9  *
 10  * Adapted for SH by Stuart Menefy, Aug 1999
 11  *
 12  * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
 13  */
 14 
 15 #include <linux/uaccess.h>
 16 #include <asm/addrspace.h>
 17 #include <asm/page.h>
 18 
 19 #include "misc.h"
 20 
 21 /*
 22  * gzip declarations
 23  */
 24 
 25 #define STATIC static
 26 
 27 #undef memset
 28 #undef memcpy
 29 #define memzero(s, n)     memset ((s), 0, (n))
 30 
 31 extern char input_data[];
 32 extern int input_len;
 33 static unsigned char *output;
 34 
 35 static void error(char *m);
 36 
 37 int puts(const char *);
 38 
 39 extern int _text;               /* Defined in vmlinux.lds.S */
 40 extern int _end;
 41 static unsigned long free_mem_ptr;
 42 static unsigned long free_mem_end_ptr;
 43 
 44 #ifdef CONFIG_HAVE_KERNEL_BZIP2
 45 #define HEAP_SIZE       0x400000
 46 #else
 47 #define HEAP_SIZE       0x10000
 48 #endif
 49 
 50 #ifdef CONFIG_KERNEL_GZIP
 51 #include "../../../../lib/decompress_inflate.c"
 52 #endif
 53 
 54 #ifdef CONFIG_KERNEL_BZIP2
 55 #include "../../../../lib/decompress_bunzip2.c"
 56 #endif
 57 
 58 #ifdef CONFIG_KERNEL_LZMA
 59 #include "../../../../lib/decompress_unlzma.c"
 60 #endif
 61 
 62 #ifdef CONFIG_KERNEL_XZ
 63 #include "../../../../lib/decompress_unxz.c"
 64 #endif
 65 
 66 #ifdef CONFIG_KERNEL_LZO
 67 #include "../../../../lib/decompress_unlzo.c"
 68 #endif
 69 
 70 int puts(const char *s)
 71 {
 72         /* This should be updated to use the sh-sci routines */
 73         return 0;
 74 }
 75 
 76 void* memset(void* s, int c, size_t n)
 77 {
 78         int i;
 79         char *ss = (char*)s;
 80 
 81         for (i=0;i<n;i++) ss[i] = c;
 82         return s;
 83 }
 84 
 85 void* memcpy(void* __dest, __const void* __src,
 86                             size_t __n)
 87 {
 88         int i;
 89         char *d = (char *)__dest, *s = (char *)__src;
 90 
 91         for (i=0;i<__n;i++) d[i] = s[i];
 92         return __dest;
 93 }
 94 
 95 static void error(char *x)
 96 {
 97         puts("\n\n");
 98         puts(x);
 99         puts("\n\n -- System halted");
100 
101         while(1);       /* Halt */
102 }
103 
104 const unsigned long __stack_chk_guard = 0x000a0dff;
105 
106 void __stack_chk_fail(void)
107 {
108         error("stack-protector: Kernel stack is corrupted\n");
109 }
110 
111 /* Needed because vmlinux.lds.h references this */
112 void ftrace_stub(void)
113 {
114 }
115 void arch_ftrace_ops_list_func(void)
116 {
117 }
118 
119 #define stackalign      4
120 
121 #define STACK_SIZE (4096)
122 long __attribute__ ((aligned(stackalign))) user_stack[STACK_SIZE];
123 long *stack_start = &user_stack[STACK_SIZE];
124 
125 void decompress_kernel(void)
126 {
127         unsigned long output_addr;
128 
129         output_addr = __pa((unsigned long)&_text+PAGE_SIZE);
130 #if defined(CONFIG_29BIT)
131         output_addr |= P2SEG;
132 #endif
133 
134         output = (unsigned char *)output_addr;
135         free_mem_ptr = (unsigned long)&_end;
136         free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
137 
138         puts("Uncompressing Linux... ");
139         __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
140         puts("Ok, booting the kernel.\n");
141 }
142 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php