/[dynamips]/upstream/dynamips-0.2.6-RC3/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

Annotation of /upstream/dynamips-0.2.6-RC3/dev_c3600_serial.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Sat Oct 6 16:06:49 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 2811 byte(s)
dynamips-0.2.6-RC3

1 dpavlin 1 /*
2     * Cisco C3600 (Predator) simulation platform.
3     * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4     *
5     * Serial Network Modules.
6     */
7    
8     #include <stdio.h>
9     #include <stdlib.h>
10     #include <string.h>
11     #include <stdarg.h>
12     #include <unistd.h>
13     #include <time.h>
14     #include <errno.h>
15     #include <assert.h>
16    
17     #include "utils.h"
18     #include "net.h"
19     #include "net_io.h"
20     #include "ptask.h"
21     #include "dev_mueslix.h"
22     #include "dev_c3600.h"
23     #include "dev_c3600_bay.h"
24    
25     /* ====================================================================== */
26     /* NM-4T */
27     /* ====================================================================== */
28    
29     /*
30     * dev_c3600_nm_4t_init()
31     *
32 dpavlin 4 * Add a NM-4T network module into specified slot.
33 dpavlin 1 */
34     int dev_c3600_nm_4t_init(c3600_t *router,char *name,u_int nm_bay)
35     {
36     struct nm_bay_info *bay_info;
37     struct mueslix_data *data;
38    
39     /* Set the EEPROM */
40 dpavlin 3 c3600_nm_set_eeprom(router,nm_bay,cisco_eeprom_find_nm("NM-4T"));
41 dpavlin 1
42     /* Get PCI bus info about this bay */
43     bay_info = c3600_nm_get_bay_info(c3600_chassis_get_id(router),nm_bay);
44    
45     if (!bay_info) {
46 dpavlin 4 fprintf(stderr,"%s: unable to get info for NM bay %u\n",name,nm_bay);
47 dpavlin 1 return(-1);
48     }
49    
50     /* Create the Mueslix chip */
51     data = dev_mueslix_init(router->vm,name,0,
52     router->nm_bay[nm_bay].pci_map,
53     bay_info->pci_device,
54     C3600_NETIO_IRQ);
55     if (!data) return(-1);
56    
57     /* Store device info into the router structure */
58     return(c3600_nm_set_drvinfo(router,nm_bay,data));
59     }
60    
61 dpavlin 4 /* Remove a NM-4T from the specified slot */
62 dpavlin 1 int dev_c3600_nm_4t_shutdown(c3600_t *router,u_int nm_bay)
63     {
64     struct c3600_nm_bay *bay;
65    
66     if (!(bay = c3600_nm_get_info(router,nm_bay)))
67     return(-1);
68    
69     c3600_nm_unset_eeprom(router,nm_bay);
70     dev_mueslix_remove(bay->drv_info);
71     return(0);
72     }
73    
74     /* Bind a Network IO descriptor to a specific port */
75     int dev_c3600_nm_4t_set_nio(c3600_t *router,u_int nm_bay,u_int port_id,
76     netio_desc_t *nio)
77     {
78     struct mueslix_data *data;
79    
80     if ((port_id >= MUESLIX_NR_CHANNELS) ||
81     !(data = c3600_nm_get_drvinfo(router,nm_bay)))
82     return(-1);
83    
84     return(dev_mueslix_set_nio(data,port_id,nio));
85     }
86    
87     /* Unbind a Network IO descriptor to a specific port */
88     int dev_c3600_nm_4t_unset_nio(c3600_t *router,u_int nm_bay,u_int port_id)
89     {
90     struct mueslix_data *d;
91    
92     if ((port_id >= MUESLIX_NR_CHANNELS) ||
93     !(d = c3600_nm_get_drvinfo(router,nm_bay)))
94     return(-1);
95    
96     return(dev_mueslix_unset_nio(d,port_id));
97     }
98    
99     /* NM-4T driver */
100     struct c3600_nm_driver dev_c3600_nm_4t_driver = {
101     "NM-4T", 1, 0,
102     dev_c3600_nm_4t_init,
103     dev_c3600_nm_4t_shutdown,
104     dev_c3600_nm_4t_set_nio,
105     dev_c3600_nm_4t_unset_nio,
106 dpavlin 2 NULL,
107 dpavlin 1 };

  ViewVC Help
Powered by ViewVC 1.1.26