summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/app.lds3
-rw-r--r--firmware/target/mips/ingenic_jz47xx/boot.lds3
-rw-r--r--firmware/target/mips/ingenic_jz47xx/crt0.S92
3 files changed, 60 insertions, 38 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/app.lds b/firmware/target/mips/ingenic_jz47xx/app.lds
index 85c332b182..acb1e86b4f 100644
--- a/firmware/target/mips/ingenic_jz47xx/app.lds
+++ b/firmware/target/mips/ingenic_jz47xx/app.lds
@@ -83,6 +83,9 @@ SECTIONS
83 stackbegin = .; 83 stackbegin = .;
84 . += 0x2000; 84 . += 0x2000;
85 stackend = .; 85 stackend = .;
86 irqstackbegin = .;
87 . += 0x400;
88 irqstackend = .;
86 } > IRAM 89 } > IRAM
87 90
88 .bss (NOLOAD): 91 .bss (NOLOAD):
diff --git a/firmware/target/mips/ingenic_jz47xx/boot.lds b/firmware/target/mips/ingenic_jz47xx/boot.lds
index c207fcbac3..5c25a042b9 100644
--- a/firmware/target/mips/ingenic_jz47xx/boot.lds
+++ b/firmware/target/mips/ingenic_jz47xx/boot.lds
@@ -87,5 +87,8 @@ SECTIONS
87 stackbegin = .; 87 stackbegin = .;
88 . += 0x2000; 88 . += 0x2000;
89 stackend = .; 89 stackend = .;
90 irqstackbegin = .;
91 . += 0x400;
92 irqstackend = .;
90 } > IRAM 93 } > IRAM
91} 94}
diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S
index 49de3e6a01..ce74b78e81 100644
--- a/firmware/target/mips/ingenic_jz47xx/crt0.S
+++ b/firmware/target/mips/ingenic_jz47xx/crt0.S
@@ -28,7 +28,7 @@
28 * e-mail: seeger.chin@gmail.com 28 * e-mail: seeger.chin@gmail.com
29 * 29 *
30 * Copyright (C) 2006 Ingenic Semiconductor Inc. 30 * Copyright (C) 2006 Ingenic Semiconductor Inc.
31 * 31 *
32 * This program is free software; you can redistribute it and/or modify 32 * This program is free software; you can redistribute it and/or modify
33 * it under the terms of the GNU General Public License version 2 as 33 * it under the terms of the GNU General Public License version 2 as
34 * published by the Free Software Foundation. 34 * published by the Free Software Foundation.
@@ -120,7 +120,7 @@ _cache_loop:
120 ori t0, 2 120 ori t0, 2
121 mtc0 t0, C0_CONFIG 121 mtc0 t0, C0_CONFIG
122 nop 122 nop
123 123
124 /* 124 /*
125 ---------------------------------------------------- 125 ----------------------------------------------------
126 Copy IRAM section 126 Copy IRAM section
@@ -137,7 +137,7 @@ _iram_loop:
137 addiu t0, 4 137 addiu t0, 4
138 bne t1, t2, _iram_loop 138 bne t1, t2, _iram_loop
139 sw t3, -4(t1) 139 sw t3, -4(t1)
140 140
141 /* 141 /*
142 ---------------------------------------------------- 142 ----------------------------------------------------
143 Clear BSS section 143 Clear BSS section
@@ -158,7 +158,7 @@ _bss_loop:
158 la sp, stackend 158 la sp, stackend
159 la t0, stackbegin 159 la t0, stackbegin
160 li t2, 0xDEADBEEF 160 li t2, 0xDEADBEEF
161 161
162_stack_loop: 162_stack_loop:
163 addiu t0, 4 163 addiu t0, 4
164 bne t0, sp, _stack_loop 164 bne t0, sp, _stack_loop
@@ -166,6 +166,19 @@ _stack_loop:
166 166
167 /* 167 /*
168 ---------------------------------------------------- 168 ----------------------------------------------------
169 Set up interrupt stack
170 ----------------------------------------------------
171 */
172 la k0, irqstackend
173 la t0, irqstackbegin
174
175_irq_stack_loop:
176 addiu t0, 4
177 bne t0, k0, _irq_stack_loop
178 sw t2, -4(t0)
179
180 /*
181 ----------------------------------------------------
169 Jump to C code 182 Jump to C code
170 ---------------------------------------------------- 183 ----------------------------------------------------
171 */ 184 */
@@ -174,33 +187,43 @@ _stack_loop:
174 j main 187 j main
175 nop 188 nop
176 189
177 190
178 /* 191 /*
179 * 0x0 - Simple TLB refill handler 192 * 0x0 - Simple TLB refill handler
180 * 0x100 - Cache error handler 193 * 0x100 - Cache error handler
181 * 0x180 - Exception/Interrupt handler 194 * 0x180 - Exception/Interrupt handler
182 * 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE) 195 * 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE)
183 */ 196 */
184 197
185 .section .vectors.1, "ax", %progbits 198 .section .vectors.1, "ax", %progbits
186 j tlb_refill_handler 199 j tlb_refill_handler
187 nop 200 nop
188 201
189 .section .vectors.2, "ax", %progbits 202 .section .vectors.2, "ax", %progbits
190 j real_exception_handler 203 j real_exception_handler
191 nop 204 nop
192 205
193 .section .vectors.3, "ax", %progbits 206 .section .vectors.3, "ax", %progbits
194 j real_exception_handler 207 j real_exception_handler
195 nop 208 nop
196 209
197 .section .vectors.4, "ax", %progbits 210 .section .vectors.4, "ax", %progbits
198 j real_exception_handler 211 j real_exception_handler
199 nop 212 nop
200 213
201 .section .vectors, "ax", %progbits 214 .section .vectors, "ax", %progbits
202real_exception_handler: 215real_exception_handler:
203 addiu sp, -0x80 216
217 /* Store stack pointer */
218 move k0, sp
219 /* jump to IRQ stack */
220 la sp, irqstackend
221
222 /* Push crap on frame */
223 addiu sp, -0x84
224 /* store current stack pointer */
225 sw k0, 0x80(sp)
226
204 sw ra, 0(sp) 227 sw ra, 0(sp)
205 sw fp, 4(sp) 228 sw fp, 4(sp)
206 sw gp, 8(sp) 229 sw gp, 8(sp)
@@ -236,18 +259,16 @@ real_exception_handler:
236 nop 259 nop
237 sw k0, 0x74(sp) 260 sw k0, 0x74(sp)
238 mfc0 k0, C0_STATUS 261 mfc0 k0, C0_STATUS
239 sll zero, 1 262 nop
240 sll zero, 1 263 nop
241 sll zero, 1 264 nop
242 sll zero, 1
243 sw k0, 0x78(sp) 265 sw k0, 0x78(sp)
244 mfc0 k0, C0_EPC 266 mfc0 k0, C0_EPC
245 sll zero, 1 267 nop
246 sll zero, 1 268 nop
247 sll zero, 1 269 nop
248 sll zero, 1
249 sw k0, 0x7C(sp) 270 sw k0, 0x7C(sp)
250 271
251 li k1, M_CauseExcCode 272 li k1, M_CauseExcCode
252 mfc0 k0, C0_CAUSE 273 mfc0 k0, C0_CAUSE
253 and k0, k1 274 and k0, k1
@@ -255,24 +276,22 @@ real_exception_handler:
255 nop 276 nop
256 j _exception 277 j _exception
257 nop 278 nop
258 279
259_int: 280_int:
260 jal intr_handler 281 jal intr_handler
261 nop 282 nop
262 j _exception_return 283 j _exception_return
263 284
264_exception: 285_exception:
265 move a0, sp 286 move a0, sp
266 mfc0 a1, C0_CAUSE 287 mfc0 a1, C0_CAUSE
267 sll zero, 1 288 nop
268 sll zero, 1 289 nop
269 sll zero, 1 290 nop
270 sll zero, 1
271 mfc0 a2, C0_EPC 291 mfc0 a2, C0_EPC
272 sll zero, 1 292 nop
273 sll zero, 1 293 nop
274 sll zero, 1 294 nop
275 sll zero, 1
276 jal exception_handler 295 jal exception_handler
277 nop 296 nop
278 297
@@ -314,18 +333,15 @@ _exception_return:
314 lw k0, 0x78(sp) 333 lw k0, 0x78(sp)
315 mtc0 k0, C0_STATUS 334 mtc0 k0, C0_STATUS
316 nop 335 nop
317 sll zero, 1 336 nop
318 sll zero, 1 337 nop
319 sll zero, 1
320 sll zero, 1
321 lw k0, 0x7C(sp) 338 lw k0, 0x7C(sp)
322 mtc0 k0, C0_EPC 339 mtc0 k0, C0_EPC
323 nop 340 nop
324 sll zero, 1 341 nop
325 sll zero, 1 342 nop
326 sll zero, 1 343 /* Restore previous stack pointer */
327 sll zero, 1 344 lw sp, 0x80(sp)
328 addiu sp, 0x80
329 eret 345 eret
330 nop 346 nop
331 .set reorder 347 .set reorder