diff options
Diffstat (limited to 'arch/sh/boot')
-rw-r--r-- | arch/sh/boot/.gitignore | 5 | ||||
-rw-r--r-- | arch/sh/boot/Makefile | 48 | ||||
-rw-r--r-- | arch/sh/boot/compressed/.gitignore | 1 | ||||
-rw-r--r-- | arch/sh/boot/compressed/Makefile | 21 | ||||
-rw-r--r-- | arch/sh/boot/compressed/head_32.S | 2 | ||||
-rw-r--r-- | arch/sh/boot/compressed/misc.c | 149 | ||||
-rw-r--r-- | arch/sh/boot/compressed/misc_32.c | 206 | ||||
-rw-r--r-- | arch/sh/boot/compressed/misc_64.c | 210 | ||||
-rw-r--r-- | arch/sh/boot/compressed/piggy.S | 8 | ||||
-rw-r--r-- | arch/sh/boot/compressed/vmlinux.scr | 10 | ||||
-rw-r--r-- | arch/sh/boot/romimage/Makefile | 19 | ||||
-rw-r--r-- | arch/sh/boot/romimage/head.S | 10 | ||||
-rw-r--r-- | arch/sh/boot/romimage/vmlinux.scr | 6 |
13 files changed, 249 insertions, 446 deletions
diff --git a/arch/sh/boot/.gitignore b/arch/sh/boot/.gitignore index aad5edddf93b..541087d2029c 100644 --- a/arch/sh/boot/.gitignore +++ b/arch/sh/boot/.gitignore | |||
@@ -1,4 +1,3 @@ | |||
1 | zImage | 1 | zImage |
2 | vmlinux.srec | 2 | vmlinux* |
3 | uImage | 3 | uImage* |
4 | uImage.srec | ||
diff --git a/arch/sh/boot/Makefile b/arch/sh/boot/Makefile index 78efb04c28f3..a1316872be6f 100644 --- a/arch/sh/boot/Makefile +++ b/arch/sh/boot/Makefile | |||
@@ -20,8 +20,13 @@ CONFIG_BOOT_LINK_OFFSET ?= 0x00800000 | |||
20 | CONFIG_ZERO_PAGE_OFFSET ?= 0x00001000 | 20 | CONFIG_ZERO_PAGE_OFFSET ?= 0x00001000 |
21 | CONFIG_ENTRY_OFFSET ?= 0x00001000 | 21 | CONFIG_ENTRY_OFFSET ?= 0x00001000 |
22 | 22 | ||
23 | targets := zImage vmlinux.srec uImage uImage.srec | 23 | suffix-$(CONFIG_KERNEL_GZIP) := gz |
24 | subdir- := compressed | 24 | suffix-$(CONFIG_KERNEL_BZIP2) := bz2 |
25 | suffix-$(CONFIG_KERNEL_LZMA) := lzma | ||
26 | |||
27 | targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz uImage.bz2 uImage.lzma | ||
28 | extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma | ||
29 | subdir- := compressed romimage | ||
25 | 30 | ||
26 | $(obj)/zImage: $(obj)/compressed/vmlinux FORCE | 31 | $(obj)/zImage: $(obj)/compressed/vmlinux FORCE |
27 | $(call if_changed,objcopy) | 32 | $(call if_changed,objcopy) |
@@ -30,6 +35,13 @@ $(obj)/zImage: $(obj)/compressed/vmlinux FORCE | |||
30 | $(obj)/compressed/vmlinux: FORCE | 35 | $(obj)/compressed/vmlinux: FORCE |
31 | $(Q)$(MAKE) $(build)=$(obj)/compressed $@ | 36 | $(Q)$(MAKE) $(build)=$(obj)/compressed $@ |
32 | 37 | ||
38 | $(obj)/romImage: $(obj)/romimage/vmlinux FORCE | ||
39 | $(call if_changed,objcopy) | ||
40 | @echo ' Kernel: $@ is ready' | ||
41 | |||
42 | $(obj)/romimage/vmlinux: $(obj)/zImage FORCE | ||
43 | $(Q)$(MAKE) $(build)=$(obj)/romimage $@ | ||
44 | |||
33 | KERNEL_MEMORY := 0x00000000 | 45 | KERNEL_MEMORY := 0x00000000 |
34 | ifeq ($(CONFIG_PMB_FIXED),y) | 46 | ifeq ($(CONFIG_PMB_FIXED),y) |
35 | KERNEL_MEMORY := $(shell /bin/bash -c 'printf "0x%08x" \ | 47 | KERNEL_MEMORY := $(shell /bin/bash -c 'printf "0x%08x" \ |
@@ -40,9 +52,6 @@ KERNEL_MEMORY := $(shell /bin/bash -c 'printf "0x%08x" \ | |||
40 | $$[$(CONFIG_MEMORY_START)]') | 52 | $$[$(CONFIG_MEMORY_START)]') |
41 | endif | 53 | endif |
42 | 54 | ||
43 | export CONFIG_PAGE_OFFSET CONFIG_MEMORY_START CONFIG_BOOT_LINK_OFFSET \ | ||
44 | CONFIG_ZERO_PAGE_OFFSET CONFIG_ENTRY_OFFSET KERNEL_MEMORY | ||
45 | |||
46 | KERNEL_LOAD := $(shell /bin/bash -c 'printf "0x%08x" \ | 55 | KERNEL_LOAD := $(shell /bin/bash -c 'printf "0x%08x" \ |
47 | $$[$(CONFIG_PAGE_OFFSET) + \ | 56 | $$[$(CONFIG_PAGE_OFFSET) + \ |
48 | $(KERNEL_MEMORY) + \ | 57 | $(KERNEL_MEMORY) + \ |
@@ -55,19 +64,30 @@ KERNEL_ENTRY := $(shell /bin/bash -c 'printf "0x%08x" \ | |||
55 | 64 | ||
56 | quiet_cmd_uimage = UIMAGE $@ | 65 | quiet_cmd_uimage = UIMAGE $@ |
57 | cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \ | 66 | cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \ |
58 | -C gzip -a $(KERNEL_LOAD) -e $(KERNEL_ENTRY) \ | 67 | -C $(2) -a $(KERNEL_LOAD) -e $(KERNEL_ENTRY) \ |
59 | -n 'Linux-$(KERNELRELEASE)' -d $< $@ | 68 | -n 'Linux-$(KERNELRELEASE)' -d $< $@ |
60 | 69 | ||
61 | $(obj)/uImage: $(obj)/vmlinux.bin.gz FORCE | ||
62 | $(call if_changed,uimage) | ||
63 | @echo ' Image $@ is ready' | ||
64 | |||
65 | $(obj)/vmlinux.bin: vmlinux FORCE | 70 | $(obj)/vmlinux.bin: vmlinux FORCE |
66 | $(call if_changed,objcopy) | 71 | $(call if_changed,objcopy) |
67 | 72 | ||
68 | $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE | 73 | $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE |
69 | $(call if_changed,gzip) | 74 | $(call if_changed,gzip) |
70 | 75 | ||
76 | $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE | ||
77 | $(call if_changed,bzip2) | ||
78 | |||
79 | $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE | ||
80 | $(call if_changed,lzma) | ||
81 | |||
82 | $(obj)/uImage.bz2: $(obj)/vmlinux.bin.bz2 | ||
83 | $(call if_changed,uimage,bzip2) | ||
84 | |||
85 | $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz | ||
86 | $(call if_changed,uimage,gzip) | ||
87 | |||
88 | $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma | ||
89 | $(call if_changed,uimage,lzma) | ||
90 | |||
71 | OBJCOPYFLAGS_vmlinux.srec := -I binary -O srec | 91 | OBJCOPYFLAGS_vmlinux.srec := -I binary -O srec |
72 | $(obj)/vmlinux.srec: $(obj)/compressed/vmlinux | 92 | $(obj)/vmlinux.srec: $(obj)/compressed/vmlinux |
73 | $(call if_changed,objcopy) | 93 | $(call if_changed,objcopy) |
@@ -76,5 +96,9 @@ OBJCOPYFLAGS_uImage.srec := -I binary -O srec | |||
76 | $(obj)/uImage.srec: $(obj)/uImage | 96 | $(obj)/uImage.srec: $(obj)/uImage |
77 | $(call if_changed,objcopy) | 97 | $(call if_changed,objcopy) |
78 | 98 | ||
79 | clean-files += uImage uImage.srec vmlinux.srec \ | 99 | $(obj)/uImage: $(obj)/uImage.$(suffix-y) |
80 | vmlinux.bin vmlinux.bin.gz | 100 | @ln -sf $(notdir $<) $@ |
101 | @echo ' Image $@ is ready' | ||
102 | |||
103 | export CONFIG_PAGE_OFFSET CONFIG_MEMORY_START CONFIG_BOOT_LINK_OFFSET \ | ||
104 | CONFIG_ZERO_PAGE_OFFSET CONFIG_ENTRY_OFFSET KERNEL_MEMORY suffix-y | ||
diff --git a/arch/sh/boot/compressed/.gitignore b/arch/sh/boot/compressed/.gitignore new file mode 100644 index 000000000000..2374a83d87b2 --- /dev/null +++ b/arch/sh/boot/compressed/.gitignore | |||
@@ -0,0 +1 @@ | |||
vmlinux.bin.* | |||
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index 9531bf1b7c2f..6182eca5180a 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile | |||
@@ -5,9 +5,10 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | targets := vmlinux vmlinux.bin vmlinux.bin.gz \ | 7 | targets := vmlinux vmlinux.bin vmlinux.bin.gz \ |
8 | head_$(BITS).o misc_$(BITS).o piggy.o | 8 | vmlinux.bin.bz2 vmlinux.bin.lzma \ |
9 | head_$(BITS).o misc.o piggy.o | ||
9 | 10 | ||
10 | OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc_$(BITS).o $(obj)/cache.o | 11 | OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/cache.o |
11 | 12 | ||
12 | ifdef CONFIG_SH_STANDARD_BIOS | 13 | ifdef CONFIG_SH_STANDARD_BIOS |
13 | OBJECTS += $(obj)/../../kernel/sh_bios.o | 14 | OBJECTS += $(obj)/../../kernel/sh_bios.o |
@@ -23,7 +24,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \ | |||
23 | 24 | ||
24 | LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) | 25 | LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) |
25 | 26 | ||
26 | ifeq ($(CONFIG_FUNCTION_TRACER),y) | 27 | ifeq ($(CONFIG_MCOUNT),y) |
27 | ORIG_CFLAGS := $(KBUILD_CFLAGS) | 28 | ORIG_CFLAGS := $(KBUILD_CFLAGS) |
28 | KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) | 29 | KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) |
29 | endif | 30 | endif |
@@ -38,10 +39,18 @@ $(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE | |||
38 | $(obj)/vmlinux.bin: vmlinux FORCE | 39 | $(obj)/vmlinux.bin: vmlinux FORCE |
39 | $(call if_changed,objcopy) | 40 | $(call if_changed,objcopy) |
40 | 41 | ||
41 | $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE | 42 | vmlinux.bin.all-y := $(obj)/vmlinux.bin |
43 | |||
44 | $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE | ||
42 | $(call if_changed,gzip) | 45 | $(call if_changed,gzip) |
46 | $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE | ||
47 | $(call if_changed,bzip2) | ||
48 | $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE | ||
49 | $(call if_changed,lzma) | ||
43 | 50 | ||
44 | OBJCOPYFLAGS += -R .empty_zero_page | 51 | OBJCOPYFLAGS += -R .empty_zero_page |
45 | 52 | ||
46 | $(obj)/piggy.o: $(obj)/piggy.S $(obj)/vmlinux.bin.gz FORCE | 53 | LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T |
47 | $(call if_changed,as_o_S) | 54 | |
55 | $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE | ||
56 | $(call if_changed,ld) | ||
diff --git a/arch/sh/boot/compressed/head_32.S b/arch/sh/boot/compressed/head_32.S index 06ac31f3be88..02a30935f0b9 100644 --- a/arch/sh/boot/compressed/head_32.S +++ b/arch/sh/boot/compressed/head_32.S | |||
@@ -22,7 +22,7 @@ startup: | |||
22 | bt clear_bss | 22 | bt clear_bss |
23 | sub r0, r2 | 23 | sub r0, r2 |
24 | mov.l bss_start_addr, r0 | 24 | mov.l bss_start_addr, r0 |
25 | mov #0xe0, r1 | 25 | mov #0xffffffe0, r1 |
26 | and r1, r0 ! align cache line | 26 | and r1, r0 ! align cache line |
27 | mov.l text_start_addr, r3 | 27 | mov.l text_start_addr, r3 |
28 | mov r0, r1 | 28 | mov r0, r1 |
diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c new file mode 100644 index 000000000000..fd56a71ca9d9 --- /dev/null +++ b/arch/sh/boot/compressed/misc.c | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * arch/sh/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 | * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000 | ||
12 | */ | ||
13 | |||
14 | #include <asm/uaccess.h> | ||
15 | #include <asm/addrspace.h> | ||
16 | #include <asm/page.h> | ||
17 | #include <asm/sh_bios.h> | ||
18 | |||
19 | /* | ||
20 | * gzip declarations | ||
21 | */ | ||
22 | |||
23 | #define STATIC static | ||
24 | |||
25 | #undef memset | ||
26 | #undef memcpy | ||
27 | #define memzero(s, n) memset ((s), 0, (n)) | ||
28 | |||
29 | /* cache.c */ | ||
30 | #define CACHE_ENABLE 0 | ||
31 | #define CACHE_DISABLE 1 | ||
32 | int cache_control(unsigned int command); | ||
33 | |||
34 | extern char input_data[]; | ||
35 | extern int input_len; | ||
36 | static unsigned char *output; | ||
37 | |||
38 | static void error(char *m); | ||
39 | |||
40 | int puts(const char *); | ||
41 | |||
42 | extern int _text; /* Defined in vmlinux.lds.S */ | ||
43 | extern int _end; | ||
44 | static unsigned long free_mem_ptr; | ||
45 | static unsigned long free_mem_end_ptr; | ||
46 | |||
47 | #ifdef CONFIG_HAVE_KERNEL_BZIP2 | ||
48 | #define HEAP_SIZE 0x400000 | ||
49 | #else | ||
50 | #define HEAP_SIZE 0x10000 | ||
51 | #endif | ||
52 | |||
53 | #ifdef CONFIG_KERNEL_GZIP | ||
54 | #include "../../../../lib/decompress_inflate.c" | ||
55 | #endif | ||
56 | |||
57 | #ifdef CONFIG_KERNEL_BZIP2 | ||
58 | #include "../../../../lib/decompress_bunzip2.c" | ||
59 | #endif | ||
60 | |||
61 | #ifdef CONFIG_KERNEL_LZMA | ||
62 | #include "../../../../lib/decompress_unlzma.c" | ||
63 | #endif | ||
64 | |||
65 | #ifdef CONFIG_SH_STANDARD_BIOS | ||
66 | size_t strlen(const char *s) | ||
67 | { | ||
68 | int i = 0; | ||
69 | |||
70 | while (*s++) | ||
71 | i++; | ||
72 | return i; | ||
73 | } | ||
74 | |||
75 | int puts(const char *s) | ||
76 | { | ||
77 | int len = strlen(s); | ||
78 | sh_bios_console_write(s, len); | ||
79 | return len; | ||
80 | } | ||
81 | #else | ||
82 | int puts(const char *s) | ||
83 | { | ||
84 | /* This should be updated to use the sh-sci routines */ | ||
85 | return 0; | ||
86 | } | ||
87 | #endif | ||
88 | |||
89 | void* memset(void* s, int c, size_t n) | ||
90 | { | ||
91 | int i; | ||
92 | char *ss = (char*)s; | ||
93 | |||
94 | for (i=0;i<n;i++) ss[i] = c; | ||
95 | return s; | ||
96 | } | ||
97 | |||
98 | void* memcpy(void* __dest, __const void* __src, | ||
99 | size_t __n) | ||
100 | { | ||
101 | int i; | ||
102 | char *d = (char *)__dest, *s = (char *)__src; | ||
103 | |||
104 | for (i=0;i<__n;i++) d[i] = s[i]; | ||
105 | return __dest; | ||
106 | } | ||
107 | |||
108 | static void error(char *x) | ||
109 | { | ||
110 | puts("\n\n"); | ||
111 | puts(x); | ||
112 | puts("\n\n -- System halted"); | ||
113 | |||
114 | while(1); /* Halt */ | ||
115 | } | ||
116 | |||
117 | #ifdef CONFIG_SUPERH64 | ||
118 | #define stackalign 8 | ||
119 | #else | ||
120 | #define stackalign 4 | ||
121 | #endif | ||
122 | |||
123 | #define STACK_SIZE (4096) | ||
124 | long __attribute__ ((aligned(stackalign))) user_stack[STACK_SIZE]; | ||
125 | long *stack_start = &user_stack[STACK_SIZE]; | ||
126 | |||
127 | void decompress_kernel(void) | ||
128 | { | ||
129 | unsigned long output_addr; | ||
130 | |||
131 | #ifdef CONFIG_SUPERH64 | ||
132 | output_addr = (CONFIG_MEMORY_START + 0x2000); | ||
133 | #else | ||
134 | output_addr = PHYSADDR((unsigned long)&_text+PAGE_SIZE); | ||
135 | #ifdef CONFIG_29BIT | ||
136 | output_addr |= P2SEG; | ||
137 | #endif | ||
138 | #endif | ||
139 | |||
140 | output = (unsigned char *)output_addr; | ||
141 | free_mem_ptr = (unsigned long)&_end; | ||
142 | free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; | ||
143 | |||
144 | puts("Uncompressing Linux... "); | ||
145 | cache_control(CACHE_ENABLE); | ||
146 | decompress(input_data, input_len, NULL, NULL, output, NULL, error); | ||
147 | cache_control(CACHE_DISABLE); | ||
148 | puts("Ok, booting the kernel.\n"); | ||
149 | } | ||
diff --git a/arch/sh/boot/compressed/misc_32.c b/arch/sh/boot/compressed/misc_32.c deleted file mode 100644 index efdba6b29572..000000000000 --- a/arch/sh/boot/compressed/misc_32.c +++ /dev/null | |||
@@ -1,206 +0,0 @@ | |||
1 | /* | ||
2 | * arch/sh/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 | * Modified to use standard LinuxSH BIOS by Greg Banks 7Jul2000 | ||
12 | */ | ||
13 | |||
14 | #include <asm/uaccess.h> | ||
15 | #include <asm/addrspace.h> | ||
16 | #include <asm/page.h> | ||
17 | #ifdef CONFIG_SH_STANDARD_BIOS | ||
18 | #include <asm/sh_bios.h> | ||
19 | #endif | ||
20 | |||
21 | /* | ||
22 | * gzip declarations | ||
23 | */ | ||
24 | |||
25 | #define OF(args) args | ||
26 | #define STATIC static | ||
27 | |||
28 | #undef memset | ||
29 | #undef memcpy | ||
30 | #define memzero(s, n) memset ((s), 0, (n)) | ||
31 | |||
32 | typedef unsigned char uch; | ||
33 | typedef unsigned short ush; | ||
34 | typedef unsigned long ulg; | ||
35 | |||
36 | #define WSIZE 0x8000 /* Window size must be at least 32k, */ | ||
37 | /* and a power of two */ | ||
38 | |||
39 | static uch *inbuf; /* input buffer */ | ||
40 | static uch window[WSIZE]; /* Sliding window buffer */ | ||
41 | |||
42 | static unsigned insize = 0; /* valid bytes in inbuf */ | ||
43 | static unsigned inptr = 0; /* index of next byte to be processed in inbuf */ | ||
44 | static unsigned outcnt = 0; /* bytes in output buffer */ | ||
45 | |||
46 | /* gzip flag byte */ | ||
47 | #define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ | ||
48 | #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ | ||
49 | #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ | ||
50 | #define ORIG_NAME 0x08 /* bit 3 set: original file name present */ | ||
51 | #define COMMENT 0x10 /* bit 4 set: file comment present */ | ||
52 | #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ | ||
53 | #define RESERVED 0xC0 /* bit 6,7: reserved */ | ||
54 | |||
55 | #define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) | ||
56 | |||
57 | /* Diagnostic functions */ | ||
58 | #ifdef DEBUG | ||
59 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | ||
60 | # define Trace(x) fprintf x | ||
61 | # define Tracev(x) {if (verbose) fprintf x ;} | ||
62 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | ||
63 | # define Tracec(c,x) {if (verbose && (c)) fprintf x ;} | ||
64 | # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} | ||
65 | #else | ||
66 | # define Assert(cond,msg) | ||
67 | # define Trace(x) | ||
68 | # define Tracev(x) | ||
69 | # define Tracevv(x) | ||
70 | # define Tracec(c,x) | ||
71 | # define Tracecv(c,x) | ||
72 | #endif | ||
73 | |||
74 | static int fill_inbuf(void); | ||
75 | static void flush_window(void); | ||
76 | static void error(char *m); | ||
77 | |||
78 | extern char input_data[]; | ||
79 | extern int input_len; | ||
80 | |||
81 | static long bytes_out = 0; | ||
82 | static uch *output_data; | ||
83 | static unsigned long output_ptr = 0; | ||
84 | |||
85 | static void error(char *m); | ||
86 | |||
87 | int puts(const char *); | ||
88 | |||
89 | extern int _text; /* Defined in vmlinux.lds.S */ | ||
90 | extern int _end; | ||
91 | static unsigned long free_mem_ptr; | ||
92 | static unsigned long free_mem_end_ptr; | ||
93 | |||
94 | #define HEAP_SIZE 0x10000 | ||
95 | |||
96 | #include "../../../../lib/inflate.c" | ||
97 | |||
98 | #ifdef CONFIG_SH_STANDARD_BIOS | ||
99 | size_t strlen(const char *s) | ||
100 | { | ||
101 | int i = 0; | ||
102 | |||
103 | while (*s++) | ||
104 | i++; | ||
105 | return i; | ||
106 | } | ||
107 | |||
108 | int puts(const char *s) | ||
109 | { | ||
110 | int len = strlen(s); | ||
111 | sh_bios_console_write(s, len); | ||
112 | return len; | ||
113 | } | ||
114 | #else | ||
115 | int puts(const char *s) | ||
116 | { | ||
117 | /* This should be updated to use the sh-sci routines */ | ||
118 | return 0; | ||
119 | } | ||
120 | #endif | ||
121 | |||
122 | void* memset(void* s, int c, size_t n) | ||
123 | { | ||
124 | int i; | ||
125 | char *ss = (char*)s; | ||
126 | |||
127 | for (i=0;i<n;i++) ss[i] = c; | ||
128 | return s; | ||
129 | } | ||
130 | |||
131 | void* memcpy(void* __dest, __const void* __src, | ||
132 | size_t __n) | ||
133 | { | ||
134 | int i; | ||
135 | char *d = (char *)__dest, *s = (char *)__src; | ||
136 | |||
137 | for (i=0;i<__n;i++) d[i] = s[i]; | ||
138 | return __dest; | ||
139 | } | ||
140 | |||
141 | /* =========================================================================== | ||
142 | * Fill the input buffer. This is called only when the buffer is empty | ||
143 | * and at least one byte is really needed. | ||
144 | */ | ||
145 | static int fill_inbuf(void) | ||
146 | { | ||
147 | if (insize != 0) { | ||
148 | error("ran out of input data"); | ||
149 | } | ||
150 | |||
151 | inbuf = input_data; | ||
152 | insize = input_len; | ||
153 | inptr = 1; | ||
154 | return inbuf[0]; | ||
155 | } | ||
156 | |||
157 | /* =========================================================================== | ||
158 | * Write the output window window[0..outcnt-1] and update crc and bytes_out. | ||
159 | * (Used for the decompressed data only.) | ||
160 | */ | ||
161 | static void flush_window(void) | ||
162 | { | ||
163 | ulg c = crc; /* temporary variable */ | ||
164 | unsigned n; | ||
165 | uch *in, *out, ch; | ||
166 | |||
167 | in = window; | ||
168 | out = &output_data[output_ptr]; | ||
169 | for (n = 0; n < outcnt; n++) { | ||
170 | ch = *out++ = *in++; | ||
171 | c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); | ||
172 | } | ||
173 | crc = c; | ||
174 | bytes_out += (ulg)outcnt; | ||
175 | output_ptr += (ulg)outcnt; | ||
176 | outcnt = 0; | ||
177 | } | ||
178 | |||
179 | static void error(char *x) | ||
180 | { | ||
181 | puts("\n\n"); | ||
182 | puts(x); | ||
183 | puts("\n\n -- System halted"); | ||
184 | |||
185 | while(1); /* Halt */ | ||
186 | } | ||
187 | |||
188 | #define STACK_SIZE (4096) | ||
189 | long user_stack [STACK_SIZE]; | ||
190 | long* stack_start = &user_stack[STACK_SIZE]; | ||
191 | |||
192 | void decompress_kernel(void) | ||
193 | { | ||
194 | output_data = NULL; | ||
195 | output_ptr = PHYSADDR((unsigned long)&_text+PAGE_SIZE); | ||
196 | #ifdef CONFIG_29BIT | ||
197 | output_ptr |= P2SEG; | ||
198 | #endif | ||
199 | free_mem_ptr = (unsigned long)&_end; | ||
200 | free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; | ||
201 | |||
202 | makecrc(); | ||
203 | puts("Uncompressing Linux... "); | ||
204 | gunzip(); | ||
205 | puts("Ok, booting the kernel.\n"); | ||
206 | } | ||
diff --git a/arch/sh/boot/compressed/misc_64.c b/arch/sh/boot/compressed/misc_64.c deleted file mode 100644 index 2941657e18aa..000000000000 --- a/arch/sh/boot/compressed/misc_64.c +++ /dev/null | |||
@@ -1,210 +0,0 @@ | |||
1 | /* | ||
2 | * arch/sh/boot/compressed/misc_64.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 SHmedia from sh by Stuart Menefy, May 2002 | ||
10 | */ | ||
11 | |||
12 | #include <asm/uaccess.h> | ||
13 | |||
14 | /* cache.c */ | ||
15 | #define CACHE_ENABLE 0 | ||
16 | #define CACHE_DISABLE 1 | ||
17 | int cache_control(unsigned int command); | ||
18 | |||
19 | /* | ||
20 | * gzip declarations | ||
21 | */ | ||
22 | |||
23 | #define OF(args) args | ||
24 | #define STATIC static | ||
25 | |||
26 | #undef memset | ||
27 | #undef memcpy | ||
28 | #define memzero(s, n) memset ((s), 0, (n)) | ||
29 | |||
30 | typedef unsigned char uch; | ||
31 | typedef unsigned short ush; | ||
32 | typedef unsigned long ulg; | ||
33 | |||
34 | #define WSIZE 0x8000 /* Window size must be at least 32k, */ | ||
35 | /* and a power of two */ | ||
36 | |||
37 | static uch *inbuf; /* input buffer */ | ||
38 | static uch window[WSIZE]; /* Sliding window buffer */ | ||
39 | |||
40 | static unsigned insize = 0; /* valid bytes in inbuf */ | ||
41 | static unsigned inptr = 0; /* index of next byte to be processed in inbuf */ | ||
42 | static unsigned outcnt = 0; /* bytes in output buffer */ | ||
43 | |||
44 | /* gzip flag byte */ | ||
45 | #define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ | ||
46 | #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ | ||
47 | #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ | ||
48 | #define ORIG_NAME 0x08 /* bit 3 set: original file name present */ | ||
49 | #define COMMENT 0x10 /* bit 4 set: file comment present */ | ||
50 | #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ | ||
51 | #define RESERVED 0xC0 /* bit 6,7: reserved */ | ||
52 | |||
53 | #define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) | ||
54 | |||
55 | /* Diagnostic functions */ | ||
56 | #ifdef DEBUG | ||
57 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | ||
58 | # define Trace(x) fprintf x | ||
59 | # define Tracev(x) {if (verbose) fprintf x ;} | ||
60 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | ||
61 | # define Tracec(c,x) {if (verbose && (c)) fprintf x ;} | ||
62 | # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} | ||
63 | #else | ||
64 | # define Assert(cond,msg) | ||
65 | # define Trace(x) | ||
66 | # define Tracev(x) | ||
67 | # define Tracevv(x) | ||
68 | # define Tracec(c,x) | ||
69 | # define Tracecv(c,x) | ||
70 | #endif | ||
71 | |||
72 | static int fill_inbuf(void); | ||
73 | static void flush_window(void); | ||
74 | static void error(char *m); | ||
75 | |||
76 | extern char input_data[]; | ||
77 | extern int input_len; | ||
78 | |||
79 | static long bytes_out = 0; | ||
80 | static uch *output_data; | ||
81 | static unsigned long output_ptr = 0; | ||
82 | |||
83 | static void error(char *m); | ||
84 | |||
85 | static void puts(const char *); | ||
86 | |||
87 | extern int _text; /* Defined in vmlinux.lds.S */ | ||
88 | extern int _end; | ||
89 | static unsigned long free_mem_ptr; | ||
90 | static unsigned long free_mem_end_ptr; | ||
91 | |||
92 | #define HEAP_SIZE 0x10000 | ||
93 | |||
94 | #include "../../../../lib/inflate.c" | ||
95 | |||
96 | void puts(const char *s) | ||
97 | { | ||
98 | } | ||
99 | |||
100 | void *memset(void *s, int c, size_t n) | ||
101 | { | ||
102 | int i; | ||
103 | char *ss = (char *) s; | ||
104 | |||
105 | for (i = 0; i < n; i++) | ||
106 | ss[i] = c; | ||
107 | return s; | ||
108 | } | ||
109 | |||
110 | void *memcpy(void *__dest, __const void *__src, size_t __n) | ||
111 | { | ||
112 | int i; | ||
113 | char *d = (char *) __dest, *s = (char *) __src; | ||
114 | |||
115 | for (i = 0; i < __n; i++) | ||
116 | d[i] = s[i]; | ||
117 | return __dest; | ||
118 | } | ||
119 | |||
120 | /* =========================================================================== | ||
121 | * Fill the input buffer. This is called only when the buffer is empty | ||
122 | * and at least one byte is really needed. | ||
123 | */ | ||
124 | static int fill_inbuf(void) | ||
125 | { | ||
126 | if (insize != 0) { | ||
127 | error("ran out of input data\n"); | ||
128 | } | ||
129 | |||
130 | inbuf = input_data; | ||
131 | insize = input_len; | ||
132 | inptr = 1; | ||
133 | return inbuf[0]; | ||
134 | } | ||
135 | |||
136 | /* =========================================================================== | ||
137 | * Write the output window window[0..outcnt-1] and update crc and bytes_out. | ||
138 | * (Used for the decompressed data only.) | ||
139 | */ | ||
140 | static void flush_window(void) | ||
141 | { | ||
142 | ulg c = crc; /* temporary variable */ | ||
143 | unsigned n; | ||
144 | uch *in, *out, ch; | ||
145 | |||
146 | in = window; | ||
147 | out = &output_data[output_ptr]; | ||
148 | for (n = 0; n < outcnt; n++) { | ||
149 | ch = *out++ = *in++; | ||
150 | c = crc_32_tab[((int) c ^ ch) & 0xff] ^ (c >> 8); | ||
151 | } | ||
152 | crc = c; | ||
153 | bytes_out += (ulg) outcnt; | ||
154 | output_ptr += (ulg) outcnt; | ||
155 | outcnt = 0; | ||
156 | puts("."); | ||
157 | } | ||
158 | |||
159 | static void error(char *x) | ||
160 | { | ||
161 | puts("\n\n"); | ||
162 | puts(x); | ||
163 | puts("\n\n -- System halted"); | ||
164 | |||
165 | while (1) ; /* Halt */ | ||
166 | } | ||
167 | |||
168 | #define STACK_SIZE (4096) | ||
169 | long __attribute__ ((aligned(8))) user_stack[STACK_SIZE]; | ||
170 | long *stack_start = &user_stack[STACK_SIZE]; | ||
171 | |||
172 | void decompress_kernel(void) | ||
173 | { | ||
174 | output_data = (uch *) (CONFIG_MEMORY_START + 0x2000); | ||
175 | free_mem_ptr = (unsigned long) &_end; | ||
176 | free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; | ||
177 | |||
178 | makecrc(); | ||
179 | puts("Uncompressing Linux... "); | ||
180 | cache_control(CACHE_ENABLE); | ||
181 | gunzip(); | ||
182 | puts("\n"); | ||
183 | |||
184 | #if 0 | ||
185 | /* When booting from ROM may want to do something like this if the | ||
186 | * boot loader doesn't. | ||
187 | */ | ||
188 | |||
189 | /* Set up the parameters and command line */ | ||
190 | { | ||
191 | volatile unsigned int *parambase = | ||
192 | (int *) (CONFIG_MEMORY_START + 0x1000); | ||
193 | |||
194 | parambase[0] = 0x1; /* MOUNT_ROOT_RDONLY */ | ||
195 | parambase[1] = 0x0; /* RAMDISK_FLAGS */ | ||
196 | parambase[2] = 0x0200; /* ORIG_ROOT_DEV */ | ||
197 | parambase[3] = 0x0; /* LOADER_TYPE */ | ||
198 | parambase[4] = 0x0; /* INITRD_START */ | ||
199 | parambase[5] = 0x0; /* INITRD_SIZE */ | ||
200 | parambase[6] = 0; | ||
201 | |||
202 | strcpy((char *) ((int) parambase + 0x100), | ||
203 | "console=ttySC0,38400"); | ||
204 | } | ||
205 | #endif | ||
206 | |||
207 | puts("Ok, booting the kernel.\n"); | ||
208 | |||
209 | cache_control(CACHE_DISABLE); | ||
210 | } | ||
diff --git a/arch/sh/boot/compressed/piggy.S b/arch/sh/boot/compressed/piggy.S deleted file mode 100644 index 566071926b13..000000000000 --- a/arch/sh/boot/compressed/piggy.S +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | .global input_len, input_data | ||
2 | .data | ||
3 | input_len: | ||
4 | .long input_data_end - input_data | ||
5 | input_data: | ||
6 | .incbin "arch/sh/boot/compressed/vmlinux.bin.gz" | ||
7 | input_data_end: | ||
8 | .end | ||
diff --git a/arch/sh/boot/compressed/vmlinux.scr b/arch/sh/boot/compressed/vmlinux.scr new file mode 100644 index 000000000000..f02382ae5c48 --- /dev/null +++ b/arch/sh/boot/compressed/vmlinux.scr | |||
@@ -0,0 +1,10 @@ | |||
1 | SECTIONS | ||
2 | { | ||
3 | .rodata.compressed : { | ||
4 | input_len = .; | ||
5 | LONG(input_data_end - input_data) input_data = .; | ||
6 | *(.data) | ||
7 | output_len = . - 4; | ||
8 | input_data_end = .; | ||
9 | } | ||
10 | } | ||
diff --git a/arch/sh/boot/romimage/Makefile b/arch/sh/boot/romimage/Makefile new file mode 100644 index 000000000000..5806eee84f6f --- /dev/null +++ b/arch/sh/boot/romimage/Makefile | |||
@@ -0,0 +1,19 @@ | |||
1 | # | ||
2 | # linux/arch/sh/boot/romimage/Makefile | ||
3 | # | ||
4 | # create an image suitable for burning to flash from zImage | ||
5 | # | ||
6 | |||
7 | targets := vmlinux head.o | ||
8 | |||
9 | OBJECTS = $(obj)/head.o | ||
10 | LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext 0 -e romstart | ||
11 | |||
12 | $(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE | ||
13 | $(call if_changed,ld) | ||
14 | @: | ||
15 | |||
16 | LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T | ||
17 | |||
18 | $(obj)/piggy.o: $(obj)/vmlinux.scr arch/sh/boot/zImage FORCE | ||
19 | $(call if_changed,ld) | ||
diff --git a/arch/sh/boot/romimage/head.S b/arch/sh/boot/romimage/head.S new file mode 100644 index 000000000000..219bc626dd71 --- /dev/null +++ b/arch/sh/boot/romimage/head.S | |||
@@ -0,0 +1,10 @@ | |||
1 | /* | ||
2 | * linux/arch/sh/boot/romimage/head.S | ||
3 | * | ||
4 | * Board specific setup code, executed before zImage loader | ||
5 | */ | ||
6 | |||
7 | .text | ||
8 | .global romstart | ||
9 | romstart: | ||
10 | #include <mach/romimage.h> | ||
diff --git a/arch/sh/boot/romimage/vmlinux.scr b/arch/sh/boot/romimage/vmlinux.scr new file mode 100644 index 000000000000..287c08f8b4bb --- /dev/null +++ b/arch/sh/boot/romimage/vmlinux.scr | |||
@@ -0,0 +1,6 @@ | |||
1 | SECTIONS | ||
2 | { | ||
3 | .text : { | ||
4 | *(.data) | ||
5 | } | ||
6 | } | ||