misc.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/h8300/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 h8300 by Yoshinori Sato 2006
  11. */
  12. #include <linux/uaccess.h>
  13. /*
  14. * gzip declarations
  15. */
  16. #define OF(args) args
  17. #define STATIC static
  18. #undef memset
  19. #undef memcpy
  20. #define memzero(s, n) memset((s), (0), (n))
  21. extern int _end;
  22. static unsigned long free_mem_ptr;
  23. static unsigned long free_mem_end_ptr;
  24. extern char input_data[];
  25. extern int input_len;
  26. extern char output[];
  27. #define HEAP_SIZE 0x10000
  28. #ifdef CONFIG_KERNEL_GZIP
  29. #include "../../../../lib/decompress_inflate.c"
  30. #endif
  31. #ifdef CONFIG_KERNEL_LZO
  32. #include "../../../../lib/decompress_unlzo.c"
  33. #endif
  34. void *memset(void *s, int c, size_t n)
  35. {
  36. int i;
  37. char *ss = (char *)s;
  38. for (i = 0; i < n; i++)
  39. ss[i] = c;
  40. return s;
  41. }
  42. void *memcpy(void *dest, const void *src, size_t n)
  43. {
  44. int i;
  45. char *d = (char *)dest, *s = (char *)src;
  46. for (i = 0; i < n; i++)
  47. d[i] = s[i];
  48. return dest;
  49. }
  50. static void error(char *x)
  51. {
  52. while (1)
  53. ; /* Halt */
  54. }
  55. void decompress_kernel(void)
  56. {
  57. free_mem_ptr = (unsigned long)&_end;
  58. free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
  59. __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
  60. }