28 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
29 |
* |
* |
30 |
* |
* |
31 |
* $Id: cpu.h,v 1.27 2005/06/27 10:43:17 debug Exp $ |
* $Id: cpu.h,v 1.43 2005/08/16 05:37:13 debug Exp $ |
32 |
* |
* |
33 |
* See cpu.c. |
* See cpu.c. |
34 |
*/ |
*/ |
42 |
#include "../../config.h" |
#include "../../config.h" |
43 |
|
|
44 |
#include "cpu_arm.h" |
#include "cpu_arm.h" |
45 |
|
#include "cpu_alpha.h" |
46 |
|
#include "cpu_ia64.h" |
47 |
|
#include "cpu_m68k.h" |
48 |
#include "cpu_mips.h" |
#include "cpu_mips.h" |
49 |
#include "cpu_ppc.h" |
#include "cpu_ppc.h" |
50 |
#include "cpu_urisc.h" |
#include "cpu_sparc.h" |
51 |
#include "cpu_x86.h" |
#include "cpu_x86.h" |
52 |
|
|
53 |
struct cpu; |
struct cpu; |
83 |
int (*interrupt)(struct cpu *cpu, uint64_t irq_nr); |
int (*interrupt)(struct cpu *cpu, uint64_t irq_nr); |
84 |
int (*interrupt_ack)(struct cpu *cpu, |
int (*interrupt_ack)(struct cpu *cpu, |
85 |
uint64_t irq_nr); |
uint64_t irq_nr); |
86 |
|
void (*functioncall_trace)(struct cpu *, |
87 |
|
uint64_t f, int n_args); |
88 |
}; |
}; |
89 |
|
|
90 |
#ifdef TRACE_NULL_CRASHES |
#ifdef TRACE_NULL_CRASHES |
91 |
#define TRACE_NULL_N_ENTRIES 16 |
#define TRACE_NULL_N_ENTRIES 16 |
92 |
#endif |
#endif |
93 |
|
|
94 |
|
|
95 |
|
/* |
96 |
|
* Dynamic translation definitions: |
97 |
|
* |
98 |
|
* The translation cache begins with N_BASE_TABLE_ENTRIES uint32_t offsets |
99 |
|
* into the cache, for possible translation cache structs for physical pages. |
100 |
|
*/ |
101 |
|
|
102 |
|
/* Physpage flags: */ |
103 |
|
#define TRANSLATIONS 1 |
104 |
|
#define COMBINATIONS 2 |
105 |
|
|
106 |
|
#define DYNTRANS_CACHE_SIZE (16*1048576) |
107 |
|
#define DYNTRANS_CACHE_MARGIN 300000 |
108 |
|
|
109 |
|
#define N_BASE_TABLE_ENTRIES 32768 |
110 |
|
#define PAGENR_TO_TABLE_INDEX(a) ((a) & (N_BASE_TABLE_ENTRIES-1)) |
111 |
|
|
112 |
|
|
113 |
|
/* |
114 |
|
* The generic CPU struct: |
115 |
|
*/ |
116 |
|
|
117 |
struct cpu { |
struct cpu { |
118 |
/* Pointer back to the machine this CPU is in: */ |
/* Pointer back to the machine this CPU is in: */ |
119 |
struct machine *machine; |
struct machine *machine; |
123 |
int dead; |
int dead; |
124 |
int bootstrap_cpu_flag; |
int bootstrap_cpu_flag; |
125 |
int cpu_id; |
int cpu_id; |
126 |
|
int is_32bit; /* 0 for 64-bit, 1 for 32-bit */ |
127 |
char *name; |
char *name; |
128 |
|
|
129 |
struct memory *mem; |
struct memory *mem; |
133 |
int writeflag, int cache_flags); |
int writeflag, int cache_flags); |
134 |
int (*translate_address)(struct cpu *, uint64_t vaddr, |
int (*translate_address)(struct cpu *, uint64_t vaddr, |
135 |
uint64_t *return_addr, int flags); |
uint64_t *return_addr, int flags); |
136 |
void (*useremul_syscall)(struct cpu *cpu, |
void (*update_translation_table)(struct cpu *, |
137 |
uint32_t code); |
uint64_t vaddr_page, unsigned char *host_page, |
138 |
|
int writeflag, uint64_t paddr_page); |
139 |
|
void (*invalidate_translation_caches_paddr)(struct cpu *, |
140 |
|
uint64_t paddr); |
141 |
|
void (*invalidate_code_translation_caches)(struct cpu *); |
142 |
|
void (*useremul_syscall)(struct cpu *cpu, uint32_t code); |
143 |
|
|
|
/* Things that all CPU families have: */ |
|
144 |
uint64_t pc; |
uint64_t pc; |
145 |
|
|
146 |
#ifdef TRACE_NULL_CRASHES |
#ifdef TRACE_NULL_CRASHES |
|
uint64_t trace_null_addr[TRACE_NULL_N_ENTRIES]; |
|
147 |
int trace_null_index; |
int trace_null_index; |
148 |
|
uint64_t trace_null_addr[TRACE_NULL_N_ENTRIES]; |
149 |
#endif |
#endif |
150 |
|
|
151 |
/* CPU-family dependant: */ |
int trace_tree_depth; |
152 |
|
|
153 |
|
/* |
154 |
|
* Dynamic translation: |
155 |
|
*/ |
156 |
|
int running_translated; |
157 |
|
int n_translated_instrs; |
158 |
|
unsigned char *translation_cache; |
159 |
|
size_t translation_cache_cur_ofs; |
160 |
|
|
161 |
|
/* |
162 |
|
* CPU-family dependent: |
163 |
|
*/ |
164 |
union { |
union { |
165 |
|
struct alpha_cpu alpha; |
166 |
struct arm_cpu arm; |
struct arm_cpu arm; |
167 |
|
struct ia64_cpu ia64; |
168 |
|
struct m68k_cpu m68k; |
169 |
struct mips_cpu mips; |
struct mips_cpu mips; |
170 |
struct ppc_cpu ppc; |
struct ppc_cpu ppc; |
171 |
struct urisc_cpu urisc; |
struct sparc_cpu sparc; |
172 |
struct x86_cpu x86; |
struct x86_cpu x86; |
173 |
} cd; |
} cd; |
174 |
}; |
}; |
187 |
unsigned char *instr, int running, uint64_t addr, int bintrans); |
unsigned char *instr, int running, uint64_t addr, int bintrans); |
188 |
int cpu_interrupt(struct cpu *cpu, uint64_t irq_nr); |
int cpu_interrupt(struct cpu *cpu, uint64_t irq_nr); |
189 |
int cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr); |
int cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr); |
190 |
void cpu_run_init(struct emul *emul, struct machine *machine); |
void cpu_functioncall_trace(struct cpu *cpu, uint64_t f); |
191 |
|
void cpu_functioncall_trace_return(struct cpu *cpu); |
192 |
|
void cpu_create_or_reset_tc(struct cpu *cpu); |
193 |
|
void cpu_run_init(struct machine *machine); |
194 |
int cpu_run(struct emul *emul, struct machine *machine); |
int cpu_run(struct emul *emul, struct machine *machine); |
195 |
void cpu_run_deinit(struct emul *emul, struct machine *machine); |
void cpu_run_deinit(struct machine *machine); |
196 |
void cpu_dumpinfo(struct machine *m, struct cpu *cpu); |
void cpu_dumpinfo(struct machine *m, struct cpu *cpu); |
197 |
void cpu_list_available_types(void); |
void cpu_list_available_types(void); |
198 |
void cpu_show_cycles(struct machine *machine, int forced); |
void cpu_show_cycles(struct machine *machine, int forced); |
200 |
void cpu_init(void); |
void cpu_init(void); |
201 |
|
|
202 |
|
|
203 |
|
#define CPU_FAMILY_INIT(n,s) int n ## _cpu_family_init( \ |
204 |
|
struct cpu_family *fp) { \ |
205 |
|
/* Fill in the cpu_family struct with valid data for this arch. */ \ |
206 |
|
fp->name = s; \ |
207 |
|
fp->cpu_new = n ## _cpu_new; \ |
208 |
|
fp->list_available_types = n ## _cpu_list_available_types; \ |
209 |
|
fp->register_match = n ## _cpu_register_match; \ |
210 |
|
fp->disassemble_instr = n ## _cpu_disassemble_instr; \ |
211 |
|
fp->register_dump = n ## _cpu_register_dump; \ |
212 |
|
fp->run = n ## _cpu_run; \ |
213 |
|
fp->dumpinfo = n ## _cpu_dumpinfo; \ |
214 |
|
fp->show_full_statistics = n ## _cpu_show_full_statistics; \ |
215 |
|
fp->tlbdump = n ## _cpu_tlbdump; \ |
216 |
|
fp->interrupt = n ## _cpu_interrupt; \ |
217 |
|
fp->interrupt_ack = n ## _cpu_interrupt_ack; \ |
218 |
|
fp->functioncall_trace = n ## _cpu_functioncall_trace; \ |
219 |
|
return 1; \ |
220 |
|
} |
221 |
|
|
222 |
|
|
223 |
#endif /* CPU_H */ |
#endif /* CPU_H */ |