machine.h Source File

Back to the index.

machine.h
Go to the documentation of this file.
1 #ifndef MACHINE_H
2 #define MACHINE_H
3 
4 /*
5  * Copyright (C) 2005-2018 Anders Gavare. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  * derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 #include <sys/types.h>
32 
33 #include "symbol.h"
34 
35 struct cpu_family;
36 struct diskimage;
37 struct emul;
38 struct fb_window;
39 struct machine_arcbios;
40 struct machine_pmax;
41 struct memory;
42 struct of_data;
43 struct settings;
44 
45 
46 /* TODO: This should probably go away... */
47 struct isa_pic_data {
48  struct pic8259_data *pic1;
49  struct pic8259_data *pic2;
50 
52  int last_int;
53 };
54 
55 struct breakpoints {
56  int n;
57 
58  /* Arrays, with one element for each entry: */
59  char **string;
60  uint64_t *addr;
61 };
62 
63 struct statistics {
64  char *filename;
65  FILE *file;
66  int enabled;
67  char *fields; /* "vpi" etc. */
68 };
69 
71  int n_entries;
72 
73  /* Arrays, with one element for each entry: */
76  void (**f)(struct cpu *, void *);
77  void **extra;
78 };
79 
80 struct x11_md {
81  /* X11/framebuffer stuff: */
82  int in_use;
83  int scaledown;
84  int scaleup;
86  char **display_names;
87  int current_display_name_nr; /* updated by x11.c */
88 
91 };
92 
93 
94 /*
95  * The machine struct:
96  */
97 struct machine {
98  /* Pointer back to the emul struct we are in: */
99  struct emul *emul;
100 
101  /* Settings: */
103 
104  /* Name as choosen by the user: */
105  const char *name;
106 
107  /* Full "path" to the machine, e.g. "machine[0]": */
108  char *path;
109 
110  int arch; /* ARCH_MIPS, ARCH_PPC, .. */
111  int machine_type; /* MACHINE_PMAX, .. */
112  int machine_subtype; /* MACHINE_DEC_3MAX_5000, .. */
113 
114  /* Name set by code in src/machines/machine_*.c: */
115  const char *machine_name;
116 
117  /* The serial number is mostly used when emulating multiple machines
118  in a network. nr_of_nics is the current nr of network cards, which
119  is useful when emulating multiple cards in one machine: */
122 
123  /* TODO: How about multiple cpu familys in one machine? */
125 
126  struct memory *memory;
127 
129 
130  /* Tick functions (e.g. hardware devices): */
132 
133  char *cpu_name; /* TODO: remove this, there could be several
134  cpus with different names in a machine */
139  int ncpus;
140  struct cpu **cpus;
141 
143 
145 
152 
155  char *bootstr;
156  char *bootarg;
157 
158  /* Breakpoints: */
160 
174 
175  /* Instruction statistics: */
177 
178  /* X11/framebuffer stuff (per machine): */
179  struct x11_md x11_md;
180 
181  /* Machine-dependent: (PROM stuff, etc.) */
182  union {
185  struct of_data *of_data;
186  } md;
187 
188  /* Bus-specific interrupt data: */
189  /* TODO: Remove! */
191 };
192 
193 
194 /* Tick function "prototype": */
195 #define DEVICE_TICK(x) void dev_ ## x ## _tick(struct cpu *cpu, void *extra)
196 
197 
198 /*
199  * Machine emulation types:
200  */
201 
202 #define ARCH_NOARCH 0
203 #define ARCH_MIPS 1
204 #define ARCH_PPC 2
205 #define ARCH_ALPHA 4
206 #define ARCH_ARM 5
207 #define ARCH_SH 6
208 #define ARCH_M88K 7
209 
210 /* MIPS: */
211 #define MACHINE_BAREMIPS 1000
212 #define MACHINE_TESTMIPS 1001
213 #define MACHINE_PMAX 1002
214 #define MACHINE_COBALT 1003
215 #define MACHINE_HPCMIPS 1004
216 #define MACHINE_PS2 1005
217 #define MACHINE_SGI 1006
218 #define MACHINE_ARC 1007
219 #define MACHINE_EVBMIPS 1008
220 #define MACHINE_ALGOR 1009
221 #define MACHINE_QEMU_MIPS 1010
222 #define MACHINE_VOCORE 1011
223 
224 /* PPC: */
225 #define MACHINE_BAREPPC 2000
226 #define MACHINE_TESTPPC 2001
227 #define MACHINE_PMPPC 2002
228 #define MACHINE_PREP 2003
229 #define MACHINE_MACPPC 2004
230 #define MACHINE_MVMEPPC 2005
231 
232 /* Alpha: */
233 #define MACHINE_BAREALPHA 4000
234 #define MACHINE_TESTALPHA 4001
235 #define MACHINE_ALPHA 4002
236 
237 /* ARM: */
238 #define MACHINE_BAREARM 5000
239 #define MACHINE_TESTARM 5001
240 #define MACHINE_CATS 5002
241 #define MACHINE_HPCARM 5003
242 #define MACHINE_NETWINDER 5004
243 #define MACHINE_IQ80321 5005
244 #define MACHINE_IYONIX 5006
245 #define MACHINE_QEMU_ARM 5007
246 #define MACHINE_RPI 5008
247 
248 /* SH: */
249 #define MACHINE_BARESH 6000
250 #define MACHINE_TESTSH 6001
251 #define MACHINE_HPCSH 6002
252 #define MACHINE_DREAMCAST 6003
253 #define MACHINE_LANDISK 6004
254 
255 /* M88K: */
256 #define MACHINE_BAREM88K 7000
257 #define MACHINE_TESTM88K 7001
258 #define MACHINE_MVME88K 7002
259 #define MACHINE_LUNA88K 7003
260 
261 /* Other "pseudo"-machines: */
262 #define MACHINE_NONE 0
263 
264 /* DEC: */
265 #define MACHINE_DEC_PMAX_3100 1
266 #define MACHINE_DEC_3MAX_5000 2
267 #define MACHINE_DEC_3MIN_5000 3
268 #define MACHINE_DEC_3MAXPLUS_5000 4
269 #define MACHINE_DEC_5800 5
270 #define MACHINE_DEC_5400 6
271 #define MACHINE_DEC_MAXINE_5000 7
272 #define MACHINE_DEC_5500 11
273 #define MACHINE_DEC_MIPSMATE_5100 12
274 
275 #define DEC_PROM_CALLBACK_STRUCT 0xffffffffbfc04000ULL
276 #define DEC_PROM_EMULATION 0xffffffffbfc08000ULL
277 #define DEC_PROM_INITIAL_ARGV (INITIAL_STACK_POINTER + 0x80)
278 #define DEC_PROM_STRINGS 0xffffffffbfc20000ULL
279 #define DEC_PROM_TCINFO 0xffffffffbfc2c000ULL
280 #define DEC_MEMMAP_ADDR 0xffffffffbfc30000ULL
281 
282 /* HPCmips: */
283 #define MACHINE_HPCMIPS_CASIO_BE300 1
284 #define MACHINE_HPCMIPS_CASIO_E105 2
285 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_770 3
286 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_780 4
287 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_800 5
288 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_880 6
289 #define MACHINE_HPCMIPS_AGENDA_VR3 7
290 #define MACHINE_HPCMIPS_IBM_WORKPAD_Z50 8
291 
292 /* HPCarm: */
293 #define MACHINE_HPCARM_IPAQ 1
294 #define MACHINE_HPCARM_JORNADA720 2
295 #define MACHINE_HPCARM_JORNADA728 3
296 
297 /* HPCsh: */
298 #define MACHINE_HPCSH_JORNADA680 1
299 #define MACHINE_HPCSH_JORNADA690 2
300 
301 /* SGI and ARC: */
302 #define MACHINE_ARC_JAZZ_PICA 1
303 #define MACHINE_ARC_JAZZ_MAGNUM 2
304 
305 /* Algor: */
306 #define MACHINE_ALGOR_P4032 1
307 #define MACHINE_ALGOR_P5064 2
308 
309 /* EVBMIPS: */
310 #define MACHINE_EVBMIPS_MALTA 1
311 #define MACHINE_EVBMIPS_MALTA_BE 2
312 
313 /* PReP: */
314 #define MACHINE_PREP_IBM6050 1
315 #define MACHINE_PREP_MVME2400 2
316 
317 /* MacPPC: TODO: Real model names */
318 #define MACHINE_MACPPC_G3 1
319 #define MACHINE_MACPPC_G4 2
320 #define MACHINE_MACPPC_G5 3
321 
322 /* MVMEPPC */
323 #define MACHINE_MVMEPPC_1600 1
324 #define MACHINE_MVMEPPC_2100 2
325 #define MACHINE_MVMEPPC_5500 3
326 
327 /* MVME88K */
328 #define MACHINE_MVME88K_187 1
329 #define MACHINE_MVME88K_188 2
330 #define MACHINE_MVME88K_197 3
331 
332 /* LUNA88K */
333 #define MACHINE_LUNA_88K 1
334 #define MACHINE_LUNA_88K2 2
335 
336 
337 /* For the automachine system: */
339  int machine_subtype;/* Old-style subtype */
340  const char *name; /* Official name */
342  char **aliases; /* Aliases */
343 };
344 
347 
348  /* Machine type: */
349  int arch;
350  int machine_type; /* Old-style type */
351  const char *name; /* Official name */
353  char **aliases; /* Aliases */
354 
355  void (*setup)(struct machine *, struct cpu *);
356  void (*set_default_cpu)(struct machine *);
357  void (*set_default_ram)(struct machine *);
358 
359  /* Machine subtypes: */
362 };
363 
364 #define MACHINE_SETUP_TYPE(n) void (*n)(struct machine *, struct cpu *)
365 #define MACHINE_SETUP(x) void machine_setup_ ## x(struct machine *machine, \
366  struct cpu *cpu)
367 #define MACHINE_DEFAULT_CPU(x) void machine_default_cpu_ ## x(struct machine *machine)
368 #define MACHINE_DEFAULT_RAM(x) void machine_default_ram_ ## x(struct machine *machine)
369 #define MACHINE_REGISTER(x) void machine_register_ ## x(void)
370 #define MR_DEFAULT(x,name,arch,type) struct machine_entry \
371  *me = machine_entry_new(name,arch,type); \
372  me->setup = machine_setup_ ## x; \
373  me->set_default_cpu = machine_default_cpu_ ## x; \
374  machine_entry_register(me, arch);
375 void automachine_init(void);
376 
377 
378 /* machine.c: */
379 struct machine *machine_new(char *name, struct emul *emul, int id);
380 void machine_destroy(struct machine *machine);
381 int machine_name_to_type(char *stype, char *ssubtype,
382  int *type, int *subtype, int *arch);
383 void machine_add_breakpoint_string(struct machine *machine, char *str);
385  void (*func)(struct cpu *, void *), void *extra, int clockshift);
386 void machine_statistics_init(struct machine *, char *fname);
387 void machine_register(char *name, MACHINE_SETUP_TYPE(setup));
388 void machine_setup(struct machine *);
389 void machine_memsize_fix(struct machine *);
390 void machine_default_cputype(struct machine *);
391 void machine_dumpinfo(struct machine *);
392 int machine_run(struct machine *machine);
394 struct machine_entry *machine_entry_new(const char *name,
395  int arch, int oldstyle_type);
396 void machine_entry_add_alias(struct machine_entry *me, const char *name);
397 void machine_entry_add_subtype(struct machine_entry *me, const char *name,
398  int oldstyle_subtype, ...);
399 void machine_entry_register(struct machine_entry *me, int arch);
400 void machine_init(void);
401 
402 
403 #endif /* MACHINE_H */
void ** extra
Definition: machine.h:77
int * ticks_till_next
Definition: machine.h:74
int emulated_hz
Definition: machine.h:165
int prom_emulation
Definition: machine.h:149
char * cpu_name
Definition: machine.h:133
int arch_pagesize
Definition: machine.h:151
char ** aliases
Definition: machine.h:353
int main_console_handle
Definition: machine.h:128
int serial_nr
Definition: machine.h:120
int n_aliases
Definition: machine.h:352
void machine_memsize_fix(struct machine *)
Definition: machine.cc:527
int machine_type
Definition: machine.h:111
int arch
Definition: machine.h:349
void(* setup)(struct machine *, struct cpu *)
Definition: machine.h:355
int * pending_timer_interrupts
Definition: machine.h:51
void machine_register(char *name, MACHINE_SETUP_TYPE(setup))
int scaleup
Definition: machine.h:84
int machine_type
Definition: machine.h:350
void f(int s, int func, int only_name)
int n_aliases
Definition: machine.h:341
Definition: x11.h:50
int slow_serial_interrupts_hack_for_linux
Definition: machine.h:168
int current_display_name_nr
Definition: machine.h:87
struct memory * memory
Definition: machine.h:126
char ** aliases
Definition: machine.h:342
int machine_run(struct machine *machine)
Definition: machine.cc:617
struct machine_arcbios * arc
Definition: machine.h:183
int enabled
Definition: machine.h:66
struct cpu ** cpus
Definition: machine.h:140
int exit_without_entering_debugger
Definition: machine.h:172
int physical_ram_in_mb
Definition: machine.h:147
int ncpus
Definition: machine.h:139
int scaledown
Definition: machine.h:83
struct machine_entry_subtype ** subtype
Definition: machine.h:361
char * boot_string_argument
Definition: machine.h:171
struct emul * emul
Definition: machine.h:99
#define MACHINE_SETUP_TYPE(n)
Definition: machine.h:364
struct diskimage * first_diskimage
Definition: machine.h:142
char * boot_kernel_filename
Definition: machine.h:170
char * path
Definition: machine.h:108
Definition: machine.h:80
int n_subtypes
Definition: machine.h:360
int bootstrap_cpu
Definition: machine.h:136
int instruction_trace
Definition: machine.h:162
struct pic8259_data * pic1
Definition: machine.h:48
Definition: machine.h:338
void machine_setup(struct machine *)
Definition: machine.cc:449
int start_paused
Definition: machine.h:138
void machine_entry_register(struct machine_entry *me, int arch)
Definition: machine.cc:766
struct of_data * of_data
Definition: machine.h:185
int force_netboot
Definition: machine.h:167
void machine_entry_add_subtype(struct machine_entry *me, const char *name, int oldstyle_subtype,...)
Definition: machine.cc:717
void machine_destroy(struct machine *machine)
Definition: machine.cc:124
FILE * file
Definition: machine.h:65
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
int n_fb_windows
Definition: machine.h:89
void machine_default_cputype(struct machine *)
Definition: machine.cc:572
void machine_init(void)
Definition: machine.cc:865
Definition: emul.h:37
char ** display_names
Definition: machine.h:86
int machine_name_to_type(char *stype, char *ssubtype, int *type, int *subtype, int *arch)
Definition: machine.cc:156
int random_mem_contents
Definition: machine.h:146
int machine_subtype
Definition: machine.h:339
void machine_list_available_types_and_cpus(void)
Definition: machine.cc:802
int halt_on_nonexistant_memaccess
Definition: machine.h:161
char * bootstr
Definition: machine.h:155
Definition: cpu.h:326
Definition: machine.h:345
int last_int
Definition: machine.h:52
int register_dump
Definition: machine.h:150
struct machine * machine_new(char *name, struct emul *emul, int id)
Definition: machine.cc:58
int bootdev_type
Definition: machine.h:153
char ** string
Definition: machine.h:59
struct settings * settings
Definition: machine.h:102
struct fb_window ** fb_windows
Definition: machine.h:90
int bootdev_id
Definition: machine.h:154
int in_use
Definition: machine.h:82
struct machine_entry * next
Definition: machine.h:346
void machine_add_breakpoint_string(struct machine *machine, char *str)
Definition: machine.cc:252
int allow_instruction_combinations
Definition: machine.h:166
struct pic8259_data * pic2
Definition: machine.h:49
const char * name
Definition: machine.h:105
const char * name
Definition: machine.h:340
int nr_of_nics
Definition: machine.h:121
Definition: memory.h:75
int n_display_names
Definition: machine.h:85
char * fields
Definition: machine.h:67
void machine_statistics_init(struct machine *, char *fname)
Definition: machine.cc:323
uint64_t file_loaded_end_addr
Definition: machine.h:169
int * ticks_reset_value
Definition: machine.h:75
void machine_add_tickfunction(struct machine *machine, void(*func)(struct cpu *, void *), void *extra, int clockshift)
Definition: machine.cc:280
int memory_offset_in_mb
Definition: machine.h:148
int arch
Definition: machine.h:110
struct machine_entry * machine_entry_new(const char *name, int arch, int oldstyle_type)
Definition: machine.cc:672
void automachine_init(void)
Definition: automachine.cc:84
char * filename
Definition: machine.h:64
int machine_subtype
Definition: machine.h:112
struct machine_pmax * pmax
Definition: machine.h:184
void machine_dumpinfo(struct machine *)
Definition: machine.cc:392
uint64_t * addr
Definition: machine.h:60
int show_nr_of_instructions
Definition: machine.h:163
int show_trace_tree
Definition: machine.h:164
int n_entries
Definition: machine.h:71
int use_random_bootstrap_cpu
Definition: machine.h:137
struct cpu_family * cpu_family
Definition: machine.h:124
const char * machine_name
Definition: machine.h:115
const char * name
Definition: machine.h:351
int byte_order_override
Definition: machine.h:135
int n_gfx_cards
Definition: machine.h:173
char * bootarg
Definition: machine.h:156

Generated on Fri Dec 7 2018 19:52:23 for GXemul by doxygen 1.8.13