/[gxemul]/trunk/src/devices/dev_ssc.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_ssc.c

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

revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  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_ssc.c,v 1.24 2005/11/13 00:14:10 debug Exp $   *  $Id: dev_ssc.c,v 1.31 2007/06/15 19:57:34 debug Exp $
29   *     *
30     *  COMMENT: System Support Chip serial controller
31     *
32   *  Serial controller on DECsystem 5400 and 5800.   *  Serial controller on DECsystem 5400 and 5800.
33   *  Known as System Support Chip on VAX 3600 (KA650).   *  Known as System Support Chip on VAX 3600 (KA650).
34   *   *
# Line 50  Line 52 
52  #define TX_INT_ENABLE   0x40  #define TX_INT_ENABLE   0x40
53  #define TX_READY        0x80  #define TX_READY        0x80
54    
55    #define SSC_TICK_SHIFT  14
56    
57  /*  /*
58   *  _TXRX is for debugging putchar/getchar. The other   *  _TXRX is for debugging putchar/getchar. The other
# Line 59  Line 62 
62  #define SSC_DEBUG  #define SSC_DEBUG
63    
64  struct ssc_data {  struct ssc_data {
         int             irq_nr;  
65          int             console_handle;          int             console_handle;
66          int             use_fb;          int             use_fb;
67    
68          int             rx_ctl;          int             rx_ctl;
69          int             tx_ctl;          int             tx_ctl;
70    
71          uint32_t        *csrp;          struct interrupt irq;
72  };  };
73    
74    
75  /*  DEVICE_TICK(ssc)
  *  dev_ssc_tick():  
  */  
 void dev_ssc_tick(struct cpu *cpu, void *extra)  
76  {  {
77          struct ssc_data *d = extra;          struct ssc_data *d = extra;
78    
# Line 86  void dev_ssc_tick(struct cpu *cpu, void Line 85  void dev_ssc_tick(struct cpu *cpu, void
85          /*  rx interrupts enabled, and char avail?  */          /*  rx interrupts enabled, and char avail?  */
86          if (d->rx_ctl & RX_INT_ENABLE && d->rx_ctl & RX_AVAIL) {          if (d->rx_ctl & RX_INT_ENABLE && d->rx_ctl & RX_AVAIL) {
87                  /*  TODO:  This is for 5800 only!  */                  /*  TODO:  This is for 5800 only!  */
88                    unsigned char txvector = 0xf8;
89                  if (d->csrp != NULL) {                  cpu->memory_rw(cpu, cpu->mem, 0x40000050, &txvector,
90                          unsigned char txvector = 0xf8;                      1, MEM_WRITE, NO_EXCEPTIONS | PHYSICAL);
91                          (*d->csrp) |= 0x10000000;                  INTERRUPT_ASSERT(d->irq);
                         cpu->memory_rw(cpu, cpu->mem, 0x40000050, &txvector,  
                             1, MEM_WRITE, NO_EXCEPTIONS | PHYSICAL);  
                         cpu_interrupt(cpu, 2);  
                 }  
92          }          }
93    
94          /*  tx interrupts enabled?  */          /*  tx interrupts enabled?  */
95          if (d->tx_ctl & TX_INT_ENABLE) {          if (d->tx_ctl & TX_INT_ENABLE) {
96                  /*  TODO:  This is for 5800 only!  */                  /*  TODO:  This is for 5800 only!  */
97                    unsigned char txvector = 0xfc;
98                  if (d->csrp != NULL) {                  cpu->memory_rw(cpu, cpu->mem, 0x40000050, &txvector,
99                          unsigned char txvector = 0xfc;                      1, MEM_WRITE, NO_EXCEPTIONS | PHYSICAL);
100                          (*d->csrp) |= 0x10000000;                  INTERRUPT_ASSERT(d->irq);
                         cpu->memory_rw(cpu, cpu->mem, 0x40000050, &txvector,  
                             1, MEM_WRITE, NO_EXCEPTIONS | PHYSICAL);  
                         cpu_interrupt(cpu, 2);  
                 }  
101          }          }
102  }  }
103    
104    
105  /*  DEVICE_ACCESS(ssc)
  *  dev_ssc_access():  
  */  
 int dev_ssc_access(struct cpu *cpu, struct memory *mem,  
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
106  {  {
107          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
108          struct ssc_data *d = extra;          struct ssc_data *d = extra;
# Line 137  int dev_ssc_access(struct cpu *cpu, stru Line 123  int dev_ssc_access(struct cpu *cpu, stru
123                  } else {                  } else {
124                          d->rx_ctl = idata;                          d->rx_ctl = idata;
125    
126                          /*  TODO:  This only works for 5800  */                          INTERRUPT_DEASSERT(d->irq);
127                          if (d->csrp != NULL) {  
                                 (*d->csrp) &= ~0x10000000;  
                                 cpu_interrupt_ack(cpu, 2);  
                         }  
128  #ifdef SSC_DEBUG_TXRX  #ifdef SSC_DEBUG_TXRX
129                          debug("[ ssc: write to  0x%08lx: 0x%02x ]\n",                          debug("[ ssc: write to  0x%08lx: 0x%02x ]\n",
130                              (long)relative_addr, (int)idata);                              (long)relative_addr, (int)idata);
# Line 175  int dev_ssc_access(struct cpu *cpu, stru Line 158  int dev_ssc_access(struct cpu *cpu, stru
158                  } else {                  } else {
159                          d->tx_ctl = idata;                          d->tx_ctl = idata;
160    
161                          /*  TODO:  This only works for 5800  */                          INTERRUPT_DEASSERT(d->irq);
162                          if (d->csrp != NULL) {  
                                 (*d->csrp) &= ~0x10000000;  
                                 cpu_interrupt_ack(cpu, 2);  
                         }  
163  #ifdef SSC_DEBUG_TXRX  #ifdef SSC_DEBUG_TXRX
164                          debug("[ ssc: write to  0x%08lx: 0x%02x ]\n",                          debug("[ ssc: write to  0x%08lx: 0x%02x ]\n",
165                              (long)relative_addr, (int)idata);                              (long)relative_addr, (int)idata);
# Line 244  int dev_ssc_access(struct cpu *cpu, stru Line 224  int dev_ssc_access(struct cpu *cpu, stru
224  }  }
225    
226    
 /*  
  *  dev_ssc_init():  
  */  
227  void dev_ssc_init(struct machine *machine, struct memory *mem,  void dev_ssc_init(struct machine *machine, struct memory *mem,
228          uint64_t baseaddr, int irq_nr, int use_fb, uint32_t *csrp)          uint64_t baseaddr, char *irq_path, int use_fb)
229  {  {
230          struct ssc_data *d;          struct ssc_data *d;
231    
232          d = malloc(sizeof(struct ssc_data));          CHECK_ALLOCATION(d = malloc(sizeof(struct ssc_data)));
         if (d == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
233          memset(d, 0, sizeof(struct ssc_data));          memset(d, 0, sizeof(struct ssc_data));
234          d->irq_nr = irq_nr;  
235          d->use_fb = use_fb;          d->use_fb = use_fb;
236          d->csrp   = csrp;          d->console_handle = console_start_slave(machine, "SSC", 1);
237          d->console_handle = console_start_slave(machine, "SSC");  
238            INTERRUPT_CONNECT(irq_path, d->irq);
239    
240          memory_device_register(mem, "ssc", baseaddr, DEV_SSC_LENGTH,          memory_device_register(mem, "ssc", baseaddr, DEV_SSC_LENGTH,
241              dev_ssc_access, d, DM_DEFAULT, NULL);              dev_ssc_access, d, DM_DEFAULT, NULL);
242    
243          machine_add_tickfunction(machine, dev_ssc_tick, d, 14);          machine_add_tickfunction(machine, dev_ssc_tick, d, SSC_TICK_SHIFT);
244  }  }
245    

Legend:
Removed from v.20  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26