diff options
author | yz70s <yz70s@users.noreply.github.com> | 2020-01-10 20:41:04 +0100 |
---|---|---|
committer | yz70s <yz70s@users.noreply.github.com> | 2020-01-10 21:23:44 +0100 |
commit | 8f3f144166c0ea9531df71137afc5a27b0841378 (patch) | |
tree | 154aa6965ff581e98ab892c9a939cf2a6583cb43 | |
parent | dc59d3cb3fb788347b223d1e2cfc913bdc02c8a1 (diff) |
naomi: add a new device for the 315-6154 system manager chip used in the dimm board [Samuele Zannoli]
It is still incomplete but can be used.
-rw-r--r-- | scripts/target/mame/arcade.lua | 2 | ||||
-rw-r--r-- | scripts/target/mame/mess.lua | 2 | ||||
-rw-r--r-- | src/mame/machine/315-6154.cpp | 124 | ||||
-rw-r--r-- | src/mame/machine/315-6154.h | 46 | ||||
-rw-r--r-- | src/mame/machine/naomigd.cpp | 43 | ||||
-rw-r--r-- | src/mame/machine/naomigd.h | 4 |
6 files changed, 208 insertions, 13 deletions
diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index ba359a63a16..f536c2db331 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -3407,6 +3407,8 @@ files { MAME_DIR .. "src/mame/machine/m3comm.h", MAME_DIR .. "src/mame/machine/315-5881_crypt.cpp", MAME_DIR .. "src/mame/machine/315-5881_crypt.h", + MAME_DIR .. "src/mame/machine/315-6154.cpp", + MAME_DIR .. "src/mame/machine/315-6154.h", MAME_DIR .. "src/mame/machine/awboard.cpp", MAME_DIR .. "src/mame/machine/awboard.h", MAME_DIR .. "src/mame/machine/mie.cpp", diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 856b820ceed..3f04f87a7d8 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -1445,6 +1445,8 @@ files { MAME_DIR .. "src/mame/machine/naomirom.h", MAME_DIR .. "src/mame/machine/315-5881_crypt.cpp", MAME_DIR .. "src/mame/machine/315-5881_crypt.h", + MAME_DIR .. "src/mame/machine/315-6154.cpp", + MAME_DIR .. "src/mame/machine/315-6154.h", MAME_DIR .. "src/mame/video/powervr2.cpp", MAME_DIR .. "src/mame/video/powervr2.h", MAME_DIR .. "src/mame/drivers/neogeo.cpp", diff --git a/src/mame/machine/315-6154.cpp b/src/mame/machine/315-6154.cpp new file mode 100644 index 00000000000..a086c4a009f --- /dev/null +++ b/src/mame/machine/315-6154.cpp @@ -0,0 +1,124 @@ +// license:BSD-3-Clause +// copyright-holders:Samuele Zannoli + +#include "emu.h" +#include "machine/315-6154.h" + +DEFINE_DEVICE_TYPE(SEGA315_6154, sega_315_6154_device, "sega315_6154", "Sega 315-6154 Northbridge") + +sega_315_6154_device::sega_315_6154_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, SEGA315_6154, tag, owner, clock), + device_memory_interface(mconfig, *this), + m_memory_config("memory", ENDIANNESS_LITTLE, 32, 32), + m_configuration_config("configuration", ENDIANNESS_LITTLE, 32, 32) +{ + memset(m_registers, 0, sizeof(m_registers)); + memset(m_bases, 0, sizeof(m_bases)); + m_useconfig_14x = false; + m_useconfig_18x = false; +} + +void sega_315_6154_device::device_start() +{ + m_memory = &space(AS_PCI_MEMORY); + m_configuration = &space(AS_PCI_CONFIGURATION); + + save_item(NAME(m_registers)); + save_item(NAME(m_bases)); + save_item(NAME(m_useconfig_14x)); + save_item(NAME(m_useconfig_18x)); +} + +void sega_315_6154_device::device_reset() +{ + memset(m_registers, 0, sizeof(m_registers)); +} + +device_memory_interface::space_config_vector sega_315_6154_device::memory_space_config() const +{ + return space_config_vector{ + std::make_pair(AS_PCI_MEMORY, &m_memory_config), + std::make_pair(AS_PCI_CONFIGURATION, &m_configuration_config) + }; +} + +READ32_MEMBER(sega_315_6154_device::registers_r) +{ + return m_registers[offset]; +} + +static inline void parse_address_register(u32 reg, u32 *base) +{ + base[0] = (reg & 0xff) << 24; + reg = reg >> 8; + base[1] = (reg & 0xff) << 24; + reg = reg >> 8; + base[2] = (reg & 0xff) << 24; + reg = reg >> 8; + base[3] = reg << 24; +} + +WRITE32_MEMBER(sega_315_6154_device::registers_w) +{ + COMBINE_DATA(m_registers + offset); + + if (offset == 0x10 / 4) + parse_address_register(m_registers[0x10 / 4], m_bases); + else if (offset == 0x14 / 4) + parse_address_register(m_registers[0x14 / 4], m_bases + 4); + else if (offset == 0x18 / 4) + parse_address_register(m_registers[0x18 / 4], m_bases + 8); + else if (offset == 0x1c / 4) + { + m_useconfig_14x = (m_registers[0x1c / 4] & 1) != 0; + m_useconfig_18x = (m_registers[0x1c / 4] & 2) != 0; + } + else if (offset == 0x38 / 4) + { + if (m_registers[0x38 / 4] & 0x01000000) + logerror("got dma transfer request from 0x%08x to 0x%08x size 0x%08x bytes\n", m_registers[0x30 / 4], m_registers[0x34 / 4], (m_registers[0x38 / 4] & 0xffffff) << 2); + m_registers[0x38 / 4] &= ~0x01000000; + } +} + +template<int Aperture> +u32 sega_315_6154_device::aperture_r(address_space &space, offs_t offset, u32 mem_mask) +{ + const u32 destination_offset = offset & 0x3fffff; + const int destination = (offset >> 22) & 3; + const int index = Aperture * 4 + destination; + + if ((Aperture == 0) && (destination == 0) && (m_useconfig_14x == true)) + return m_configuration->read_dword(destination_offset << 2, mem_mask); + if ((Aperture == 1) && (destination == 0) && (m_useconfig_18x == true)) + return m_configuration->read_dword(destination_offset << 2, mem_mask); + return m_memory->read_dword(m_bases[index] + (destination_offset << 2), mem_mask); +} + +template u32 sega_315_6154_device::aperture_r<0>(address_space &space, offs_t offset, u32 mem_mask); +template u32 sega_315_6154_device::aperture_r<1>(address_space &space, offs_t offset, u32 mem_mask); +template u32 sega_315_6154_device::aperture_r<2>(address_space &space, offs_t offset, u32 mem_mask); + +template<int Aperture> +void sega_315_6154_device::aperture_w(address_space &space, offs_t offset, u32 data, u32 mem_mask) +{ + const u32 destination_offset = offset & 0x3fffff; + const int destination = (offset >> 22) & 3; + const int index = Aperture * 4 + destination; + + if ((Aperture == 0) && (destination == 0) && (m_useconfig_14x == true)) + { + m_configuration->write_dword(destination_offset << 2, data, mem_mask); + return; + } + if ((Aperture == 1) && (destination == 0) && (m_useconfig_18x == true)) + { + m_configuration->write_dword(destination_offset << 2, data, mem_mask); + return; + } + m_memory->write_dword(m_bases[index] + (destination_offset << 2), data, mem_mask); +} + +template void sega_315_6154_device::aperture_w<0>(address_space &space, offs_t offset, u32 data, u32 mem_mask); +template void sega_315_6154_device::aperture_w<1>(address_space &space, offs_t offset, u32 data, u32 mem_mask); +template void sega_315_6154_device::aperture_w<2>(address_space &space, offs_t offset, u32 data, u32 mem_mask); diff --git a/src/mame/machine/315-6154.h b/src/mame/machine/315-6154.h new file mode 100644 index 00000000000..c35547f150e --- /dev/null +++ b/src/mame/machine/315-6154.h @@ -0,0 +1,46 @@ +// license:BSD-3-Clause +// copyright-holders:Samuele Zannoli +#ifndef MAME_MACHINE_315_6154_H +#define MAME_MACHINE_315_6154_H + +#pragma once + +DECLARE_DEVICE_TYPE(SEGA315_6154, sega_315_6154_device) + +class sega_315_6154_device : public device_t, public device_memory_interface +{ +public: + // construction/destruction + sega_315_6154_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + DECLARE_READ32_MEMBER(registers_r); + DECLARE_WRITE32_MEMBER(registers_w); + template<int Aperture> + u32 aperture_r(address_space &space, offs_t offset, u32 mem_mask = 0xffffffff); + template<int Aperture> + void aperture_w(address_space &space, offs_t offset, u32 data, u32 mem_mask = 0xffffffff); + + static const int AS_PCI_MEMORY = 0; + static const int AS_PCI_CONFIGURATION = 1; + +protected: + virtual void device_start() override; + virtual void device_reset() override; + + // device_memory_interface overrides + virtual space_config_vector memory_space_config() const override; + +private: + address_space_config m_memory_config; + address_space_config m_configuration_config; + address_space *m_memory; + address_space *m_configuration; + + u32 m_registers[0x100 / 4]; + u32 m_bases[4 * 3]; + bool m_useconfig_14x; + bool m_useconfig_18x; + +}; + +#endif // MAME_MACHINE_315_6154_H diff --git a/src/mame/machine/naomigd.cpp b/src/mame/machine/naomigd.cpp index 4de880b3548..0a26306a10a 100644 --- a/src/mame/machine/naomigd.cpp +++ b/src/mame/machine/naomigd.cpp @@ -408,6 +408,7 @@ naomi_gdrom_board::naomi_gdrom_board(const machine_config &mconfig, const char * m_i2c0(*this, "i2c_0"), m_i2c1(*this, "i2c_1"), m_eeprom(*this, "eeprom"), + m_315_6154(*this, "northbridge"), picdata(*this, finder_base::DUMMY_TAG), dimm_command(0xffff), dimm_offsetl(0xffff), @@ -439,19 +440,11 @@ void naomi_gdrom_board::submap(address_map &map) void naomi_gdrom_board::sh4_map(address_map &map) { map(0x00000000, 0x001fffff).mirror(0xa0000000).rom().region("bios", 0); - map(0x04000000, 0x040000ff).rw(FUNC(naomi_gdrom_board::memorymanager_r), FUNC(naomi_gdrom_board::memorymanager_w)); - map(0x0c000000, 0x0cffffff).ram(); - map(0x10000000, 0x103fffff).ram(); - map(0x14000000, 0x14000003).rw(FUNC(naomi_gdrom_board::sh4_unknown_r), FUNC(naomi_gdrom_board::sh4_unknown_w)); - map(0x14000014, 0x14000017).rw(FUNC(naomi_gdrom_board::sh4_command_r), FUNC(naomi_gdrom_board::sh4_command_w)); - map(0x14000018, 0x1400001b).rw(FUNC(naomi_gdrom_board::sh4_offsetl_r), FUNC(naomi_gdrom_board::sh4_offsetl_w)); - map(0x1400001c, 0x1400001f).rw(FUNC(naomi_gdrom_board::sh4_parameterl_r), FUNC(naomi_gdrom_board::sh4_parameterl_w)); - map(0x14000020, 0x14000023).rw(FUNC(naomi_gdrom_board::sh4_parameterh_r), FUNC(naomi_gdrom_board::sh4_parameterh_w)); - map(0x14000024, 0x14000027).rw(FUNC(naomi_gdrom_board::sh4_status_r), FUNC(naomi_gdrom_board::sh4_status_w)); - map(0x1400002c, 0x1400002f).lr32([]() { return 0x0c; }, "Constant 0x0c"); // 0x0a or 0x0e possible too - map(0x14000030, 0x14000033).rw(FUNC(naomi_gdrom_board::sh4_des_keyl_r), FUNC(naomi_gdrom_board::sh4_des_keyl_w)); - map(0x14000034, 0x14000037).rw(FUNC(naomi_gdrom_board::sh4_des_keyh_r), FUNC(naomi_gdrom_board::sh4_des_keyh_w)); - map(0x18001000, 0x18001007).lr32([]() { return 0x189d11db; }, "Constant 0x189d11db"); // 0x10001022 or 0x11720001 possible too + map(0x04000000, 0x040000ff).rw(m_315_6154, FUNC(sega_315_6154_device::registers_r), FUNC(sega_315_6154_device::registers_w)); + map(0x0c000000, 0x0cffffff).ram().share("sh4sdram"); + map(0x10000000, 0x103fffff).ram().share("6154sdram"); + map(0x14000000, 0x17ffffff).rw(m_315_6154, FUNC(sega_315_6154_device::aperture_r<0>), FUNC(sega_315_6154_device::aperture_w<0>)); + map(0x18000000, 0x1bffffff).rw(m_315_6154, FUNC(sega_315_6154_device::aperture_r<1>), FUNC(sega_315_6154_device::aperture_w<1>)); map.unmap_value_high(); } @@ -460,6 +453,27 @@ void naomi_gdrom_board::sh4_io_map(address_map &map) map(0x00, 0x0f).rw(FUNC(naomi_gdrom_board::i2cmem_dimm_r), FUNC(naomi_gdrom_board::i2cmem_dimm_w)); } +void naomi_gdrom_board::pci_map(address_map& map) +{ + map(0x00000000, 0x00000003).rw(FUNC(naomi_gdrom_board::sh4_unknown_r), FUNC(naomi_gdrom_board::sh4_unknown_w)); + map(0x00000014, 0x00000017).rw(FUNC(naomi_gdrom_board::sh4_command_r), FUNC(naomi_gdrom_board::sh4_command_w)); + map(0x00000018, 0x0000001b).rw(FUNC(naomi_gdrom_board::sh4_offsetl_r), FUNC(naomi_gdrom_board::sh4_offsetl_w)); + map(0x0000001c, 0x0000001f).rw(FUNC(naomi_gdrom_board::sh4_parameterl_r), FUNC(naomi_gdrom_board::sh4_parameterl_w)); + map(0x00000020, 0x00000023).rw(FUNC(naomi_gdrom_board::sh4_parameterh_r), FUNC(naomi_gdrom_board::sh4_parameterh_w)); + map(0x00000024, 0x00000027).rw(FUNC(naomi_gdrom_board::sh4_status_r), FUNC(naomi_gdrom_board::sh4_status_w)); + map(0x0000002c, 0x0000002f).lr32([]() { return 0x0c; }, "Constant 0x0c"); // 0x0a or 0x0e possible too + map(0x00000030, 0x00000033).rw(FUNC(naomi_gdrom_board::sh4_des_keyl_r), FUNC(naomi_gdrom_board::sh4_des_keyl_w)); + map(0x00000034, 0x00000037).rw(FUNC(naomi_gdrom_board::sh4_des_keyh_r), FUNC(naomi_gdrom_board::sh4_des_keyh_w)); + map(0x10000000, 0x10000003).ram(); // temporary for testing + map(0x70000000, 0x70ffffff).ram().share("sh4sdram"); + map(0x78000000, 0x783fffff).ram().share("6154sdram"); +} + +void naomi_gdrom_board::pci_config_map(address_map& map) +{ + map(0x1000, 0x1003).lr32([]() { return 0x189d11db; }, "Constant 0x189d11db"); // 0x10001022 or 0x11720001 possible too +} + WRITE32_MEMBER(naomi_gdrom_board::memorymanager_w) { memctl_regs[offset] = data; @@ -997,6 +1011,9 @@ void naomi_gdrom_board::device_add_mconfig(machine_config &config) m_maincpu->set_sh4_clock(CPU_CLOCK); m_maincpu->set_addrmap(AS_PROGRAM, &naomi_gdrom_board::sh4_map); m_maincpu->set_addrmap(AS_IO, &naomi_gdrom_board::sh4_io_map); + SEGA315_6154(config, m_315_6154, 0); + m_315_6154->set_addrmap(sega_315_6154_device::AS_PCI_MEMORY, &naomi_gdrom_board::pci_map); + m_315_6154->set_addrmap(sega_315_6154_device::AS_PCI_CONFIGURATION, &naomi_gdrom_board::pci_config_map); PIC16C622(config, m_securitycpu, PIC_CLOCK); m_securitycpu->set_addrmap(AS_IO, &naomi_gdrom_board::pic_map); I2C_24C01(config, m_i2c0, 0); diff --git a/src/mame/machine/naomigd.h b/src/mame/machine/naomigd.h index 8ba2b20e2bf..8ab1a6b85fe 100644 --- a/src/mame/machine/naomigd.h +++ b/src/mame/machine/naomigd.h @@ -9,6 +9,7 @@ #include "cpu/pic16c62x/pic16c62x.h" #include "machine/i2cmem.h" #include "machine/eepromser.h" +#include "machine/315-6154.h" class naomi_gdrom_board : public naomi_board { @@ -37,6 +38,8 @@ public: void sh4_map(address_map &map); void sh4_io_map(address_map &map); void pic_map(address_map &map); + void pci_map(address_map &map); + void pci_config_map(address_map &map); void set_image_tag(const char *_image_tag) { @@ -100,6 +103,7 @@ private: required_device<i2cmem_device> m_i2c0; required_device<i2cmem_device> m_i2c1; required_device<eeprom_serial_93cxx_device> m_eeprom; + required_device<sega_315_6154_device> m_315_6154; const char *image_tag; optional_region_ptr<uint8_t> picdata; |