28 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
29 |
* |
* |
30 |
* |
* |
31 |
* $Id: cpu.h,v 1.109 2007/02/10 14:29:54 debug Exp $ |
* $Id: cpu.h,v 1.114 2007/04/10 17:26:20 debug Exp $ |
32 |
* |
* |
33 |
* CPU-related definitions. |
* CPU-related definitions. |
34 |
*/ |
*/ |
197 |
#include "cpu_m68k.h" |
#include "cpu_m68k.h" |
198 |
#include "cpu_mips.h" |
#include "cpu_mips.h" |
199 |
#include "cpu_ppc.h" |
#include "cpu_ppc.h" |
|
#include "cpu_rca180x.h" |
|
200 |
#include "cpu_sh.h" |
#include "cpu_sh.h" |
201 |
#include "cpu_sparc.h" |
#include "cpu_sparc.h" |
|
#include "cpu_transputer.h" |
|
202 |
|
|
203 |
struct cpu; |
struct cpu; |
204 |
struct emul; |
struct emul; |
255 |
(This is called for each function call, if running with -t.) */ |
(This is called for each function call, if running with -t.) */ |
256 |
void (*functioncall_trace)(struct cpu *, |
void (*functioncall_trace)(struct cpu *, |
257 |
uint64_t f, int n_args); |
uint64_t f, int n_args); |
|
|
|
|
/* GDB command handler. */ |
|
|
char *(*gdb_stub)(struct cpu *, char *cmd); |
|
258 |
}; |
}; |
259 |
|
|
260 |
|
|
277 |
#define DEFAULT_DYNTRANS_CACHE_SIZE (40*1048576) |
#define DEFAULT_DYNTRANS_CACHE_SIZE (40*1048576) |
278 |
#define DYNTRANS_CACHE_MARGIN 200000 |
#define DYNTRANS_CACHE_MARGIN 200000 |
279 |
|
|
280 |
#define N_BASE_TABLE_ENTRIES 32768 |
#define N_BASE_TABLE_ENTRIES 65536 |
281 |
#define PAGENR_TO_TABLE_INDEX(a) ((a) & (N_BASE_TABLE_ENTRIES-1)) |
#define PAGENR_TO_TABLE_INDEX(a) ((a) & (N_BASE_TABLE_ENTRIES-1)) |
282 |
|
|
283 |
|
|
284 |
|
#ifdef NATIVE_CODE_GENERATION |
285 |
|
/* |
286 |
|
* Intermediate Native Representation (INR). |
287 |
|
* Used for native code generation. |
288 |
|
*/ |
289 |
|
#include "inr.h" |
290 |
|
#endif |
291 |
|
|
292 |
|
|
293 |
/* |
/* |
294 |
* The generic CPU struct: |
* The generic CPU struct: |
295 |
*/ |
*/ |
373 |
* Note that it can also be adjusted negatively, that is, the way |
* Note that it can also be adjusted negatively, that is, the way |
374 |
* to "get out" of a dyntrans loop is to set the current instruction |
* to "get out" of a dyntrans loop is to set the current instruction |
375 |
* call pointer to the "nothing" instruction. This instruction |
* call pointer to the "nothing" instruction. This instruction |
376 |
* _decreases_ n_translated_instrs. That way, once the dyntrans loop |
* _decreases_ n_translated_instrs by 1. That way, once the dyntrans |
377 |
* exits, only real instructions will be counted, and not the |
* loop exits, only real instructions will be counted, and not the |
378 |
* "nothing" instructions. |
* "nothing" instructions. |
379 |
* |
* |
380 |
* The translation cache is a relative large chunk of memory (say, |
* The translation cache is a relative large chunk of memory (say, |
381 |
* 32 MB) which is used for translations. When it has been used up, |
* 32 MB) which is used for translations. When it has been used up, |
382 |
* everything restarts from scratch. |
* everything restarts from scratch. |
383 |
* |
* |
384 |
* When translating to native code, currently_translating_to_native |
* The INR struct contains the Intermediate Native Representation, |
385 |
* is non-zero, and native_code_function_pointer points to the |
* used during native code generation. |
|
* "ic->f" which will be modified (once the translation has finished) |
|
|
* to point to the newly translated code. |
|
386 |
*/ |
*/ |
387 |
int n_translated_instrs; |
int n_translated_instrs; |
388 |
unsigned char *translation_cache; |
unsigned char *translation_cache; |
389 |
size_t translation_cache_cur_ofs; |
size_t translation_cache_cur_ofs; |
390 |
int currently_translating_to_native; |
|
391 |
int nr_of_instructions_translated_to_native; |
#ifdef NATIVE_CODE_GENERATION |
392 |
unsigned char *native_cur_output_ptr; |
struct inr inr; |
393 |
void **native_code_function_pointer; |
#endif |
394 |
|
|
395 |
/* |
/* |
396 |
* CPU-family dependent: |
* CPU-family dependent: |
405 |
struct m68k_cpu m68k; |
struct m68k_cpu m68k; |
406 |
struct mips_cpu mips; |
struct mips_cpu mips; |
407 |
struct ppc_cpu ppc; |
struct ppc_cpu ppc; |
|
struct rca180x_cpu rca180x; |
|
408 |
struct sh_cpu sh; |
struct sh_cpu sh; |
409 |
struct sparc_cpu sparc; |
struct sparc_cpu sparc; |
|
struct transputer_cpu transputer; |
|
410 |
} cd; |
} cd; |
411 |
}; |
}; |
412 |
|
|
421 |
int gprs, int coprocs); |
int gprs, int coprocs); |
422 |
int cpu_disassemble_instr(struct machine *m, struct cpu *cpu, |
int cpu_disassemble_instr(struct machine *m, struct cpu *cpu, |
423 |
unsigned char *instr, int running, uint64_t addr); |
unsigned char *instr, int running, uint64_t addr); |
|
char *cpu_gdb_stub(struct cpu *cpu, char *cmd); |
|
424 |
|
|
425 |
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f); |
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f); |
426 |
void cpu_functioncall_trace_return(struct cpu *cpu); |
void cpu_functioncall_trace_return(struct cpu *cpu); |
472 |
fp->register_dump = n ## _cpu_register_dump; \ |
fp->register_dump = n ## _cpu_register_dump; \ |
473 |
fp->dumpinfo = n ## _cpu_dumpinfo; \ |
fp->dumpinfo = n ## _cpu_dumpinfo; \ |
474 |
fp->functioncall_trace = n ## _cpu_functioncall_trace; \ |
fp->functioncall_trace = n ## _cpu_functioncall_trace; \ |
|
fp->gdb_stub = n ## _cpu_gdb_stub; \ |
|
475 |
fp->tlbdump = n ## _cpu_tlbdump; \ |
fp->tlbdump = n ## _cpu_tlbdump; \ |
476 |
fp->init_tables = n ## _cpu_init_tables; \ |
fp->init_tables = n ## _cpu_init_tables; \ |
477 |
return 1; \ |
return 1; \ |