1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_arm.c,v 1.44 2005/11/19 18:53:07 debug Exp $ |
* $Id: cpu_arm.c,v 1.67 2006/12/30 13:30:53 debug Exp $ |
29 |
* |
* |
30 |
* ARM CPU emulation. |
* ARM CPU emulation. |
31 |
* |
* |
42 |
|
|
43 |
#include "arm_cpu_types.h" |
#include "arm_cpu_types.h" |
44 |
#include "cpu.h" |
#include "cpu.h" |
45 |
|
#include "interrupt.h" |
46 |
#include "machine.h" |
#include "machine.h" |
47 |
#include "memory.h" |
#include "memory.h" |
48 |
#include "misc.h" |
#include "misc.h" |
49 |
|
#include "of.h" |
50 |
|
#include "settings.h" |
51 |
#include "symbol.h" |
#include "symbol.h" |
52 |
|
|
53 |
#define DYNTRANS_32 |
#define DYNTRANS_32 |
66 |
static int arm_exception_to_mode[N_ARM_EXCEPTIONS] = ARM_EXCEPTION_TO_MODE; |
static int arm_exception_to_mode[N_ARM_EXCEPTIONS] = ARM_EXCEPTION_TO_MODE; |
67 |
|
|
68 |
/* For quick_pc_to_pointers(): */ |
/* For quick_pc_to_pointers(): */ |
69 |
#include "arm_quick_pc_to_pointers.h" |
void arm_pc_to_pointers(struct cpu *cpu); |
70 |
|
#include "quick_pc_to_pointers.h" |
71 |
|
|
72 |
|
void arm_irq_interrupt_assert(struct interrupt *interrupt); |
73 |
|
void arm_irq_interrupt_deassert(struct interrupt *interrupt); |
74 |
|
|
75 |
|
|
76 |
/* |
/* |
82 |
int arm_cpu_new(struct cpu *cpu, struct memory *mem, |
int arm_cpu_new(struct cpu *cpu, struct memory *mem, |
83 |
struct machine *machine, int cpu_id, char *cpu_type_name) |
struct machine *machine, int cpu_id, char *cpu_type_name) |
84 |
{ |
{ |
85 |
int any_cache = 0, i, found; |
int i, found; |
86 |
struct arm_cpu_type_def cpu_type_defs[] = ARM_CPU_TYPE_DEFS; |
struct arm_cpu_type_def cpu_type_defs[] = ARM_CPU_TYPE_DEFS; |
87 |
|
|
88 |
/* Scan the list for this cpu type: */ |
/* Scan the list for this cpu type: */ |
97 |
if (found == -1) |
if (found == -1) |
98 |
return 0; |
return 0; |
99 |
|
|
100 |
|
cpu->run_instr = arm_run_instr; |
101 |
cpu->memory_rw = arm_memory_rw; |
cpu->memory_rw = arm_memory_rw; |
102 |
cpu->update_translation_table = arm_update_translation_table; |
cpu->update_translation_table = arm_update_translation_table; |
103 |
cpu->invalidate_translation_caches = |
cpu->invalidate_translation_caches = |
104 |
arm_invalidate_translation_caches; |
arm_invalidate_translation_caches; |
105 |
cpu->invalidate_code_translation = arm_invalidate_code_translation; |
cpu->invalidate_code_translation = arm_invalidate_code_translation; |
106 |
cpu->translate_address = arm_translate_address; |
cpu->translate_v2p = arm_translate_v2p; |
107 |
|
|
108 |
cpu->cd.arm.cpu_type = cpu_type_defs[found]; |
cpu->cd.arm.cpu_type = cpu_type_defs[found]; |
109 |
cpu->name = cpu->cd.arm.cpu_type.name; |
cpu->name = cpu->cd.arm.cpu_type.name; |
110 |
cpu->is_32bit = 1; |
cpu->is_32bit = 1; |
111 |
|
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
112 |
|
|
113 |
cpu->cd.arm.cpsr = ARM_FLAG_I | ARM_FLAG_F; |
cpu->cd.arm.cpsr = ARM_FLAG_I | ARM_FLAG_F; |
114 |
cpu->cd.arm.control = ARM_CONTROL_PROG32 | ARM_CONTROL_DATA32 |
cpu->cd.arm.control = ARM_CONTROL_PROG32 | ARM_CONTROL_DATA32 |
115 |
| ARM_CONTROL_CACHE | ARM_CONTROL_ICACHE | ARM_CONTROL_ALIGN; |
| ARM_CONTROL_CACHE | ARM_CONTROL_ICACHE | ARM_CONTROL_ALIGN; |
116 |
|
/* TODO: default auxctrl contents */ |
117 |
|
|
118 |
if (cpu->machine->prom_emulation) { |
if (cpu->machine->prom_emulation) { |
119 |
cpu->cd.arm.cpsr |= ARM_MODE_SVC32; |
cpu->cd.arm.cpsr |= ARM_MODE_SVC32; |
126 |
/* Only show name and caches etc for CPU nr 0: */ |
/* Only show name and caches etc for CPU nr 0: */ |
127 |
if (cpu_id == 0) { |
if (cpu_id == 0) { |
128 |
debug("%s", cpu->name); |
debug("%s", cpu->name); |
129 |
if (cpu->cd.arm.cpu_type.icache_shift != 0) |
if (cpu->cd.arm.cpu_type.icache_shift != 0 || |
130 |
any_cache = 1; |
cpu->cd.arm.cpu_type.dcache_shift != 0) { |
131 |
if (cpu->cd.arm.cpu_type.dcache_shift != 0) |
int isize = cpu->cd.arm.cpu_type.icache_shift; |
132 |
any_cache = 1; |
int dsize = cpu->cd.arm.cpu_type.dcache_shift; |
133 |
if (any_cache) { |
if (isize != 0) |
134 |
debug(" (I+D = %i+%i KB", |
isize = 1 << (isize - 10); |
135 |
(int)(1 << (cpu->cd.arm.cpu_type.icache_shift-10)), |
if (dsize != 0) |
136 |
(int)(1 << (cpu->cd.arm.cpu_type.dcache_shift-10))); |
dsize = 1 << (dsize - 10); |
137 |
debug(")"); |
debug(" (I+D = %i+%i KB)", isize, dsize); |
138 |
} |
} |
139 |
} |
} |
140 |
|
|
141 |
|
/* TODO: Some of these values (iway and dway) aren't used yet: */ |
142 |
|
cpu->cd.arm.cachetype = |
143 |
|
(5 << ARM_CACHETYPE_CLASS_SHIFT) |
144 |
|
| (1 << ARM_CACHETYPE_HARVARD_SHIFT) |
145 |
|
| ((cpu->cd.arm.cpu_type.dcache_shift - 9) << |
146 |
|
ARM_CACHETYPE_DSIZE_SHIFT) |
147 |
|
| (5 << ARM_CACHETYPE_DASSOC_SHIFT) /* 32-way */ |
148 |
|
| (2 << ARM_CACHETYPE_DLINE_SHIFT) /* 8 words/line */ |
149 |
|
| ((cpu->cd.arm.cpu_type.icache_shift - 9) << |
150 |
|
ARM_CACHETYPE_ISIZE_SHIFT) |
151 |
|
| (5 << ARM_CACHETYPE_IASSOC_SHIFT) /* 32-way */ |
152 |
|
| (2 << ARM_CACHETYPE_ILINE_SHIFT); /* 8 words/line */ |
153 |
|
|
154 |
/* Coprocessor 15 = the system control coprocessor. */ |
/* Coprocessor 15 = the system control coprocessor. */ |
155 |
cpu->cd.arm.coproc[15] = arm_coproc_15; |
cpu->cd.arm.coproc[15] = arm_coproc_15; |
156 |
|
|
157 |
|
/* Coprocessor 14 for XScale: */ |
158 |
|
if (cpu->cd.arm.cpu_type.flags & ARM_XSCALE) |
159 |
|
cpu->cd.arm.coproc[14] = arm_coproc_xscale_14; |
160 |
|
|
161 |
/* |
/* |
162 |
* NOTE/TODO: Ugly hack for OpenFirmware emulation: |
* NOTE/TODO: Ugly hack for OpenFirmware emulation: |
163 |
*/ |
*/ |
169 |
|
|
170 |
cpu->cd.arm.flags = cpu->cd.arm.cpsr >> 28; |
cpu->cd.arm.flags = cpu->cd.arm.cpsr >> 28; |
171 |
|
|
172 |
|
CPU_SETTINGS_ADD_REGISTER64("pc", cpu->pc); |
173 |
|
for (i=0; i<N_ARM_REGS - 1; i++) |
174 |
|
CPU_SETTINGS_ADD_REGISTER32(arm_regname[i], cpu->cd.arm.r[i]); |
175 |
|
|
176 |
|
/* Register the CPU's "IRQ" and "FIQ" interrupts: */ |
177 |
|
{ |
178 |
|
struct interrupt template; |
179 |
|
char name[50]; |
180 |
|
snprintf(name, sizeof(name), "%s.irq", cpu->path); |
181 |
|
|
182 |
|
memset(&template, 0, sizeof(template)); |
183 |
|
template.line = 0; |
184 |
|
template.name = name; |
185 |
|
template.extra = cpu; |
186 |
|
template.interrupt_assert = arm_irq_interrupt_assert; |
187 |
|
template.interrupt_deassert = arm_irq_interrupt_deassert; |
188 |
|
interrupt_handler_register(&template); |
189 |
|
|
190 |
|
/* FIQ: TODO */ |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
return 1; |
return 1; |
195 |
} |
} |
196 |
|
|
214 |
} |
} |
215 |
|
|
216 |
cpu->cd.arm.control |= ARM_CONTROL_MMU; |
cpu->cd.arm.control |= ARM_CONTROL_MMU; |
217 |
cpu->translate_address = arm_translate_address_mmu; |
cpu->translate_v2p = arm_translate_v2p_mmu; |
218 |
cpu->cd.arm.dacr |= 0x00000003; |
cpu->cd.arm.dacr |= 0x00000003; |
219 |
cpu->cd.arm.ttb = ttb_addr; |
cpu->cd.arm.ttb = ttb_addr; |
220 |
|
|
332 |
|
|
333 |
|
|
334 |
/* |
/* |
|
* arm_cpu_register_match(): |
|
|
*/ |
|
|
void arm_cpu_register_match(struct machine *m, char *name, |
|
|
int writeflag, uint64_t *valuep, int *match_register) |
|
|
{ |
|
|
int i, cpunr = 0; |
|
|
|
|
|
/* CPU number: */ |
|
|
|
|
|
/* TODO */ |
|
|
|
|
|
/* Register names: */ |
|
|
for (i=0; i<N_ARM_REGS; i++) { |
|
|
if (strcasecmp(name, arm_regname[i]) == 0) { |
|
|
if (writeflag) { |
|
|
m->cpus[cpunr]->cd.arm.r[i] = *valuep; |
|
|
if (i == ARM_PC) |
|
|
m->cpus[cpunr]->pc = *valuep; |
|
|
} else |
|
|
*valuep = m->cpus[cpunr]->cd.arm.r[i]; |
|
|
*match_register = 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
335 |
* arm_cpu_register_dump(): |
* arm_cpu_register_dump(): |
336 |
* |
* |
337 |
* Dump cpu registers in a relatively readable format. |
* Dump cpu registers in a relatively readable format. |
400 |
} |
} |
401 |
|
|
402 |
if (m != ARM_MODE_USR32 && m != ARM_MODE_SYS32) { |
if (m != ARM_MODE_USR32 && m != ARM_MODE_SYS32) { |
403 |
debug("cpu%i: usr r8..r14 =", x); |
debug("cpu%i: usr r8-14:", x); |
404 |
for (i=0; i<7; i++) |
for (i=0; i<7; i++) |
405 |
debug(" %08x", cpu->cd.arm.default_r8_r14[i]); |
debug(" %08x", cpu->cd.arm.default_r8_r14[i]); |
406 |
debug("\n"); |
debug("\n"); |
407 |
} |
} |
408 |
|
|
409 |
if (m != ARM_MODE_FIQ32) { |
if (m != ARM_MODE_FIQ32) { |
410 |
debug("cpu%i: fiq r8..r14 =", x); |
debug("cpu%i: fiq r8-14:", x); |
411 |
for (i=0; i<7; i++) |
for (i=0; i<7; i++) |
412 |
debug(" %08x", cpu->cd.arm.fiq_r8_r14[i]); |
debug(" %08x", cpu->cd.arm.fiq_r8_r14[i]); |
413 |
debug("\n"); |
debug("\n"); |
414 |
} |
} |
415 |
|
|
416 |
if (m != ARM_MODE_IRQ32) { |
if (m != ARM_MODE_IRQ32) { |
417 |
debug("cpu%i: irq r13..r14 =", x); |
debug("cpu%i: irq r13-14:", x); |
418 |
for (i=0; i<2; i++) |
for (i=0; i<2; i++) |
419 |
debug(" %08x", cpu->cd.arm.irq_r13_r14[i]); |
debug(" %08x", cpu->cd.arm.irq_r13_r14[i]); |
420 |
debug("\n"); |
debug("\n"); |
421 |
} |
} |
422 |
|
|
423 |
if (m != ARM_MODE_SVC32) { |
if (m != ARM_MODE_SVC32) { |
424 |
debug("cpu%i: svc r13..r14 =", x); |
debug("cpu%i: svc r13-14:", x); |
425 |
for (i=0; i<2; i++) |
for (i=0; i<2; i++) |
426 |
debug(" %08x", cpu->cd.arm.svc_r13_r14[i]); |
debug(" %08x", cpu->cd.arm.svc_r13_r14[i]); |
427 |
debug("\n"); |
debug("\n"); |
428 |
} |
} |
429 |
|
|
430 |
if (m != ARM_MODE_ABT32) { |
if (m != ARM_MODE_ABT32) { |
431 |
debug("cpu%i: abt r13..r14 =", x); |
debug("cpu%i: abt r13-14:", x); |
432 |
for (i=0; i<2; i++) |
for (i=0; i<2; i++) |
433 |
debug(" %08x", cpu->cd.arm.abt_r13_r14[i]); |
debug(" %08x", cpu->cd.arm.abt_r13_r14[i]); |
434 |
debug("\n"); |
debug("\n"); |
435 |
} |
} |
436 |
|
|
437 |
if (m != ARM_MODE_UND32) { |
if (m != ARM_MODE_UND32) { |
438 |
debug("cpu%i: und r13..r14 =", x); |
debug("cpu%i: und r13-14:", x); |
439 |
for (i=0; i<2; i++) |
for (i=0; i<2; i++) |
440 |
debug(" %08x", cpu->cd.arm.und_r13_r14[i]); |
debug(" %08x", cpu->cd.arm.und_r13_r14[i]); |
441 |
debug("\n"); |
debug("\n"); |
472 |
cpu->cd.arm.control & |
cpu->cd.arm.control & |
473 |
ARM_CONTROL_V? "yes (0xffff0000)" : "no"); |
ARM_CONTROL_V? "yes (0xffff0000)" : "no"); |
474 |
|
|
475 |
|
/* TODO: auxctrl on which CPU types? */ |
476 |
|
if (cpu->cd.arm.cpu_type.flags & ARM_XSCALE) { |
477 |
|
debug("cpu%i: auxctrl = 0x%08x\n", x, |
478 |
|
cpu->cd.arm.auxctrl); |
479 |
|
debug("cpu%i: minidata cache attr = 0x%x\n", x, |
480 |
|
(cpu->cd.arm.auxctrl & ARM_AUXCTRL_MD) |
481 |
|
>> ARM_AUXCTRL_MD_SHIFT); |
482 |
|
debug("cpu%i: page table memory attr: %i\n", x, |
483 |
|
(cpu->cd.arm.auxctrl & ARM_AUXCTRL_P)? 1 : 0); |
484 |
|
debug("cpu%i: write buffer coalescing: %s\n", x, |
485 |
|
(cpu->cd.arm.auxctrl & ARM_AUXCTRL_K)? |
486 |
|
"disabled" : "enabled"); |
487 |
|
} |
488 |
|
|
489 |
debug("cpu%i: ttb = 0x%08x dacr = 0x%08x\n", x, |
debug("cpu%i: ttb = 0x%08x dacr = 0x%08x\n", x, |
490 |
cpu->cd.arm.ttb, cpu->cd.arm.dacr); |
cpu->cd.arm.ttb, cpu->cd.arm.dacr); |
491 |
debug("cpu%i: fsr = 0x%08x far = 0x%08x\n", x, |
debug("cpu%i: fsr = 0x%08x far = 0x%08x\n", x, |
688 |
"mode 0x%02x (pc=0x%x) ]\n", newmode, (int)cpu->pc); |
"mode 0x%02x (pc=0x%x) ]\n", newmode, (int)cpu->pc); |
689 |
/* exit(1); */ |
/* exit(1); */ |
690 |
} |
} |
691 |
#if 0 |
|
|
if (oldmode==0x10 && newmode ==0x17 && cpu->pc == 0x1644f0) |
|
|
single_step = 1; |
|
|
/* 00008554 */ |
|
|
#endif |
|
692 |
cpu->cd.arm.cpsr |= ARM_FLAG_I; |
cpu->cd.arm.cpsr |= ARM_FLAG_I; |
693 |
if (exception_nr == ARM_EXCEPTION_RESET || |
if (exception_nr == ARM_EXCEPTION_RESET || |
694 |
exception_nr == ARM_EXCEPTION_FIQ) |
exception_nr == ARM_EXCEPTION_FIQ) |
713 |
|
|
714 |
|
|
715 |
/* |
/* |
716 |
* arm_cpu_interrupt(): |
* arm_cpu_tlbdump(): |
717 |
* |
* |
718 |
* 0..31 are used as footbridge interrupt numbers, 32..47 = ISA, |
* Called from the debugger to dump the TLB in a readable format. |
719 |
* 64 is used as a "re-assert" signal to cpu->machine->md_interrupt(). |
* x is the cpu number to dump, or -1 to dump all CPUs. |
720 |
* |
* |
721 |
* TODO: don't hardcode to footbridge! |
* If rawflag is nonzero, then the TLB contents isn't formated nicely, |
722 |
|
* just dumped. |
723 |
*/ |
*/ |
724 |
int arm_cpu_interrupt(struct cpu *cpu, uint64_t irq_nr) |
void arm_cpu_tlbdump(struct machine *m, int x, int rawflag) |
725 |
{ |
{ |
726 |
/* fatal("arm_cpu_interrupt(): 0x%x\n", (int)irq_nr); */ |
} |
|
if (irq_nr <= 64) { |
|
|
if (cpu->machine->md_interrupt != NULL) |
|
|
cpu->machine->md_interrupt(cpu->machine, |
|
|
cpu, irq_nr, 1); |
|
|
else |
|
|
fatal("arm_cpu_interrupt(): md_interrupt == NULL\n"); |
|
|
} else { |
|
|
/* Assert ARM IRQs: */ |
|
|
cpu->cd.arm.irq_asserted = 1; |
|
|
} |
|
727 |
|
|
728 |
return 1; |
|
729 |
|
static void add_response_word(struct cpu *cpu, char *r, uint32_t value, |
730 |
|
size_t maxlen) |
731 |
|
{ |
732 |
|
if (cpu->byte_order == EMUL_LITTLE_ENDIAN) { |
733 |
|
value = ((value & 0xff) << 24) + |
734 |
|
((value & 0xff00) << 8) + |
735 |
|
((value & 0xff0000) >> 8) + |
736 |
|
((value & 0xff000000) >> 24); |
737 |
|
} |
738 |
|
snprintf(r + strlen(r), maxlen - strlen(r), "%08"PRIx32, value); |
739 |
} |
} |
740 |
|
|
741 |
|
|
742 |
/* |
/* |
743 |
* arm_cpu_interrupt_ack(): |
* arm_cpu_gdb_stub(): |
744 |
|
* |
745 |
|
* Execute a "remote GDB" command. Returns a newly allocated response string |
746 |
|
* on success, NULL on failure. |
747 |
*/ |
*/ |
748 |
int arm_cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr) |
char *arm_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
749 |
{ |
{ |
750 |
if (irq_nr <= 64) { |
if (strcmp(cmd, "g") == 0) { |
751 |
if (cpu->machine->md_interrupt != NULL) |
/* 15 gprs, pc, 8 fprs, fps, cpsr. */ |
752 |
cpu->machine->md_interrupt(cpu->machine, |
int i; |
753 |
cpu, irq_nr, 0); |
char *r; |
754 |
} else { |
size_t len = 1 + 18 * sizeof(uint32_t); |
755 |
/* De-assert ARM IRQs: */ |
r = malloc(len); |
756 |
cpu->cd.arm.irq_asserted = 0; |
if (r == NULL) { |
757 |
|
fprintf(stderr, "out of memory\n"); |
758 |
|
exit(1); |
759 |
|
} |
760 |
|
r[0] = '\0'; |
761 |
|
for (i=0; i<15; i++) |
762 |
|
add_response_word(cpu, r, cpu->cd.arm.r[i], len); |
763 |
|
add_response_word(cpu, r, cpu->pc, len); |
764 |
|
/* TODO: fprs: */ |
765 |
|
for (i=0; i<8; i++) |
766 |
|
add_response_word(cpu, r, 0, len); |
767 |
|
/* TODO: fps */ |
768 |
|
add_response_word(cpu, r, 0, len); |
769 |
|
add_response_word(cpu, r, cpu->cd.arm.cpsr, len); |
770 |
|
return r; |
771 |
} |
} |
772 |
|
|
773 |
return 1; |
if (cmd[0] == 'p') { |
774 |
|
int regnr = strtol(cmd + 1, NULL, 16); |
775 |
|
size_t len = 2 * sizeof(uint32_t) + 1; |
776 |
|
char *r = malloc(len); |
777 |
|
r[0] = '\0'; |
778 |
|
if (regnr == ARM_PC) { |
779 |
|
add_response_word(cpu, r, cpu->pc, len); |
780 |
|
} else if (regnr >= 0 && regnr < ARM_PC) { |
781 |
|
add_response_word(cpu, r, cpu->cd.arm.r[regnr], len); |
782 |
|
} else if (regnr >= 0x10 && regnr <= 0x17) { |
783 |
|
/* TODO: fprs */ |
784 |
|
add_response_word(cpu, r, 0, len); |
785 |
|
add_response_word(cpu, r, 0, len); |
786 |
|
add_response_word(cpu, r, 0, len); |
787 |
|
} else if (regnr == 0x18) { |
788 |
|
/* TODO: fps */ |
789 |
|
add_response_word(cpu, r, 0, len); |
790 |
|
} else if (regnr == 0x19) { |
791 |
|
add_response_word(cpu, r, cpu->cd.arm.cpsr, len); |
792 |
|
} |
793 |
|
return r; |
794 |
|
} |
795 |
|
|
796 |
|
fatal("arm_cpu_gdb_stub(): TODO\n"); |
797 |
|
return NULL; |
798 |
|
} |
799 |
|
|
800 |
|
|
801 |
|
/* |
802 |
|
* arm_irq_interrupt_assert(): |
803 |
|
*/ |
804 |
|
void arm_irq_interrupt_assert(struct interrupt *interrupt) |
805 |
|
{ |
806 |
|
struct cpu *cpu = (struct cpu *) interrupt->extra; |
807 |
|
cpu->cd.arm.irq_asserted = 1; |
808 |
|
} |
809 |
|
|
810 |
|
|
811 |
|
/* |
812 |
|
* arm_irq_interrupt_deassert(): |
813 |
|
*/ |
814 |
|
void arm_irq_interrupt_deassert(struct interrupt *interrupt) |
815 |
|
{ |
816 |
|
struct cpu *cpu = (struct cpu *) interrupt->extra; |
817 |
|
cpu->cd.arm.irq_asserted = 0; |
818 |
} |
} |
819 |
|
|
820 |
|
|
831 |
* cpu->pc for relative addresses. |
* cpu->pc for relative addresses. |
832 |
*/ |
*/ |
833 |
int arm_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
int arm_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
834 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
835 |
{ |
{ |
836 |
uint32_t iw, tmp; |
uint32_t iw, tmp; |
837 |
int main_opcode, secondary_opcode, s_bit, r16, r12, r8; |
int main_opcode, secondary_opcode, s_bit, r16, r12, r8; |
1323 |
* xxxx1100 0100nnnn ddddcccc oooommmm MCRR c,op,Rd,Rn,CRm |
* xxxx1100 0100nnnn ddddcccc oooommmm MCRR c,op,Rd,Rn,CRm |
1324 |
* xxxx1100 0101nnnn ddddcccc oooommmm MRRC c,op,Rd,Rn,CRm |
* xxxx1100 0101nnnn ddddcccc oooommmm MRRC c,op,Rd,Rn,CRm |
1325 |
*/ |
*/ |
1326 |
|
if ((iw & 0x0fe00fff) == 0x0c400000) { |
1327 |
|
debug("%s%s\t", iw & 0x100000? "mra" : "mar", |
1328 |
|
condition); |
1329 |
|
if (iw & 0x100000) |
1330 |
|
debug("%s,%s,acc0\n", |
1331 |
|
arm_regname[r12], arm_regname[r16]); |
1332 |
|
else |
1333 |
|
debug("acc0,%s,%s\n", |
1334 |
|
arm_regname[r12], arm_regname[r16]); |
1335 |
|
break; |
1336 |
|
} |
1337 |
if ((iw & 0x0fe00000) == 0x0c400000) { |
if ((iw & 0x0fe00000) == 0x0c400000) { |
1338 |
debug("%s%s\t", iw & 0x100000? "mrrc" : "mcrr", |
debug("%s%s\t", iw & 0x100000? "mrrc" : "mcrr", |
1339 |
condition); |
condition); |
1350 |
* xxxx1110 oooonnnn ddddpppp qqq0mmmm CDP |
* xxxx1110 oooonnnn ddddpppp qqq0mmmm CDP |
1351 |
* xxxx1110 oooLNNNN ddddpppp qqq1MMMM MRC/MCR |
* xxxx1110 oooLNNNN ddddpppp qqq1MMMM MRC/MCR |
1352 |
*/ |
*/ |
1353 |
|
if ((iw & 0x0ff00ff0) == 0x0e200010) { |
1354 |
|
/* Special case: mia* DSP instructions */ |
1355 |
|
switch ((iw >> 16) & 0xf) { |
1356 |
|
case 0: debug("mia"); break; |
1357 |
|
case 8: debug("miaph"); break; |
1358 |
|
case 12: debug("miaBB"); break; |
1359 |
|
case 13: debug("miaTB"); break; |
1360 |
|
case 14: debug("miaBT"); break; |
1361 |
|
case 15: debug("miaTT"); break; |
1362 |
|
default: debug("UNKNOWN mia vector instruction?"); |
1363 |
|
} |
1364 |
|
debug("%s\t", condition); |
1365 |
|
debug("acc%i,%s,%s\n", ((iw >> 5) & 7), |
1366 |
|
arm_regname[iw & 15], arm_regname[r12]); |
1367 |
|
break; |
1368 |
|
} |
1369 |
if (iw & 0x10) { |
if (iw & 0x10) { |
1370 |
debug("%s%s\t", |
debug("%s%s\t", |
1371 |
(iw & 0x00100000)? "mrc" : "mcr", condition); |
(iw & 0x00100000)? "mrc" : "mcr", condition); |