/[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 14 - (show annotations)
Mon Oct 8 16:18:51 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 12572 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.982 2005/10/07 22:45:32 debug Exp $
20050816	Some success in decoding the way the SGI O2 PROM draws graphics
		during bootup; lines/rectangles and bitmaps work, enough to
		show the bootlogo etc. :-)
		Adding more PPC instructions, and (dummy) BAT registers.
20050817	Updating the pckbc to support scancode type 3 keyboards
		(required in order to interact with the SGI O2 PROM).
		Adding more PPC instructions.
20050818	Adding more ARM instructions; general register forms.
		Importing armreg.h from NetBSD (ARM cpu ids). Adding a (dummy)
		CATS machine mode (using SA110 as the default CPU).
		Continuing on general dyntrans related stuff.
20050819	Register forms for ARM load/stores. Gaah! The Compaq C Compiler
		bug is triggered for ARM loads as well, not just PPC :-(
		Adding full support for ARM PC-relative load/stores, and load/
		stores where the PC register is the destination register.
		Adding support for ARM a.out binaries.
20050820	Continuing to add more ARM instructions, and correcting some
		bugs. Continuing on CATS emulation.
		More work on the PPC stuff.
20050821	Minor PPC and ARM updates. Adding more machine types.
20050822	All ARM "data processing instructions" are now generated
		automatically.
20050824	Beginning the work on the ARM system control coprocessor.
		Adding support for ARM halfword load/stores, and signed loads.
20050825	Fixing an important bug related to the ARM condition codes.
		OpenBSD/zaurus and NetBSD/netwinder now print some boot
		messages. :)
		Adding a dummy SH (Hitachi SuperH) cpu family.
		Beginning to add some ARM virtual address translation.
		MIPS bugfixes: unaligned PC now cause an ADEL exception (at
		least for non-bintrans execution), and ADEL/ADES (not
		TLBL/TLBS) are used if userland tries to access kernel space.
		(Thanks to Joshua Wise for making me aware of these bugs.)
20050827	More work on the ARM emulation, and various other updates.
20050828	More ARM updates.
		Finally taking the time to work on translation invalidation
		(i.e. invalidating translated code mappings when memory is
		written to). Hopefully this doesn't break anything.
20050829	Moving CPU related files from src/ to a new subdir, src/cpus/.
		Moving PROM emulation stuff from src/ to src/promemul/.
		Better debug instruction trace for ARM loads and stores.
20050830	Various ARM updates (correcting CMP flag calculation, etc).
20050831	PPC instruction updates. (Flag fixes, etc.)
20050901	Various minor PPC and ARM instruction emulation updates.
		Minor OpenFirmware emulation updates.
20050903	Adding support for adding arbitrary ARM coprocessors (with
		the i80321 I/O coprocessor as a first test).
		Various other ARM and PPC updates.
20050904	Adding some SHcompact disassembly routines.
20050907	(Re)adding a dummy HPPA CPU module, and a dummy i960 module.
20050908	Began hacking on some Apple Partition Table support.
20050909	Adding support for loading Mach-O (Darwin PPC) binaries.
20050910	Fixing an ARM bug (Carry flag was incorrectly updated for some
		data processing instructions); OpenBSD/cats and NetBSD/
		netwinder get quite a bit further now.
		Applying a patch to dev_wdc, and a one-liner to dev_pcic, to
		make them work better when emulating new versions of OpenBSD.
		(Thanks to Alexander Yurchenko for the patches.)
		Also doing some other minor updates to dev_wdc. (Some cleanup,
		and finally converting to devinit, etc.)
20050912	IRIX doesn't have u_int64_t by default (noticed by Andreas
		<avr@gnulinux.nl>); configure updated to reflect this.
		Working on ARM register bank switching, CPSR vs SPSR issues,
		and beginning the work on interrupt/exception support.
20050913	Various minor ARM updates (speeding up load/store multiple,
		and fixing a ROR bug in R(); NetBSD/cats now boots as far as
		OpenBSD/cats).
20050917	Adding a dummy Atmel AVR (8-bit) cpu family skeleton.
20050918	Various minor updates.
20050919	Symbols are now loaded from Mach-O executables.
		Continuing the work on adding ARM exception support.
20050920	More work on ARM stuff: OpenBSD/cats and NetBSD/cats reach
		userland! :-)
20050921	Some more progress on ARM interrupt specifics.
20050923	Fixing linesize for VR4121 (patch by Yurchenko). Also fixing
		linesizes/cachesizes for some other VR4xxx.
		Adding a dummy Acer Labs M1543 PCI-ISA bridge (for CATS) and a
		dummy Symphony Labs 83C553 bridge (for Netwinder), usable by 
		dev_footbridge.
20050924	Some PPC progress.
20050925	More PPC progress.
20050926	PPC progress (fixing some bugs etc); Darwin's kernel gets
		slightly further than before.
20050928	Various updates: footbridge/ISA/pciide stuff, and finally
		fixing the VGA text scroll-by-changing-the-base-offset bug.
20050930	Adding a dummy S3 ViRGE pci card for CATS emulation, which
		both NetBSD and OpenBSD detects as VGA.
		Continuing on Footbridge (timers, ISA interrupt stuff).
20051001	Continuing... there are still bugs, probably interrupt-
		related.
20051002	More work on the Footbridge (interrupt stuff).
20051003	Various minor updates. (Trying to find the bug(s).)
20051004	Continuing on the ARM stuff.
20051005	More ARM-related fixes.
20051007	FINALLY! Found and fixed 2 ARM bugs: 1 memory related, and the
		other was because of an error in the ARM manual (load multiple
		with the S-bit set should _NOT_ load usermode registers, as the
		manual says, but it should load saved registers, which may or
		may not happen to be usermode registers).
		NetBSD/cats and OpenBSD/cats seem to install fine now :-)
		except for a minor bug at the end of the OpenBSD/cats install.
		Updating the documentation, preparing for the next release.
20051008	Continuing with release testing and cleanup.

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

  ViewVC Help
Powered by ViewVC 1.1.26