summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/scsicb.c
blob: affe48e5fd096f8c020d75f7009b841a6f88763e (plain) (blame)
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
143
144
145
146
147
148
/*

scsicb.c

Implementation of a raw SCSI/SASI bus for machines that don't use a SCSI
controler chip such as the RM Nimbus, which implements it as a bunch of
74LS series chips.

*/

#include "scsicb.h"
#include "scsibus.h"

scsicb_device::scsicb_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
    : scsidev_device(mconfig, SCSICB, "SCSI callback", tag, owner, clock)
{
}

void scsicb_device::device_config_complete()
{
	// inherit a copy of the static data
	const SCSICB_interface *intf = reinterpret_cast<const SCSICB_interface *>(static_config());
	if (intf != NULL)
	{
		*static_cast<SCSICB_interface *>(this) = *intf;
	}
}

void scsicb_device::device_start()
{
	scsidev_device::device_start();

	out_bsy_func.resolve(_out_bsy_func, *this);
	out_sel_func.resolve(_out_sel_func, *this);
	out_cd_func.resolve(_out_cd_func, *this);
	out_io_func.resolve(_out_io_func, *this);
	out_msg_func.resolve(_out_msg_func, *this);
	out_req_func.resolve(_out_req_func, *this);
	out_ack_func.resolve(_out_ack_func, *this);
	out_atn_func.resolve(_out_atn_func, *this);
	out_rst_func.resolve(_out_rst_func, *this);
}

void scsicb_device::scsi_in( UINT32 data, UINT32 mask )
{
	linestate = data;

	if( ( mask & SCSI_MASK_BSY ) != 0 )
	{
		out_bsy_func( (int) ( data & SCSI_MASK_BSY ) != 0 );
	}

	if( ( mask & SCSI_MASK_SEL ) != 0 )
	{
		out_sel_func( (int) ( data & SCSI_MASK_SEL ) != 0 );
	}

	if( ( mask & SCSI_MASK_CD ) != 0 )
	{
		out_cd_func( (int) ( data & SCSI_MASK_CD ) != 0 );
	}

	if( ( mask & SCSI_MASK_IO ) != 0 )
	{
		out_io_func( (int) ( data & SCSI_MASK_IO ) != 0 );
	}

	if( ( mask & SCSI_MASK_MSG ) != 0 )
	{
		out_msg_func( (int) ( data & SCSI_MASK_MSG ) != 0 );
	}

	if( ( mask & SCSI_MASK_REQ ) != 0 )
	{
		out_req_func( (int) ( data & SCSI_MASK_REQ ) != 0 );
	}

	if( ( mask & SCSI_MASK_ACK ) != 0 )
	{
		out_ack_func( (int) ( data & SCSI_MASK_ACK ) != 0 );
	}

	if( ( mask & SCSI_MASK_ATN ) != 0 )
	{
		out_ack_func( (int) ( data & SCSI_MASK_ATN ) != 0 );
	}

	if( ( mask & SCSI_MASK_RST ) != 0 )
	{
		out_rst_func( (int) ( data & SCSI_MASK_RST ) != 0 );
	}
}

UINT8 scsicb_device::scsi_data_r()
{
	return linestate & SCSI_MASK_DATA;
}

void scsicb_device::scsi_data_w( UINT8 data )
{
	scsi_out( data, SCSI_MASK_DATA );
}

UINT8 scsicb_device::get_scsi_line( UINT32 line )
{
	UINT8 result = (int)( ( linestate & line ) != 0 );

//	LOG(3,"get_scsi_line(%s)=%d\n",linenames[lineno],result);

	return result;
}

void scsicb_device::set_scsi_line( UINT32 mask, UINT8 state )
{
	scsi_out( state * mask, mask );
}

READ8_MEMBER( scsicb_device::scsi_data_r )
{
	return scsi_data_r();
}

WRITE8_MEMBER( scsicb_device::scsi_data_w )
{
	scsi_data_w( data );
}

READ_LINE_MEMBER( scsicb_device::scsi_bsy_r ) { return get_scsi_line(SCSI_MASK_BSY); }
READ_LINE_MEMBER( scsicb_device::scsi_sel_r ) { return get_scsi_line(SCSI_MASK_SEL); }
READ_LINE_MEMBER( scsicb_device::scsi_cd_r ) { return get_scsi_line(SCSI_MASK_CD); }
READ_LINE_MEMBER( scsicb_device::scsi_io_r ) { return get_scsi_line(SCSI_MASK_IO); }
READ_LINE_MEMBER( scsicb_device::scsi_msg_r ) { return get_scsi_line(SCSI_MASK_MSG); }
READ_LINE_MEMBER( scsicb_device::scsi_req_r ) { return get_scsi_line(SCSI_MASK_REQ); }
READ_LINE_MEMBER( scsicb_device::scsi_ack_r ) { return get_scsi_line(SCSI_MASK_ACK); }
READ_LINE_MEMBER( scsicb_device::scsi_atn_r ) { return get_scsi_line(SCSI_MASK_ATN); }
READ_LINE_MEMBER( scsicb_device::scsi_rst_r ) { return get_scsi_line(SCSI_MASK_RST); }

WRITE_LINE_MEMBER( scsicb_device::scsi_bsy_w ) { set_scsi_line(SCSI_MASK_BSY, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_sel_w ) { set_scsi_line(SCSI_MASK_SEL, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_cd_w ) { set_scsi_line(SCSI_MASK_CD, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_io_w ) { set_scsi_line(SCSI_MASK_IO, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_msg_w ) { set_scsi_line(SCSI_MASK_MSG, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_req_w ) { set_scsi_line(SCSI_MASK_REQ, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_ack_w ) { set_scsi_line(SCSI_MASK_ACK, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_atn_w ) { set_scsi_line(SCSI_MASK_ATN, state); }
WRITE_LINE_MEMBER( scsicb_device::scsi_rst_w ) { set_scsi_line(SCSI_MASK_RST, state); }

const device_type SCSICB = &device_creator<scsicb_device>;