bus/ata: Do slot output signals the sensible way (fixes GitHub #11346).

This commit is contained in:
Vas Crabb 2023-06-18 06:15:56 +10:00
parent f9002c38ee
commit a3e4ece95e
5 changed files with 65 additions and 57 deletions

View File

@ -20,10 +20,7 @@
device_ata_interface::device_ata_interface(const machine_config &mconfig, device_t &device) : device_ata_interface::device_ata_interface(const machine_config &mconfig, device_t &device) :
device_interface(device, "ata"), device_interface(device, "ata"),
m_irq_handler(device), m_slot(dynamic_cast<ata_slot_device *>(device.owner()))
m_dmarq_handler(device),
m_dasp_handler(device),
m_pdiag_handler(device)
{ {
} }
@ -42,6 +39,10 @@ DEFINE_DEVICE_TYPE(ATA_SLOT, ata_slot_device, "ata_slot", "ATA Connector")
ata_slot_device::ata_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : ata_slot_device::ata_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, ATA_SLOT, tag, owner, clock), device_t(mconfig, ATA_SLOT, tag, owner, clock),
device_single_card_slot_interface<device_ata_interface>(mconfig, *this), device_single_card_slot_interface<device_ata_interface>(mconfig, *this),
m_irq_handler(*this),
m_dmarq_handler(*this),
m_dasp_handler(*this),
m_pdiag_handler(*this),
m_dev(nullptr) m_dev(nullptr)
{ {
} }

View File

@ -13,14 +13,43 @@
#pragma once #pragma once
class device_ata_interface;
// ======================> device_ata_interface
class ata_interface_device; class ata_slot_device :
public device_t,
public device_single_card_slot_interface<device_ata_interface>
{
public:
// construction/destruction
ata_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
auto irq_handler() { return m_irq_handler.bind(); }
auto dmarq_handler() { return m_dmarq_handler.bind(); }
auto dasp_handler() { return m_dasp_handler.bind(); }
auto pdiag_handler() { return m_pdiag_handler.bind(); }
device_ata_interface *dev() { return m_dev; }
protected:
// device_t implementation
virtual void device_config_complete() override;
virtual void device_start() override;
private:
devcb_write_line m_irq_handler;
devcb_write_line m_dmarq_handler;
devcb_write_line m_dasp_handler;
devcb_write_line m_pdiag_handler;
device_ata_interface *m_dev;
friend class device_ata_interface;
};
class device_ata_interface : public device_interface class device_ata_interface : public device_interface
{ {
friend class abstract_ata_interface_device;
public: public:
virtual uint16_t read_dma() = 0; virtual uint16_t read_dma() = 0;
virtual uint16_t read_cs0(offs_t offset, uint16_t mem_mask = 0xffff) = 0; virtual uint16_t read_cs0(offs_t offset, uint16_t mem_mask = 0xffff) = 0;
@ -38,33 +67,17 @@ public:
protected: protected:
device_ata_interface(const machine_config &mconfig, device_t &device); device_ata_interface(const machine_config &mconfig, device_t &device);
devcb_write_line m_irq_handler; void set_irq(int state) { m_slot->m_irq_handler(state); }
devcb_write_line m_dmarq_handler; void set_dmarq(int state) { m_slot->m_dmarq_handler(state); }
devcb_write_line m_dasp_handler; void set_dasp(int state) { m_slot->m_dasp_handler(state); }
devcb_write_line m_pdiag_handler; void set_pdiag(int state) { m_slot->m_pdiag_handler(state); }
};
// ======================> ata_slot_device
class ata_slot_device : public device_t,
public device_single_card_slot_interface<device_ata_interface>
{
public:
// construction/destruction
ata_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
device_ata_interface *dev() { return m_dev; }
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_config_complete() override;
private: private:
device_ata_interface *m_dev; ata_slot_device *const m_slot;
}; };
// device type definition
// device type declaration
DECLARE_DEVICE_TYPE(ATA_SLOT, ata_slot_device) DECLARE_DEVICE_TYPE(ATA_SLOT, ata_slot_device)
void ata_devices(device_slot_interface &device); void ata_devices(device_slot_interface &device);

View File

@ -40,8 +40,8 @@ enum
#define DEVICE1_PDIAG_TIME (attotime::from_msec(2)) #define DEVICE1_PDIAG_TIME (attotime::from_msec(2))
#define DIAGNOSTIC_TIME (attotime::from_msec(2)) #define DIAGNOSTIC_TIME (attotime::from_msec(2))
ata_hle_device::ata_hle_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) ata_hle_device::ata_hle_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
: device_t(mconfig, type, tag, owner, clock), device_t(mconfig, type, tag, owner, clock),
device_ata_interface(mconfig, *this), device_ata_interface(mconfig, *this),
m_buffer_offset(0), m_buffer_offset(0),
m_buffer_size(0), m_buffer_size(0),
@ -396,9 +396,9 @@ void ata_hle_device::write_data(uint16_t data)
void ata_hle_device::update_irq() void ata_hle_device::update_irq()
{ {
if (device_selected() && (m_device_control & IDE_DEVICE_CONTROL_NIEN) == 0) if (device_selected() && (m_device_control & IDE_DEVICE_CONTROL_NIEN) == 0)
m_irq_handler(m_irq); device_ata_interface::set_irq(m_irq);
else else
m_irq_handler(CLEAR_LINE); device_ata_interface::set_irq(CLEAR_LINE);
} }
void ata_hle_device::set_irq(int state) void ata_hle_device::set_irq(int state)
@ -417,7 +417,7 @@ void ata_hle_device::set_dmarq(int state)
{ {
m_dmarq = state; m_dmarq = state;
m_dmarq_handler(state); device_ata_interface::set_dmarq(state);
} }
} }
@ -427,7 +427,7 @@ void ata_hle_device::set_dasp(int state)
{ {
m_daspout = state; m_daspout = state;
m_dasp_handler(state); device_ata_interface::set_dasp(state);
} }
} }
@ -437,7 +437,7 @@ void ata_hle_device::set_pdiag(int state)
{ {
m_pdiagout = state; m_pdiagout = state;
m_pdiag_handler(state); device_ata_interface::set_pdiag(state);
} }
} }

View File

@ -237,28 +237,11 @@ void abstract_ata_interface_device::device_start()
m_dasp[i] = 0; m_dasp[i] = 0;
m_pdiag[i] = 0; m_pdiag[i] = 0;
device_ata_interface *dev = m_slot[i]->dev(); device_ata_interface *const dev = m_slot[i]->dev();
if (dev) if (dev)
{
if (i == 0)
{
dev->m_irq_handler.bind().set(*this, FUNC(abstract_ata_interface_device::irq0_write_line));
dev->m_dmarq_handler.bind().set(*this, FUNC(abstract_ata_interface_device::dmarq0_write_line));
dev->m_dasp_handler.bind().set(*this, FUNC(abstract_ata_interface_device::dasp0_write_line));
dev->m_pdiag_handler.bind().set(*this, FUNC(abstract_ata_interface_device::pdiag0_write_line));
}
else
{
dev->m_irq_handler.bind().set(*this, FUNC(abstract_ata_interface_device::irq1_write_line));
dev->m_dmarq_handler.bind().set(*this, FUNC(abstract_ata_interface_device::dmarq1_write_line));
dev->m_dasp_handler.bind().set(*this, FUNC(abstract_ata_interface_device::dasp1_write_line));
dev->m_pdiag_handler.bind().set(*this, FUNC(abstract_ata_interface_device::pdiag1_write_line));
}
dev->write_csel(i); dev->write_csel(i);
} }
} }
}
//------------------------------------------------- //-------------------------------------------------
@ -267,6 +250,15 @@ void abstract_ata_interface_device::device_start()
void abstract_ata_interface_device::device_add_mconfig(machine_config &config) void abstract_ata_interface_device::device_add_mconfig(machine_config &config)
{ {
for (size_t slot = 0; slot < SLOT_COUNT; slot++) ATA_SLOT(config, m_slot[0]);
ATA_SLOT(config, m_slot[slot]); m_slot[0]->irq_handler().set(FUNC(abstract_ata_interface_device::irq0_write_line));
m_slot[0]->dmarq_handler().set(FUNC(abstract_ata_interface_device::dmarq0_write_line));
m_slot[0]->dasp_handler().set(FUNC(abstract_ata_interface_device::dasp0_write_line));
m_slot[0]->pdiag_handler().set(FUNC(abstract_ata_interface_device::pdiag0_write_line));
ATA_SLOT(config, m_slot[1]);
m_slot[1]->irq_handler().set(FUNC(abstract_ata_interface_device::irq1_write_line));
m_slot[1]->dmarq_handler().set(FUNC(abstract_ata_interface_device::dmarq1_write_line));
m_slot[1]->dasp_handler().set(FUNC(abstract_ata_interface_device::dasp1_write_line));
m_slot[1]->pdiag_handler().set(FUNC(abstract_ata_interface_device::pdiag1_write_line));
} }

View File

@ -861,6 +861,7 @@ devcb_read<Result, DefaultMask>::devcb_read(device_t &owner, Result dflt)
template <typename Result, std::make_unsigned_t<Result> DefaultMask> template <typename Result, std::make_unsigned_t<Result> DefaultMask>
typename devcb_read<Result, DefaultMask>::binder devcb_read<Result, DefaultMask>::bind() typename devcb_read<Result, DefaultMask>::binder devcb_read<Result, DefaultMask>::bind()
{ {
assert(m_functions.empty());
return binder(*this); return binder(*this);
} }
@ -2380,6 +2381,7 @@ devcb_write<Input, DefaultMask>::devcb_write(device_t &owner)
template <typename Input, std::make_unsigned_t<Input> DefaultMask> template <typename Input, std::make_unsigned_t<Input> DefaultMask>
typename devcb_write<Input, DefaultMask>::binder devcb_write<Input, DefaultMask>::bind() typename devcb_write<Input, DefaultMask>::binder devcb_write<Input, DefaultMask>::bind()
{ {
assert(m_functions.empty());
return binder(*this); return binder(*this);
} }