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.7 2005/10/22 17:24:21 debug Exp $ |
* $Id: cpu_sh.c,v 1.15 2006/06/16 18:31:26 debug Exp $ |
29 |
* |
* |
30 |
* Hitachi SuperH ("SH") CPU emulation. |
* Hitachi SuperH ("SH") CPU emulation. |
31 |
* |
* |
89 |
debug("%s", cpu->name); |
debug("%s", cpu->name); |
90 |
} |
} |
91 |
|
|
92 |
|
sh_init_64bit_dummy_tables(cpu); |
93 |
|
|
94 |
return 1; |
return 1; |
95 |
} |
} |
96 |
|
|
128 |
void sh_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs) |
void sh_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs) |
129 |
{ |
{ |
130 |
char *symbol; |
char *symbol; |
131 |
uint64_t offset, tmp; |
uint64_t offset; |
132 |
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; |
133 |
int bits32 = cpu->cd.sh.bits == 32; |
int bits32 = cpu->cd.sh.bits == 32; |
134 |
|
|
194 |
|
|
195 |
|
|
196 |
/* |
/* |
|
* 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"); |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
197 |
* sh_cpu_tlbdump(): |
* sh_cpu_tlbdump(): |
198 |
* |
* |
199 |
* Called from the debugger to dump the TLB in a readable format. |
* Called from the debugger to dump the TLB in a readable format. |
204 |
*/ |
*/ |
205 |
void sh_cpu_tlbdump(struct machine *m, int x, int rawflag) |
void sh_cpu_tlbdump(struct machine *m, int x, int rawflag) |
206 |
{ |
{ |
207 |
fatal("sh_cpu_tlbdump(): TODO\n"); |
} |
208 |
|
|
209 |
|
|
210 |
|
/* |
211 |
|
* sh_cpu_gdb_stub(): |
212 |
|
* |
213 |
|
* Execute a "remote GDB" command. Returns a newly allocated response string |
214 |
|
* on success, NULL on failure. |
215 |
|
*/ |
216 |
|
char *sh_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
217 |
|
{ |
218 |
|
fatal("sh_cpu_gdb_stub(): TODO\n"); |
219 |
|
return NULL; |
220 |
} |
} |
221 |
|
|
222 |
|
|
248 |
* lowest 4 or 8 bits then select sub-opcode. |
* lowest 4 or 8 bits then select sub-opcode. |
249 |
*/ |
*/ |
250 |
int sh_cpu_disassemble_instr_compact(struct cpu *cpu, unsigned char *instr, |
int sh_cpu_disassemble_instr_compact(struct cpu *cpu, unsigned char *instr, |
251 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
252 |
{ |
{ |
253 |
uint64_t offset, addr; |
uint64_t addr; |
254 |
uint16_t iword; |
uint16_t iword; |
255 |
int hi4, lo4, lo8, r8, r4; |
int hi4, lo4, lo8, r8, r4; |
|
char *symbol, *mnem = "ERROR"; |
|
256 |
|
|
257 |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
258 |
iword = (instr[0] << 8) + instr[1]; |
iword = (instr[0] << 8) + instr[1]; |
571 |
* cpu->pc for relative addresses. |
* cpu->pc for relative addresses. |
572 |
*/ |
*/ |
573 |
int sh_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr, |
int sh_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr, |
574 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
575 |
{ |
{ |
576 |
uint64_t offset, addr; |
uint64_t offset; |
577 |
uint32_t iword; |
uint32_t iword; |
578 |
int hi6; |
char *symbol; |
|
char *symbol, *mnem = "ERROR"; |
|
579 |
|
|
580 |
if (running) |
if (running) |
581 |
dumpaddr = cpu->pc; |
dumpaddr = cpu->pc; |
595 |
|
|
596 |
if (cpu->cd.sh.compact) |
if (cpu->cd.sh.compact) |
597 |
return sh_cpu_disassemble_instr_compact(cpu, instr, |
return sh_cpu_disassemble_instr_compact(cpu, instr, |
598 |
running, dumpaddr, bintrans); |
running, dumpaddr); |
599 |
|
|
600 |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
601 |
iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8) |
iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8) |