/[gxemul]/trunk/src/include/machine.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/src/include/machine.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (show annotations)
Mon Oct 8 16:21:34 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 14016 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1497 2007/03/18 03:41:36 debug Exp $
20070224	Minor update to the initialization of the ns16550 in
		machine_walnut.c, to allow that machine type to boot with the
		new interrupt system (although it is still a dummy machine).
		Adding a wdc at 0x14000000 to machine_landisk.c, and fixing
		the SCIF serial interrupts of the SH4 cpu enough to get
		NetBSD/landisk booting from a disk image :-)  Adding a
		preliminary install instruction skeleton to guestoses.html.
20070306	Adding SH-IPL+G PROM emulation, and also passing the "end"
		symbol in r5 on bootup, for Landisk emulation. This is enough
		to get OpenBSD/landisk to install :)  Adding a preliminary
		install instruction skeleton to the documentation. SuperH
		emulation is still shaky, though :-/
20070307	Fixed a strangeness in memory_sh.c (read/write was never
		returned for any page). (Unknown whether this fixes any actual
		problems, though.)
20070308	dev_ram.c fix: invalidate code translations on writes to
		RAM, emulated as separate devices. Linux/dreamcast gets
		further in the boot process than before, but still bugs out
		in userland.
		Fixing bugs in the "stc.l gbr,@-rN" and "ldc.l @rN+,gbr" SuperH 
		instructions (they should NOT check the MD bit), allowing the
		Linux/dreamcast Live CD to reach userland correctly :-)
20070310	Changing the cpu name "Alpha" in src/useremul.c to "21364" to
		unbreak userland syscall emulation of FreeBSD/Alpha binaries.
20070314	Applying a patch from Michael Yaroslavtsev which fixes the
		previous Linux lib64 patch to the configure script.
20070315	Adding a (dummy) sun4v machine type, and SPARC T1 cpu type.
20070316	Creating a new directory, src/disk, and moving diskimage.c
		to it. Separating out bootblock loading stuff from emul.c into
		new files in src/disk.
		Adding some more SPARC registers.
20070318	Preparing/testing for a minirelease, 0.4.4.1.

==============  RELEASE 0.4.4.1  ==============


1 #ifndef MACHINE_H
2 #define MACHINE_H
3
4 /*
5 * Copyright (C) 2005-2007 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 * $Id: machine.h,v 1.157 2007/03/15 15:42:58 debug Exp $
32 */
33
34 #include <sys/types.h>
35 #include <sys/time.h>
36
37 #include "debugger_gdb.h"
38 #include "symbol.h"
39
40 #include "machine_arc.h"
41 #include "machine_pmax.h"
42
43
44 #define MAX_BREAKPOINTS 8
45
46 #define MAX_TICK_FUNCTIONS 16
47
48 #define MAX_STATISTICS_FIELDS 8
49
50 struct cpu_family;
51 struct diskimage;
52 struct emul;
53 struct fb_window;
54 struct memory;
55 struct of_data;
56 struct settings;
57
58
59 /* TODO: This should probably go away... */
60 struct isa_pic_data {
61 struct pic8259_data *pic1;
62 struct pic8259_data *pic2;
63
64 int *pending_timer_interrupts;
65 int last_int;
66 };
67
68
69 struct machine {
70 /* Pointer back to the emul struct we are in: */
71 struct emul *emul;
72
73 /* Settings: */
74 struct settings *settings;
75
76 /* Name as choosen by the user: */
77 char *name;
78
79 /* Full "path" to the machine, e.g. "emul[0].machine[0]": */
80 char *path;
81
82 int arch; /* ARCH_MIPS, ARCH_PPC, .. */
83 int machine_type; /* MACHINE_PMAX, .. */
84 int machine_subtype; /* MACHINE_DEC_3MAX_5000, .. */
85
86 /* NOTE/TODO: This isn't working yet: */
87 int cycle_accurate; /* Set to non-zero for cycle
88 accurate (slow) emulation. */
89
90 /* Name set by code in src/machines/machine_*.c: */
91 char *machine_name;
92
93 int stable; /* startup warning for non-stable
94 emulation modes. */
95
96 /* The serial number is mostly used when emulating multiple machines
97 in a network. nr_of_nics is the current nr of network cards, which
98 is useful when emulating multiple cards in one machine: */
99 int serial_nr;
100 int nr_of_nics;
101
102 /* TODO: How about multiple cpu familys in one machine? */
103 struct cpu_family *cpu_family;
104
105 /*
106 * The "mainbus":
107 *
108 * o) memory
109 * o) devices
110 * o) CPUs
111 */
112
113 struct memory *memory;
114
115 int main_console_handle;
116
117 /* Hardware devices, run every x clock cycles. */
118 int n_tick_entries;
119 int ticks_till_next[MAX_TICK_FUNCTIONS];
120 int ticks_reset_value[MAX_TICK_FUNCTIONS];
121 void (*tick_func[MAX_TICK_FUNCTIONS])(struct cpu *, void *);
122 void *tick_extra[MAX_TICK_FUNCTIONS];
123 double tick_hz[MAX_TICK_FUNCTIONS];
124
125 char *cpu_name; /* TODO: remove this, there could be several
126 cpus with different names in a machine */
127 int byte_order_override;
128 int bootstrap_cpu;
129 int use_random_bootstrap_cpu;
130 int start_paused;
131 int ncpus;
132 struct cpu **cpus;
133
134 /* These are used by stuff in cpu.c, mostly: */
135 /* TODO: Move to cpu.h! */
136 int64_t ninstrs;
137 int64_t ninstrs_show;
138 int64_t ninstrs_flush;
139 int64_t ninstrs_since_gettimeofday;
140 struct timeval starttime;
141
142 struct diskimage *first_diskimage;
143
144 struct symbol_context symbol_context;
145
146 int random_mem_contents;
147 int physical_ram_in_mb;
148 int memory_offset_in_mb;
149 int prom_emulation;
150 int register_dump;
151 int arch_pagesize;
152
153 int bootdev_type;
154 int bootdev_id;
155 char *bootstr;
156 char *bootarg;
157
158 struct debugger_gdb gdb;
159
160 /* Breakpoints: */
161 int n_breakpoints;
162 char *breakpoint_string[MAX_BREAKPOINTS];
163 uint64_t breakpoint_addr[MAX_BREAKPOINTS];
164 int breakpoint_flags[MAX_BREAKPOINTS];
165
166 /* Cache sizes: (1 << x) x=0 for default values */
167 /* TODO: these should be _PER CPU_! */
168 int cache_picache;
169 int cache_pdcache;
170 int cache_secondary;
171 int cache_picache_linesize;
172 int cache_pdcache_linesize;
173 int cache_secondary_linesize;
174
175 int dbe_on_nonexistant_memaccess;
176 int halt_on_nonexistant_memaccess;
177 int instruction_trace;
178 int show_nr_of_instructions;
179 int show_trace_tree;
180 int show_symbolic_register_names;
181 int emulated_hz;
182 int allow_instruction_combinations;
183 char *userland_emul; /* NULL for no userland emulation */
184 int force_netboot;
185 int slow_serial_interrupts_hack_for_linux;
186 uint64_t file_loaded_end_addr;
187 char *boot_kernel_filename;
188 char *boot_string_argument;
189 int exit_without_entering_debugger;
190 int n_gfx_cards;
191
192 /* Instruction statistics: */
193 char *statistics_filename;
194 FILE *statistics_file;
195 int statistics_enabled;
196 char *statistics_fields; /* "vpi" etc. */
197
198 /* Machine-dependent: (PROM stuff, etc.) */
199 union {
200 struct machine_arcbios arc;
201 struct machine_pmax pmax;
202 struct of_data *of_data;
203 } md;
204
205 /* Bus-specific interrupt data: */
206 /* TODO: Remove! */
207 struct isa_pic_data isa_pic_data;
208
209 /* X11/framebuffer stuff: */
210 int use_x11;
211 int x11_scaledown;
212 int x11_scaleup;
213 int x11_n_display_names;
214 char **x11_display_names;
215 int x11_current_display_name_nr; /* updated by x11.c */
216
217 int n_fb_windows;
218 struct fb_window **fb_windows;
219 };
220
221
222 /* Tick function "prototype": */
223 #define DEVICE_TICK(x) void dev_ ## x ## _tick(struct cpu *cpu, void *extra)
224
225
226 /*
227 * Machine emulation types:
228 */
229
230 #define ARCH_NOARCH 0
231 #define ARCH_MIPS 1
232 #define ARCH_PPC 2
233 #define ARCH_SPARC 3
234 #define ARCH_ALPHA 4
235 #define ARCH_ARM 5
236 #define ARCH_M68K 6
237 #define ARCH_SH 7
238 #define ARCH_AVR 8
239 #define ARCH_TRANSPUTER 9
240 #define ARCH_RCA180X 10
241
242 /* MIPS: */
243 #define MACHINE_BAREMIPS 1000
244 #define MACHINE_TESTMIPS 1001
245 #define MACHINE_PMAX 1002
246 #define MACHINE_COBALT 1003
247 #define MACHINE_HPCMIPS 1004
248 #define MACHINE_PS2 1005
249 #define MACHINE_SGI 1006
250 #define MACHINE_ARC 1007
251 #define MACHINE_NETGEAR 1008
252 #define MACHINE_SONYNEWS 1009
253 #define MACHINE_EVBMIPS 1010
254 #define MACHINE_PSP 1011
255 #define MACHINE_ALGOR 1012
256 #define MACHINE_QEMU_MIPS 1013
257
258 /* PPC: */
259 #define MACHINE_BAREPPC 2000
260 #define MACHINE_TESTPPC 2001
261 #define MACHINE_WALNUT 2002
262 #define MACHINE_PMPPC 2003
263 #define MACHINE_SANDPOINT 2004
264 #define MACHINE_BEBOX 2005
265 #define MACHINE_PREP 2006
266 #define MACHINE_MACPPC 2007
267 #define MACHINE_MVMEPPC 2008
268
269 /* SPARC: */
270 #define MACHINE_BARESPARC 3000
271 #define MACHINE_TESTSPARC 3001
272 #define MACHINE_SPARC 3002
273
274 /* Alpha: */
275 #define MACHINE_BAREALPHA 4000
276 #define MACHINE_TESTALPHA 4001
277 #define MACHINE_ALPHA 4002
278
279 /* ARM: */
280 #define MACHINE_BAREARM 5000
281 #define MACHINE_TESTARM 5001
282 #define MACHINE_CATS 5002
283 #define MACHINE_HPCARM 5003
284 #define MACHINE_ZAURUS 5004
285 #define MACHINE_NETWINDER 5005
286 #define MACHINE_SHARK 5006
287 #define MACHINE_IQ80321 5007
288 #define MACHINE_IYONIX 5008
289 #define MACHINE_TS7200 5009
290 #define MACHINE_QEMU_ARM 5010
291
292 /* M68K: */
293 #define MACHINE_BAREM68K 6000
294 #define MACHINE_TESTM68K 6001
295
296 /* SH: */
297 #define MACHINE_BARESH 7000
298 #define MACHINE_TESTSH 7001
299 #define MACHINE_HPCSH 7002
300 #define MACHINE_DREAMCAST 7003
301 #define MACHINE_LANDISK 7004
302
303 /* AVR: */
304 #define MACHINE_BAREAVR 8000
305 #define MACHINE_AVR_PAL 8001
306 #define MACHINE_AVR_MAHPONG 8002
307
308 /* TRANSPUTER: */
309 #define MACHINE_BARETRANSPUTER 9000
310
311 /* ARCH_RCA180X: */
312 #define MACHINE_BARE180X 10000
313 #define MACHINE_CHIP8 10001
314
315 /* Other "pseudo"-machines: */
316 #define MACHINE_NONE 0
317 #define MACHINE_USERLAND 100000
318
319 /* DEC: */
320 #define MACHINE_DEC_PMAX_3100 1
321 #define MACHINE_DEC_3MAX_5000 2
322 #define MACHINE_DEC_3MIN_5000 3
323 #define MACHINE_DEC_3MAXPLUS_5000 4
324 #define MACHINE_DEC_5800 5
325 #define MACHINE_DEC_5400 6
326 #define MACHINE_DEC_MAXINE_5000 7
327 #define MACHINE_DEC_5500 11
328 #define MACHINE_DEC_MIPSMATE_5100 12
329
330 #define DEC_PROM_CALLBACK_STRUCT 0xffffffffbfc04000ULL
331 #define DEC_PROM_EMULATION 0xffffffffbfc08000ULL
332 #define DEC_PROM_INITIAL_ARGV (INITIAL_STACK_POINTER + 0x80)
333 #define DEC_PROM_STRINGS 0xffffffffbfc20000ULL
334 #define DEC_PROM_TCINFO 0xffffffffbfc2c000ULL
335 #define DEC_MEMMAP_ADDR 0xffffffffbfc30000ULL
336
337 /* HPCmips: */
338 #define MACHINE_HPCMIPS_CASIO_BE300 1
339 #define MACHINE_HPCMIPS_CASIO_E105 2
340 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_770 3
341 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_780 4
342 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_800 5
343 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_880 6
344 #define MACHINE_HPCMIPS_AGENDA_VR3 7
345 #define MACHINE_HPCMIPS_IBM_WORKPAD_Z50 8
346
347 /* HPCarm: */
348 #define MACHINE_HPCARM_IPAQ 1
349 #define MACHINE_HPCARM_JORNADA720 2
350
351 /* HPCsh: */
352 #define MACHINE_HPCSH_JORNADA680 1
353 #define MACHINE_HPCSH_JORNADA690 2
354
355 /* SGI and ARC: */
356 #define MACHINE_ARC_NEC_RD94 1
357 #define MACHINE_ARC_JAZZ_PICA 2
358 #define MACHINE_ARC_NEC_R94 3
359 #define MACHINE_ARC_DESKTECH_TYNE 4
360 #define MACHINE_ARC_JAZZ_MAGNUM 5
361 #define MACHINE_ARC_NEC_R98 6
362 #define MACHINE_ARC_JAZZ_M700 7
363 #define MACHINE_ARC_NEC_R96 8
364
365 /* Algor: */
366 #define MACHINE_ALGOR_P4032 4
367 #define MACHINE_ALGOR_P5064 5
368
369 /* EVBMIPS: */
370 #define MACHINE_EVBMIPS_MALTA 1
371 #define MACHINE_EVBMIPS_MALTA_BE 2
372 #define MACHINE_EVBMIPS_MESHCUBE 3
373 #define MACHINE_EVBMIPS_PB1000 4
374
375 /* PReP: */
376 #define MACHINE_PREP_IBM6050 1
377 #define MACHINE_PREP_MVME2400 2
378
379 /* Sun SPARC: */
380 #define MACHINE_SPARC_SS5 1
381 #define MACHINE_SPARC_SS20 2
382 #define MACHINE_SPARC_ULTRA1 3
383 #define MACHINE_SPARC_ULTRA60 4
384 #define MACHINE_SPARC_SUN4V 5
385
386 /* MacPPC: TODO: Real model names */
387 #define MACHINE_MACPPC_G3 1
388 #define MACHINE_MACPPC_G4 2
389 #define MACHINE_MACPPC_G5 3
390
391 /* MVMEPPC */
392 #define MACHINE_MVMEPPC_1600 1
393 #define MACHINE_MVMEPPC_2100 2
394 #define MACHINE_MVMEPPC_5500 3
395
396
397 /* For the automachine system: */
398 struct machine_entry_subtype {
399 int machine_subtype;/* Old-style subtype */
400 const char *name; /* Official name */
401 int n_aliases;
402 char **aliases; /* Aliases */
403 };
404
405 struct machine_entry {
406 struct machine_entry *next;
407
408 /* Machine type: */
409 int arch;
410 int machine_type; /* Old-style type */
411 const char *name; /* Official name */
412 int n_aliases;
413 char **aliases; /* Aliases */
414
415 void (*setup)(struct machine *, struct cpu *);
416 void (*set_default_cpu)(struct machine *);
417 void (*set_default_ram)(struct machine *);
418
419 /* Machine subtypes: */
420 int n_subtypes;
421 struct machine_entry_subtype **subtype;
422 };
423
424 #define MACHINE_SETUP_TYPE(n) void (*n)(struct machine *, struct cpu *)
425 #define MACHINE_SETUP(x) void machine_setup_ ## x(struct machine *machine, \
426 struct cpu *cpu)
427 #define MACHINE_DEFAULT_CPU(x) void machine_default_cpu_ ## x(struct machine *machine)
428 #define MACHINE_DEFAULT_RAM(x) void machine_default_ram_ ## x(struct machine *machine)
429 #define MACHINE_REGISTER(x) void machine_register_ ## x(void)
430 #define MR_DEFAULT(x,name,arch,type) struct machine_entry \
431 *me = machine_entry_new(name,arch,type); \
432 me->setup = machine_setup_ ## x; \
433 me->set_default_cpu = machine_default_cpu_ ## x; \
434 machine_entry_register(me, arch);
435 void automachine_init(void);
436
437
438 /* machine.c: */
439 struct machine *machine_new(char *name, struct emul *emul, int id);
440 void machine_destroy(struct machine *machine);
441 int machine_name_to_type(char *stype, char *ssubtype,
442 int *type, int *subtype, int *arch);
443 void machine_add_tickfunction(struct machine *machine,
444 void (*func)(struct cpu *, void *), void *extra,
445 int clockshift, double hz);
446 void machine_statistics_init(struct machine *, char *fname);
447 void machine_register(char *name, MACHINE_SETUP_TYPE(setup));
448 void dump_mem_string(struct cpu *cpu, uint64_t addr);
449 void store_string(struct cpu *cpu, uint64_t addr, char *s);
450 int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64);
451 int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32);
452 int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16);
453 void store_byte(struct cpu *cpu, uint64_t addr, uint8_t data);
454 void store_64bit_word_in_host(struct cpu *cpu, unsigned char *data,
455 uint64_t data32);
456 void store_32bit_word_in_host(struct cpu *cpu, unsigned char *data,
457 uint64_t data32);
458 void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data,
459 uint16_t data16);
460 uint64_t load_64bit_word(struct cpu *cpu, uint64_t addr);
461 uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr);
462 uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr);
463 void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len);
464 void add_environment_string(struct cpu *cpu, char *s, uint64_t *addr);
465 void add_environment_string_dual(struct cpu *cpu,
466 uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2);
467 void store_pointer_and_advance(struct cpu *cpu, uint64_t *addrp,
468 uint64_t data, int flag64);
469 void machine_setup(struct machine *);
470 void machine_memsize_fix(struct machine *);
471 void machine_default_cputype(struct machine *);
472 void machine_dumpinfo(struct machine *);
473 int machine_run(struct machine *machine);
474 void machine_list_available_types_and_cpus(void);
475 struct machine_entry *machine_entry_new(const char *name,
476 int arch, int oldstyle_type);
477 void machine_entry_add_alias(struct machine_entry *me, const char *name);
478 void machine_entry_add_subtype(struct machine_entry *me, const char *name,
479 int oldstyle_subtype, ...);
480 void machine_entry_register(struct machine_entry *me, int arch);
481 void machine_init(void);
482
483
484 #endif /* MACHINE_H */

  ViewVC Help
Powered by ViewVC 1.1.26