2 |
#define CPU_H |
#define CPU_H |
3 |
|
|
4 |
/* |
/* |
5 |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 Anders Gavare. All rights reserved. |
6 |
* |
* |
7 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
8 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
28 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
29 |
* |
* |
30 |
* |
* |
31 |
* $Id: cpu.h,v 1.100 2006/10/25 09:24:06 debug Exp $ |
* $Id: cpu.h,v 1.109 2007/02/10 14:29:54 debug Exp $ |
32 |
* |
* |
33 |
* CPU-related definitions. |
* CPU-related definitions. |
34 |
*/ |
*/ |
194 |
#include "cpu_alpha.h" |
#include "cpu_alpha.h" |
195 |
#include "cpu_arm.h" |
#include "cpu_arm.h" |
196 |
#include "cpu_avr.h" |
#include "cpu_avr.h" |
|
#include "cpu_avr32.h" |
|
|
#include "cpu_hppa.h" |
|
|
#include "cpu_i960.h" |
|
|
#include "cpu_ia64.h" |
|
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" |
201 |
#include "cpu_sh.h" |
#include "cpu_sh.h" |
202 |
#include "cpu_sparc.h" |
#include "cpu_sparc.h" |
203 |
#include "cpu_transputer.h" |
#include "cpu_transputer.h" |
|
#include "cpu_x86.h" |
|
204 |
|
|
205 |
struct cpu; |
struct cpu; |
206 |
struct emul; |
struct emul; |
253 |
void (*tlbdump)(struct machine *m, int x, |
void (*tlbdump)(struct machine *m, int x, |
254 |
int rawflag); |
int rawflag); |
255 |
|
|
|
/* Assert an interrupt. */ |
|
|
int (*interrupt)(struct cpu *cpu, uint64_t irq_nr); |
|
|
|
|
|
/* De-assert an interrupt. */ |
|
|
int (*interrupt_ack)(struct cpu *cpu, |
|
|
uint64_t irq_nr); |
|
|
|
|
256 |
/* Print architecture-specific function call arguments. |
/* Print architecture-specific function call arguments. |
257 |
(This is called for each function call, if running with -t.) */ |
(This is called for each function call, if running with -t.) */ |
258 |
void (*functioncall_trace)(struct cpu *, |
void (*functioncall_trace)(struct cpu *, |
279 |
#define N_SAFE_DYNTRANS_LIMIT_SHIFT 14 |
#define N_SAFE_DYNTRANS_LIMIT_SHIFT 14 |
280 |
#define N_SAFE_DYNTRANS_LIMIT ((1 << (N_SAFE_DYNTRANS_LIMIT_SHIFT - 1)) - 1) |
#define N_SAFE_DYNTRANS_LIMIT ((1 << (N_SAFE_DYNTRANS_LIMIT_SHIFT - 1)) - 1) |
281 |
|
|
282 |
#define DYNTRANS_CACHE_SIZE (32*1048576) |
#define DEFAULT_DYNTRANS_CACHE_SIZE (40*1048576) |
283 |
#define DYNTRANS_CACHE_MARGIN 200000 |
#define DYNTRANS_CACHE_MARGIN 200000 |
284 |
|
|
285 |
#define N_BASE_TABLE_ENTRIES 32768 |
#define N_BASE_TABLE_ENTRIES 32768 |
300 |
/* CPU-specific name, e.g. "R2000", "21164PC", etc. */ |
/* CPU-specific name, e.g. "R2000", "21164PC", etc. */ |
301 |
char *name; |
char *name; |
302 |
|
|
303 |
|
/* Full "path" to the CPU, e.g. "emul[0].machine[0].cpu[0]": */ |
304 |
|
char *path; |
305 |
|
|
306 |
/* EMUL_LITTLE_ENDIAN or EMUL_BIG_ENDIAN. */ |
/* EMUL_LITTLE_ENDIAN or EMUL_BIG_ENDIAN. */ |
307 |
int byte_order; |
int byte_order; |
308 |
|
|
372 |
* _decreases_ n_translated_instrs. That way, once the dyntrans loop |
* _decreases_ n_translated_instrs. That way, once the dyntrans loop |
373 |
* exits, only real instructions will be counted, and not the |
* exits, only real instructions will be counted, and not the |
374 |
* "nothing" instructions. |
* "nothing" instructions. |
375 |
|
* |
376 |
|
* The translation cache is a relative large chunk of memory (say, |
377 |
|
* 32 MB) which is used for translations. When it has been used up, |
378 |
|
* everything restarts from scratch. |
379 |
|
* |
380 |
|
* When translating to native code, currently_translating_to_native |
381 |
|
* is non-zero, and native_code_function_pointer points to the |
382 |
|
* "ic->f" which will be modified (once the translation has finished) |
383 |
|
* to point to the newly translated code. |
384 |
*/ |
*/ |
385 |
int n_translated_instrs; |
int n_translated_instrs; |
386 |
unsigned char *translation_cache; |
unsigned char *translation_cache; |
387 |
size_t translation_cache_cur_ofs; |
size_t translation_cache_cur_ofs; |
388 |
|
int currently_translating_to_native; |
389 |
|
int nr_of_instructions_translated_to_native; |
390 |
|
unsigned char *native_cur_output_ptr; |
391 |
|
void **native_code_function_pointer; |
392 |
|
|
393 |
/* |
/* |
394 |
* CPU-family dependent: |
* CPU-family dependent: |
400 |
struct alpha_cpu alpha; |
struct alpha_cpu alpha; |
401 |
struct arm_cpu arm; |
struct arm_cpu arm; |
402 |
struct avr_cpu avr; |
struct avr_cpu avr; |
|
struct avr32_cpu avr32; |
|
|
struct hppa_cpu hppa; |
|
|
struct i960_cpu i960; |
|
|
struct ia64_cpu ia64; |
|
403 |
struct m68k_cpu m68k; |
struct m68k_cpu m68k; |
404 |
struct mips_cpu mips; |
struct mips_cpu mips; |
405 |
struct ppc_cpu ppc; |
struct ppc_cpu ppc; |
407 |
struct sh_cpu sh; |
struct sh_cpu sh; |
408 |
struct sparc_cpu sparc; |
struct sparc_cpu sparc; |
409 |
struct transputer_cpu transputer; |
struct transputer_cpu transputer; |
|
struct x86_cpu x86; |
|
410 |
} cd; |
} cd; |
411 |
}; |
}; |
412 |
|
|
423 |
unsigned char *instr, int running, uint64_t addr); |
unsigned char *instr, int running, uint64_t addr); |
424 |
char *cpu_gdb_stub(struct cpu *cpu, char *cmd); |
char *cpu_gdb_stub(struct cpu *cpu, char *cmd); |
425 |
|
|
|
int cpu_interrupt(struct cpu *cpu, uint64_t irq_nr); |
|
|
int cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr); |
|
426 |
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f); |
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f); |
427 |
void cpu_functioncall_trace_return(struct cpu *cpu); |
void cpu_functioncall_trace_return(struct cpu *cpu); |
428 |
|
|
472 |
fp->disassemble_instr = n ## _cpu_disassemble_instr; \ |
fp->disassemble_instr = n ## _cpu_disassemble_instr; \ |
473 |
fp->register_dump = n ## _cpu_register_dump; \ |
fp->register_dump = n ## _cpu_register_dump; \ |
474 |
fp->dumpinfo = n ## _cpu_dumpinfo; \ |
fp->dumpinfo = n ## _cpu_dumpinfo; \ |
|
fp->interrupt = n ## _cpu_interrupt; \ |
|
|
fp->interrupt_ack = n ## _cpu_interrupt_ack; \ |
|
475 |
fp->functioncall_trace = n ## _cpu_functioncall_trace; \ |
fp->functioncall_trace = n ## _cpu_functioncall_trace; \ |
476 |
fp->gdb_stub = n ## _cpu_gdb_stub; \ |
fp->gdb_stub = n ## _cpu_gdb_stub; \ |
477 |
fp->tlbdump = n ## _cpu_tlbdump; \ |
fp->tlbdump = n ## _cpu_tlbdump; \ |