summaryrefslogtreecommitdiff
path: root/arch/h8300/boot/compressed/misc.c
blob: c4f2cfcb117bd6a6b9f1844c3a3313fa5e6be94a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * arch/h8300/boot/compressed/misc.c
 *
 * This is a collection of several routines from gzip-1.0.3
 * adapted for Linux.
 *
 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
 *
 * Adapted for h8300 by Yoshinori Sato 2006
 */

#include <asm/uaccess.h>

/*
 * gzip declarations
 */

#define OF(args)  args
#define STATIC static

#undef memset
#undef memcpy
#define memzero(s, n)     memset((s), (0), (n))

extern int _end;
static unsigned long free_mem_ptr;
static unsigned long free_mem_end_ptr;

extern char input_data[];
extern int input_len;
static unsigned char *output;

#define HEAP_SIZE             0x10000

#include "../../../../lib/decompress_inflate.c"

void *memset(void *s, int c, size_t n)
{
	int i;
	char *ss = (char *)s;

	for (i = 0; i < n; i++)
		ss[i] = c;
	return s;
}

void *memcpy(void *dest, const void *src, size_t n)
{
	int i;
	char *d = (char *)dest, *s = (char *)src;

	for (i = 0; i < n; i++)
		d[i] = s[i];
	return dest;
}

static void error(char *x)
{

	while (1)
		;	/* Halt */
}

#define STACK_SIZE (4096)
long user_stack[STACK_SIZE];
long *stack_start = &user_stack[STACK_SIZE];

void decompress_kernel(void)
{
	free_mem_ptr = (unsigned long)&_end;
	free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;

	__decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);
}