/[gxemul]/upstream/0.3.1/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 /upstream/0.3.1/include/machine.h

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26