source: rtems/c/src/lib/libbsp/arm/csb336/start/start.S @ 2433a8ab

5
Last change on this file since 2433a8ab was 2433a8ab, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 7, 2017 at 1:32:42 PM

arm: Remove legacy execption support

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2 * Cogent CSB336 startup code
3 *
4 * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 * http://www.rtems.org/license/LICENSE.
9 */
10
11#include <bsp/linker-symbols.h>
12
13/* Some standard definitions...*/
14.equ PSR_MODE_USR,       0x10
15.equ PSR_MODE_FIQ,       0x11
16.equ PSR_MODE_IRQ,       0x12
17.equ PSR_MODE_SVC,       0x13
18.equ PSR_MODE_ABT,       0x17
19.equ PSR_MODE_UNDEF,     0x1B
20.equ PSR_MODE_SYS,       0x1F
21
22.equ PSR_I,              0x80
23.equ PSR_F,              0x40
24.equ PSR_T,              0x20
25
26.section .bsp_start_text,"ax"
27         .code 32
28_start_jump_at_origin:
29        ldr     pc, _start_address
30_start_address:
31        .word   _start
32
33.text
34.globl  _start
35_start:
36        /*
37         * Since I don't plan to return to the bootloader,
38         * I don't have to save the registers.
39         *
40         * I'll just set the CPSR for SVC mode, interrupts
41         * off, and ARM instructions.
42         */
43        mov     r0, #(PSR_MODE_SVC | PSR_I | PSR_F)
44        msr     cpsr, r0
45
46        /* zero the bss */
47        ldr     r1, =bsp_section_bss_end
48        ldr     r0, =bsp_section_bss_begin
49
50_bss_init:
51        mov     r2, #0
52        cmp     r0, r1
53        strlot  r2, [r0], #4
54        blo     _bss_init        /* loop while r0 < r1 */
55
56
57        /* --- Initialize stack pointer registers */
58        /* Enter IRQ mode and set up the IRQ stack pointer */
59        mov     r0, #(PSR_MODE_IRQ | PSR_I | PSR_F)     /* No interrupts */
60        msr     cpsr, r0
61        ldr     r1, =bsp_stack_irq_size
62        ldr     sp, =bsp_stack_irq_begin
63        add     sp, sp, r1
64
65        /* Enter FIQ mode and set up the FIQ stack pointer */
66        mov     r0, #(PSR_MODE_FIQ | PSR_I | PSR_F)     /* No interrupts */
67        msr     cpsr, r0
68        ldr     r1, =bsp_stack_fiq_size
69        ldr     sp, =bsp_stack_fiq_begin
70        add     sp, sp, r1
71
72        /* Enter ABT mode and set up the ABT stack pointer */
73        mov     r0, #(PSR_MODE_ABT | PSR_I | PSR_F)     /* No interrupts */
74        msr     cpsr, r0
75        ldr     r1, =bsp_stack_abt_size
76        ldr     sp, =bsp_stack_abt_begin
77        add     sp, sp, r1
78
79        /* Enter UNDEF mode and set up the UNDEF stack pointer */
80        mov     r0, #(PSR_MODE_UNDEF | PSR_I | PSR_F)     /* No interrupts */
81        msr     cpsr, r0
82        ldr     r1, =bsp_stack_und_size
83        ldr     sp, =bsp_stack_und_begin
84        add     sp, sp, r1
85
86        /* Set up the SVC stack pointer last and stay in SVC mode */
87        mov     r0, #(PSR_MODE_SVC | PSR_I | PSR_F)     /* No interrupts */
88        msr     cpsr, r0
89        ldr     r1, =bsp_stack_svc_size
90        ldr     sp, =bsp_stack_svc_begin
91        add     sp, sp, r1
92        sub     sp, sp, #0x64
93
94        /*
95         * Initialize the MMU. After we return, the MMU is enabled,
96         * and memory may be remapped. I hope we don't remap this
97         * memory away.
98         */
99        ldr     r0, =mem_map
100        bl      mmu_init
101
102        /*
103         * Initialize the exception vectors. This includes the
104         * exceptions vectors (0x00000000-0x0000001c), and the
105         * pointers to the exception handlers (0x00000020-0x0000003c).
106         */
107        mov     r0, #0
108        adr     r1, vector_block
109        ldmia   r1!, {r2-r9}
110        stmia   r0!, {r2-r9}
111        ldmia   r1!, {r2-r9}
112        stmia   r0!, {r2-r9}
113
114        /* Now we are prepared to start the BSP's C code */
115        mov     r0, #0
116        bl      boot_card
117
118        /*
119         * Theoretically, we could return to what started us up,
120         * but we'd have to have saved the registers and stacks.
121         * Instead, we'll just reset.
122         */
123        bl      bsp_reset
124
125        /* We shouldn't get here. If we do, hang */
126_hang:  b       _hang
127
128
129/*
130 * This is the exception vector table and the pointers to
131 * the functions that handle the exceptions. It's a total
132 * of 16 words (64 bytes)
133 */
134vector_block:
135        ldr    pc, handler_addr_reset
136        ldr    pc, handler_addr_undef
137        ldr    pc, handler_addr_swi
138        ldr    pc, handler_addr_prefetch
139        ldr    pc, handler_addr_abort
140        nop
141        ldr    pc, handler_addr_irq
142        ldr    pc, handler_addr_fiq
143
144handler_addr_reset:
145        .word  bsp_reset
146
147handler_addr_undef:
148        .word  _ARMV4_Exception_undef_default
149
150handler_addr_swi:
151        .word  _ARMV4_Exception_swi_default
152
153handler_addr_prefetch:
154        .word  _ARMV4_Exception_pref_abort_default
155
156handler_addr_abort:
157        .word  _ARMV4_Exception_data_abort_default
158
159handler_addr_reserved:
160        .word  _ARMV4_Exception_reserved_default
161
162handler_addr_irq:
163        .word  _ARMV4_Exception_interrupt
164
165handler_addr_fiq:
166        .word  _ARMV4_Exception_fiq_default
Note: See TracBrowser for help on using the repository browser.