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>
17 #include <asm/sh_bios.h>
27 #define memzero(s, n) memset ((s), 0, (n))
29 static void error(char *m
);
31 extern char input_data
[];
33 static unsigned char *output
;
35 static void error(char *m
);
37 int puts(const char *);
39 extern int _text
; /* Defined in vmlinux.lds.S */
41 static unsigned long free_mem_ptr
;
42 static unsigned long free_mem_end_ptr
;
44 #ifdef CONFIG_HAVE_KERNEL_BZIP2
45 #define HEAP_SIZE 0x400000
47 #define HEAP_SIZE 0x10000
50 #ifdef CONFIG_KERNEL_GZIP
51 #include "../../../../lib/decompress_inflate.c"
54 #ifdef CONFIG_KERNEL_BZIP2
55 #include "../../../../lib/decompress_bunzip2.c"
58 #ifdef CONFIG_KERNEL_LZMA
59 #include "../../../../lib/decompress_unlzma.c"
62 #ifdef CONFIG_SH_STANDARD_BIOS
63 size_t strlen(const char *s
)
72 int puts(const char *s
)
75 sh_bios_console_write(s
, len
);
79 int puts(const char *s
)
81 /* This should be updated to use the sh-sci routines */
86 void* memset(void* s
, int c
, size_t n
)
91 for (i
=0;i
<n
;i
++) ss
[i
] = c
;
95 void* memcpy(void* __dest
, __const
void* __src
,
99 char *d
= (char *)__dest
, *s
= (char *)__src
;
101 for (i
=0;i
<__n
;i
++) d
[i
] = s
[i
];
105 static void error(char *x
)
109 puts("\n\n -- System halted");
114 #define STACK_SIZE (4096)
115 long user_stack
[STACK_SIZE
];
116 long* stack_start
= &user_stack
[STACK_SIZE
];
118 void decompress_kernel(void)
120 unsigned long output_addr
;
122 output_addr
= PHYSADDR((unsigned long)&_text
+PAGE_SIZE
);
124 output_addr
|= P2SEG
;
127 output
= (unsigned char *)output_addr
;
128 free_mem_ptr
= (unsigned long)&_end
;
129 free_mem_end_ptr
= free_mem_ptr
+ HEAP_SIZE
;
131 puts("Uncompressing Linux... ");
132 decompress(input_data
, input_len
, NULL
, NULL
, output
, NULL
, error
);
133 puts("Ok, booting the kernel.\n");