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

4.115
Last change on this file since 183af89 was 183af89, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 19:17:23

Miscellaneous - Clean up file headers so patterns followed

XXX

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