diff options
Diffstat (limited to 'firmware/target/arm/crt0.S')
-rw-r--r-- | firmware/target/arm/crt0.S | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/firmware/target/arm/crt0.S b/firmware/target/arm/crt0.S index 3765df9ffc..f75f37006d 100644 --- a/firmware/target/arm/crt0.S +++ b/firmware/target/arm/crt0.S | |||
@@ -100,15 +100,6 @@ newstart: | |||
100 | strhi r4, [r2], #4 | 100 | strhi r4, [r2], #4 |
101 | bhi 1b | 101 | bhi 1b |
102 | 102 | ||
103 | /* Set up some stack and munge it with 0xdeadbeef */ | ||
104 | ldr sp, =stackend | ||
105 | ldr r2, =stackbegin | ||
106 | ldr r3, =0xdeadbeef | ||
107 | 1: | ||
108 | cmp sp, r2 | ||
109 | strhi r3, [r2], #4 | ||
110 | bhi 1b | ||
111 | |||
112 | /* Set up stack for IRQ mode */ | 103 | /* Set up stack for IRQ mode */ |
113 | msr cpsr_c, #0xd2 | 104 | msr cpsr_c, #0xd2 |
114 | ldr sp, =irq_stack | 105 | ldr sp, =irq_stack |
@@ -117,14 +108,26 @@ newstart: | |||
117 | msr cpsr_c, #0xd1 | 108 | msr cpsr_c, #0xd1 |
118 | ldr sp, =fiq_stack | 109 | ldr sp, =fiq_stack |
119 | 110 | ||
120 | /* Let abort and undefined modes use IRQ stack */ | 111 | /* Let svc, abort and undefined modes use irq stack */ |
112 | msr cpsr_c, #0xd3 | ||
113 | ldr sp, =irq_stack | ||
121 | msr cpsr_c, #0xd7 | 114 | msr cpsr_c, #0xd7 |
122 | ldr sp, =irq_stack | 115 | ldr sp, =irq_stack |
123 | msr cpsr_c, #0xdb | 116 | msr cpsr_c, #0xdb |
124 | ldr sp, =irq_stack | 117 | ldr sp, =irq_stack |
125 | 118 | ||
126 | /* Switch back to supervisor mode */ | 119 | /* Switch to sys mode */ |
127 | msr cpsr_c, #0xd3 | 120 | msr cpsr_c, #0xdf |
121 | |||
122 | /* Set up some stack and munge it with 0xdeadbeef */ | ||
123 | ldr sp, =stackend | ||
124 | ldr r2, =stackbegin | ||
125 | ldr r3, =0xdeadbeef | ||
126 | 1: | ||
127 | cmp sp, r2 | ||
128 | strhi r3, [r2], #4 | ||
129 | bhi 1b | ||
130 | |||
128 | ldr ip, =main @ make sure we are using the virtual address | 131 | ldr ip, =main @ make sure we are using the virtual address |
129 | bx ip | 132 | bx ip |
130 | 133 | ||
@@ -142,11 +145,13 @@ undef_instr_handler: | |||
142 | mov r1, #0 | 145 | mov r1, #0 |
143 | b UIE | 146 | b UIE |
144 | 147 | ||
145 | /* We run supervisor mode most of the time, and should never see a software | 148 | /* We run sys mode most of the time, and should never see a software |
146 | * exception being thrown. Perhaps make it illegal and call UIE? */ | 149 | * exception being thrown. Make it illegal and call UIE. */ |
147 | software_int_handler: | 150 | software_int_handler: |
148 | reserved_handler: | 151 | reserved_handler: |
149 | movs pc, lr | 152 | sub r0, lr, #4 |
153 | mov r1, #4 | ||
154 | b UIE | ||
150 | 155 | ||
151 | prefetch_abort_handler: | 156 | prefetch_abort_handler: |
152 | sub r0, lr, #4 | 157 | sub r0, lr, #4 |
@@ -165,5 +170,4 @@ irq_stack: | |||
165 | /* 256 words of FIQ stack */ | 170 | /* 256 words of FIQ stack */ |
166 | .space 256*4 | 171 | .space 256*4 |
167 | fiq_stack: | 172 | fiq_stack: |
168 | |||
169 | end: | 173 | end: |