/[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 6 - (show annotations)
Mon Oct 8 16:18:11 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 11203 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.772 2005/06/04 12:02:16 debug Exp $
20050428	Disabling the "-fmove-all-movables" option in the configure
		script, because it causes the compile to fail on OpenBSD/sgi.
20050502	Minor updates.
20050503	Removing the WRT54G mode (it was bogus anyway), and adding a
		comment about Windows NT for MIPS in doc/experiments.html.
		Minor updates to the x86 instruction decoding.
20050504	Adding some more x86 instructions.
		Adding support for reading files from ISO9660 CDROMs (including
		gzipped files). It's an ugly hack, but it seems to work.
		Various other minor updates (dev_vga.c, pc_bios.c etc).
20050505	Some more x86-related updates.
		Beginning (what I hope will be) a major code cleanup phase.
		"bootris" (an x86 bootsector) runs :-)
20050506	Adding some more x86 instructions.
20050507	tmpnam => mkstemp.
		Working on a hack to allow VGA charcells to be shown even when
		not running with X11.
		Adding more x86 instructions.
20050508	x86 32-bit SIB addressing fix, and more instructions.
20050509	Adding more x86 instructions.
20050510	Minor documentation updates, and other updates (x86 stuff etc.)
20050511	More x86-related updates.
20050513	Various updates, mostly x86-related. (Trying to fix flag 
		calculation, factoring out the ugly shift/rotate code, and
		some other things.)
20050514	Adding support for loading some old i386 a.out executables.
		Finally beginning the cleanup of machine/PROM/bios dependant
		info.
		Some minor documentation updates.
		Trying to clean up ARCBIOS stuff a little.
20050515	Trying to make it possible to actually use more than one disk
		type per machine (floppy, ide, scsi).
		Trying to clean up the kbd vs PROM console stuff. (For PC and
		ARC emulation modes, mostly.)
		Beginning to add an 8259 interrupt controller, and connecting
		it to the x86 emulation.
20050516	The first x86 interrupts seem to work (keyboard stuff).
		Adding a 8253/8254 programmable interval timer skeleton.
		FreeDOS now reaches a command prompt and can be interacted
		with.
20050517	After some bugfixes, MS-DOS also (sometimes) reaches a
		command prompt now.
		Trying to fix the pckbc to work with MS-DOS' keyb.com, but no
		success yet.
20050518	Adding a simple 32-bit x86 MMU skeleton.
20050519	Some more work on the x86 stuff. (Beginning the work on paging,
		and various other fixes).
20050520	More updates. Working on dev_vga (4-bit graphics modes), adding
		40 columns support to the PC bios emulation.
		Trying to add support for resizing windows when switching
		between graphics modes.
20050521	Many more x86-related updates.
20050522	Correcting the initial stack pointer's sign-extension for
		ARCBIOS emulation (thanks to Alec Voropay for noticing the
		error).
		Continuing on the cleanup (ARCBIOS etc).
		dev_vga updates.
20050523	More x86 updates: trying to add some support for protected mode
		interrupts (via gate descriptors) and many other fixes.
		More ARCBIOS cleanup.
		Adding a device flag which indicates that reads cause no
		side-effects. (Useful for the "dump" command in the debugger,
		and other things.)
		Adding support for directly starting up x86 ELFs, skipping the
		bootloader stage. (Most ELFs, however, are not suitable for
		this.)
20050524	Adding simple 32-bit x86 TSS task switching, but no privilege
		level support yet.
		More work on dev_vga. A small "Copper bars" demo works. :-)
		Adding support for Trap Flag (single-step exceptions), at least
		in real mode, and various other x86-related fixes.
20050525	Adding a new disk image prefix (gH;S;) which can be used to
		override the default nr of heads and sectors per track.
20050527	Various bug fixes, more work on the x86 mode (stack change on
		interrupts between different priv.levels), and some minor
		documentation updates.
20050528	Various fixes (x86 stuff).
20050529	More x86 fixes. An OpenBSD/i386 bootfloppy reaches userland
		and can be interacted with (although there are problems with
		key repetition). NetBSD/i386 triggers a serious CISC-related
		problem: instruction fetches across page boundaries, where
		the later part isn't actually part of the instruction.
20050530	Various minor updates. (Documentation updates, etc.)
20050531	Adding some experimental code (experiments/new_test_*) which
		could be useful for dynamic (but not binary) translation in
		the future.
20050602	Adding a dummy ARM skeleton.
		Fixing the pckbc key repetition problem (by adding release
		scancodes for all keypresses).
20050603	Minor updates for the next release.
20050604	Release testing. Minor updates.

==============  RELEASE 0.3.3  ==============

20050604	There'll probably be a 0.3.3.1 release soon, with some very
		very tiny updates.


1 #ifndef MACHINE_H
2 #define MACHINE_H
3
4 /*
5 * Copyright (C) 2005 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.53 2005/06/02 17:11:36 debug Exp $
32 */
33
34 #include <sys/types.h>
35 #include <sys/time.h>
36
37 #include "symbol.h"
38
39 #include "arcbios.h"
40 #include "machine_x86.h"
41
42 #define MAX_BREAKPOINTS 8
43 #define BREAKPOINT_FLAG_R 1
44
45 #define MAX_TICK_FUNCTIONS 14
46
47 struct cpu_family;
48 struct diskimage;
49 struct emul;
50 struct fb_window;
51 struct memory;
52
53 /* Ugly: */
54 struct kn230_csr;
55 struct kn02_csr;
56 struct dec_ioasic_data;
57 struct ps2_data;
58 struct dec5800_data;
59 struct au1x00_ic_data;
60 struct vr41xx_data;
61 struct jazz_data;
62 struct crime_data;
63 struct mace_data;
64 struct sgi_ip20_data;
65 struct sgi_ip22_data;
66 struct sgi_ip30_data;
67
68 struct machine {
69 /* Pointer back to the emul struct we are in: */
70 struct emul *emul;
71
72 /* Name as choosen by the user: */
73 char *name;
74
75 int arch; /* ARCH_MIPS, ARCH_PPC, .. */
76 int machine_type; /* MACHINE_DEC, .. */
77 int machine_subtype; /* MACHINE_DEC_3MAX_5000, .. */
78
79 char *machine_name;
80
81 /* The serial number is mostly used when emulating multiple machines
82 in a network. nr_of_nics is the current nr of network cards, which
83 is useful when emulating multiple cards in one machine: */
84 int serial_nr;
85 int nr_of_nics;
86
87 struct cpu_family *cpu_family;
88
89 /*
90 * The "mainbus":
91 *
92 * o) memory
93 * o) devices
94 * o) CPUs
95 */
96
97 struct memory *memory;
98
99 int main_console_handle;
100
101 /* Hardware devices, run every x clock cycles. */
102 int n_tick_entries;
103 int ticks_till_next[MAX_TICK_FUNCTIONS];
104 int ticks_reset_value[MAX_TICK_FUNCTIONS];
105 void (*tick_func[MAX_TICK_FUNCTIONS])(struct cpu *, void *);
106 void *tick_extra[MAX_TICK_FUNCTIONS];
107
108 void (*md_interrupt)(struct machine *m, struct cpu *cpu,
109 int irq_nr, int assert);
110
111 char *cpu_name; /* TODO: remove this, there could be several
112 cpus with different names in a machine */
113 int byte_order_override;
114 int bootstrap_cpu;
115 int use_random_bootstrap_cpu;
116 int start_paused;
117 int ncpus;
118 struct cpu **cpus;
119
120 /* These are used by stuff in cpu.c, mostly: */
121 struct timeval starttime;
122 int64_t ncycles;
123 int64_t ncycles_show;
124 int64_t ncycles_flush;
125 int a_few_cycles;
126 int a_few_instrs;
127
128 struct diskimage *first_diskimage;
129
130 struct symbol_context symbol_context;
131
132 int random_mem_contents;
133 int physical_ram_in_mb;
134 int memory_offset_in_mb;
135 int prom_emulation;
136 int register_dump;
137
138 int n_breakpoints;
139 char *breakpoint_string[MAX_BREAKPOINTS];
140 uint64_t breakpoint_addr[MAX_BREAKPOINTS];
141 int breakpoint_flags[MAX_BREAKPOINTS];
142
143 /* Cache sizes: (1 << x) x=0 for default values */
144 /* TODO: these are _PER CPU_! */
145 int cache_picache;
146 int cache_pdcache;
147 int cache_secondary;
148 int cache_picache_linesize;
149 int cache_pdcache_linesize;
150 int cache_secondary_linesize;
151
152 int dbe_on_nonexistant_memaccess;
153 int bintrans_enable;
154 int old_bintrans_enable;
155 int bintrans_enabled_from_start;
156 int bintrans_size;
157 int instruction_trace;
158 int single_step_on_bad_addr;
159 int show_nr_of_instructions;
160 int show_symbolic_register_names;
161 int64_t max_instructions;
162 int emulated_hz;
163 int max_random_cycles_per_chunk;
164 int speed_tricks;
165 char *userland_emul; /* NULL for no userland emulation */
166 int force_netboot;
167 int slow_serial_interrupts_hack_for_linux;
168 uint64_t file_loaded_end_addr;
169 char *boot_kernel_filename;
170 char *boot_string_argument;
171
172 int automatic_clock_adjustment;
173 int exit_without_entering_debugger;
174 int show_trace_tree;
175
176 int n_gfx_cards;
177
178 /* Machine-dependent: (PROM stuff, etc.) */
179 union {
180 struct machine_arcbios arc;
181 struct machine_pc pc;
182 } md;
183
184 /* Machine-dependent interrupt specific structs: */
185 union {
186 struct kn230_csr *kn230_csr;
187 struct kn02_csr *kn02_csr;
188 struct dec_ioasic_data *dec_ioasic_data;
189 struct ps2_data *ps2_data;
190 struct dec5800_data *dec5800_csr;
191 struct au1x00_ic_data *au1x00_ic_data;
192 struct vr41xx_data *vr41xx_data;
193 struct jazz_data *jazz_data;
194 struct sgi_ip20_data *sgi_ip20_data;
195 struct sgi_ip22_data *sgi_ip22_data;
196 struct sgi_ip30_data *sgi_ip30_data;
197 struct {
198 struct crime_data *crime_data;
199 struct mace_data *mace_data;
200 } ip32;
201 } md_int;
202
203 /* X11/framebuffer stuff: */
204 int use_x11;
205 int x11_scaledown;
206 int x11_n_display_names;
207 char **x11_display_names;
208 int x11_current_display_name_nr; /* updated by x11.c */
209
210 int n_fb_windows;
211 struct fb_window **fb_windows;
212 };
213
214
215 /*
216 * Machine emulation types:
217 */
218
219 #define ARCH_NOARCH 0
220 #define ARCH_MIPS 1
221 #define ARCH_PPC 2
222 #define ARCH_SPARC 3
223 #define ARCH_URISC 4
224 #define ARCH_HPPA 5
225 #define ARCH_ALPHA 6
226 #define ARCH_X86 7
227 #define ARCH_ARM 8
228
229 /* MIPS: */
230 #define MACHINE_BAREMIPS 1000
231 #define MACHINE_TESTMIPS 1001
232 #define MACHINE_DEC 1002
233 #define MACHINE_COBALT 1003
234 #define MACHINE_HPCMIPS 1004
235 #define MACHINE_PS2 1005
236 #define MACHINE_SGI 1006
237 #define MACHINE_ARC 1007
238 #define MACHINE_MESHCUBE 1008
239 #define MACHINE_NETGEAR 1009
240 #define MACHINE_SONYNEWS 1010
241
242 /* PPC: */
243 #define MACHINE_BAREPPC 2000
244 #define MACHINE_TESTPPC 2001
245 #define MACHINE_WALNUT 2002
246 #define MACHINE_PMPPC 2003
247 #define MACHINE_SANDPOINT 2004
248 #define MACHINE_BEBOX 2005
249 #define MACHINE_PREP 2006
250 #define MACHINE_MACPPC 2007
251 #define MACHINE_DB64360 2008
252
253 /* SPARC: */
254 #define MACHINE_BARESPARC 3000
255 #define MACHINE_ULTRA1 3001
256
257 /* URISC: */
258 #define MACHINE_BAREURISC 4000
259 #define MACHINE_TESTURISC 4001
260
261 /* HPPA: */
262 #define MACHINE_BAREHPPA 5000
263 #define MACHINE_TESTHPPA 5001
264
265 /* Alpha: */
266 #define MACHINE_BAREALPHA 6000
267 #define MACHINE_TESTALPHA 6001
268
269 /* X86: */
270 #define MACHINE_BAREX86 7000
271 #define MACHINE_X86 7001
272
273 /* ARM: */
274 #define MACHINE_BAREARM 8000
275 #define MACHINE_TESTARM 8001
276
277 /* Other "pseudo"-machines: */
278 #define MACHINE_NONE 0
279 #define MACHINE_USERLAND 100000
280
281 /* DEC: */
282 #define MACHINE_DEC_PMAX_3100 1
283 #define MACHINE_DEC_3MAX_5000 2
284 #define MACHINE_DEC_3MIN_5000 3
285 #define MACHINE_DEC_3MAXPLUS_5000 4
286 #define MACHINE_DEC_5800 5
287 #define MACHINE_DEC_5400 6
288 #define MACHINE_DEC_MAXINE_5000 7
289 #define MACHINE_DEC_5500 11
290 #define MACHINE_DEC_MIPSMATE_5100 12
291
292 #define DEC_PROM_CALLBACK_STRUCT 0xffffffffbfc04000ULL
293 #define DEC_PROM_EMULATION 0xffffffffbfc08000ULL
294 #define DEC_PROM_INITIAL_ARGV (INITIAL_STACK_POINTER + 0x80)
295 #define DEC_PROM_STRINGS 0xffffffffbfc20000ULL
296 #define DEC_PROM_TCINFO 0xffffffffbfc2c000ULL
297 #define DEC_MEMMAP_ADDR 0xffffffffbfc30000ULL
298
299
300 /* HPCmips: */
301 /* Machine types: */
302 #define MACHINE_HPCMIPS_CASIO_BE300 1
303 #define MACHINE_HPCMIPS_CASIO_E105 2
304 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_770 3
305 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_780 4
306 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_800 5
307 #define MACHINE_HPCMIPS_NEC_MOBILEPRO_880 6
308 #define MACHINE_HPCMIPS_AGENDA_VR3 7
309 #define MACHINE_HPCMIPS_IBM_WORKPAD_Z50 8
310
311 /* Playstation 2: */
312 #define PLAYSTATION2_BDA 0xffffffffa0001000ULL
313 #define PLAYSTATION2_OPTARGS 0xffffffff81fff100ULL
314 #define PLAYSTATION2_SIFBIOS 0xffffffffbfc10000ULL
315
316 /* SGI and ARC: */
317 #define MACHINE_ARC_NEC_RD94 1
318 #define MACHINE_ARC_JAZZ_PICA 2
319 #define MACHINE_ARC_NEC_R94 3
320 #define MACHINE_ARC_DESKTECH_TYNE 4
321 #define MACHINE_ARC_JAZZ_MAGNUM 5
322 #define MACHINE_ARC_NEC_R98 6
323 #define MACHINE_ARC_JAZZ_M700 7
324 #define MACHINE_ARC_NEC_R96 8
325
326 /* MacPPC: TODO: Real model names */
327 #define MACHINE_MACPPC_G4 1
328 #define MACHINE_MACPPC_G5 2
329
330 /* X86: */
331 #define MACHINE_X86_GENERIC 1
332 #define MACHINE_X86_XT 2
333
334
335 /*
336 * Problem: kernels seem to be loaded at low addresses in RAM, so
337 * storing environment strings and memory descriptors there is a bad
338 * idea. They are stored at 0xbfc..... instead. The ARC SPB must
339 * be at physical address 0x1000 though.
340 */
341 #define SGI_SPB_ADDR 0xffffffff80001000ULL
342 /* 0xbfc10000 is firmware callback vector stuff */
343 #define ARC_FIRMWARE_VECTORS 0xffffffffbfc80000ULL
344 #define ARC_FIRMWARE_ENTRIES 0xffffffffbfc88000ULL
345 #define ARC_ARGV_START 0xffffffffbfc90000ULL
346 #define ARC_ENV_STRINGS 0xffffffffbfc98000ULL
347 #define ARC_ENV_POINTERS 0xffffffffbfc9d000ULL
348 #define SGI_SYSID_ADDR 0xffffffffbfca1800ULL
349 #define ARC_DSPSTAT_ADDR 0xffffffffbfca1c00ULL
350 #define ARC_MEMDESC_ADDR 0xffffffffbfca1c80ULL
351 #define ARC_CONFIG_DATA_ADDR 0xffffffffbfca2000ULL
352 #define FIRST_ARC_COMPONENT 0xffffffffbfca8000ULL
353 #define ARC_PRIVATE_VECTORS 0xffffffffbfcb0000ULL
354 #define ARC_PRIVATE_ENTRIES 0xffffffffbfcb8000ULL
355
356
357 /* machine.c: */
358 struct machine *machine_new(char *name, struct emul *emul);
359 int machine_name_to_type(char *stype, char *ssubtype,
360 int *type, int *subtype, int *arch);
361 void machine_add_tickfunction(struct machine *machine,
362 void (*func)(struct cpu *, void *), void *extra, int clockshift);
363 void dump_mem_string(struct cpu *cpu, uint64_t addr);
364 void store_string(struct cpu *cpu, uint64_t addr, char *s);
365 int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64);
366 int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32);
367 int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16);
368 void store_byte(struct cpu *cpu, uint64_t addr, uint8_t data);
369 void store_64bit_word_in_host(struct cpu *cpu, unsigned char *data,
370 uint64_t data32);
371 void store_32bit_word_in_host(struct cpu *cpu, unsigned char *data,
372 uint64_t data32);
373 void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data,
374 uint16_t data16);
375 uint32_t load_32bit_word(struct cpu *cpu, uint64_t addr);
376 uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr);
377 void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len);
378 void machine_setup(struct machine *);
379 void machine_memsize_fix(struct machine *);
380 void machine_default_cputype(struct machine *);
381 void machine_dumpinfo(struct machine *);
382 void machine_list_available_types_and_cpus(void);
383 void machine_init(void);
384
385
386 #endif /* MACHINE_H */

  ViewVC Help
Powered by ViewVC 1.1.26