1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2006 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_sh.c,v 1.6 2005/09/04 14:38:17 debug Exp $ |
* $Id: cpu_sh.c,v 1.16 2006/06/24 21:47:23 debug Exp $ |
29 |
* |
* |
30 |
* Hitachi SuperH ("SH") CPU emulation. |
* Hitachi SuperH ("SH") CPU emulation. |
31 |
* |
* |
72 |
|
|
73 |
if (cpu->is_32bit) { |
if (cpu->is_32bit) { |
74 |
cpu->update_translation_table = sh32_update_translation_table; |
cpu->update_translation_table = sh32_update_translation_table; |
75 |
cpu->invalidate_translation_caches_paddr = |
cpu->invalidate_translation_caches = |
76 |
sh32_invalidate_translation_caches_paddr; |
sh32_invalidate_translation_caches; |
77 |
cpu->invalidate_code_translation = |
cpu->invalidate_code_translation = |
78 |
sh32_invalidate_code_translation; |
sh32_invalidate_code_translation; |
79 |
} else { |
} else { |
80 |
cpu->update_translation_table = sh_update_translation_table; |
cpu->update_translation_table = sh_update_translation_table; |
81 |
cpu->invalidate_translation_caches_paddr = |
cpu->invalidate_translation_caches = |
82 |
sh_invalidate_translation_caches_paddr; |
sh_invalidate_translation_caches; |
83 |
cpu->invalidate_code_translation = |
cpu->invalidate_code_translation = |
84 |
sh_invalidate_code_translation; |
sh_invalidate_code_translation; |
85 |
} |
} |
126 |
void sh_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs) |
void sh_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs) |
127 |
{ |
{ |
128 |
char *symbol; |
char *symbol; |
129 |
uint64_t offset, tmp; |
uint64_t offset; |
130 |
int i, x = cpu->cpu_id, nregs = cpu->cd.sh.compact? 16 : 64; |
int i, x = cpu->cpu_id, nregs = cpu->cd.sh.compact? 16 : 64; |
131 |
int bits32 = cpu->cd.sh.bits == 32; |
int bits32 = cpu->cd.sh.bits == 32; |
132 |
|
|
192 |
|
|
193 |
|
|
194 |
/* |
/* |
|
* sh_cpu_show_full_statistics(): |
|
|
* |
|
|
* Show detailed statistics on opcode usage on each cpu. |
|
|
*/ |
|
|
void sh_cpu_show_full_statistics(struct machine *m) |
|
|
{ |
|
|
fatal("sh_cpu_show_full_statistics(): TODO\n"); |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
195 |
* sh_cpu_tlbdump(): |
* sh_cpu_tlbdump(): |
196 |
* |
* |
197 |
* Called from the debugger to dump the TLB in a readable format. |
* Called from the debugger to dump the TLB in a readable format. |
202 |
*/ |
*/ |
203 |
void sh_cpu_tlbdump(struct machine *m, int x, int rawflag) |
void sh_cpu_tlbdump(struct machine *m, int x, int rawflag) |
204 |
{ |
{ |
205 |
fatal("sh_cpu_tlbdump(): TODO\n"); |
} |
206 |
|
|
207 |
|
|
208 |
|
/* |
209 |
|
* sh_cpu_gdb_stub(): |
210 |
|
* |
211 |
|
* Execute a "remote GDB" command. Returns a newly allocated response string |
212 |
|
* on success, NULL on failure. |
213 |
|
*/ |
214 |
|
char *sh_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
215 |
|
{ |
216 |
|
fatal("sh_cpu_gdb_stub(): TODO\n"); |
217 |
|
return NULL; |
218 |
} |
} |
219 |
|
|
220 |
|
|
246 |
* lowest 4 or 8 bits then select sub-opcode. |
* lowest 4 or 8 bits then select sub-opcode. |
247 |
*/ |
*/ |
248 |
int sh_cpu_disassemble_instr_compact(struct cpu *cpu, unsigned char *instr, |
int sh_cpu_disassemble_instr_compact(struct cpu *cpu, unsigned char *instr, |
249 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
250 |
{ |
{ |
251 |
uint64_t offset, addr; |
uint64_t addr; |
252 |
uint16_t iword; |
uint16_t iword; |
253 |
int hi4, lo4, lo8, r8, r4; |
int hi4, lo4, lo8, r8, r4; |
|
char *symbol, *mnem = "ERROR"; |
|
254 |
|
|
255 |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
256 |
iword = (instr[0] << 8) + instr[1]; |
iword = (instr[0] << 8) + instr[1]; |
569 |
* cpu->pc for relative addresses. |
* cpu->pc for relative addresses. |
570 |
*/ |
*/ |
571 |
int sh_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr, |
int sh_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr, |
572 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
573 |
{ |
{ |
574 |
uint64_t offset, addr; |
uint64_t offset; |
575 |
uint32_t iword; |
uint32_t iword; |
576 |
int hi6; |
char *symbol; |
|
char *symbol, *mnem = "ERROR"; |
|
577 |
|
|
578 |
if (running) |
if (running) |
579 |
dumpaddr = cpu->pc; |
dumpaddr = cpu->pc; |
593 |
|
|
594 |
if (cpu->cd.sh.compact) |
if (cpu->cd.sh.compact) |
595 |
return sh_cpu_disassemble_instr_compact(cpu, instr, |
return sh_cpu_disassemble_instr_compact(cpu, instr, |
596 |
running, dumpaddr, bintrans); |
running, dumpaddr); |
597 |
|
|
598 |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
599 |
iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8) |
iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8) |