33 #include <sys/types.h> 46 static struct cpu_family *first_cpu_family = NULL;
67 fprintf(stderr,
"cpu_new(): cpu name = NULL?\n");
77 "%s.cpu[%i]", machine->
path, cpu_id);
80 cpu->
name = cpu_type_name;
89 snprintf(tmpstr,
sizeof(tmpstr),
"cpu[%i]", cpu_id);
100 fp = first_cpu_family;
104 if (fp->
cpu_new(cpu, mem, machine, cpu_id,
108 fatal(
"\ncpu_new(): memory_rw == " 120 fatal(
"\ncpu_new(): unknown cpu type '%s'\n", cpu_type_name);
127 fatal(
"\ncpu_new(): Internal bug: Endianness not set.\n");
150 if (cpu->
path != NULL)
155 munmap((
void *)cpu,
sizeof(
struct cpu));
171 fatal(
"cpu_tlbdump(): NULL\n");
187 fatal(
"cpu_disassemble_instr(): NULL\n");
204 int gprs,
int coprocs)
207 fatal(
"cpu_register_dump(): NULL\n");
221 int show_symbolic_function_name = 1;
229 show_symbolic_function_name = 0;
243 f, &offset, &n_args);
244 if (symbol != NULL && show_symbolic_function_name)
248 fatal(
"0x%" PRIx32, (uint32_t) f);
250 fatal(
"0x%" PRIx64, (uint64_t) f);
259 #ifdef PRINT_MEMORY_CHECKSUM 301 N_BASE_TABLE_ENTRIES *
sizeof(uint32_t);
321 cpu->
running?
"running" :
"stopped");
324 fatal(
"cpu_dumpinfo(): NULL\n");
340 fp = first_cpu_family;
343 debug(
"No CPUs defined!\n");
353 debug(
"(internal error: list_available_types" 403 int64_t mseconds, ninstrs, is, avg;
407 static int64_t mseconds_last = 0;
408 static int64_t ninstrs_last = -1;
412 gettimeofday(&tv, NULL);
413 mseconds = (tv.tv_sec - cpu->
starttime.tv_sec) * 1000
414 + (tv.tv_usec - cpu->
starttime.tv_usec) / 1000;
419 if (mseconds - mseconds_last == 0)
428 printf(
"[ %" PRIi64
" instrs", (int64_t) cpu->
ninstrs);
431 is = 1000 * (ninstrs-ninstrs_last) / (mseconds-mseconds_last);
432 avg = (
long long)1000 * ninstrs / mseconds;
442 printf(
"; i/s=%" PRIi64
" avg=%" PRIi64, is, avg);
446 if (machine->
ncpus == 1) {
448 printf(
"; pc=0x%08" PRIx32, (uint32_t) pc);
450 printf(
"; pc=0x%016" PRIx64, (uint64_t) pc);
459 printf(
" <%s>", symbol);
464 mseconds_last = mseconds;
478 if (machine->
ncpus == 0) {
479 printf(
"Machine with no CPUs? TODO.\n");
483 for (i=0; i<machine->
ncpus; i++) {
503 static void add_cpu_family(
int (*family_init)(
struct cpu_family *),
int arch)
516 res = family_init(fp);
525 tmp = first_cpu_family;
527 first_cpu_family = fp;
529 while (tmp->
next != NULL)
544 fp = first_cpu_family;
549 if (arch == fp->
arch)
569 ADD_ALL_CPU_FAMILIES;
void cpu_list_available_types(void)
#define SETTINGS_TYPE_UINT8
void * zeroed_alloc(size_t s)
void fatal(const char *fmt,...)
#define EMUL_UNDEFINED_ENDIAN
#define DEBUG_INDENTATION
void cpu_dumpinfo(struct machine *m, struct cpu *cpu)
#define SETTINGS_FORMAT_YESNO
struct settings * settings_new(void)
void(* list_available_types)(void)
#define DYNTRANS_CACHE_MARGIN
void cpu_tlbdump(struct machine *m, int x, int rawflag)
void(* dumpinfo)(struct cpu *cpu)
#define SETTINGS_TYPE_STRING
void cpu_run_deinit(struct machine *machine)
struct cpu * cpu_new(struct memory *mem, struct machine *machine, int cpu_id, char *name)
void f(int s, int func, int only_name)
struct settings * settings
void(* functioncall_trace)(struct cpu *, int n_args)
char * get_symbol_name(struct symbol_context *, uint64_t addr, uint64_t *offset)
void cpu_show_cycles(struct machine *machine, int forced)
void(* register_dump)(struct cpu *cpu, int gprs, int coprocs)
#define CHECK_ALLOCATION(ptr)
uint64_t memory_checksum(struct memory *mem)
void cpu_destroy(struct cpu *cpu)
int(* memory_rw)(struct cpu *cpu, struct memory *mem, uint64_t vaddr, unsigned char *data, size_t len, int writeflag, int cache_flags)
void settings_remove(struct settings *settings, const char *name)
void settings_destroy(struct settings *settings)
void(* tlbdump)(struct machine *m, int x, int rawflag)
size_t translation_cache_cur_ofs
#define SETTINGS_FORMAT_STRING
unsigned char * translation_cache
void cpu_register_dump(struct machine *m, struct cpu *cpu, int gprs, int coprocs)
struct cpu_family * cpu_family_ptr_by_number(int arch)
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f)
int(* disassemble_instr)(struct cpu *cpu, unsigned char *instr, int running, uint64_t dumpaddr)
void cpu_functioncall_trace_return(struct cpu *cpu)
#define SETTINGS_TYPE_SUBSETTINGS
uint32_t cr[N_M88K_CONTROL_REGS]
void COMBINE() strlen(struct cpu *cpu, struct arm_instr_call *ic, int low_addr)
void f(struct cpu *, void *)
void debug_indentation(int diff)
int64_t ninstrs_since_gettimeofday
struct symbol_context symbol_context
void settings_remove_all(struct settings *settings)
void settings_add(struct settings *settings, const char *name, int writable, int type, int format, void *ptr)
struct settings * settings
void cpu_run_init(struct machine *machine)
int(* cpu_new)(struct cpu *cpu, struct memory *mem, struct machine *machine, int cpu_id, char *cpu_type_name)
#define N_BASE_TABLE_ENTRIES
size_t dyntrans_cache_size
char * get_symbol_name_and_n_args(struct symbol_context *, uint64_t addr, uint64_t *offset, int *n_argsp)
int cpu_disassemble_instr(struct machine *m, struct cpu *cpu, unsigned char *instr, int running, uint64_t addr)
void cpu_create_or_reset_tc(struct cpu *cpu)
void(* invalidate_code_translation)(struct cpu *, uint64_t paddr, int flags)
int show_nr_of_instructions
struct tick_functions tick_functions
struct cpu_family * cpu_family
void(* init_tables)(struct cpu *cpu)