/[gxemul]/trunk/src/include/cpu.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/cpu.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 34 - (show annotations)
Mon Oct 8 16:21:17 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 16898 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1480 2007/02/19 01:34:42 debug Exp $
20061029	Changing usleep(1) calls in the debugger to usleep(10000)
20061107	Adding a new disk image option (-d o...) which sets the ISO9660
		filesystem base offset; also making some other hacks to allow
		NetBSD/dreamcast and homebrew demos/games to boot directly
		from a filesystem image.
		Moving Dreamcast-specific stuff in the documentation to its
		own page (dreamcast.html).
		Adding a border to the Dreamcast PVR framebuffer.
20061108	Adding a -T command line option (again?), for halting the
		emulator on unimplemented memory accesses.
20061109	Continuing on various SH4 and Dreamcast related things.
		The emulator should now halt on more unimplemented device
		accesses, instead of just printing a warning, forcing me to
		actually implement missing stuff :)
20061111	Continuing on SH4 and Dreamcast stuff.
		Adding a bogus Landisk (SH4) machine mode.
20061112	Implementing some parts of the Dreamcast GDROM device. With
		some ugly hacks, NetBSD can (barely) mount an ISO image.
20061113	NetBSD/dreamcast now starts booting from the Live CD image,
		but crashes randomly quite early on in the boot process.
20061122	Beginning on a skeleton interrupt.h and interrupt.c for the
		new interrupt subsystem.
20061124	Continuing on the new interrupt system; taking the first steps
		to attempt to connect CPUs (SuperH and MIPS) and devices
		(dev_cons and SH4 timer interrupts) to it. Many things will
		probably break from now on.
20061125	Converting dev_ns16550, dev_8253 to the new interrupt system.
		Attempting to begin to convert the ISA bus.
20061130	Incorporating a patch from Brian Foley for the configure
		script, which checks for X11 libs in /usr/X11R6/lib64 (which
		is used on some Linux systems).
20061227	Adding a note in the man page about booting from Dreamcast
		CDROM images (i.e. that no external kernel is needed).
20061229	Continuing on the interrupt system rewrite: beginning to
		convert more devices, adding abort() calls for legacy interrupt
		system calls so that everything now _has_ to be rewritten!
		Almost all machine modes are now completely broken.
20061230	More progress on removing old interrupt code, mostly related
		to the ISA bus + devices, the LCA bus (on AlphaBook1), and
		the Footbridge bus (for CATS). And some minor PCI stuff.
		Connecting the ARM cpu to the new interrupt system.
		The CATS, NetWinder, and QEMU_MIPS machine modes now work with
		the new interrupt system :)
20061231	Connecting PowerPC CPUs to the new interrupt system.
		Making PReP machines (IBM 6050) work again.
		Beginning to convert the GT PCI controller (for e.g. Malta
		and Cobalt emulation). Some things work, but not everything.
		Updating Copyright notices for 2007.
20070101	Converting dev_kn02 from legacy style to devinit; the 3max
		machine mode now works with the new interrupt system :-]
20070105	Beginning to convert the SGI O2 machine to the new interrupt
		system; finally converting O2 (IP32) devices to devinit, etc.
20070106	Continuing on the interrupt system redesign/rewrite; KN01
		(PMAX), KN230, and Dreamcast ASIC interrupts should work again,
		moving out stuff from machine.h and devices.h into the
		corresponding devices, beginning the rewrite of i80321
		interrupts, etc.
20070107	Beginning on the rewrite of Eagle interrupt stuff (PReP, etc).
20070117	Beginning the rewrite of Algor (V3) interrupts (finally
		changing dev_v3 into devinit style).
20070118	Removing the "bus" registry concept from machine.h, because
		it was practically meaningless.
		Continuing on the rewrite of Algor V3 ISA interrupts.
20070121	More work on Algor interrupts; they are now working again,
		well enough to run NetBSD/algor. :-)
20070122	Converting VR41xx (HPCmips) interrupts. NetBSD/hpcmips
		can be installed using the new interrupt system :-)
20070123	Making the testmips mode work with the new interrupt system.
20070127	Beginning to convert DEC5800 devices to devinit, and to the
		new interrupt system.
		Converting Playstation 2 devices to devinit, and converting
		the interrupt system. Also fixing a severe bug: the interrupt
		mask register on Playstation 2 is bitwise _toggled_ on writes.
20070128	Removing the dummy NetGear machine mode and the 8250 device
		(which was only used by the NetGear machine).
		Beginning to convert the MacPPC GC (Grand Central) interrupt
		controller to the new interrupt system.
		Converting Jazz interrupts (PICA61 etc.) to the new interrupt
		system. NetBSD/arc can be installed again :-)
		Fixing the JAZZ timer (hardcoding it at 100 Hz, works with
		NetBSD and it is better than a completely dummy timer as it
		was before).
		Converting dev_mp to the new interrupt system, although I
		haven't had time to actually test it yet.
		Completely removing src/machines/interrupts.c, cpu_interrupt
		and cpu_interrupt_ack in src/cpu.c, and
		src/include/machine_interrupts.h! Adding fatal error messages
		+ abort() in the few places that are left to fix.
		Converting dev_z8530 to the new interrupt system.
		FINALLY removing the md_int struct completely from the
		machine struct.
		SH4 fixes (adding a PADDR invalidation in the ITLB replacement
		code in memory_sh.c); the NetBSD/dreamcast LiveCD now runs
		all the way to the login prompt, and can be interacted with :-)
		Converting the CPC700 controller (PCI and interrupt controller
		for PM/PPC) to the new interrupt system.
20070129	Fixing MACE ISA interrupts (SGI IP32 emulation). Both NetBSD/
		sgimips' and OpenBSD/sgi's ramdisk kernels can now be
		interacted with again.
20070130	Moving out the MIPS multi_lw and _sw instruction combinations
		so that they are auto-generated at compile time instead.
20070131	Adding detection of amd64/x86_64 hosts in the configure script,
		for doing initial experiments (again :-) with native code
		generation.
		Adding a -k command line option to set the size of the dyntrans
		cache, and a -B command line option to disable native code
		generation, even if GXemul was compiled with support for
		native code generation for the specific host CPU architecture.
20070201	Experimenting with a skeleton for native code generation.
		Changing the default behaviour, so that native code generation
		is now disabled by default, and has to be enabled by using
		-b on the command line.
20070202	Continuing the native code generation experiments.
		Making PCI interrupts work for Footbridge again.
20070203	More native code generation experiments.
		Removing most of the native code generation experimental code,
		it does not make sense to include any quick hacks like this.
		Minor cleanup/removal of some more legacy MIPS interrupt code.
20070204	Making i80321 interrupts work again (for NetBSD/evbarm etc.),
		and fixing the timer at 100 Hz.
20070206	Experimenting with removing the wdc interrupt slowness hack.
20070207	Lowering the number of dyntrans TLB entries for MIPS from
		192 to 128, resulting in a minor speed improvement.
		Minor optimization to the code invalidation routine in
		cpu_dyntrans.c.
20070208	Increasing (experimentally) the nr of dyntrans instructions per
		loop from 60 to 120.
20070210	Commenting out (experimentally) the dyntrans_device_danger
		detection in memory_rw.c.
		Changing the testmips and baremips machines to use a revision 2
		MIPS64 CPU by default, instead of revision 1.
		Removing the dummy i960, IA64, x86, AVR32, and HP PA-RISC
		files, the PC bios emulation, and the Olivetti M700 (ARC) and
		db64360 emulation modes.
20070211	Adding an "mp" demo to the demos directory, which tests the
		SMP functionality of the testmips machine.
		Fixing PReP interrupts some more. NetBSD/prep now boots again.
20070216	Adding a "nop workaround" for booting Mach/PMAX to the
		documentation; thanks to Artur Bujdoso for the values.
		Converting more of the MacPPC interrupt stuff to the new
		system.
		Beginning to convert BeBox interrupts to the new system.
		PPC603e should NOT have the PPC_NO_DEC flag! Removing it.
		Correcting BeBox clock speed (it was set to 100 in the NetBSD
		bootinfo block, but should be 33000000/4), allowing NetBSD
		to start without using the (incorrect) PPC_NO_DEC hack.
20070217	Implementing (slow) AltiVec vector loads and stores, allowing
		NetBSD/macppc to finally boot using the GENERIC kernel :-)
		Updating the documentation with install instructions for
		NetBSD/macppc.
20070218-19	Regression testing for the release.

==============  RELEASE 0.4.4  ==============


1 #ifndef CPU_H
2 #define CPU_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: cpu.h,v 1.109 2007/02/10 14:29:54 debug Exp $
32 *
33 * CPU-related definitions.
34 */
35
36
37 #include <sys/types.h>
38 #include <inttypes.h>
39 #include <sys/time.h>
40
41 /* This is needed for undefining 'mips', 'ppc' etc. on weird systems: */
42 #include "../../config.h"
43
44 /*
45 * Dyntrans misc declarations, used throughout the dyntrans code.
46 *
47 * Note that there is place for all instruction calls within a page,
48 * and then 2 more. The first one of these "extra" instruction slots is
49 * the end-of-page slot. It transfers control to the first instruction
50 * slot on the next (virtual) page.
51 *
52 * The second of these extra instruction slots is an additional
53 * end-of-page slot for delay-slot architectures. On e.g. MIPS, a branch
54 * instruction can "nullify" (skip) the delay-slot. If the end-of-page
55 * slot is skipped, then we end up one step after that. That's where the
56 * end_of_page2 slot is. :)
57 *
58 * next_ofs points to the next page in a chain of possible pages.
59 * (several pages can be in the same chain, but only one matches the
60 * specific physaddr.)
61 *
62 * translations is a tiny bitmap indicating which parts of the page have
63 * actual translations. Bit 0 corresponds to the lowest 1/32th of the page,
64 * bit 1 to the second-lowest 1/32th, and so on.
65 */
66 #define DYNTRANS_MISC_DECLARATIONS(arch,ARCH,addrtype) struct \
67 arch ## _instr_call { \
68 void (*f)(struct cpu *, struct arch ## _instr_call *); \
69 size_t arg[ARCH ## _N_IC_ARGS]; \
70 }; \
71 \
72 /* Translation cache struct for each physical page: */ \
73 struct arch ## _tc_physpage { \
74 struct arch ## _instr_call ics[ARCH ## _IC_ENTRIES_PER_PAGE+2];\
75 uint32_t next_ofs; /* (0 for end of chain) */ \
76 uint32_t translations; \
77 addrtype physaddr; \
78 }; \
79 \
80 struct arch ## _vpg_tlb_entry { \
81 uint8_t valid; \
82 uint8_t writeflag; \
83 addrtype vaddr_page; \
84 addrtype paddr_page; \
85 unsigned char *host_page; \
86 };
87
88 #define DYNTRANS_MISC64_DECLARATIONS(arch,ARCH,tlbindextype) \
89 struct arch ## _l3_64_table { \
90 unsigned char *host_load[1 << ARCH ## _L3N]; \
91 unsigned char *host_store[1 << ARCH ## _L3N]; \
92 uint64_t phys_addr[1 << ARCH ## _L3N]; \
93 tlbindextype vaddr_to_tlbindex[1 << ARCH ## _L3N]; \
94 struct arch ## _tc_physpage *phys_page[1 << ARCH ## _L3N]; \
95 struct arch ## _l3_64_table *next; \
96 int refcount; \
97 }; \
98 struct arch ## _l2_64_table { \
99 struct arch ## _l3_64_table *l3[1 << ARCH ## _L2N]; \
100 struct arch ## _l2_64_table *next; \
101 int refcount; \
102 };
103
104 /*
105 * Dyntrans "Instruction Translation Cache":
106 *
107 * cur_physpage is a pointer to the current physpage. (It _HAPPENS_ to
108 * be the same as cur_ic_page, because all the instrcalls should be placed
109 * first in the physpage struct!)
110 *
111 * cur_ic_page is a pointer to an array of xxx_IC_ENTRIES_PER_PAGE
112 * instruction call entries.
113 *
114 * next_ic points to the next such instruction call to be executed.
115 *
116 * combination_check, when set to non-NULL, is executed automatically after
117 * an instruction has been translated. (It check for combinations of
118 * instructions; low_addr is the offset of the translated instruction in the
119 * current page, NOT shifted right.)
120 */
121 #define DYNTRANS_ITC(arch) struct arch ## _tc_physpage *cur_physpage; \
122 struct arch ## _instr_call *cur_ic_page; \
123 struct arch ## _instr_call *next_ic; \
124 struct arch ## _tc_physpage *physpage_template;\
125 void (*combination_check)(struct cpu *, \
126 struct arch ## _instr_call *, int low_addr);
127
128 /*
129 * Virtual -> physical -> host address translation TLB entries:
130 * ------------------------------------------------------------
131 *
132 * Regardless of whether 32-bit or 64-bit address translation is used, the
133 * same TLB entry structure is used.
134 */
135 #define VPH_TLBS(arch,ARCH) \
136 struct arch ## _vpg_tlb_entry \
137 vph_tlb_entry[ARCH ## _MAX_VPH_TLB_ENTRIES];
138
139 /*
140 * 32-bit dyntrans emulated Virtual -> physical -> host address translation:
141 * -------------------------------------------------------------------------
142 *
143 * This stuff assumes that 4 KB pages are used. 20 bits to select a page
144 * means just 1 M entries needed. This is small enough that a couple of
145 * full-size tables can fit in virtual memory on modern hosts (both 32-bit
146 * and 64-bit hosts). :-)
147 *
148 * Usage: e.g. VPH32(arm,ARM,uint32_t,uint8_t)
149 * or VPH32(sparc,SPARC,uint64_t,uint16_t)
150 *
151 * The vph_tlb_entry entries are cpu dependent tlb entries.
152 *
153 * The host_load and host_store entries point to host pages; the phys_addr
154 * entries are uint32_t or uint64_t (emulated physical addresses).
155 *
156 * phys_page points to translation cache physpages.
157 *
158 * vaddr_to_tlbindex is a virtual address to tlb index hint table.
159 * The values in this array are the tlb index plus 1, so a value of, say,
160 * 3 means tlb index 2. A value of 0 would mean a tlb index of -1, which
161 * is not a valid index. (I.e. no hit.)
162 */
163 #define N_VPH32_ENTRIES 1048576
164 #define VPH32(arch,ARCH,paddrtype,tlbindextype) \
165 unsigned char *host_load[N_VPH32_ENTRIES]; \
166 unsigned char *host_store[N_VPH32_ENTRIES]; \
167 paddrtype phys_addr[N_VPH32_ENTRIES]; \
168 struct arch ## _tc_physpage *phys_page[N_VPH32_ENTRIES]; \
169 tlbindextype vaddr_to_tlbindex[N_VPH32_ENTRIES];
170
171 /*
172 * 64-bit dyntrans emulated Virtual -> physical -> host address translation:
173 * -------------------------------------------------------------------------
174 *
175 * Usage: e.g. VPH64(alpha,ALPHA,uint8_t)
176 * or VPH64(sparc,SPARC,uint16_t)
177 *
178 * l1_64 is an array containing poiners to l2 tables.
179 *
180 * l2_64_dummy is a pointer to a "dummy l2 table". Instead of having NULL
181 * pointers in l1_64 for unused slots, a pointer to the dummy table can be
182 * used.
183 */
184 #define DYNTRANS_L1N 17
185 #define VPH64(arch,ARCH,tlbindextype) \
186 struct arch ## _l3_64_table *l3_64_dummy; \
187 struct arch ## _l3_64_table *next_free_l3; \
188 struct arch ## _l2_64_table *l2_64_dummy; \
189 struct arch ## _l2_64_table *next_free_l2; \
190 struct arch ## _l2_64_table *l1_64[1 << DYNTRANS_L1N];
191
192
193 /* Include all CPUs' header files here: */
194 #include "cpu_alpha.h"
195 #include "cpu_arm.h"
196 #include "cpu_avr.h"
197 #include "cpu_m68k.h"
198 #include "cpu_mips.h"
199 #include "cpu_ppc.h"
200 #include "cpu_rca180x.h"
201 #include "cpu_sh.h"
202 #include "cpu_sparc.h"
203 #include "cpu_transputer.h"
204
205 struct cpu;
206 struct emul;
207 struct machine;
208 struct memory;
209 struct settings;
210
211
212 /*
213 * cpu_family
214 * ----------
215 *
216 * This structure consists of various pointers to functions, performing
217 * architecture-specific functions.
218 *
219 * Except for the next and arch fields at the top, all fields in the
220 * cpu_family struct are filled in by ecah CPU family's init function.
221 */
222 struct cpu_family {
223 struct cpu_family *next;
224 int arch;
225
226 /* Familty name, e.g. "MIPS", "Alpha" etc. */
227 char *name;
228
229 /* Fill in architecture specific parts of a struct cpu. */
230 int (*cpu_new)(struct cpu *cpu, struct memory *mem,
231 struct machine *machine,
232 int cpu_id, char *cpu_type_name);
233
234 /* Initialize various translation tables. */
235 void (*init_tables)(struct cpu *cpu);
236
237 /* List available CPU types for this architecture. */
238 void (*list_available_types)(void);
239
240 /* Disassemble an instruction. */
241 int (*disassemble_instr)(struct cpu *cpu,
242 unsigned char *instr, int running,
243 uint64_t dumpaddr);
244
245 /* Dump CPU registers in readable format. */
246 void (*register_dump)(struct cpu *cpu,
247 int gprs, int coprocs);
248
249 /* Dump generic CPU info in readable format. */
250 void (*dumpinfo)(struct cpu *cpu);
251
252 /* Dump TLB data for CPU id x. */
253 void (*tlbdump)(struct machine *m, int x,
254 int rawflag);
255
256 /* Print architecture-specific function call arguments.
257 (This is called for each function call, if running with -t.) */
258 void (*functioncall_trace)(struct cpu *,
259 uint64_t f, int n_args);
260
261 /* GDB command handler. */
262 char *(*gdb_stub)(struct cpu *, char *cmd);
263 };
264
265
266 /*
267 * More dyntrans stuff:
268 *
269 * The translation cache begins with N_BASE_TABLE_ENTRIES uint32_t offsets
270 * into the cache, for possible translation cache structs for physical pages.
271 */
272
273 /* Meaning of delay_slot: */
274 #define NOT_DELAYED 0
275 #define DELAYED 1
276 #define TO_BE_DELAYED 2
277 #define EXCEPTION_IN_DELAY_SLOT 8
278
279 #define N_SAFE_DYNTRANS_LIMIT_SHIFT 14
280 #define N_SAFE_DYNTRANS_LIMIT ((1 << (N_SAFE_DYNTRANS_LIMIT_SHIFT - 1)) - 1)
281
282 #define DEFAULT_DYNTRANS_CACHE_SIZE (40*1048576)
283 #define DYNTRANS_CACHE_MARGIN 200000
284
285 #define N_BASE_TABLE_ENTRIES 32768
286 #define PAGENR_TO_TABLE_INDEX(a) ((a) & (N_BASE_TABLE_ENTRIES-1))
287
288
289 /*
290 * The generic CPU struct:
291 */
292
293 struct cpu {
294 /* Pointer back to the machine this CPU is in: */
295 struct machine *machine;
296
297 /* Settings: */
298 struct settings *settings;
299
300 /* CPU-specific name, e.g. "R2000", "21164PC", etc. */
301 char *name;
302
303 /* Full "path" to the CPU, e.g. "emul[0].machine[0].cpu[0]": */
304 char *path;
305
306 /* EMUL_LITTLE_ENDIAN or EMUL_BIG_ENDIAN. */
307 int byte_order;
308
309 /* 0-based CPU id, in an emulated SMP system. */
310 int cpu_id;
311
312 /* 0 for emulated 64-bit CPUs, 1 for 32-bit. */
313 int is_32bit;
314
315 /* 1 while running, 0 when paused/stopped. */
316 int running;
317
318 /* A pointer to the main memory connected to this CPU. */
319 struct memory *mem;
320
321 int (*run_instr)(struct cpu *cpu);
322 int (*memory_rw)(struct cpu *cpu,
323 struct memory *mem, uint64_t vaddr,
324 unsigned char *data, size_t len,
325 int writeflag, int cache_flags);
326 int (*translate_v2p)(struct cpu *, uint64_t vaddr,
327 uint64_t *return_paddr, int flags);
328 void (*update_translation_table)(struct cpu *,
329 uint64_t vaddr_page, unsigned char *host_page,
330 int writeflag, uint64_t paddr_page);
331 void (*invalidate_translation_caches)(struct cpu *,
332 uint64_t paddr, int flags);
333 void (*invalidate_code_translation)(struct cpu *,
334 uint64_t paddr, int flags);
335 void (*useremul_syscall)(struct cpu *cpu, uint32_t code);
336 int (*instruction_has_delayslot)(struct cpu *cpu,
337 unsigned char *ib);
338
339 /* The program counter. (For 32-bit modes, not all bits are used.) */
340 uint64_t pc;
341
342 /* See comment further up. */
343 int delay_slot;
344
345 /* The current depth of function call tracing. */
346 int trace_tree_depth;
347
348 /*
349 * If is_halted is true when an interrupt trap occurs, the pointer
350 * to the next instruction to execute will be the instruction
351 * following the halt instruction, not the halt instrucion itself.
352 *
353 * If has_been_idling is true when printing the number of executed
354 * instructions per second, "idling" is printed instead. (The number
355 * of instrs per second when idling is meaningless anyway.)
356 */
357 int is_halted;
358 int has_been_idling;
359
360 /*
361 * Dynamic translation:
362 *
363 * The number of translated instructions is assumed to be 1 per
364 * instruction call. For each case where this differs from the
365 * truth, n_translated_instrs should be modified. E.g. if 1000
366 * instruction calls are done, and n_translated_instrs is 50, then
367 * 1050 emulated instructions were actually executed.
368 *
369 * Note that it can also be adjusted negatively, that is, the way
370 * to "get out" of a dyntrans loop is to set the current instruction
371 * call pointer to the "nothing" instruction. This instruction
372 * _decreases_ n_translated_instrs. That way, once the dyntrans loop
373 * exits, only real instructions will be counted, and not the
374 * "nothing" instructions.
375 *
376 * The translation cache is a relative large chunk of memory (say,
377 * 32 MB) which is used for translations. When it has been used up,
378 * everything restarts from scratch.
379 *
380 * When translating to native code, currently_translating_to_native
381 * is non-zero, and native_code_function_pointer points to the
382 * "ic->f" which will be modified (once the translation has finished)
383 * to point to the newly translated code.
384 */
385 int n_translated_instrs;
386 unsigned char *translation_cache;
387 size_t translation_cache_cur_ofs;
388 int currently_translating_to_native;
389 int nr_of_instructions_translated_to_native;
390 unsigned char *native_cur_output_ptr;
391 void **native_code_function_pointer;
392
393 /*
394 * CPU-family dependent:
395 *
396 * These contain everything ranging from registers, memory management,
397 * status words, etc.
398 */
399 union {
400 struct alpha_cpu alpha;
401 struct arm_cpu arm;
402 struct avr_cpu avr;
403 struct m68k_cpu m68k;
404 struct mips_cpu mips;
405 struct ppc_cpu ppc;
406 struct rca180x_cpu rca180x;
407 struct sh_cpu sh;
408 struct sparc_cpu sparc;
409 struct transputer_cpu transputer;
410 } cd;
411 };
412
413
414 /* cpu.c: */
415 struct cpu *cpu_new(struct memory *mem, struct machine *machine,
416 int cpu_id, char *cpu_type_name);
417 void cpu_destroy(struct cpu *cpu);
418
419 void cpu_tlbdump(struct machine *m, int x, int rawflag);
420 void cpu_register_dump(struct machine *m, struct cpu *cpu,
421 int gprs, int coprocs);
422 int cpu_disassemble_instr(struct machine *m, struct cpu *cpu,
423 unsigned char *instr, int running, uint64_t addr);
424 char *cpu_gdb_stub(struct cpu *cpu, char *cmd);
425
426 void cpu_functioncall_trace(struct cpu *cpu, uint64_t f);
427 void cpu_functioncall_trace_return(struct cpu *cpu);
428
429 void cpu_create_or_reset_tc(struct cpu *cpu);
430
431 void cpu_run_init(struct machine *machine);
432 void cpu_run_deinit(struct machine *machine);
433
434 void cpu_dumpinfo(struct machine *m, struct cpu *cpu);
435 void cpu_list_available_types(void);
436 void cpu_show_cycles(struct machine *machine, int forced);
437
438 struct cpu_family *cpu_family_ptr_by_number(int arch);
439 void cpu_init(void);
440
441
442 #define JUST_MARK_AS_NON_WRITABLE 1
443 #define INVALIDATE_ALL 2
444 #define INVALIDATE_PADDR 4
445 #define INVALIDATE_VADDR 8
446 #define INVALIDATE_VADDR_UPPER4 16 /* useful for PPC emulation */
447
448
449 /* Note: 64-bit processors running in 32-bit mode use a 32-bit
450 display format, even though the underlying data is 64-bits. */
451 #define CPU_SETTINGS_ADD_REGISTER64(name, var) \
452 settings_add(cpu->settings, name, 1, SETTINGS_TYPE_UINT64, \
453 cpu->is_32bit? SETTINGS_FORMAT_HEX32 : SETTINGS_FORMAT_HEX64, \
454 (void *) &(var));
455 #define CPU_SETTINGS_ADD_REGISTER32(name, var) \
456 settings_add(cpu->settings, name, 1, SETTINGS_TYPE_UINT32, \
457 SETTINGS_FORMAT_HEX32, (void *) &(var));
458 #define CPU_SETTINGS_ADD_REGISTER16(name, var) \
459 settings_add(cpu->settings, name, 1, SETTINGS_TYPE_UINT16, \
460 SETTINGS_FORMAT_HEX16, (void *) &(var));
461 #define CPU_SETTINGS_ADD_REGISTER8(name, var) \
462 settings_add(cpu->settings, name, 1, SETTINGS_TYPE_UINT8, \
463 SETTINGS_FORMAT_HEX8, (void *) &(var));
464
465
466 #define CPU_FAMILY_INIT(n,s) int n ## _cpu_family_init( \
467 struct cpu_family *fp) { \
468 /* Fill in the cpu_family struct with valid data for this arch. */ \
469 fp->name = s; \
470 fp->cpu_new = n ## _cpu_new; \
471 fp->list_available_types = n ## _cpu_list_available_types; \
472 fp->disassemble_instr = n ## _cpu_disassemble_instr; \
473 fp->register_dump = n ## _cpu_register_dump; \
474 fp->dumpinfo = n ## _cpu_dumpinfo; \
475 fp->functioncall_trace = n ## _cpu_functioncall_trace; \
476 fp->gdb_stub = n ## _cpu_gdb_stub; \
477 fp->tlbdump = n ## _cpu_tlbdump; \
478 fp->init_tables = n ## _cpu_init_tables; \
479 return 1; \
480 }
481
482
483 #endif /* CPU_H */

  ViewVC Help
Powered by ViewVC 1.1.26