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

4.104.114.84.95
Last change on this file since 34c4852 was e8c785c6, checked in by Jay Monkman <jtm@…>, on 03/11/05 at 07:27:56

2005-03-11 Philippe Simons <loki_666@…>

  • acinclude.m4: Added gp32 BSP.
  • gp32/.cvsignore, gp32/Makefile.am, gp32/README, gp32/bsp_specs, gp32/configure.ac, gp32/console/.cvsignore, gp32/console/conio.c, gp32/console/console.c, gp32/console/defaultfont.c, gp32/include/.cvsignore, gp32/include/bsp.h, gp32/include/conio.h, gp32/include/tm27.h, gp32/start/.cvsignore, gp32/start/start.S, gp32/startup/.cvsignore, gp32/startup/bspstart.c, gp32/startup/exit.c, gp32/startup/linkcmds, gp32/startup/memmap.c: New files.
  • Property mode set to 100644
File size: 5.3 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.OARcorp.com/rtems/license.html.
9 *
10 *
11 *  $Id$
12 */
13
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   _axf_text_start
37        .word   _axf_ro_end
38        .word   _axf_data_start
39        .word   _axf_bss_end
40        .word   _axf_bss_start
41        .word   _axf_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, =_irq_stack_size
82        ldr     sp, =_irq_stack
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, =_fiq_stack_size
89        ldr     sp, =_fiq_stack
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, =_abt_stack_size
96        ldr     sp, =_abt_stack
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, =_svc_stack_size
103        ldr     sp, =_svc_stack
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        bl      boot_card
157
158        /*
159         * Theoretically, we could return to what started us up,
160         * but we'd have to have saved the registers and stacks.
161         * Instead, we'll just reset.
162         */
163        bl      bsp_reset
164
165        /* We shouldn't get here. If we do, hang */
166_hang:  b       _hang
167
168       
169/*
170 * This is the exception vector table and the pointers to
171 * the functions that handle the exceptions. It's a total
172 * of 16 words (64 bytes)
173 */
174vector_block:   
175        ldr     pc, Reset_Handler
176        ldr     pc, Undefined_Handler
177        ldr     pc, SWI_Handler
178        ldr     pc, Prefetch_Handler
179        ldr     pc, Abort_Handler
180        nop
181        ldr     pc, IRQ_Handler
182        ldr     pc, FIQ_Handler
183
184Reset_Handler:          b       bsp_reset
185Undefined_Handler:      b       Undefined_Handler
186SWI_Handler:            b       SWI_Handler
187Prefetch_Handler:       b       Prefetch_Handler
188Abort_Handler:          b       Abort_Handler
189                        nop
190IRQ_Handler:            b       IRQ_Handler
191FIQ_Handler:            b       FIQ_Handler
192
193.globl Reset_Handler
194.globl Undefined_Handler
195.globl SWI_Handler
196.globl Prefetch_Handler
197.globl Abort_Handler
198.globl IRQ_Handler
199.globl FIQ_Handler
Note: See TracBrowser for help on using the repository browser.