root/arch/unicore32/boot/compressed/misc.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. memcpy
  2. error
  3. decompress_kernel

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * linux/arch/unicore32/boot/compressed/misc.c
   4  *
   5  * Code specific to PKUnity SoC and UniCore ISA
   6  *
   7  * Copyright (C) 2001-2010 GUAN Xue-tao
   8  */
   9 
  10 #include <asm/unaligned.h>
  11 #include <mach/uncompress.h>
  12 
  13 /*
  14  * gzip delarations
  15  */
  16 unsigned char *output_data;
  17 unsigned long output_ptr;
  18 
  19 unsigned int free_mem_ptr;
  20 unsigned int free_mem_end_ptr;
  21 
  22 #define STATIC static
  23 #define STATIC_RW_DATA  /* non-static please */
  24 
  25 /*
  26  * arch-dependent implementations
  27  */
  28 #ifndef ARCH_HAVE_DECOMP_ERROR
  29 #define arch_decomp_error(x)
  30 #endif
  31 
  32 #ifndef ARCH_HAVE_DECOMP_SETUP
  33 #define arch_decomp_setup()
  34 #endif
  35 
  36 #ifndef ARCH_HAVE_DECOMP_PUTS
  37 #define arch_decomp_puts(p)
  38 #endif
  39 
  40 void *memcpy(void *dest, const void *src, size_t n)
  41 {
  42         int i = 0;
  43         unsigned char *d = (unsigned char *)dest, *s = (unsigned char *)src;
  44 
  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++;
  54         }
  55 
  56         if (n & 1 << 2) {
  57                 *d++ = *s++;
  58                 *d++ = *s++;
  59                 *d++ = *s++;
  60                 *d++ = *s++;
  61         }
  62 
  63         if (n & 1 << 1) {
  64                 *d++ = *s++;
  65                 *d++ = *s++;
  66         }
  67 
  68         if (n & 1)
  69                 *d++ = *s++;
  70 
  71         return dest;
  72 }
  73 
  74 void error(char *x)
  75 {
  76         arch_decomp_puts("\n\n");
  77         arch_decomp_puts(x);
  78         arch_decomp_puts("\n\n -- System halted");
  79 
  80         arch_decomp_error(x);
  81 
  82         for (;;)
  83                 ; /* Halt */
  84 }
  85 
  86 /* Heap size should be adjusted for different decompress method */
  87 #ifdef CONFIG_KERNEL_GZIP
  88 #include "../../../../lib/decompress_inflate.c"
  89 #endif
  90 
  91 #ifdef CONFIG_KERNEL_BZIP2
  92 #include "../../../../lib/decompress_bunzip2.c"
  93 #endif
  94 
  95 #ifdef CONFIG_KERNEL_LZO
  96 #include "../../../../lib/decompress_unlzo.c"
  97 #endif
  98 
  99 #ifdef CONFIG_KERNEL_LZMA
 100 #include "../../../../lib/decompress_unlzma.c"
 101 #endif
 102 
 103 unsigned long decompress_kernel(unsigned long output_start,
 104                 unsigned long free_mem_ptr_p,
 105                 unsigned long free_mem_ptr_end_p)
 106 {
 107         unsigned char *tmp;
 108 
 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;
 112 
 113         arch_decomp_setup();
 114 
 115         tmp = (unsigned char *) (((unsigned long)input_data_end) - 4);
 116         output_ptr = get_unaligned_le32(tmp);
 117 
 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;
 123 }

/* [<][>][^][v][top][bottom][index][help] */