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>
This commit is contained in:
parent
a939b96ccc
commit
66ab3a74c5
23 changed files with 186 additions and 429 deletions
|
|
@ -70,7 +70,7 @@ SRC_ARCH = $(srctree)/arch/cris
|
|||
# cris object files path
|
||||
OBJ_ARCH = $(objtree)/arch/cris
|
||||
|
||||
boot := arch/cris/$(SARCH)/boot
|
||||
boot := arch/cris/boot
|
||||
MACHINE := arch/cris/$(SARCH)
|
||||
|
||||
all: zImage
|
||||
|
|
@ -81,15 +81,15 @@ zImage Image: vmlinux
|
|||
archprepare:
|
||||
|
||||
archclean:
|
||||
$(Q)if [ -e arch/cris/$(SARCH)/boot ]; then \
|
||||
$(MAKE) $(clean)=arch/cris/$(SARCH)/boot; \
|
||||
$(Q)if [ -e arch/cris/boot ]; then \
|
||||
$(MAKE) $(clean)=arch/cris/boot; \
|
||||
fi
|
||||
|
||||
CLEAN_FILES += \
|
||||
$(MACHINE)/boot/zImage \
|
||||
$(MACHINE)/boot/compressed/decompress.bin \
|
||||
$(MACHINE)/boot/compressed/piggy.gz \
|
||||
$(MACHINE)/boot/rescue/rescue.bin
|
||||
$(boot)/zImage \
|
||||
$(boot)/compressed/decompress.bin \
|
||||
$(boot)/compressed/piggy.gz \
|
||||
$(boot)/rescue/rescue.bin
|
||||
|
||||
|
||||
# MRPROPER_FILES +=
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# arch/cris/arch-v32/boot/compressed/Makefile
|
||||
#
|
||||
|
||||
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
|
||||
ldflags-y += -T$(srctree)/$(src)/decompress.lds
|
||||
OBJECTS = $(obj)/head.o $(obj)/misc.o
|
||||
OBJCOPYFLAGS = -O binary --remove-section=.bss
|
||||
|
||||
quiet_cmd_image = BUILD $@
|
||||
cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@
|
||||
|
||||
targets := vmlinux piggy.gz decompress.o decompress.bin
|
||||
|
||||
$(obj)/decompress.o: $(OBJECTS) FORCE
|
||||
$(call if_changed,ld)
|
||||
|
||||
$(obj)/decompress.bin: $(obj)/decompress.o FORCE
|
||||
$(call if_changed,objcopy)
|
||||
|
||||
$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
|
||||
$(call if_changed,image)
|
||||
|
||||
$(obj)/piggy.gz: $(obj)/../Image FORCE
|
||||
$(call if_changed,gzip)
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# Makefile for rescue (bootstrap) code
|
||||
#
|
||||
|
||||
CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE)
|
||||
ccflags-y += -O2 -I $(srctree)/include/asm/arch/mach/ \
|
||||
-I $(srctree)/include/asm/arch
|
||||
asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch
|
||||
LD = gcc-cris -mlinux -march=v32 -nostdlib
|
||||
ldflags-y += -T $(srctree)/$(src)/rescue.lds
|
||||
LDPOSTFLAGS = -lgcc
|
||||
OBJCOPYFLAGS = -O binary --remove-section=.bss
|
||||
obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o
|
||||
OBJECT := $(obj)/head.o
|
||||
|
||||
targets := rescue.o rescue.bin
|
||||
|
||||
quiet_cmd_ldlibgcc = LD $@
|
||||
cmd_ldlibgcc = $(LD) $(LDFLAGS) $(filter-out FORCE,$^) $(LDPOSTFLAGS) -o $@
|
||||
|
||||
$(obj)/rescue.o: $(OBJECTS) FORCE
|
||||
$(call if_changed,ldlibgcc)
|
||||
|
||||
$(obj)/rescue.bin: $(obj)/rescue.o FORCE
|
||||
$(call if_changed,objcopy)
|
||||
cp -p $(obj)/rescue.bin $(objtree)
|
||||
2
arch/cris/boot/.gitignore
vendored
Normal file
2
arch/cris/boot/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Image
|
||||
zImage
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
#
|
||||
# arch/cris/arch-v32/boot/Makefile
|
||||
# arch/cris/boot/Makefile
|
||||
#
|
||||
|
||||
OBJCOPYFLAGS = -O binary -R .note -R .comment
|
||||
objcopyflags-$(CONFIG_ETRAX_ARCH_V10) += -R .note -R .comment
|
||||
objcopyflags-$(CONFIG_ETRAX_ARCH_V32) += --remove-section=.bss
|
||||
|
||||
OBJCOPYFLAGS = -O binary $(objcopyflags-y)
|
||||
|
||||
|
||||
subdir- := compressed rescue
|
||||
targets := Image
|
||||
38
arch/cris/boot/compressed/Makefile
Normal file
38
arch/cris/boot/compressed/Makefile
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# arch/cris/boot/compressed/Makefile
|
||||
#
|
||||
|
||||
asflags-y += $(LINUXINCLUDE)
|
||||
ccflags-y += -O2 $(LINUXINCLUDE)
|
||||
|
||||
# asflags-$(CONFIG_ETRAX_ARCH_V32) += -I$(srctree)/include/asm/mach \
|
||||
# -I$(srctree)/include/asm/arch
|
||||
# ccflags-$(CONFIG_ETRAX_ARCH_V32) += -O2 -I$(srctree)/include/asm/mach
|
||||
# -I$(srctree)/include/asm/arch
|
||||
|
||||
arch-$(CONFIG_ETRAX_ARCH_V10) = v10
|
||||
arch-$(CONFIG_ETRAX_ARCH_V32) = v32
|
||||
|
||||
ldflags-y += -T $(srctree)/$(src)/decompress_$(arch-y).lds
|
||||
|
||||
OBJECTS-$(CONFIG_ETRAX_ARCH_V32) = $(obj)/head_v32.o
|
||||
OBJECTS-$(CONFIG_ETRAX_ARCH_V10) = $(obj)/head_v10.o
|
||||
OBJECTS= $(OBJECTS-y) $(obj)/misc.o
|
||||
OBJCOPYFLAGS = -O binary --remove-section=.bss
|
||||
|
||||
quiet_cmd_image = BUILD $@
|
||||
cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@
|
||||
|
||||
targets := vmlinux piggy.gz decompress.o decompress.bin
|
||||
|
||||
$(obj)/decompress.o: $(OBJECTS) FORCE
|
||||
$(call if_changed,ld)
|
||||
|
||||
$(obj)/decompress.bin: $(obj)/decompress.o FORCE
|
||||
$(call if_changed,objcopy)
|
||||
|
||||
$(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE
|
||||
$(call if_changed,image)
|
||||
|
||||
$(obj)/piggy.gz: $(obj)/../Image FORCE
|
||||
$(call if_changed,gzip)
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
Creation of the self-extracting compressed kernel image (vmlinuz)
|
||||
-----------------------------------------------------------------
|
||||
$Id: README,v 1.1 2001/12/17 13:59:27 bjornw Exp $
|
||||
|
||||
This can be slightly confusing because it's a process with many steps.
|
||||
|
||||
The kernel object built by the arch/etrax100/Makefile, vmlinux, is split
|
||||
by that makefile into text and data binary files, vmlinux.text and
|
||||
by that makefile into text and data binary files, vmlinux.text and
|
||||
vmlinux.data.
|
||||
|
||||
Those files together with a ROM filesystem can be catted together and
|
||||
burned into a flash or executed directly at the DRAM origin.
|
||||
|
||||
They can also be catted together and compressed with gzip, which is what
|
||||
happens in this makefile. Together they make up piggy.img.
|
||||
happens in this makefile. Together they make up piggy.img.
|
||||
|
||||
The decompressor is built into the file decompress.o. It is turned into
|
||||
the binary file decompress.bin, which is catted together with piggy.img
|
||||
30
arch/cris/boot/compressed/decompress_v10.lds
Normal file
30
arch/cris/boot/compressed/decompress_v10.lds
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* OUTPUT_FORMAT(elf32-us-cris) */
|
||||
OUTPUT_FORMAT(elf32-cris)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
dram : ORIGIN = 0x40700000,
|
||||
LENGTH = 0x00100000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
_stext = . ;
|
||||
*(.text)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
_etext = . ;
|
||||
} > dram
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
_edata = . ;
|
||||
} > dram
|
||||
.bss :
|
||||
{
|
||||
*(.bss)
|
||||
_end = ALIGN( 0x10 ) ;
|
||||
} > dram
|
||||
}
|
||||
30
arch/cris/boot/compressed/decompress_v32.lds
Normal file
30
arch/cris/boot/compressed/decompress_v32.lds
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*#OUTPUT_FORMAT(elf32-us-cris) */
|
||||
OUTPUT_ARCH (crisv32)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
dram : ORIGIN = 0x40700000,
|
||||
LENGTH = 0x00100000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
_stext = . ;
|
||||
*(.text)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
_etext = . ;
|
||||
} > dram
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
_edata = . ;
|
||||
} > dram
|
||||
.bss :
|
||||
{
|
||||
*(.bss)
|
||||
_end = ALIGN( 0x10 ) ;
|
||||
} > dram
|
||||
}
|
||||
126
arch/cris/boot/compressed/head_v10.S
Normal file
126
arch/cris/boot/compressed/head_v10.S
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* arch/cris/boot/compressed/head.S
|
||||
*
|
||||
* Copyright (C) 1999, 2001 Axis Communications AB
|
||||
*
|
||||
* Code that sets up the DRAM registers, calls the
|
||||
* decompressor to unpack the piggybacked kernel, and jumps.
|
||||
*
|
||||
*/
|
||||
|
||||
#define ASSEMBLER_MACROS_ONLY
|
||||
#include <arch/sv_addr_ag.h>
|
||||
|
||||
#define RAM_INIT_MAGIC 0x56902387
|
||||
#define COMMAND_LINE_MAGIC 0x87109563
|
||||
|
||||
;; Exported symbols
|
||||
|
||||
.globl input_data
|
||||
|
||||
|
||||
.text
|
||||
|
||||
nop
|
||||
di
|
||||
|
||||
;; We need to initialze DRAM registers before we start using the DRAM
|
||||
|
||||
cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
|
||||
beq dram_init_finished
|
||||
nop
|
||||
|
||||
#include "../../arch-v10/lib/dram_init.S"
|
||||
|
||||
dram_init_finished:
|
||||
|
||||
;; Initiate the PA and PB ports
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
|
||||
move.b $r0, [R_PORT_PA_DATA]
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
|
||||
move.b $r0, [R_PORT_PA_DIR]
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
|
||||
move.b $r0, [R_PORT_PB_DATA]
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
|
||||
move.b $r0, [R_PORT_PB_DIR]
|
||||
|
||||
;; Setup the stack to a suitably high address.
|
||||
;; We assume 8 MB is the minimum DRAM in an eLinux
|
||||
;; product 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.
|
||||
;; Use (_edata - basse) as offset to the current PC.
|
||||
|
||||
basse: move.d $pc, $r5
|
||||
and.d 0x7fffffff, $r5 ; strip any non-cache bit
|
||||
subq 2, $r5 ; compensate for the move.d $pc instr
|
||||
move.d $r5, $r0 ; save for later - flash address of 'basse'
|
||||
add.d _edata, $r5
|
||||
sub.d basse, $r5 ; $r5 = flash address of '_edata'
|
||||
|
||||
;; Copy text+data to DRAM
|
||||
|
||||
move.d basse, $r1 ; destination
|
||||
move.d _edata, $r2 ; end destination
|
||||
1: move.w [$r0+], $r3
|
||||
move.w $r3, [$r1+]
|
||||
cmp.d $r2, $r1
|
||||
bcs 1b
|
||||
nop
|
||||
|
||||
move.d $r5, [input_data] ; for the decompressor
|
||||
|
||||
|
||||
;; Clear the decompressors BSS (between _edata and _end)
|
||||
|
||||
moveq 0, $r0
|
||||
move.d _edata, $r1
|
||||
move.d _end, $r2
|
||||
1: move.w $r0, [$r1+]
|
||||
cmp.d $r2, $r1
|
||||
bcs 1b
|
||||
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]
|
||||
|
||||
;; Do the decompression and save compressed size in inptr
|
||||
|
||||
jsr decompress_kernel
|
||||
|
||||
;; Put start address of root partition in $r9 so the kernel can use it
|
||||
;; when mounting from flash
|
||||
|
||||
move.d [input_data], $r9 ; flash address of compressed kernel
|
||||
add.d [inptr], $r9 ; size of compressed kernel
|
||||
|
||||
;; Restore command line magic and address.
|
||||
move.d _cmd_line_magic, $r10
|
||||
move.d [$r10], $r10
|
||||
move.d _cmd_line_addr, $r11
|
||||
move.d [$r11], $r11
|
||||
|
||||
;; Enter the decompressed kernel
|
||||
move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
|
||||
jump 0x40004000 ; kernel is linked to this address
|
||||
|
||||
.data
|
||||
|
||||
input_data:
|
||||
.dword 0 ; used by the decompressor
|
||||
_cmd_line_magic:
|
||||
.dword 0
|
||||
_cmd_line_addr:
|
||||
.dword 0
|
||||
#include "../../arch-v10/lib/hw_settings.S"
|
||||
145
arch/cris/boot/compressed/head_v32.S
Normal file
145
arch/cris/boot/compressed/head_v32.S
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Code that sets up the DRAM registers, calls the
|
||||
* decompressor to unpack the piggybacked kernel, and jumps.
|
||||
*
|
||||
* Copyright (C) 1999 - 2006, Axis Communications AB
|
||||
*/
|
||||
|
||||
#define ASSEMBLER_MACROS_ONLY
|
||||
#include <hwregs/asm/reg_map_asm.h>
|
||||
#include <mach/startup.inc>
|
||||
|
||||
#define RAM_INIT_MAGIC 0x56902387
|
||||
#define COMMAND_LINE_MAGIC 0x87109563
|
||||
|
||||
;; Exported symbols
|
||||
|
||||
.globl input_data
|
||||
|
||||
.text
|
||||
start:
|
||||
di
|
||||
|
||||
;; Start clocks for used blocks.
|
||||
START_CLOCKS
|
||||
|
||||
;; Initialize the DRAM registers.
|
||||
cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
|
||||
beq dram_init_finished
|
||||
nop
|
||||
|
||||
#if defined CONFIG_ETRAXFS
|
||||
#include "../../arch-v32/mach-fs/dram_init.S"
|
||||
#elif defined CONFIG_CRIS_MACH_ARTPEC3
|
||||
#include "../../arch-v32/mach-a3/dram_init.S"
|
||||
#else
|
||||
#error Only ETRAXFS and ARTPEC-3 supported!
|
||||
#endif
|
||||
|
||||
dram_init_finished:
|
||||
|
||||
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.
|
||||
;; 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.
|
||||
|
||||
hereami:
|
||||
lapcq ., $r5 ; get PC
|
||||
and.d 0x7fffffff, $r5 ; strip any non-cache bit
|
||||
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
|
||||
|
||||
;; Copy text+data to DRAM
|
||||
|
||||
move.d _edata, $r2 ; end destination
|
||||
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
|
||||
|
||||
;; Clear the decompressors BSS (between _edata and _end)
|
||||
|
||||
moveq 0, $r0
|
||||
move.d _edata, $r1
|
||||
move.d _end, $r2
|
||||
1: move.w $r0, [$r1+]
|
||||
cmp.d $r2, $r1
|
||||
bcs 1b
|
||||
nop
|
||||
|
||||
;; Save command line magic and address.
|
||||
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
|
||||
move.d _cmd_line_addr, $r11
|
||||
move.d [$r11], $r11
|
||||
|
||||
;; Put start address of root partition in r9 so the kernel can use it
|
||||
;; when mounting from flash
|
||||
move.d input_data, $r0
|
||||
move.d [$r0], $r9 ; flash address of compressed kernel
|
||||
move.d inptr, $r0
|
||||
add.d [$r0], $r9 ; size of compressed kernel
|
||||
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
|
||||
move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
|
||||
jump 0x40004000 ; kernel is linked to this address
|
||||
nop
|
||||
|
||||
.data
|
||||
|
||||
input_data:
|
||||
.dword 0 ; used by the decompressor
|
||||
_cmd_line_magic:
|
||||
.dword 0
|
||||
_cmd_line_addr:
|
||||
.dword 0
|
||||
_boot_source:
|
||||
.dword 0
|
||||
|
||||
#if defined CONFIG_ETRAXFS
|
||||
#include "../../arch-v32/mach-fs/hw_settings.S"
|
||||
#elif defined CONFIG_CRIS_MACH_ARTPEC3
|
||||
#include "../../arch-v32/mach-a3/hw_settings.S"
|
||||
#else
|
||||
#error Only ETRAXFS and ARTPEC-3 supported!
|
||||
#endif
|
||||
|
|
@ -18,9 +18,19 @@
|
|||
|
||||
#define KERNEL_LOAD_ADR 0x40004000
|
||||
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
#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
|
||||
#else
|
||||
#include <arch/svinto.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* gzip declarations
|
||||
|
|
@ -96,13 +106,13 @@ static unsigned outcnt = 0; /* bytes in output buffer */
|
|||
|
||||
static void flush_window(void);
|
||||
static void error(char *m);
|
||||
static void puts(const char *);
|
||||
|
||||
extern char *input_data; /* lives in head.S */
|
||||
|
||||
static long bytes_out = 0;
|
||||
static long bytes_out;
|
||||
static uch *output_data;
|
||||
static unsigned long output_ptr = 0;
|
||||
static void puts(const char *);
|
||||
static unsigned long output_ptr;
|
||||
|
||||
/* the "heap" is put directly after the BSS ends, at end */
|
||||
|
||||
|
|
@ -114,38 +124,73 @@ static long free_mem_end_ptr;
|
|||
|
||||
/* decompressor info and error messages to serial console */
|
||||
|
||||
static void
|
||||
puts(const char *s)
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
static inline void serout(const char *s, reg_scope_instances regi_ser)
|
||||
{
|
||||
reg_ser_rs_stat_din rs;
|
||||
reg_ser_rw_dout dout = {.data = *s};
|
||||
|
||||
do {
|
||||
rs = REG_RD(ser, regi_ser, rs_stat_din);
|
||||
}
|
||||
while (!rs.tr_rdy);/* Wait for transceiver. */
|
||||
|
||||
REG_WR(ser, regi_ser, rw_dout, dout);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void puts(const char *s)
|
||||
{
|
||||
#ifndef CONFIG_ETRAX_DEBUG_PORT_NULL
|
||||
while (*s) {
|
||||
#ifdef CONFIG_ETRAX_DEBUG_PORT0
|
||||
while (!(*R_SERIAL0_STATUS & (1 << 5))) ;
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
serout(s, regi_ser0);
|
||||
#else
|
||||
while (!(*R_SERIAL0_STATUS & (1 << 5)))
|
||||
;
|
||||
*R_SERIAL0_TR_DATA = *s++;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_DEBUG_PORT1
|
||||
while (!(*R_SERIAL1_STATUS & (1 << 5))) ;
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
serout(s, regi_ser1);
|
||||
#else
|
||||
while (!(*R_SERIAL1_STATUS & (1 << 5)))
|
||||
;
|
||||
*R_SERIAL1_TR_DATA = *s++;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_DEBUG_PORT2
|
||||
while (!(*R_SERIAL2_STATUS & (1 << 5))) ;
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
serout(s, regi_ser2);
|
||||
#else
|
||||
while (!(*R_SERIAL2_STATUS & (1 << 5)))
|
||||
;
|
||||
*R_SERIAL2_TR_DATA = *s++;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_DEBUG_PORT3
|
||||
while (!(*R_SERIAL3_STATUS & (1 << 5))) ;
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
serout(s, regi_ser3);
|
||||
#else
|
||||
while (!(*R_SERIAL3_STATUS & (1 << 5)))
|
||||
;
|
||||
*R_SERIAL3_TR_DATA = *s++;
|
||||
#endif
|
||||
#endif
|
||||
*s++;
|
||||
}
|
||||
/* CONFIG_ETRAX_DEBUG_PORT_NULL */
|
||||
#endif
|
||||
}
|
||||
|
||||
void *memset(void *s, int c, size_t n)
|
||||
{
|
||||
int i;
|
||||
char *ss = (char *)s;
|
||||
char *ss = (char*)s;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
ss[i] = c;
|
||||
for (i=0;i<n;i++) ss[i] = c;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
@ -192,7 +237,7 @@ static void error(char *x)
|
|||
puts(x);
|
||||
puts("\n\n -- System halted\n");
|
||||
|
||||
while (1); /* Halt */
|
||||
while(1); /* Halt */
|
||||
}
|
||||
|
||||
void setup_normal_output_buffer(void)
|
||||
|
|
@ -200,9 +245,104 @@ void setup_normal_output_buffer(void)
|
|||
output_data = (char *)KERNEL_LOAD_ADR;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
static inline void serial_setup(reg_scope_instances regi_ser)
|
||||
{
|
||||
reg_ser_rw_xoff xoff;
|
||||
reg_ser_rw_tr_ctrl tr_ctrl;
|
||||
reg_ser_rw_rec_ctrl rec_ctrl;
|
||||
reg_ser_rw_tr_baud_div tr_baud;
|
||||
reg_ser_rw_rec_baud_div rec_baud;
|
||||
|
||||
/* Turn off XOFF. */
|
||||
xoff = REG_RD(ser, regi_ser, rw_xoff);
|
||||
|
||||
xoff.chr = 0;
|
||||
xoff.automatic = regk_ser_no;
|
||||
|
||||
REG_WR(ser, regi_ser, rw_xoff, xoff);
|
||||
|
||||
/* Set baudrate and stopbits. */
|
||||
tr_ctrl = REG_RD(ser, regi_ser, rw_tr_ctrl);
|
||||
rec_ctrl = REG_RD(ser, regi_ser, rw_rec_ctrl);
|
||||
tr_baud = REG_RD(ser, regi_ser, rw_tr_baud_div);
|
||||
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 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) / 115200;
|
||||
rec_baud.div = (29493000 / 8) / 115200;
|
||||
|
||||
REG_WR(ser, regi_ser, rw_tr_ctrl, tr_ctrl);
|
||||
REG_WR(ser, regi_ser, rw_tr_baud_div, tr_baud);
|
||||
REG_WR(ser, regi_ser, rw_rec_ctrl, rec_ctrl);
|
||||
REG_WR(ser, regi_ser, rw_rec_baud_div, rec_baud);
|
||||
}
|
||||
#endif
|
||||
|
||||
void decompress_kernel(void)
|
||||
{
|
||||
char revision;
|
||||
char compile_rev;
|
||||
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
/* Need at least a CRISv32 to run. */
|
||||
compile_rev = 32;
|
||||
#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;
|
||||
#else /* CRISv10 */
|
||||
/* Need at least a crisv10 to run. */
|
||||
compile_rev = 10;
|
||||
|
||||
/* input_data is set in head.S */
|
||||
inbuf = input_data;
|
||||
|
|
@ -228,6 +368,7 @@ void decompress_kernel(void)
|
|||
*R_SERIAL3_XOFF = 0;
|
||||
*R_SERIAL3_BAUD = 0x99;
|
||||
*R_SERIAL3_TR_CTRL = 0x40;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
setup_normal_output_buffer();
|
||||
|
|
@ -235,12 +376,16 @@ void decompress_kernel(void)
|
|||
makecrc();
|
||||
|
||||
__asm__ volatile ("move $vr,%0" : "=rm" (revision));
|
||||
if (revision < 10) {
|
||||
if (revision < compile_rev) {
|
||||
#ifdef CONFIG_ETRAX_ARCH_V32
|
||||
puts("You need an ETRAX FS to run Linux 2.6/crisv32\n");
|
||||
#else
|
||||
puts("You need an ETRAX 100LX to run linux 2.6\n");
|
||||
while (1);
|
||||
#endif
|
||||
while(1);
|
||||
}
|
||||
|
||||
puts("Uncompressing Linux...\n");
|
||||
gunzip();
|
||||
puts("Done. Now booting the kernel.\n");
|
||||
puts("Done. Now booting the kernel\n");
|
||||
}
|
||||
47
arch/cris/boot/rescue/Makefile
Normal file
47
arch/cris/boot/rescue/Makefile
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#
|
||||
# Makefile for rescue (bootstrap) code
|
||||
#
|
||||
|
||||
# CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE)
|
||||
# ccflags-$(CONFIG_ETRAX_ARCH_V32) += -I$(srctree)/include/asm/arch/mach/ \
|
||||
# -I$(srctree)/include/asm/arch
|
||||
# asflags-y += -I $(srctree)/include/asm/arch/mach/ -I $(srctree)/include/asm/arch
|
||||
# LD = gcc-cris -mlinux -march=v32 -nostdlib
|
||||
|
||||
asflags-y += $(LINUXINCLUDE)
|
||||
ccflags-y += -O2 $(LINUXINCLUDE)
|
||||
arch-$(CONFIG_ETRAX_ARCH_V10) = v10
|
||||
arch-$(CONFIG_ETRAX_ARCH_V32) = v32
|
||||
|
||||
ldflags-y += -T $(srctree)/$(src)/rescue_$(arch-y).lds
|
||||
OBJCOPYFLAGS = -O binary --remove-section=.bss
|
||||
obj-$(CONFIG_ETRAX_ARCH_V32) = $(obj)/head_v32.o
|
||||
obj-$(CONFIG_ETRAX_ARCH_V10) = $(obj)/head_v10.o
|
||||
OBJECTS := $(obj-y)
|
||||
|
||||
targets := rescue.o rescue.bin
|
||||
|
||||
$(obj)/rescue.o: $(OBJECTS) FORCE
|
||||
$(call if_changed,ld)
|
||||
|
||||
$(obj)/rescue.bin: $(obj)/rescue.o FORCE
|
||||
$(call if_changed,objcopy)
|
||||
cp -p $(obj)/rescue.bin $(objtree)
|
||||
|
||||
$(obj)/testrescue.bin: $(obj)/testrescue.o
|
||||
$(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin
|
||||
# Pad it to 784 bytes
|
||||
dd if=/dev/zero of=tmp2423 bs=1 count=784
|
||||
cat tr.bin tmp2423 >testrescue_tmp.bin
|
||||
dd if=testrescue_tmp.bin of=$(obj)/testrescue.bin bs=1 count=784
|
||||
rm tr.bin tmp2423 testrescue_tmp.bin
|
||||
|
||||
|
||||
$(obj)/kimagerescue.bin: $(obj)/kimagerescue.o
|
||||
$(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/kimagerescue.o ktr.bin
|
||||
# Pad it to 784 bytes, that's what the rescue loader expects
|
||||
dd if=/dev/zero of=tmp2423 bs=1 count=784
|
||||
cat ktr.bin tmp2423 >kimagerescue_tmp.bin
|
||||
dd if=kimagerescue_tmp.bin of=$(obj)/kimagerescue.bin bs=1 count=784
|
||||
rm ktr.bin tmp2423 kimagerescue_tmp.bin
|
||||
|
||||
360
arch/cris/boot/rescue/head_v10.S
Normal file
360
arch/cris/boot/rescue/head_v10.S
Normal file
|
|
@ -0,0 +1,360 @@
|
|||
/*
|
||||
* Rescue code, made to reside at the beginning of the
|
||||
* flash-memory. when it starts, it checks a partition
|
||||
* table at the first sector after the rescue sector.
|
||||
* the partition table was generated by the product builder
|
||||
* script and contains offsets, lengths, types and checksums
|
||||
* for each partition that this code should check.
|
||||
*
|
||||
* If any of the checksums fail, we assume the flash is so
|
||||
* corrupt that we cant use it to boot into the ftp flash
|
||||
* loader, and instead we initialize the serial port to
|
||||
* receive a flash-loader and new flash image. we dont include
|
||||
* any flash code here, but just accept a certain amount of
|
||||
* bytes from the serial port and jump into it. the downloaded
|
||||
* code is put in the cache.
|
||||
*
|
||||
* The partitiontable is designed so that it is transparent to
|
||||
* code execution - it has a relative branch opcode in the
|
||||
* beginning that jumps over it. each entry contains extra
|
||||
* data so we can add stuff later.
|
||||
*
|
||||
* Partition table format:
|
||||
*
|
||||
* Code transparency:
|
||||
*
|
||||
* 2 bytes [opcode 'nop']
|
||||
* 2 bytes [opcode 'di']
|
||||
* 4 bytes [opcode 'ba <offset>', 8-bit or 16-bit version]
|
||||
* 2 bytes [opcode 'nop', delay slot]
|
||||
*
|
||||
* Table validation (at +10):
|
||||
*
|
||||
* 2 bytes [magic/version word for partitiontable - 0xef, 0xbe]
|
||||
* 2 bytes [length of all entries plus the end marker]
|
||||
* 4 bytes [checksum for the partitiontable itself]
|
||||
*
|
||||
* Entries, each with the following format, last has offset -1:
|
||||
*
|
||||
* 4 bytes [offset in bytes, from start of flash]
|
||||
* 4 bytes [length in bytes of partition]
|
||||
* 4 bytes [checksum, simple longword sum]
|
||||
* 2 bytes [partition type]
|
||||
* 2 bytes [flags, only bit 0 used, ro/rw = 1/0]
|
||||
* 16 bytes [reserved for future use]
|
||||
*
|
||||
* End marker
|
||||
*
|
||||
* 4 bytes [-1]
|
||||
*
|
||||
* 10 bytes [0, padding]
|
||||
*
|
||||
* Bit 0 in flags signifies RW or RO. The rescue code only bothers
|
||||
* to check the checksum for RO partitions, since the others will
|
||||
* change their data without updating the checksums. A 1 in bit 0
|
||||
* means RO, 0 means RW. That way, it is possible to set a partition
|
||||
* in RO mode initially, and later mark it as RW, since you can always
|
||||
* write 0's to the flash.
|
||||
*
|
||||
* During the wait for serial input, the status LED will flash so the
|
||||
* user knows something went wrong.
|
||||
*
|
||||
* Copyright (C) 1999-2007 Axis Communications AB
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ETRAX_AXISFLASHMAP
|
||||
|
||||
#define ASSEMBLER_MACROS_ONLY
|
||||
#include <arch/sv_addr_ag.h>
|
||||
|
||||
;; The partitiontable is looked for at the first sector after the boot
|
||||
;; sector. Sector size is 65536 bytes in all flashes we use.
|
||||
|
||||
#define PTABLE_START CONFIG_ETRAX_PTABLE_SECTOR
|
||||
#define PTABLE_MAGIC 0xbeef
|
||||
|
||||
;; The normal Etrax100 on-chip boot ROM does serial boot at 0x380000f0.
|
||||
;; That is not where we put our downloaded serial boot-code.
|
||||
;; The length is enough for downloading code that loads the rest
|
||||
;; of itself (after having setup the DRAM etc).
|
||||
;; It is the same length as the on-chip ROM loads, so the same
|
||||
;; host loader can be used to load a rescued product as well as
|
||||
;; one booted through the Etrax serial boot code.
|
||||
|
||||
#define CODE_START 0x40000000
|
||||
#define CODE_LENGTH 784
|
||||
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER0
|
||||
#define SERXOFF R_SERIAL0_XOFF
|
||||
#define SERBAUD R_SERIAL0_BAUD
|
||||
#define SERRECC R_SERIAL0_REC_CTRL
|
||||
#define SERRDAT R_SERIAL0_REC_DATA
|
||||
#define SERSTAT R_SERIAL0_STATUS
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER1
|
||||
#define SERXOFF R_SERIAL1_XOFF
|
||||
#define SERBAUD R_SERIAL1_BAUD
|
||||
#define SERRECC R_SERIAL1_REC_CTRL
|
||||
#define SERRDAT R_SERIAL1_REC_DATA
|
||||
#define SERSTAT R_SERIAL1_STATUS
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER2
|
||||
#define SERXOFF R_SERIAL2_XOFF
|
||||
#define SERBAUD R_SERIAL2_BAUD
|
||||
#define SERRECC R_SERIAL2_REC_CTRL
|
||||
#define SERRDAT R_SERIAL2_REC_DATA
|
||||
#define SERSTAT R_SERIAL2_STATUS
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER3
|
||||
#define SERXOFF R_SERIAL3_XOFF
|
||||
#define SERBAUD R_SERIAL3_BAUD
|
||||
#define SERRECC R_SERIAL3_REC_CTRL
|
||||
#define SERRDAT R_SERIAL3_REC_DATA
|
||||
#define SERSTAT R_SERIAL3_STATUS
|
||||
#endif
|
||||
|
||||
#define NOP_DI 0xf025050f
|
||||
#define RAM_INIT_MAGIC 0x56902387
|
||||
|
||||
.text
|
||||
|
||||
;; This is the entry point of the rescue code
|
||||
;; 0x80000000 if loaded in flash (as it should be)
|
||||
;; Since etrax actually starts at address 2 when booting from flash, we
|
||||
;; put a nop (2 bytes) here first so we dont accidentally skip the di
|
||||
|
||||
nop
|
||||
di
|
||||
|
||||
jump in_cache ; enter cached area instead
|
||||
in_cache:
|
||||
|
||||
|
||||
;; First put a jump test to give a possibility of upgrading the
|
||||
;; rescue code without erasing/reflashing the sector.
|
||||
;; We put a longword of -1 here and if it is not -1, we jump using
|
||||
;; the value as jump target. Since we can always change 1's to 0's
|
||||
;; without erasing the sector, it is possible to add new
|
||||
;; code after this and altering the jumptarget in an upgrade.
|
||||
|
||||
jtcd: move.d [jumptarget], $r0
|
||||
cmp.d 0xffffffff, $r0
|
||||
beq no_newjump
|
||||
nop
|
||||
|
||||
jump [$r0]
|
||||
|
||||
jumptarget:
|
||||
.dword 0xffffffff ; can be overwritten later to insert new code
|
||||
|
||||
no_newjump:
|
||||
#ifdef CONFIG_ETRAX_ETHERNET
|
||||
;; Start MII clock to make sure it is running when tranceiver is reset
|
||||
move.d 0x3, $r0 ; enable = on, phy = mii_clk
|
||||
move.d $r0, [R_NETWORK_GEN_CONFIG]
|
||||
#endif
|
||||
|
||||
;; We need to setup the bus registers before we start using the DRAM
|
||||
#include "../../../arch-v10/lib/dram_init.S"
|
||||
|
||||
;; we now should go through the checksum-table and check the listed
|
||||
;; partitions for errors.
|
||||
|
||||
move.d PTABLE_START, $r3
|
||||
move.d [$r3], $r0
|
||||
cmp.d NOP_DI, $r0 ; make sure the nop/di is there...
|
||||
bne do_rescue
|
||||
nop
|
||||
|
||||
;; skip the code transparency block (10 bytes).
|
||||
|
||||
addq 10, $r3
|
||||
|
||||
;; check for correct magic
|
||||
|
||||
move.w [$r3+], $r0
|
||||
cmp.w PTABLE_MAGIC, $r0
|
||||
bne do_rescue ; didn't recognize - trig rescue
|
||||
nop
|
||||
|
||||
;; check for correct ptable checksum
|
||||
|
||||
movu.w [$r3+], $r2 ; ptable length
|
||||
move.d $r2, $r8 ; save for later, length of total ptable
|
||||
addq 28, $r8 ; account for the rest
|
||||
move.d [$r3+], $r4 ; ptable checksum
|
||||
move.d $r3, $r1
|
||||
jsr checksum ; r1 source, r2 length, returns in r0
|
||||
|
||||
cmp.d $r0, $r4
|
||||
bne do_rescue ; didn't match - trig rescue
|
||||
nop
|
||||
|
||||
;; ptable is ok. validate each entry.
|
||||
|
||||
moveq -1, $r7
|
||||
|
||||
ploop: move.d [$r3+], $r1 ; partition offset (from ptable start)
|
||||
bne notfirst ; check if it is the partition containing ptable
|
||||
nop ; yes..
|
||||
move.d $r8, $r1 ; for its checksum check, skip the ptable
|
||||
move.d [$r3+], $r2 ; partition length
|
||||
sub.d $r8, $r2 ; minus the ptable length
|
||||
ba bosse
|
||||
nop
|
||||
notfirst:
|
||||
cmp.d -1, $r1 ; the end of the ptable ?
|
||||
beq flash_ok ; if so, the flash is validated
|
||||
move.d [$r3+], $r2 ; partition length
|
||||
bosse: move.d [$r3+], $r5 ; checksum
|
||||
move.d [$r3+], $r4 ; type and flags
|
||||
addq 16, $r3 ; skip the reserved bytes
|
||||
btstq 16, $r4 ; check ro flag
|
||||
bpl ploop ; rw partition, skip validation
|
||||
nop
|
||||
btstq 17, $r4 ; check bootable flag
|
||||
bpl 1f
|
||||
nop
|
||||
move.d $r1, $r7 ; remember boot partition offset
|
||||
1:
|
||||
add.d PTABLE_START, $r1
|
||||
|
||||
jsr checksum ; checksum the partition
|
||||
|
||||
cmp.d $r0, $r5
|
||||
beq ploop ; checksums matched, go to next entry
|
||||
nop
|
||||
|
||||
;; otherwise fall through to the rescue code.
|
||||
|
||||
do_rescue:
|
||||
;; setup port PA and PB default initial directions and data
|
||||
;; (so we can flash LEDs, and so that DTR and others are set)
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
|
||||
move.b $r0, [R_PORT_PA_DIR]
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
|
||||
move.b $r0, [R_PORT_PA_DATA]
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
|
||||
move.b $r0, [R_PORT_PB_DIR]
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
|
||||
move.b $r0, [R_PORT_PB_DATA]
|
||||
|
||||
;; setup the serial port at 115200 baud
|
||||
|
||||
moveq 0, $r0
|
||||
move.d $r0, [SERXOFF]
|
||||
|
||||
move.b 0x99, $r0
|
||||
move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive
|
||||
|
||||
move.b 0x40, $r0 ; rec enable
|
||||
move.b $r0, [SERRECC]
|
||||
|
||||
moveq 0, $r1 ; "timer" to clock out a LED red flash
|
||||
move.d CODE_START, $r3 ; destination counter
|
||||
movu.w CODE_LENGTH, $r4; length
|
||||
|
||||
wait_ser:
|
||||
addq 1, $r1
|
||||
#ifndef CONFIG_ETRAX_NO_LEDS
|
||||
#ifdef CONFIG_ETRAX_PA_LEDS
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r2
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_PB_LEDS
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r2
|
||||
#endif
|
||||
move.d (1 << CONFIG_ETRAX_LED1R) | (1 << CONFIG_ETRAX_LED2R), $r0
|
||||
btstq 16, $r1
|
||||
bpl 1f
|
||||
nop
|
||||
or.d $r0, $r2 ; set bit
|
||||
ba 2f
|
||||
nop
|
||||
1: not $r0 ; clear bit
|
||||
and.d $r0, $r2
|
||||
2:
|
||||
#ifdef CONFIG_ETRAX_PA_LEDS
|
||||
move.b $r2, [R_PORT_PA_DATA]
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_PB_LEDS
|
||||
move.b $r2, [R_PORT_PB_DATA]
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_90000000_LEDS
|
||||
move.b $r2, [0x90000000]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
;; check if we got something on the serial port
|
||||
|
||||
move.b [SERSTAT], $r0
|
||||
btstq 0, $r0 ; data_avail
|
||||
bpl wait_ser
|
||||
nop
|
||||
|
||||
;; got something - copy the byte and loop
|
||||
|
||||
move.b [SERRDAT], $r0
|
||||
move.b $r0, [$r3+]
|
||||
|
||||
subq 1, $r4 ; decrease length
|
||||
bne wait_ser
|
||||
nop
|
||||
|
||||
;; jump into downloaded code
|
||||
|
||||
move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is
|
||||
; initialized
|
||||
jump CODE_START
|
||||
|
||||
flash_ok:
|
||||
;; check r7, which contains either -1 or the partition to boot from
|
||||
|
||||
cmp.d -1, $r7
|
||||
bne 1f
|
||||
nop
|
||||
move.d PTABLE_START, $r7; otherwise use the ptable start
|
||||
1:
|
||||
move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is
|
||||
; initialized
|
||||
jump $r7 ; boot!
|
||||
|
||||
|
||||
;; Helper subroutines
|
||||
|
||||
;; Will checksum by simple addition
|
||||
;; r1 - source
|
||||
;; r2 - length in bytes
|
||||
;; result will be in r0
|
||||
checksum:
|
||||
moveq 0, $r0
|
||||
moveq CONFIG_ETRAX_FLASH1_SIZE, $r6
|
||||
|
||||
;; If the first physical flash memory is exceeded wrap to the
|
||||
;; second one
|
||||
btstq 26, $r1 ; Are we addressing first flash?
|
||||
bpl 1f
|
||||
nop
|
||||
clear.d $r6
|
||||
|
||||
1: test.d $r6 ; 0 = no wrapping
|
||||
beq 2f
|
||||
nop
|
||||
lslq 20, $r6 ; Convert MB to bytes
|
||||
sub.d $r1, $r6
|
||||
|
||||
2: addu.b [$r1+], $r0
|
||||
subq 1, $r6 ; Flash memory left
|
||||
beq 3f
|
||||
subq 1, $r2 ; Length left
|
||||
bne 2b
|
||||
nop
|
||||
ret
|
||||
nop
|
||||
|
||||
3: move.d MEM_CSE1_START, $r1 ; wrap to second flash
|
||||
ba 2b
|
||||
nop
|
||||
|
||||
#endif
|
||||
26
arch/cris/boot/rescue/head_v32.S
Normal file
26
arch/cris/boot/rescue/head_v32.S
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Just get started by jumping to CONFIG_ETRAX_PTABLE_SECTOR to start
|
||||
* kernel decompressor.
|
||||
*
|
||||
* In practice, this only works for NOR flash (or some convoluted RAM boot)
|
||||
* and hence is not really useful for Artpec-3, so it's Etrax FS / NOR only.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <mach/startup.inc>
|
||||
|
||||
#ifdef CONFIG_ETRAX_AXISFLASHMAP
|
||||
|
||||
;; Code
|
||||
|
||||
.text
|
||||
start:
|
||||
|
||||
;; Start clocks for used blocks.
|
||||
START_CLOCKS
|
||||
|
||||
move.d CONFIG_ETRAX_PTABLE_SECTOR, $r10
|
||||
jump $r10 ; Jump to decompressor
|
||||
nop
|
||||
|
||||
#endif
|
||||
143
arch/cris/boot/rescue/kimagerescue.S
Normal file
143
arch/cris/boot/rescue/kimagerescue.S
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Rescue code to be prepended on a kimage and copied to the
|
||||
* rescue serial port.
|
||||
* This is called from the rescue code, it will copy received data to
|
||||
* 4004000 and after a timeout jump to it.
|
||||
*/
|
||||
|
||||
#define ASSEMBLER_MACROS_ONLY
|
||||
#include <arch/sv_addr_ag.h>
|
||||
|
||||
#define CODE_START 0x40004000
|
||||
#define CODE_LENGTH 784
|
||||
#define TIMEOUT_VALUE 1000
|
||||
|
||||
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER0
|
||||
#define SERXOFF R_SERIAL0_XOFF
|
||||
#define SERBAUD R_SERIAL0_BAUD
|
||||
#define SERRECC R_SERIAL0_REC_CTRL
|
||||
#define SERRDAT R_SERIAL0_REC_DATA
|
||||
#define SERSTAT R_SERIAL0_STATUS
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER1
|
||||
#define SERXOFF R_SERIAL1_XOFF
|
||||
#define SERBAUD R_SERIAL1_BAUD
|
||||
#define SERRECC R_SERIAL1_REC_CTRL
|
||||
#define SERRDAT R_SERIAL1_REC_DATA
|
||||
#define SERSTAT R_SERIAL1_STATUS
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER2
|
||||
#define SERXOFF R_SERIAL2_XOFF
|
||||
#define SERBAUD R_SERIAL2_BAUD
|
||||
#define SERRECC R_SERIAL2_REC_CTRL
|
||||
#define SERRDAT R_SERIAL2_REC_DATA
|
||||
#define SERSTAT R_SERIAL2_STATUS
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_RESCUE_SER3
|
||||
#define SERXOFF R_SERIAL3_XOFF
|
||||
#define SERBAUD R_SERIAL3_BAUD
|
||||
#define SERRECC R_SERIAL3_REC_CTRL
|
||||
#define SERRDAT R_SERIAL3_REC_DATA
|
||||
#define SERSTAT R_SERIAL3_STATUS
|
||||
#endif
|
||||
|
||||
.text
|
||||
;; This is the entry point of the rescue code
|
||||
;; 0x80000000 if loaded in flash (as it should be)
|
||||
;; since etrax actually starts at address 2 when booting from flash, we
|
||||
;; put a nop (2 bytes) here first so we dont accidentally skip the di
|
||||
|
||||
nop
|
||||
di
|
||||
#ifndef CONFIG_SVINTO_SIM
|
||||
;; setup port PA and PB default initial directions and data
|
||||
;; (so we can flash LEDs, and so that DTR and others are set)
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0
|
||||
move.b $r0, [R_PORT_PA_DIR]
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0
|
||||
move.b $r0, [R_PORT_PA_DATA]
|
||||
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0
|
||||
move.b $r0, [R_PORT_PB_DIR]
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0
|
||||
move.b $r0, [R_PORT_PB_DATA]
|
||||
|
||||
;; We need to setup the bus registers before we start using the DRAM
|
||||
#include "../../lib/dram_init.S"
|
||||
|
||||
#endif
|
||||
;; Setup the stack to a suitably high address.
|
||||
;; We assume 8 MB is the minimum DRAM in an eLinux
|
||||
;; product and put the sp at the top for now.
|
||||
|
||||
move.d 0x40800000, $sp
|
||||
|
||||
;; setup the serial port at 115200 baud
|
||||
|
||||
moveq 0, $r0
|
||||
move.d $r0, [SERXOFF]
|
||||
|
||||
move.b 0x99, $r0
|
||||
move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit
|
||||
; and receive
|
||||
|
||||
move.b 0x40, $r0 ; rec enable
|
||||
move.b $r0, [SERRECC]
|
||||
|
||||
|
||||
moveq 0, $r1 ; "timer" to clock out a LED red flash
|
||||
move.d CODE_START, $r3 ; destination counter
|
||||
move.d CODE_LENGTH, $r4 ; length
|
||||
move.d TIMEOUT_VALUE, $r5 ; "timeout" until jump
|
||||
|
||||
wait_ser:
|
||||
addq 1, $r1
|
||||
subq 1, $r5 ; decrease timeout
|
||||
beq jump_start ; timed out
|
||||
nop
|
||||
#ifndef CONFIG_ETRAX_NO_LEDS
|
||||
#ifdef CONFIG_ETRAX_PA_LEDS
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r2
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_PB_LEDS
|
||||
move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r2
|
||||
#endif
|
||||
move.d (1 << CONFIG_ETRAX_LED1R) | (1 << CONFIG_ETRAX_LED2R), $r0
|
||||
btstq 16, $r1
|
||||
bpl 1f
|
||||
nop
|
||||
or.d $r0, $r2 ; set bit
|
||||
ba 2f
|
||||
nop
|
||||
1: not $r0 ; clear bit
|
||||
and.d $r0, $r2
|
||||
2:
|
||||
#ifdef CONFIG_ETRAX_PA_LEDS
|
||||
move.b $r2, [R_PORT_PA_DATA]
|
||||
#endif
|
||||
#ifdef CONFIG_ETRAX_PB_LEDS
|
||||
move.b $r2, [R_PORT_PB_DATA]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
;; check if we got something on the serial port
|
||||
|
||||
move.b [SERSTAT], $r0
|
||||
btstq 0, $r0 ; data_avail
|
||||
bpl wait_ser
|
||||
nop
|
||||
|
||||
;; got something - copy the byte and loop
|
||||
|
||||
move.b [SERRDAT], $r0
|
||||
move.b $r0, [$r3+]
|
||||
move.d TIMEOUT_VALUE, $r5 ; reset "timeout"
|
||||
subq 1, $r4 ; decrease length
|
||||
bne wait_ser
|
||||
nop
|
||||
jump_start:
|
||||
;; jump into downloaded code
|
||||
|
||||
jump CODE_START
|
||||
20
arch/cris/boot/rescue/rescue_v10.lds
Normal file
20
arch/cris/boot/rescue/rescue_v10.lds
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
MEMORY
|
||||
{
|
||||
flash : ORIGIN = 0x00000000,
|
||||
LENGTH = 0x00100000
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
stext = . ;
|
||||
*(.text)
|
||||
etext = . ;
|
||||
} > flash
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
edata = . ;
|
||||
} > flash
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue