2 * arch/sh/boot/compressed/misc.c
4 * This is a collection of several routines from gzip-1.0.3
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
9 * Adapted for SH by Stuart Menefy, Aug 1999
11 * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000
14 #include <asm/uaccess.h>
15 #include <asm/addrspace.h>
26 #define memzero(s, n) memset ((s), 0, (n))
29 #define CACHE_ENABLE 0
30 #define CACHE_DISABLE 1
31 int cache_control(unsigned int command
);
33 extern char input_data
[];
35 static unsigned char *output
;
37 static void error(char *m
);
39 int puts(const char *);
41 extern int _text
; /* Defined in vmlinux.lds.S */
43 static unsigned long free_mem_ptr
;
44 static unsigned long free_mem_end_ptr
;
46 #ifdef CONFIG_HAVE_KERNEL_BZIP2
47 #define HEAP_SIZE 0x400000
49 #define HEAP_SIZE 0x10000
52 #ifdef CONFIG_KERNEL_GZIP
53 #include "../../../../lib/decompress_inflate.c"
56 #ifdef CONFIG_KERNEL_BZIP2
57 #include "../../../../lib/decompress_bunzip2.c"
60 #ifdef CONFIG_KERNEL_LZMA
61 #include "../../../../lib/decompress_unlzma.c"
64 #ifdef CONFIG_KERNEL_XZ
65 #include "../../../../lib/decompress_unxz.c"
68 #ifdef CONFIG_KERNEL_LZO
69 #include "../../../../lib/decompress_unlzo.c"
72 int puts(const char *s
)
74 /* This should be updated to use the sh-sci routines */
78 void* memset(void* s
, int c
, size_t n
)
83 for (i
=0;i
<n
;i
++) ss
[i
] = c
;
87 void* memcpy(void* __dest
, __const
void* __src
,
91 char *d
= (char *)__dest
, *s
= (char *)__src
;
93 for (i
=0;i
<__n
;i
++) d
[i
] = s
[i
];
97 static void error(char *x
)
101 puts("\n\n -- System halted");
106 #ifdef CONFIG_SUPERH64
112 #define STACK_SIZE (4096)
113 long __attribute__ ((aligned(stackalign
))) user_stack
[STACK_SIZE
];
114 long *stack_start
= &user_stack
[STACK_SIZE
];
116 void decompress_kernel(void)
118 unsigned long output_addr
;
120 #ifdef CONFIG_SUPERH64
121 output_addr
= (CONFIG_MEMORY_START
+ 0x2000);
123 output_addr
= __pa((unsigned long)&_text
+PAGE_SIZE
);
124 #if defined(CONFIG_29BIT)
125 output_addr
|= P2SEG
;
129 output
= (unsigned char *)output_addr
;
130 free_mem_ptr
= (unsigned long)&_end
;
131 free_mem_end_ptr
= free_mem_ptr
+ HEAP_SIZE
;
133 puts("Uncompressing Linux... ");
134 cache_control(CACHE_ENABLE
);
135 decompress(input_data
, input_len
, NULL
, NULL
, output
, NULL
, error
);
136 cache_control(CACHE_DISABLE
);
137 puts("Ok, booting the kernel.\n");