/[dynamips]/upstream/dynamips-0.2.8-RC1/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.8-RC1/dev_c2600_iofpga.c

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

upstream/dynamips-0.2.7/dev_c2600_iofpga.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC upstream/dynamips-0.2.8-RC1/dev_c2600_iofpga.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 20  Line 20 
20  #include "device.h"  #include "device.h"
21  #include "dev_vtty.h"  #include "dev_vtty.h"
22  #include "nmc93cX6.h"  #include "nmc93cX6.h"
23    #include "dev_mpc860.h"
24  #include "dev_c2600.h"  #include "dev_c2600.h"
25    
26  /* Debugging flags */  /* Debugging flags */
# Line 58  struct c2600_iofpga_data { Line 59  struct c2600_iofpga_data {
59    
60     /* Interrupt mask */     /* Interrupt mask */
61     m_uint16_t intr_mask;     m_uint16_t intr_mask;
62    
63       /* WIC SPI selection */
64       m_uint8_t wic_select;
65  };  };
66    
67  /* Mainboard EEPROM definition */  /* Mainboard EEPROM definition */
# Line 68  static const struct nmc93cX6_eeprom_def Line 72  static const struct nmc93cX6_eeprom_def
72    
73  /* Mainboard EEPROM */  /* Mainboard EEPROM */
74  static const struct nmc93cX6_group eeprom_mb_group = {  static const struct nmc93cX6_group eeprom_mb_group = {
75     EEPROM_TYPE_NMC93C46, 1, 0, "Mainboard EEPROM", 0, { &eeprom_mb_def },     EEPROM_TYPE_NMC93C46, 1, 0,
76       EEPROM_DORD_NORMAL,
77       EEPROM_DOUT_HIGH,
78       EEPROM_DEBUG_DISABLED,
79       "Mainboard EEPROM",
80       { &eeprom_mb_def },
81  };  };
82    
83  /* NM EEPROM definition */  /* NM EEPROM definition */
# Line 79  static const struct nmc93cX6_eeprom_def Line 88  static const struct nmc93cX6_eeprom_def
88    
89  /* NM EEPROM */  /* NM EEPROM */
90  static const struct nmc93cX6_group eeprom_nm_group = {  static const struct nmc93cX6_group eeprom_nm_group = {
91     EEPROM_TYPE_NMC93C46, 1, 0, "NM EEPROM", 0, { &eeprom_nm_def },     EEPROM_TYPE_NMC93C46, 1, 0,
92       EEPROM_DORD_NORMAL,
93       EEPROM_DOUT_HIGH,
94       EEPROM_DEBUG_DISABLED,
95       "NM EEPROM",
96       { &eeprom_nm_def },
97  };  };
98    
99  /* Update network interrupt status */  /* Update network interrupt status */
# Line 116  void dev_c2600_iofpga_net_clear_irq(stru Line 130  void dev_c2600_iofpga_net_clear_irq(stru
130     dev_c2600_iofpga_net_update_irq(d);     dev_c2600_iofpga_net_update_irq(d);
131  }  }
132    
133    /* Callback for MPC860 SPI Transmit */
134    static void dev_c2600_mpc860_spi_tx_callback(struct mpc860_data *mpc_data,
135                                                 u_char *buffer,u_int len,
136                                                 void *user_arg)
137    {
138       struct c2600_iofpga_data *d = user_arg;
139       struct cisco_eeprom *eeprom;
140       u_char reply_buf[4];
141       u_int wic_port;
142       u_int eeprom_offset;
143    
144       if (d->wic_select & 0x20)
145          wic_port = 0x10;
146       else if (d->wic_select & 0x08)
147          wic_port = 0x20;
148       else {
149          vm_error(d->router->vm,"unknown value for wic_select (0x%8.8x)\n",
150                   d->wic_select);
151          wic_port = 0;
152       }
153    
154       /* No WIC in slot or no EEPROM: fake an empty EEPROM */
155       if (!wic_port || !(eeprom = vm_slot_get_eeprom(d->router->vm,0,wic_port))) {
156          memset(reply_buf,0xFF,sizeof(reply_buf));
157          mpc860_spi_receive(mpc_data,reply_buf,sizeof(reply_buf));
158          return;
159       }
160    
161       /* Read request: 0x03 offset 0x00 0x00 */
162       eeprom_offset = buffer[1];
163    
164       reply_buf[0] = 0;
165       reply_buf[1] = 0;
166       cisco_eeprom_get_byte(eeprom,eeprom_offset,&reply_buf[2]);
167       cisco_eeprom_get_byte(eeprom,eeprom_offset+1,&reply_buf[3]);
168    
169       mpc860_spi_receive(mpc_data,reply_buf,sizeof(reply_buf));
170    }
171        
172  /*  /*
173   * dev_c2600_iofpga_access()   * dev_c2600_iofpga_access()
174   */   */
# Line 160  dev_c2600_iofpga_access(cpu_gen_t *cpu,s Line 213  dev_c2600_iofpga_access(cpu_gen_t *cpu,s
213           break;           break;
214    
215        case 0x10:        case 0x10:
216             if (op_type == MTS_READ)
217                *data = d->wic_select;
218             else {
219                d->wic_select = *data;
220             }
221             break;
222    
223        case 0x14:        case 0x14:
224           if (op_type == MTS_READ)           if (op_type == MTS_READ)
225              *data = 0xFFFFFFFF;              *data = 0; //0xFFFFFFFF;
226           break;           break;
227    
228        /*        /*
# Line 173  dev_c2600_iofpga_access(cpu_gen_t *cpu,s Line 233  dev_c2600_iofpga_access(cpu_gen_t *cpu,s
233         *         *
234         * Other bits unknown.         * Other bits unknown.
235         */         */
 #if 1  
236        case 0x0c:        case 0x0c:
237           if (op_type == MTS_READ)           if (op_type == MTS_READ) {
238              *data = 0x10; //0x10;              *data = 0x10;
239    
240                /* check WIC 0 */
241                if (vm_slot_check_eeprom(d->router->vm,0,0x10))
242                   *data |= 0x02;
243    
244                /* check WIC 1 */
245                if (vm_slot_check_eeprom(d->router->vm,0,0x20))
246                   *data |= 0x04;
247             }
248           break;           break;
 #endif  
249    
250        /* NM EEPROM */        /* NM EEPROM */
251        case 0x1c:        case 0x1c:
# Line 206  dev_c2600_iofpga_access(cpu_gen_t *cpu,s Line 273  dev_c2600_iofpga_access(cpu_gen_t *cpu,s
273     return NULL;     return NULL;
274  }  }
275    
 /* Initialize EEPROM groups */  
 void c2600_init_eeprom_groups(c2600_t *router)  
 {  
    /* Initialize Mainboard EEPROM */  
    router->mb_eeprom_group = eeprom_mb_group;  
    router->mb_eeprom_group.eeprom[0] = &router->mb_eeprom;  
    router->mb_eeprom.data = NULL;  
    router->mb_eeprom.len  = 0;  
   
    /* EEPROM for NM slot 1 */  
    router->nm_eeprom_group = eeprom_nm_group;  
    router->nm_eeprom_group.eeprom[0] = &router->nm_bay[1].eeprom;  
 }  
   
276  /* Shutdown the IO FPGA device */  /* Shutdown the IO FPGA device */
277  static void  static void
278  dev_c2600_iofpga_shutdown(vm_instance_t *vm,struct c2600_iofpga_data *d)  dev_c2600_iofpga_shutdown(vm_instance_t *vm,struct c2600_iofpga_data *d)
# Line 263  int dev_c2600_iofpga_init(c2600_t *route Line 316  int dev_c2600_iofpga_init(c2600_t *route
316     d->dev.priv_data = d;     d->dev.priv_data = d;
317     d->dev.handler   = dev_c2600_iofpga_access;     d->dev.handler   = dev_c2600_iofpga_access;
318    
319       /* Initialize the MPC860 SPI TX callback to read mainboard WIC EEPROMs */
320       mpc860_spi_set_tx_callback(router->mpc_data,
321                                  dev_c2600_mpc860_spi_tx_callback,d);
322                                  
323     /* Map this device to the VM */     /* Map this device to the VM */
324     vm_bind_device(router->vm,&d->dev);     vm_bind_device(router->vm,&d->dev);
325     vm_object_add(vm,&d->vm_obj);     vm_object_add(vm,&d->vm_obj);
326     return(0);     return(0);
327  }  }
328    
329    /* Initialize EEPROM groups */
330    void c2600_init_eeprom_groups(c2600_t *router)
331    {
332       /* Initialize Mainboard EEPROM */
333       router->mb_eeprom_group = eeprom_mb_group;
334       router->mb_eeprom_group.eeprom[0] = &router->mb_eeprom;
335       router->mb_eeprom.data = NULL;
336       router->mb_eeprom.len  = 0;
337    
338       /* EEPROM for NM slot 1 */
339       router->nm_eeprom_group = eeprom_nm_group;
340    }

Legend:
Removed from v.10  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.26