7 |
#define __CPU_H__ |
#define __CPU_H__ |
8 |
|
|
9 |
#include <pthread.h> |
#include <pthread.h> |
10 |
|
#include <setjmp.h> |
11 |
#include "utils.h" |
#include "utils.h" |
12 |
|
#include "jit_op.h" |
|
/* Forward declaration for generic CPU type */ |
|
|
typedef struct cpu_gen cpu_gen_t; |
|
13 |
|
|
14 |
#include "mips64.h" |
#include "mips64.h" |
15 |
#include "mips64_cp0.h" |
#include "mips64_cp0.h" |
50 |
m_uint32_t op_type; |
m_uint32_t op_type; |
51 |
}; |
}; |
52 |
|
|
53 |
|
/* Undefined memory access handler */ |
54 |
|
typedef int (*cpu_undefined_mem_handler_t)(cpu_gen_t *cpu,m_uint64_t vaddr, |
55 |
|
u_int op_size,u_int op_type, |
56 |
|
m_uint64_t *data); |
57 |
|
|
58 |
/* Generic CPU definition */ |
/* Generic CPU definition */ |
59 |
struct cpu_gen { |
struct cpu_gen { |
60 |
/* CPU type and identifier for MP systems */ |
/* CPU type and identifier for MP systems */ |
68 |
pthread_t cpu_thread; |
pthread_t cpu_thread; |
69 |
int cpu_thread_running; |
int cpu_thread_running; |
70 |
|
|
71 |
|
/* Exception restore point */ |
72 |
|
jmp_buf exec_loop_env; |
73 |
|
|
74 |
/* "Idle" loop management */ |
/* "Idle" loop management */ |
75 |
u_int idle_count,idle_max,idle_sleep_time; |
u_int idle_count,idle_max,idle_sleep_time; |
76 |
pthread_mutex_t idle_mutex; |
pthread_mutex_t idle_mutex; |
104 |
void (*mts_rebuild)(cpu_gen_t *cpu); |
void (*mts_rebuild)(cpu_gen_t *cpu); |
105 |
void (*mts_show_stats)(cpu_gen_t *cpu); |
void (*mts_show_stats)(cpu_gen_t *cpu); |
106 |
|
|
107 |
|
cpu_undefined_mem_handler_t undef_mem_handler; |
108 |
|
|
109 |
/* Memory access log for fault debugging */ |
/* Memory access log for fault debugging */ |
110 |
u_int memlog_pos; |
u_int memlog_pos; |
111 |
memlog_access_t memlog_array[MEMLOG_COUNT]; |
memlog_access_t memlog_array[MEMLOG_COUNT]; |
112 |
|
|
113 |
/* Statistics */ |
/* Statistics */ |
114 |
m_uint64_t dev_access_counter; |
m_uint64_t dev_access_counter; |
115 |
|
|
116 |
|
/* JIT op array for current compiled page */ |
117 |
|
u_int jit_op_array_size; |
118 |
|
jit_op_t **jit_op_array; |
119 |
|
jit_op_t **jit_op_current; |
120 |
|
|
121 |
|
/* JIT op pool */ |
122 |
|
jit_op_t *jit_op_pool[JIT_OP_POOL_NR]; |
123 |
}; |
}; |
124 |
|
|
125 |
/* CPU group definition */ |
/* CPU group definition */ |
147 |
} |
} |
148 |
|
|
149 |
/* Get CPU performance counter */ |
/* Get CPU performance counter */ |
150 |
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) |
151 |
{ |
{ |
152 |
switch(cpu->type) { |
switch(cpu->type) { |
153 |
case CPU_TYPE_MIPS64: |
case CPU_TYPE_MIPS64: |
216 |
/* Break idle wait state */ |
/* Break idle wait state */ |
217 |
void cpu_idle_break_wait(cpu_gen_t *cpu); |
void cpu_idle_break_wait(cpu_gen_t *cpu); |
218 |
|
|
219 |
|
/* Returns to the CPU exec loop */ |
220 |
|
static inline void cpu_exec_loop_enter(cpu_gen_t *cpu) |
221 |
|
{ |
222 |
|
longjmp(cpu->exec_loop_env,1); |
223 |
|
} |
224 |
|
|
225 |
|
/* Set the exec loop entry point */ |
226 |
|
#define cpu_exec_loop_set(cpu) setjmp((cpu)->exec_loop_env) |
227 |
|
|
228 |
#endif |
#endif |