Skip to content

Commit

Permalink
FPU update as latest MAME
Browse files Browse the repository at this point in the history
  • Loading branch information
shanshe committed Apr 13, 2021
1 parent 073c27d commit 6c9276f
Show file tree
Hide file tree
Showing 9 changed files with 1,955 additions and 220 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MAINFILES = emulator.c \
platforms/amiga/net/pi-net.c \
platforms/shared/rtc.c

MUSASHIFILES = m68kcpu.c m68kdasm.c softfloat/softfloat.c
MUSASHIFILES = m68kcpu.c m68kdasm.c softfloat/softfloat.c softfloat/fsincos.c softfloat/fyl2x.c
MUSASHIGENCFILES = m68kops.c
MUSASHIGENHFILES = m68kops.h
MUSASHIGENERATOR = m68kmake
Expand Down
17 changes: 15 additions & 2 deletions m68k_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ M68KMAKE_OPCODE_HANDLER_HEADER
extern void m68040_fpu_op0(void);
extern void m68040_fpu_op1(void);
extern void m68881_mmu_ops();
extern void m68881_ftrap();

/* ======================================================================== */
/* ========================= INSTRUCTION HANDLERS ========================= */
Expand Down Expand Up @@ -561,6 +562,7 @@ cpdbcc 32 . . 1111...001001... .......... . . U U . . . 4
cpgen 32 . . 1111...000...... .......... . . U U . . . 4 4 . unemulated
cpscc 32 . . 1111...001...... .......... . . U U . . . 4 4 . unemulated
cptrapcc 32 . . 1111...001111... .......... . . U U . . . 4 4 . unemulated
ftrapcc 32 . . 1111001001111... .......... . . U U . . . 4 4 .
dbt 16 . . 0101000011001... .......... U U U U U 12 12 6 6 6
dbf 16 . . 0101000111001... .......... U U U U U 12 12 6 6 6
dbcc 16 . . 0101....11001... .......... U U U U U 12 12 6 6 6
Expand Down Expand Up @@ -915,7 +917,8 @@ M68KMAKE_OP(1111, 0, ., .)

M68KMAKE_OP(040fpu0, 32, ., .)
{
if(CPU_TYPE_IS_030_PLUS(CPU_TYPE))
// printf("FPU 040fpu0 HAS_FPU=%d\n",!!HAS_FPU);
if(HAS_FPU)
{
m68040_fpu_op0();
return;
Expand All @@ -926,7 +929,8 @@ M68KMAKE_OP(040fpu0, 32, ., .)

M68KMAKE_OP(040fpu1, 32, ., .)
{
if(CPU_TYPE_IS_030_PLUS(CPU_TYPE))
// printf("FPU 040fpu1 HAS_FPU=%d\n",!!HAS_FPU);
if(HAS_FPU)
{
m68040_fpu_op1();
return;
Expand Down Expand Up @@ -4370,6 +4374,15 @@ M68KMAKE_OP(cptrapcc, 32, ., .)
m68ki_exception_1111();
}

M68KMAKE_OP(ftrapcc,32, ., .)
{
if(HAS_FPU)
{
m68881_ftrap();
} else {
m68ki_exception_1111();
}
}

M68KMAKE_OP(dbt, 16, ., .)
{
Expand Down
28 changes: 19 additions & 9 deletions m68kcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 3;
CYC_SHIFT = 1;
CYC_RESET = 132;
HAS_PMMU = 0;
HAS_PMMU = 0;
HAS_FPU = 0;
return;
case M68K_CPU_TYPE_SCC68070:
m68k_set_cpu_type(M68K_CPU_TYPE_68010);
Expand All @@ -816,7 +817,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 3;
CYC_SHIFT = 1;
CYC_RESET = 130;
HAS_PMMU = 0;
HAS_PMMU = 0;
HAS_FPU = 0;
return;
case M68K_CPU_TYPE_68EC020:
CPU_TYPE = CPU_TYPE_EC020;
Expand All @@ -833,7 +835,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 2;
CYC_SHIFT = 0;
CYC_RESET = 518;
HAS_PMMU = 0;
HAS_PMMU = 0;
HAS_FPU = 0;
return;
case M68K_CPU_TYPE_68020:
CPU_TYPE = CPU_TYPE_020;
Expand All @@ -850,7 +853,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 2;
CYC_SHIFT = 0;
CYC_RESET = 518;
HAS_PMMU = 0;
HAS_PMMU = 0;
HAS_FPU = 0;
return;
case M68K_CPU_TYPE_68030:
CPU_TYPE = CPU_TYPE_030;
Expand All @@ -867,7 +871,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 2;
CYC_SHIFT = 0;
CYC_RESET = 518;
HAS_PMMU = 1;
HAS_PMMU = 1;
HAS_FPU = 1;
return;
case M68K_CPU_TYPE_68EC030:
CPU_TYPE = CPU_TYPE_EC030;
Expand All @@ -884,7 +889,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 2;
CYC_SHIFT = 0;
CYC_RESET = 518;
HAS_PMMU = 0; /* EC030 lacks the PMMU and is effectively a die-shrink 68020 */
HAS_PMMU = 0; /* EC030 lacks the PMMU and is effectively a die-shrink 68020 */
HAS_FPU = 1;
return;
case M68K_CPU_TYPE_68040: // TODO: these values are not correct
CPU_TYPE = CPU_TYPE_040;
Expand All @@ -901,7 +907,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 2;
CYC_SHIFT = 0;
CYC_RESET = 518;
HAS_PMMU = 1;
HAS_PMMU = 1;
HAS_FPU = 1;
return;
case M68K_CPU_TYPE_68EC040: // Just a 68040 without pmmu apparently...
CPU_TYPE = CPU_TYPE_EC040;
Expand All @@ -918,10 +925,12 @@ void m68k_set_cpu_type(unsigned int cpu_type)
CYC_MOVEM_L = 2;
CYC_SHIFT = 0;
CYC_RESET = 518;
HAS_PMMU = 0;
HAS_PMMU = 0;
HAS_FPU = 0;
return;
case M68K_CPU_TYPE_68LC040:
CPU_TYPE = CPU_TYPE_LC040;
CPU_ADDRESS_MASK = 0xffffffff;
m68ki_cpu.sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */
m68ki_cpu.cyc_instruction = m68ki_cycles[4];
m68ki_cpu.cyc_exception = m68ki_exception_cycle_table[4];
Expand All @@ -934,7 +943,8 @@ void m68k_set_cpu_type(unsigned int cpu_type)
m68ki_cpu.cyc_movem_l = 2;
m68ki_cpu.cyc_shift = 0;
m68ki_cpu.cyc_reset = 518;
HAS_PMMU = 1;
HAS_PMMU = 1;
HAS_FPU = 0;
return;
}
}
Expand Down
10 changes: 6 additions & 4 deletions m68kcpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,10 @@ typedef uint32 uint64;
#define CYC_MOVEM_L m68ki_cpu.cyc_movem_l
#define CYC_SHIFT m68ki_cpu.cyc_shift
#define CYC_RESET m68ki_cpu.cyc_reset
#define HAS_PMMU m68ki_cpu.has_pmmu
#define PMMU_ENABLED m68ki_cpu.pmmu_enabled
#define RESET_CYCLES m68ki_cpu.reset_cycles
#define HAS_PMMU m68ki_cpu.has_pmmu
#define HAS_FPU m68ki_cpu.has_fpu
#define PMMU_ENABLED m68ki_cpu.pmmu_enabled
#define RESET_CYCLES m68ki_cpu.reset_cycles


#define CALLBACK_INT_ACK m68ki_cpu.int_ack_callback
Expand Down Expand Up @@ -960,7 +961,8 @@ typedef struct
uint sr_mask; /* Implemented status register bits */
uint instr_mode; /* Stores whether we are in instruction mode or group 0/1 exception mode */
uint run_mode; /* Stores whether we are processing a reset, bus error, address error, or something else */
int has_pmmu; /* Indicates if a PMMU available (yes on 030, 040, no on EC030) */
int has_pmmu; /* Indicates if a PMMU available (yes on 030, 040, no on EC030) */
int has_fpu; /* Indicates if a FPU available */
int pmmu_enabled; /* Indicates if the PMMU is enabled */
int fpu_just_reset; /* Indicates the FPU was just reset */
uint reset_cycles;
Expand Down
Loading

0 comments on commit 6c9276f

Please sign in to comment.