From: batt Date: Mon, 29 Mar 2010 20:56:42 +0000 (+0000) Subject: Add generic ARM7TDMI crt. X-Git-Tag: 2.5.0~602 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=0bbd43b1953df23a20c6c622ea58588b526fef64;p=bertos.git Add generic ARM7TDMI crt. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3306 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/arm/hw/crt_arm7tdmi.S b/bertos/cpu/arm/hw/crt_arm7tdmi.S new file mode 100644 index 00000000..ca2e968c --- /dev/null +++ b/bertos/cpu/arm/hw/crt_arm7tdmi.S @@ -0,0 +1,152 @@ +/** + * \file + * + * + * \author Francesco Sacchi + * + * \brief ARM7TDMI CRT. + */ + +#define ARM_MODE_USR 0x10 +#define ARM_MODE_FIQ 0x11 +#define ARM_MODE_IRQ 0x12 +#define ARM_MODE_SVC 0x13 +#define ARM_MODE_ABORT 0x17 +#define ARM_MODE_UNDEF 0x1B +#define ARM_MODE_SYS 0x1F + +#define IRQ_BIT 0x80 +#define FIQ_BIT 0x40 + + +/* + * Hardware initialization. + */ + .section .init, "ax", %progbits +__init0: + /* + * Set stack pointers + */ + ldr r0, =__stack_fiq_end + msr CPSR_c, #ARM_MODE_FIQ | IRQ_BIT | FIQ_BIT + mov r13, r0 + ldr r0, =__stack_irq_end + msr CPSR_c, #ARM_MODE_IRQ | IRQ_BIT | FIQ_BIT + mov r13, r0 + ldr r0, =__stack_abt_end + msr CPSR_c, #ARM_MODE_ABORT | IRQ_BIT | FIQ_BIT + mov r13, r0 + ldr r0, =__stack_und_end + msr CPSR_c, #ARM_MODE_UNDEF | IRQ_BIT | FIQ_BIT + mov r13, r0 + ldr r0, =__stack_sys_end + msr CPSR_c, #ARM_MODE_SYS | IRQ_BIT | FIQ_BIT + mov r13, r0 + + /* + * Early hw initialization #1. + * Called before clearing .bss and + * loading .data segments. + */ + bl __init1 + + /* + * Clear .bss + */ + ldr r1, =__bss_start + ldr r2, =__bss_end + ldr r3, =0 + +bss_loop: + cmp r1, r2 + strne r3, [r1], #+4 + bne bss_loop + + /* + * Relocate .data section (Copy from ROM to RAM). + */ + ldr r1, =__etext + ldr r2, =__data_start + ldr r3, =__data_end + +data_loop: + cmp r2, r3 + ldrlo r0, [r1], #4 + strlo r0, [r2], #4 + blo data_loop + + /* + * Early hw initialization #2. + * Called after setting up .bss and .data segments + * but before calling main(). + */ + bl __init2 + + /* + * Jump to main + */ + bl main + +end: + b end + +__dummy_init: + mov pc, lr + +__xcpt_dummy_undef: + b __xcpt_dummy_undef + +__xcpt_dummy_swi: + b __xcpt_dummy_swi + +__xcpt_dummy_pref: + b __xcpt_dummy_pref + +__xcpt_dummy_dab: + b __xcpt_dummy_dab + + .weak __init1 + .set __init1, __dummy_init + .weak __init2 + .set __init2, __dummy_init + + .weak __init + .set __init, __init0 + .weak __undef + .set __undef, __xcpt_dummy_undef + .weak __swi + .set __swi, __xcpt_dummy_swi + .weak __prefetch_abort + .set __prefetch_abort, __xcpt_dummy_pref + .weak __data_abort + .set __data_abort, __xcpt_dummy_dab + + .ltorg