From 15b7c421ddb08a3870dfb4bc7677523b58be6bd4 Mon Sep 17 00:00:00 2001 From: arbee Date: Sat, 26 Oct 2024 16:07:57 -0400 Subject: cpu/m68000: Stub out the Coprocesor Interface Registers found on '010-'030 so that Mac ROMs can detect if an FPU is present. [R. Belmont] --- src/devices/cpu/m68000/m68kcpu.h | 48 ++++++++++++++++++++++++++++++++++++ src/devices/cpu/m68000/m68kfpu.cpp | 41 ++++++++++++++++++++++++++++++ src/devices/cpu/m68000/m68kmusashi.h | 2 ++ 3 files changed, 91 insertions(+) diff --git a/src/devices/cpu/m68000/m68kcpu.h b/src/devices/cpu/m68000/m68kcpu.h index aebe498f899..620fe5dae96 100644 --- a/src/devices/cpu/m68000/m68kcpu.h +++ b/src/devices/cpu/m68000/m68kcpu.h @@ -656,6 +656,16 @@ inline u32 m68ki_read_8_fc(u32 address, u32 fc) m_mmu_tmp_fc = fc; m_mmu_tmp_rw = 1; m_mmu_tmp_sz = M68K_SZ_BYTE; + // Check for reading the FPU's CIRs if this is an '020 or '030. + // In CPU space (FC 7), addresses 0x0002xxxx are coprocessor interface registers. + // Bits 15-13 are the coprocessor ID, and bits 0-4 are the register select. + if ((fc == 7) && CPU_TYPE_IS_020_PLUS() && !CPU_TYPE_IS_040_PLUS()) + { + if ((address & 0xffffeff0) == 0x00022000) + { + return m6888x_read_cir(address); + } + } return m_read8(address); } inline u32 m68ki_read_16_fc(u32 address, u32 fc) @@ -667,6 +677,13 @@ inline u32 m68ki_read_16_fc(u32 address, u32 fc) m_mmu_tmp_fc = fc; m_mmu_tmp_rw = 1; m_mmu_tmp_sz = M68K_SZ_WORD; + if ((fc == 7) && CPU_TYPE_IS_020_PLUS() && !CPU_TYPE_IS_040_PLUS()) + { + if ((address & 0xffffeff0) == 0x00022000) + { + return m6888x_read_cir(address); + } + } return m_read16(address); } inline u32 m68ki_read_32_fc(u32 address, u32 fc) @@ -678,6 +695,13 @@ inline u32 m68ki_read_32_fc(u32 address, u32 fc) m_mmu_tmp_fc = fc; m_mmu_tmp_rw = 1; m_mmu_tmp_sz = M68K_SZ_LONG; + if ((fc == 7) && CPU_TYPE_IS_020_PLUS() && !CPU_TYPE_IS_040_PLUS()) + { + if ((address & 0xffffeff0) == 0x00022000) + { + return m6888x_read_cir(address); + } + } return m_read32(address); } @@ -686,6 +710,14 @@ inline void m68ki_write_8_fc(u32 address, u32 fc, u32 value) m_mmu_tmp_fc = fc; m_mmu_tmp_rw = 0; m_mmu_tmp_sz = M68K_SZ_BYTE; + if ((fc == 7) && CPU_TYPE_IS_020_PLUS() && !CPU_TYPE_IS_040_PLUS()) + { + if ((address & 0xffffeff0) == 0x00022000) + { + m6888x_write_cir(address, value); + return; + } + } m_write8(address, value); } inline void m68ki_write_16_fc(u32 address, u32 fc, u32 value) @@ -697,6 +729,14 @@ inline void m68ki_write_16_fc(u32 address, u32 fc, u32 value) m_mmu_tmp_fc = fc; m_mmu_tmp_rw = 0; m_mmu_tmp_sz = M68K_SZ_WORD; + if ((fc == 7) && CPU_TYPE_IS_020_PLUS() && !CPU_TYPE_IS_040_PLUS()) + { + if ((address & 0xffffeff0) == 0x00022000) + { + m6888x_write_cir(address, value); + return; + } + } m_write16(address, value); } inline void m68ki_write_32_fc(u32 address, u32 fc, u32 value) @@ -708,6 +748,14 @@ inline void m68ki_write_32_fc(u32 address, u32 fc, u32 value) m_mmu_tmp_fc = fc; m_mmu_tmp_rw = 0; m_mmu_tmp_sz = M68K_SZ_LONG; + if ((fc == 7) && CPU_TYPE_IS_020_PLUS() && !CPU_TYPE_IS_040_PLUS()) + { + if ((address & 0xffffeff0) == 0x00022000) + { + m6888x_write_cir(address, value); + return; + } + } m_write32(address, value); } diff --git a/src/devices/cpu/m68000/m68kfpu.cpp b/src/devices/cpu/m68000/m68kfpu.cpp index 218e383a8fa..dda4c0fb4b6 100644 --- a/src/devices/cpu/m68000/m68kfpu.cpp +++ b/src/devices/cpu/m68000/m68kfpu.cpp @@ -2548,3 +2548,44 @@ void m68000_musashi_device::m68881_ftrap() } } } + +// Read the FPU's Coprocessor Interface Registers (CIRs). +// References: MC68881/68882 Coprocessor User's Manual 1st Edition, +// pages 7-1 to 7-8 and M68030 User's Manual 3rd Edition page 7-69. +u32 m68000_musashi_device::m6888x_read_cir(offs_t offset) +{ + // If no FPU is present, reading any CIRs causes a bus error. + // Pre-1992 Macintosh ROMs use this method to detect the presence + // of an FPU. 1992 and later ROMs just execute FNOP and check for + // an F-line trap, because this mechanism does not exist on the 68040. + if (!m_has_fpu) + { + m68k_cause_bus_error(); + } + + // TODO: actually try to return meaningful values? + // offset function + // 0x00 Response read-only 16 bit (value in D31-D16) + // 0x02 Control write-only 16 + // 0x04 Save read 16 + // 0x06 Restore read/write 16 + // 0x08 Operation Word read/write 16 + // 0x0a Command write-only 16 + // 0x0c (reserved) N/A 16 + // 0x0e Condition write-only 16 + // 0x10 Operand read/write 32 bit + // 0x14 Register Select read-only 16 + // 0x18 Instruction Address write-only 32 + // 0x1c Operand Address read/write 32 + return 0; +} + +void m68000_musashi_device::m6888x_write_cir(offs_t offset, u32 data) +{ + if (!m_has_fpu) + { + m68k_cause_bus_error(); + } + + // TODO: actually do something with these values? +} diff --git a/src/devices/cpu/m68000/m68kmusashi.h b/src/devices/cpu/m68000/m68kmusashi.h index 9ab05c39161..9ec2bea312e 100644 --- a/src/devices/cpu/m68000/m68kmusashi.h +++ b/src/devices/cpu/m68000/m68kmusashi.h @@ -378,6 +378,8 @@ protected: void m68040_do_frestore(u32 addr, int reg); void m68040_fpu_op1(); void m68881_ftrap(); + u32 m6888x_read_cir(offs_t offset); + void m6888x_write_cir(offs_t offset, u32 data); }; #endif // MAME_CPU_M68000_M68KMUSASHI_H -- cgit v1.2.3