summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/isa/side116.cpp
blob: bad6645bf5a0d601df5856566728c2154b919c1f (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// license:BSD-3-Clause
// copyright-holders:Dirk Best
/***************************************************************************

    Acculogic sIDE-1/16

    IDE Disk Controller for IBM PC, XT and compatibles

***************************************************************************/

#include "emu.h"
#include "side116.h"


//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(ISA8_SIDE116, side116_device, "side116", "Acculogic sIDE-1/16 IDE Disk Controller")

//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

void side116_device::device_add_mconfig(machine_config &config)
{
	ATA_INTERFACE(config, m_ata).options(ata_devices, "hdd", nullptr, false);
	m_ata->irq_handler().set(FUNC(side116_device::ide_interrupt));
}


//-------------------------------------------------
//  input_ports - device-specific input ports
//-------------------------------------------------

static INPUT_PORTS_START( side116 )
	PORT_START("configuration")
	PORT_DIPNAME(0x01, 0x00, "sIDE-1/16 ROM")
	PORT_DIPLOCATION("JP:1")
	PORT_DIPSETTING(0x00, "Enabled")
	PORT_DIPSETTING(0x01, "Disabled")
	PORT_DIPNAME(0x06, 0x00, "sIDE-1/16 ROM Address")
	PORT_DIPLOCATION("JP:2,3")
	PORT_DIPSETTING(0x00, "Range C800h")
	PORT_DIPSETTING(0x04, "Range CC00h")
	PORT_DIPSETTING(0x02, "Range D800h")
	PORT_DIPSETTING(0x06, "Range DC00h")
	PORT_DIPNAME(0x18, 0x10, "sIDE-1/16 IDE IRQ")
	PORT_DIPLOCATION("JP:4,5")
	PORT_DIPSETTING(0x10, "Level 5")
	PORT_DIPSETTING(0x08, "Level 2")
	PORT_DIPNAME(0x20, 0x20, "sIDE-1/16 IDE")
	PORT_DIPLOCATION("JP:6")
	PORT_DIPSETTING(0x00, "Disabled")
	PORT_DIPSETTING(0x20, "Enabled")
INPUT_PORTS_END

ioport_constructor side116_device::device_input_ports() const
{
	return INPUT_PORTS_NAME( side116 );
}

//-------------------------------------------------
//  rom_region - device-specific ROM region
//-------------------------------------------------

ROM_START( side116 )
	ROM_REGION(0x2000, "option", 0)
	ROM_LOAD("bios12.u2", 0x0000, 0x2000, CRC(c202a0e6) SHA1(a5b130a6d17c972d6c378cb2cd8113a4039631fe))
ROM_END

const tiny_rom_entry *side116_device::device_rom_region() const
{
	return ROM_NAME( side116 );
}


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  side116_device - constructor
//-------------------------------------------------

side116_device::side116_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, ISA8_SIDE116, tag, owner, clock),
	device_isa8_card_interface( mconfig, *this ),
	m_ata(*this, "ata"),
	m_config(*this, "configuration"),
	m_latch(0xff)
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void side116_device::device_start()
{
	set_isa_device();
}

//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void side116_device::device_reset()
{
	// install option rom
	if ((m_config->read() & 0x01) == 0x00)
	{
		switch ((m_config->read() >> 1) & 0x03)
		{
		case 0: m_isa->install_rom(this, 0xc8000, 0xc9fff, "option"); break;
		case 1: m_isa->install_rom(this, 0xd8000, 0xd9fff, "option"); break;
		case 2: m_isa->install_rom(this, 0xcc000, 0xcdfff, "option"); break;
		case 3: m_isa->install_rom(this, 0xdc000, 0xddfff, "option"); break;
		}
	}

	// install io access
	if ((m_config->read() & 0x20) == 0x20)
		m_isa->install_device(0x360, 0x36f, read8sm_delegate(*this, FUNC(side116_device::read)), write8sm_delegate(*this, FUNC(side116_device::write)));
}


//**************************************************************************
//  IDE INTERFACE
//**************************************************************************

uint8_t side116_device::read(offs_t offset)
{
	uint8_t data;

	if (offset == 0)
	{
		uint16_t ide_data = m_ata->cs0_r(0);
		data = ide_data & 0xff;
		m_latch = ide_data >> 8;
	}
	else if (offset < 8)
	{
		data = m_ata->cs0_r(offset & 7, 0xff);
	}
	else if (offset == 8)
	{
		data = m_latch;
	}
	else
	{
		data = m_ata->cs1_r(offset & 7, 0xff);
	}

	return data;
}

void side116_device::write(offs_t offset, uint8_t data)
{
	if (offset == 0)
	{
		uint16_t ide_data = (m_latch << 8) | data;
		m_ata->cs0_w(0, ide_data);
	}
	else if (offset < 8)
	{
		m_ata->cs0_w(offset & 7, data, 0xff);
	}
	else if (offset == 8)
	{
		m_latch = data;
	}
	else
	{
		m_ata->cs1_w(offset & 7, data, 0xff);
	}
}

WRITE_LINE_MEMBER( side116_device::ide_interrupt )
{
	uint8_t level = m_config->read() & 0x18;

	if (level == 0x08)
		m_isa->irq2_w(state);
	else if (level == 0x10)
		m_isa->irq5_w(state);
}