aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v32/boot/compressed
diff options
context:
space:
mode:
Diffstat (limited to 'arch/cris/arch-v32/boot/compressed')
-rw-r--r--arch/cris/arch-v32/boot/compressed/Makefile45
-rw-r--r--arch/cris/arch-v32/boot/compressed/README1
-rw-r--r--arch/cris/arch-v32/boot/compressed/head.S137
-rw-r--r--arch/cris/arch-v32/boot/compressed/misc.c72
4 files changed, 109 insertions, 146 deletions
diff --git a/arch/cris/arch-v32/boot/compressed/Makefile b/arch/cris/arch-v32/boot/compressed/Makefile
index 609692f9d5eb..2c8c2c3039c5 100644
--- a/arch/cris/arch-v32/boot/compressed/Makefile
+++ b/arch/cris/arch-v32/boot/compressed/Makefile
@@ -1,41 +1,30 @@
1# 1#
2# lx25/arch/cris/arch-v32/boot/compressed/Makefile 2# arch/cris/arch-v32/boot/compressed/Makefile
3# 3#
4# create a compressed vmlinux image from the original vmlinux files and romfs
5#
6
7target = $(target_compressed_dir)
8src = $(src_compressed_dir)
9 4
10CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE) 5CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE)
11CFLAGS = -O2 6asflags-y += -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch
7ccflags-y += -O2 -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch
12LD = gcc-cris -mlinux -march=v32 -nostdlib 8LD = gcc-cris -mlinux -march=v32 -nostdlib
9ldflags-y += -T $(obj)/decompress.ld
10obj-y = head.o misc.o
11OBJECTS = $(obj)/head.o $(obj)/misc.o
13OBJCOPY = objcopy-cris 12OBJCOPY = objcopy-cris
14OBJCOPYFLAGS = -O binary --remove-section=.bss 13OBJCOPYFLAGS = -O binary --remove-section=.bss
15OBJECTS = $(target)/head.o $(target)/misc.o
16
17# files to compress
18SYSTEM = $(objtree)/vmlinux.bin
19
20all: vmlinuz
21
22$(target)/decompress.bin: $(OBJECTS)
23 $(LD) -T $(src)/decompress.ld -o $(target)/decompress.o $(OBJECTS)
24 $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/decompress.o $(target)/decompress.bin
25 14
26$(objtree)/vmlinuz: $(target) piggy.img $(target)/decompress.bin 15quiet_cmd_image = BUILD $@
27 cat $(target)/decompress.bin piggy.img > $(objtree)/vmlinuz 16cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@
28 rm -f piggy.img
29 cp $(objtree)/vmlinuz $(src)
30 17
31$(target)/head.o: $(src)/head.S 18targets := vmlinux piggy.gz decompress.o decompress.bin
32 $(CC) -D__ASSEMBLY__ -c $< -o $@
33 19
34# gzip the kernel image 20$(obj)/decompress.o: $(OBJECTS) FORCE
21 $(call if_changed,ld)
35 22
36piggy.img: $(SYSTEM) 23$(obj)/decompress.bin: $(obj)/decompress.o FORCE
37 cat $(SYSTEM) | gzip -f -9 > piggy.img 24 $(call if_changed,objcopy)
38 25
39clean: 26$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
40 rm -f piggy.img $(objtree)/vmlinuz vmlinuz.o decompress.o decompress.bin $(OBJECTS) 27 $(call if_changed,image)
41 28
29$(obj)/piggy.gz: $(obj)/../Image FORCE
30 $(call if_changed,gzip)
diff --git a/arch/cris/arch-v32/boot/compressed/README b/arch/cris/arch-v32/boot/compressed/README
index e33691d15c57..182c5d75784b 100644
--- a/arch/cris/arch-v32/boot/compressed/README
+++ b/arch/cris/arch-v32/boot/compressed/README
@@ -1,6 +1,5 @@
1Creation of the self-extracting compressed kernel image (vmlinuz) 1Creation of the self-extracting compressed kernel image (vmlinuz)
2----------------------------------------------------------------- 2-----------------------------------------------------------------
3$Id: README,v 1.1 2003/08/21 09:37:03 johana Exp $
4 3
5This can be slightly confusing because it's a process with many steps. 4This can be slightly confusing because it's a process with many steps.
6 5
diff --git a/arch/cris/arch-v32/boot/compressed/head.S b/arch/cris/arch-v32/boot/compressed/head.S
index 34cea10a8998..f86208caf32d 100644
--- a/arch/cris/arch-v32/boot/compressed/head.S
+++ b/arch/cris/arch-v32/boot/compressed/head.S
@@ -2,13 +2,12 @@
2 * Code that sets up the DRAM registers, calls the 2 * Code that sets up the DRAM registers, calls the
3 * decompressor to unpack the piggybacked kernel, and jumps. 3 * decompressor to unpack the piggybacked kernel, and jumps.
4 * 4 *
5 * Copyright (C) 1999 - 2003, Axis Communications AB 5 * Copyright (C) 1999 - 2006, Axis Communications AB
6 */ 6 */
7 7
8#define ASSEMBLER_MACROS_ONLY 8#define ASSEMBLER_MACROS_ONLY
9#include <asm/arch/hwregs/asm/reg_map_asm.h> 9#include <hwregs/asm/reg_map_asm.h>
10#include <asm/arch/hwregs/asm/gio_defs_asm.h> 10#include <asm/arch/mach/startup.inc>
11#include <asm/arch/hwregs/asm/config_defs_asm.h>
12 11
13#define RAM_INIT_MAGIC 0x56902387 12#define RAM_INIT_MAGIC 0x56902387
14#define COMMAND_LINE_MAGIC 0x87109563 13#define COMMAND_LINE_MAGIC 0x87109563
@@ -22,114 +21,49 @@ start:
22 di 21 di
23 22
24 ;; Start clocks for used blocks. 23 ;; Start clocks for used blocks.
25 move.d REG_ADDR(config, regi_config, rw_clk_ctrl), $r1 24 START_CLOCKS
26 move.d [$r1], $r0 25
27 or.d REG_STATE(config, rw_clk_ctrl, cpu, yes) | \ 26 ;; Initialize the DRAM registers.
28 REG_STATE(config, rw_clk_ctrl, bif, yes) | \
29 REG_STATE(config, rw_clk_ctrl, fix_io, yes), $r0
30 move.d $r0, [$r1]
31
32 ;; If booting from NAND flash we first have to copy some
33 ;; data from NAND flash to internal RAM to get the code
34 ;; that initializes the SDRAM. Lets copy 20 KB. This
35 ;; code executes at 0x38010000 if booting from NAND and
36 ;; we are guaranted that at least 0x200 bytes are good so
37 ;; lets start from there. The first 8192 bytes in the nand
38 ;; flash is spliced with zeroes and is thus 16384 bytes.
39 move.d 0x38010200, $r10
40 move.d 0x14200, $r11 ; Start offset in NAND flash 0x10200 + 16384
41 move.d 0x5000, $r12 ; Length of copy
42
43 ;; Before this code the tools add a partitiontable so the PC
44 ;; has an offset from the linked address.
45offset1:
46 lapcq ., $r13 ; get PC
47 add.d first_copy_complete-offset1, $r13
48
49#include "../../lib/nand_init.S"
50
51first_copy_complete:
52 ;; Initialze the DRAM registers.
53 cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? 27 cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
54 beq dram_init_finished 28 beq dram_init_finished
55 nop 29 nop
56 30
57#include "../../lib/dram_init.S" 31#include "../../mach/dram_init.S"
58 32
59dram_init_finished: 33dram_init_finished:
60 lapcq ., $r13 ; get PC
61 add.d second_copy_complete-dram_init_finished, $r13
62
63 move.d REG_ADDR(config, regi_config, r_bootsel), $r0
64 move.d [$r0], $r0
65 and.d REG_MASK(config, r_bootsel, boot_mode), $r0
66 cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0
67 bne second_copy_complete ; No NAND boot
68 nop
69
70 ;; Copy 2MB from NAND flash to SDRAM (at 2-4MB into the SDRAM)
71 move.d 0x40204000, $r10
72 move.d 0x8000, $r11
73 move.d 0x200000, $r12
74 ba copy_nand_to_ram
75 nop
76second_copy_complete:
77
78 ;; Initiate the PA port.
79 move.d CONFIG_ETRAX_DEF_GIO_PA_OUT, $r0
80 move.d REG_ADDR(gio, regi_gio, rw_pa_dout), $r1
81 move.d $r0, [$r1]
82
83 move.d CONFIG_ETRAX_DEF_GIO_PA_OE, $r0
84 move.d REG_ADDR(gio, regi_gio, rw_pa_oe), $r1
85 move.d $r0, [$r1]
86 34
35 GIO_INIT
87 ;; Setup the stack to a suitably high address. 36 ;; Setup the stack to a suitably high address.
88 ;; We assume 8 MB is the minimum DRAM and put 37 ;; We assume 8 MB is the minimum DRAM and put
89 ;; the SP at the top for now. 38 ;; the SP at the top for now.
90 39
91 move.d 0x40800000, $sp 40 move.d 0x40800000, $sp
92 41
93 ;; Figure out where the compressed piggyback image is 42 ;; Figure out where the compressed piggyback image is.
94 ;; in the flash (since we wont try to copy it to DRAM 43 ;; It is either in [NOR] flash (we don't want to copy it
95 ;; before unpacking). It is at _edata, but in flash. 44 ;; to DRAM before unpacking), or copied to DRAM
45 ;; by the [NAND] flash boot loader.
46 ;; The piggyback image is at _edata, but relative to where the
47 ;; image is actually located in memory, not where it is linked
48 ;; (the decompressor is linked at 0x40700000+ and runs there).
96 ;; Use (_edata - herami) as offset to the current PC. 49 ;; Use (_edata - herami) as offset to the current PC.
97 50
98 move.d REG_ADDR(config, regi_config, r_bootsel), $r0
99 move.d [$r0], $r0
100 and.d REG_MASK(config, r_bootsel, boot_mode), $r0
101 cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0
102 beq hereami2
103 nop
104hereami: 51hereami:
105 lapcq ., $r5 ; get PC 52 lapcq ., $r5 ; get PC
106 and.d 0x7fffffff, $r5 ; strip any non-cache bit 53 and.d 0x7fffffff, $r5 ; strip any non-cache bit
107 move.d $r5, $r0 ; save for later - flash address of 'herami' 54 move.d $r5, $r0 ; source address of 'herami'
108 add.d _edata, $r5 55 add.d _edata, $r5
109 sub.d hereami, $r5 ; r5 = flash address of '_edata' 56 sub.d hereami, $r5 ; r5 = flash address of '_edata'
110 move.d hereami, $r1 ; destination 57 move.d hereami, $r1 ; destination
111 ba 2f 58
112 nop
113hereami2:
114 lapcq ., $r5 ; get PC
115 and.d 0x00ffffff, $r5 ; strip any non-cache bit
116 move.d $r5, $r6
117 or.d 0x40200000, $r6
118 move.d $r6, $r0 ; save for later - flash address of 'herami'
119 add.d _edata, $r5
120 sub.d hereami2, $r5 ; r5 = flash address of '_edata'
121 add.d 0x40200000, $r5
122 move.d hereami2, $r1 ; destination
1232:
124 ;; Copy text+data to DRAM 59 ;; Copy text+data to DRAM
125 60
126 move.d _edata, $r2 ; end destination 61 move.d _edata, $r2 ; end destination
1271: move.w [$r0+], $r3 621: move.w [$r0+], $r3 ; from herami+ source
128 move.w $r3, [$r1+] 63 move.w $r3, [$r1+] ; to hereami+ destination (linked address)
129 cmp.d $r2, $r1 64 cmp.d $r2, $r1 ; finish when destination == _edata
130 bcs 1b 65 bcs 1b
131 nop 66 nop
132
133 move.d input_data, $r0 ; for the decompressor 67 move.d input_data, $r0 ; for the decompressor
134 move.d $r5, [$r0] ; for the decompressor 68 move.d $r5, [$r0] ; for the decompressor
135 69
@@ -144,16 +78,24 @@ hereami2:
144 nop 78 nop
145 79
146 ;; Save command line magic and address. 80 ;; Save command line magic and address.
147 move.d _cmd_line_magic, $r12 81 move.d _cmd_line_magic, $r0
148 move.d $r10, [$r12] 82 move.d $r10, [$r0]
149 move.d _cmd_line_addr, $r12 83 move.d _cmd_line_addr, $r0
150 move.d $r11, [$r12] 84 move.d $r11, [$r0]
85
86 ;; Save boot source indicator
87 move.d _boot_source, $r0
88 move.d $r12, [$r0]
151 89
152 ;; Do the decompression and save compressed size in _inptr 90 ;; Do the decompression and save compressed size in _inptr
153 91
154 jsr decompress_kernel 92 jsr decompress_kernel
155 nop 93 nop
156 94
95 ;; Restore boot source indicator
96 move.d _boot_source, $r12
97 move.d [$r12], $r12
98
157 ;; Restore command line magic and address. 99 ;; Restore command line magic and address.
158 move.d _cmd_line_magic, $r10 100 move.d _cmd_line_magic, $r10
159 move.d [$r10], $r10 101 move.d [$r10], $r10
@@ -166,11 +108,10 @@ hereami2:
166 move.d [$r0], $r9 ; flash address of compressed kernel 108 move.d [$r0], $r9 ; flash address of compressed kernel
167 move.d inptr, $r0 109 move.d inptr, $r0
168 add.d [$r0], $r9 ; size of compressed kernel 110 add.d [$r0], $r9 ; size of compressed kernel
169 cmp.d 0x40200000, $r9 111 cmp.d 0x40000000, $r9 ; image in DRAM ?
170 blo enter_kernel 112 blo enter_kernel ; no, must be [NOR] flash, jump
171 nop 113 nop ; delay slot
172 sub.d 0x40200000, $r9 114 and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M
173 add.d 0x4000, $r9
174 115
175enter_kernel: 116enter_kernel:
176 ;; Enter the decompressed kernel 117 ;; Enter the decompressed kernel
@@ -186,7 +127,7 @@ _cmd_line_magic:
186 .dword 0 127 .dword 0
187_cmd_line_addr: 128_cmd_line_addr:
188 .dword 0 129 .dword 0
189is_nand_boot: 130_boot_source:
190 .dword 0 131 .dword 0
191 132
192#include "../../lib/hw_settings.S" 133#include "../../mach/hw_settings.S"
diff --git a/arch/cris/arch-v32/boot/compressed/misc.c b/arch/cris/arch-v32/boot/compressed/misc.c
index 0169ba1ca9c9..55b2695c5d70 100644
--- a/arch/cris/arch-v32/boot/compressed/misc.c
+++ b/arch/cris/arch-v32/boot/compressed/misc.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * misc.c 2 * misc.c
3 * 3 *
4 * $Id: misc.c,v 1.8 2005/04/24 18:34:29 starvik Exp $
5 *
6 * This is a collection of several routines from gzip-1.0.3 4 * This is a collection of several routines from gzip-1.0.3
7 * adapted for Linux. 5 * adapted for Linux.
8 * 6 *
@@ -22,9 +20,13 @@
22 20
23 21
24#include <linux/types.h> 22#include <linux/types.h>
25#include <asm/arch/hwregs/reg_rdwr.h> 23#include <hwregs/reg_rdwr.h>
26#include <asm/arch/hwregs/reg_map.h> 24#include <hwregs/reg_map.h>
27#include <asm/arch/hwregs/ser_defs.h> 25#include <hwregs/ser_defs.h>
26#include <hwregs/pinmux_defs.h>
27#ifdef CONFIG_CRIS_MACH_ARTPEC3
28#include <hwregs/clkgen_defs.h>
29#endif
28 30
29/* 31/*
30 * gzip declarations 32 * gzip declarations
@@ -85,7 +87,6 @@ static unsigned outcnt = 0; /* bytes in output buffer */
85# define Tracecv(c,x) 87# define Tracecv(c,x)
86#endif 88#endif
87 89
88static int fill_inbuf(void);
89static void flush_window(void); 90static void flush_window(void);
90static void error(char *m); 91static void error(char *m);
91static void gzip_mark(void **); 92static void gzip_mark(void **);
@@ -186,6 +187,8 @@ memset(void* s, int c, size_t n)
186 char *ss = (char*)s; 187 char *ss = (char*)s;
187 188
188 for (i=0;i<n;i++) ss[i] = c; 189 for (i=0;i<n;i++) ss[i] = c;
190
191 return s;
189} 192}
190 193
191void* 194void*
@@ -196,6 +199,8 @@ memcpy(void* __dest, __const void* __src,
196 char *d = (char *)__dest, *s = (char *)__src; 199 char *d = (char *)__dest, *s = (char *)__src;
197 200
198 for (i=0;i<__n;i++) d[i] = s[i]; 201 for (i=0;i<__n;i++) d[i] = s[i];
202
203 return __dest;
199} 204}
200 205
201/* =========================================================================== 206/* ===========================================================================
@@ -225,15 +230,15 @@ flush_window()
225static void 230static void
226error(char *x) 231error(char *x)
227{ 232{
228 puts("\n\n"); 233 puts("\r\n\n");
229 puts(x); 234 puts(x);
230 puts("\n\n -- System halted\n"); 235 puts("\r\n\n -- System halted\n");
231 236
232 while(1); /* Halt */ 237 while(1); /* Halt */
233} 238}
234 239
235void 240void
236setup_normal_output_buffer() 241setup_normal_output_buffer(void)
237{ 242{
238 output_data = (char *)KERNEL_LOAD_ADR; 243 output_data = (char *)KERNEL_LOAD_ADR;
239} 244}
@@ -262,15 +267,17 @@ serial_setup(reg_scope_instances regi_ser)
262 rec_baud = REG_RD(ser, regi_ser, rw_rec_baud_div); 267 rec_baud = REG_RD(ser, regi_ser, rw_rec_baud_div);
263 268
264 tr_ctrl.stop_bits = 1; /* 2 stop bits. */ 269 tr_ctrl.stop_bits = 1; /* 2 stop bits. */
270 tr_ctrl.en = 1; /* enable transmitter */
271 rec_ctrl.en = 1; /* enabler receiver */
265 272
266 /* 273 /*
267 * The baudrate setup is a bit fishy, but in the end the transceiver is 274 * The baudrate setup used to be a bit fishy, but now transmitter and
268 * set to 4800 and the receiver to 115200. The magic value is 275 * receiver are both set to the intended baud rate, 115200.
269 * 29.493 MHz. 276 * The magic value is 29.493 MHz.
270 */ 277 */
271 tr_ctrl.base_freq = regk_ser_f29_493; 278 tr_ctrl.base_freq = regk_ser_f29_493;
272 rec_ctrl.base_freq = regk_ser_f29_493; 279 rec_ctrl.base_freq = regk_ser_f29_493;
273 tr_baud.div = (29493000 / 8) / 4800; 280 tr_baud.div = (29493000 / 8) / 115200;
274 rec_baud.div = (29493000 / 8) / 115200; 281 rec_baud.div = (29493000 / 8) / 115200;
275 282
276 REG_WR(ser, regi_ser, rw_tr_ctrl, tr_ctrl); 283 REG_WR(ser, regi_ser, rw_tr_ctrl, tr_ctrl);
@@ -280,25 +287,52 @@ serial_setup(reg_scope_instances regi_ser)
280} 287}
281 288
282void 289void
283decompress_kernel() 290decompress_kernel(void)
284{ 291{
285 char revision; 292 char revision;
286 293
287 /* input_data is set in head.S */ 294#if defined(CONFIG_ETRAX_DEBUG_PORT1) || \
288 inbuf = input_data; 295 defined(CONFIG_ETRAX_DEBUG_PORT2) || \
296 defined(CONFIG_ETRAX_DEBUG_PORT3)
297 reg_pinmux_rw_hwprot hwprot;
298
299#ifdef CONFIG_CRIS_MACH_ARTPEC3
300 reg_clkgen_rw_clk_ctrl clk_ctrl;
301
302 /* Enable corresponding clock region when serial 1..3 selected */
303
304 clk_ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl);
305 clk_ctrl.sser_ser_dma6_7 = regk_clkgen_yes;
306 REG_WR(clkgen, regi_clkgen, rw_clk_ctrl, clk_ctrl);
307#endif
308
309 /* pinmux setup for ports 1..3 */
310 hwprot = REG_RD(pinmux, regi_pinmux, rw_hwprot);
311#endif
289 312
290#ifdef CONFIG_ETRAX_DEBUG_PORT0 313#ifdef CONFIG_ETRAX_DEBUG_PORT0
291 serial_setup(regi_ser0); 314 serial_setup(regi_ser0);
292#endif 315#endif
293#ifdef CONFIG_ETRAX_DEBUG_PORT1 316#ifdef CONFIG_ETRAX_DEBUG_PORT1
317 hwprot.ser1 = regk_pinmux_yes;
294 serial_setup(regi_ser1); 318 serial_setup(regi_ser1);
295#endif 319#endif
296#ifdef CONFIG_ETRAX_DEBUG_PORT2 320#ifdef CONFIG_ETRAX_DEBUG_PORT2
321 hwprot.ser2 = regk_pinmux_yes;
297 serial_setup(regi_ser2); 322 serial_setup(regi_ser2);
298#endif 323#endif
299#ifdef CONFIG_ETRAX_DEBUG_PORT3 324#ifdef CONFIG_ETRAX_DEBUG_PORT3
325 hwprot.ser3 = regk_pinmux_yes;
300 serial_setup(regi_ser3); 326 serial_setup(regi_ser3);
301#endif 327#endif
328#if defined(CONFIG_ETRAX_DEBUG_PORT1) || \
329 defined(CONFIG_ETRAX_DEBUG_PORT2) || \
330 defined(CONFIG_ETRAX_DEBUG_PORT3)
331 REG_WR(pinmux, regi_pinmux, rw_hwprot, hwprot);
332#endif
333
334 /* input_data is set in head.S */
335 inbuf = input_data;
302 336
303 setup_normal_output_buffer(); 337 setup_normal_output_buffer();
304 338
@@ -307,11 +341,11 @@ decompress_kernel()
307 __asm__ volatile ("move $vr,%0" : "=rm" (revision)); 341 __asm__ volatile ("move $vr,%0" : "=rm" (revision));
308 if (revision < 32) 342 if (revision < 32)
309 { 343 {
310 puts("You need an ETRAX FS to run Linux 2.6/crisv32.\n"); 344 puts("You need an ETRAX FS to run Linux 2.6/crisv32.\r\n");
311 while(1); 345 while(1);
312 } 346 }
313 347
314 puts("Uncompressing Linux...\n"); 348 puts("Uncompressing Linux...\r\n");
315 gunzip(); 349 gunzip();
316 puts("Done. Now booting the kernel.\n"); 350 puts("Done. Now booting the kernel.\r\n");
317} 351}