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: |
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
16 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 |
* ARE DISCLAIMED. IN NO EVENT HPPAALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
19 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
21 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_hppa.c,v 1.1 2005/09/07 07:10:16 debug Exp $ |
* $Id: cpu_hppa.c,v 1.16 2006/09/19 10:50:08 debug Exp $ |
29 |
* |
* |
30 |
* HP PA-RISC CPU emulation. |
* HP PA-RISC CPU emulation. |
31 |
* |
* |
41 |
#include "machine.h" |
#include "machine.h" |
42 |
#include "memory.h" |
#include "memory.h" |
43 |
#include "misc.h" |
#include "misc.h" |
44 |
|
#include "settings.h" |
45 |
#include "symbol.h" |
#include "symbol.h" |
46 |
|
|
47 |
|
|
71 |
cpu->cd.hppa.bits = 32; |
cpu->cd.hppa.bits = 32; |
72 |
|
|
73 |
if (cpu->is_32bit) { |
if (cpu->is_32bit) { |
74 |
|
cpu->run_instr = hppa32_run_instr; |
75 |
cpu->update_translation_table = hppa32_update_translation_table; |
cpu->update_translation_table = hppa32_update_translation_table; |
76 |
cpu->invalidate_translation_caches_paddr = |
cpu->invalidate_translation_caches = |
77 |
hppa32_invalidate_translation_caches_paddr; |
hppa32_invalidate_translation_caches; |
78 |
cpu->invalidate_code_translation = |
cpu->invalidate_code_translation = |
79 |
hppa32_invalidate_code_translation; |
hppa32_invalidate_code_translation; |
80 |
} else { |
} else { |
81 |
|
cpu->run_instr = hppa_run_instr; |
82 |
cpu->update_translation_table = hppa_update_translation_table; |
cpu->update_translation_table = hppa_update_translation_table; |
83 |
cpu->invalidate_translation_caches_paddr = |
cpu->invalidate_translation_caches = |
84 |
hppa_invalidate_translation_caches_paddr; |
hppa_invalidate_translation_caches; |
85 |
cpu->invalidate_code_translation = |
cpu->invalidate_code_translation = |
86 |
hppa_invalidate_code_translation; |
hppa_invalidate_code_translation; |
87 |
} |
} |
88 |
|
|
89 |
/* Only hppaow name and caches etc for CPU nr 0 (in SMP machines): */ |
/* Only show name and caches etc for CPU nr 0 (in SMP machines): */ |
90 |
if (cpu_id == 0) { |
if (cpu_id == 0) { |
91 |
debug("%s", cpu->name); |
debug("%s", cpu->name); |
92 |
} |
} |
93 |
|
|
94 |
|
/* Add all register names to the settings: */ |
95 |
|
CPU_SETTINGS_ADD_REGISTER64("pc", cpu->pc); |
96 |
|
|
97 |
return 1; |
return 1; |
98 |
} |
} |
99 |
|
|
131 |
void hppa_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs) |
void hppa_cpu_register_dump(struct cpu *cpu, int gprs, int coprocs) |
132 |
{ |
{ |
133 |
char *symbol; |
char *symbol; |
134 |
uint64_t offset, tmp; |
uint64_t offset; |
135 |
int i, x = cpu->cpu_id, nregs = 32; |
int i, x = cpu->cpu_id, nregs = 32; |
136 |
int bits32 = cpu->cd.hppa.bits == 32; |
int bits32 = cpu->cd.hppa.bits == 32; |
137 |
|
|
142 |
|
|
143 |
debug("cpu%i: pc = 0x", x); |
debug("cpu%i: pc = 0x", x); |
144 |
if (bits32) |
if (bits32) |
145 |
debug("%08x", (int)cpu->pc); |
debug("%08"PRIx32, (uint32_t) cpu->pc); |
146 |
else |
else |
147 |
debug("%016llx", (long long)cpu->pc); |
debug("%016"PRIx64, (uint64_t) cpu->pc); |
148 |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
149 |
|
|
150 |
if (bits32) { |
if (bits32) { |
152 |
for (i=0; i<nregs; i++) { |
for (i=0; i<nregs; i++) { |
153 |
if ((i % 4) == 0) |
if ((i % 4) == 0) |
154 |
debug("cpu%i:", x); |
debug("cpu%i:", x); |
155 |
debug(" r%02i = 0x%08x ", i, |
debug(" r%02i = 0x%08"PRIx32" ", i, |
156 |
(int)cpu->cd.hppa.r[i]); |
(uint32_t)cpu->cd.hppa.r[i]); |
157 |
if ((i % 4) == 3) |
if ((i % 4) == 3) |
158 |
debug("\n"); |
debug("\n"); |
159 |
} |
} |
163 |
int r = (i >> 1) + ((i & 1) << 4); |
int r = (i >> 1) + ((i & 1) << 4); |
164 |
if ((i % 2) == 0) |
if ((i % 2) == 0) |
165 |
debug("cpu%i:", x); |
debug("cpu%i:", x); |
166 |
debug(" r%02i = 0x%016llx ", r, |
debug(" r%02i = 0x%016"PRIx64" ", r, |
167 |
(long long)cpu->cd.hppa.r[r]); |
(uint64_t) cpu->cd.hppa.r[r]); |
168 |
if ((i % 2) == 1) |
if ((i % 2) == 1) |
169 |
debug("\n"); |
debug("\n"); |
170 |
} |
} |
174 |
|
|
175 |
|
|
176 |
/* |
/* |
|
* hppa_cpu_register_match(): |
|
|
*/ |
|
|
void hppa_cpu_register_match(struct machine *m, char *name, |
|
|
int writeflag, uint64_t *valuep, int *match_register) |
|
|
{ |
|
|
int cpunr = 0; |
|
|
|
|
|
/* CPU number: */ |
|
|
|
|
|
/* TODO */ |
|
|
|
|
|
/* Register name: */ |
|
|
if (strcasecmp(name, "pc") == 0) { |
|
|
if (writeflag) { |
|
|
m->cpus[cpunr]->pc = *valuep; |
|
|
} else |
|
|
*valuep = m->cpus[cpunr]->pc; |
|
|
*match_register = 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* hppa_cpu_show_full_statistics(): |
|
|
* |
|
|
* Show detailed statistics on opcode usage on each cpu. |
|
|
*/ |
|
|
void hppa_cpu_show_full_statistics(struct machine *m) |
|
|
{ |
|
|
fatal("hppa_cpu_show_full_statistics(): TODO\n"); |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
177 |
* hppa_cpu_tlbdump(): |
* hppa_cpu_tlbdump(): |
178 |
* |
* |
179 |
* Called from the debugger to dump the TLB in a readable format. |
* Called from the debugger to dump the TLB in a readable format. |
184 |
*/ |
*/ |
185 |
void hppa_cpu_tlbdump(struct machine *m, int x, int rawflag) |
void hppa_cpu_tlbdump(struct machine *m, int x, int rawflag) |
186 |
{ |
{ |
187 |
fatal("hppa_cpu_tlbdump(): TODO\n"); |
} |
188 |
|
|
189 |
|
|
190 |
|
/* |
191 |
|
* hppa_cpu_gdb_stub(): |
192 |
|
* |
193 |
|
* Execute a "remote GDB" command. Returns a newly allocated response string |
194 |
|
* on success, NULL on failure. |
195 |
|
*/ |
196 |
|
char *hppa_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
197 |
|
{ |
198 |
|
fatal("hppa_cpu_gdb_stub(): TODO\n"); |
199 |
|
return NULL; |
200 |
} |
} |
201 |
|
|
202 |
|
|
226 |
* Convert an instruction word into human readable format, for instruction |
* Convert an instruction word into human readable format, for instruction |
227 |
* tracing. |
* tracing. |
228 |
* |
* |
229 |
* If running is 1, cpu->pc hppaould be the address of the instruction. |
* If running is 1, cpu->pc should be the address of the instruction. |
230 |
* |
* |
231 |
* If running is 0, things that depend on the runtime environment (eg. |
* If running is 0, things that depend on the runtime environment (eg. |
232 |
* register contents) will not be hppaown, and addr will be used instead of |
* register contents) will not be shown, and addr will be used instead of |
233 |
* cpu->pc for relative addresses. |
* cpu->pc for relative addresses. |
234 |
*/ |
*/ |
235 |
int hppa_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr, |
int hppa_cpu_disassemble_instr(struct cpu *cpu, unsigned char *instr, |
236 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
237 |
{ |
{ |
238 |
uint64_t offset, addr; |
uint64_t offset; |
239 |
uint32_t iword; |
uint32_t iword; |
240 |
int hi6; |
char *symbol; |
|
char *symbol, *mnem = "ERROR"; |
|
241 |
|
|
242 |
if (running) |
if (running) |
243 |
dumpaddr = cpu->pc; |
dumpaddr = cpu->pc; |
251 |
debug("cpu%i: ", cpu->cpu_id); |
debug("cpu%i: ", cpu->cpu_id); |
252 |
|
|
253 |
if (cpu->cd.hppa.bits == 32) |
if (cpu->cd.hppa.bits == 32) |
254 |
debug("%08x", (int)dumpaddr); |
debug("%08"PRIx32, (uint32_t) dumpaddr); |
255 |
else |
else |
256 |
debug("%016llx", (long long)dumpaddr); |
debug("%016"PRIx64, (uint64_t) dumpaddr); |
257 |
|
|
258 |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
if (cpu->byte_order == EMUL_BIG_ENDIAN) |
259 |
iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8) |
iword = (instr[0] << 24) + (instr[1] << 16) + (instr[2] << 8) |
262 |
iword = (instr[3] << 24) + (instr[2] << 16) + (instr[1] << 8) |
iword = (instr[3] << 24) + (instr[2] << 16) + (instr[1] << 8) |
263 |
+ instr[0]; |
+ instr[0]; |
264 |
|
|
265 |
debug(": %08x\t", iword); |
debug(": %08"PRIx32"\t", (uint32_t) iword); |
266 |
|
|
267 |
/* |
/* |
268 |
* Decode the instruction: |
* Decode the instruction: |