summaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v32/boot/compressed
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 10:01:28 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 10:01:28 -0800
commit0cf975e16927fd70f34cee20d3856246c13bb4c8 (patch)
treebb955d50f28e5d98c198701798c8341d9763299a /arch/cris/arch-v32/boot/compressed
parent03054de1e0b90b33e9974107d84dabd2509f5898 (diff)
parentbc10ac3f2fe44e65f787d6197fd5d17304bf7d83 (diff)
Merge branch 'cris' of git://www.jni.nu/cris
* 'cris' of git://www.jni.nu/cris: (158 commits) CRIS v32: Remove hwregs/timer_defs.h, it is now architecture specific. CRIS v32: Change drivers/i2c.c locking. CRIS v32: Rewrite ARTPEC-3 gpio driver to avoid volatiles and general cleanup. CRIS: Add new timerfd syscall entries. MAINTAINERS: Add my information for the CRIS port. CRIS v32: Correct spelling of bandwidth in function name. CRIS v32: Clean up nandflash.c for ARTPEC-3 and ETRAX FS. CRIS v10: Cleanup of drivers/gpio.c CRIS v10: drivers/net/cris/eth_v10.c rename LED defines to CRIS_LED to avoid name clash. CRIS: Make io_pwm_set_period members unsigned in etraxgpio.h CRIS: Move ETRAX_AXISFLASHMAP to common Kconfig file. CRIS: Drop regs parameter from call to profile_tick in kernel/time.c CRIS v32: Fix minor formatting issue in mach-a3/io.c CRIS v32: Initialize GIO even if we're rambooting in kernel/head.S CRIS v32: Remove kernel/arbiter.c, it now exists in machine dependent directory. CRIS v32: Minor changes to avoid errors in asm-cris/arch-v32/hwregs/reg_rdwr.h CRIS v32: arch-v32/hwregs/intr_vect_defs.h moved to machine dependent directory. CRIS v32: Correct offset for TASK_pid in asm-cris/arch-v32/offset.h CRIS v32: Move register map header to machine dependent directory. CRIS v32: Let compiler know that memory is clobbered after a break op. ...
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 609692f9d5e..2c8c2c3039c 100644
--- a/arch/cris/arch-v32/boot/compressed/Makefile
+++ b/arch/cris/arch-v32/boot/compressed/Makefile
@@ -1,41 +1,30 @@
#
-# lx25/arch/cris/arch-v32/boot/compressed/Makefile
+# arch/cris/arch-v32/boot/compressed/Makefile
#
-# create a compressed vmlinux image from the original vmlinux files and romfs
-#
-
-target = $(target_compressed_dir)
-src = $(src_compressed_dir)
CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE)
-CFLAGS = -O2
+asflags-y += -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch
+ccflags-y += -O2 -I $(srctree)/include/asm/mach/ -I $(srctree)/include/asm/arch
LD = gcc-cris -mlinux -march=v32 -nostdlib
+ldflags-y += -T $(obj)/decompress.ld
+obj-y = head.o misc.o
+OBJECTS = $(obj)/head.o $(obj)/misc.o
OBJCOPY = objcopy-cris
OBJCOPYFLAGS = -O binary --remove-section=.bss
-OBJECTS = $(target)/head.o $(target)/misc.o
-
-# files to compress
-SYSTEM = $(objtree)/vmlinux.bin
-
-all: vmlinuz
-
-$(target)/decompress.bin: $(OBJECTS)
- $(LD) -T $(src)/decompress.ld -o $(target)/decompress.o $(OBJECTS)
- $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/decompress.o $(target)/decompress.bin
-$(objtree)/vmlinuz: $(target) piggy.img $(target)/decompress.bin
- cat $(target)/decompress.bin piggy.img > $(objtree)/vmlinuz
- rm -f piggy.img
- cp $(objtree)/vmlinuz $(src)
+quiet_cmd_image = BUILD $@
+cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@
-$(target)/head.o: $(src)/head.S
- $(CC) -D__ASSEMBLY__ -c $< -o $@
+targets := vmlinux piggy.gz decompress.o decompress.bin
-# gzip the kernel image
+$(obj)/decompress.o: $(OBJECTS) FORCE
+ $(call if_changed,ld)
-piggy.img: $(SYSTEM)
- cat $(SYSTEM) | gzip -f -9 > piggy.img
+$(obj)/decompress.bin: $(obj)/decompress.o FORCE
+ $(call if_changed,objcopy)
-clean:
- rm -f piggy.img $(objtree)/vmlinuz vmlinuz.o decompress.o decompress.bin $(OBJECTS)
+$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
+ $(call if_changed,image)
+$(obj)/piggy.gz: $(obj)/../Image FORCE
+ $(call if_changed,gzip)
diff --git a/arch/cris/arch-v32/boot/compressed/README b/arch/cris/arch-v32/boot/compressed/README
index e33691d15c5..182c5d75784 100644
--- a/arch/cris/arch-v32/boot/compressed/README
+++ b/arch/cris/arch-v32/boot/compressed/README
@@ -1,6 +1,5 @@
Creation of the self-extracting compressed kernel image (vmlinuz)
-----------------------------------------------------------------
-$Id: README,v 1.1 2003/08/21 09:37:03 johana Exp $
This can be slightly confusing because it's a process with many steps.
diff --git a/arch/cris/arch-v32/boot/compressed/head.S b/arch/cris/arch-v32/boot/compressed/head.S
index 34cea10a899..f86208caf32 100644
--- a/arch/cris/arch-v32/boot/compressed/head.S
+++ b/arch/cris/arch-v32/boot/compressed/head.S
@@ -2,13 +2,12 @@
* Code that sets up the DRAM registers, calls the
* decompressor to unpack the piggybacked kernel, and jumps.
*
- * Copyright (C) 1999 - 2003, Axis Communications AB
+ * Copyright (C) 1999 - 2006, Axis Communications AB
*/
#define ASSEMBLER_MACROS_ONLY
-#include <asm/arch/hwregs/asm/reg_map_asm.h>
-#include <asm/arch/hwregs/asm/gio_defs_asm.h>
-#include <asm/arch/hwregs/asm/config_defs_asm.h>
+#include <hwregs/asm/reg_map_asm.h>
+#include <asm/arch/mach/startup.inc>
#define RAM_INIT_MAGIC 0x56902387
#define COMMAND_LINE_MAGIC 0x87109563
@@ -22,114 +21,49 @@ start:
di
;; Start clocks for used blocks.
- move.d REG_ADDR(config, regi_config, rw_clk_ctrl), $r1
- move.d [$r1], $r0
- or.d REG_STATE(config, rw_clk_ctrl, cpu, yes) | \
- REG_STATE(config, rw_clk_ctrl, bif, yes) | \
- REG_STATE(config, rw_clk_ctrl, fix_io, yes), $r0
- move.d $r0, [$r1]
-
- ;; If booting from NAND flash we first have to copy some
- ;; data from NAND flash to internal RAM to get the code
- ;; that initializes the SDRAM. Lets copy 20 KB. This
- ;; code executes at 0x38010000 if booting from NAND and
- ;; we are guaranted that at least 0x200 bytes are good so
- ;; lets start from there. The first 8192 bytes in the nand
- ;; flash is spliced with zeroes and is thus 16384 bytes.
- move.d 0x38010200, $r10
- move.d 0x14200, $r11 ; Start offset in NAND flash 0x10200 + 16384
- move.d 0x5000, $r12 ; Length of copy
-
- ;; Before this code the tools add a partitiontable so the PC
- ;; has an offset from the linked address.
-offset1:
- lapcq ., $r13 ; get PC
- add.d first_copy_complete-offset1, $r13
-
-#include "../../lib/nand_init.S"
-
-first_copy_complete:
- ;; Initialze the DRAM registers.
+ START_CLOCKS
+
+ ;; Initialize the DRAM registers.
cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
beq dram_init_finished
nop
-#include "../../lib/dram_init.S"
+#include "../../mach/dram_init.S"
dram_init_finished:
- lapcq ., $r13 ; get PC
- add.d second_copy_complete-dram_init_finished, $r13
-
- move.d REG_ADDR(config, regi_config, r_bootsel), $r0
- move.d [$r0], $r0
- and.d REG_MASK(config, r_bootsel, boot_mode), $r0
- cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0
- bne second_copy_complete ; No NAND boot
- nop
-
- ;; Copy 2MB from NAND flash to SDRAM (at 2-4MB into the SDRAM)
- move.d 0x40204000, $r10
- move.d 0x8000, $r11
- move.d 0x200000, $r12
- ba copy_nand_to_ram
- nop
-second_copy_complete:
-
- ;; Initiate the PA port.
- move.d CONFIG_ETRAX_DEF_GIO_PA_OUT, $r0
- move.d REG_ADDR(gio, regi_gio, rw_pa_dout), $r1
- move.d $r0, [$r1]
-
- move.d CONFIG_ETRAX_DEF_GIO_PA_OE, $r0
- move.d REG_ADDR(gio, regi_gio, rw_pa_oe), $r1
- move.d $r0, [$r1]
+ GIO_INIT
;; Setup the stack to a suitably high address.
;; We assume 8 MB is the minimum DRAM and put
;; the SP at the top for now.
move.d 0x40800000, $sp
- ;; Figure out where the compressed piggyback image is
- ;; in the flash (since we wont try to copy it to DRAM
- ;; before unpacking). It is at _edata, but in flash.
+ ;; Figure out where the compressed piggyback image is.
+ ;; It is either in [NOR] flash (we don't want to copy it
+ ;; to DRAM before unpacking), or copied to DRAM
+ ;; by the [NAND] flash boot loader.
+ ;; The piggyback image is at _edata, but relative to where the
+ ;; image is actually located in memory, not where it is linked
+ ;; (the decompressor is linked at 0x40700000+ and runs there).
;; Use (_edata - herami) as offset to the current PC.
- move.d REG_ADDR(config, regi_config, r_bootsel), $r0
- move.d [$r0], $r0
- and.d REG_MASK(config, r_bootsel, boot_mode), $r0
- cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0
- beq hereami2
- nop
hereami:
lapcq ., $r5 ; get PC
and.d 0x7fffffff, $r5 ; strip any non-cache bit
- move.d $r5, $r0 ; save for later - flash address of 'herami'
+ move.d $r5, $r0 ; source address of 'herami'
add.d _edata, $r5
sub.d hereami, $r5 ; r5 = flash address of '_edata'
move.d hereami, $r1 ; destination
- ba 2f
- nop
-hereami2:
- lapcq ., $r5 ; get PC
- and.d 0x00ffffff, $r5 ; strip any non-cache bit
- move.d $r5, $r6
- or.d 0x40200000, $r6
- move.d $r6, $r0 ; save for later - flash address of 'herami'
- add.d _edata, $r5
- sub.d hereami2, $r5 ; r5 = flash address of '_edata'
- add.d 0x40200000, $r5
- move.d hereami2, $r1 ; destination
-2:
+
;; Copy text+data to DRAM
move.d _edata, $r2 ; end destination
-1: move.w [$r0+], $r3
- move.w $r3, [$r1+]
- cmp.d $r2, $r1
+1: move.w [$r0+], $r3 ; from herami+ source
+ move.w $r3, [$r1+] ; to hereami+ destination (linked address)
+ cmp.d $r2, $r1 ; finish when destination == _edata
bcs 1b
nop
-
move.d input_data, $r0 ; for the decompressor
move.d $r5, [$r0] ; for the decompressor
@@ -144,16 +78,24 @@ hereami2:
nop
;; Save command line magic and address.
- move.d _cmd_line_magic, $r12
- move.d $r10, [$r12]
- move.d _cmd_line_addr, $r12
- move.d $r11, [$r12]
+ move.d _cmd_line_magic, $r0
+ move.d $r10, [$r0]
+ move.d _cmd_line_addr, $r0
+ move.d $r11, [$r0]
+
+ ;; Save boot source indicator
+ move.d _boot_source, $r0
+ move.d $r12, [$r0]
;; Do the decompression and save compressed size in _inptr
jsr decompress_kernel
nop
+ ;; Restore boot source indicator
+ move.d _boot_source, $r12
+ move.d [$r12], $r12
+
;; Restore command line magic and address.
move.d _cmd_line_magic, $r10
move.d [$r10], $r10
@@ -166,11 +108,10 @@ hereami2:
move.d [$r0], $r9 ; flash address of compressed kernel
move.d inptr, $r0
add.d [$r0], $r9 ; size of compressed kernel
- cmp.d 0x40200000, $r9
- blo enter_kernel
- nop
- sub.d 0x40200000, $r9
- add.d 0x4000, $r9
+ cmp.d 0x40000000, $r9 ; image in DRAM ?
+ blo enter_kernel ; no, must be [NOR] flash, jump
+ nop ; delay slot
+ and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M
enter_kernel:
;; Enter the decompressed kernel
@@ -186,7 +127,7 @@ _cmd_line_magic:
.dword 0
_cmd_line_addr:
.dword 0
-is_nand_boot:
- .dword 0
+_boot_source:
+ .dword 0
-#include "../../lib/hw_settings.S"
+#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 0169ba1ca9c..55b2695c5d7 100644
--- a/arch/cris/arch-v32/boot/compressed/misc.c
+++ b/arch/cris/arch-v32/boot/compressed/misc.c
@@ -1,8 +1,6 @@
/*
* misc.c
*
- * $Id: misc.c,v 1.8 2005/04/24 18:34:29 starvik Exp $
- *
* This is a collection of several routines from gzip-1.0.3
* adapted for Linux.
*
@@ -22,9 +20,13 @@
#include <linux/types.h>
-#include <asm/arch/hwregs/reg_rdwr.h>
-#include <asm/arch/hwregs/reg_map.h>
-#include <asm/arch/hwregs/ser_defs.h>
+#include <hwregs/reg_rdwr.h>
+#include <hwregs/reg_map.h>
+#include <hwregs/ser_defs.h>
+#include <hwregs/pinmux_defs.h>
+#ifdef CONFIG_CRIS_MACH_ARTPEC3
+#include <hwregs/clkgen_defs.h>
+#endif
/*
* gzip declarations
@@ -85,7 +87,6 @@ static unsigned outcnt = 0; /* bytes in output buffer */
# define Tracecv(c,x)
#endif
-static int fill_inbuf(void);
static void flush_window(void);
static void error(char *m);
static void gzip_mark(void **);
@@ -186,6 +187,8 @@ memset(void* s, int c, size_t n)
char *ss = (char*)s;
for (i=0;i<n;i++) ss[i] = c;
+
+ return s;
}
void*
@@ -196,6 +199,8 @@ memcpy(void* __dest, __const void* __src,
char *d = (char *)__dest, *s = (char *)__src;
for (i=0;i<__n;i++) d[i] = s[i];
+
+ return __dest;
}
/* ===========================================================================
@@ -225,15 +230,15 @@ flush_window()
static void
error(char *x)
{
- puts("\n\n");
+ puts("\r\n\n");
puts(x);
- puts("\n\n -- System halted\n");
+ puts("\r\n\n -- System halted\n");
while(1); /* Halt */
}
void
-setup_normal_output_buffer()
+setup_normal_output_buffer(void)
{
output_data = (char *)KERNEL_LOAD_ADR;
}
@@ -262,15 +267,17 @@ serial_setup(reg_scope_instances regi_ser)
rec_baud = REG_RD(ser, regi_ser, rw_rec_baud_div);
tr_ctrl.stop_bits = 1; /* 2 stop bits. */
+ tr_ctrl.en = 1; /* enable transmitter */
+ rec_ctrl.en = 1; /* enabler receiver */
/*
- * The baudrate setup is a bit fishy, but in the end the transceiver is
- * set to 4800 and the receiver to 115200. The magic value is
- * 29.493 MHz.
+ * The baudrate setup used to be a bit fishy, but now transmitter and
+ * receiver are both set to the intended baud rate, 115200.
+ * The magic value is 29.493 MHz.
*/
tr_ctrl.base_freq = regk_ser_f29_493;
rec_ctrl.base_freq = regk_ser_f29_493;
- tr_baud.div = (29493000 / 8) / 4800;
+ tr_baud.div = (29493000 / 8) / 115200;
rec_baud.div = (29493000 / 8) / 115200;
REG_WR(ser, regi_ser, rw_tr_ctrl, tr_ctrl);
@@ -280,25 +287,52 @@ serial_setup(reg_scope_instances regi_ser)
}
void
-decompress_kernel()
+decompress_kernel(void)
{
char revision;
- /* input_data is set in head.S */
- inbuf = input_data;
+#if defined(CONFIG_ETRAX_DEBUG_PORT1) || \
+ defined(CONFIG_ETRAX_DEBUG_PORT2) || \
+ defined(CONFIG_ETRAX_DEBUG_PORT3)
+ reg_pinmux_rw_hwprot hwprot;
+
+#ifdef CONFIG_CRIS_MACH_ARTPEC3
+ reg_clkgen_rw_clk_ctrl clk_ctrl;
+
+ /* Enable corresponding clock region when serial 1..3 selected */
+
+ clk_ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl);
+ clk_ctrl.sser_ser_dma6_7 = regk_clkgen_yes;
+ REG_WR(clkgen, regi_clkgen, rw_clk_ctrl, clk_ctrl);
+#endif
+
+ /* pinmux setup for ports 1..3 */
+ hwprot = REG_RD(pinmux, regi_pinmux, rw_hwprot);
+#endif
#ifdef CONFIG_ETRAX_DEBUG_PORT0
serial_setup(regi_ser0);
#endif
#ifdef CONFIG_ETRAX_DEBUG_PORT1
+ hwprot.ser1 = regk_pinmux_yes;
serial_setup(regi_ser1);
#endif
#ifdef CONFIG_ETRAX_DEBUG_PORT2
+ hwprot.ser2 = regk_pinmux_yes;
serial_setup(regi_ser2);
#endif
#ifdef CONFIG_ETRAX_DEBUG_PORT3
+ hwprot.ser3 = regk_pinmux_yes;
serial_setup(regi_ser3);
#endif
+#if defined(CONFIG_ETRAX_DEBUG_PORT1) || \
+ defined(CONFIG_ETRAX_DEBUG_PORT2) || \
+ defined(CONFIG_ETRAX_DEBUG_PORT3)
+ REG_WR(pinmux, regi_pinmux, rw_hwprot, hwprot);
+#endif
+
+ /* input_data is set in head.S */
+ inbuf = input_data;
setup_normal_output_buffer();
@@ -307,11 +341,11 @@ decompress_kernel()
__asm__ volatile ("move $vr,%0" : "=rm" (revision));
if (revision < 32)
{
- puts("You need an ETRAX FS to run Linux 2.6/crisv32.\n");
+ puts("You need an ETRAX FS to run Linux 2.6/crisv32.\r\n");
while(1);
}
- puts("Uncompressing Linux...\n");
+ puts("Uncompressing Linux...\r\n");
gunzip();
- puts("Done. Now booting the kernel.\n");
+ puts("Done. Now booting the kernel.\r\n");
}