/[dynamips]/upstream/dynamips-0.2.7-RC2/dev_c2600_iofpga.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 /upstream/dynamips-0.2.7-RC2/dev_c2600_iofpga.c

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

upstream/dynamips-0.2.7-RC1/dev_c2600_iofpga.c revision 7 by dpavlin, Sat Oct 6 16:23:47 2007 UTC upstream/dynamips-0.2.7-RC2/dev_c2600_iofpga.c revision 8 by dpavlin, Sat Oct 6 16:24:54 2007 UTC
# Line 19  Line 19 
19  #include "memory.h"  #include "memory.h"
20  #include "device.h"  #include "device.h"
21  #include "dev_vtty.h"  #include "dev_vtty.h"
22  #include "nmc93c46.h"  #include "nmc93cX6.h"
23  #include "dev_c2600.h"  #include "dev_c2600.h"
24    
25  /* Debugging flags */  /* Debugging flags */
26  #define DEBUG_UNKNOWN   1  #define DEBUG_UNKNOWN   1
27  #define DEBUG_ACCESS    0  #define DEBUG_ACCESS    0
28    #define DEBUG_NET_IRQ   0
29    
30  /* Definitions for Mainboard EEPROM */  /* Definitions for Mainboard EEPROM */
31  #define EEPROM_MB_DOUT  3  #define EEPROM_MB_DOUT  3
# Line 40  Line 41 
41    
42  #define C2691_NET_IRQ_CLEARING_DELAY  16  #define C2691_NET_IRQ_CLEARING_DELAY  16
43    
44    /* Network IRQ distribution */
45    static u_int net_irq_dist[C2600_MAX_NM_BAYS] = {
46       4,  /* reg 0x08, bits 4-5 */
47       0,  /* reg 0x08, bits 0-3 */
48    };
49    
50  /* IO FPGA structure */  /* IO FPGA structure */
51  struct iofpga_data {  struct c2600_iofpga_data {
52     vm_obj_t vm_obj;     vm_obj_t vm_obj;
53     struct vdevice dev;     struct vdevice dev;
54     c2600_t *router;     c2600_t *router;
55        
56     /*     /* Network Interrupt status */
57      * Used to introduce a "delay" before clearing the network interrupt     m_uint8_t net_irq_status;
     * on 3620/3640 platforms. Added due to a packet loss when using an  
     * Ethernet NM on these platforms.  
     *  
     * Anyway, we should rely on the device information with appropriate IRQ  
     * routing.  
     */  
    int net_irq_clearing_count;  
58    
59     /* Interrupt mask*/     /* Interrupt mask */
60     m_uint16_t intr_mask;     m_uint16_t intr_mask;
61  };  };
62    
63  /* Mainboard EEPROM definition */  /* Mainboard EEPROM definition */
64  static const struct nmc93c46_eeprom_def eeprom_mb_def = {  static const struct nmc93cX6_eeprom_def eeprom_mb_def = {
65     EEPROM_MB_CLK, EEPROM_MB_CS,     EEPROM_MB_CLK, EEPROM_MB_CS,
66     EEPROM_MB_DIN, EEPROM_MB_DOUT,     EEPROM_MB_DIN, EEPROM_MB_DOUT,
67  };  };
68    
69  /* Mainboard EEPROM */  /* Mainboard EEPROM */
70  static const struct nmc93c46_group eeprom_mb_group = {  static const struct nmc93cX6_group eeprom_mb_group = {
71     1, 0, "Mainboard EEPROM", 0, { &eeprom_mb_def },     EEPROM_TYPE_NMC93C46, 1, 0, "Mainboard EEPROM", 0, { &eeprom_mb_def },
72  };  };
73    
74  /* NM EEPROM definition */  /* NM EEPROM definition */
75  static const struct nmc93c46_eeprom_def eeprom_nm_def = {  static const struct nmc93cX6_eeprom_def eeprom_nm_def = {
76     EEPROM_NM_CLK, EEPROM_NM_CS,     EEPROM_NM_CLK, EEPROM_NM_CS,
77     EEPROM_NM_DIN, EEPROM_NM_DOUT,     EEPROM_NM_DIN, EEPROM_NM_DOUT,
78  };  };
79    
80  /* NM EEPROM */  /* NM EEPROM */
81  static const struct nmc93c46_group eeprom_nm_group = {  static const struct nmc93cX6_group eeprom_nm_group = {
82     1, 0, "NM EEPROM", 0, { &eeprom_nm_def },     EEPROM_TYPE_NMC93C46, 1, 0, "NM EEPROM", 0, { &eeprom_nm_def },
83  };  };
84    
85    /* Update network interrupt status */
86    static inline void dev_c2600_iofpga_net_update_irq(struct c2600_iofpga_data *d)
87    {
88       if (d->net_irq_status) {
89          vm_set_irq(d->router->vm,C2600_NETIO_IRQ);
90       } else {
91          vm_clear_irq(d->router->vm,C2600_NETIO_IRQ);
92       }
93    }
94    
95    /* Trigger a Network IRQ for the specified slot/port */
96    void dev_c2600_iofpga_net_set_irq(struct c2600_iofpga_data *d,
97                                      u_int slot,u_int port)
98    {
99    #if DEBUG_NET_IRQ
100       vm_log(d->router->vm,"IO_FPGA","setting NetIRQ for slot %u port %u\n",
101              slot,port);
102    #endif
103       d->net_irq_status |= 1 << (net_irq_dist[slot] + port);
104       dev_c2600_iofpga_net_update_irq(d);
105    }
106    
107    /* Clear a Network IRQ for the specified slot/port */
108    void dev_c2600_iofpga_net_clear_irq(struct c2600_iofpga_data *d,
109                                        u_int slot,u_int port)
110    {
111    #if DEBUG_NET_IRQ
112       vm_log(d->router->vm,"IO_FPGA","clearing NetIRQ for slot %u port %u\n",
113              slot,port);
114    #endif
115       d->net_irq_status &= ~(1 << (net_irq_dist[slot] + port));
116       dev_c2600_iofpga_net_update_irq(d);
117    }
118    
119  /*  /*
120   * dev_c2600_iofpga_access()   * dev_c2600_iofpga_access()
121   */   */
# Line 90  dev_c2600_iofpga_access(cpu_gen_t *cpu,s Line 124  dev_c2600_iofpga_access(cpu_gen_t *cpu,s
124                          m_uint32_t offset,u_int op_size,u_int op_type,                          m_uint32_t offset,u_int op_size,u_int op_type,
125                          m_uint64_t *data)                          m_uint64_t *data)
126  {  {
127     struct iofpga_data *d = dev->priv_data;     struct c2600_iofpga_data *d = dev->priv_data;
128    
129     if (op_type == MTS_READ)     if (op_type == MTS_READ)
130        *data = 0x0;        *data = 0x0;
# Line 110  dev_c2600_iofpga_access(cpu_gen_t *cpu,s Line 144  dev_c2600_iofpga_access(cpu_gen_t *cpu,s
144        case 0x04:        case 0x04:
145           if (op_type == MTS_READ)           if (op_type == MTS_READ)
146              *data = 0x00;              *data = 0x00;
          //vm_clear_irq(cpu->vm,C2600_NETIO_IRQ);  
147           break;           break;
148    
149        /*        /*
150         * Network Interrupt.         * Network Interrupt.
151         *         *
152         * Bit 0: slot 1.         * Bit 0-3: slot 1.
153         * Bit 4: slot 0 (MB), port 0         * Bit 4: slot 0 (MB), port 0
154         * Bit 5: slot 0 (MB), port 1         * Bit 5: slot 0 (MB), port 1
155         * Other: AIM ? (error messages displayed)         * Other: AIM ? (error messages displayed)
156         */         */
157        case 0x08:        case 0x08:
158           if (op_type == MTS_READ)           if (op_type == MTS_READ)
159              *data = 0x31;              *data = d->net_irq_status;
          vm_clear_irq(cpu->vm,C2600_NETIO_IRQ);  
160           break;           break;
161    
162        case 0x10:        case 0x10:
# Line 133  dev_c2600_iofpga_access(cpu_gen_t *cpu,s Line 165  dev_c2600_iofpga_access(cpu_gen_t *cpu,s
165              *data = 0xFFFFFFFF;              *data = 0xFFFFFFFF;
166           break;           break;
167    
168        /* Flash Related: 0x1y */        /*
169           * Flash Related: 0x1y
170           *
171           * Bit 1: card present in slot 0 / WIC 0.
172           * Bit 2: card present in slot 0 / WIC 1.
173           *
174           * Other bits unknown.
175           */
176  #if 1  #if 1
177        case 0x0c:        case 0x0c:
178           if (op_type == MTS_READ)           if (op_type == MTS_READ)
179              *data = 0x10;              *data = 0x10; //0x10;
180           break;           break;
181  #endif  #endif
182    
183        /* NM EEPROM */        /* NM EEPROM */
184        case 0x1c:        case 0x1c:
185           if (op_type == MTS_WRITE)           if (op_type == MTS_WRITE)
186              nmc93c46_write(&d->router->nm_eeprom_group,(u_int)(*data));              nmc93cX6_write(&d->router->nm_eeprom_group,(u_int)(*data));
187           else           else
188              *data = nmc93c46_read(&d->router->nm_eeprom_group);              *data = nmc93cX6_read(&d->router->nm_eeprom_group);
189           break;           break;
190    
191  #if DEBUG_UNKNOWN  #if DEBUG_UNKNOWN
# Line 182  void c2600_init_eeprom_groups(c2600_t *r Line 221  void c2600_init_eeprom_groups(c2600_t *r
221  }  }
222    
223  /* Shutdown the IO FPGA device */  /* Shutdown the IO FPGA device */
224  void dev_c2600_iofpga_shutdown(vm_instance_t *vm,struct iofpga_data *d)  static void
225    dev_c2600_iofpga_shutdown(vm_instance_t *vm,struct c2600_iofpga_data *d)
226  {  {
227     if (d != NULL) {     if (d != NULL) {
228        /* Remove the device */        /* Remove the device */
# Line 199  void dev_c2600_iofpga_shutdown(vm_instan Line 239  void dev_c2600_iofpga_shutdown(vm_instan
239  int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len)  int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len)
240  {  {
241     vm_instance_t *vm = router->vm;     vm_instance_t *vm = router->vm;
242     struct iofpga_data *d;     struct c2600_iofpga_data *d;
243    
244     /* Allocate private data structure */     /* Allocate private data structure */
245     if (!(d = malloc(sizeof(*d)))) {     if (!(d = malloc(sizeof(*d)))) {

Legend:
Removed from v.7  
changed lines
  Added in v.8

  ViewVC Help
Powered by ViewVC 1.1.26