source: rtems/c/src/lib/libbsp/arm/gp32/start/start.S @ dfee787

4.115
Last change on this file since dfee787 was dfee787, checked in by Sebastian Huber <sebastian.huber@…>, on 12/03/10 at 10:50:52

2010-12-03 Sebastian Huber <sebastian.huber@…>

  • start/start.S, startup/linkcmds: Use linker command base file.
  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*
2 * GP32 startup code
3 *
4 *
5 * The license and distribution terms for this file may be
6 * found in the file LICENSE in this distribution or at
7 *
8 * http://www.rtems.com/license/LICENSE.
9 *
10 *
11 *  $Id$
12 */
13
14#include <bsp/linker-symbols.h>
15
16/* Some standard definitions...*/
17.equ PSR_MODE_USR,       0x10
18.equ PSR_MODE_FIQ,       0x11
19.equ PSR_MODE_IRQ,       0x12
20.equ PSR_MODE_SVC,       0x13
21.equ PSR_MODE_ABT,       0x17
22.equ PSR_MODE_UNDEF,     0x1B
23.equ PSR_MODE_SYS,       0x1F
24
25.equ PSR_I,              0x80
26.equ PSR_F,              0x40
27.equ PSR_T,              0x20
28
29.text
30.globl  _start
31_start:
32        b               _start2
33
34@---------------------------------------------------------------------------------
35@ AXF addresses
36@---------------------------------------------------------------------------------
37        .word   bsp_section_text_begin
38        .word   bsp_section_rodata_end
39        .word   bsp_section_data_begin
40        .word   bsp_section_bss_end
41        .word   bsp_section_bss_begin
42        .word   bsp_section_bss_end
43
44@---------------------------------------------------------------------------------
45@ GamePark magic sequence
46@---------------------------------------------------------------------------------
47        .word   0x44450011
48        .word   0x44450011
49        .word   0x01234567
50        .word   0x12345678
51        .word   0x23456789
52        .word   0x34567890
53        .word   0x45678901
54        .word   0x56789012
55        .word   0x23456789
56        .word   0x34567890
57        .word   0x45678901
58        .word   0x56789012
59        .word   0x23456789
60        .word   0x34567890
61        .word   0x45678901
62        .word   0x56789012
63
64@---------------------------------------------------------------------------------
65_start2:
66@---------------------------------------------------------------------------------
67
68        /*
69         * Since I don't plan to return to the bootloader,
70         * I don't have to save the registers.
71         *
72         * I'll just set the CPSR for SVC mode, interrupts
73         * off, and ARM instructions.
74         */
75        mov     r0, #(PSR_MODE_SVC | PSR_I | PSR_F)
76        msr     cpsr, r0
77
78        /* --- Initialize stack pointer registers */
79        /* Enter IRQ mode and set up the IRQ stack pointer */
80        mov     r0, #(PSR_MODE_IRQ | PSR_I | PSR_F)     /* No interrupts */
81        msr     cpsr, r0
82        ldr     r1, =bsp_stack_irq_size
83        ldr     sp, =bsp_stack_irq_begin
84        add     sp, sp, r1
85
86        /* Enter FIQ mode and set up the FIQ stack pointer */
87        mov     r0, #(PSR_MODE_FIQ | PSR_I | PSR_F)     /* No interrupts */
88        msr     cpsr, r0
89        ldr     r1, =bsp_stack_fiq_size
90        ldr     sp, =bsp_stack_fiq_begin
91        add     sp, sp, r1
92
93        /* Enter ABT mode and set up the ABT stack pointer */
94        mov     r0, #(PSR_MODE_ABT | PSR_I | PSR_F)     /* No interrupts */
95        msr     cpsr, r0
96        ldr     r1, =bsp_stack_abt_size
97        ldr     sp, =bsp_stack_abt_begin
98        add     sp, sp, r1
99
100        /* Set up the SVC stack pointer last and stay in SVC mode */
101        mov     r0, #(PSR_MODE_SVC | PSR_I | PSR_F)     /* No interrupts */
102        msr     cpsr, r0
103        ldr     r1, =bsp_stack_svc_size
104        ldr     sp, =bsp_stack_svc_begin
105        add     sp, sp, r1
106        sub     sp, sp, #0x64
107
108
109        /* disable mmu, I and D caches*/
110        nop
111        nop
112        mrc p15, 0, r0, c1, c0, 0
113        bic r0, r0, #0x01
114        bic r0, r0, #0x04
115        bic r0, r0, #0x01000
116        mcr p15, 0, r0, c1, c0, 0
117        nop
118        nop
119
120        /* clean data cache */
121        mov   r1,#0x00
122Loop1:
123        mov   r2,#0x00
124Loop2:
125        mov r3, r2, lsl#26
126        orr r3, r3, r1, lsl#5
127        mcr p15, 0, r3, c7, c14, 2
128        add r2, r2, #0x01
129        cmp r2, #64
130        bne Loop2
131        add r1, r1, #0x01
132        cmp r1, #8
133        bne Loop1
134
135
136        /*
137         * Initialize the MMU. After we return, the MMU is enabled,
138         * and memory may be remapped. I hope we don't remap this
139         * memory away.
140         */
141        ldr     r0, =mem_map
142        bl      mmu_init
143
144        /*
145         * Initialize the exception vectors. This includes the
146         * exceptions vectors (0x00000000-0x0000001c), and the
147         * pointers to the exception handlers (0x00000020-0x0000003c).
148         */
149        mov     r0, #0
150        adr     r1, vector_block
151        ldmia   r1!, {r2-r9}
152        stmia   r0!, {r2-r9}
153        ldmia   r1!, {r2-r9}
154        stmia   r0!, {r2-r9}
155
156        /* Now we are prepared to start the BSP's C code */
157        mov     r0, #0
158        bl      boot_card
159
160        /*
161         * Theoretically, we could return to what started us up,
162         * but we'd have to have saved the registers and stacks.
163         * Instead, we'll just reset.
164         */
165        bl      bsp_reset
166
167        /* We shouldn't get here. If we do, hang */
168_hang:  b       _hang
169
170
171/*
172 * This is the exception vector table and the pointers to
173 * the functions that handle the exceptions. It's a total
174 * of 16 words (64 bytes)
175 */
176vector_block:
177        ldr     pc, Reset_Handler
178        ldr     pc, Undefined_Handler
179        ldr     pc, SWI_Handler
180        ldr     pc, Prefetch_Handler
181        ldr     pc, Abort_Handler
182        nop
183        ldr     pc, IRQ_Handler
184        ldr     pc, FIQ_Handler
185
186Reset_Handler:          b       bsp_reset
187Undefined_Handler:      b       Undefined_Handler
188SWI_Handler:            b       SWI_Handler
189Prefetch_Handler:       b       Prefetch_Handler
190Abort_Handler:          b       Abort_Handler
191                        nop
192IRQ_Handler:            b       IRQ_Handler
193FIQ_Handler:            b       FIQ_Handler
194
195.globl Reset_Handler
196.globl Undefined_Handler
197.globl SWI_Handler
198.globl Prefetch_Handler
199.globl Abort_Handler
200.globl IRQ_Handler
201.globl FIQ_Handler
Note: See TracBrowser for help on using the repository browser.