From 1c565c9c3b5005ca1f1708040718e35a0cf69e88 Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Tue, 28 Feb 2012 15:51:09 +0100 Subject: rk27xx: rework linker scripts and crt0.S Change-Id: Id1d509056026bc67e1a5051c60818336933d4aeb --- firmware/target/arm/rk27xx/crt0.S | 81 +++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 37 deletions(-) (limited to 'firmware/target/arm/rk27xx/crt0.S') diff --git a/firmware/target/arm/rk27xx/crt0.S b/firmware/target/arm/rk27xx/crt0.S index 23f3fcf2c9..1bbd46a12c 100644 --- a/firmware/target/arm/rk27xx/crt0.S +++ b/firmware/target/arm/rk27xx/crt0.S @@ -5,7 +5,6 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: crt0.S 18776 2008-10-11 18:32:17Z gevaerts $ * * Copyright (C) 2008 by Marcoen Hirschberg * Copyright (C) 2008 by Denes Balatoni @@ -24,26 +23,50 @@ #include "config.h" #include "cpu.h" - .section .intvect,"ax",%progbits - .global start - .global _newstart + .global start + .global entry_point + /* Exception vectors */ -start: - b _newstart - ldr pc, =undef_instr_handler - ldr pc, =software_int_handler - ldr pc, =prefetch_abort_handler - ldr pc, =data_abort_handler - ldr pc, =reserved_handler - ldr pc, =irq_handler - ldr pc, =fiq_handler + .section .intvect,"ax",%progbits + ldr pc, =start + ldr pc, =undef_instr_handler + ldr pc, =software_int_handler + ldr pc, =prefetch_abort_handler + ldr pc, =data_abort_handler + ldr pc, =reserved_handler + ldr pc, =irq_handler + ldr pc, =fiq_handler .ltorg -_newstart: - ldr pc, =newstart2 - .section .init.text,"ax",%progbits -newstart2: - msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ + .text +start: + msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ/FIQ */ + +#ifdef BOOTLOADER + sub r4, pc, #12 /* copy running address, accomodate + * for prefetch (-8) and msr instr (-4) + */ + + ldr r0, =0xefff0000 /* cache controler base address */ + ldrh r1, [r0] + strh r1, [r0] /* global cache disable */ + + ldr r2, =_relocstart + ldr r3, =_relocend + + cmp r2, r4 + beq entry_point /* skip copying if we are in place already */ +1: + cmp r3, r2 + ldrhi r1, [r4], #4 + strhi r1, [r2], #4 + bhi 1b + +entry_point_jmp: + ldr pc, =entry_point +#endif + +entry_point: mov r0, #0x18000000 add r0, r0, #0x1c000 @@ -135,26 +158,14 @@ newstart2: strhi r4, [r2], #4 bhi 1b -#ifndef BOOTLOADER - /* Copy icode and data to ram */ - ldr r2, =_iramstart - ldr r3, =_iramend - ldr r4, =_iramcopy -1: - cmp r3, r2 - ldrhi r1, [r4], #4 - strhi r1, [r2], #4 - bhi 1b - - /* Initialise ibss section to zero */ - ldr r2, =_iedata - ldr r3, =_iend + /* Initialise bss, ibss section to zero */ + ldr r2, =_edata + ldr r3, =_end mov r4, #0 1: cmp r3, r2 strhi r4, [r2], #4 bhi 1b -#endif /* Set up stack for IRQ mode */ msr cpsr_c, #0xd2 @@ -184,12 +195,8 @@ newstart2: strhi r3, [r2], #4 bhi 1b - bl main - .text -/* .global UIE*/ - /* All illegal exceptions call into UIE with exception address as first * parameter. This is calculated differently depending on which exception * we're in. Second parameter is exception number, used for a string lookup -- cgit v1.2.3