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-2019 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: */
159  struct breakpoints breakpoints;
160 
174 
175  /* Instruction statistics: */
176  struct statistics 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! */
190  struct isa_pic_data isa_pic_data;
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_VOCORE 1010
222 
223 /* PPC: */
224 #define MACHINE_BAREPPC 2000
225 #define MACHINE_TESTPPC 2001
226 #define MACHINE_PMPPC 2002
227 #define MACHINE_PREP 2003
228 #define MACHINE_MACPPC 2004
229 #define MACHINE_MVMEPPC 2005
230 
231 /* Alpha: */
232 #define MACHINE_BAREALPHA 4000
233 #define MACHINE_TESTALPHA 4001
234 #define MACHINE_ALPHA 4002
235 
236 /* ARM: */
237 #define MACHINE_BAREARM 5000
238 #define MACHINE_TESTARM 5001
239 #define MACHINE_CATS 5002
240 #define MACHINE_HPCARM 5003
241 #define MACHINE_NETWINDER 5004
242 #define MACHINE_IQ80321 5005
243 #define MACHINE_IYONIX 5006
244 #define MACHINE_RPI 5007
245 #define MACHINE_ANDROIDARM 5008
246 
247 /* SH: */
248 #define MACHINE_BARESH 6000
249 #define MACHINE_TESTSH 6001
250 #define MACHINE_HPCSH 6002
251 #define MACHINE_DREAMCAST 6003
252 #define MACHINE_LANDISK 6004
253 
254 /* M88K: */
255 #define MACHINE_BAREM88K 7000
256 #define MACHINE_TESTM88K 7001
257 #define MACHINE_MVME88K 7002
258 #define MACHINE_LUNA88K 7003
259 
260 /* Other "pseudo"-machines: */
261 #define MACHINE_NONE 0
262 
263 /* DEC: */
264 #define MACHINE_DEC_PMAX_3100 1
265 #define MACHINE_DEC_3MAX_5000 2
266 #define MACHINE_DEC_3MIN_5000 3
267 #define MACHINE_DEC_3MAXPLUS_5000 4
268 #define MACHINE_DEC_5800 5
269 #define MACHINE_DEC_5400 6
270 #define MACHINE_DEC_MAXINE_5000 7
271 #define MACHINE_DEC_5500 11
272 #define MACHINE_DEC_MIPSMATE_5100 12
273 
274 #define DEC_PROM_CALLBACK_STRUCT 0xffffffffbfc04000ULL
275 #define DEC_PROM_EMULATION 0xffffffffbfc08000ULL
276 #define DEC_PROM_INITIAL_ARGV (INITIAL_STACK_POINTER + 0x80)
277 #define DEC_PROM_STRINGS 0xffffffffbfc20000ULL
278 #define DEC_PROM_TCINFO 0xffffffffbfc2c000ULL
279 #define DEC_MEMMAP_ADDR 0xffffffffbfc30000ULL
280 
281 /* HPCmips: */
282 #define MACHINE_HPCMIPS_CASIO_BE300 1
283 #define MACHINE_HPCMIPS_CASIO_E105 2
284 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_770 3
285 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_780 4
286 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_800 5
287 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_880 6
288 #define MACHINE_HPCMIPS_AGENDA_VR3 7
289 #define MACHINE_HPCMIPS_IBM_WORKPAD_Z50 8
290 
291 /* HPCarm: */
292 #define MACHINE_HPCARM_IPAQ 1
293 #define MACHINE_HPCARM_JORNADA720 2
294 #define MACHINE_HPCARM_JORNADA728 3
295 
296 /* HPCsh: */
297 #define MACHINE_HPCSH_JORNADA680 1
298 #define MACHINE_HPCSH_JORNADA690 2
299 
300 /* SGI and ARC: */
301 #define MACHINE_ARC_JAZZ_PICA 1
302 #define MACHINE_ARC_JAZZ_MAGNUM 2
303 
304 /* Algor: */
305 #define MACHINE_ALGOR_P4032 1
306 #define MACHINE_ALGOR_P5064 2
307 
308 /* EVBMIPS: */
309 #define MACHINE_EVBMIPS_MALTA 1
310 #define MACHINE_EVBMIPS_MALTA_BE 2
311 
312 /* PReP: */
313 #define MACHINE_PREP_IBM6050 1
314 #define MACHINE_PREP_MVME2400 2
315 
316 /* MacPPC: TODO: Real model names */
317 #define MACHINE_MACPPC_G3 1
318 #define MACHINE_MACPPC_G4 2
319 #define MACHINE_MACPPC_G5 3
320 
321 /* MVMEPPC */
322 #define MACHINE_MVMEPPC_1600 1
323 #define MACHINE_MVMEPPC_2100 2
324 #define MACHINE_MVMEPPC_5500 3
325 
326 /* MVME88K */
327 #define MACHINE_MVME88K_187 1
328 #define MACHINE_MVME88K_188 2
329 #define MACHINE_MVME88K_197 3
330 
331 /* LUNA88K */
332 #define MACHINE_LUNA_88K 1
333 #define MACHINE_LUNA_88K2 2
334 
335 /* Android ARM */
336 #define MACHINE_ANDROIDARM_SONYXPERIAMINI 1
337 #define MACHINE_ANDROIDARM_FINOWX5AIR 2
338 
339 
340 /* For the automachine system: */
342  int machine_subtype;/* Old-style subtype */
343  const char *name; /* Official name */
345  char **aliases; /* Aliases */
346 };
347 
350 
351  /* Machine type: */
352  int arch;
353  int machine_type; /* Old-style type */
354  const char *name; /* Official name */
356  char **aliases; /* Aliases */
357 
358  void (*setup)(struct machine *, struct cpu *);
359  void (*set_default_cpu)(struct machine *);
360  void (*set_default_ram)(struct machine *);
361 
362  /* Machine subtypes: */
365 };
366 
367 #define MACHINE_SETUP_TYPE(n) void (*n)(struct machine *, struct cpu *)
368 #define MACHINE_SETUP(x) void machine_setup_ ## x(struct machine *machine, \
369  struct cpu *cpu)
370 #define MACHINE_DEFAULT_CPU(x) void machine_default_cpu_ ## x(struct machine *machine)
371 #define MACHINE_DEFAULT_RAM(x) void machine_default_ram_ ## x(struct machine *machine)
372 #define MACHINE_REGISTER(x) void machine_register_ ## x(void)
373 #define MR_DEFAULT(x,name,arch,type) struct machine_entry \
374  *me = machine_entry_new(name,arch,type); \
375  me->setup = machine_setup_ ## x; \
376  me->set_default_cpu = machine_default_cpu_ ## x; \
377  machine_entry_register(me, arch);
378 void automachine_init(void);
379 
380 
381 /* machine.c: */
382 struct machine *machine_new(char *name, struct emul *emul, int id);
383 void machine_destroy(struct machine *machine);
384 int machine_name_to_type(char *stype, char *ssubtype,
385  int *type, int *subtype, int *arch);
386 void machine_add_breakpoint_string(struct machine *machine, char *str);
388  void (*func)(struct cpu *, void *), void *extra, int clockshift);
389 void machine_statistics_init(struct machine *, char *fname);
391 void machine_setup(struct machine *);
392 void machine_memsize_fix(struct machine *);
393 void machine_default_cputype(struct machine *);
394 void machine_dumpinfo(struct machine *);
395 int machine_run(struct machine *machine);
397 struct machine_entry *machine_entry_new(const char *name,
398  int arch, int oldstyle_type);
399 void machine_entry_add_alias(struct machine_entry *me, const char *name);
400 void machine_entry_add_subtype(struct machine_entry *me, const char *name,
401  int oldstyle_subtype, ...);
402 void machine_entry_register(struct machine_entry *me, int arch);
403 void machine_init(void);
404 
405 
406 #endif /* MACHINE_H */
machine::bootdev_type
int bootdev_type
Definition: machine.h:153
machine::machine_subtype
int machine_subtype
Definition: machine.h:112
isa_pic_data::pending_timer_interrupts
int * pending_timer_interrupts
Definition: machine.h:51
machine::arch_pagesize
int arch_pagesize
Definition: machine.h:151
machine::bootstrap_cpu
int bootstrap_cpu
Definition: machine.h:136
tick_functions::extra
void ** extra
Definition: machine.h:77
machine::file_loaded_end_addr
uint64_t file_loaded_end_addr
Definition: machine.h:169
machine::cpu_family
struct cpu_family * cpu_family
Definition: machine.h:124
machine::bootarg
char * bootarg
Definition: machine.h:156
machine::name
const char * name
Definition: machine.h:105
machine_entry::setup
void(* setup)(struct machine *, struct cpu *)
Definition: machine.h:358
statistics
Definition: machine.h:63
machine::register_dump
int register_dump
Definition: machine.h:150
machine_entry_subtype::n_aliases
int n_aliases
Definition: machine.h:344
machine_entry::n_aliases
int n_aliases
Definition: machine.h:355
machine_entry::aliases
char ** aliases
Definition: machine.h:356
memory
Definition: memory.h:75
machine::emul
struct emul * emul
Definition: machine.h:99
machine::cpus
struct cpu ** cpus
Definition: machine.h:140
machine::show_nr_of_instructions
int show_nr_of_instructions
Definition: machine.h:163
automachine_init
void automachine_init(void)
Definition: automachine.cc:84
isa_pic_data::pic2
struct pic8259_data * pic2
Definition: machine.h:49
machine_destroy
void machine_destroy(struct machine *machine)
Definition: machine.cc:124
tick_functions::ticks_till_next
int * ticks_till_next
Definition: machine.h:74
symbol_context
Definition: symbol.h:49
breakpoints::string
char ** string
Definition: machine.h:59
statistics::enabled
int enabled
Definition: machine.h:66
machine::show_trace_tree
int show_trace_tree
Definition: machine.h:164
machine_list_available_types_and_cpus
void machine_list_available_types_and_cpus(void)
Definition: machine.cc:802
machine_default_cputype
void machine_default_cputype(struct machine *)
Definition: machine.cc:572
x11_md
Definition: machine.h:80
machine_entry::machine_type
int machine_type
Definition: machine.h:353
machine::use_random_bootstrap_cpu
int use_random_bootstrap_cpu
Definition: machine.h:137
machine::allow_instruction_combinations
int allow_instruction_combinations
Definition: machine.h:166
machine_entry::arch
int arch
Definition: machine.h:352
machine_memsize_fix
void machine_memsize_fix(struct machine *)
Definition: machine.cc:527
isa_pic_data::pic1
struct pic8259_data * pic1
Definition: machine.h:48
machine::arc
struct machine_arcbios * arc
Definition: machine.h:183
isa_pic_data::last_int
int last_int
Definition: machine.h:52
x11_md::fb_windows
struct fb_window ** fb_windows
Definition: machine.h:90
machine_run
int machine_run(struct machine *machine)
Definition: machine.cc:617
machine::start_paused
int start_paused
Definition: machine.h:138
machine::prom_emulation
int prom_emulation
Definition: machine.h:149
machine::first_diskimage
struct diskimage * first_diskimage
Definition: machine.h:142
machine_setup
void machine_setup(struct machine *)
Definition: machine.cc:449
machine::boot_string_argument
char * boot_string_argument
Definition: machine.h:171
machine_add_breakpoint_string
void machine_add_breakpoint_string(struct machine *machine, char *str)
Definition: machine.cc:252
tick_functions
Definition: machine.h:70
machine::slow_serial_interrupts_hack_for_linux
int slow_serial_interrupts_hack_for_linux
Definition: machine.h:168
breakpoints::n
int n
Definition: machine.h:56
machine::instruction_trace
int instruction_trace
Definition: machine.h:162
machine_add_tickfunction
void machine_add_tickfunction(struct machine *machine, void(*func)(struct cpu *, void *), void *extra, int clockshift)
Definition: machine.cc:280
machine_entry::n_subtypes
int n_subtypes
Definition: machine.h:363
machine::byte_order_override
int byte_order_override
Definition: machine.h:135
machine_dumpinfo
void machine_dumpinfo(struct machine *)
Definition: machine.cc:392
machine::cpu_name
char * cpu_name
Definition: machine.h:133
machine_entry_add_subtype
void machine_entry_add_subtype(struct machine_entry *me, const char *name, int oldstyle_subtype,...)
Definition: machine.cc:717
x11_md::scaledown
int scaledown
Definition: machine.h:83
x11_md::in_use
int in_use
Definition: machine.h:82
MACHINE_SETUP_TYPE
#define MACHINE_SETUP_TYPE(n)
Definition: machine.h:367
machine::serial_nr
int serial_nr
Definition: machine.h:120
machine::halt_on_nonexistant_memaccess
int halt_on_nonexistant_memaccess
Definition: machine.h:161
machine
Definition: machine.h:97
machine::main_console_handle
int main_console_handle
Definition: machine.h:128
breakpoints::addr
uint64_t * addr
Definition: machine.h:60
machine::force_netboot
int force_netboot
Definition: machine.h:167
machine::settings
struct settings * settings
Definition: machine.h:102
pic8259_data
Definition: devices.h:63
machine_entry::next
struct machine_entry * next
Definition: machine.h:349
machine_entry_register
void machine_entry_register(struct machine_entry *me, int arch)
Definition: machine.cc:766
machine_entry::set_default_cpu
void(* set_default_cpu)(struct machine *)
Definition: machine.h:359
x11_md::display_names
char ** display_names
Definition: machine.h:86
x11_md::n_display_names
int n_display_names
Definition: machine.h:85
symbol.h
machine_entry_subtype::machine_subtype
int machine_subtype
Definition: machine.h:342
machine_register
void machine_register(char *name, MACHINE_SETUP_TYPE(setup))
machine::pmax
struct machine_pmax * pmax
Definition: machine.h:184
machine::path
char * path
Definition: machine.h:108
tick_functions::ticks_reset_value
int * ticks_reset_value
Definition: machine.h:75
machine::bootdev_id
int bootdev_id
Definition: machine.h:154
x11_md::n_fb_windows
int n_fb_windows
Definition: machine.h:89
machine_new
struct machine * machine_new(char *name, struct emul *emul, int id)
Definition: machine.cc:58
machine::memory
struct memory * memory
Definition: machine.h:126
machine::physical_ram_in_mb
uint32_t physical_ram_in_mb
Definition: machine.h:147
x11_md::scaleup
int scaleup
Definition: machine.h:84
settings
Definition: settings.cc:57
machine::boot_kernel_filename
char * boot_kernel_filename
Definition: machine.h:170
machine::random_mem_contents
int random_mem_contents
Definition: machine.h:146
breakpoints
Definition: machine.h:55
machine_entry_subtype::name
const char * name
Definition: machine.h:343
statistics::file
FILE * file
Definition: machine.h:65
machine_pmax
Definition: machine_pmax.h:37
machine_entry
Definition: machine.h:348
machine_entry::set_default_ram
void(* set_default_ram)(struct machine *)
Definition: machine.h:360
statistics::filename
char * filename
Definition: machine.h:64
machine_init
void machine_init(void)
Definition: machine.cc:865
diskimage
Definition: diskimage.h:56
machine::machine_type
int machine_type
Definition: machine.h:111
statistics::fields
char * fields
Definition: machine.h:67
machine::emulated_hz
int emulated_hz
Definition: machine.h:165
machine_entry_subtype
Definition: machine.h:341
emul
Definition: emul.h:37
fb_window
Definition: x11.h:50
tick_functions::n_entries
int n_entries
Definition: machine.h:71
machine::bootstr
char * bootstr
Definition: machine.h:155
machine_entry_new
struct machine_entry * machine_entry_new(const char *name, int arch, int oldstyle_type)
Definition: machine.cc:672
machine::machine_name
const char * machine_name
Definition: machine.h:115
cpu
Definition: cpu.h:326
machine::exit_without_entering_debugger
int exit_without_entering_debugger
Definition: machine.h:172
machine::of_data
struct of_data * of_data
Definition: machine.h:185
machine::md
union machine::@2 md
machine::n_gfx_cards
int n_gfx_cards
Definition: machine.h:173
machine_arcbios
Definition: machine_arc.h:48
isa_pic_data
Definition: machine.h:47
machine::memory_offset_in_mb
int memory_offset_in_mb
Definition: machine.h:148
machine_entry_add_alias
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
machine::nr_of_nics
int nr_of_nics
Definition: machine.h:121
machine_entry::name
const char * name
Definition: machine.h:354
tick_functions::f
void(** f)(struct cpu *, void *)
Definition: machine.h:76
machine_entry_subtype::aliases
char ** aliases
Definition: machine.h:345
machine::arch
int arch
Definition: machine.h:110
machine_statistics_init
void machine_statistics_init(struct machine *, char *fname)
Definition: machine.cc:323
machine_name_to_type
int machine_name_to_type(char *stype, char *ssubtype, int *type, int *subtype, int *arch)
Definition: machine.cc:156
x11_md::current_display_name_nr
int current_display_name_nr
Definition: machine.h:87
machine_entry::subtype
struct machine_entry_subtype ** subtype
Definition: machine.h:364
machine::ncpus
int ncpus
Definition: machine.h:139
cpu_family
Definition: cpu.h:256

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18