--- upstream/dynamips-0.2.7/cpu.h 2007/10/06 16:29:14 10 +++ upstream/dynamips-0.2.8-RC1/cpu.h 2007/10/06 16:33:40 11 @@ -7,6 +7,7 @@ #define __CPU_H__ #include +#include #include "utils.h" #include "jit_op.h" @@ -49,6 +50,11 @@ m_uint32_t op_type; }; +/* Undefined memory access handler */ +typedef int (*cpu_undefined_mem_handler_t)(cpu_gen_t *cpu,m_uint64_t vaddr, + u_int op_size,u_int op_type, + m_uint64_t *data); + /* Generic CPU definition */ struct cpu_gen { /* CPU type and identifier for MP systems */ @@ -62,6 +68,9 @@ pthread_t cpu_thread; int cpu_thread_running; + /* Exception restore point */ + jmp_buf exec_loop_env; + /* "Idle" loop management */ u_int idle_count,idle_max,idle_sleep_time; pthread_mutex_t idle_mutex; @@ -95,6 +104,8 @@ void (*mts_rebuild)(cpu_gen_t *cpu); void (*mts_show_stats)(cpu_gen_t *cpu); + cpu_undefined_mem_handler_t undef_mem_handler; + /* Memory access log for fault debugging */ u_int memlog_pos; memlog_access_t memlog_array[MEMLOG_COUNT]; @@ -136,7 +147,7 @@ } /* Get CPU performance counter */ -static forced_inline m_uint64_t cpu_get_perf_counter(cpu_gen_t *cpu) +static forced_inline m_uint32_t cpu_get_perf_counter(cpu_gen_t *cpu) { switch(cpu->type) { case CPU_TYPE_MIPS64: @@ -205,4 +216,13 @@ /* Break idle wait state */ void cpu_idle_break_wait(cpu_gen_t *cpu); +/* Returns to the CPU exec loop */ +static inline void cpu_exec_loop_enter(cpu_gen_t *cpu) +{ + longjmp(cpu->exec_loop_env,1); +} + +/* Set the exec loop entry point */ +#define cpu_exec_loop_set(cpu) setjmp((cpu)->exec_loop_env) + #endif