misc.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * arch/h8300/boot/compressed/misc.c
  3. *
  4. * This is a collection of several routines from gzip-1.0.3
  5. * adapted for Linux.
  6. *
  7. * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
  8. *
  9. * Adapted for h8300 by Yoshinori Sato 2006
  10. */
  11. #include <asm/uaccess.h>
  12. /*
  13. * gzip declarations
  14. */
  15. #define OF(args) args
  16. #define STATIC static
  17. #undef memset
  18. #undef memcpy
  19. #define memzero(s, n) memset((s), (0), (n))
  20. extern int _end;
  21. static unsigned long free_mem_ptr;
  22. static unsigned long free_mem_end_ptr;
  23. extern char input_data[];
  24. extern int input_len;
  25. extern char output[];
  26. #define HEAP_SIZE 0x10000
  27. #ifdef CONFIG_KERNEL_GZIP
  28. #include "../../../../lib/decompress_inflate.c"
  29. #endif
  30. #ifdef CONFIG_KERNEL_LZO
  31. #include "../../../../lib/decompress_unlzo.c"
  32. #endif
  33. void *memset(void *s, int c, size_t n)
  34. {
  35. int i;
  36. char *ss = (char *)s;
  37. for (i = 0; i < n; i++)
  38. ss[i] = c;
  39. return s;
  40. }
  41. void *memcpy(void *dest, const void *src, size_t n)
  42. {
  43. int i;
  44. char *d = (char *)dest, *s = (char *)src;
  45. for (i = 0; i < n; i++)
  46. d[i] = s[i];
  47. return dest;
  48. }
  49. static void error(char *x)
  50. {
  51. while (1)
  52. ; /* Halt */
  53. }
  54. void decompress_kernel(void)
  55. {
  56. free_mem_ptr = (unsigned long)&_end;
  57. free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
  58. __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
  59. }