misc.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. static unsigned char *output;
  26. #define HEAP_SIZE 0x10000
  27. #include "../../../../lib/decompress_inflate.c"
  28. void *memset(void *s, int c, size_t n)
  29. {
  30. int i;
  31. char *ss = (char *)s;
  32. for (i = 0; i < n; i++)
  33. ss[i] = c;
  34. return s;
  35. }
  36. void *memcpy(void *dest, const void *src, size_t n)
  37. {
  38. int i;
  39. char *d = (char *)dest, *s = (char *)src;
  40. for (i = 0; i < n; i++)
  41. d[i] = s[i];
  42. return dest;
  43. }
  44. static void error(char *x)
  45. {
  46. while (1)
  47. ; /* Halt */
  48. }
  49. #define STACK_SIZE (4096)
  50. long user_stack[STACK_SIZE];
  51. long *stack_start = &user_stack[STACK_SIZE];
  52. void decompress_kernel(void)
  53. {
  54. free_mem_ptr = (unsigned long)&_end;
  55. free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
  56. __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
  57. }