25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_dc7085.c,v 1.60 2006/12/31 21:35:26 debug Exp $ |
* $Id: dev_dc7085.c,v 1.62 2007/06/15 18:44:19 debug Exp $ |
29 |
* |
* |
30 |
* DC7085 serial controller, used in some DECstation models. |
* COMMENT: DC7085 serial controller, used in some DECstation models |
31 |
*/ |
*/ |
32 |
|
|
33 |
#include <stdio.h> |
#include <stdio.h> |
161 |
|
|
162 |
DEVICE_ACCESS(dc7085) |
DEVICE_ACCESS(dc7085) |
163 |
{ |
{ |
164 |
|
struct dc_data *d = extra; |
165 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
166 |
size_t i; |
size_t i; |
|
struct dc_data *d = extra; |
|
167 |
|
|
168 |
if (writeflag == MEM_WRITE) |
if (writeflag == MEM_WRITE) |
169 |
idata = memory_readmax64(cpu, data, len); |
idata = memory_readmax64(cpu, data, len); |
172 |
d->regs.dc_csr &= ~CSR_CLR; |
d->regs.dc_csr &= ~CSR_CLR; |
173 |
|
|
174 |
switch (relative_addr) { |
switch (relative_addr) { |
175 |
|
|
176 |
case 0x00: /* CSR: Control and Status */ |
case 0x00: /* CSR: Control and Status */ |
177 |
if (writeflag == MEM_WRITE) { |
if (writeflag == MEM_WRITE) { |
178 |
debug("[ dc7085 write to CSR: 0x%04x ]\n", idata); |
debug("[ dc7085 write to CSR: 0x%04x ]\n", idata); |
192 |
odata = d->regs.dc_csr; |
odata = d->regs.dc_csr; |
193 |
} |
} |
194 |
break; |
break; |
195 |
|
|
196 |
case 0x08: /* LPR: */ |
case 0x08: /* LPR: */ |
197 |
if (writeflag == MEM_WRITE) { |
if (writeflag == MEM_WRITE) { |
198 |
debug("[ dc7085 write to LPR: 0x%04x ]\n", idata); |
debug("[ dc7085 write to LPR: 0x%04x ]\n", idata); |
228 |
d->just_transmitted_something = 4; |
d->just_transmitted_something = 4; |
229 |
} |
} |
230 |
break; |
break; |
231 |
|
|
232 |
case 0x10: /* TCR: */ |
case 0x10: /* TCR: */ |
233 |
if (writeflag == MEM_WRITE) { |
if (writeflag == MEM_WRITE) { |
234 |
/* fatal("[ dc7085 write to TCR: 0x%04x) ]\n", |
/* fatal("[ dc7085 write to TCR: 0x%04x) ]\n", |
244 |
odata = d->regs.dc_tcr; |
odata = d->regs.dc_tcr; |
245 |
} |
} |
246 |
break; |
break; |
247 |
|
|
248 |
case 0x18: /* Modem status (R), transmit data (W) */ |
case 0x18: /* Modem status (R), transmit data (W) */ |
249 |
if (writeflag == MEM_WRITE) { |
if (writeflag == MEM_WRITE) { |
250 |
int line_no = (d->regs.dc_csr >> |
int line_no = (d->regs.dc_csr >> |
266 |
odata = d->regs.dc_msr_tdr; |
odata = d->regs.dc_msr_tdr; |
267 |
} |
} |
268 |
break; |
break; |
269 |
|
|
270 |
default: |
default: |
271 |
if (writeflag==MEM_READ) { |
if (writeflag==MEM_READ) { |
272 |
debug("[ dc7085 read from 0x%08lx ]\n", |
debug("[ dc7085 read from 0x%08lx ]\n", |
302 |
{ |
{ |
303 |
struct dc_data *d; |
struct dc_data *d; |
304 |
|
|
305 |
d = malloc(sizeof(struct dc_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct dc_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
306 |
memset(d, 0, sizeof(struct dc_data)); |
memset(d, 0, sizeof(struct dc_data)); |
307 |
|
|
308 |
INTERRUPT_CONNECT(irq_path, d->irq); |
INTERRUPT_CONNECT(irq_path, d->irq); |
318 |
memory_device_register(mem, "dc7085", baseaddr, DEV_DC7085_LENGTH, |
memory_device_register(mem, "dc7085", baseaddr, DEV_DC7085_LENGTH, |
319 |
dev_dc7085_access, d, DM_DEFAULT, NULL); |
dev_dc7085_access, d, DM_DEFAULT, NULL); |
320 |
machine_add_tickfunction(machine, dev_dc7085_tick, d, |
machine_add_tickfunction(machine, dev_dc7085_tick, d, |
321 |
DC_TICK_SHIFT, 0.0); |
DC_TICK_SHIFT); |
322 |
|
|
323 |
return d->console_handle; |
return d->console_handle; |
324 |
} |
} |