Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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