aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJesper Nilsson <jesper.nilsson@axis.com>2009-04-21 05:44:57 -0400
committerJesper Nilsson <jesper.nilsson@axis.com>2009-04-21 05:44:57 -0400
commit66ab3a74c5ce737effc2c64391e036b0938b1c36 (patch)
treeabe71b0c811dd13c9b9ad2587ba8779a8f852220 /arch
parenta939b96cccdb65df80a52447ec8e4a6d79c56dbb (diff)
CRIS: Merge machine dependent boot/compressed and boot/rescue
Merge the machine dependent boot directories for v10 and v32. This avoids some code duplication and eases the way for further merging later on. Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/cris/Makefile14
-rw-r--r--arch/cris/arch-v10/boot/compressed/README25
-rw-r--r--arch/cris/arch-v10/boot/compressed/misc.c246
-rw-r--r--arch/cris/arch-v32/boot/Makefile20
-rw-r--r--arch/cris/arch-v32/boot/compressed/Makefile26
-rw-r--r--arch/cris/arch-v32/boot/rescue/Makefile26
-rw-r--r--arch/cris/boot/.gitignore (renamed from arch/cris/arch-v10/boot/.gitignore)0
-rw-r--r--arch/cris/boot/Makefile (renamed from arch/cris/arch-v10/boot/Makefile)8
-rw-r--r--arch/cris/boot/compressed/Makefile (renamed from arch/cris/arch-v10/boot/compressed/Makefile)19
-rw-r--r--arch/cris/boot/compressed/README (renamed from arch/cris/arch-v32/boot/compressed/README)0
-rw-r--r--arch/cris/boot/compressed/decompress_v10.lds (renamed from arch/cris/arch-v10/boot/compressed/decompress.lds)0
-rw-r--r--arch/cris/boot/compressed/decompress_v32.lds (renamed from arch/cris/arch-v32/boot/compressed/decompress.lds)0
-rw-r--r--arch/cris/boot/compressed/head_v10.S (renamed from arch/cris/arch-v10/boot/compressed/head.S)4
-rw-r--r--arch/cris/boot/compressed/head_v32.S (renamed from arch/cris/arch-v32/boot/compressed/head.S)10
-rw-r--r--arch/cris/boot/compressed/misc.c (renamed from arch/cris/arch-v32/boot/compressed/misc.c)193
-rw-r--r--arch/cris/boot/rescue/Makefile (renamed from arch/cris/arch-v10/boot/rescue/Makefile)22
-rw-r--r--arch/cris/boot/rescue/head_v10.S (renamed from arch/cris/arch-v10/boot/rescue/head.S)2
-rw-r--r--arch/cris/boot/rescue/head_v32.S (renamed from arch/cris/arch-v32/boot/rescue/head.S)0
-rw-r--r--arch/cris/boot/rescue/kimagerescue.S (renamed from arch/cris/arch-v10/boot/rescue/kimagerescue.S)0
-rw-r--r--arch/cris/boot/rescue/rescue_v10.lds (renamed from arch/cris/arch-v10/boot/rescue/rescue.lds)0
-rw-r--r--arch/cris/boot/rescue/rescue_v32.lds (renamed from arch/cris/arch-v32/boot/rescue/rescue.lds)0
-rw-r--r--arch/cris/boot/rescue/testrescue.S (renamed from arch/cris/arch-v10/boot/rescue/testrescue.S)0
-rw-r--r--arch/cris/boot/tools/build.c (renamed from arch/cris/arch-v10/boot/tools/build.c)0
23 files changed, 186 insertions, 429 deletions
diff --git a/arch/cris/Makefile b/arch/cris/Makefile
index 3662cfb7b61d..71e17d3eeddb 100644
--- a/arch/cris/Makefile
+++ b/arch/cris/Makefile
@@ -70,7 +70,7 @@ SRC_ARCH = $(srctree)/arch/cris
70# cris object files path 70# cris object files path
71OBJ_ARCH = $(objtree)/arch/cris 71OBJ_ARCH = $(objtree)/arch/cris
72 72
73boot := arch/cris/$(SARCH)/boot 73boot := arch/cris/boot
74MACHINE := arch/cris/$(SARCH) 74MACHINE := arch/cris/$(SARCH)
75 75
76all: zImage 76all: zImage
@@ -81,15 +81,15 @@ zImage Image: vmlinux
81archprepare: 81archprepare:
82 82
83archclean: 83archclean:
84 $(Q)if [ -e arch/cris/$(SARCH)/boot ]; then \ 84 $(Q)if [ -e arch/cris/boot ]; then \
85 $(MAKE) $(clean)=arch/cris/$(SARCH)/boot; \ 85 $(MAKE) $(clean)=arch/cris/boot; \
86 fi 86 fi
87 87
88CLEAN_FILES += \ 88CLEAN_FILES += \
89 $(MACHINE)/boot/zImage \ 89 $(boot)/zImage \
90 $(MACHINE)/boot/compressed/decompress.bin \ 90 $(boot)/compressed/decompress.bin \
91 $(MACHINE)/boot/compressed/piggy.gz \ 91 $(boot)/compressed/piggy.gz \
92 $(MACHINE)/boot/rescue/rescue.bin 92 $(boot)/rescue/rescue.bin
93 93
94 94
95# MRPROPER_FILES += 95# MRPROPER_FILES +=
diff --git a/arch/cris/arch-v10/boot/compressed/README b/arch/cris/arch-v10/boot/compressed/README
deleted file mode 100644
index 48b3db9924b9..000000000000
--- a/arch/cris/arch-v10/boot/compressed/README
+++ /dev/null
@@ -1,25 +0,0 @@
1Creation of the self-extracting compressed kernel image (vmlinuz)
2-----------------------------------------------------------------
3$Id: README,v 1.1 2001/12/17 13:59:27 bjornw Exp $
4
5This can be slightly confusing because it's a process with many steps.
6
7The kernel object built by the arch/etrax100/Makefile, vmlinux, is split
8by that makefile into text and data binary files, vmlinux.text and
9vmlinux.data.
10
11Those files together with a ROM filesystem can be catted together and
12burned into a flash or executed directly at the DRAM origin.
13
14They can also be catted together and compressed with gzip, which is what
15happens in this makefile. Together they make up piggy.img.
16
17The decompressor is built into the file decompress.o. It is turned into
18the binary file decompress.bin, which is catted together with piggy.img
19into the file vmlinuz. It can be executed in an arbitrary place in flash.
20
21Be careful - it assumes some things about free locations in DRAM. It
22assumes the DRAM starts at 0x40000000 and that it is at least 8 MB,
23so it puts its code at 0x40700000, and initial stack at 0x40800000.
24
25-Bjorn
diff --git a/arch/cris/arch-v10/boot/compressed/misc.c b/arch/cris/arch-v10/boot/compressed/misc.c
deleted file mode 100644
index a4db1507d3b1..000000000000
--- a/arch/cris/arch-v10/boot/compressed/misc.c
+++ /dev/null
@@ -1,246 +0,0 @@
1/*
2 * 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 * puts by Nick Holloway 1993, better puts by Martin Mares 1995
9 * adaptation for Linux/CRIS Axis Communications AB, 1999
10 *
11 */
12
13/* where the piggybacked kernel image expects itself to live.
14 * it is the same address we use when we network load an uncompressed
15 * image into DRAM, and it is the address the kernel is linked to live
16 * at by vmlinux.lds.S
17 */
18
19#define KERNEL_LOAD_ADR 0x40004000
20
21
22#include <linux/types.h>
23#include <arch/svinto.h>
24
25/*
26 * gzip declarations
27 */
28
29#define OF(args) args
30#define STATIC static
31
32void *memset(void *s, int c, size_t n);
33void *memcpy(void *__dest, __const void *__src, size_t __n);
34
35#define memzero(s, n) memset((s), 0, (n))
36
37typedef unsigned char uch;
38typedef unsigned short ush;
39typedef unsigned long ulg;
40
41#define WSIZE 0x8000 /* Window size must be at least 32k, */
42 /* and a power of two */
43
44static uch *inbuf; /* input buffer */
45static uch window[WSIZE]; /* Sliding window buffer */
46
47unsigned inptr = 0; /* index of next byte to be processed in inbuf
48 * After decompression it will contain the
49 * compressed size, and head.S will read it.
50 */
51
52static unsigned outcnt = 0; /* bytes in output buffer */
53
54/* gzip flag byte */
55#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
56#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
57#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
58#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
59#define COMMENT 0x10 /* bit 4 set: file comment present */
60#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
61#define RESERVED 0xC0 /* bit 6,7: reserved */
62
63#define get_byte() (inbuf[inptr++])
64
65/* Diagnostic functions */
66#ifdef DEBUG
67# define Assert(cond, msg) do { \
68 if (!(cond)) \
69 error(msg); \
70 } while (0)
71# define Trace(x) fprintf x
72# define Tracev(x) do { \
73 if (verbose) \
74 fprintf x; \
75 } while (0)
76# define Tracevv(x) do { \
77 if (verbose > 1) \
78 fprintf x; \
79 } while (0)
80# define Tracec(c, x) do { \
81 if (verbose && (c)) \
82 fprintf x; \
83 } while (0)
84# define Tracecv(c, x) do { \
85 if (verbose > 1 && (c)) \
86 fprintf x; \
87 } while (0)
88#else
89# define Assert(cond, msg)
90# define Trace(x)
91# define Tracev(x)
92# define Tracevv(x)
93# define Tracec(c, x)
94# define Tracecv(c, x)
95#endif
96
97static void flush_window(void);
98static void error(char *m);
99
100extern char *input_data; /* lives in head.S */
101
102static long bytes_out = 0;
103static uch *output_data;
104static unsigned long output_ptr = 0;
105static void puts(const char *);
106
107/* the "heap" is put directly after the BSS ends, at end */
108
109extern int _end;
110static long free_mem_ptr = (long)&_end;
111static long free_mem_end_ptr;
112
113#include "../../../../../lib/inflate.c"
114
115/* decompressor info and error messages to serial console */
116
117static void
118puts(const char *s)
119{
120#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
121 while (*s) {
122#ifdef CONFIG_ETRAX_DEBUG_PORT0
123 while (!(*R_SERIAL0_STATUS & (1 << 5))) ;
124 *R_SERIAL0_TR_DATA = *s++;
125#endif
126#ifdef CONFIG_ETRAX_DEBUG_PORT1
127 while (!(*R_SERIAL1_STATUS & (1 << 5))) ;
128 *R_SERIAL1_TR_DATA = *s++;
129#endif
130#ifdef CONFIG_ETRAX_DEBUG_PORT2
131 while (!(*R_SERIAL2_STATUS & (1 << 5))) ;
132 *R_SERIAL2_TR_DATA = *s++;
133#endif
134#ifdef CONFIG_ETRAX_DEBUG_PORT3
135 while (!(*R_SERIAL3_STATUS & (1 << 5))) ;
136 *R_SERIAL3_TR_DATA = *s++;
137#endif
138 }
139#endif
140}
141
142void *memset(void *s, int c, size_t n)
143{
144 int i;
145 char *ss = (char *)s;
146
147 for (i = 0; i < n; i++)
148 ss[i] = c;
149
150 return s;
151}
152
153void *memcpy(void *__dest, __const void *__src, size_t __n)
154{
155 int i;
156 char *d = (char *)__dest, *s = (char *)__src;
157
158 for (i = 0; i < __n; i++)
159 d[i] = s[i];
160
161 return __dest;
162}
163
164/* ===========================================================================
165 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
166 * (Used for the decompressed data only.)
167 */
168
169static void flush_window(void)
170{
171 ulg c = crc; /* temporary variable */
172 unsigned n;
173 uch *in, *out, ch;
174
175 in = window;
176 out = &output_data[output_ptr];
177 for (n = 0; n < outcnt; n++) {
178 ch = *out = *in;
179 out++;
180 in++;
181 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
182 }
183 crc = c;
184 bytes_out += (ulg)outcnt;
185 output_ptr += (ulg)outcnt;
186 outcnt = 0;
187}
188
189static void error(char *x)
190{
191 puts("\n\n");
192 puts(x);
193 puts("\n\n -- System halted\n");
194
195 while (1); /* Halt */
196}
197
198void setup_normal_output_buffer(void)
199{
200 output_data = (char *)KERNEL_LOAD_ADR;
201}
202
203void decompress_kernel(void)
204{
205 char revision;
206
207 /* input_data is set in head.S */
208 inbuf = input_data;
209
210#ifdef CONFIG_ETRAX_DEBUG_PORT0
211 *R_SERIAL0_XOFF = 0;
212 *R_SERIAL0_BAUD = 0x99;
213 *R_SERIAL0_TR_CTRL = 0x40;
214#endif
215#ifdef CONFIG_ETRAX_DEBUG_PORT1
216 *R_SERIAL1_XOFF = 0;
217 *R_SERIAL1_BAUD = 0x99;
218 *R_SERIAL1_TR_CTRL = 0x40;
219#endif
220#ifdef CONFIG_ETRAX_DEBUG_PORT2
221 *R_GEN_CONFIG = 0x08;
222 *R_SERIAL2_XOFF = 0;
223 *R_SERIAL2_BAUD = 0x99;
224 *R_SERIAL2_TR_CTRL = 0x40;
225#endif
226#ifdef CONFIG_ETRAX_DEBUG_PORT3
227 *R_GEN_CONFIG = 0x100;
228 *R_SERIAL3_XOFF = 0;
229 *R_SERIAL3_BAUD = 0x99;
230 *R_SERIAL3_TR_CTRL = 0x40;
231#endif
232
233 setup_normal_output_buffer();
234
235 makecrc();
236
237 __asm__ volatile ("move $vr,%0" : "=rm" (revision));
238 if (revision < 10) {
239 puts("You need an ETRAX 100LX to run linux 2.6\n");
240 while (1);
241 }
242
243 puts("Uncompressing Linux...\n");
244 gunzip();
245 puts("Done. Now booting the kernel.\n");
246}
diff --git a/arch/cris/arch-v32/boot/Makefile b/arch/cris/arch-v32/boot/Makefile
deleted file mode 100644
index 99896ad60b30..000000000000
--- a/arch/cris/arch-v32/boot/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
1#
2# arch/cris/arch-v32/boot/Makefile
3#
4
5OBJCOPYFLAGS = -O binary -R .note -R .comment
6
7subdir- := compressed rescue
8targets := Image
9
10$(obj)/Image: vmlinux FORCE
11 $(call if_changed,objcopy)
12 @echo ' Kernel: $@ is ready'
13
14$(obj)/compressed/vmlinux: $(obj)/Image FORCE
15 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
16 $(Q)$(MAKE) $(build)=$(obj)/rescue $(obj)/rescue/rescue.bin
17
18$(obj)/zImage: $(obj)/compressed/vmlinux
19 @cp $< $@
20 @echo ' Kernel: $@ is ready'
diff --git a/arch/cris/arch-v32/boot/compressed/Makefile b/arch/cris/arch-v32/boot/compressed/Makefile
deleted file mode 100644
index e176b8b69d92..000000000000
--- a/arch/cris/arch-v32/boot/compressed/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
1#
2# arch/cris/arch-v32/boot/compressed/Makefile
3#
4
5asflags-y += -I$(srctree)/include/asm/mach/ -I$(srctree)/include/asm/arch
6ccflags-y += -O2 -I$(srctree)/include/asm/mach/ -I$(srctree)/include/asm/arch
7ldflags-y += -T$(srctree)/$(src)/decompress.lds
8OBJECTS = $(obj)/head.o $(obj)/misc.o
9OBJCOPYFLAGS = -O binary --remove-section=.bss
10
11quiet_cmd_image = BUILD $@
12cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@
13
14targets := vmlinux piggy.gz decompress.o decompress.bin
15
16$(obj)/decompress.o: $(OBJECTS) FORCE
17 $(call if_changed,ld)
18
19$(obj)/decompress.bin: $(obj)/decompress.o FORCE
20 $(call if_changed,objcopy)
21
22$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
23 $(call if_changed,image)
24
25$(obj)/piggy.gz: $(obj)/../Image FORCE
26 $(call if_changed,gzip)
diff --git a/arch/cris/arch-v32/boot/rescue/Makefile b/arch/cris/arch-v32/boot/rescue/Makefile
deleted file mode 100644
index 566aac663a38..000000000000
--- a/arch/cris/arch-v32/boot/rescue/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
1#
2# Makefile for rescue (bootstrap) code
3#
4
5CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE)
6ccflags-y += -O2 -I $(srctree)/include/asm/arch/mach/ \
7 -I $(srctree)/include/asm/arch
8asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch
9LD = gcc-cris -mlinux -march=v32 -nostdlib
10ldflags-y += -T $(srctree)/$(src)/rescue.lds
11LDPOSTFLAGS = -lgcc
12OBJCOPYFLAGS = -O binary --remove-section=.bss
13obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o
14OBJECT := $(obj)/head.o
15
16targets := rescue.o rescue.bin
17
18quiet_cmd_ldlibgcc = LD $@
19cmd_ldlibgcc = $(LD) $(LDFLAGS) $(filter-out FORCE,$^) $(LDPOSTFLAGS) -o $@
20
21$(obj)/rescue.o: $(OBJECTS) FORCE
22 $(call if_changed,ldlibgcc)
23
24$(obj)/rescue.bin: $(obj)/rescue.o FORCE
25 $(call if_changed,objcopy)
26 cp -p $(obj)/rescue.bin $(objtree)
diff --git a/arch/cris/arch-v10/boot/.gitignore b/arch/cris/boot/.gitignore
index 171a0853caf8..171a0853caf8 100644
--- a/arch/cris/arch-v10/boot/.gitignore
+++ b/arch/cris/boot/.gitignore
diff --git a/arch/cris/arch-v10/boot/Makefile b/arch/cris/boot/Makefile
index 217203014433..144f3afa0119 100644
--- a/arch/cris/arch-v10/boot/Makefile
+++ b/arch/cris/boot/Makefile
@@ -1,8 +1,12 @@
1# 1#
2# arch/cris/arch-v10/boot/Makefile 2# arch/cris/boot/Makefile
3# 3#
4 4
5OBJCOPYFLAGS = -O binary --remove-section=.bss 5objcopyflags-$(CONFIG_ETRAX_ARCH_V10) += -R .note -R .comment
6objcopyflags-$(CONFIG_ETRAX_ARCH_V32) += --remove-section=.bss
7
8OBJCOPYFLAGS = -O binary $(objcopyflags-y)
9
6 10
7subdir- := compressed rescue 11subdir- := compressed rescue
8targets := Image 12targets := Image
diff --git a/arch/cris/arch-v10/boot/compressed/Makefile b/arch/cris/boot/compressed/Makefile
index 6fe0ffaf3be6..8fe9338c1775 100644
--- a/arch/cris/arch-v10/boot/compressed/Makefile
+++ b/arch/cris/boot/compressed/Makefile
@@ -1,11 +1,23 @@
1# 1#
2# arch/cris/arch-v10/boot/compressed/Makefile 2# arch/cris/boot/compressed/Makefile
3# 3#
4 4
5asflags-y += $(LINUXINCLUDE) 5asflags-y += $(LINUXINCLUDE)
6ccflags-y += -O2 $(LINUXINCLUDE) 6ccflags-y += -O2 $(LINUXINCLUDE)
7ldflags-y += -T $(srctree)/$(src)/decompress.lds 7
8OBJECTS = $(obj)/head.o $(obj)/misc.o 8# asflags-$(CONFIG_ETRAX_ARCH_V32) += -I$(srctree)/include/asm/mach \
9# -I$(srctree)/include/asm/arch
10# ccflags-$(CONFIG_ETRAX_ARCH_V32) += -O2 -I$(srctree)/include/asm/mach
11# -I$(srctree)/include/asm/arch
12
13arch-$(CONFIG_ETRAX_ARCH_V10) = v10
14arch-$(CONFIG_ETRAX_ARCH_V32) = v32
15
16ldflags-y += -T $(srctree)/$(src)/decompress_$(arch-y).lds
17
18OBJECTS-$(CONFIG_ETRAX_ARCH_V32) = $(obj)/head_v32.o
19OBJECTS-$(CONFIG_ETRAX_ARCH_V10) = $(obj)/head_v10.o
20OBJECTS= $(OBJECTS-y) $(obj)/misc.o
9OBJCOPYFLAGS = -O binary --remove-section=.bss 21OBJCOPYFLAGS = -O binary --remove-section=.bss
10 22
11quiet_cmd_image = BUILD $@ 23quiet_cmd_image = BUILD $@
@@ -24,4 +36,3 @@ $(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
24 36
25$(obj)/piggy.gz: $(obj)/../Image FORCE 37$(obj)/piggy.gz: $(obj)/../Image FORCE
26 $(call if_changed,gzip) 38 $(call if_changed,gzip)
27
diff --git a/arch/cris/arch-v32/boot/compressed/README b/arch/cris/boot/compressed/README
index 182c5d75784b..182c5d75784b 100644
--- a/arch/cris/arch-v32/boot/compressed/README
+++ b/arch/cris/boot/compressed/README
diff --git a/arch/cris/arch-v10/boot/compressed/decompress.lds b/arch/cris/boot/compressed/decompress_v10.lds
index e80f4594d543..e80f4594d543 100644
--- a/arch/cris/arch-v10/boot/compressed/decompress.lds
+++ b/arch/cris/boot/compressed/decompress_v10.lds
diff --git a/arch/cris/arch-v32/boot/compressed/decompress.lds b/arch/cris/boot/compressed/decompress_v32.lds
index 3c837feca3ac..3c837feca3ac 100644
--- a/arch/cris/arch-v32/boot/compressed/decompress.lds
+++ b/arch/cris/boot/compressed/decompress_v32.lds
diff --git a/arch/cris/arch-v10/boot/compressed/head.S b/arch/cris/boot/compressed/head_v10.S
index 0bb4dcc29254..9edb8ade7e1f 100644
--- a/arch/cris/arch-v10/boot/compressed/head.S
+++ b/arch/cris/boot/compressed/head_v10.S
@@ -30,7 +30,7 @@
30 beq dram_init_finished 30 beq dram_init_finished
31 nop 31 nop
32 32
33#include "../../lib/dram_init.S" 33#include "../../arch-v10/lib/dram_init.S"
34 34
35dram_init_finished: 35dram_init_finished:
36 36
@@ -123,4 +123,4 @@ _cmd_line_magic:
123 .dword 0 123 .dword 0
124_cmd_line_addr: 124_cmd_line_addr:
125 .dword 0 125 .dword 0
126#include "../../lib/hw_settings.S" 126#include "../../arch-v10/lib/hw_settings.S"
diff --git a/arch/cris/arch-v32/boot/compressed/head.S b/arch/cris/boot/compressed/head_v32.S
index a4a65c5c669e..f483005f3d48 100644
--- a/arch/cris/arch-v32/boot/compressed/head.S
+++ b/arch/cris/boot/compressed/head_v32.S
@@ -17,7 +17,7 @@
17 .globl input_data 17 .globl input_data
18 18
19 .text 19 .text
20_start: 20start:
21 di 21 di
22 22
23 ;; Start clocks for used blocks. 23 ;; Start clocks for used blocks.
@@ -29,9 +29,9 @@ _start:
29 nop 29 nop
30 30
31#if defined CONFIG_ETRAXFS 31#if defined CONFIG_ETRAXFS
32#include "../../mach-fs/dram_init.S" 32#include "../../arch-v32/mach-fs/dram_init.S"
33#elif defined CONFIG_CRIS_MACH_ARTPEC3 33#elif defined CONFIG_CRIS_MACH_ARTPEC3
34#include "../../mach-a3/dram_init.S" 34#include "../../arch-v32/mach-a3/dram_init.S"
35#else 35#else
36#error Only ETRAXFS and ARTPEC-3 supported! 36#error Only ETRAXFS and ARTPEC-3 supported!
37#endif 37#endif
@@ -137,9 +137,9 @@ _boot_source:
137 .dword 0 137 .dword 0
138 138
139#if defined CONFIG_ETRAXFS 139#if defined CONFIG_ETRAXFS
140#include "../../mach-fs/hw_settings.S" 140#include "../../arch-v32/mach-fs/hw_settings.S"
141#elif defined CONFIG_CRIS_MACH_ARTPEC3 141#elif defined CONFIG_CRIS_MACH_ARTPEC3
142#include "../../mach-a3/hw_settings.S" 142#include "../../arch-v32/mach-a3/hw_settings.S"
143#else 143#else
144#error Only ETRAXFS and ARTPEC-3 supported! 144#error Only ETRAXFS and ARTPEC-3 supported!
145#endif 145#endif
diff --git a/arch/cris/arch-v32/boot/compressed/misc.c b/arch/cris/boot/compressed/misc.c
index 3595e16e82bc..47bc190ba6d4 100644
--- a/arch/cris/arch-v32/boot/compressed/misc.c
+++ b/arch/cris/boot/compressed/misc.c
@@ -18,8 +18,9 @@
18 18
19#define KERNEL_LOAD_ADR 0x40004000 19#define KERNEL_LOAD_ADR 0x40004000
20 20
21
22#include <linux/types.h> 21#include <linux/types.h>
22
23#ifdef CONFIG_ETRAX_ARCH_V32
23#include <hwregs/reg_rdwr.h> 24#include <hwregs/reg_rdwr.h>
24#include <hwregs/reg_map.h> 25#include <hwregs/reg_map.h>
25#include <hwregs/ser_defs.h> 26#include <hwregs/ser_defs.h>
@@ -27,6 +28,9 @@
27#ifdef CONFIG_CRIS_MACH_ARTPEC3 28#ifdef CONFIG_CRIS_MACH_ARTPEC3
28#include <hwregs/clkgen_defs.h> 29#include <hwregs/clkgen_defs.h>
29#endif 30#endif
31#else
32#include <arch/svinto.h>
33#endif
30 34
31/* 35/*
32 * gzip declarations 36 * gzip declarations
@@ -35,12 +39,10 @@
35#define OF(args) args 39#define OF(args) args
36#define STATIC static 40#define STATIC static
37 41
38void* memset(void* s, int c, size_t n); 42void *memset(void *s, int c, size_t n);
39void* memcpy(void* __dest, __const void* __src, 43void *memcpy(void *__dest, __const void *__src, size_t __n);
40 size_t __n);
41
42#define memzero(s, n) memset ((s), 0, (n))
43 44
45#define memzero(s, n) memset((s), 0, (n))
44 46
45typedef unsigned char uch; 47typedef unsigned char uch;
46typedef unsigned short ush; 48typedef unsigned short ush;
@@ -68,27 +70,43 @@ static unsigned outcnt = 0; /* bytes in output buffer */
68#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ 70#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
69#define RESERVED 0xC0 /* bit 6,7: reserved */ 71#define RESERVED 0xC0 /* bit 6,7: reserved */
70 72
71#define get_byte() inbuf[inptr++] 73#define get_byte() (inbuf[inptr++])
72 74
73/* Diagnostic functions */ 75/* Diagnostic functions */
74#ifdef DEBUG 76#ifdef DEBUG
75# define Assert(cond,msg) {if(!(cond)) error(msg);} 77# define Assert(cond, msg) do { \
78 if (!(cond)) \
79 error(msg); \
80 } while (0)
76# define Trace(x) fprintf x 81# define Trace(x) fprintf x
77# define Tracev(x) {if (verbose) fprintf x ;} 82# define Tracev(x) do { \
78# define Tracevv(x) {if (verbose>1) fprintf x ;} 83 if (verbose) \
79# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} 84 fprintf x; \
80# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} 85 } while (0)
86# define Tracevv(x) do { \
87 if (verbose > 1) \
88 fprintf x; \
89 } while (0)
90# define Tracec(c, x) do { \
91 if (verbose && (c)) \
92 fprintf x; \
93 } while (0)
94# define Tracecv(c, x) do { \
95 if (verbose > 1 && (c)) \
96 fprintf x; \
97 } while (0)
81#else 98#else
82# define Assert(cond,msg) 99# define Assert(cond, msg)
83# define Trace(x) 100# define Trace(x)
84# define Tracev(x) 101# define Tracev(x)
85# define Tracevv(x) 102# define Tracevv(x)
86# define Tracec(c,x) 103# define Tracec(c, x)
87# define Tracecv(c,x) 104# define Tracecv(c, x)
88#endif 105#endif
89 106
90static void flush_window(void); 107static void flush_window(void);
91static void error(char *m); 108static void error(char *m);
109static void puts(const char *);
92 110
93extern char *input_data; /* lives in head.S */ 111extern char *input_data; /* lives in head.S */
94 112
@@ -96,10 +114,6 @@ static long bytes_out;
96static uch *output_data; 114static uch *output_data;
97static unsigned long output_ptr; 115static unsigned long output_ptr;
98 116
99static void error(char *m);
100
101static void puts(const char *);
102
103/* the "heap" is put directly after the BSS ends, at end */ 117/* the "heap" is put directly after the BSS ends, at end */
104 118
105extern int _end; 119extern int _end;
@@ -110,8 +124,8 @@ static long free_mem_end_ptr;
110 124
111/* decompressor info and error messages to serial console */ 125/* decompressor info and error messages to serial console */
112 126
113static inline void 127#ifdef CONFIG_ETRAX_ARCH_V32
114serout(const char *s, reg_scope_instances regi_ser) 128static inline void serout(const char *s, reg_scope_instances regi_ser)
115{ 129{
116 reg_ser_rs_stat_din rs; 130 reg_ser_rs_stat_din rs;
117 reg_ser_rw_dout dout = {.data = *s}; 131 reg_ser_rw_dout dout = {.data = *s};
@@ -123,23 +137,47 @@ serout(const char *s, reg_scope_instances regi_ser)
123 137
124 REG_WR(ser, regi_ser, rw_dout, dout); 138 REG_WR(ser, regi_ser, rw_dout, dout);
125} 139}
140#endif
126 141
127static void 142static void puts(const char *s)
128puts(const char *s)
129{ 143{
130#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL 144#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
131 while (*s) { 145 while (*s) {
132#ifdef CONFIG_ETRAX_DEBUG_PORT0 146#ifdef CONFIG_ETRAX_DEBUG_PORT0
147#ifdef CONFIG_ETRAX_ARCH_V32
133 serout(s, regi_ser0); 148 serout(s, regi_ser0);
149#else
150 while (!(*R_SERIAL0_STATUS & (1 << 5)))
151 ;
152 *R_SERIAL0_TR_DATA = *s++;
153#endif
134#endif 154#endif
135#ifdef CONFIG_ETRAX_DEBUG_PORT1 155#ifdef CONFIG_ETRAX_DEBUG_PORT1
156#ifdef CONFIG_ETRAX_ARCH_V32
136 serout(s, regi_ser1); 157 serout(s, regi_ser1);
158#else
159 while (!(*R_SERIAL1_STATUS & (1 << 5)))
160 ;
161 *R_SERIAL1_TR_DATA = *s++;
162#endif
137#endif 163#endif
138#ifdef CONFIG_ETRAX_DEBUG_PORT2 164#ifdef CONFIG_ETRAX_DEBUG_PORT2
165#ifdef CONFIG_ETRAX_ARCH_V32
139 serout(s, regi_ser2); 166 serout(s, regi_ser2);
167#else
168 while (!(*R_SERIAL2_STATUS & (1 << 5)))
169 ;
170 *R_SERIAL2_TR_DATA = *s++;
171#endif
140#endif 172#endif
141#ifdef CONFIG_ETRAX_DEBUG_PORT3 173#ifdef CONFIG_ETRAX_DEBUG_PORT3
174#ifdef CONFIG_ETRAX_ARCH_V32
142 serout(s, regi_ser3); 175 serout(s, regi_ser3);
176#else
177 while (!(*R_SERIAL3_STATUS & (1 << 5)))
178 ;
179 *R_SERIAL3_TR_DATA = *s++;
180#endif
143#endif 181#endif
144 *s++; 182 *s++;
145 } 183 }
@@ -147,8 +185,7 @@ puts(const char *s)
147#endif 185#endif
148} 186}
149 187
150void* 188void *memset(void *s, int c, size_t n)
151memset(void* s, int c, size_t n)
152{ 189{
153 int i; 190 int i;
154 char *ss = (char*)s; 191 char *ss = (char*)s;
@@ -158,14 +195,13 @@ memset(void* s, int c, size_t n)
158 return s; 195 return s;
159} 196}
160 197
161void* 198void *memcpy(void *__dest, __const void *__src, size_t __n)
162memcpy(void* __dest, __const void* __src,
163 size_t __n)
164{ 199{
165 int i; 200 int i;
166 char *d = (char *)__dest, *s = (char *)__src; 201 char *d = (char *)__dest, *s = (char *)__src;
167 202
168 for (i=0;i<__n;i++) d[i] = s[i]; 203 for (i = 0; i < __n; i++)
204 d[i] = s[i];
169 205
170 return __dest; 206 return __dest;
171} 207}
@@ -175,43 +211,42 @@ memcpy(void* __dest, __const void* __src,
175 * (Used for the decompressed data only.) 211 * (Used for the decompressed data only.)
176 */ 212 */
177 213
178static void 214static void flush_window(void)
179flush_window()
180{ 215{
181 ulg c = crc; /* temporary variable */ 216 ulg c = crc; /* temporary variable */
182 unsigned n; 217 unsigned n;
183 uch *in, *out, ch; 218 uch *in, *out, ch;
184 219
185 in = window; 220 in = window;
186 out = &output_data[output_ptr]; 221 out = &output_data[output_ptr];
187 for (n = 0; n < outcnt; n++) { 222 for (n = 0; n < outcnt; n++) {
188 ch = *out++ = *in++; 223 ch = *out = *in;
189 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); 224 out++;
190 } 225 in++;
191 crc = c; 226 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
192 bytes_out += (ulg)outcnt; 227 }
193 output_ptr += (ulg)outcnt; 228 crc = c;
194 outcnt = 0; 229 bytes_out += (ulg)outcnt;
230 output_ptr += (ulg)outcnt;
231 outcnt = 0;
195} 232}
196 233
197static void 234static void error(char *x)
198error(char *x)
199{ 235{
200 puts("\r\n\n"); 236 puts("\n\n");
201 puts(x); 237 puts(x);
202 puts("\r\n\n -- System halted\n"); 238 puts("\n\n -- System halted\n");
203 239
204 while(1); /* Halt */ 240 while(1); /* Halt */
205} 241}
206 242
207void 243void setup_normal_output_buffer(void)
208setup_normal_output_buffer(void)
209{ 244{
210 output_data = (char *)KERNEL_LOAD_ADR; 245 output_data = (char *)KERNEL_LOAD_ADR;
211} 246}
212 247
213static inline void 248#ifdef CONFIG_ETRAX_ARCH_V32
214serial_setup(reg_scope_instances regi_ser) 249static inline void serial_setup(reg_scope_instances regi_ser)
215{ 250{
216 reg_ser_rw_xoff xoff; 251 reg_ser_rw_xoff xoff;
217 reg_ser_rw_tr_ctrl tr_ctrl; 252 reg_ser_rw_tr_ctrl tr_ctrl;
@@ -252,12 +287,16 @@ serial_setup(reg_scope_instances regi_ser)
252 REG_WR(ser, regi_ser, rw_rec_ctrl, rec_ctrl); 287 REG_WR(ser, regi_ser, rw_rec_ctrl, rec_ctrl);
253 REG_WR(ser, regi_ser, rw_rec_baud_div, rec_baud); 288 REG_WR(ser, regi_ser, rw_rec_baud_div, rec_baud);
254} 289}
290#endif
255 291
256void 292void decompress_kernel(void)
257decompress_kernel(void)
258{ 293{
259 char revision; 294 char revision;
295 char compile_rev;
260 296
297#ifdef CONFIG_ETRAX_ARCH_V32
298 /* Need at least a CRISv32 to run. */
299 compile_rev = 32;
261#if defined(CONFIG_ETRAX_DEBUG_PORT1) || \ 300#if defined(CONFIG_ETRAX_DEBUG_PORT1) || \
262 defined(CONFIG_ETRAX_DEBUG_PORT2) || \ 301 defined(CONFIG_ETRAX_DEBUG_PORT2) || \
263 defined(CONFIG_ETRAX_DEBUG_PORT3) 302 defined(CONFIG_ETRAX_DEBUG_PORT3)
@@ -277,6 +316,7 @@ decompress_kernel(void)
277 hwprot = REG_RD(pinmux, regi_pinmux, rw_hwprot); 316 hwprot = REG_RD(pinmux, regi_pinmux, rw_hwprot);
278#endif 317#endif
279 318
319
280#ifdef CONFIG_ETRAX_DEBUG_PORT0 320#ifdef CONFIG_ETRAX_DEBUG_PORT0
281 serial_setup(regi_ser0); 321 serial_setup(regi_ser0);
282#endif 322#endif
@@ -300,19 +340,52 @@ decompress_kernel(void)
300 340
301 /* input_data is set in head.S */ 341 /* input_data is set in head.S */
302 inbuf = input_data; 342 inbuf = input_data;
343#else /* CRISv10 */
344 /* Need at least a crisv10 to run. */
345 compile_rev = 10;
346
347 /* input_data is set in head.S */
348 inbuf = input_data;
349
350#ifdef CONFIG_ETRAX_DEBUG_PORT0
351 *R_SERIAL0_XOFF = 0;
352 *R_SERIAL0_BAUD = 0x99;
353 *R_SERIAL0_TR_CTRL = 0x40;
354#endif
355#ifdef CONFIG_ETRAX_DEBUG_PORT1
356 *R_SERIAL1_XOFF = 0;
357 *R_SERIAL1_BAUD = 0x99;
358 *R_SERIAL1_TR_CTRL = 0x40;
359#endif
360#ifdef CONFIG_ETRAX_DEBUG_PORT2
361 *R_GEN_CONFIG = 0x08;
362 *R_SERIAL2_XOFF = 0;
363 *R_SERIAL2_BAUD = 0x99;
364 *R_SERIAL2_TR_CTRL = 0x40;
365#endif
366#ifdef CONFIG_ETRAX_DEBUG_PORT3
367 *R_GEN_CONFIG = 0x100;
368 *R_SERIAL3_XOFF = 0;
369 *R_SERIAL3_BAUD = 0x99;
370 *R_SERIAL3_TR_CTRL = 0x40;
371#endif
372#endif
303 373
304 setup_normal_output_buffer(); 374 setup_normal_output_buffer();
305 375
306 makecrc(); 376 makecrc();
307 377
308 __asm__ volatile ("move $vr,%0" : "=rm" (revision)); 378 __asm__ volatile ("move $vr,%0" : "=rm" (revision));
309 if (revision < 32) 379 if (revision < compile_rev) {
310 { 380#ifdef CONFIG_ETRAX_ARCH_V32
311 puts("You need an ETRAX FS to run Linux 2.6/crisv32.\r\n"); 381 puts("You need an ETRAX FS to run Linux 2.6/crisv32\n");
382#else
383 puts("You need an ETRAX 100LX to run linux 2.6\n");
384#endif
312 while(1); 385 while(1);
313 } 386 }
314 387
315 puts("Uncompressing Linux...\r\n"); 388 puts("Uncompressing Linux...\n");
316 gunzip(); 389 gunzip();
317 puts("Done. Now booting the kernel.\r\n"); 390 puts("Done. Now booting the kernel\n");
318} 391}
diff --git a/arch/cris/arch-v10/boot/rescue/Makefile b/arch/cris/boot/rescue/Makefile
index 82ab59b968e5..52bd0bd1dd22 100644
--- a/arch/cris/arch-v10/boot/rescue/Makefile
+++ b/arch/cris/boot/rescue/Makefile
@@ -2,16 +2,26 @@
2# Makefile for rescue (bootstrap) code 2# Makefile for rescue (bootstrap) code
3# 3#
4 4
5ccflags-y += -O2 $(LINUXINCLUDE) 5# CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE)
6# ccflags-$(CONFIG_ETRAX_ARCH_V32) += -I$(srctree)/include/asm/arch/mach/ \
7# -I$(srctree)/include/asm/arch
8# asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch
9# LD = gcc-cris -mlinux -march=v32 -nostdlib
10
6asflags-y += $(LINUXINCLUDE) 11asflags-y += $(LINUXINCLUDE)
7ldflags-y += -T $(srctree)/$(src)/rescue.lds 12ccflags-y += -O2 $(LINUXINCLUDE)
13arch-$(CONFIG_ETRAX_ARCH_V10) = v10
14arch-$(CONFIG_ETRAX_ARCH_V32) = v32
15
16ldflags-y += -T $(srctree)/$(src)/rescue_$(arch-y).lds
8OBJCOPYFLAGS = -O binary --remove-section=.bss 17OBJCOPYFLAGS = -O binary --remove-section=.bss
9obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o 18obj-$(CONFIG_ETRAX_ARCH_V32) = $(obj)/head_v32.o
10OBJECT := $(obj)/head.o 19obj-$(CONFIG_ETRAX_ARCH_V10) = $(obj)/head_v10.o
20OBJECTS := $(obj-y)
11 21
12targets := rescue.o rescue.bin 22targets := rescue.o rescue.bin
13 23
14$(obj)/rescue.o: $(OBJECT) FORCE 24$(obj)/rescue.o: $(OBJECTS) FORCE
15 $(call if_changed,ld) 25 $(call if_changed,ld)
16 26
17$(obj)/rescue.bin: $(obj)/rescue.o FORCE 27$(obj)/rescue.bin: $(obj)/rescue.o FORCE
@@ -26,6 +36,7 @@ $(obj)/testrescue.bin: $(obj)/testrescue.o
26 dd if=testrescue_tmp.bin of=$(obj)/testrescue.bin bs=1 count=784 36 dd if=testrescue_tmp.bin of=$(obj)/testrescue.bin bs=1 count=784
27 rm tr.bin tmp2423 testrescue_tmp.bin 37 rm tr.bin tmp2423 testrescue_tmp.bin
28 38
39
29$(obj)/kimagerescue.bin: $(obj)/kimagerescue.o 40$(obj)/kimagerescue.bin: $(obj)/kimagerescue.o
30 $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/kimagerescue.o ktr.bin 41 $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/kimagerescue.o ktr.bin
31# Pad it to 784 bytes, that's what the rescue loader expects 42# Pad it to 784 bytes, that's what the rescue loader expects
@@ -33,3 +44,4 @@ $(obj)/kimagerescue.bin: $(obj)/kimagerescue.o
33 cat ktr.bin tmp2423 >kimagerescue_tmp.bin 44 cat ktr.bin tmp2423 >kimagerescue_tmp.bin
34 dd if=kimagerescue_tmp.bin of=$(obj)/kimagerescue.bin bs=1 count=784 45 dd if=kimagerescue_tmp.bin of=$(obj)/kimagerescue.bin bs=1 count=784
35 rm ktr.bin tmp2423 kimagerescue_tmp.bin 46 rm ktr.bin tmp2423 kimagerescue_tmp.bin
47
diff --git a/arch/cris/arch-v10/boot/rescue/head.S b/arch/cris/boot/rescue/head_v10.S
index fb503d1eeea4..2fafe247a25b 100644
--- a/arch/cris/arch-v10/boot/rescue/head.S
+++ b/arch/cris/boot/rescue/head_v10.S
@@ -155,7 +155,7 @@ no_newjump:
155#endif 155#endif
156 156
157 ;; We need to setup the bus registers before we start using the DRAM 157 ;; We need to setup the bus registers before we start using the DRAM
158#include "../../lib/dram_init.S" 158#include "../../../arch-v10/lib/dram_init.S"
159 159
160 ;; we now should go through the checksum-table and check the listed 160 ;; we now should go through the checksum-table and check the listed
161 ;; partitions for errors. 161 ;; partitions for errors.
diff --git a/arch/cris/arch-v32/boot/rescue/head.S b/arch/cris/boot/rescue/head_v32.S
index 5f846b7700a3..5f846b7700a3 100644
--- a/arch/cris/arch-v32/boot/rescue/head.S
+++ b/arch/cris/boot/rescue/head_v32.S
diff --git a/arch/cris/arch-v10/boot/rescue/kimagerescue.S b/arch/cris/boot/rescue/kimagerescue.S
index 6f7b3e61260b..6f7b3e61260b 100644
--- a/arch/cris/arch-v10/boot/rescue/kimagerescue.S
+++ b/arch/cris/boot/rescue/kimagerescue.S
diff --git a/arch/cris/arch-v10/boot/rescue/rescue.lds b/arch/cris/boot/rescue/rescue_v10.lds
index 0b52a9490db6..0b52a9490db6 100644
--- a/arch/cris/arch-v10/boot/rescue/rescue.lds
+++ b/arch/cris/boot/rescue/rescue_v10.lds
diff --git a/arch/cris/arch-v32/boot/rescue/rescue.lds b/arch/cris/boot/rescue/rescue_v32.lds
index 8ac646bc1a2b..8ac646bc1a2b 100644
--- a/arch/cris/arch-v32/boot/rescue/rescue.lds
+++ b/arch/cris/boot/rescue/rescue_v32.lds
diff --git a/arch/cris/arch-v10/boot/rescue/testrescue.S b/arch/cris/boot/rescue/testrescue.S
index fc7ec674eca5..fc7ec674eca5 100644
--- a/arch/cris/arch-v10/boot/rescue/testrescue.S
+++ b/arch/cris/boot/rescue/testrescue.S
diff --git a/arch/cris/arch-v10/boot/tools/build.c b/arch/cris/boot/tools/build.c
index c8adef364160..c8adef364160 100644
--- a/arch/cris/arch-v10/boot/tools/build.c
+++ b/arch/cris/boot/tools/build.c