28 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
29 |
* |
* |
30 |
* |
* |
31 |
* $Id: machine.h,v 1.156 2007/02/10 14:29:55 debug Exp $ |
* $Id: machine.h,v 1.182 2007/08/29 20:36:49 debug Exp $ |
32 |
*/ |
*/ |
33 |
|
|
34 |
#include <sys/types.h> |
#include <sys/types.h> |
|
#include <sys/time.h> |
|
35 |
|
|
|
#include "debugger_gdb.h" |
|
36 |
#include "symbol.h" |
#include "symbol.h" |
37 |
|
|
|
#include "machine_arc.h" |
|
|
#include "machine_pmax.h" |
|
|
|
|
|
|
|
|
#define MAX_BREAKPOINTS 8 |
|
|
|
|
|
#define MAX_TICK_FUNCTIONS 16 |
|
|
|
|
|
#define MAX_STATISTICS_FIELDS 8 |
|
|
|
|
38 |
struct cpu_family; |
struct cpu_family; |
39 |
struct diskimage; |
struct diskimage; |
40 |
struct emul; |
struct emul; |
41 |
struct fb_window; |
struct fb_window; |
42 |
|
struct machine_arcbios; |
43 |
|
struct machine_pmax; |
44 |
struct memory; |
struct memory; |
45 |
struct of_data; |
struct of_data; |
46 |
struct settings; |
struct settings; |
55 |
int last_int; |
int last_int; |
56 |
}; |
}; |
57 |
|
|
58 |
|
struct breakpoints { |
59 |
|
int n; |
60 |
|
|
61 |
|
/* Arrays, with one element for each entry: */ |
62 |
|
char **string; |
63 |
|
uint64_t *addr; |
64 |
|
}; |
65 |
|
|
66 |
|
struct statistics { |
67 |
|
char *filename; |
68 |
|
FILE *file; |
69 |
|
int enabled; |
70 |
|
char *fields; /* "vpi" etc. */ |
71 |
|
}; |
72 |
|
|
73 |
|
struct tick_functions { |
74 |
|
int n_entries; |
75 |
|
|
76 |
|
/* Arrays, with one element for each entry: */ |
77 |
|
int *ticks_till_next; |
78 |
|
int *ticks_reset_value; |
79 |
|
void (*(*f))(struct cpu *, void *); |
80 |
|
void **extra; |
81 |
|
}; |
82 |
|
|
83 |
|
struct x11_md { |
84 |
|
/* X11/framebuffer stuff: */ |
85 |
|
int in_use; |
86 |
|
int scaledown; |
87 |
|
int scaleup; |
88 |
|
int n_display_names; |
89 |
|
char **display_names; |
90 |
|
int current_display_name_nr; /* updated by x11.c */ |
91 |
|
|
92 |
|
int n_fb_windows; |
93 |
|
struct fb_window **fb_windows; |
94 |
|
}; |
95 |
|
|
96 |
|
|
97 |
|
/* |
98 |
|
* The machine struct: |
99 |
|
*/ |
100 |
struct machine { |
struct machine { |
101 |
/* Pointer back to the emul struct we are in: */ |
/* Pointer back to the emul struct we are in: */ |
102 |
struct emul *emul; |
struct emul *emul; |
107 |
/* Name as choosen by the user: */ |
/* Name as choosen by the user: */ |
108 |
char *name; |
char *name; |
109 |
|
|
110 |
/* Full "path" to the machine, e.g. "emul[0].machine[0]": */ |
/* Full "path" to the machine, e.g. "machine[0]": */ |
111 |
char *path; |
char *path; |
112 |
|
|
113 |
int arch; /* ARCH_MIPS, ARCH_PPC, .. */ |
int arch; /* ARCH_MIPS, ARCH_PPC, .. */ |
114 |
int machine_type; /* MACHINE_PMAX, .. */ |
int machine_type; /* MACHINE_PMAX, .. */ |
115 |
int machine_subtype; /* MACHINE_DEC_3MAX_5000, .. */ |
int machine_subtype; /* MACHINE_DEC_3MAX_5000, .. */ |
116 |
|
|
|
/* NOTE/TODO: This isn't working yet: */ |
|
|
int cycle_accurate; /* Set to non-zero for cycle |
|
|
accurate (slow) emulation. */ |
|
|
|
|
117 |
/* Name set by code in src/machines/machine_*.c: */ |
/* Name set by code in src/machines/machine_*.c: */ |
118 |
char *machine_name; |
char *machine_name; |
119 |
|
|
|
int stable; /* startup warning for non-stable |
|
|
emulation modes. */ |
|
|
|
|
120 |
/* The serial number is mostly used when emulating multiple machines |
/* The serial number is mostly used when emulating multiple machines |
121 |
in a network. nr_of_nics is the current nr of network cards, which |
in a network. nr_of_nics is the current nr of network cards, which |
122 |
is useful when emulating multiple cards in one machine: */ |
is useful when emulating multiple cards in one machine: */ |
126 |
/* TODO: How about multiple cpu familys in one machine? */ |
/* TODO: How about multiple cpu familys in one machine? */ |
127 |
struct cpu_family *cpu_family; |
struct cpu_family *cpu_family; |
128 |
|
|
|
/* |
|
|
* The "mainbus": |
|
|
* |
|
|
* o) memory |
|
|
* o) devices |
|
|
* o) CPUs |
|
|
*/ |
|
|
|
|
129 |
struct memory *memory; |
struct memory *memory; |
130 |
|
|
131 |
int main_console_handle; |
int main_console_handle; |
132 |
|
|
133 |
/* Hardware devices, run every x clock cycles. */ |
/* Tick functions (e.g. hardware devices): */ |
134 |
int n_tick_entries; |
struct tick_functions tick_functions; |
|
int ticks_till_next[MAX_TICK_FUNCTIONS]; |
|
|
int ticks_reset_value[MAX_TICK_FUNCTIONS]; |
|
|
void (*tick_func[MAX_TICK_FUNCTIONS])(struct cpu *, void *); |
|
|
void *tick_extra[MAX_TICK_FUNCTIONS]; |
|
|
double tick_hz[MAX_TICK_FUNCTIONS]; |
|
135 |
|
|
136 |
char *cpu_name; /* TODO: remove this, there could be several |
char *cpu_name; /* TODO: remove this, there could be several |
137 |
cpus with different names in a machine */ |
cpus with different names in a machine */ |
142 |
int ncpus; |
int ncpus; |
143 |
struct cpu **cpus; |
struct cpu **cpus; |
144 |
|
|
|
/* These are used by stuff in cpu.c, mostly: */ |
|
|
/* TODO: Move to cpu.h! */ |
|
|
int64_t ninstrs; |
|
|
int64_t ninstrs_show; |
|
|
int64_t ninstrs_flush; |
|
|
int64_t ninstrs_since_gettimeofday; |
|
|
struct timeval starttime; |
|
|
|
|
145 |
struct diskimage *first_diskimage; |
struct diskimage *first_diskimage; |
146 |
|
|
147 |
struct symbol_context symbol_context; |
struct symbol_context symbol_context; |
158 |
char *bootstr; |
char *bootstr; |
159 |
char *bootarg; |
char *bootarg; |
160 |
|
|
|
struct debugger_gdb gdb; |
|
|
|
|
161 |
/* Breakpoints: */ |
/* Breakpoints: */ |
162 |
int n_breakpoints; |
struct breakpoints breakpoints; |
|
char *breakpoint_string[MAX_BREAKPOINTS]; |
|
|
uint64_t breakpoint_addr[MAX_BREAKPOINTS]; |
|
|
int breakpoint_flags[MAX_BREAKPOINTS]; |
|
|
|
|
|
/* Cache sizes: (1 << x) x=0 for default values */ |
|
|
/* TODO: these should be _PER CPU_! */ |
|
|
int cache_picache; |
|
|
int cache_pdcache; |
|
|
int cache_secondary; |
|
|
int cache_picache_linesize; |
|
|
int cache_pdcache_linesize; |
|
|
int cache_secondary_linesize; |
|
163 |
|
|
|
int dbe_on_nonexistant_memaccess; |
|
164 |
int halt_on_nonexistant_memaccess; |
int halt_on_nonexistant_memaccess; |
165 |
int instruction_trace; |
int instruction_trace; |
166 |
int show_nr_of_instructions; |
int show_nr_of_instructions; |
167 |
int show_trace_tree; |
int show_trace_tree; |
|
int show_symbolic_register_names; |
|
168 |
int emulated_hz; |
int emulated_hz; |
169 |
int allow_instruction_combinations; |
int allow_instruction_combinations; |
170 |
char *userland_emul; /* NULL for no userland emulation */ |
char *userland_emul; /* NULL for no userland emulation */ |
177 |
int n_gfx_cards; |
int n_gfx_cards; |
178 |
|
|
179 |
/* Instruction statistics: */ |
/* Instruction statistics: */ |
180 |
char *statistics_filename; |
struct statistics statistics; |
181 |
FILE *statistics_file; |
|
182 |
int statistics_enabled; |
/* X11/framebuffer stuff (per machine): */ |
183 |
char *statistics_fields; /* "vpi" etc. */ |
struct x11_md x11_md; |
184 |
|
|
185 |
/* Machine-dependent: (PROM stuff, etc.) */ |
/* Machine-dependent: (PROM stuff, etc.) */ |
186 |
union { |
union { |
187 |
struct machine_arcbios arc; |
struct machine_arcbios *arc; |
188 |
struct machine_pmax pmax; |
struct machine_pmax *pmax; |
189 |
struct of_data *of_data; |
struct of_data *of_data; |
190 |
} md; |
} md; |
191 |
|
|
192 |
/* Bus-specific interrupt data: */ |
/* Bus-specific interrupt data: */ |
193 |
/* TODO: Remove! */ |
/* TODO: Remove! */ |
194 |
struct isa_pic_data isa_pic_data; |
struct isa_pic_data isa_pic_data; |
|
|
|
|
/* X11/framebuffer stuff: */ |
|
|
int use_x11; |
|
|
int x11_scaledown; |
|
|
int x11_scaleup; |
|
|
int x11_n_display_names; |
|
|
char **x11_display_names; |
|
|
int x11_current_display_name_nr; /* updated by x11.c */ |
|
|
|
|
|
int n_fb_windows; |
|
|
struct fb_window **fb_windows; |
|
195 |
}; |
}; |
196 |
|
|
197 |
|
|
209 |
#define ARCH_SPARC 3 |
#define ARCH_SPARC 3 |
210 |
#define ARCH_ALPHA 4 |
#define ARCH_ALPHA 4 |
211 |
#define ARCH_ARM 5 |
#define ARCH_ARM 5 |
212 |
#define ARCH_M68K 6 |
#define ARCH_SH 6 |
213 |
#define ARCH_SH 7 |
#define ARCH_M88K 7 |
214 |
#define ARCH_AVR 8 |
#define ARCH_M32R 8 |
|
#define ARCH_TRANSPUTER 9 |
|
|
#define ARCH_RCA180X 10 |
|
215 |
|
|
216 |
/* MIPS: */ |
/* MIPS: */ |
217 |
#define MACHINE_BAREMIPS 1000 |
#define MACHINE_BAREMIPS 1000 |
222 |
#define MACHINE_PS2 1005 |
#define MACHINE_PS2 1005 |
223 |
#define MACHINE_SGI 1006 |
#define MACHINE_SGI 1006 |
224 |
#define MACHINE_ARC 1007 |
#define MACHINE_ARC 1007 |
225 |
#define MACHINE_NETGEAR 1008 |
#define MACHINE_EVBMIPS 1008 |
226 |
#define MACHINE_SONYNEWS 1009 |
#define MACHINE_ALGOR 1009 |
227 |
#define MACHINE_EVBMIPS 1010 |
#define MACHINE_QEMU_MIPS 1010 |
|
#define MACHINE_PSP 1011 |
|
|
#define MACHINE_ALGOR 1012 |
|
|
#define MACHINE_QEMU_MIPS 1013 |
|
228 |
|
|
229 |
/* PPC: */ |
/* PPC: */ |
230 |
#define MACHINE_BAREPPC 2000 |
#define MACHINE_BAREPPC 2000 |
231 |
#define MACHINE_TESTPPC 2001 |
#define MACHINE_TESTPPC 2001 |
232 |
#define MACHINE_WALNUT 2002 |
#define MACHINE_PMPPC 2002 |
233 |
#define MACHINE_PMPPC 2003 |
#define MACHINE_BEBOX 2003 |
234 |
#define MACHINE_SANDPOINT 2004 |
#define MACHINE_PREP 2004 |
235 |
#define MACHINE_BEBOX 2005 |
#define MACHINE_MACPPC 2005 |
236 |
#define MACHINE_PREP 2006 |
#define MACHINE_MVMEPPC 2006 |
|
#define MACHINE_MACPPC 2007 |
|
|
#define MACHINE_MVMEPPC 2008 |
|
237 |
|
|
238 |
/* SPARC: */ |
/* SPARC: */ |
239 |
#define MACHINE_BARESPARC 3000 |
#define MACHINE_BARESPARC 3000 |
250 |
#define MACHINE_TESTARM 5001 |
#define MACHINE_TESTARM 5001 |
251 |
#define MACHINE_CATS 5002 |
#define MACHINE_CATS 5002 |
252 |
#define MACHINE_HPCARM 5003 |
#define MACHINE_HPCARM 5003 |
253 |
#define MACHINE_ZAURUS 5004 |
#define MACHINE_NETWINDER 5004 |
254 |
#define MACHINE_NETWINDER 5005 |
#define MACHINE_IQ80321 5005 |
255 |
#define MACHINE_SHARK 5006 |
#define MACHINE_QEMU_ARM 5006 |
|
#define MACHINE_IQ80321 5007 |
|
|
#define MACHINE_IYONIX 5008 |
|
|
#define MACHINE_TS7200 5009 |
|
|
#define MACHINE_QEMU_ARM 5010 |
|
|
|
|
|
/* M68K: */ |
|
|
#define MACHINE_BAREM68K 6000 |
|
|
#define MACHINE_TESTM68K 6001 |
|
256 |
|
|
257 |
/* SH: */ |
/* SH: */ |
258 |
#define MACHINE_BARESH 7000 |
#define MACHINE_BARESH 6000 |
259 |
#define MACHINE_TESTSH 7001 |
#define MACHINE_TESTSH 6001 |
260 |
#define MACHINE_HPCSH 7002 |
#define MACHINE_HPCSH 6002 |
261 |
#define MACHINE_DREAMCAST 7003 |
#define MACHINE_DREAMCAST 6003 |
262 |
#define MACHINE_LANDISK 7004 |
#define MACHINE_LANDISK 6004 |
263 |
|
|
264 |
/* AVR: */ |
/* M88K: */ |
265 |
#define MACHINE_BAREAVR 8000 |
#define MACHINE_BAREM88K 7000 |
266 |
#define MACHINE_AVR_PAL 8001 |
#define MACHINE_TESTM88K 7001 |
267 |
#define MACHINE_AVR_MAHPONG 8002 |
#define MACHINE_MVME88K 7002 |
268 |
|
|
269 |
/* TRANSPUTER: */ |
/* M32R: */ |
270 |
#define MACHINE_BARETRANSPUTER 9000 |
#define MACHINE_BAREM32R 8000 |
271 |
|
#define MACHINE_TESTM32R 8001 |
|
/* ARCH_RCA180X: */ |
|
|
#define MACHINE_BARE180X 10000 |
|
|
#define MACHINE_CHIP8 10001 |
|
272 |
|
|
273 |
/* Other "pseudo"-machines: */ |
/* Other "pseudo"-machines: */ |
274 |
#define MACHINE_NONE 0 |
#define MACHINE_NONE 0 |
311 |
#define MACHINE_HPCSH_JORNADA690 2 |
#define MACHINE_HPCSH_JORNADA690 2 |
312 |
|
|
313 |
/* SGI and ARC: */ |
/* SGI and ARC: */ |
314 |
#define MACHINE_ARC_NEC_RD94 1 |
#define MACHINE_ARC_JAZZ_PICA 1 |
315 |
#define MACHINE_ARC_JAZZ_PICA 2 |
#define MACHINE_ARC_JAZZ_MAGNUM 2 |
|
#define MACHINE_ARC_NEC_R94 3 |
|
|
#define MACHINE_ARC_DESKTECH_TYNE 4 |
|
|
#define MACHINE_ARC_JAZZ_MAGNUM 5 |
|
|
#define MACHINE_ARC_NEC_R98 6 |
|
|
#define MACHINE_ARC_JAZZ_M700 7 |
|
|
#define MACHINE_ARC_NEC_R96 8 |
|
316 |
|
|
317 |
/* Algor: */ |
/* Algor: */ |
318 |
#define MACHINE_ALGOR_P4032 4 |
#define MACHINE_ALGOR_P4032 1 |
319 |
#define MACHINE_ALGOR_P5064 5 |
#define MACHINE_ALGOR_P5064 2 |
320 |
|
|
321 |
/* EVBMIPS: */ |
/* EVBMIPS: */ |
322 |
#define MACHINE_EVBMIPS_MALTA 1 |
#define MACHINE_EVBMIPS_MALTA 1 |
323 |
#define MACHINE_EVBMIPS_MALTA_BE 2 |
#define MACHINE_EVBMIPS_MALTA_BE 2 |
|
#define MACHINE_EVBMIPS_MESHCUBE 3 |
|
|
#define MACHINE_EVBMIPS_PB1000 4 |
|
324 |
|
|
325 |
/* PReP: */ |
/* PReP: */ |
326 |
#define MACHINE_PREP_IBM6050 1 |
#define MACHINE_PREP_IBM6050 1 |
331 |
#define MACHINE_SPARC_SS20 2 |
#define MACHINE_SPARC_SS20 2 |
332 |
#define MACHINE_SPARC_ULTRA1 3 |
#define MACHINE_SPARC_ULTRA1 3 |
333 |
#define MACHINE_SPARC_ULTRA60 4 |
#define MACHINE_SPARC_ULTRA60 4 |
334 |
|
#define MACHINE_SPARC_SUN4V 5 |
335 |
|
|
336 |
/* MacPPC: TODO: Real model names */ |
/* MacPPC: TODO: Real model names */ |
337 |
#define MACHINE_MACPPC_G3 1 |
#define MACHINE_MACPPC_G3 1 |
343 |
#define MACHINE_MVMEPPC_2100 2 |
#define MACHINE_MVMEPPC_2100 2 |
344 |
#define MACHINE_MVMEPPC_5500 3 |
#define MACHINE_MVMEPPC_5500 3 |
345 |
|
|
346 |
|
/* MVME88K */ |
347 |
|
#define MACHINE_MVME88K_187 1 |
348 |
|
#define MACHINE_MVME88K_188 2 |
349 |
|
#define MACHINE_MVME88K_197 3 |
350 |
|
|
351 |
|
|
352 |
/* For the automachine system: */ |
/* For the automachine system: */ |
353 |
struct machine_entry_subtype { |
struct machine_entry_subtype { |
395 |
void machine_destroy(struct machine *machine); |
void machine_destroy(struct machine *machine); |
396 |
int machine_name_to_type(char *stype, char *ssubtype, |
int machine_name_to_type(char *stype, char *ssubtype, |
397 |
int *type, int *subtype, int *arch); |
int *type, int *subtype, int *arch); |
398 |
|
void machine_add_breakpoint_string(struct machine *machine, char *str); |
399 |
void machine_add_tickfunction(struct machine *machine, |
void machine_add_tickfunction(struct machine *machine, |
400 |
void (*func)(struct cpu *, void *), void *extra, |
void (*func)(struct cpu *, void *), void *extra, int clockshift); |
|
int clockshift, double hz); |
|
401 |
void machine_statistics_init(struct machine *, char *fname); |
void machine_statistics_init(struct machine *, char *fname); |
402 |
void machine_register(char *name, MACHINE_SETUP_TYPE(setup)); |
void machine_register(char *name, MACHINE_SETUP_TYPE(setup)); |
|
void dump_mem_string(struct cpu *cpu, uint64_t addr); |
|
|
void store_string(struct cpu *cpu, uint64_t addr, char *s); |
|
|
int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64); |
|
|
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32); |
|
|
int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16); |
|
|
void store_byte(struct cpu *cpu, uint64_t addr, uint8_t data); |
|
|
void store_64bit_word_in_host(struct cpu *cpu, unsigned char *data, |
|
|
uint64_t data32); |
|
|
void store_32bit_word_in_host(struct cpu *cpu, unsigned char *data, |
|
|
uint64_t data32); |
|
|
void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data, |
|
|
uint16_t data16); |
|
|
uint64_t load_64bit_word(struct cpu *cpu, uint64_t addr); |
|
|
uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr); |
|
|
uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr); |
|
|
void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len); |
|
|
void add_environment_string(struct cpu *cpu, char *s, uint64_t *addr); |
|
|
void add_environment_string_dual(struct cpu *cpu, |
|
|
uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2); |
|
|
void store_pointer_and_advance(struct cpu *cpu, uint64_t *addrp, |
|
|
uint64_t data, int flag64); |
|
403 |
void machine_setup(struct machine *); |
void machine_setup(struct machine *); |
404 |
void machine_memsize_fix(struct machine *); |
void machine_memsize_fix(struct machine *); |
405 |
void machine_default_cputype(struct machine *); |
void machine_default_cputype(struct machine *); |