diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-20 10:19:28 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-20 13:08:36 +0200 |
commit | fbcd7c8fa65eb695e96a62ea1c1ac7a024fa9dfc (patch) | |
tree | a17e285cf22cd49cd42e8b3ad562febc3987d566 /bsps/arm | |
parent | bsps: Move console drivers to bsps (diff) | |
download | rtems-fbcd7c8fa65eb695e96a62ea1c1ac7a024fa9dfc.tar.bz2 |
bsps: Move start files to bsps
This patch is a part of the BSP source reorganization.
Update #3285.
Diffstat (limited to 'bsps/arm')
-rw-r--r-- | bsps/arm/csb336/start/start.S | 166 | ||||
-rw-r--r-- | bsps/arm/csb337/start/start.S | 152 | ||||
-rw-r--r-- | bsps/arm/edb7312/start/start.S | 136 | ||||
-rw-r--r-- | bsps/arm/gumstix/start/start.S | 156 | ||||
-rw-r--r-- | bsps/arm/rtl22xx/start/start.S | 157 | ||||
-rwxr-xr-x | bsps/arm/shared/start/start.S | 462 | ||||
-rw-r--r-- | bsps/arm/smdk2410/start/start.S | 205 |
7 files changed, 1434 insertions, 0 deletions
diff --git a/bsps/arm/csb336/start/start.S b/bsps/arm/csb336/start/start.S new file mode 100644 index 0000000000..ce452f52a2 --- /dev/null +++ b/bsps/arm/csb336/start/start.S @@ -0,0 +1,166 @@ +/* + * Cogent CSB336 startup code + * + * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include <bsp/linker-symbols.h> + +/* Some standard definitions...*/ +.equ PSR_MODE_USR, 0x10 +.equ PSR_MODE_FIQ, 0x11 +.equ PSR_MODE_IRQ, 0x12 +.equ PSR_MODE_SVC, 0x13 +.equ PSR_MODE_ABT, 0x17 +.equ PSR_MODE_UNDEF, 0x1B +.equ PSR_MODE_SYS, 0x1F + +.equ PSR_I, 0x80 +.equ PSR_F, 0x40 +.equ PSR_T, 0x20 + +.section .bsp_start_text,"ax" + .code 32 +_start_jump_at_origin: + ldr pc, _start_address +_start_address: + .word _start + +.text +.globl _start +_start: + /* + * Since I don't plan to return to the bootloader, + * I don't have to save the registers. + * + * I'll just set the CPSR for SVC mode, interrupts + * off, and ARM instructions. + */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) + msr cpsr, r0 + + /* zero the bss */ + ldr r1, =bsp_section_bss_end + ldr r0, =bsp_section_bss_begin + +_bss_init: + mov r2, #0 + cmp r0, r1 + strlot r2, [r0], #4 + blo _bss_init /* loop while r0 < r1 */ + + + /* --- Initialize stack pointer registers */ + /* Enter IRQ mode and set up the IRQ stack pointer */ + mov r0, #(PSR_MODE_IRQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_irq_size + ldr sp, =bsp_stack_irq_begin + add sp, sp, r1 + + /* Enter FIQ mode and set up the FIQ stack pointer */ + mov r0, #(PSR_MODE_FIQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_fiq_size + ldr sp, =bsp_stack_fiq_begin + add sp, sp, r1 + + /* Enter ABT mode and set up the ABT stack pointer */ + mov r0, #(PSR_MODE_ABT | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_abt_size + ldr sp, =bsp_stack_abt_begin + add sp, sp, r1 + + /* Enter UNDEF mode and set up the UNDEF stack pointer */ + mov r0, #(PSR_MODE_UNDEF | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_und_size + ldr sp, =bsp_stack_und_begin + add sp, sp, r1 + + /* Set up the SVC stack pointer last and stay in SVC mode */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_svc_size + ldr sp, =bsp_stack_svc_begin + add sp, sp, r1 + sub sp, sp, #0x64 + + /* + * Initialize the MMU. After we return, the MMU is enabled, + * and memory may be remapped. I hope we don't remap this + * memory away. + */ + ldr r0, =mem_map + bl mmu_init + + /* + * Initialize the exception vectors. This includes the + * exceptions vectors (0x00000000-0x0000001c), and the + * pointers to the exception handlers (0x00000020-0x0000003c). + */ + mov r0, #0 + adr r1, vector_block + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + + /* Now we are prepared to start the BSP's C code */ + mov r0, #0 + bl boot_card + + /* + * Theoretically, we could return to what started us up, + * but we'd have to have saved the registers and stacks. + * Instead, we'll just reset. + */ + bl bsp_reset + + /* We shouldn't get here. If we do, hang */ +_hang: b _hang + + +/* + * This is the exception vector table and the pointers to + * the functions that handle the exceptions. It's a total + * of 16 words (64 bytes) + */ +vector_block: + ldr pc, handler_addr_reset + ldr pc, handler_addr_undef + ldr pc, handler_addr_swi + ldr pc, handler_addr_prefetch + ldr pc, handler_addr_abort + nop + ldr pc, handler_addr_irq + ldr pc, handler_addr_fiq + +handler_addr_reset: + .word bsp_reset + +handler_addr_undef: + .word _ARMV4_Exception_undef_default + +handler_addr_swi: + .word _ARMV4_Exception_swi_default + +handler_addr_prefetch: + .word _ARMV4_Exception_pref_abort_default + +handler_addr_abort: + .word _ARMV4_Exception_data_abort_default + +handler_addr_reserved: + .word _ARMV4_Exception_reserved_default + +handler_addr_irq: + .word _ARMV4_Exception_interrupt + +handler_addr_fiq: + .word _ARMV4_Exception_fiq_default diff --git a/bsps/arm/csb337/start/start.S b/bsps/arm/csb337/start/start.S new file mode 100644 index 0000000000..f88cf41d78 --- /dev/null +++ b/bsps/arm/csb337/start/start.S @@ -0,0 +1,152 @@ +/* + * Cogent CSB337 startup code + * + * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. +*/ + +#include <bsp/linker-symbols.h> + +/* Some standard definitions...*/ +.equ PSR_MODE_USR, 0x10 +.equ PSR_MODE_FIQ, 0x11 +.equ PSR_MODE_IRQ, 0x12 +.equ PSR_MODE_SVC, 0x13 +.equ PSR_MODE_ABT, 0x17 +.equ PSR_MODE_UNDEF, 0x1B +.equ PSR_MODE_SYS, 0x1F + +.equ PSR_I, 0x80 +.equ PSR_F, 0x40 +.equ PSR_T, 0x20 + +.text +.globl _start +_start: + /* + * Since I don't plan to return to the bootloader, + * I don't have to save the registers. + * + * I'll just set the CPSR for SVC mode, interrupts + * off, and ARM instructions. + */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) + msr cpsr, r0 + + /* zero the bss */ + ldr r1, =bsp_section_bss_end + ldr r0, =bsp_section_bss_begin + +_bss_init: + mov r2, #0 + cmp r0, r1 + strlot r2, [r0], #4 + blo _bss_init /* loop while r0 < r1 */ + + + /* --- Initialize stack pointer registers */ + /* Enter IRQ mode and set up the IRQ stack pointer */ + mov r0, #(PSR_MODE_IRQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_irq_size + ldr sp, =bsp_stack_irq_begin + add sp, sp, r1 + + /* Enter FIQ mode and set up the FIQ stack pointer */ + mov r0, #(PSR_MODE_FIQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_fiq_size + ldr sp, =bsp_stack_fiq_begin + add sp, sp, r1 + + /* Enter ABT mode and set up the ABT stack pointer */ + mov r0, #(PSR_MODE_ABT | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_abt_size + ldr sp, =bsp_stack_abt_begin + add sp, sp, r1 + + /* Set up the SVC stack pointer last and stay in SVC mode */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_svc_size + ldr sp, =bsp_stack_svc_begin + add sp, sp, r1 + sub sp, sp, #0x64 + + /* + * Initialize the MMU. After we return, the MMU is enabled, + * and memory may be remapped. I hope we don't remap this + * memory away. + */ + ldr r0, =mem_map + bl mmu_init + + /* + * Initialize the exception vectors. This includes the + * exceptions vectors (0x00000000-0x0000001c), and the + * pointers to the exception handlers (0x00000020-0x0000003c). + */ + mov r0, #0 + adr r1, vector_block + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + + /* Now we are prepared to start the BSP's C code */ + mov r0, #0 + bl boot_card + + /* + * Theoretically, we could return to what started us up, + * but we'd have to have saved the registers and stacks. + * Instead, we'll just reset. + */ + bl bsp_reset + + /* We shouldn't get here. If we do, hang */ +_hang: b _hang + + +/* + * This is the exception vector table and the pointers to + * the functions that handle the exceptions. It's a total + * of 16 words (64 bytes) + */ +vector_block: + ldr pc, handler_addr_reset + ldr pc, handler_addr_undef + ldr pc, handler_addr_swi + ldr pc, handler_addr_prefetch + ldr pc, handler_addr_abort + nop + ldr pc, handler_addr_irq + ldr pc, handler_addr_fiq + +handler_addr_reset: + .word bsp_reset + +handler_addr_undef: + .word _ARMV4_Exception_undef_default + +handler_addr_swi: + .word _ARMV4_Exception_swi_default + +handler_addr_prefetch: + .word _ARMV4_Exception_pref_abort_default + +handler_addr_abort: + .word _ARMV4_Exception_data_abort_default + +handler_addr_reserved: + .word _ARMV4_Exception_reserved_default + +handler_addr_irq: + .word _ARMV4_Exception_interrupt + +handler_addr_fiq: + .word _ARMV4_Exception_fiq_default diff --git a/bsps/arm/edb7312/start/start.S b/bsps/arm/edb7312/start/start.S new file mode 100644 index 0000000000..e03707bfcf --- /dev/null +++ b/bsps/arm/edb7312/start/start.S @@ -0,0 +1,136 @@ +/* + * Cirrus EP7312 Startup code + * + * Copyright (c) 2010 embedded brains GmbH. + * + * Copyright (c) 2002 by Jay Monkman <jtm@smoothsmoothie.com> + * + * Copyright (c) 2002 by Charlie Steader <charlies@poliac.com> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. +*/ + +#include <bsp/linker-symbols.h> + +/* Some standard definitions...*/ + +.equ Mode_USR, 0x10 +.equ Mode_FIQ, 0x11 +.equ Mode_IRQ, 0x12 +.equ Mode_SVC, 0x13 +.equ Mode_ABT, 0x17 +.equ Mode_ABORT, 0x17 +.equ Mode_UNDEF, 0x1B +.equ Mode_SYS, 0x1F /*only available on ARM Arch. v4*/ + +.equ I_Bit, 0x80 +.equ F_Bit, 0x40 + +.section ".bsp_start_text", "ax" +.arm + +/******************************************************* + standard exception vectors table + *** Must be located at address 0 +********************************************************/ + +Vector_Init_Block: + ldr pc, handler_addr_reset + ldr pc, handler_addr_undef + ldr pc, handler_addr_swi + ldr pc, handler_addr_prefetch + ldr pc, handler_addr_abort + nop + ldr pc, handler_addr_irq + ldr pc, handler_addr_fiq + +handler_addr_reset: + .word _start + +handler_addr_undef: + .word _ARMV4_Exception_undef_default + +handler_addr_swi: + .word _ARMV4_Exception_swi_default + +handler_addr_prefetch: + .word _ARMV4_Exception_pref_abort_default + +handler_addr_abort: + .word _ARMV4_Exception_data_abort_default + +handler_addr_reserved: + .word _ARMV4_Exception_reserved_default + +handler_addr_irq: + .word _ARMV4_Exception_interrupt + +handler_addr_fiq: + .word _ARMV4_Exception_fiq_default + + .globl _start +_start: + /* store the sp */ + mov r12, sp +/* + * Here is the code to initialize the low-level BSP environment + * (Chip Select, PLL, ....?) + */ + +/* zero the bss */ + LDR r1, =bsp_section_bss_end /* get end of ZI region */ + LDR r0, =bsp_section_bss_begin /* load base address of ZI region */ + +zi_init: + MOV r2, #0 + CMP r0, r1 /* loop whilst r0 < r1 */ + STRLOT r2, [r0], #4 + BLO zi_init + +/* --- Initialise stack pointer registers */ + +/* Enter IRQ mode and set up the IRQ stack pointer */ + MOV r0, #Mode_IRQ | I_Bit | F_Bit /* No interrupts */ + MSR cpsr, r0 + ldr r1, =bsp_stack_irq_size + LDR sp, =bsp_stack_irq_begin + add sp, sp, r1 + sub sp, sp, #0x64 + +/* Enter FIQ mode and set up the FIQ stack pointer */ + MOV r0, #Mode_FIQ | I_Bit | F_Bit /* No interrupts */ + MSR cpsr, r0 + ldr r1, =bsp_stack_fiq_size + LDR sp, =bsp_stack_fiq_begin + add sp, sp, r1 + sub sp, sp, #0x64 + +/* Enter ABT mode and set up the ABT stack pointer */ + MOV r0, #Mode_ABT | I_Bit | F_Bit /* No interrupts */ + MSR cpsr, r0 + ldr r1, =bsp_stack_abt_size + LDR sp, =bsp_stack_abt_begin + add sp, sp, r1 + sub sp, sp, #0x64 + +/* Set up the SVC stack pointer last and stay in SVC mode */ + MOV r0, #Mode_SVC | I_Bit | F_Bit /* No interrupts */ + MSR cpsr, r0 + ldr r1, =bsp_stack_svc_size + LDR sp, =bsp_stack_svc_begin + add sp, sp, r1 + sub sp, sp, #0x64 + + /* save the original registers */ + stmdb sp!, {r4-r12, lr} + +/* --- Now we enter the C code */ + + mov r0, #0 + bl boot_card + + ldmia sp!, {r4-r12, lr} + mov sp, r12 + mov pc, lr diff --git a/bsps/arm/gumstix/start/start.S b/bsps/arm/gumstix/start/start.S new file mode 100644 index 0000000000..dccc99993e --- /dev/null +++ b/bsps/arm/gumstix/start/start.S @@ -0,0 +1,156 @@ +/* + * By Yang Xi <hiyangxi@gmail.com>. + * Based upon CSB337 + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include <bsp/linker-symbols.h> + +/* Some standard definitions...*/ +.equ PSR_MODE_USR, 0x10 +.equ PSR_MODE_FIQ, 0x11 +.equ PSR_MODE_IRQ, 0x12 +.equ PSR_MODE_SVC, 0x13 +.equ PSR_MODE_ABT, 0x17 +.equ PSR_MODE_UNDEF, 0x1B +.equ PSR_MODE_SYS, 0x1F + +.equ PSR_I, 0x80 +.equ PSR_F, 0x40 +.equ PSR_T, 0x20 + +.text +.globl _start +_start: + /* + * Since I don't plan to return to the bootloader, + * I don't have to save the registers. + * + * I'll just set the CPSR for SVC mode, interrupts + * off, and ARM instructions. + */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) + msr cpsr, r0 + + + /* zero the bss */ + ldr r1, =bsp_section_bss_end + ldr r0, =bsp_section_bss_begin + +_bss_init: + mov r2, #0 + cmp r0, r1 + strlot r2, [r0], #4 + blo _bss_init /* loop while r0 < r1 */ + + /* --- Initialize stack pointer registers */ + /* Enter IRQ mode and set up the IRQ stack pointer */ + mov r0, #(PSR_MODE_IRQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_irq_size + ldr sp, =bsp_stack_irq_begin + add sp, sp, r1 + + /* Enter FIQ mode and set up the FIQ stack pointer */ + mov r0, #(PSR_MODE_FIQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_fiq_size + ldr sp, =bsp_stack_fiq_begin + add sp, sp, r1 + + /* Enter ABT mode and set up the ABT stack pointer */ + mov r0, #(PSR_MODE_ABT | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_abt_size + ldr sp, =bsp_stack_abt_begin + add sp, sp, r1 + + /* Set up the SVC stack pointer last and stay in SVC mode */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_und_size + ldr sp, =bsp_stack_und_begin + add sp, sp, r1 + sub sp, sp, #0x64 + + /* + * Initialize the MMU. After we return, the MMU is enabled, + * and memory may be remapped. I hope we don't remap this + * memory away. + */ + + ldr r0, =mem_map + bl mmu_init + + + + /* + * Initialize the exception vectors. This includes the + * exceptions vectors (0x00000000-0x0000001c), and the + * pointers to the exception handlers (0x00000020-0x0000003c). + */ + mov r0, #0 + adr r1, vector_block + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + + + + /* Now we are prepared to start the BSP's C code */ + mov r0, #0 + bl boot_card + + /* + * Theoretically, we could return to what started us up, + * but we'd have to have saved the registers and stacks. + * Instead, we'll just reset. + */ + bl bsp_reset + + /* We shouldn't get here. If we do, hang */ +_hang: b _hang + + +/* + * This is the exception vector table and the pointers to + * the functions that handle the exceptions. It's a total + * of 16 words (64 bytes) + */ +vector_block: + ldr pc, handler_addr_reset + ldr pc, handler_addr_undef + ldr pc, handler_addr_swi + ldr pc, handler_addr_prefetch + ldr pc, handler_addr_abort + nop + ldr pc, handler_addr_irq + ldr pc, handler_addr_fiq + +handler_addr_reset: + .word bsp_reset + +handler_addr_undef: + .word _ARMV4_Exception_undef_default + +handler_addr_swi: + .word _ARMV4_Exception_swi_default + +handler_addr_prefetch: + .word _ARMV4_Exception_pref_abort_default + +handler_addr_abort: + .word _ARMV4_Exception_data_abort_default + +handler_addr_reserved: + .word _ARMV4_Exception_reserved_default + +handler_addr_irq: + .word _ARMV4_Exception_interrupt + +handler_addr_fiq: + .word _ARMV4_Exception_fiq_default diff --git a/bsps/arm/rtl22xx/start/start.S b/bsps/arm/rtl22xx/start/start.S new file mode 100644 index 0000000000..c038198aff --- /dev/null +++ b/bsps/arm/rtl22xx/start/start.S @@ -0,0 +1,157 @@ +/* + * Philips LPC22XX/LPC21xx Startup code + * + * Copyright (c) 2007 Ray Xu<rayx.cn@gmail.com> + * Change from CSB337's code by Jay Monkman <jtm@lopingdog.com> + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. +*/ + +#include <bsp/linker-symbols.h> + +/* Some standard definitions...*/ +.equ PSR_MODE_USR, 0x10 +.equ PSR_MODE_FIQ, 0x11 +.equ PSR_MODE_IRQ, 0x12 +.equ PSR_MODE_SVC, 0x13 +.equ PSR_MODE_ABT, 0x17 +.equ PSR_MODE_UNDEF, 0x1B +.equ PSR_MODE_SYS, 0x1F + +.equ PSR_I, 0x80 +.equ PSR_F, 0x40 +.equ PSR_T, 0x20 + +.text +.code 32 +.globl _start +_start: + /* + * Since I don't plan to return to the bootloader, + * I don't have to save the registers. + * + * I'll just set the CPSR for SVC mode, interrupts + * off, and ARM instructions. + */ + + /* --- Initialize stack pointer registers */ + /* Enter IRQ mode and set up the IRQ stack pointer */ + mov r0, #(PSR_MODE_IRQ | PSR_I | PSR_F) /* No interrupts */ + bic r0, r0, #PSR_T + msr cpsr, r0 + ldr r1, =bsp_stack_irq_size + ldr sp, =bsp_stack_irq_begin + add sp, sp, r1 + + /* Enter FIQ mode and set up the FIQ stack pointer */ + mov r0, #(PSR_MODE_FIQ | PSR_I | PSR_F) /* No interrupts */ + bic r0, r0, #PSR_T + msr cpsr, r0 + ldr r1, =bsp_stack_fiq_size + ldr sp, =bsp_stack_fiq_begin + add sp, sp, r1 + + /* Enter ABT mode and set up the ABT stack pointer */ + mov r0, #(PSR_MODE_ABT | PSR_I | PSR_F) /* No interrupts */ + bic r0, r0, #PSR_T + msr cpsr, r0 + bic r0, r0, #PSR_T + ldr r1, =bsp_stack_abt_size + ldr sp, =bsp_stack_abt_begin + add sp, sp, r1 + + /* Set up the SVC stack pointer last and stay in SVC mode */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) /* No interrupts */ + bic r0, r0, #PSR_T + msr cpsr, r0 + ldr r1, =bsp_stack_svc_size + ldr sp, =bsp_stack_svc_begin + add sp, sp, r1 + sub sp, sp, #0x64 + + /* + * Initialize the exception vectors. This includes the + * exceptions vectors (0x00000000-0x0000001c), and the + * pointers to the exception handlers (0x00000020-0x0000003c). + */ + mov r0, #0 + adr r1, vector_block + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + + + /* zero the bss */ + ldr r1, =bsp_section_bss_end + ldr r0, =bsp_section_bss_begin + +_bss_init: + mov r2, #0 + cmp r0, r1 + strlot r2, [r0], #4 + blo _bss_init /* loop while r0 < r1 */ + + + /* Now we are prepared to start the BSP's C code */ + mov r0, #0 +#ifdef __thumb__ + ldr r3, =boot_card + bx r3 +#else + bl boot_card + + + /* + * Theoretically, we could return to what started us up, + * but we'd have to have saved the registers and stacks. + * Instead, we'll just reset. + */ + bl bsp_reset +#endif + .code 32 + + /* We shouldn't get here. If we do, hang */ +_hang: b _hang + + +/******************************************************* + standard exception vectors table + *** Must be located at address 0 +********************************************************/ + +vector_block: + ldr pc, handler_addr_reset + ldr pc, handler_addr_undef + ldr pc, handler_addr_swi + ldr pc, handler_addr_prefetch + ldr pc, handler_addr_abort + nop + ldr pc, handler_addr_irq + ldr pc, handler_addr_fiq + +handler_addr_reset: + .word _start + +handler_addr_undef: + .word _ARMV4_Exception_undef_default + +handler_addr_swi: + .word _ARMV4_Exception_swi_default + +handler_addr_prefetch: + .word _ARMV4_Exception_pref_abort_default + +handler_addr_abort: + .word _ARMV4_Exception_data_abort_default + +handler_addr_reserved: + .word _ARMV4_Exception_reserved_default + +handler_addr_irq: + .word _ARMV4_Exception_interrupt + +handler_addr_fiq: + .word _ARMV4_Exception_fiq_default diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S new file mode 100755 index 0000000000..aa0f3782c9 --- /dev/null +++ b/bsps/arm/shared/start/start.S @@ -0,0 +1,462 @@ +/** + * @file + * + * @brief Boot and system start code. + */ + +/* + * Copyright (c) 2008, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include <rtems/asm.h> +#include <rtems/system.h> +#include <rtems/score/percpu.h> + +#include <bspopts.h> +#include <bsp/irq.h> +#include <bsp/linker-symbols.h> + + /* External symbols */ + .extern bsp_reset + .extern boot_card + .extern bsp_start_hook_0 + .extern bsp_start_hook_1 + .extern bsp_stack_irq_end + .extern bsp_stack_fiq_end + .extern bsp_stack_abt_end + .extern bsp_stack_und_end + .extern bsp_stack_svc_end +#ifdef RTEMS_SMP + .extern bsp_stack_all_size +#endif + .extern _ARMV4_Exception_undef_default + .extern _ARMV4_Exception_swi_default + .extern _ARMV4_Exception_data_abort_default + .extern _ARMV4_Exception_pref_abort_default + .extern _ARMV4_Exception_reserved_default + .extern _ARMV4_Exception_interrupt + .extern _ARMV4_Exception_fiq_default + .extern _ARMV7M_Exception_default + +#ifdef BSP_START_NEEDS_REGISTER_INITIALIZATION + .extern bsp_start_init_registers_core + .extern bsp_start_init_registers_banked_fiq + .extern bsp_start_init_registers_vfp +#endif + +#ifdef BSP_START_IN_HYP_SUPPORT + .extern bsp_start_arm_drop_hyp_mode + .globl bsp_start_hyp_vector_table_begin +#endif + + /* Global symbols */ + .globl _start + .globl bsp_start_vector_table_begin + .globl bsp_start_vector_table_end + .globl bsp_start_vector_table_size + .globl bsp_vector_table_size + .globl bsp_start_hook_0_done + + .section ".bsp_start_text", "ax" + +#if defined(ARM_MULTILIB_ARCH_V4) + + .arm + +/* + * This is the exception vector table and the pointers to the default + * exceptions handlers. + */ + +bsp_start_vector_table_begin: + + ldr pc, handler_addr_reset + ldr pc, handler_addr_undef + ldr pc, handler_addr_swi + ldr pc, handler_addr_prefetch + ldr pc, handler_addr_abort + + /* Program signature checked by boot loader */ + .word 0xb8a06f58 + + ldr pc, handler_addr_irq + ldr pc, handler_addr_fiq + +handler_addr_reset: + +#ifdef BSP_START_RESET_VECTOR + .word BSP_START_RESET_VECTOR +#else + .word _start +#endif + +handler_addr_undef: + + .word _ARMV4_Exception_undef_default + +handler_addr_swi: + + .word _ARMV4_Exception_swi_default + +handler_addr_prefetch: + + .word _ARMV4_Exception_pref_abort_default + +handler_addr_abort: + + .word _ARMV4_Exception_data_abort_default + +handler_addr_reserved: + + .word _ARMV4_Exception_reserved_default + +handler_addr_irq: + + .word _ARMV4_Exception_interrupt + +handler_addr_fiq: + + .word _ARMV4_Exception_fiq_default + +bsp_start_vector_table_end: + +#ifdef BSP_START_IN_HYP_SUPPORT +bsp_start_hyp_vector_table_begin: + ldr pc, handler_addr_hyp_reset + ldr pc, handler_addr_hyp_undef + ldr pc, handler_addr_hyp_swi + ldr pc, handler_addr_hyp_prefetch + ldr pc, handler_addr_hyp_abort + ldr pc, handler_addr_hyp_hyp + ldr pc, handler_addr_hyp_irq + ldr pc, handler_addr_hyp_fiq + +handler_addr_hyp_reset: + .word _ARMV4_Exception_reserved_default + +handler_addr_hyp_undef: + .word _ARMV4_Exception_reserved_default + +handler_addr_hyp_swi: + .word _ARMV4_Exception_reserved_default + +handler_addr_hyp_prefetch: + .word _ARMV4_Exception_reserved_default + +handler_addr_hyp_abort: + .word _ARMV4_Exception_reserved_default + +handler_addr_hyp_hyp: + .word _ARMV4_Exception_reserved_default + +handler_addr_hyp_irq: + .word _ARMV4_Exception_reserved_default + +handler_addr_hyp_fiq: + .word _ARMV4_Exception_reserved_default + +bsp_start_hyp_vector_table_end: +#endif + +/* Start entry */ + +_start: + + /* + * We do not save the context since we do not return to the boot + * loader but preserve r1 and r2 to allow access to bootloader parameters + */ +#ifndef BSP_START_NEEDS_REGISTER_INITIALIZATION + mov r5, r1 /* machine type number or ~0 for DT boot */ + mov r6, r2 /* physical address of ATAGs or DTB */ +#else /* BSP_START_NEEDS_REGISTER_INITIALIZATION */ + bl bsp_start_init_registers_core +#endif + +#ifdef RTEMS_SMP + /* Read MPIDR and get current processor index */ + mrc p15, 0, r7, c0, c0, 5 + and r7, #0xff +#endif + +#ifdef BSP_START_COPY_FDT_FROM_U_BOOT +#ifdef RTEMS_SMP + cmp r7, #0 + bne 1f +#endif + mov r0, r6 + bl bsp_fdt_copy +1: +#endif + +#ifdef RTEMS_SMP + /* + * Get current per-CPU control and store it in PL1 only Thread ID + * Register (TPIDRPRW). + */ + ldr r1, =_Per_CPU_Information + add r1, r1, r7, asl #PER_CPU_CONTROL_SIZE_LOG2 + mcr p15, 0, r1, c13, c0, 4 + + /* Calculate stack offset */ + ldr r1, =bsp_stack_all_size + mul r1, r7 +#endif + + mrs r4, cpsr /* save original procesor status value */ +#ifdef BSP_START_IN_HYP_SUPPORT + orr r0, r4, #(ARM_PSR_I | ARM_PSR_F) + msr cpsr, r4 + + and r0, r4, #ARM_PSR_M_MASK + cmp r0, #ARM_PSR_M_HYP + bne bsp_start_skip_hyp_svc_switch + + /* Boot loader stats kernel in HYP mode, switch to SVC necessary */ + ldr sp, =bsp_stack_hyp_end +#ifdef RTEMS_SMP + add sp, r1 +#endif + bl bsp_start_arm_drop_hyp_mode + +bsp_start_skip_hyp_svc_switch: +#endif + /* + * Set SVC mode, disable interrupts and enable ARM instructions. + */ + mov r0, #(ARM_PSR_M_SVC | ARM_PSR_I | ARM_PSR_F) + msr cpsr, r0 + + /* Initialize stack pointer registers for the various modes */ + + /* Enter IRQ mode and set up the IRQ stack pointer */ + mov r0, #(ARM_PSR_M_IRQ | ARM_PSR_I | ARM_PSR_F) + msr cpsr, r0 + ldr sp, =bsp_stack_irq_end +#ifdef RTEMS_SMP + add sp, r1 +#endif + + /* Enter FIQ mode and set up the FIQ stack pointer */ + mov r0, #(ARM_PSR_M_FIQ | ARM_PSR_I | ARM_PSR_F) + msr cpsr, r0 + ldr sp, =bsp_stack_fiq_end +#ifdef RTEMS_SMP + add sp, r1 +#endif + +#ifdef BSP_START_NEEDS_REGISTER_INITIALIZATION + bl bsp_start_init_registers_banked_fiq +#endif + + /* Enter ABT mode and set up the ABT stack pointer */ + mov r0, #(ARM_PSR_M_ABT | ARM_PSR_I | ARM_PSR_F) + msr cpsr, r0 + ldr sp, =bsp_stack_abt_end +#ifdef RTEMS_SMP + add sp, r1 +#endif + + /* Enter UND mode and set up the UND stack pointer */ + mov r0, #(ARM_PSR_M_UND | ARM_PSR_I | ARM_PSR_F) + msr cpsr, r0 + ldr sp, =bsp_stack_und_end +#ifdef RTEMS_SMP + add sp, r1 +#endif + + /* Enter SVC mode and set up the SVC stack pointer */ + mov r0, #(ARM_PSR_M_SVC | ARM_PSR_I | ARM_PSR_F) + msr cpsr, r0 + ldr sp, =bsp_stack_svc_end +#ifdef RTEMS_SMP + add sp, r1 +#endif + + /* Stay in SVC mode */ + +#ifdef ARM_MULTILIB_VFP +#ifdef ARM_MULTILIB_HAS_CPACR + /* Read CPACR */ + mrc p15, 0, r0, c1, c0, 2 + + /* Enable CP10 and CP11 */ + orr r0, r0, #(1 << 20) + orr r0, r0, #(1 << 22) + + /* + * Clear ASEDIS and D32DIS. Writes to D32DIS are ignored for VFP-D16. + */ + bic r0, r0, #(3 << 30) + + /* Write CPACR */ + mcr p15, 0, r0, c1, c0, 2 + isb +#endif + + /* Enable FPU */ + mov r0, #(1 << 30) + vmsr FPEXC, r0 + +#ifdef BSP_START_NEEDS_REGISTER_INITIALIZATION + bl bsp_start_init_registers_vfp +#endif + +#endif /* ARM_MULTILIB_VFP */ + + /* + * Branch to start hook 0. + * + * The previous code and parts of the start hook 0 may run with an + * address offset. This implies that only branches relative to the + * program counter are allowed. After the start hook 0 it is assumed + * that the code can run at its intended position. Thus the link + * register will be loaded with the absolute address. In THUMB mode + * the start hook 0 must be within a 2kByte range due to the branch + * instruction limitation. + */ + + ldr lr, =bsp_start_hook_0_done +#ifdef __thumb__ + orr lr, #1 +#endif + + SWITCH_FROM_ARM_TO_THUMB r0 + + mov r0, r4 /* original cpsr value */ + mov r1, r5 /* machine type number or ~0 for DT boot */ + mov r2, r6 /* physical address of ATAGs or DTB */ + + b bsp_start_hook_0 + +bsp_start_hook_0_done: + + SWITCH_FROM_THUMB_TO_ARM + + /* + * Initialize the exception vectors. This includes the exceptions + * vectors and the pointers to the default exception handlers. + */ + + stmdb sp!, {r4, r5, r6} + + ldr r0, =bsp_vector_table_begin + adr r1, bsp_start_vector_table_begin + cmp r0, r1 + beq bsp_vector_table_copy_done + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + +bsp_vector_table_copy_done: + + ldmia sp!, {r0, r1, r2} + + SWITCH_FROM_ARM_TO_THUMB r3 + + /* Branch to start hook 1 */ + bl bsp_start_hook_1 + + /* Branch to boot card */ + mov r0, #0 + bl boot_card + +twiddle: + + /* Branch to reset function */ + bl bsp_reset + + b twiddle + +#elif defined(ARM_MULTILIB_ARCH_V7M) + +#include <rtems/score/armv7m.h> + + .syntax unified + + .extern bsp_stack_main_end + + .thumb + +bsp_start_vector_table_begin: + + .word bsp_stack_main_end + .word _start /* Reset */ + .word _ARMV7M_Exception_default /* NMI */ + .word _ARMV7M_Exception_default /* Hard Fault */ + .word _ARMV7M_Exception_default /* MPU Fault */ + .word _ARMV7M_Exception_default /* Bus Fault */ + .word _ARMV7M_Exception_default /* Usage Fault */ + .word _ARMV7M_Exception_default /* Reserved */ + .word _ARMV7M_Exception_default /* Reserved */ + .word _ARMV7M_Exception_default /* Reserved */ + .word _ARMV7M_Exception_default /* Reserved */ + .word _ARMV7M_Exception_default /* SVC */ + .word _ARMV7M_Exception_default /* Debug Monitor */ + .word _ARMV7M_Exception_default /* Reserved */ + .word _ARMV7M_Exception_default /* PendSV */ + .word _ARMV7M_Exception_default /* SysTick */ + .rept BSP_INTERRUPT_VECTOR_MAX + 1 + .word _ARMV7M_Exception_default /* IRQ */ + .endr + +bsp_start_vector_table_end: + + .thumb_func + +_start: + +#ifdef BSP_START_NEEDS_REGISTER_INITIALIZATION + bl bsp_start_init_registers_core +#endif + +#ifdef ARM_MULTILIB_VFP +#ifdef ARM_MULTILIB_HAS_CPACR + /* + * Enable CP10 and CP11 coprocessors for privileged and user mode in + * CPACR (bits 20-23). Ensure that write to register completes. + */ + ldr r0, =ARMV7M_CPACR + ldr r1, [r0] + orr r1, r1, #(0xf << 20) + str r1, [r0] + dsb + isb +#endif + +#ifdef BSP_START_NEEDS_REGISTER_INITIALIZATION + bl bsp_start_init_registers_vfp +#endif + +#endif /* ARM_MULTILIB_VFP */ + + ldr sp, =bsp_stack_main_end + ldr lr, =bsp_start_hook_0_done + 1 + b bsp_start_hook_0 + +bsp_start_hook_0_done: + + bl bsp_start_hook_1 + movs r0, #0 + bl boot_card + +twiddle: + + bl bsp_reset + b twiddle + +#endif /* defined(ARM_MULTILIB_ARCH_V7M) */ + + .set bsp_start_vector_table_size, bsp_start_vector_table_end - bsp_start_vector_table_begin + .set bsp_vector_table_size, bsp_start_vector_table_size diff --git a/bsps/arm/smdk2410/start/start.S b/bsps/arm/smdk2410/start/start.S new file mode 100644 index 0000000000..95d781cb89 --- /dev/null +++ b/bsps/arm/smdk2410/start/start.S @@ -0,0 +1,205 @@ +/* + * SMDK2410 startup code + */ + +/* + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include <bsp/linker-symbols.h> + +/* Some standard definitions...*/ +.equ PSR_MODE_USR, 0x10 +.equ PSR_MODE_FIQ, 0x11 +.equ PSR_MODE_IRQ, 0x12 +.equ PSR_MODE_SVC, 0x13 +.equ PSR_MODE_ABT, 0x17 +.equ PSR_MODE_UNDEF, 0x1B +.equ PSR_MODE_SYS, 0x1F + +.equ PSR_I, 0x80 +.equ PSR_F, 0x40 +.equ PSR_T, 0x20 + +.text +.globl _start +_start: + b _start2 + +@--------------------------------------------------------------------------------- +@ AXF addresses +@--------------------------------------------------------------------------------- + .word bsp_section_text_begin + .word bsp_section_rodata_end + .word bsp_section_data_begin + .word bsp_section_bss_end + .word bsp_section_bss_begin + .word bsp_section_bss_end + +@--------------------------------------------------------------------------------- +@ GamePark magic sequence +@--------------------------------------------------------------------------------- + .word 0x44450011 + .word 0x44450011 + .word 0x01234567 + .word 0x12345678 + .word 0x23456789 + .word 0x34567890 + .word 0x45678901 + .word 0x56789012 + .word 0x23456789 + .word 0x34567890 + .word 0x45678901 + .word 0x56789012 + .word 0x23456789 + .word 0x34567890 + .word 0x45678901 + .word 0x56789012 + +@--------------------------------------------------------------------------------- +_start2: +@--------------------------------------------------------------------------------- + + /* + * Since I don't plan to return to the bootloader, + * I don't have to save the registers. + * + * I'll just set the CPSR for SVC mode, interrupts + * off, and ARM instructions. + */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) + msr cpsr, r0 + + /* --- Initialize stack pointer registers */ + /* Enter IRQ mode and set up the IRQ stack pointer */ + mov r0, #(PSR_MODE_IRQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_irq_size + ldr sp, =bsp_stack_irq_begin + add sp, sp, r1 + + /* Enter FIQ mode and set up the FIQ stack pointer */ + mov r0, #(PSR_MODE_FIQ | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_fiq_size + ldr sp, =bsp_stack_fiq_begin + add sp, sp, r1 + + /* Enter ABT mode and set up the ABT stack pointer */ + mov r0, #(PSR_MODE_ABT | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_abt_size + ldr sp, =bsp_stack_abt_begin + add sp, sp, r1 + + /* Set up the SVC stack pointer last and stay in SVC mode */ + mov r0, #(PSR_MODE_SVC | PSR_I | PSR_F) /* No interrupts */ + msr cpsr, r0 + ldr r1, =bsp_stack_svc_size + ldr sp, =bsp_stack_svc_begin + add sp, sp, r1 + sub sp, sp, #0x64 + + + /* disable mmu, I and D caches*/ + nop + nop + mrc p15, 0, r0, c1, c0, 0 + bic r0, r0, #0x01 + bic r0, r0, #0x04 + bic r0, r0, #0x01000 + mcr p15, 0, r0, c1, c0, 0 + nop + nop + + /* clean data cache */ + mov r1,#0x00 +Loop1: + mov r2,#0x00 +Loop2: + mov r3, r2, lsl#26 + orr r3, r3, r1, lsl#5 + mcr p15, 0, r3, c7, c14, 2 + add r2, r2, #0x01 + cmp r2, #64 + bne Loop2 + add r1, r1, #0x01 + cmp r1, #8 + bne Loop1 + + + /* + * Initialize the MMU. After we return, the MMU is enabled, + * and memory may be remapped. I hope we don't remap this + * memory away. + */ + ldr r0, =mem_map + bl mmu_init + + /* + * Initialize the exception vectors. This includes the + * exceptions vectors (0x00000000-0x0000001c), and the + * pointers to the exception handlers (0x00000020-0x0000003c). + */ + mov r0, #0 + adr r1, vector_block + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + ldmia r1!, {r2-r9} + stmia r0!, {r2-r9} + + /* Now we are prepared to start the BSP's C code */ + mov r0, #0 + bl boot_card + + /* + * Theoretically, we could return to what started us up, + * but we'd have to have saved the registers and stacks. + * Instead, we'll just reset. + */ + bl bsp_reset + + /* We shouldn't get here. If we do, hang */ +_hang: b _hang + + +/* + * This is the exception vector table and the pointers to + * the functions that handle the exceptions. It's a total + * of 16 words (64 bytes) + */ +vector_block: + ldr pc, handler_addr_reset + ldr pc, handler_addr_undef + ldr pc, handler_addr_swi + ldr pc, handler_addr_prefetch + ldr pc, handler_addr_abort + nop + ldr pc, handler_addr_irq + ldr pc, handler_addr_fiq + +handler_addr_reset: + .word bsp_reset + +handler_addr_undef: + .word _ARMV4_Exception_undef_default + +handler_addr_swi: + .word _ARMV4_Exception_swi_default + +handler_addr_prefetch: + .word _ARMV4_Exception_pref_abort_default + +handler_addr_abort: + .word _ARMV4_Exception_data_abort_default + +handler_addr_reserved: + .word _ARMV4_Exception_reserved_default + +handler_addr_irq: + .word _ARMV4_Exception_interrupt + +handler_addr_fiq: + .word _ARMV4_Exception_fiq_default |