From d9d7c9d17aaaa207b475c2968f297ec832360f7e Mon Sep 17 00:00:00 2001 From: AJR Date: Wed, 23 Jan 2019 00:24:44 -0500 Subject: machine/idectrl: Another use for required_address_space (nw) --- src/devices/machine/idectrl.cpp | 13 ++----------- src/devices/machine/idectrl.h | 6 ++---- src/mame/machine/xbox_pci.cpp | 2 +- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/devices/machine/idectrl.cpp b/src/devices/machine/idectrl.cpp index b8ab541fc8d..45f6ab6f703 100644 --- a/src/devices/machine/idectrl.cpp +++ b/src/devices/machine/idectrl.cpp @@ -222,6 +222,7 @@ DEFINE_DEVICE_TYPE(BUS_MASTER_IDE_CONTROLLER, bus_master_ide_controller_device, bus_master_ide_controller_device::bus_master_ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : ide_controller_32_device(mconfig, BUS_MASTER_IDE_CONTROLLER, tag, owner, clock), + m_dma_space(*this, finder_base::DUMMY_TAG, -1, 32), m_dma_address(0), m_dma_bytes_left(0), m_dma_descriptor(0), @@ -239,17 +240,7 @@ void bus_master_ide_controller_device::device_start() ide_controller_32_device::device_start(); /* find the bus master space */ - if (m_bmcpu != nullptr) - { - device_t *bmtarget = machine().device(m_bmcpu); - if (bmtarget == nullptr) - throw emu_fatalerror("IDE controller '%s' bus master target '%s' doesn't exist!", tag(), m_bmcpu); - device_memory_interface *memory; - if (!bmtarget->interface(memory)) - throw emu_fatalerror("IDE controller '%s' bus master target '%s' has no memory!", tag(), m_bmcpu); - m_dma_space = &memory->space(m_bmspace); - m_dma_address_xor = (m_dma_space->endianness() == ENDIANNESS_LITTLE) ? 0 : 3; - } + m_dma_address_xor = (m_dma_space->endianness() == ENDIANNESS_LITTLE) ? 0 : 3; save_item(NAME(m_dma_address)); save_item(NAME(m_dma_bytes_left)); diff --git a/src/devices/machine/idectrl.h b/src/devices/machine/idectrl.h index 3a0886a5185..c0e84e3c562 100644 --- a/src/devices/machine/idectrl.h +++ b/src/devices/machine/idectrl.h @@ -105,7 +105,7 @@ class bus_master_ide_controller_device : public ide_controller_32_device { public: bus_master_ide_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - void set_bus_master_space(const char *bmcpu, uint32_t bmspace) { m_bmcpu = bmcpu; m_bmspace = bmspace; } + template void set_bus_master_space(T &&bmtag, int bmspace) { m_dma_space.set_tag(std::forward(bmtag), bmspace); } template bus_master_ide_controller_device &master(T &&opts, const char *dflt = nullptr, bool fixed = false) { @@ -140,9 +140,7 @@ protected: private: void execute_dma(); - const char *m_bmcpu; - uint32_t m_bmspace; - address_space *m_dma_space; + required_address_space m_dma_space; uint8_t m_dma_address_xor; offs_t m_dma_address; diff --git a/src/mame/machine/xbox_pci.cpp b/src/mame/machine/xbox_pci.cpp index 5ef0dbdfd59..0e09e9254d1 100644 --- a/src/mame/machine/xbox_pci.cpp +++ b/src/mame/machine/xbox_pci.cpp @@ -915,7 +915,7 @@ void mcpx_ide_device::device_add_mconfig(machine_config &config) { bus_master_ide_controller_device &ide(BUS_MASTER_IDE_CONTROLLER(config, "ide", 0)); ide.irq_handler().set(FUNC(mcpx_ide_device::ide_interrupt)); - ide.set_bus_master_space("maincpu", AS_PROGRAM); + ide.set_bus_master_space(":maincpu", AS_PROGRAM); } WRITE_LINE_MEMBER(mcpx_ide_device::ide_interrupt) -- cgit v1.2.3