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

Contents of /upstream/dynamips-0.2.6-RC1/dev_c3600_serial.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Sat Oct 6 16:03:58 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 3166 byte(s)
import dynamips-0.2.6-RC1

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 /* NM-4T: 4 Serial Network Module EEPROM */
30 static m_uint16_t eeprom_c3600_nm_4t_data[64] = {
31 0x0154, 0x0101, 0x009D, 0x2D64, 0x5009, 0x0A02, 0x0000, 0x0000,
32 0x5800, 0x0000, 0x9811, 0x0300, 0x0005, 0xFFFF, 0xFFFF, 0xFFFF,
33 };
34
35 static const struct c3600_eeprom eeprom_c3600_nm_4t = {
36 "NM-4T", eeprom_c3600_nm_4t_data, sizeof(eeprom_c3600_nm_4t_data)/2,
37 };
38
39 /*
40 * dev_c3600_nm_4t_init()
41 *
42 * Add a PA-4T network module into specified slot.
43 */
44 int dev_c3600_nm_4t_init(c3600_t *router,char *name,u_int nm_bay)
45 {
46 struct nm_bay_info *bay_info;
47 struct mueslix_data *data;
48
49 /* Set the EEPROM */
50 c3600_nm_set_eeprom(router,nm_bay,&eeprom_c3600_nm_4t);
51
52 /* Get PCI bus info about this bay */
53 bay_info = c3600_nm_get_bay_info(c3600_chassis_get_id(router),nm_bay);
54
55 if (!bay_info) {
56 fprintf(stderr,"%s: unable to get info for PA bay %u\n",name,nm_bay);
57 return(-1);
58 }
59
60 /* Create the Mueslix chip */
61 data = dev_mueslix_init(router->vm,name,0,
62 router->nm_bay[nm_bay].pci_map,
63 bay_info->pci_device,
64 C3600_NETIO_IRQ);
65 if (!data) return(-1);
66
67 /* Store device info into the router structure */
68 return(c3600_nm_set_drvinfo(router,nm_bay,data));
69 }
70
71 /* Remove a PA-4T+ from the specified slot */
72 int dev_c3600_nm_4t_shutdown(c3600_t *router,u_int nm_bay)
73 {
74 struct c3600_nm_bay *bay;
75
76 if (!(bay = c3600_nm_get_info(router,nm_bay)))
77 return(-1);
78
79 c3600_nm_unset_eeprom(router,nm_bay);
80 dev_mueslix_remove(bay->drv_info);
81 return(0);
82 }
83
84 /* Bind a Network IO descriptor to a specific port */
85 int dev_c3600_nm_4t_set_nio(c3600_t *router,u_int nm_bay,u_int port_id,
86 netio_desc_t *nio)
87 {
88 struct mueslix_data *data;
89
90 if ((port_id >= MUESLIX_NR_CHANNELS) ||
91 !(data = c3600_nm_get_drvinfo(router,nm_bay)))
92 return(-1);
93
94 return(dev_mueslix_set_nio(data,port_id,nio));
95 }
96
97 /* Unbind a Network IO descriptor to a specific port */
98 int dev_c3600_nm_4t_unset_nio(c3600_t *router,u_int nm_bay,u_int port_id)
99 {
100 struct mueslix_data *d;
101
102 if ((port_id >= MUESLIX_NR_CHANNELS) ||
103 !(d = c3600_nm_get_drvinfo(router,nm_bay)))
104 return(-1);
105
106 return(dev_mueslix_unset_nio(d,port_id));
107 }
108
109 /* NM-4T driver */
110 struct c3600_nm_driver dev_c3600_nm_4t_driver = {
111 "NM-4T", 1, 0,
112 dev_c3600_nm_4t_init,
113 dev_c3600_nm_4t_shutdown,
114 dev_c3600_nm_4t_set_nio,
115 dev_c3600_nm_4t_unset_nio,
116 NULL,
117 };

  ViewVC Help
Powered by ViewVC 1.1.26