/[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 10 - (show annotations)
Mon Oct 8 16:18:27 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 11443 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.815 2005/06/27 23:04:35 debug Exp $
20050617	Experimenting some more with netbooting OpenBSD/sgi. Adding
		a hack which allows emulated ethernet networks to be
		distributed across multiple emulator processes.
20050618	Minor updates (documentation, dummy YAMON emulation, etc).
20050620	strcpy/strcat -> strlcpy/strlcat updates.
		Some more progress on evbmips (Malta).
20050621	Adding a section to doc/configfiles.html about ethernet
		emulation across multiple hosts.
		Beginning the work on the ARM translation engine (using the
		dynamic-but-not-binary translation method).
		Fixing a bintrans bug: 0x9fc00000 should always be treated as
		PROM area, just as 0xbfc00000 is.
		Minor progress on Malta emulation (the PCI-ISA bus).
20050622	NetBSD/evbmips can now be installed (using another emulated
		machine) and run (including userland and so on). :-)
		Spliting up the bintrans haddr_entry field into two (one for
		read, one for write). Probably not much of a speed increase,
		though.
		Updating some NetBSD 2.0 -> 2.0.2 in the documentation.
20050623	Minor updates (documentation, the TODO file, etc).
		gzipped kernels are now always automagically gunzipped when
		loaded.
20050624	Adding a dummy Playstation Portable (PSP) mode, just barely
		enough to run Hello World (in weird colors :-).
		Removing the -b command line option; old bintrans is enabled
		by default instead. It makes more sense.
		Trying to finally fix the non-working performance measurement
		thing (instr/second etc).
20050625	Continuing on the essential basics for ARM emulation. Two
		instructions seem to work, a branch and a simple "mov". (The
		mov arguments are not correct yet.) Performance is definitely
		reasonable.
		Various other minor updates.
		Adding the ARM "bl" instruction.
		Adding support for combining multiple ARM instructions into one
		function call. ("mov" + "mov" is the only one implemented so
		far, but it seems to work.)
		Cleaning up some IP32 interrupt things (crime/mace); disabling
		the PS/2 keyboard controller on IP32, so that NetBSD/sgimips
		boots into userland again.
20050626	Finally! NetBSD/sgimips netboots. Adding instructions to
		doc/guestoses.html on how to set up an nfs server etc.
		Various other minor fixes.
		Playstation Portable ".pbp" files can now be used directly.
		(The ELF part of the .pbp is extracted transparently.)
		Converting some sprintf -> snprintf.
		Adding some more instructions to the ARM disassembler.
20050627	More ARM updates. Adding some simple ldr(b), str(b),
		cmps, and conditional branch instructions, enough to run
		a simple Hello World program.
		All ARM instructions are now inlined/generated for all possible
		condition codes.
		Adding add and sub, and more load/store instructions.
		Removing dummy files: cpu_alpha.c, cpu_hppa.c, and cpu_sparc.c.
		Some minor documentation updates; preparing for a 0.3.4
		release. Updating some URLs.

==============  RELEASE 0.3.4  ==============


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

  ViewVC Help
Powered by ViewVC 1.1.26