1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_dc7085.c,v 1.51 2005/11/13 00:14:08 debug Exp $ |
* $Id: dev_dc7085.c,v 1.58 2006/09/06 04:55:35 debug Exp $ |
29 |
* |
* |
30 |
* DC7085 serial controller, used in some DECstation models. |
* DC7085 serial controller, used in some DECstation models. |
31 |
*/ |
*/ |
46 |
|
|
47 |
#define DC_TICK_SHIFT 14 |
#define DC_TICK_SHIFT 14 |
48 |
|
|
49 |
#define MAX_QUEUE_LEN 4096 |
#define MAX_QUEUE_LEN 32768 |
50 |
|
|
51 |
struct dc_data { |
struct dc_data { |
52 |
struct dc7085regs regs; |
struct dc7085regs regs; |
78 |
struct dc_data *d = (struct dc_data *) e; |
struct dc_data *d = (struct dc_data *) e; |
79 |
int entries_in_use = d->cur_rx_queue_pos_write - |
int entries_in_use = d->cur_rx_queue_pos_write - |
80 |
d->cur_rx_queue_pos_read; |
d->cur_rx_queue_pos_read; |
81 |
|
|
82 |
while (entries_in_use < 0) |
while (entries_in_use < 0) |
83 |
entries_in_use += MAX_QUEUE_LEN; |
entries_in_use += MAX_QUEUE_LEN; |
84 |
|
|
97 |
} |
} |
98 |
|
|
99 |
|
|
100 |
/* |
DEVICE_TICK(dc7085) |
|
* dev_dc7085_tick(): |
|
|
* |
|
|
* This function is called "every now and then". |
|
|
* If a key is available from the keyboard, add it to the rx queue. |
|
|
* If other bits are set, an interrupt might need to be caused. |
|
|
*/ |
|
|
void dev_dc7085_tick(struct cpu *cpu, void *extra) |
|
101 |
{ |
{ |
102 |
|
/* |
103 |
|
* If a key is available from the keyboard, add it to the rx queue. |
104 |
|
* If other bits are set, an interrupt might need to be caused. |
105 |
|
*/ |
106 |
struct dc_data *d = extra; |
struct dc_data *d = extra; |
107 |
int avail; |
int avail; |
108 |
|
|
147 |
return; |
return; |
148 |
} |
} |
149 |
|
|
150 |
lk201_tick(&d->lk201); |
lk201_tick(cpu->machine, &d->lk201); |
151 |
|
|
152 |
avail = d->cur_rx_queue_pos_write != d->cur_rx_queue_pos_read; |
avail = d->cur_rx_queue_pos_write != d->cur_rx_queue_pos_read; |
153 |
|
|
159 |
} |
} |
160 |
|
|
161 |
|
|
162 |
/* |
DEVICE_ACCESS(dc7085) |
|
* dev_dc7085_access(): |
|
|
*/ |
|
|
int dev_dc7085_access(struct cpu *cpu, struct memory *mem, |
|
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
163 |
{ |
{ |
164 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
165 |
int i; |
size_t i; |
166 |
struct dc_data *d = extra; |
struct dc_data *d = extra; |
167 |
|
|
168 |
if (writeflag == MEM_WRITE) |
if (writeflag == MEM_WRITE) |
309 |
d->regs.dc_csr = CSR_TRDY | CSR_MSE; |
d->regs.dc_csr = CSR_TRDY | CSR_MSE; |
310 |
d->regs.dc_tcr = 0x00; |
d->regs.dc_tcr = 0x00; |
311 |
|
|
312 |
d->console_handle = console_start_slave(machine, "DC7085"); |
d->console_handle = console_start_slave(machine, "DC7085", 1); |
313 |
|
|
314 |
lk201_init(&d->lk201, use_fb, add_to_rx_queue, d->console_handle, d); |
lk201_init(&d->lk201, use_fb, add_to_rx_queue, d->console_handle, d); |
315 |
|
|
316 |
memory_device_register(mem, "dc7085", baseaddr, DEV_DC7085_LENGTH, |
memory_device_register(mem, "dc7085", baseaddr, DEV_DC7085_LENGTH, |
317 |
dev_dc7085_access, d, DM_DEFAULT, NULL); |
dev_dc7085_access, d, DM_DEFAULT, NULL); |
318 |
machine_add_tickfunction(machine, dev_dc7085_tick, d, DC_TICK_SHIFT); |
machine_add_tickfunction(machine, dev_dc7085_tick, d, |
319 |
|
DC_TICK_SHIFT, 0.0); |
320 |
|
|
321 |
return d->console_handle; |
return d->console_handle; |
322 |
} |
} |