/[gxemul]/trunk/src/devices/dev_dc7085.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/devices/dev_dc7085.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by dpavlin, Mon Oct 8 16:20:40 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2007  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:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_dc7085.c,v 1.56 2006/07/23 14:37:34 debug Exp $   *  $Id: dev_dc7085.c,v 1.60 2006/12/31 21:35:26 debug Exp $
29   *     *  
30   *  DC7085 serial controller, used in some DECstation models.   *  DC7085 serial controller, used in some DECstation models.
31   */   */
# Line 46  Line 46 
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;
# Line 63  struct dc_data { Line 63  struct dc_data {
63    
64          int                     tx_scanner;          int                     tx_scanner;
65    
66          int                     irqnr;          struct interrupt        irq;
67          int                     use_fb;          int                     use_fb;
68    
69          struct lk201_data       lk201;          struct lk201_data       lk201;
# Line 78  void add_to_rx_queue(void *e, int ch, in Line 78  void add_to_rx_queue(void *e, int ch, in
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    
# Line 130  DEVICE_TICK(dc7085) Line 131  DEVICE_TICK(dc7085)
131                          if (d->regs.dc_tcr & (1 << d->tx_scanner)) {                          if (d->regs.dc_tcr & (1 << d->tx_scanner)) {
132                                  d->regs.dc_csr |= CSR_TRDY;                                  d->regs.dc_csr |= CSR_TRDY;
133                                  if (d->regs.dc_csr & CSR_TIE)                                  if (d->regs.dc_csr & CSR_TIE)
134                                          cpu_interrupt(cpu, d->irqnr);                                          INTERRUPT_ASSERT(d->irq);
135    
136                                  d->regs.dc_csr &= ~CSR_TX_LINE_NUM;                                  d->regs.dc_csr &= ~CSR_TX_LINE_NUM;
137                                  d->regs.dc_csr |= (d->tx_scanner << 8);                                  d->regs.dc_csr |= (d->tx_scanner << 8);
# Line 146  DEVICE_TICK(dc7085) Line 147  DEVICE_TICK(dc7085)
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    
# Line 154  DEVICE_TICK(dc7085) Line 155  DEVICE_TICK(dc7085)
155                  d->regs.dc_csr |= CSR_RDONE;                  d->regs.dc_csr |= CSR_RDONE;
156    
157          if ((d->regs.dc_csr & CSR_RDONE) && (d->regs.dc_csr & CSR_RIE))          if ((d->regs.dc_csr & CSR_RDONE) && (d->regs.dc_csr & CSR_RIE))
158                  cpu_interrupt(cpu, d->irqnr);                  INTERRUPT_ASSERT(d->irq);
159  }  }
160    
161    
# Line 220  DEVICE_ACCESS(dc7085) Line 221  DEVICE_ACCESS(dc7085)
221                              (lineno << RBUF_LINE_NUM_SHIFT) | ch;                              (lineno << RBUF_LINE_NUM_SHIFT) | ch;
222    
223                          d->regs.dc_csr &= ~CSR_RDONE;                          d->regs.dc_csr &= ~CSR_RDONE;
224                          cpu_interrupt_ack(cpu, d->irqnr);                          INTERRUPT_DEASSERT(d->irq);
225    
226                          d->just_transmitted_something = 4;                          d->just_transmitted_something = 4;
227                  }                  }
# Line 231  DEVICE_ACCESS(dc7085) Line 232  DEVICE_ACCESS(dc7085)
232                              (int)idata);  */                              (int)idata);  */
233                          d->regs.dc_tcr = idata;                          d->regs.dc_tcr = idata;
234                          d->regs.dc_csr &= ~CSR_TRDY;                          d->regs.dc_csr &= ~CSR_TRDY;
235                          cpu_interrupt_ack(cpu, d->irqnr);                          INTERRUPT_DEASSERT(d->irq);
236                          goto do_return;                          goto do_return;
237                  } else {                  } else {
238                          /*  read:  */                          /*  read:  */
# Line 249  DEVICE_ACCESS(dc7085) Line 250  DEVICE_ACCESS(dc7085)
250                          lk201_tx_data(&d->lk201, line_no, idata);                          lk201_tx_data(&d->lk201, line_no, idata);
251    
252                          d->regs.dc_csr &= ~CSR_TRDY;                          d->regs.dc_csr &= ~CSR_TRDY;
253                          cpu_interrupt_ack(cpu, d->irqnr);                          INTERRUPT_DEASSERT(d->irq);
254    
255                          d->just_transmitted_something = 4;                          d->just_transmitted_something = 4;
256                  } else {                  } else {
# Line 292  do_return: Line 293  do_return:
293   *  DECstation keyboard, instead of a plain serial console.   *  DECstation keyboard, instead of a plain serial console.
294   */   */
295  int dev_dc7085_init(struct machine *machine, struct memory *mem,  int dev_dc7085_init(struct machine *machine, struct memory *mem,
296          uint64_t baseaddr, int irq_nr, int use_fb)          uint64_t baseaddr, char *irq_path, int use_fb)
297  {  {
298          struct dc_data *d;          struct dc_data *d;
299    
# Line 302  int dev_dc7085_init(struct machine *mach Line 303  int dev_dc7085_init(struct machine *mach
303                  exit(1);                  exit(1);
304          }          }
305          memset(d, 0, sizeof(struct dc_data));          memset(d, 0, sizeof(struct dc_data));
306          d->irqnr  = irq_nr;  
307            INTERRUPT_CONNECT(irq_path, d->irq);
308          d->use_fb = use_fb;          d->use_fb = use_fb;
309    
310          d->regs.dc_csr = CSR_TRDY | CSR_MSE;          d->regs.dc_csr = CSR_TRDY | CSR_MSE;

Legend:
Removed from v.30  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26