--- trunk/src/devices/dev_dc7085.c 2007/10/08 16:19:11 18 +++ trunk/src/devices/dev_dc7085.c 2007/10/08 16:21:17 34 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2005 Anders Gavare. All rights reserved. + * Copyright (C) 2003-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_dc7085.c,v 1.50 2005/10/26 14:37:03 debug Exp $ + * $Id: dev_dc7085.c,v 1.60 2006/12/31 21:35:26 debug Exp $ * * DC7085 serial controller, used in some DECstation models. */ @@ -46,7 +46,7 @@ #define DC_TICK_SHIFT 14 -#define MAX_QUEUE_LEN 4096 +#define MAX_QUEUE_LEN 32768 struct dc_data { struct dc7085regs regs; @@ -63,7 +63,7 @@ int tx_scanner; - int irqnr; + struct interrupt irq; int use_fb; struct lk201_data lk201; @@ -78,6 +78,7 @@ struct dc_data *d = (struct dc_data *) e; int entries_in_use = d->cur_rx_queue_pos_write - d->cur_rx_queue_pos_read; + while (entries_in_use < 0) entries_in_use += MAX_QUEUE_LEN; @@ -96,15 +97,12 @@ } -/* - * 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) +DEVICE_TICK(dc7085) { + /* + * 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. + */ struct dc_data *d = extra; int avail; @@ -133,7 +131,7 @@ if (d->regs.dc_tcr & (1 << d->tx_scanner)) { d->regs.dc_csr |= CSR_TRDY; if (d->regs.dc_csr & CSR_TIE) - cpu_interrupt(cpu, d->irqnr); + INTERRUPT_ASSERT(d->irq); d->regs.dc_csr &= ~CSR_TX_LINE_NUM; d->regs.dc_csr |= (d->tx_scanner << 8); @@ -149,7 +147,7 @@ return; } - lk201_tick(&d->lk201); + lk201_tick(cpu->machine, &d->lk201); avail = d->cur_rx_queue_pos_write != d->cur_rx_queue_pos_read; @@ -157,19 +155,14 @@ d->regs.dc_csr |= CSR_RDONE; if ((d->regs.dc_csr & CSR_RDONE) && (d->regs.dc_csr & CSR_RIE)) - cpu_interrupt(cpu, d->irqnr); + INTERRUPT_ASSERT(d->irq); } -/* - * 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) +DEVICE_ACCESS(dc7085) { uint64_t idata = 0, odata = 0; - int i; + size_t i; struct dc_data *d = extra; if (writeflag == MEM_WRITE) @@ -228,7 +221,7 @@ (lineno << RBUF_LINE_NUM_SHIFT) | ch; d->regs.dc_csr &= ~CSR_RDONE; - cpu_interrupt_ack(cpu, d->irqnr); + INTERRUPT_DEASSERT(d->irq); d->just_transmitted_something = 4; } @@ -239,7 +232,7 @@ (int)idata); */ d->regs.dc_tcr = idata; d->regs.dc_csr &= ~CSR_TRDY; - cpu_interrupt_ack(cpu, d->irqnr); + INTERRUPT_DEASSERT(d->irq); goto do_return; } else { /* read: */ @@ -257,7 +250,7 @@ lk201_tx_data(&d->lk201, line_no, idata); d->regs.dc_csr &= ~CSR_TRDY; - cpu_interrupt_ack(cpu, d->irqnr); + INTERRUPT_DEASSERT(d->irq); d->just_transmitted_something = 4; } else { @@ -300,7 +293,7 @@ * DECstation keyboard, instead of a plain serial console. */ int dev_dc7085_init(struct machine *machine, struct memory *mem, - uint64_t baseaddr, int irq_nr, int use_fb) + uint64_t baseaddr, char *irq_path, int use_fb) { struct dc_data *d; @@ -310,19 +303,21 @@ exit(1); } memset(d, 0, sizeof(struct dc_data)); - d->irqnr = irq_nr; + + INTERRUPT_CONNECT(irq_path, d->irq); d->use_fb = use_fb; d->regs.dc_csr = CSR_TRDY | CSR_MSE; d->regs.dc_tcr = 0x00; - d->console_handle = console_start_slave(machine, "DC7085"); + d->console_handle = console_start_slave(machine, "DC7085", 1); lk201_init(&d->lk201, use_fb, add_to_rx_queue, d->console_handle, d); memory_device_register(mem, "dc7085", baseaddr, DEV_DC7085_LENGTH, - dev_dc7085_access, d, MEM_DEFAULT, NULL); - machine_add_tickfunction(machine, dev_dc7085_tick, d, DC_TICK_SHIFT); + dev_dc7085_access, d, DM_DEFAULT, NULL); + machine_add_tickfunction(machine, dev_dc7085_tick, d, + DC_TICK_SHIFT, 0.0); return d->console_handle; }