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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
// license: BSD-3-Clause
// copyright-holders: Dirk Best
/***************************************************************************
VIA VT8231 South Bridge - PCI to ISA Bridge
***************************************************************************/
#include "emu.h"
#include "vt8231_isa.h"
#define LOG_MAPPING (1U << 1)
#define LOG_REG (1U << 2)
#define LOG_SUPERIO (1U << 3)
#define VERBOSE (LOG_GENERAL | LOG_MAPPING | LOG_REG | LOG_SUPERIO)
#include "logmacro.h"
DEFINE_DEVICE_TYPE(VT8231_ISA, vt8231_isa_device, "vt8231_isa", "VT8231 South Bridge - PCI to ISA Bridge")
vt8231_isa_device::vt8231_isa_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
pci_device(mconfig, VT8231_ISA, tag, owner, clock),
m_com1(*this, "com1"),
m_com1_txd_cb(*this), m_com1_dtr_cb(*this), m_com1_rts_cb(*this),
m_initialized(false)
{
set_ids(0x11068231, 0x00, 0x060100, 0x00000000);
}
void vt8231_isa_device::device_add_mconfig(machine_config &config)
{
NS16550(config, m_com1, 1'843'200);
m_com1->out_tx_callback().set(FUNC(vt8231_isa_device::com1_txd_w));
m_com1->out_dtr_callback().set(FUNC(vt8231_isa_device::com1_dtr_w));
m_com1->out_rts_callback().set(FUNC(vt8231_isa_device::com1_rts_w));
}
void vt8231_isa_device::device_start()
{
pci_device::device_start();
// register for save states (TODO)
}
void vt8231_isa_device::device_reset()
{
pci_device::device_reset();
// setup superio configuration defaults
std::fill_n(m_superio_cfg, 0x10, 0x00);
m_superio_cfg[0x00] = 0x3c; // device id
m_superio_cfg[0x01] = 0x01; // revision
m_superio_cfg[0x02] = 0x03; // function select
m_superio_cfg[0x04] = 0xfe; // serial port base address (3f8)
m_superio_cfg[0x06] = 0xde; // parallel port base address (378)
m_superio_cfg[0x07] = 0xfc; // floppy controller base address (3f0)
m_baud_divisor = 0x01; // 115200 baud
m_initialized = true;
remap_cb();
}
void vt8231_isa_device::map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space)
{
if (!m_initialized)
return;
io_space->install_device(0x000, 0x7ff, *this, &vt8231_isa_device::io_map);
// serial port enabled?
if (BIT(m_superio_cfg[0x02], 2) == 1)
{
uint16_t com1_base = m_superio_cfg[0x04] << 2;
LOGMASKED(LOG_MAPPING, "Mapping COM1 from %04x to %04x\n", com1_base, com1_base + 0x0f);
io_space->install_device(com1_base, com1_base + 0x0f, *this, &vt8231_isa_device::com1_map);
}
}
void vt8231_isa_device::config_map(address_map &map)
{
pci_device::config_map(map);
map(0x50, 0x50).rw(FUNC(vt8231_isa_device::function_control_1_r), FUNC(vt8231_isa_device::function_control_1_w));
}
uint8_t vt8231_isa_device::function_control_1_r()
{
// 7------- mc97 enable
// -6------ ac97 enable
// --5----- usb enable
// ---4---- usb enable
// ----3--- ide enable
// -----2-- super io configuration enable
// ------1- super io enable
// -------0 internal audio enable
return 0x00;
}
void vt8231_isa_device::function_control_1_w(uint8_t data)
{
LOGMASKED(LOG_REG, "function_control_1_w: %02x\n", data);
}
void vt8231_isa_device::io_map(address_map &map)
{
map(0x3f0, 0x3f0).rw(FUNC(vt8231_isa_device::superio_cfg_idx_r), FUNC(vt8231_isa_device::superio_cfg_idx_w));
map(0x3f1, 0x3f1).rw(FUNC(vt8231_isa_device::superio_cfg_data_r), FUNC(vt8231_isa_device::superio_cfg_data_w));
}
//**************************************************************************
// SUPER IO
//**************************************************************************
uint8_t vt8231_isa_device::superio_cfg_idx_r()
{
return m_superio_cfg_idx;
}
void vt8231_isa_device::superio_cfg_idx_w(uint8_t data)
{
LOGMASKED(LOG_SUPERIO, "superio_cfg_idx_w: %02x\n", data);
m_superio_cfg_idx = data & 0x0f;
}
uint8_t vt8231_isa_device::superio_cfg_data_r()
{
return m_superio_cfg[m_superio_cfg_idx];
}
void vt8231_isa_device::superio_cfg_data_w(uint8_t data)
{
LOGMASKED(LOG_SUPERIO, "superio_cfg_data_w: %02x\n", data);
// first two registers are read-only
if (m_superio_cfg_idx < 2)
return;
m_superio_cfg[m_superio_cfg_idx] = data;
remap_cb();
switch (m_superio_cfg_idx)
{
case 0x02:
// 765----- reserved
// ---4---- floppy controller enable
// ----3--- reserved
// -----2-- serial port enable
// ------10 parellel port enable/mode
LOGMASKED(LOG_SUPERIO, "SuperIO function select\n");
break;
case 0x03:
LOGMASKED(LOG_SUPERIO, "SuperIO power down control\n");
break;
case 0x04:
LOGMASKED(LOG_SUPERIO, "SuperIO serial port i/o base address\n");
break;
case 0x06:
LOGMASKED(LOG_SUPERIO, "SuperIO parallel port i/o base address\n");
break;
case 0x07:
LOGMASKED(LOG_SUPERIO, "SuperIO floppy controller base address\n");
break;
case 0x09:
LOGMASKED(LOG_SUPERIO, "SuperIO serial port control\n");
break;
case 0x0a:
LOGMASKED(LOG_SUPERIO, "SuperIO parallel port control\n");
break;
case 0x0b:
LOGMASKED(LOG_SUPERIO, "SuperIO floppy controller control\n");
break;
case 0x0c:
LOGMASKED(LOG_SUPERIO, "SuperIO floppy controller drive type\n");
break;
case 0x0e:
LOGMASKED(LOG_SUPERIO, "SuperIO test mode a\n");
break;
case 0x0f:
LOGMASKED(LOG_SUPERIO, "SuperIO test mode b\n");
break;
default:
LOGMASKED(LOG_SUPERIO, "SuperIO reserved register\n");
break;
}
}
//**************************************************************************
// SERIAL PORT
//**************************************************************************
void vt8231_isa_device::com1_map(address_map &map)
{
map(0x00, 0x07).rw("com1", FUNC(ins8250_device::ins8250_r), FUNC(ins8250_device::ins8250_w));
map(0x08, 0x09).rw(FUNC(vt8231_isa_device::com1_baud_r), FUNC(vt8231_isa_device::com1_baud_w));
}
uint16_t vt8231_isa_device::com1_baud_r()
{
return m_baud_divisor;
}
void vt8231_isa_device::com1_baud_w(uint16_t data)
{
logerror("com1_baud_w: %04x\n", data);
m_baud_divisor = data;
// TODO: setting this to 0 might disable it?
if (data > 0)
m_com1->set_clock_scale(1.0 / data);
}
|