misc.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * arch/m32r/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 SH by Stuart Menefy, Aug 1999
  10. *
  11. * 2003-02-12: Support M32R by Takeo Takahashi
  12. */
  13. /*
  14. * gzip declarations
  15. */
  16. #define STATIC static
  17. #undef memset
  18. #undef memcpy
  19. #define memzero(s, n) memset ((s), 0, (n))
  20. static void error(char *m);
  21. #include "m32r_sio.c"
  22. static unsigned long free_mem_ptr;
  23. static unsigned long free_mem_end_ptr;
  24. #ifdef CONFIG_KERNEL_BZIP2
  25. static void *memset(void *s, int c, size_t n)
  26. {
  27. char *ss = s;
  28. while (n--)
  29. *ss++ = c;
  30. return s;
  31. }
  32. #endif
  33. #ifdef CONFIG_KERNEL_GZIP
  34. #define BOOT_HEAP_SIZE 0x10000
  35. #include "../../../../lib/decompress_inflate.c"
  36. #endif
  37. #ifdef CONFIG_KERNEL_BZIP2
  38. #define BOOT_HEAP_SIZE 0x400000
  39. #include "../../../../lib/decompress_bunzip2.c"
  40. #endif
  41. #ifdef CONFIG_KERNEL_LZMA
  42. #define BOOT_HEAP_SIZE 0x10000
  43. #include "../../../../lib/decompress_unlzma.c"
  44. #endif
  45. static void error(char *x)
  46. {
  47. puts("\n\n");
  48. puts(x);
  49. puts("\n\n -- System halted");
  50. while(1); /* Halt */
  51. }
  52. void
  53. decompress_kernel(int mmu_on, unsigned char *zimage_data,
  54. unsigned int zimage_len, unsigned long heap)
  55. {
  56. unsigned char *input_data = zimage_data;
  57. int input_len = zimage_len;
  58. unsigned char *output_data;
  59. output_data = (unsigned char *)CONFIG_MEMORY_START + 0x2000
  60. + (mmu_on ? 0x80000000 : 0);
  61. free_mem_ptr = heap;
  62. free_mem_end_ptr = free_mem_ptr + BOOT_HEAP_SIZE;
  63. puts("\nDecompressing Linux... ");
  64. decompress(input_data, input_len, NULL, NULL, output_data, NULL, error);
  65. puts("done.\nBooting the kernel.\n");
  66. }