/[dynamips]/trunk/dev_c3600_serial.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/dev_c3600_serial.c

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

upstream/dynamips-0.2.7/dev_c3600_serial.c revision 10 by dpavlin, Sat Oct 6 16:29:14 2007 UTC upstream/dynamips-0.2.8-RC1/dev_c3600_serial.c revision 11 by dpavlin, Sat Oct 6 16:33:40 2007 UTC
# Line 31  Line 31 
31   *   *
32   * Add a NM-4T network module into specified slot.   * Add a NM-4T network module into specified slot.
33   */   */
34  int dev_c3600_nm_4t_init(c3600_t *router,char *name,u_int nm_bay)  int dev_c3600_nm_4t_init(vm_instance_t *vm,struct cisco_card *card)
35  {  {
36     struct nm_bay_info *bay_info;     struct nm_bay_info *bay_info;
37     struct mueslix_data *data;     struct mueslix_data *data;
38       u_int slot = card->slot_id;
39       u_int chassis_id;
40    
41       /* Set the PCI bus */
42       card->pci_bus = vm->slots_pci_bus[slot];
43    
44     /* Set the EEPROM */     /* Set the EEPROM */
45     c3600_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-4T"));     cisco_card_set_eeprom(vm,card,cisco_eeprom_find_nm("NM-4T"));
46       c3600_set_slot_eeprom(VM_C3600(vm),slot,&card->eeprom);
47    
48     /* Get PCI bus info about this bay */     /* Get PCI bus info about this bay */
49     bay_info = c3600_nm_get_bay_info(c3600_chassis_get_id(router),nm_bay);     chassis_id = c3600_chassis_get_id(VM_C3600(vm));
50       bay_info = c3600_nm_get_bay_info(chassis_id,slot);
51    
52     if (!bay_info) {     if (!bay_info) {
53        fprintf(stderr,"%s: unable to get info for NM bay %u\n",name,nm_bay);        vm_error(vm,"unable to get info for NM bay %u\n",slot);
54        return(-1);        return(-1);
55     }     }
56    
57     /* Create the Mueslix chip */     /* Create the Mueslix chip */
58     data = dev_mueslix_init(router->vm,name,0,     data = dev_mueslix_init(vm,card->dev_name,0,
59                             router->nm_bay[nm_bay].pci_map,                             card->pci_bus,bay_info->pci_device,
60                             bay_info->pci_device,                             c3600_net_irq_for_slot_port(slot,0));
                            c3600_net_irq_for_slot_port(nm_bay,0));  
61     if (!data) return(-1);     if (!data) return(-1);
62    
63     /* Store device info into the router structure */     /* Store device info into the router structure */
64     return(c3600_nm_set_drvinfo(router,nm_bay,data));     card->drv_info = data;
65       return(0);
66  }  }
67    
68  /* Remove a NM-4T from the specified slot */  /* Remove a NM-4T from the specified slot */
69  int dev_c3600_nm_4t_shutdown(c3600_t *router,u_int nm_bay)  int dev_c3600_nm_4t_shutdown(vm_instance_t *vm,struct cisco_card *card)
70  {  {
71     struct c3600_nm_bay *bay;     /* Remove the NM EEPROM */
72       cisco_card_unset_eeprom(card);
73     if (!(bay = c3600_nm_get_info(router,nm_bay)))     c3600_set_slot_eeprom(VM_C3600(vm),card->slot_id,NULL);
       return(-1);  
74    
75     c3600_nm_unset_eeprom(router,nm_bay);     /* Remove the mueslix driver */
76     dev_mueslix_remove(bay->drv_info);     dev_mueslix_remove(card->drv_info);
77     return(0);     return(0);
78  }  }
79    
80  /* Bind a Network IO descriptor to a specific port */  /* Bind a Network IO descriptor to a specific port */
81  int dev_c3600_nm_4t_set_nio(c3600_t *router,u_int nm_bay,u_int port_id,  int dev_c3600_nm_4t_set_nio(vm_instance_t *vm,struct cisco_card *card,
82                              netio_desc_t *nio)                              u_int port_id,netio_desc_t *nio)
83  {  {
84     struct mueslix_data *data;     struct mueslix_data *d = card->drv_info;
85    
86     if ((port_id >= MUESLIX_NR_CHANNELS) ||     if (!d || (port_id >= MUESLIX_NR_CHANNELS))
        !(data = c3600_nm_get_drvinfo(router,nm_bay)))  
87        return(-1);        return(-1);
88    
89     return(dev_mueslix_set_nio(data,port_id,nio));     return(dev_mueslix_set_nio(d,port_id,nio));
90  }  }
91    
92  /* Unbind a Network IO descriptor to a specific port */  /* Unbind a Network IO descriptor to a specific port */
93  int dev_c3600_nm_4t_unset_nio(c3600_t *router,u_int nm_bay,u_int port_id)  int dev_c3600_nm_4t_unset_nio(vm_instance_t *vm,struct cisco_card *card,
94                                  u_int port_id)
95  {  {
96     struct mueslix_data *d;     struct mueslix_data *d = card->drv_info;
97    
98     if ((port_id >= MUESLIX_NR_CHANNELS) ||     if (!d || (port_id >= MUESLIX_NR_CHANNELS))
        !(d = c3600_nm_get_drvinfo(router,nm_bay)))  
99        return(-1);        return(-1);
100        
101     return(dev_mueslix_unset_nio(d,port_id));     return(dev_mueslix_unset_nio(d,port_id));
102  }  }
103    
104  /* NM-4T driver */  /* NM-4T driver */
105  struct c3600_nm_driver dev_c3600_nm_4t_driver = {  struct cisco_card_driver dev_c3600_nm_4t_driver = {
106     "NM-4T", 1, 0,     "NM-4T", 1, 0,
107     dev_c3600_nm_4t_init,     dev_c3600_nm_4t_init,
108     dev_c3600_nm_4t_shutdown,     dev_c3600_nm_4t_shutdown,
109       NULL,
110     dev_c3600_nm_4t_set_nio,     dev_c3600_nm_4t_set_nio,
111     dev_c3600_nm_4t_unset_nio,     dev_c3600_nm_4t_unset_nio,
112     NULL,     NULL,

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

  ViewVC Help
Powered by ViewVC 1.1.26