cstartup_pre.S 2.35 KB
# 1 "cstartup.S"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "cstartup.S"
# 39 "cstartup.S"
# 1 "project.h" 1
# 44 "project.h"
# 1 "include/AT91SAM9263-EK.h" 1
# 45 "project.h" 2
# 1 "include/AT91SAM9263.h" 1
# 46 "project.h" 2
# 40 "cstartup.S" 2
# 55 "cstartup.S"
        .globl reset_handler
        .align 4

.section .vectors
.arm



_exception_vectors:
reset_vector:
        ldr pc, =reset_handler
undef_vector:
        b undef_vector
swi_vector:
        b swi_vector
pabt_vector:
        ldr pc, =pabt_handler
dabt_vector:
        ldr pc, =dabt_handler
rsvd_vector:
        b rsvd_vector
irq_vector:
        b irq_handler
fiq_vector:





fiq_handler:
 b fiq_handler






irq_handler:


        sub lr, lr, #4
        stmfd sp!, {lr}

        mrs r14, SPSR
        stmfd sp!, {r0,r14}




        ldr r14, =( 0xFFFFF000)
        ldr r0 , [r14, #( 0x00000100)]
        str r14, [r14, #( 0x00000100)]


        msr CPSR_c, #0x13


        stmfd sp!, {r1-r3, r12, r14}


        mov r14, pc
        bx r0


        ldmia sp!, {r1-r3, r12, r14}


        msr CPSR_c, #0x12 | 0x80


        ldr r14, =( 0xFFFFF000)
        str r14, [r14, #( 0x00000130)]


        ldmia sp!, {r0,r14}
        msr SPSR_cxsf, r14


        ldmia sp!, {pc}^







.section .text
reset_handler:
 ldr pc, =_low_level_init






_low_level_init:
 ldr r2, =_lp_ll_init
        ldmia r2, {r0, r1}
        mov sp, r1
        mov lr, pc
        bx r0




_stack_init:
 ldr r2, =_lp_stack_init
        ldmia r2, {r0, r1, r2}


        msr CPSR_c, #0x17 | 0x80 | 0x40
        mov sp, r0
        sub r0, r0, r1


        msr CPSR_c, #0x12 | 0x80 | 0x40
        mov sp, r0
        sub r0, r0, r2


        msr CPSR_c, #0x13 | 0x40
        mov sp, r0





_init_data:
 ldr r2, =_lp_data
        ldmia r2, {r1, r3, r4}
1:
        cmp r3, r4
        ldrcc r2, [r1], #4
        strcc r2, [r3], #4
        bcc 1b


_init_bss:
 ldr r2, =_lp_bss
        ldmia r2, {r3, r4}
        mov r2, #0
1:
        cmp r3, r4
        strcc r2, [r3], #4
        bcc 1b




_branch_main:
        ldr r0, =main
        mov lr, pc
        bx r0




_lp_ll_init:
        .word lowlevel_init
        .word ((0x00300000) + (0x00014000))

_lp_stack_init:
        .word ((0x00300000) + (0x00014000))
        .word 8*3*4
        .word 8*3*4

_lp_bss:
        .word _sbss
        .word _ebss

_lp_data:
        .word _etext
        .word _sdata
        .word _edata