]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/vector_functions.s
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_NXP / TARGET_LPC23XX / TOOLCHAIN_GCC_ARM / vector_functions.s
1 /* .include "vector_defns.h" */
2
3
4
5 .section .privileged_code, "ax"
6 .arm
7
8
9 .weak __mbed_fiq
10 .weak __mbed_undef
11 .weak __mbed_prefetch_abort
12 .weak __mbed_data_abort
13 .weak __mbed_irq
14 .weak __mbed_swi
15 .weak __mbed_dcc_irq
16 .weak __mbed_reset
17 .global __mbed_init_realmonitor
18 /*  .global __mbed_init */
19
20
21
22
23 __mbed_fiq:
24         B __mbed_fiq
25 __mbed_undef:
26         LDR PC, =0x7fffffa0
27 __mbed_prefetch_abort:
28         LDR PC, =0x7fffffb0
29 __mbed_data_abort:
30         LDR PC, =0x7fffffc0
31 __mbed_irq:
32         MSR CPSR_c, #0x1F|0x80|0x40
33         
34         STMDB sp!, {r0-r3,r12,lr}
35         
36         MOV r0, #0xFFFFFF00
37         LDR r0, [r0]
38         
39         MOV lr, pc
40         BX r0
41         
42         MOV r0, #0xFFFFFF00
43         STR r0, [r0] 
44         
45         LDMFD sp!,{r0-r3,r12,lr}
46         
47         MSR CPSR_c, #0x12|0x80|0x40
48         
49         SUBS pc, lr, #4
50 __mbed_swi:
51         STMFD sp!, {a4, r4, ip, lr}
52         
53         LDR r4, =0x40000040
54         
55         LDR a4, =0x00940000
56         LDR PC, =0x7ffff820
57 __mbed_dcc_irq:
58         LDMFD sp!,{r0-r3,r12,lr}
59         
60         MSR CPSR_c, #0x12|0x80|0x40
61         
62         SUB lr, lr, #4 
63         STMFD sp!, {ip,lr} 
64         
65         LDR LR, =0xfffff000
66         STR LR, [LR, #0xf00]
67         
68         LDR PC, =0x7fffffe0
69 /*
70  __mbed_reset is called after reset
71  we setup the stacks and realmonitor, then call Reset_Handler like on M3
72 */
73
74 .section .text, "ax"
75 .arm
76 .global Reset_handler
77 Reset_Handler:   
78         .extern __libc_init_array
79         .extern  SystemInit
80         LDR     R0, =SystemInit
81         MOV     LR, PC       
82         BX      R0
83
84         LDR     R0, =__libc_init_array
85         MOV     LR, PC       
86         BX      R0
87
88         LDR     R0, =main
89         BX      R0
90
91 __mbed_reset:
92         LDR R0, =( __SRAM_segment_end__ )
93         
94         MSR CPSR_c, #0x1B|0x80|0x40
95         MOV SP, R0
96         SUB R0, R0, #0x00000040
97         
98         MSR CPSR_c, #0x17|0x80|0x40
99         MOV SP, R0
100         SUB R0, R0, #0x00000040
101         
102         MSR CPSR_c, #0x11|0x80|0x40
103         MOV SP, R0
104         SUB R0, R0, #0x00000000
105         
106         MSR CPSR_c, #0x12|0x80|0x40
107         MOV SP, R0
108         SUB R0, R0, #0x00000040
109         
110         MSR CPSR_c, #0x13|0x80|0x40
111         MOV SP, R0
112         SUB R0, R0, #0x00000040
113         
114         MSR CPSR_c, #0x10
115         MOV SP, R0
116         
117 /*  Relocate .data section (Copy from ROM to RAM) */
118         LDR     R1, =__text_end__        /* _etext */ 
119         LDR     R2, =__data_start__      /* _data  */
120         LDR     R3, =__data_end__        /* _edata */ 
121         CMP     R2, R3
122         BEQ     DataIsEmpty
123 LoopRel:        CMP     R2, R3 
124         LDRLO   R0, [R1], #4 
125         STRLO   R0, [R2], #4 
126         BLO     LoopRel 
127 DataIsEmpty:
128
129 /*   Clear .bss section (Zero init) */
130         MOV     R0, #0 
131         LDR     R1, =__bss_start__ 
132         LDR     R2, =__bss_end__ 
133         CMP     R1,R2
134         BEQ     BSSIsEmpty
135 LoopZI:         CMP     R1, R2 
136         STRLO   R0, [R1], #4 
137         BLO     LoopZI 
138 BSSIsEmpty:
139
140
141 /* Init realmonitor */
142         LDR R0, =__mbed_init_realmonitor
143         MOV LR, PC
144         BX R0
145         
146 /* Go to Reset_Handler */ 
147         LDR     R0, =Reset_Handler
148         BX R0