mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
nscsi_bus: Class overhaul (nw)
- SCSI slot options are no longer required to implement nscsi_device themselves. Instead they implement nscsi_slot_device_interface, which contains a finder for a nscsi_device. This is to accommodate LLE SCSI drives with their own LSI interface chips. - SCSI bus device connection is now done through device_resolve_objects rather than device_config_complete. (The pessimized code to access the device finder is because that will not have been resolved yet.) - Added a validity checking method for nscsi_connector.
This commit is contained in:
parent
2a751e00e7
commit
60d4fea8c8
@ -89,6 +89,7 @@ DEFINE_DEVICE_TYPE(NCR53C7XX, ncr53c7xx_device, "ncr537xx", "NCR 53C7xx SCSI")
|
||||
|
||||
ncr53c7xx_device::ncr53c7xx_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: nscsi_device(mconfig, NCR53C7XX, tag, owner, clock),
|
||||
nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF),
|
||||
device_execute_interface(mconfig, *this),
|
||||
m_icount(0),
|
||||
m_irq_handler(*this),
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "machine/nscsi_bus.h"
|
||||
|
||||
|
||||
class ncr53c7xx_device : public nscsi_device, public device_execute_interface
|
||||
class ncr53c7xx_device : public nscsi_device, public nscsi_slot_card_interface, public device_execute_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
|
@ -49,6 +49,7 @@ static char const *const aic6250_phase[] = { "DATA OUT", "*", "DATA IN", "*", "C
|
||||
|
||||
aic6250_device::aic6250_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: nscsi_device(mconfig, type, tag, owner, clock)
|
||||
, nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF)
|
||||
, m_int_cb(*this)
|
||||
, m_breq_cb(*this)
|
||||
, m_port_a_r_cb(*this)
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "machine/nscsi_bus.h"
|
||||
|
||||
class aic6250_device : public nscsi_device
|
||||
class aic6250_device : public nscsi_device, public nscsi_slot_card_interface
|
||||
{
|
||||
public:
|
||||
aic6250_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
@ -18,6 +18,7 @@ mb87030_device::mb87030_device(const machine_config &mconfig, const char *tag, d
|
||||
|
||||
mb87030_device::mb87030_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
|
||||
nscsi_device(mconfig, type, tag, owner, clock),
|
||||
nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF),
|
||||
m_irq_handler(*this),
|
||||
m_dreq_handler(*this)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "machine/nscsi_bus.h"
|
||||
#include <queue>
|
||||
|
||||
class mb87030_device : public nscsi_device
|
||||
class mb87030_device : public nscsi_device, public nscsi_slot_card_interface
|
||||
{
|
||||
public:
|
||||
mb87030_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
@ -36,6 +36,7 @@ void ncr5380n_device::map(address_map &map)
|
||||
|
||||
ncr5380n_device::ncr5380n_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: nscsi_device(mconfig, type, tag, owner, clock)
|
||||
, nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF)
|
||||
, m_fake_clock(10000000)
|
||||
, tm(nullptr), status(0), istatus(0), m_mode(0)
|
||||
, m_outdata(0), m_busstatus(0), m_dmalatch(0), m_icommand(0), m_tcommand(0), clock_conv(0), sync_offset(0), sync_period(0), bus_id(0), select_timeout(0)
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "machine/nscsi_bus.h"
|
||||
|
||||
|
||||
class ncr5380n_device : public nscsi_device
|
||||
class ncr5380n_device : public nscsi_device, public nscsi_slot_card_interface
|
||||
{
|
||||
public:
|
||||
ncr5380n_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
@ -124,6 +124,7 @@ void ncr53c94_device::write(offs_t offset, uint8_t data)
|
||||
|
||||
ncr5390_device::ncr5390_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: nscsi_device(mconfig, type, tag, owner, clock)
|
||||
, nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF)
|
||||
, tm(nullptr), config(0), status(0), istatus(0), clock_conv(0), sync_offset(0), sync_period(0), bus_id(0)
|
||||
, select_timeout(0), seq(0), tcount(0), tcounter(0), mode(0), fifo_pos(0), command_pos(0), state(0), xfr_phase(0), command_length(0), dma_dir(0), irq(false), drq(false), test_mode(false)
|
||||
, m_irq_handler(*this)
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "machine/nscsi_bus.h"
|
||||
|
||||
class ncr5390_device : public nscsi_device
|
||||
class ncr5390_device : public nscsi_device, public nscsi_slot_card_interface
|
||||
{
|
||||
public:
|
||||
ncr5390_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
@ -125,19 +125,15 @@ void nscsi_bus_device::ctrl_wait(int refid, uint32_t lines, uint32_t mask)
|
||||
dev[refid].wait_ctrl = (w & ~mask) | (lines & mask);
|
||||
}
|
||||
|
||||
void nscsi_bus_device::device_config_complete()
|
||||
void nscsi_bus_device::device_resolve_objects()
|
||||
{
|
||||
char id[3];
|
||||
for(int i=0; i<16; i++) {
|
||||
sprintf(id, "%d", i);
|
||||
nscsi_connector *conn = downcast<nscsi_connector *>(subdevice(id));
|
||||
if(conn) {
|
||||
nscsi_device *sdev = conn->get_device();
|
||||
if(sdev) {
|
||||
int rid = devcnt++;
|
||||
dev[rid].dev = sdev;
|
||||
sdev->connect_to_bus(this, rid, i);
|
||||
}
|
||||
device_t *subdev = subdevice(string_format("%d", i).c_str());
|
||||
nscsi_device *sdev = subdev ? downcast<nscsi_connector &>(*subdev).get_device() : nullptr;
|
||||
if(sdev) {
|
||||
int rid = devcnt++;
|
||||
dev[rid].dev = sdev;
|
||||
sdev->connect_to_bus(this, rid, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,18 +149,34 @@ nscsi_connector::~nscsi_connector()
|
||||
{
|
||||
}
|
||||
|
||||
void nscsi_connector::device_validity_check(validity_checker &valid) const
|
||||
{
|
||||
device_t *const carddev = get_card_device();
|
||||
if (carddev && !dynamic_cast<nscsi_slot_card_interface *>(carddev))
|
||||
osd_printf_error("Card device %s (%s) does not implement nscsi_slot_card_interface\n", carddev->tag(), carddev->name());
|
||||
}
|
||||
|
||||
void nscsi_connector::device_start()
|
||||
{
|
||||
}
|
||||
|
||||
nscsi_device *nscsi_connector::get_device()
|
||||
{
|
||||
return dynamic_cast<nscsi_device *>(get_card_device());
|
||||
nscsi_slot_card_interface *connected = dynamic_cast<nscsi_slot_card_interface *>(get_card_device());
|
||||
if (connected)
|
||||
return connected->device().subdevice<nscsi_device>(connected->m_nscsi.finder_tag());
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nscsi_slot_card_interface::nscsi_slot_card_interface(const machine_config &mconfig, device_t &device, const char *nscsi_tag) :
|
||||
device_slot_card_interface(mconfig, device),
|
||||
m_nscsi(device, nscsi_tag)
|
||||
{
|
||||
}
|
||||
|
||||
nscsi_device::nscsi_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_slot_card_interface(mconfig, *this)
|
||||
device_t(mconfig, type, tag, owner, clock)
|
||||
{
|
||||
scsi_id = scsi_refid = -1;
|
||||
scsi_bus = nullptr;
|
||||
@ -187,6 +199,12 @@ void nscsi_device::device_start()
|
||||
}
|
||||
|
||||
|
||||
nscsi_full_device::nscsi_full_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
|
||||
nscsi_device(mconfig, type, tag, owner, clock),
|
||||
nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF)
|
||||
{
|
||||
}
|
||||
|
||||
const char *const nscsi_full_device::command_names[256] = {
|
||||
/* 00 */ "TEST_UNIT_READY", "REZERO", "?", "REQUEST_SENSE", "FORMAT_UNIT", "?", "?", "REASSIGN_BLOCKS",
|
||||
/* 08 */ "READ_6/RECIEVE", "?", "WRITE_6/SEND", "SEEK", "?", "?", "?", "?",
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_config_complete() override;
|
||||
virtual void device_resolve_objects() override;
|
||||
|
||||
private:
|
||||
struct dev_t {
|
||||
@ -60,10 +60,22 @@ public:
|
||||
nscsi_device *get_device();
|
||||
|
||||
protected:
|
||||
virtual void device_validity_check(validity_checker &valid) const override;
|
||||
virtual void device_start() override;
|
||||
};
|
||||
|
||||
class nscsi_device : public device_t, public device_slot_card_interface
|
||||
class nscsi_slot_card_interface : public device_slot_card_interface
|
||||
{
|
||||
friend class nscsi_connector;
|
||||
|
||||
public:
|
||||
nscsi_slot_card_interface(const machine_config &mconfig, device_t &device, const char *nscsi_tag);
|
||||
|
||||
private:
|
||||
required_device<nscsi_device> m_nscsi;
|
||||
};
|
||||
|
||||
class nscsi_device : public device_t
|
||||
{
|
||||
public:
|
||||
// Here because the biggest users are the devices, not the bus
|
||||
@ -128,7 +140,7 @@ protected:
|
||||
nscsi_bus_device *scsi_bus;
|
||||
};
|
||||
|
||||
class nscsi_full_device : public nscsi_device
|
||||
class nscsi_full_device : public nscsi_device, public nscsi_slot_card_interface
|
||||
{
|
||||
public:
|
||||
virtual void scsi_ctrl_changed() override;
|
||||
@ -300,7 +312,7 @@ protected:
|
||||
SBUF_SENSE
|
||||
};
|
||||
|
||||
using nscsi_device::nscsi_device;
|
||||
nscsi_full_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
@ -7,6 +7,7 @@ DEFINE_DEVICE_TYPE(NSCSI_CB, nscsi_callback_device, "nscsi_cb", "SCSI callback (
|
||||
|
||||
nscsi_callback_device::nscsi_callback_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: nscsi_device(mconfig, NSCSI_CB, tag, owner, clock),
|
||||
nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF),
|
||||
m_write_rst(*this),
|
||||
m_write_atn(*this),
|
||||
m_write_ack(*this),
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "machine/nscsi_bus.h"
|
||||
|
||||
|
||||
class nscsi_callback_device : public nscsi_device
|
||||
class nscsi_callback_device : public nscsi_device, public nscsi_slot_card_interface
|
||||
{
|
||||
public:
|
||||
nscsi_callback_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
@ -359,6 +359,7 @@ DEFINE_DEVICE_TYPE(WD33C93B, wd33c93b_device, "wd33c93b", "Western Digital WD33C
|
||||
|
||||
wd33c9x_base_device::wd33c9x_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: nscsi_device{ mconfig, type, tag, owner, clock }
|
||||
, nscsi_slot_card_interface(mconfig, *this, DEVICE_SELF)
|
||||
, m_addr{ 0 }
|
||||
, m_regs{ 0 }
|
||||
, m_command_length{ 0 }
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "machine/nscsi_bus.h"
|
||||
|
||||
class wd33c9x_base_device : public nscsi_device
|
||||
class wd33c9x_base_device : public nscsi_device, public nscsi_slot_card_interface
|
||||
{
|
||||
public:
|
||||
auto irq_cb() { return m_irq_cb.bind(); }
|
||||
|
Loading…
Reference in New Issue
Block a user