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

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

upstream/dynamips-0.2.7/dev_c7200_eth.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC upstream/dynamips-0.2.8-RC1/dev_c7200_eth.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 43  static const struct cisco_eeprom eeprom_ Line 43  static const struct cisco_eeprom eeprom_
43   *   *
44   * Add an IOcard into slot 0.   * Add an IOcard into slot 0.
45   */   */
46  static int dev_c7200_iocard_init(c7200_t *router,char *name,u_int pa_bay)  static int dev_c7200_iocard_init(vm_instance_t *vm,struct cisco_card *card)
47  {  {
48     struct dec21140_data *data;     struct dec21140_data *data;
49         u_int slot = card->slot_id;
50     if (pa_bay != 0) {  
51        fprintf(stderr,"C7200 '%s': cannot put IOCARD in PA bay %u!\n",     if (slot != 0) {
52                router->vm->name,pa_bay);        vm_error(vm,"cannot put IOCARD in PA bay %u!\n",slot);
53        return(-1);        return(-1);
54     }     }
55    
56       /* Set the PCI bus */
57       card->pci_bus = vm->slots_pci_bus[slot];
58    
59     /* Set the EEPROM */     /* Set the EEPROM */
60     c7200_pa_set_eeprom(router,pa_bay,&eeprom_c7200_io_fe);     cisco_card_set_eeprom(vm,card,&eeprom_c7200_io_fe);
61       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
62    
63     /* Create the DEC21140 chip */     /* Create the DEC21140 chip */
64     data = dev_dec21140_init(router->vm,name,     data = dev_dec21140_init(vm,card->dev_name,
65                              router->pa_bay[pa_bay].pci_map,                              card->pci_bus,
66                              router->npe_driver->dec21140_pci_dev,                              VM_C7200(vm)->npe_driver->dec21140_pci_dev,
67                              c7200_net_irq_for_slot_port(pa_bay,0));                              c7200_net_irq_for_slot_port(slot,0));
68     if (!data) return(-1);     if (!data) return(-1);
69    
70     /* Store device info into the router structure */     /* Store device info into the router structure */
71     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
72       return(0);
73  }  }
74    
75  /* Remove an IOcard from slot 0 */  /* Remove an IOcard from slot 0 */
76  static int dev_c7200_iocard_shutdown(c7200_t *router,u_int pa_bay)  static int dev_c7200_iocard_shutdown(vm_instance_t *vm,struct cisco_card *card)
77  {  {
78     struct c7200_pa_bay *bay;     /* Remove the PA EEPROM */
79       cisco_card_unset_eeprom(card);
80     if (!(bay = c7200_pa_get_info(router,pa_bay)))     c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL);
       return(-1);  
81    
82     c7200_pa_unset_eeprom(router,pa_bay);     /* Shutdown the DEC21140 */
83     dev_dec21140_remove(bay->drv_info);     dev_dec21140_remove(card->drv_info);
84     return(0);     return(0);
85  }  }
86    
87  /* Bind a Network IO descriptor */  /* Bind a Network IO descriptor */
88  static int dev_c7200_iocard_set_nio(c7200_t *router,u_int pa_bay,u_int port_id,  static int dev_c7200_iocard_set_nio(vm_instance_t *vm,struct cisco_card *card,
89                                      netio_desc_t *nio)                                      u_int port_id,netio_desc_t *nio)
90  {  {
91     struct dec21140_data *d;     struct dec21140_data *d = card->drv_info;
92    
93     if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay)))     if (!d || (port_id > 0))
94        return(-1);        return(-1);
95    
96     return(dev_dec21140_set_nio(d,nio));     return(dev_dec21140_set_nio(d,nio));
97  }  }
98    
99  /* Unbind a Network IO descriptor */  /* Unbind a Network IO descriptor */
100  static int dev_c7200_iocard_unset_nio(c7200_t *router,u_int pa_bay,  static int dev_c7200_iocard_unset_nio(vm_instance_t *vm,
101                                          struct cisco_card *card,
102                                        u_int port_id)                                        u_int port_id)
103  {  {
104     struct dec21140_data *d;     struct dec21140_data *d = card->drv_info;
105    
106     if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay)))     if (!d || (port_id > 0))
107        return(-1);        return(-1);
108        
109     dev_dec21140_unset_nio(d);     dev_dec21140_unset_nio(d);
# Line 110  static int dev_c7200_iocard_unset_nio(c7 Line 115  static int dev_c7200_iocard_unset_nio(c7
115   *   *
116   * Add a PA-FE-TX port adapter into specified slot.   * Add a PA-FE-TX port adapter into specified slot.
117   */   */
118  static int dev_c7200_pa_fe_tx_init(c7200_t *router,char *name,u_int pa_bay)  static int dev_c7200_pa_fe_tx_init(vm_instance_t *vm,struct cisco_card *card)
119  {  {
120     struct dec21140_data *data;     struct dec21140_data *data;
121       u_int slot = card->slot_id;
122    
123       /* Set the PCI bus */
124       card->pci_bus = vm->slots_pci_bus[slot];
125    
126     /* Set the EEPROM */     /* Set the EEPROM */
127     c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-FE-TX"));     cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-FE-TX"));
128       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
129    
130     /* Create the DEC21140 chip */     /* Create the DEC21140 chip */
131     data = dev_dec21140_init(router->vm,name,router->pa_bay[pa_bay].pci_map,0,     data = dev_dec21140_init(vm,card->dev_name,card->pci_bus,0,
132                              c7200_net_irq_for_slot_port(pa_bay,0));                              c7200_net_irq_for_slot_port(slot,0));
133     if (!data) return(-1);     if (!data) return(-1);
134    
135     /* Store device info into the router structure */     /* Store device info into the router structure */
136     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
137       return(0);
138  }  }
139    
140  /* Remove a PA-FE-TX from the specified slot */  /* Remove a PA-FE-TX from the specified slot */
141  static int dev_c7200_pa_fe_tx_shutdown(c7200_t *router,u_int pa_bay)  static int
142    dev_c7200_pa_fe_tx_shutdown(vm_instance_t *vm,struct cisco_card *card)
143  {  {
144     struct c7200_pa_bay *bay;     /* Remove the PA EEPROM */
145       cisco_card_unset_eeprom(card);
146     if (!(bay = c7200_pa_get_info(router,pa_bay)))     c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL);
       return(-1);  
147    
148     c7200_pa_unset_eeprom(router,pa_bay);     /* Shutdown the DEC21140 */
149     dev_dec21140_remove(bay->drv_info);     dev_dec21140_remove(card->drv_info);
150     return(0);     return(0);
151  }  }
152    
153  /* Bind a Network IO descriptor */  /* Bind a Network IO descriptor */
154  static int dev_c7200_pa_fe_tx_set_nio(c7200_t *router,u_int pa_bay,  static int
155                                        u_int port_id,netio_desc_t *nio)  dev_c7200_pa_fe_tx_set_nio(vm_instance_t *vm,struct cisco_card *card,
156                               u_int port_id,netio_desc_t *nio)
157  {  {
158     struct dec21140_data *d;     struct dec21140_data *d = card->drv_info;
159    
160     if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay)))     if (!d || (port_id > 0))
161        return(-1);        return(-1);
162      
163     return(dev_dec21140_set_nio(d,nio));     return(dev_dec21140_set_nio(d,nio));
164  }  }
165    
166  /* Unbind a Network IO descriptor */  /* Unbind a Network IO descriptor */
167  static int dev_c7200_pa_fe_tx_unset_nio(c7200_t *router,u_int pa_bay,  static int
168                                          u_int port_id)  dev_c7200_pa_fe_tx_unset_nio(vm_instance_t *vm,struct cisco_card *card,
169                                 u_int port_id)
170  {  {
171     struct dec21140_data *d;     struct dec21140_data *d = card->drv_info;
172    
173     if ((port_id > 0) || !(d = c7200_pa_get_drvinfo(router,pa_bay)))     if (!d || (port_id > 0))
174        return(-1);        return(-1);
175        
176     dev_dec21140_unset_nio(d);     dev_dec21140_unset_nio(d);
# Line 165  static int dev_c7200_pa_fe_tx_unset_nio( Line 178  static int dev_c7200_pa_fe_tx_unset_nio(
178  }  }
179    
180  /* C7200-IO-FE driver */  /* C7200-IO-FE driver */
181  struct c7200_pa_driver dev_c7200_iocard_fe_driver = {  struct cisco_card_driver dev_c7200_iocard_fe_driver = {
182     "C7200-IO-FE", 1,     "C7200-IO-FE", 1, 0,
183     dev_c7200_iocard_init,     dev_c7200_iocard_init,
184     dev_c7200_iocard_shutdown,     dev_c7200_iocard_shutdown,
185       NULL,
186     dev_c7200_iocard_set_nio,     dev_c7200_iocard_set_nio,
187     dev_c7200_iocard_unset_nio,     dev_c7200_iocard_unset_nio,
188     NULL,     NULL,
189  };  };
190    
191  /* PA-FE-TX driver */  /* PA-FE-TX driver */
192  struct c7200_pa_driver dev_c7200_pa_fe_tx_driver = {  struct cisco_card_driver dev_c7200_pa_fe_tx_driver = {
193     "PA-FE-TX", 1,     "PA-FE-TX", 1, 0,
194     dev_c7200_pa_fe_tx_init,     dev_c7200_pa_fe_tx_init,
195     dev_c7200_pa_fe_tx_shutdown,     dev_c7200_pa_fe_tx_shutdown,
196       NULL,
197     dev_c7200_pa_fe_tx_set_nio,     dev_c7200_pa_fe_tx_set_nio,
198     dev_c7200_pa_fe_tx_unset_nio,     dev_c7200_pa_fe_tx_unset_nio,
199     NULL,     NULL,
# Line 194  struct pa_i8254x_data { Line 209  struct pa_i8254x_data {
209  };  };
210    
211  /* Remove a PA-2FE-TX from the specified slot */  /* Remove a PA-2FE-TX from the specified slot */
212  static int dev_c7200_pa_i8254x_shutdown(c7200_t *router,u_int pa_bay)  static int
213    dev_c7200_pa_i8254x_shutdown(vm_instance_t *vm,struct cisco_card *card)
214  {  {
215     struct c7200_pa_bay *bay;     struct pa_i8254x_data *data = card->drv_info;
    struct pa_i8254x_data *data;  
216     int i;     int i;
217    
    if (!(bay = c7200_pa_get_info(router,pa_bay)))  
       return(-1);  
   
    data = bay->drv_info;  
   
218     /* Remove the PA EEPROM */     /* Remove the PA EEPROM */
219     c7200_pa_unset_eeprom(router,pa_bay);     cisco_card_unset_eeprom(card);
220       c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL);
221    
222     /* Remove the AMD Am79c971 chips */     /* Remove the Intel i2854x chips */
223     for(i=0;i<data->nr_port;i++)     for(i=0;i<data->nr_port;i++)
224        dev_i8254x_remove(data->port[i]);        dev_i8254x_remove(data->port[i]);
225    
# Line 217  static int dev_c7200_pa_i8254x_shutdown( Line 228  static int dev_c7200_pa_i8254x_shutdown(
228  }  }
229    
230  /* Bind a Network IO descriptor */  /* Bind a Network IO descriptor */
231  static int dev_c7200_pa_i8254x_set_nio(c7200_t *router,u_int pa_bay,  static int
232                                         u_int port_id,netio_desc_t *nio)  dev_c7200_pa_i8254x_set_nio(vm_instance_t *vm,struct cisco_card *card,
233                                u_int port_id,netio_desc_t *nio)
234  {  {
235     struct pa_i8254x_data *d;     struct pa_i8254x_data *d = card->drv_info;
   
    d = c7200_pa_get_drvinfo(router,pa_bay);  
236    
237     if (!d || (port_id >= d->nr_port))     if (!d || (port_id >= d->nr_port))
238        return(-1);        return(-1);
# Line 232  static int dev_c7200_pa_i8254x_set_nio(c Line 242  static int dev_c7200_pa_i8254x_set_nio(c
242  }  }
243    
244  /* Unbind a Network IO descriptor */  /* Unbind a Network IO descriptor */
245  static int dev_c7200_pa_i8254x_unset_nio(c7200_t *router,u_int pa_bay,  static int
246                                           u_int port_id)  dev_c7200_pa_i8254x_unset_nio(vm_instance_t *vm,struct cisco_card *card,
247                                  u_int port_id)
248  {  {
249     struct pa_i8254x_data *d;     struct pa_i8254x_data *d = card->drv_info;
   
    d = c7200_pa_get_drvinfo(router,pa_bay);  
250    
251     if (!d || (port_id >= d->nr_port))     if (!d || (port_id >= d->nr_port))
252        return(-1);        return(-1);
# Line 255  static int dev_c7200_pa_i8254x_unset_nio Line 264  static int dev_c7200_pa_i8254x_unset_nio
264   *   *
265   * Add a PA-2FE-TX port adapter into specified slot.   * Add a PA-2FE-TX port adapter into specified slot.
266   */   */
267  static int dev_c7200_pa_2fe_tx_init(c7200_t *router,char *name,u_int pa_bay)  static int dev_c7200_pa_2fe_tx_init(vm_instance_t *vm,struct cisco_card *card)
268  {  {
269     struct pa_i8254x_data *data;     struct pa_i8254x_data *data;
270       u_int slot = card->slot_id;
271     int i;     int i;
272    
273     /* Allocate the private data structure for the PA-2FE-TX */     /* Allocate the private data structure for the PA-2FE-TX */
274     if (!(data = malloc(sizeof(*data)))) {     if (!(data = malloc(sizeof(*data)))) {
275        fprintf(stderr,"%s (PA-2FE-TX): out of memory\n",name);        vm_error(vm,"%s: out of memory\n",card->dev_name);
276        return(-1);        return(-1);
277     }     }
278    
# Line 270  static int dev_c7200_pa_2fe_tx_init(c720 Line 280  static int dev_c7200_pa_2fe_tx_init(c720
280     memset(data,0,sizeof(*data));     memset(data,0,sizeof(*data));
281     data->nr_port = 2;     data->nr_port = 2;
282    
283       /* Set the PCI bus */
284       card->pci_bus = vm->slots_pci_bus[slot];
285    
286     /* Set the EEPROM */     /* Set the EEPROM */
287     c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-2FE-TX"));     cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-2FE-TX"));
288       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
289    
290     /* Create the Intel i8254x chips */     /* Create the Intel i8254x chips */
291     for(i=0;i<data->nr_port;i++) {     for(i=0;i<data->nr_port;i++) {
292        data->port[i] = dev_i8254x_init(router->vm,name,0,        data->port[i] = dev_i8254x_init(vm,card->dev_name,0,
293                                        router->pa_bay[pa_bay].pci_map,i,                                        card->pci_bus,i,
294                                        c7200_net_irq_for_slot_port(pa_bay,i));                                        c7200_net_irq_for_slot_port(slot,i));
295     }     }
296    
297     /* Store device info into the router structure */     /* Store device info into the router structure */
298     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
299       return(0);
300  }  }
301    
302  /* PA-2FE-TX driver */  /* PA-2FE-TX driver */
303  struct c7200_pa_driver dev_c7200_pa_2fe_tx_driver = {  struct cisco_card_driver dev_c7200_pa_2fe_tx_driver = {
304     "PA-2FE-TX", 0,     "PA-2FE-TX", 0, 0,
305     dev_c7200_pa_2fe_tx_init,     dev_c7200_pa_2fe_tx_init,
306     dev_c7200_pa_i8254x_shutdown,     dev_c7200_pa_i8254x_shutdown,
307       NULL,
308     dev_c7200_pa_i8254x_set_nio,     dev_c7200_pa_i8254x_set_nio,
309     dev_c7200_pa_i8254x_unset_nio,     dev_c7200_pa_i8254x_unset_nio,
310     NULL,     NULL,
# Line 303  struct c7200_pa_driver dev_c7200_pa_2fe_ Line 319  struct c7200_pa_driver dev_c7200_pa_2fe_
319   *   *
320   * Add a PA-GE port adapter into specified slot.   * Add a PA-GE port adapter into specified slot.
321   */   */
322  static int dev_c7200_pa_ge_init(c7200_t *router,char *name,u_int pa_bay)  static int dev_c7200_pa_ge_init(vm_instance_t *vm,struct cisco_card *card)
323  {  {
324     struct pa_i8254x_data *data;     struct pa_i8254x_data *data;
325       u_int slot = card->slot_id;
326    
327     /* Allocate the private data structure for the PA-2FE-TX */     /* Allocate the private data structure for the PA-2FE-TX */
328     if (!(data = malloc(sizeof(*data)))) {     if (!(data = malloc(sizeof(*data)))) {
329        fprintf(stderr,"%s (PA-GE): out of memory\n",name);        vm_error(vm,"%s: out of memory\n",card->dev_name);
330        return(-1);        return(-1);
331     }     }
332    
# Line 317  static int dev_c7200_pa_ge_init(c7200_t Line 334  static int dev_c7200_pa_ge_init(c7200_t
334     memset(data,0,sizeof(*data));     memset(data,0,sizeof(*data));
335     data->nr_port = 1;     data->nr_port = 1;
336    
337       /* Set the PCI bus */
338       card->pci_bus = vm->slots_pci_bus[slot];
339    
340     /* Set the EEPROM */     /* Set the EEPROM */
341     c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-GE"));     cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-GE"));
342       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
343    
344     /* Create the Intel i8254x chip */     /* Create the Intel i8254x chip */
345     data->port[0] = dev_i8254x_init(router->vm,name,0,     data->port[0] = dev_i8254x_init(vm,card->dev_name,0,
346                                     router->pa_bay[pa_bay].pci_map,0,                                     card->pci_bus,0,
347                                     c7200_net_irq_for_slot_port(pa_bay,0));                                     c7200_net_irq_for_slot_port(slot,0));
348    
349     /* Store device info into the router structure */     /* Store device info into the router structure */
350     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
351       return(0);
352  }  }
353    
354  /* PA-GE driver */  /* PA-GE driver */
355  struct c7200_pa_driver dev_c7200_pa_ge_driver = {  struct cisco_card_driver dev_c7200_pa_ge_driver = {
356     "PA-GE", 0,     "PA-GE", 0, 0,
357     dev_c7200_pa_ge_init,     dev_c7200_pa_ge_init,
358     dev_c7200_pa_i8254x_shutdown,     dev_c7200_pa_i8254x_shutdown,
359       NULL,
360     dev_c7200_pa_i8254x_set_nio,     dev_c7200_pa_i8254x_set_nio,
361     dev_c7200_pa_i8254x_unset_nio,     dev_c7200_pa_i8254x_unset_nio,
362     NULL,     NULL,
# Line 365  static const struct cisco_eeprom eeprom_ Line 388  static const struct cisco_eeprom eeprom_
388   *   *
389   * Add a C7200-IO-2FE/E port adapter into specified slot.   * Add a C7200-IO-2FE/E port adapter into specified slot.
390   */   */
391  static int dev_c7200_iocard_2fe_init(c7200_t *router,char *name,u_int pa_bay)  static int dev_c7200_iocard_2fe_init(vm_instance_t *vm,struct cisco_card *card)
392  {  {
393     struct pa_i8254x_data *data;     struct pa_i8254x_data *data;
394       u_int slot = card->slot_id;
395    
396     /* Allocate the private data structure for the iocard */     /* Allocate the private data structure for the iocard */
397     if (!(data = malloc(sizeof(*data)))) {     if (!(data = malloc(sizeof(*data)))) {
398        fprintf(stderr,"%s (C7200-IO-2FE): out of memory\n",name);        vm_error(vm,"%s: out of memory\n",card->dev_name);
399        return(-1);        return(-1);
400     }     }
401    
# Line 379  static int dev_c7200_iocard_2fe_init(c72 Line 403  static int dev_c7200_iocard_2fe_init(c72
403     memset(data,0,sizeof(*data));     memset(data,0,sizeof(*data));
404     data->nr_port = 2;     data->nr_port = 2;
405    
406       /* Set the PCI bus */
407       card->pci_bus = vm->slots_pci_bus[slot];
408    
409     /* Set the EEPROM */     /* Set the EEPROM */
410     c7200_pa_set_eeprom(router,pa_bay,&eeprom_c7200_io_2fe);     cisco_card_set_eeprom(vm,card,&eeprom_c7200_io_2fe);
411       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
412    
413     /* Port Fa0/0 is on PCI Device 1 */     /* Port Fa0/0 is on PCI Device 1 */
414     data->port[0] = dev_i8254x_init(router->vm,name,0,     data->port[0] = dev_i8254x_init(vm,card->dev_name,0,
415                                     router->pa_bay[pa_bay].pci_map,1,                                     card->pci_bus,1,
416                                     c7200_net_irq_for_slot_port(pa_bay,1));                                     c7200_net_irq_for_slot_port(slot,1));
417    
418     /* Port Fa0/1 is on PCI Device 0 */     /* Port Fa0/1 is on PCI Device 0 */
419     data->port[1] = dev_i8254x_init(router->vm,name,0,     data->port[1] = dev_i8254x_init(vm,card->dev_name,0,
420                                     router->pa_bay[pa_bay].pci_map,0,                                     card->pci_bus,0,
421                                     c7200_net_irq_for_slot_port(pa_bay,0));                                     c7200_net_irq_for_slot_port(slot,0));
422    
423     if (!data->port[0] || !data->port[1]) {     if (!data->port[0] || !data->port[1]) {
424        dev_i8254x_remove(data->port[0]);        dev_i8254x_remove(data->port[0]);
# Line 400  static int dev_c7200_iocard_2fe_init(c72 Line 428  static int dev_c7200_iocard_2fe_init(c72
428     }     }
429    
430     /* Store device info into the router structure */     /* Store device info into the router structure */
431     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
432       return(0);
433  }  }
434    
435  /* C7200-IO-2FE driver */  /* C7200-IO-2FE driver */
436  struct c7200_pa_driver dev_c7200_iocard_2fe_driver = {  struct cisco_card_driver dev_c7200_iocard_2fe_driver = {
437     "C7200-IO-2FE", 0,     "C7200-IO-2FE", 0, 0,
438     dev_c7200_iocard_2fe_init,     dev_c7200_iocard_2fe_init,
439     dev_c7200_pa_i8254x_shutdown,     dev_c7200_pa_i8254x_shutdown,
440       NULL,
441     dev_c7200_pa_i8254x_set_nio,     dev_c7200_pa_i8254x_set_nio,
442     dev_c7200_pa_i8254x_unset_nio,     dev_c7200_pa_i8254x_unset_nio,
443     NULL,     NULL,
# Line 442  static const struct cisco_eeprom eeprom_ Line 472  static const struct cisco_eeprom eeprom_
472   *   *
473   * Add a C7200-I/O-GE+E port adapter into specified slot.   * Add a C7200-I/O-GE+E port adapter into specified slot.
474   */   */
475  static int dev_c7200_iocard_ge_e_init(c7200_t *router,char *name,u_int pa_bay)  static int
476    dev_c7200_iocard_ge_e_init(vm_instance_t *vm,struct cisco_card *card)
477  {  {
478     struct pa_i8254x_data *data;     struct pa_i8254x_data *data;
479       u_int slot = card->slot_id;
480    
481     /* Allocate the private data structure for the iocard */     /* Allocate the private data structure for the iocard */
482     if (!(data = malloc(sizeof(*data)))) {     if (!(data = malloc(sizeof(*data)))) {
483        fprintf(stderr,"%s (C7200-IO-GE+E): out of memory\n",name);        vm_error(vm,"%s: out of memory\n",card->dev_name);
484        return(-1);        return(-1);
485     }     }
486    
# Line 456  static int dev_c7200_iocard_ge_e_init(c7 Line 488  static int dev_c7200_iocard_ge_e_init(c7
488     memset(data,0,sizeof(*data));     memset(data,0,sizeof(*data));
489     data->nr_port = 2;     data->nr_port = 2;
490    
491       /* Set the PCI bus */
492       card->pci_bus = vm->slots_pci_bus[slot];
493    
494     /* Set the EEPROM */     /* Set the EEPROM */
495     c7200_pa_set_eeprom(router,pa_bay,&eeprom_c7200_io_ge_e);     cisco_card_set_eeprom(vm,card,&eeprom_c7200_io_ge_e);
496       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
497    
498     /* Port Gi0/0 is on PCI Device 1 */     /* Port Gi0/0 is on PCI Device 1 */
499     data->port[0] = dev_i8254x_init(router->vm,name,0,     data->port[0] = dev_i8254x_init(vm,card->dev_name,0,
500                                     router->pa_bay[pa_bay].pci_map,1,                                     card->pci_bus,1,
501                                     c7200_net_irq_for_slot_port(pa_bay,1));                                     c7200_net_irq_for_slot_port(slot,1));
502    
503     /* Port e0/0 is on PCI Device 0 */     /* Port e0/0 is on PCI Device 0 */
504     data->port[1] = dev_i8254x_init(router->vm,name,0,     data->port[1] = dev_i8254x_init(vm,card->dev_name,0,
505                                     router->pa_bay[pa_bay].pci_map,0,                                     card->pci_bus,0,
506                                     c7200_net_irq_for_slot_port(pa_bay,0));                                     c7200_net_irq_for_slot_port(slot,0));
507    
508     /* Store device info into the router structure */     /* Store device info into the router structure */
509     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
510       return(0);
511  }  }
512    
513  /* C7200-IO-GE-E driver */  /* C7200-IO-GE-E driver */
514  struct c7200_pa_driver dev_c7200_iocard_ge_e_driver = {  struct cisco_card_driver dev_c7200_iocard_ge_e_driver = {
515     "C7200-IO-GE-E", 0,     "C7200-IO-GE-E", 0, 0,
516     dev_c7200_iocard_ge_e_init,     dev_c7200_iocard_ge_e_init,
517     dev_c7200_pa_i8254x_shutdown,     dev_c7200_pa_i8254x_shutdown,
518       NULL,
519     dev_c7200_pa_i8254x_set_nio,     dev_c7200_pa_i8254x_set_nio,
520     dev_c7200_pa_i8254x_unset_nio,     dev_c7200_pa_i8254x_unset_nio,
521     NULL,     NULL,
# Line 498  struct pa_4e8e_data { Line 536  struct pa_4e8e_data {
536   *   *
537   * Add a PA-4E port adapter into specified slot.   * Add a PA-4E port adapter into specified slot.
538   */   */
539  static int dev_c7200_pa_4e_init(c7200_t *router,char *name,u_int pa_bay)  static int dev_c7200_pa_4e_init(vm_instance_t *vm,struct cisco_card *card)
540  {  {
541     struct pa_4e8e_data *data;     struct pa_4e8e_data *data;
542       u_int slot = card->slot_id;
543     int i;     int i;
544    
545     /* Allocate the private data structure for the PA-4E */     /* Allocate the private data structure for the PA-4E */
546     if (!(data = malloc(sizeof(*data)))) {     if (!(data = malloc(sizeof(*data)))) {
547        fprintf(stderr,"%s (PA-4E): out of memory\n",name);        vm_error(vm,"%s: out of memory\n",card->dev_name);
548        return(-1);        return(-1);
549     }     }
550    
# Line 513  static int dev_c7200_pa_4e_init(c7200_t Line 552  static int dev_c7200_pa_4e_init(c7200_t
552     memset(data,0,sizeof(*data));     memset(data,0,sizeof(*data));
553     data->nr_port = 4;     data->nr_port = 4;
554    
555       /* Set the PCI bus */
556       card->pci_bus = vm->slots_pci_bus[slot];
557    
558     /* Set the EEPROM */     /* Set the EEPROM */
559     c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-4E"));     cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-4E"));
560       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
561    
562     /* Create the AMD Am79c971 chips */     /* Create the AMD Am79c971 chips */
563     for(i=0;i<data->nr_port;i++) {     for(i=0;i<data->nr_port;i++) {
564        data->port[i] = dev_am79c971_init(router->vm,name,AM79C971_TYPE_10BASE_T,        data->port[i] = dev_am79c971_init(vm,card->dev_name,
565                                          router->pa_bay[pa_bay].pci_map,i,                                          AM79C971_TYPE_10BASE_T,
566                                          c7200_net_irq_for_slot_port(pa_bay,i));                                          card->pci_bus,i,
567                                            c7200_net_irq_for_slot_port(slot,i));
568     }     }
569    
570     /* Store device info into the router structure */     /* Store device info into the router structure */
571     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
572       return(0);
573  }  }
574    
575  /*  /*
# Line 532  static int dev_c7200_pa_4e_init(c7200_t Line 577  static int dev_c7200_pa_4e_init(c7200_t
577   *   *
578   * Add a PA-8E port adapter into specified slot.   * Add a PA-8E port adapter into specified slot.
579   */   */
580  static int dev_c7200_pa_8e_init(c7200_t *router,char *name,u_int pa_bay)  static int dev_c7200_pa_8e_init(vm_instance_t *vm,struct cisco_card *card)
581  {  {
582     struct pa_4e8e_data *data;     struct pa_4e8e_data *data;
583       u_int slot = card->slot_id;
584     int i;     int i;
585    
586     /* Allocate the private data structure for the PA-8E */     /* Allocate the private data structure for the PA-8E */
587     if (!(data = malloc(sizeof(*data)))) {     if (!(data = malloc(sizeof(*data)))) {
588        fprintf(stderr,"%s (PA-8E): out of memory\n",name);        vm_error(vm,"%s: out of memory\n",card->dev_name);
589        return(-1);        return(-1);
590     }     }
591    
# Line 547  static int dev_c7200_pa_8e_init(c7200_t Line 593  static int dev_c7200_pa_8e_init(c7200_t
593     memset(data,0,sizeof(*data));     memset(data,0,sizeof(*data));
594     data->nr_port = 8;     data->nr_port = 8;
595    
596       /* Set the PCI bus */
597       card->pci_bus = vm->slots_pci_bus[slot];
598    
599     /* Set the EEPROM */     /* Set the EEPROM */
600     c7200_pa_set_eeprom(router,pa_bay,cisco_eeprom_find_pa("PA-8E"));     cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-8E"));
601       c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom);
602    
603     /* Create the AMD Am79c971 chips */     /* Create the AMD Am79c971 chips */
604     for(i=0;i<data->nr_port;i++) {     for(i=0;i<data->nr_port;i++) {
605        data->port[i] = dev_am79c971_init(router->vm,name,AM79C971_TYPE_10BASE_T,        data->port[i] = dev_am79c971_init(vm,card->dev_name,
606                                          router->pa_bay[pa_bay].pci_map,i,                                          AM79C971_TYPE_10BASE_T,
607                                          c7200_net_irq_for_slot_port(pa_bay,i));                                          card->pci_bus,i,
608                                            c7200_net_irq_for_slot_port(slot,i));
609     }     }
610    
611     /* Store device info into the router structure */     /* Store device info into the router structure */
612     return(c7200_pa_set_drvinfo(router,pa_bay,data));     card->drv_info = data;
613       return(0);
614  }  }
615    
616  /* Remove a PA-4E/PA-8E from the specified slot */  /* Remove a PA-4E/PA-8E from the specified slot */
617  static int dev_c7200_pa_4e8e_shutdown(c7200_t *router,u_int pa_bay)  static int
618    dev_c7200_pa_4e8e_shutdown(vm_instance_t *vm,struct cisco_card *card)
619  {  {
620     struct c7200_pa_bay *bay;     struct pa_4e8e_data *data = card->drv_info;
    struct pa_4e8e_data *data;  
621     int i;     int i;
622    
    if (!(bay = c7200_pa_get_info(router,pa_bay)))  
       return(-1);  
   
    data = bay->drv_info;  
   
623     /* Remove the PA EEPROM */     /* Remove the PA EEPROM */
624     c7200_pa_unset_eeprom(router,pa_bay);     cisco_card_unset_eeprom(card);
625       c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL);
626    
627     /* Remove the AMD Am79c971 chips */     /* Remove the AMD Am79c971 chips */
628     for(i=0;i<data->nr_port;i++)     for(i=0;i<data->nr_port;i++)
# Line 585  static int dev_c7200_pa_4e8e_shutdown(c7 Line 633  static int dev_c7200_pa_4e8e_shutdown(c7
633  }  }
634    
635  /* Bind a Network IO descriptor */  /* Bind a Network IO descriptor */
636  static int dev_c7200_pa_4e8e_set_nio(c7200_t *router,u_int pa_bay,  static int
637                                       u_int port_id,netio_desc_t *nio)  dev_c7200_pa_4e8e_set_nio(vm_instance_t *vm,struct cisco_card *card,
638                              u_int port_id,netio_desc_t *nio)
639  {  {
640     struct pa_4e8e_data *d;     struct pa_4e8e_data *d = card->drv_info;
   
    d = c7200_pa_get_drvinfo(router,pa_bay);  
641    
642     if (!d || (port_id >= d->nr_port))     if (!d || (port_id >= d->nr_port))
643        return(-1);        return(-1);
# Line 600  static int dev_c7200_pa_4e8e_set_nio(c72 Line 647  static int dev_c7200_pa_4e8e_set_nio(c72
647  }  }
648    
649  /* Unbind a Network IO descriptor */  /* Unbind a Network IO descriptor */
650  static int dev_c7200_pa_4e8e_unset_nio(c7200_t *router,u_int pa_bay,  static int
651                                         u_int port_id)  dev_c7200_pa_4e8e_unset_nio(vm_instance_t *vm,struct cisco_card *card,
652                                u_int port_id)
653  {  {
654     struct pa_4e8e_data *d;     struct pa_4e8e_data *d = card->drv_info;
   
    d = c7200_pa_get_drvinfo(router,pa_bay);  
655    
656     if (!d || (port_id >= d->nr_port))     if (!d || (port_id >= d->nr_port))
657        return(-1);        return(-1);
# Line 615  static int dev_c7200_pa_4e8e_unset_nio(c Line 661  static int dev_c7200_pa_4e8e_unset_nio(c
661  }  }
662    
663  /* PA-4E driver */  /* PA-4E driver */
664  struct c7200_pa_driver dev_c7200_pa_4e_driver = {  struct cisco_card_driver dev_c7200_pa_4e_driver = {
665     "PA-4E", 1,     "PA-4E", 1, 0,
666     dev_c7200_pa_4e_init,     dev_c7200_pa_4e_init,
667     dev_c7200_pa_4e8e_shutdown,     dev_c7200_pa_4e8e_shutdown,
668       NULL,
669     dev_c7200_pa_4e8e_set_nio,     dev_c7200_pa_4e8e_set_nio,
670     dev_c7200_pa_4e8e_unset_nio,     dev_c7200_pa_4e8e_unset_nio,
671     NULL,     NULL,
672  };  };
673    
674  /* PA-8E driver */  /* PA-8E driver */
675  struct c7200_pa_driver dev_c7200_pa_8e_driver = {  struct cisco_card_driver dev_c7200_pa_8e_driver = {
676     "PA-8E", 1,     "PA-8E", 1, 0,
677     dev_c7200_pa_8e_init,     dev_c7200_pa_8e_init,
678     dev_c7200_pa_4e8e_shutdown,     dev_c7200_pa_4e8e_shutdown,
679       NULL,
680     dev_c7200_pa_4e8e_set_nio,     dev_c7200_pa_4e8e_set_nio,
681     dev_c7200_pa_4e8e_unset_nio,     dev_c7200_pa_4e8e_unset_nio,
682     NULL,     NULL,

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

  ViewVC Help
Powered by ViewVC 1.1.26