1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
Acorn AIV SCSI Host Adaptor
**********************************************************************/
#include "emu.h"
#include "scsiaiv.h"
#include "machine/nscsi_bus.h"
#include "bus/nscsi/devices.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(BBC_SCSIAIV, bbc_scsiaiv_device, "bbc_scsiaiv", "Acorn AIV SCSI Host Adaptor");
//DEFINE_DEVICE_TYPE(BBC_VP415, bbc_vp415_device, "bbc_vp415", "BBC Philips VP415");
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void bbc_scsiaiv_device::device_add_mconfig(machine_config& config)
{
NSCSI_BUS(config, "scsi");
NSCSI_CONNECTOR(config, "scsi:0", default_scsi_devices, nullptr);
NSCSI_CONNECTOR(config, "scsi:7", default_scsi_devices, "scsicb", true)
.option_add_internal("scsicb", NSCSI_CB)
.machine_config([this](device_t* device) {
downcast<nscsi_callback_device&>(*device).bsy_callback().set(*this, FUNC(bbc_scsiaiv_device::bsy_w));
downcast<nscsi_callback_device&>(*device).req_callback().set(*this, FUNC(bbc_scsiaiv_device::req_w));
});
}
//void bbc_vp415_device::device_add_mconfig(machine_config& config)
//{
// bbc_scsiaiv_device::device_add_mconfig(config);
//
// /* Philips VP415 */
// subdevice<nscsi_connector>("scsi:0")->set_default_option("vp415");
// subdevice<nscsi_connector>("scsi:0")->set_fixed(true);
//}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// bbc_scsiaiv_device - constructor
//-------------------------------------------------
bbc_scsiaiv_device::bbc_scsiaiv_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_bbc_modem_interface(mconfig, *this)
, m_scsi(*this, "scsi:7:scsicb")
{
}
bbc_scsiaiv_device::bbc_scsiaiv_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock)
: bbc_scsiaiv_device(mconfig, BBC_SCSIAIV, tag, owner, clock)
{
}
//bbc_vp415_device::bbc_vp415_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock)
// : bbc_scsiaiv_device(mconfig, BBC_VP415, tag, owner, clock)
//{
//}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void bbc_scsiaiv_device::device_start()
{
/* register for save states */
save_item(NAME(m_irq_enable));
save_item(NAME(m_irq_state));
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
uint8_t bbc_scsiaiv_device::read(offs_t offset)
{
uint8_t data = 0xff;
switch (offset & 0x07)
{
case 0x00:
data = m_scsi->read();
m_scsi->ack_w(1);
break;
case 0x01:
data = (m_scsi->msg_r() << 0)
| (m_scsi->bsy_r() << 1)
| (m_scsi->rst_r() << 2)
| (!m_irq_state << 4)
| (m_scsi->req_r() << 5)
| (m_scsi->io_r() << 6)
| (m_scsi->cd_r() << 7);
break;
}
return data;
}
void bbc_scsiaiv_device::write(offs_t offset, uint8_t data)
{
switch (offset & 0x07)
{
case 0x00:
m_scsi->write(~data);
m_scsi->ack_w(1);
break;
case 0x02:
m_scsi->sel_w(1);
break;
case 0x03:
m_irq_enable = BIT(data, 0);
break;
}
}
WRITE_LINE_MEMBER(bbc_scsiaiv_device::bsy_w)
{
m_scsi->sel_w(0);
}
WRITE_LINE_MEMBER(bbc_scsiaiv_device::req_w)
{
m_scsi->ack_w(0);
m_irq_state = (m_irq_enable && !state) ? 0 : 1;
m_slot->irq_w(m_irq_state ? CLEAR_LINE : ASSERT_LINE);
}
|