mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-11 10:30:09 +00:00
- Changes to support 68040 -> x86 dynamic translator
- Globalize FLIGHT_RECORDER, possibly used in compiler/ sources as well
This commit is contained in:
parent
c0526db089
commit
4fc127c8df
@ -22,16 +22,18 @@
|
||||
|
||||
#include "cpu_emulation.h"
|
||||
#include "main.h"
|
||||
#include "prefs.h"
|
||||
#include "emul_op.h"
|
||||
#include "rom_patches.h"
|
||||
#include "m68k.h"
|
||||
#include "memory.h"
|
||||
#include "readcpu.h"
|
||||
#include "newcpu.h"
|
||||
#include "compiler/compemu.h"
|
||||
|
||||
|
||||
// RAM and ROM pointers
|
||||
uint32 RAMBaseMac = 0; // RAM base (Mac address space) gb-- init is important
|
||||
uint32 RAMBaseMac = 0; // RAM base (Mac address space) gb-- initializer is important
|
||||
uint8 *RAMBaseHost; // RAM base (host address space)
|
||||
uint32 RAMSize; // Size of RAM
|
||||
uint32 ROMBaseMac; // ROM base (Mac address space)
|
||||
@ -49,6 +51,10 @@ int MacFrameLayout; // Frame buffer layout
|
||||
uintptr MEMBaseDiff; // Global offset between a Mac address and its Host equivalent
|
||||
#endif
|
||||
|
||||
#if USE_JIT
|
||||
bool UseJIT = false;
|
||||
#endif
|
||||
|
||||
// From newcpu.cpp
|
||||
extern int quit_program;
|
||||
|
||||
@ -90,6 +96,11 @@ bool Init680x0(void)
|
||||
#endif
|
||||
|
||||
init_m68k();
|
||||
#if USE_JIT
|
||||
UseJIT = compiler_use_jit();
|
||||
if (UseJIT)
|
||||
compiler_init();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -100,6 +111,10 @@ bool Init680x0(void)
|
||||
|
||||
void Exit680x0(void)
|
||||
{
|
||||
#if USE_JIT
|
||||
if (UseJIT)
|
||||
compiler_exit();
|
||||
#endif
|
||||
exit_m68k();
|
||||
}
|
||||
|
||||
@ -122,6 +137,11 @@ void InitFrameBufferMapping(void)
|
||||
void Start680x0(void)
|
||||
{
|
||||
m68k_reset();
|
||||
#if USE_JIT
|
||||
if (UseJIT)
|
||||
m68k_compile_execute();
|
||||
else
|
||||
#endif
|
||||
m68k_execute();
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,13 @@ extern bool Init680x0(void); // This routine may want to look at CPUType/FPUType
|
||||
extern void Exit680x0(void);
|
||||
extern void InitFrameBufferMapping(void);
|
||||
|
||||
// 680x0 dynamic recompilation activation flag
|
||||
#if USE_JIT
|
||||
extern bool UseJIT;
|
||||
#else
|
||||
const bool UseJIT = false;
|
||||
#endif
|
||||
|
||||
// 680x0 emulation functions
|
||||
struct M68kRegisters;
|
||||
extern void Start680x0(void); // Reset and start 680x0
|
||||
|
@ -2159,9 +2159,16 @@ static void gen_opcode (unsigned long int opcode)
|
||||
case i_CINVL:
|
||||
case i_CINVP:
|
||||
case i_CINVA:
|
||||
/* gb-- srcreg now contains the cache field */
|
||||
printf ("\tif (srcreg&0x2)\n");
|
||||
printf ("\t\tflush_icache(%d);\n", 30 + ((opcode >> 3) & 3));
|
||||
break;
|
||||
case i_CPUSHL:
|
||||
case i_CPUSHP:
|
||||
case i_CPUSHA:
|
||||
/* gb-- srcreg now contains the cache field */
|
||||
printf ("\tif (srcreg&0x2)\n");
|
||||
printf ("\t\tflush_icache(%d);\n", 40 + ((opcode >> 3) & 3));
|
||||
break;
|
||||
case i_MOVE16:
|
||||
if ((opcode & 0xfff8) == 0xf620) {
|
||||
@ -2227,6 +2234,7 @@ static void generate_includes (FILE * f)
|
||||
fprintf (f, "#include \"memory.h\"\n");
|
||||
fprintf (f, "#include \"readcpu.h\"\n");
|
||||
fprintf (f, "#include \"newcpu.h\"\n");
|
||||
fprintf (f, "#include \"compiler/compemu.h\"\n");
|
||||
fprintf (f, "#include \"fpu/fpu.h\"\n");
|
||||
fprintf (f, "#include \"cputbl.h\"\n");
|
||||
|
||||
|
@ -22,6 +22,7 @@ extern int intlev(void); // From baisilisk_glue.cpp
|
||||
#include "memory.h"
|
||||
#include "readcpu.h"
|
||||
#include "newcpu.h"
|
||||
#include "compiler/compemu.h"
|
||||
#include "fpu/fpu.h"
|
||||
|
||||
#if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS)
|
||||
@ -53,8 +54,6 @@ int movem_next[256];
|
||||
|
||||
cpuop_func *cpufunctbl[65536];
|
||||
|
||||
#define FLIGHT_RECORDER 0
|
||||
|
||||
#if FLIGHT_RECORDER
|
||||
struct rec_step {
|
||||
uae_u32 d[8];
|
||||
@ -72,7 +71,7 @@ static const char *log_filename(void)
|
||||
return name ? name : "log.68k";
|
||||
}
|
||||
|
||||
static void record_step(uaecptr pc)
|
||||
void m68k_record_step(uaecptr pc)
|
||||
{
|
||||
for (int i = 0; i < 8; i++) {
|
||||
log[log_ptr].d[i] = m68k_dreg(regs, i);
|
||||
@ -802,7 +801,22 @@ int m68k_move2c (int regno, uae_u32 *regp)
|
||||
switch (regno) {
|
||||
case 0: regs.sfc = *regp & 7; break;
|
||||
case 1: regs.dfc = *regp & 7; break;
|
||||
case 2: cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000); break;
|
||||
case 2:
|
||||
cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000);
|
||||
#if USE_JIT
|
||||
if (CPUType < 4) {
|
||||
set_cache_state(cacr&1);
|
||||
if (*regp & 0x08)
|
||||
flush_icache(1);
|
||||
}
|
||||
else {
|
||||
set_cache_state((cacr&0x8000) || 0);
|
||||
// FIXME: The User Manual claims bit 3 of CACR is undefined
|
||||
if (*regp & 0x08)
|
||||
flush_icache(2);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 3: tc = *regp & 0xc000; break;
|
||||
case 4: itt0 = *regp & 0xffffe364; break;
|
||||
case 5: itt1 = *regp & 0xffffe364; break;
|
||||
@ -1191,6 +1205,9 @@ cpuop_rettype REGPARAM2 op_illg (uae_u32 opcode)
|
||||
}
|
||||
|
||||
write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc);
|
||||
#if USE_JIT && JIT_DEBUG
|
||||
compiler_dumpstate();
|
||||
#endif
|
||||
|
||||
Exception (4,0);
|
||||
cpuop_return(CFLOW_TRAP);
|
||||
@ -1248,6 +1265,18 @@ static void do_trace (void)
|
||||
|
||||
int m68k_do_specialties (void)
|
||||
{
|
||||
#if USE_JIT
|
||||
// Block was compiled
|
||||
SPCFLAGS_CLEAR( SPCFLAG_JIT_END_COMPILE );
|
||||
|
||||
// Retain the request to get out of compiled code until
|
||||
// we reached the toplevel execution, i.e. the one that
|
||||
// can compile then run compiled code. This also means
|
||||
// we processed all (nested) EmulOps
|
||||
if ((m68k_execute_depth == 0) && SPCFLAGS_TEST( SPCFLAG_JIT_EXEC_RETURN ))
|
||||
SPCFLAGS_CLEAR( SPCFLAG_JIT_EXEC_RETURN );
|
||||
#endif
|
||||
|
||||
if (SPCFLAGS_TEST( SPCFLAG_DOTRACE )) {
|
||||
Exception (9,last_trace_ad);
|
||||
}
|
||||
@ -1289,7 +1318,7 @@ void m68k_do_execute (void)
|
||||
for (;;) {
|
||||
uae_u32 opcode = GET_OPCODE;
|
||||
#if FLIGHT_RECORDER
|
||||
record_step(m68k_getpc());
|
||||
m68k_record_step(m68k_getpc());
|
||||
#endif
|
||||
#ifdef X86_ASSEMBLY
|
||||
__asm__ __volatile__("\tpushl %%ebp\n\tcall *%%ebx\n\tpopl %%ebp" /* FIXME */
|
||||
@ -1305,8 +1334,32 @@ void m68k_do_execute (void)
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_JIT
|
||||
void m68k_compile_execute (void)
|
||||
{
|
||||
for (;;) {
|
||||
if (quit_program > 0) {
|
||||
if (quit_program == 1)
|
||||
break;
|
||||
quit_program = 0;
|
||||
m68k_reset ();
|
||||
}
|
||||
m68k_do_compile_execute();
|
||||
}
|
||||
if (debugging) {
|
||||
uaecptr nextpc;
|
||||
m68k_dumpstate(&nextpc);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void m68k_execute (void)
|
||||
{
|
||||
#if USE_JIT
|
||||
++m68k_execute_depth;
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
if (quit_program > 0) {
|
||||
if (quit_program == 1)
|
||||
@ -1321,6 +1374,10 @@ void m68k_execute (void)
|
||||
m68k_dumpstate(&nextpc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#if USE_JIT
|
||||
--m68k_execute_depth;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void m68k_verify (uaecptr addr, uaecptr *nextpc)
|
||||
|
@ -9,6 +9,10 @@
|
||||
#ifndef NEWCPU_H
|
||||
#define NEWCPU_H
|
||||
|
||||
#ifndef FLIGHT_RECORDER
|
||||
#define FLIGHT_RECORDER 0
|
||||
#endif
|
||||
|
||||
#include "m68k.h"
|
||||
#include "readcpu.h"
|
||||
#include "spcflags.h"
|
||||
@ -26,8 +30,8 @@ extern int broken_in;
|
||||
#define CFLOW_NORMAL 0
|
||||
#define CFLOW_BRANCH 1
|
||||
#define CFLOW_JUMP 2
|
||||
#define CFLOW_TRAP CFLOW_JUMP
|
||||
#define CFLOW_RETURN 3
|
||||
#define CFLOW_TRAP 4
|
||||
#define CFLOW_SPCFLAGS 32 /* some spcflags are set */
|
||||
#define CFLOW_EXEC_RETURN 64 /* must exit from the execution loop */
|
||||
|
||||
@ -55,6 +59,18 @@ struct cputbl {
|
||||
uae_u16 opcode;
|
||||
};
|
||||
|
||||
extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl");
|
||||
|
||||
#if USE_JIT
|
||||
typedef void compop_func (uae_u32) REGPARAM;
|
||||
|
||||
struct comptbl {
|
||||
compop_func *handler;
|
||||
uae_u32 specific;
|
||||
uae_u32 opcode;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern cpuop_rettype REGPARAM2 op_illg (uae_u32) REGPARAM;
|
||||
|
||||
typedef char flagtype;
|
||||
@ -277,7 +293,14 @@ extern struct cputbl op_smalltbl_3_ff[];
|
||||
/* 68000 slow but compatible. */
|
||||
extern struct cputbl op_smalltbl_4_ff[];
|
||||
|
||||
#if FLIGHT_RECORDER
|
||||
extern void m68k_record_step(uaecptr);
|
||||
#endif
|
||||
extern void m68k_do_execute(void);
|
||||
extern void m68k_execute(void);
|
||||
#if USE_JIT
|
||||
extern void m68k_do_compile_execute(void);
|
||||
extern void m68k_compile_execute(void);
|
||||
#endif
|
||||
|
||||
#endif /* NEWCPU_H */
|
||||
|
@ -18,8 +18,14 @@ enum {
|
||||
SPCFLAG_TRACE = 0x08,
|
||||
SPCFLAG_DOTRACE = 0x10,
|
||||
SPCFLAG_DOINT = 0x20,
|
||||
#if USE_JIT
|
||||
SPCFLAG_JIT_END_COMPILE = 0x40,
|
||||
SPCFLAG_JIT_EXEC_RETURN = 0x80,
|
||||
#else
|
||||
SPCFLAG_JIT_END_COMPILE = 0,
|
||||
SPCFLAG_JIT_EXEC_RETURN = 0,
|
||||
#endif
|
||||
|
||||
SPCFLAG_ALL = SPCFLAG_STOP
|
||||
| SPCFLAG_INT
|
||||
| SPCFLAG_BRK
|
||||
@ -27,7 +33,9 @@ enum {
|
||||
| SPCFLAG_DOTRACE
|
||||
| SPCFLAG_DOINT
|
||||
| SPCFLAG_JIT_END_COMPILE
|
||||
| SPCFLAG_JIT_EXEC_RETURN,
|
||||
| SPCFLAG_JIT_EXEC_RETURN
|
||||
,
|
||||
|
||||
SPCFLAG_ALL_BUT_EXEC_RETURN = SPCFLAG_ALL & ~SPCFLAG_JIT_EXEC_RETURN
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user