diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-15 15:52:54 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-08-15 15:52:54 +0000 |
commit | 63212628543e4f7e6b2e7a30c8c815231d1d3140 (patch) | |
tree | a4faf3ae046d56019332ffad4fb22a8b5d1c4f74 | |
parent | 57c0b6a4740d7a900dff7ff0230da1c7942a46b0 (diff) | |
download | rockbox-63212628543e4f7e6b2e7a30c8c815231d1d3140.tar.gz rockbox-63212628543e4f7e6b2e7a30c8c815231d1d3140.zip |
Jz4740: get exception handling working
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18287 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/crt0.S | 18 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/system-jz4740.c | 34 |
2 files changed, 42 insertions, 10 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S index 3d2308a578..b9ffde3b65 100644 --- a/firmware/target/mips/ingenic_jz47xx/crt0.S +++ b/firmware/target/mips/ingenic_jz47xx/crt0.S | |||
@@ -135,15 +135,14 @@ except_common_entry: | |||
135 | nop | 135 | nop |
136 | nop | 136 | nop |
137 | nop | 137 | nop |
138 | 138 | .fill 0x20 | |
139 | |||
139 | .extern _int | 140 | .extern _int |
140 | .extern _exception | 141 | .extern _exception |
141 | .global real_exception_handler | 142 | .global real_exception_handler |
142 | .type real_exception_handler,@function | 143 | .type real_exception_handler,@function |
143 | .set noreorder | 144 | .set noreorder |
144 | real_exception_handler: | 145 | real_exception_handler: |
145 | |||
146 | |||
147 | addiu sp, -0x80 | 146 | addiu sp, -0x80 |
148 | sw ra, 0(sp) | 147 | sw ra, 0(sp) |
149 | sw fp, 4(sp) | 148 | sw fp, 4(sp) |
@@ -196,8 +195,7 @@ real_exception_handler: | |||
196 | and k0, k1 | 195 | and k0, k1 |
197 | beq zero, k0, _int | 196 | beq zero, k0, _int |
198 | nop | 197 | nop |
199 | la k0, _exception | 198 | j _exception |
200 | jr k0 | ||
201 | nop | 199 | nop |
202 | 200 | ||
203 | .global _int | 201 | .global _int |
@@ -261,9 +259,17 @@ _int: | |||
261 | .global _exception | 259 | .global _exception |
262 | .type _exception,@function | 260 | .type _exception,@function |
263 | _exception: | 261 | _exception: |
264 | move a0, sp | 262 | add a0, sp, $0 |
265 | mfc0 a1, C0_CAUSE # C0_CAUSE of last exception | 263 | mfc0 a1, C0_CAUSE # C0_CAUSE of last exception |
264 | sll zero, 1 | ||
265 | sll zero, 1 | ||
266 | sll zero, 1 | ||
267 | sll zero, 1 | ||
266 | mfc0 a2, C0_EPC # Exception Program Counter | 268 | mfc0 a2, C0_EPC # Exception Program Counter |
269 | sll zero, 1 | ||
270 | sll zero, 1 | ||
271 | sll zero, 1 | ||
272 | sll zero, 1 | ||
267 | la k0, exception_handler | 273 | la k0, exception_handler |
268 | jr k0 | 274 | jr k0 |
269 | nop | 275 | nop |
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c index e878173abd..25b14106c4 100644 --- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c | |||
@@ -345,9 +345,36 @@ void intr_handler(void) | |||
345 | return; | 345 | return; |
346 | } | 346 | } |
347 | 347 | ||
348 | #define EXC(x,y) if(_cause == (x)) return (y); | ||
349 | static char* parse_exception(unsigned int cause) | ||
350 | { | ||
351 | unsigned int _cause = cause & M_CauseExcCode; | ||
352 | EXC(EXC_INT, "Interrupt"); | ||
353 | EXC(EXC_MOD, "TLB Modified"); | ||
354 | EXC(EXC_TLBL, "TLB Exception (Load or Ifetch)"); | ||
355 | EXC(EXC_ADEL, "Address Error (Load or Ifetch)"); | ||
356 | EXC(EXC_ADES, "Address Error (Store)"); | ||
357 | EXC(EXC_TLBS, "TLB Exception (Store)"); | ||
358 | EXC(EXC_IBE, "Instruction Bus Error"); | ||
359 | EXC(EXC_DBE, "Data Bus Error"); | ||
360 | EXC(EXC_SYS, "Syscall"); | ||
361 | EXC(EXC_BP, "Breakpoint"); | ||
362 | EXC(EXC_RI, "Reserved Instruction"); | ||
363 | EXC(EXC_CPU, "Coprocessor Unusable"); | ||
364 | EXC(EXC_OV, "Overflow"); | ||
365 | EXC(EXC_TR, "Trap Instruction"); | ||
366 | EXC(EXC_FPE, "Floating Point Exception"); | ||
367 | EXC(EXC_C2E, "COP2 Exception"); | ||
368 | EXC(EXC_MDMX, "MDMX Exception"); | ||
369 | EXC(EXC_WATCH, "Watch Exception"); | ||
370 | EXC(EXC_MCHECK, "Machine Check Exception"); | ||
371 | EXC(EXC_CacheErr, "Cache error caused re-entry to Debug Mode"); | ||
372 | return NULL; | ||
373 | } | ||
374 | |||
348 | void exception_handler(void* stack_ptr, unsigned int cause, unsigned int epc) | 375 | void exception_handler(void* stack_ptr, unsigned int cause, unsigned int epc) |
349 | { | 376 | { |
350 | panicf("Exception occurred: [0x%x] at 0x%x (stack at 0x%x)", cause, epc, (unsigned int)stack_ptr); | 377 | panicf("Exception occurred: %s [0x%08x] at 0x%08x (stack at 0x%08x)", parse_exception(cause), cause, epc, (unsigned int)stack_ptr); |
351 | } | 378 | } |
352 | 379 | ||
353 | static const int FR2n[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}; | 380 | static const int FR2n[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}; |
@@ -559,9 +586,8 @@ void system_main(void) | |||
559 | __dcache_writeback_all(); | 586 | __dcache_writeback_all(); |
560 | __icache_invalidate_all(); | 587 | __icache_invalidate_all(); |
561 | 588 | ||
562 | /* Init interrupt handling */ | 589 | /* Disable all interrupts */ |
563 | ipl = 0; | 590 | for(i=0; i<IRQ_MAX; i++) |
564 | for(i=0;i<IRQ_MAX;i++) | ||
565 | dis_irq(i); | 591 | dis_irq(i); |
566 | 592 | ||
567 | sti(); | 593 | sti(); |