/[dynamips]/upstream/dynamips-0.2.5/dev_c7200_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.5/dev_c7200_serial.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Sat Oct 6 16:01:44 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 6238 byte(s)
import 0.2.5 from upstream

1 /*
2 * Cisco C7200 (Predator) Simulation Platform.
3 * Copyright (C) 2005,2006 Christophe Fillot. All rights reserved.
4 *
5 * Serial Interfaces (Mueslix).
6 *
7 * EEPROM types:
8 * - 0x0C: PA-4T+
9 * - 0x0D: PA-8T-V35
10 * - 0x0E: PA-8T-X21
11 * - 0x0F: PA-8T-232
12 * - 0x10: PA-2H (HSSI)
13 * - 0x40: PA-4E1G/120
14 *
15 * It seems that the PA-8T is a combination of two PA-4T+.
16 *
17 * Note: "debug serial mueslix" gives more technical info.
18 */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <unistd.h>
24 #include <errno.h>
25 #include <assert.h>
26
27 #include "mips64.h"
28 #include "dynamips.h"
29 #include "memory.h"
30 #include "device.h"
31 #include "net.h"
32 #include "net_io.h"
33 #include "ptask.h"
34 #include "dev_mueslix.h"
35 #include "dev_c7200.h"
36
37 /* ====================================================================== */
38 /* PA-4T+ */
39 /* ====================================================================== */
40
41 /* PA-4T+ EEPROM definition */
42 static m_uint16_t eeprom_pa_4t_data[64] = {
43 0x010C, 0x010F, 0xffff, 0xffff, 0x4906, 0x2E07, 0x0000, 0x0000,
44 0x5000, 0x0000, 0x0010, 0x2400, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
45 };
46
47 static const struct c7200_eeprom eeprom_pa_4t = {
48 "PA-4T+", eeprom_pa_4t_data, sizeof(eeprom_pa_4t_data)/2,
49 };
50
51 /*
52 * dev_c7200_pa_4t_init()
53 *
54 * Add a PA-4T port adapter into specified slot.
55 */
56 int dev_c7200_pa_4t_init(c7200_t *router,char *name,u_int pa_bay)
57 {
58 struct mueslix_data *data;
59
60 /* Set the EEPROM */
61 c7200_pa_set_eeprom(router,pa_bay,&eeprom_pa_4t);
62
63 /* Create the Mueslix chip */
64 data = dev_mueslix_init(router->vm,name,1,
65 router->pa_bay[pa_bay].pci_map,0,
66 C7200_NETIO_IRQ);
67 if (!data) return(-1);
68
69 /* Store device info into the router structure */
70 return(c7200_pa_set_drvinfo(router,pa_bay,data));
71 }
72
73 /* Remove a PA-4T+ from the specified slot */
74 int dev_c7200_pa_4t_shutdown(c7200_t *router,u_int pa_bay)
75 {
76 struct c7200_pa_bay *bay;
77
78 if (!(bay = c7200_pa_get_info(router,pa_bay)))
79 return(-1);
80
81 c7200_pa_unset_eeprom(router,pa_bay);
82 dev_mueslix_remove(bay->drv_info);
83 return(0);
84 }
85
86 /* Bind a Network IO descriptor to a specific port */
87 int dev_c7200_pa_4t_set_nio(c7200_t *router,u_int pa_bay,u_int port_id,
88 netio_desc_t *nio)
89 {
90 struct mueslix_data *data;
91
92 if ((port_id >= MUESLIX_NR_CHANNELS) ||
93 !(data = c7200_pa_get_drvinfo(router,pa_bay)))
94 return(-1);
95
96 return(dev_mueslix_set_nio(data,port_id,nio));
97 }
98
99 /* Unbind a Network IO descriptor to a specific port */
100 int dev_c7200_pa_4t_unset_nio(c7200_t *router,u_int pa_bay,u_int port_id)
101 {
102 struct mueslix_data *d;
103
104 if ((port_id >= MUESLIX_NR_CHANNELS) ||
105 !(d = c7200_pa_get_drvinfo(router,pa_bay)))
106 return(-1);
107
108 return(dev_mueslix_unset_nio(d,port_id));
109 }
110
111 /* PA-4T+ driver */
112 struct c7200_pa_driver dev_c7200_pa_4t_driver = {
113 "PA-4T+", 1,
114 dev_c7200_pa_4t_init,
115 dev_c7200_pa_4t_shutdown,
116 dev_c7200_pa_4t_set_nio,
117 dev_c7200_pa_4t_unset_nio,
118 };
119
120 /* ====================================================================== */
121 /* PA-8T */
122 /* ====================================================================== */
123
124 /* PA-8T data */
125 struct pa8t_data {
126 struct mueslix_data *mueslix[2];
127 };
128
129 /* EEPROM definition */
130 static m_uint16_t eeprom_pa_8t_data[64] = {
131 0x010E, 0x010F, 0xffff, 0xffff, 0x4906, 0x2E07, 0x0000, 0x0000,
132 0x5000, 0x0000, 0x0010, 0x2400, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
133 };
134
135 static const struct c7200_eeprom eeprom_pa_8t = {
136 "PA-8T", eeprom_pa_8t_data, sizeof(eeprom_pa_8t_data)/2,
137 };
138
139 /*
140 * dev_c7200_pa_8t_init()
141 *
142 * Add a PA-8T port adapter into specified slot.
143 */
144 int dev_c7200_pa_8t_init(c7200_t *router,char *name,u_int pa_bay)
145 {
146 struct pa8t_data *data;
147
148 /* Allocate the private data structure for the PA-8T */
149 if (!(data = malloc(sizeof(*data)))) {
150 fprintf(stderr,"%s (PA-8T): out of memory\n",name);
151 return(-1);
152 }
153
154 /* Set the EEPROM */
155 c7200_pa_set_eeprom(router,pa_bay,&eeprom_pa_8t);
156
157 /* Create the 1st Mueslix chip */
158 data->mueslix[0] = dev_mueslix_init(router->vm,name,1,
159 router->pa_bay[pa_bay].pci_map,0,
160 C7200_NETIO_IRQ);
161 if (!data->mueslix[0]) return(-1);
162
163 /* Create the 2nd Mueslix chip */
164 data->mueslix[1] = dev_mueslix_init(router->vm,name,1,
165 router->pa_bay[pa_bay].pci_map,1,
166 C7200_NETIO_IRQ);
167 if (!data->mueslix[1]) return(-1);
168
169 /* Store device info into the router structure */
170 return(c7200_pa_set_drvinfo(router,pa_bay,data));
171 }
172
173 /* Remove a PA-8T from the specified slot */
174 int dev_c7200_pa_8t_shutdown(c7200_t *router,u_int pa_bay)
175 {
176 struct c7200_pa_bay *bay;
177 struct pa8t_data *data;
178
179 if (!(bay = c7200_pa_get_info(router,pa_bay)))
180 return(-1);
181
182 data = bay->drv_info;
183
184 /* Remove the PA EEPROM */
185 c7200_pa_unset_eeprom(router,pa_bay);
186
187 /* Remove the two Mueslix chips */
188 dev_mueslix_remove(data->mueslix[0]);
189 dev_mueslix_remove(data->mueslix[1]);
190 free(data);
191 return(0);
192 }
193
194 /* Bind a Network IO descriptor to a specific port */
195 int dev_c7200_pa_8t_set_nio(c7200_t *router,u_int pa_bay,u_int port_id,
196 netio_desc_t *nio)
197 {
198 struct pa8t_data *d;
199
200 if ((port_id >= (MUESLIX_NR_CHANNELS*2)) ||
201 !(d = c7200_pa_get_drvinfo(router,pa_bay)))
202 return(-1);
203
204 return(dev_mueslix_set_nio(d->mueslix[port_id>>2],(port_id&0x03),nio));
205 }
206
207 /* Bind a Network IO descriptor to a specific port */
208 int dev_c7200_pa_8t_unset_nio(c7200_t *router,u_int pa_bay,u_int port_id)
209 {
210 struct pa8t_data *d;
211
212 if ((port_id >= (MUESLIX_NR_CHANNELS*2)) ||
213 !(d = c7200_pa_get_drvinfo(router,pa_bay)))
214 return(-1);
215
216 return(dev_mueslix_unset_nio(d->mueslix[port_id>>2],port_id&0x03));
217 }
218
219 /* PA-8T driver */
220 struct c7200_pa_driver dev_c7200_pa_8t_driver = {
221 "PA-8T", 1,
222 dev_c7200_pa_8t_init,
223 dev_c7200_pa_8t_shutdown,
224 dev_c7200_pa_8t_set_nio,
225 dev_c7200_pa_8t_unset_nio,
226 };

  ViewVC Help
Powered by ViewVC 1.1.26