/[dynamips]/trunk/dev_c3600.h
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 /trunk/dev_c3600.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (show annotations)
Sat Oct 6 16:26:06 2007 UTC (12 years, 1 month ago) by dpavlin
Original Path: upstream/dynamips-0.2.7-RC3/dev_c3600.h
File MIME type: text/plain
File size: 9301 byte(s)
dynamips-0.2.7-RC3

1 /*
2 * Cisco 3600 simulation platform.
3 * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4 *
5 * Generic Cisco 3600 routines and definitions (EEPROM,...).
6 */
7
8 #ifndef __DEV_C3600_H__
9 #define __DEV_C3600_H__
10
11 #include <pthread.h>
12
13 #include "utils.h"
14 #include "net.h"
15 #include "device.h"
16 #include "pci_dev.h"
17 #include "nmc93cX6.h"
18 #include "net_io.h"
19 #include "vm.h"
20
21 /* Default C3600 parameters */
22 #define C3600_DEFAULT_CHASSIS "3640"
23 #define C3600_DEFAULT_RAM_SIZE 128
24 #define C3600_DEFAULT_ROM_SIZE 2
25 #define C3600_DEFAULT_NVRAM_SIZE 128
26 #define C3600_DEFAULT_CONF_REG 0x2102
27 #define C3600_DEFAULT_CLOCK_DIV 4
28 #define C3600_DEFAULT_RAM_MMAP 1
29 #define C3600_DEFAULT_DISK0_SIZE 0
30 #define C3600_DEFAULT_DISK1_SIZE 0
31 #define C3600_DEFAULT_IOMEM_SIZE 5 /* Percents! */
32
33 /* 6 NM slots for the 3660 + integrated FastEthernet ports */
34 #define C3600_MAX_NM_BAYS 7
35
36 /* C3600 DUART Interrupt */
37 #define C3600_DUART_IRQ 5
38
39 /* C3600 Network I/O Interrupt */
40 #define C3600_NETIO_IRQ 2
41
42 /* C3600 GT64k DMA/Timer Interrupt */
43 #define C3600_GT64K_IRQ 4
44
45 /* C3600 External Interrupt */
46 #define C3600_EXT_IRQ 6
47
48 /* C3600 NM Management Interrupt handler */
49 #define C3600_NM_MGMT_IRQ 3
50
51 /* Network IRQ */
52 #define C3600_NETIO_IRQ_BASE 32
53 #define C3600_NETIO_IRQ_PORT_BITS 2
54 #define C3600_NETIO_IRQ_PORT_MASK ((1 << C3600_NETIO_IRQ_PORT_BITS) - 1)
55 #define C3600_NETIO_IRQ_PER_SLOT (1 << C3600_NETIO_IRQ_PORT_BITS)
56 #define C3600_NETIO_IRQ_END \
57 (C3600_NETIO_IRQ_BASE + (C3600_MAX_NM_BAYS * C3600_NETIO_IRQ_PER_SLOT) - 1)
58
59 /* C3600 common device addresses */
60 #define C3600_GT64K_ADDR 0x14000000ULL
61 #define C3600_IOFPGA_ADDR 0x1e800000ULL
62 #define C3600_DUART_ADDR 0x1e840000ULL
63 #define C3600_BITBUCKET_ADDR 0x1ec00000ULL
64 #define C3600_NVRAM_ADDR 0x1fe00000ULL
65 #define C3600_ROM_ADDR 0x1fc00000ULL
66 #define C3600_BOOTFLASH_ADDR 0x30000000ULL
67 #define C3600_PCI_IO_ADDR 0x100000000ULL
68
69 /* Reserved space for ROM in NVRAM */
70 #define C3600_NVRAM_ROM_RES_SIZE 2048
71
72 /* C3600 ELF Platform ID */
73 #define C3620_ELF_MACHINE_ID 0x1e
74 #define C3640_ELF_MACHINE_ID 0x1e
75 //#define C3660_ELF_MACHINE_ID ????
76
77 /* C3600 router */
78 typedef struct c3600_router c3600_t;
79
80 /* Prototype of chassis driver initialization function */
81 typedef int (*c3600_chassis_init_fn)(c3600_t *router);
82
83 /* Prototype of NM driver initialization function */
84 typedef int (*c3600_nm_init_fn)(c3600_t *router,char *name,u_int nm_bay);
85
86 /* Prototype of NM driver shutdown function */
87 typedef int (*c3600_nm_shutdown_fn)(c3600_t *router,u_int nm_bay);
88
89 /* Prototype of NM NIO set function */
90 typedef int (*c3600_nm_set_nio_fn)(c3600_t *router,u_int nm_bay,u_int port_id,
91 netio_desc_t *nio);
92
93 /* Prototype of NM NIO unset function */
94 typedef int (*c3600_nm_unset_nio_fn)(c3600_t *router,u_int nm_bay,
95 u_int port_id);
96
97 /* Prototype of NM NIO show info function */
98 typedef int (*c3600_nm_show_info_fn)(c3600_t *router,u_int nm_bay);
99
100 /* C3600 Network Module Driver */
101 struct c3600_nm_driver {
102 char *dev_type;
103 int supported;
104 int wic_slots;
105 c3600_nm_init_fn nm_init;
106 c3600_nm_shutdown_fn nm_shutdown;
107 c3600_nm_set_nio_fn nm_set_nio;
108 c3600_nm_unset_nio_fn nm_unset_nio;
109 c3600_nm_show_info_fn nm_show_info;
110
111 /* TODO: WAN Interface Cards (WIC) */
112 };
113
114 /* C3600 NIO binding to a slot/port */
115 struct c3600_nio_binding {
116 netio_desc_t *nio;
117 u_int port_id;
118 struct c3600_nio_binding *prev,*next;
119 };
120
121 /* C3600 NM bay */
122 struct c3600_nm_bay {
123 char *dev_name; /* Device name */
124 char *dev_type; /* Device Type */
125 struct cisco_eeprom eeprom; /* NM EEPROM */
126 struct pci_bus *pci_map; /* PCI bus */
127 struct c3600_nm_driver *nm_driver; /* NM Driver */
128 void *drv_info; /* Private driver info */
129 struct c3600_nio_binding *nio_list; /* NIO bindings to ports */
130 };
131
132 /* C3600 Chassis Driver */
133 struct c3600_chassis_driver {
134 char *chassis_type;
135 int chassis_id;
136 int supported;
137 c3600_chassis_init_fn chassis_init;
138 struct cisco_eeprom *eeprom;
139 };
140
141 /* C3600 router */
142 struct c3600_router {
143 /* Chassis MAC address */
144 n_eth_addr_t mac_addr;
145
146 /* Associated VM instance */
147 vm_instance_t *vm;
148
149 /* IO memory size to be passed to Smart Init */
150 u_int nm_iomem_size;
151
152 /* I/O FPGA */
153 struct c3600_iofpga_data *iofpga_data;
154
155 /* Chassis information */
156 struct c3600_chassis_driver *chassis_driver;
157 struct c3600_nm_bay nm_bay[C3600_MAX_NM_BAYS];
158 m_uint8_t oir_status;
159
160 /*
161 * Mainboard EEPROM.
162 * It can be modified to change the chassis MAC address.
163 */
164 struct cisco_eeprom mb_eeprom;
165 struct nmc93cX6_group mb_eeprom_group;
166
167 /* Network Module EEPROMs (3620/3640) */
168 struct nmc93cX6_group nm_eeprom_group;
169
170 /* Cisco 3660 NM EEPROMs */
171 struct nmc93cX6_group c3660_nm_eeprom_group[C3600_MAX_NM_BAYS];
172 };
173
174 /* Create a new router instance */
175 c3600_t *c3600_create_instance(char *name,int instance_id);
176
177 /* Delete a router instance */
178 int c3600_delete_instance(char *name);
179
180 /* Delete all router instances */
181 int c3600_delete_all_instances(void);
182
183 /* Save configuration of a C3600 instance */
184 void c3600_save_config(c3600_t *router,FILE *fd);
185
186 /* Save configurations of all C3600 instances */
187 void c3600_save_config_all(FILE *fd);
188
189 /* Get network IRQ for specified slot/port */
190 u_int c3600_net_irq_for_slot_port(u_int slot,u_int port);
191
192 /* Set NM EEPROM definition */
193 int c3600_nm_set_eeprom(c3600_t *router,u_int nm_bay,
194 const struct cisco_eeprom *eeprom);
195
196 /* Unset NM EEPROM definition (empty bay) */
197 int c3600_nm_unset_eeprom(c3600_t *router,u_int nm_bay);
198
199 /* Check if a bay has a Network Module */
200 int c3600_nm_check_eeprom(c3600_t *router,u_int nm_bay);
201
202 /* Get bay info */
203 struct c3600_nm_bay *c3600_nm_get_info(c3600_t *router,u_int nm_bay);
204
205 /* Get NM type */
206 char *c3600_nm_get_type(c3600_t *router,u_int nm_bay);
207
208 /* Get driver info about the specified slot */
209 void *c3600_nm_get_drvinfo(c3600_t *router,u_int nm_bay);
210
211 /* Set driver info for the specified slot */
212 int c3600_nm_set_drvinfo(c3600_t *router,u_int nm_bay,void *drv_info);
213
214 /* Add a NM binding */
215 int c3600_nm_add_binding(c3600_t *router,char *dev_type,u_int nm_bay);
216
217 /* Remove a NM binding */
218 int c3600_nm_remove_binding(c3600_t *router,u_int nm_bay);
219
220 /* Find a NIO binding */
221 struct c3600_nio_binding *
222 c3600_nm_find_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id);
223
224 /* Add a network IO binding */
225 int c3600_nm_add_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id,
226 char *nio_name);
227
228 /* Remove a NIO binding */
229 int c3600_nm_remove_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id);
230
231 /* Remove all NIO bindings for the specified NM */
232 int c3600_nm_remove_all_nio_bindings(c3600_t *router,u_int nm_bay);
233
234 /* Enable a Network IO descriptor for a Network Module */
235 int c3600_nm_enable_nio(c3600_t *router,u_int nm_bay,u_int port_id);
236
237 /* Disable Network IO descriptor of a Network Module */
238 int c3600_nm_disable_nio(c3600_t *router,u_int nm_bay,u_int port_id);
239
240 /* Enable all NIO of the specified NM */
241 int c3600_nm_enable_all_nio(c3600_t *router,u_int nm_bay);
242
243 /* Disable all NIO of the specified NM */
244 int c3600_nm_disable_all_nio(c3600_t *router,u_int nm_bay);
245
246 /* Initialize a Network Module */
247 int c3600_nm_init(c3600_t *router,u_int nm_bay);
248
249 /* Shutdown a Network Module */
250 int c3600_nm_shutdown(c3600_t *router,u_int nm_bay);
251
252 /* Shutdown all NM of a router */
253 int c3600_nm_shutdown_all(c3600_t *router);
254
255 /* Show info about all NMs */
256 int c3600_nm_show_all_info(c3600_t *router);
257
258 /* Create a Network Module (command line) */
259 int c3600_cmd_nm_create(c3600_t *router,char *str);
260
261 /* Add a Network IO descriptor binding (command line) */
262 int c3600_cmd_add_nio(c3600_t *router,char *str);
263
264 /* Show the list of available NM drivers */
265 void c3600_nm_show_drivers(void);
266
267 /* Set chassis MAC address */
268 int c3600_chassis_set_mac_addr(c3600_t *router,char *mac_addr);
269
270 /* Set the chassis type */
271 int c3600_chassis_set_type(c3600_t *router,char *chassis_type);
272
273 /* Get the chassis ID */
274 int c3600_chassis_get_id(c3600_t *router);
275
276 /* Show the list of available chassis drivers */
277 void c3600_chassis_show_drivers(void);
278
279 /* Show C3600 hardware info */
280 void c3600_show_hardware(c3600_t *router);
281
282 /* Initialize default parameters for a C3600 */
283 void c3600_init_defaults(c3600_t *router);
284
285 /* Initialize the C3600 Platform */
286 int c3600_init_platform(c3600_t *router);
287
288 /* Initialize a Cisco 3600 instance */
289 int c3600_init_instance(c3600_t *router);
290
291 /* Stop a Cisco 3600 instance */
292 int c3600_stop_instance(c3600_t *router);
293
294 /* Initialize EEPROM groups */
295 void c3600_init_eeprom_groups(c3600_t *router);
296
297 /* dev_c3600_iofpga_init() */
298 int dev_c3600_iofpga_init(c3600_t *router,m_uint64_t paddr,m_uint32_t len);
299
300 /* NM drivers */
301 extern struct c3600_nm_driver dev_c3600_nm_1e_driver;
302 extern struct c3600_nm_driver dev_c3600_nm_4e_driver;
303 extern struct c3600_nm_driver dev_c3600_nm_1fe_tx_driver;
304 extern struct c3600_nm_driver dev_c3600_nm_4t_driver;
305 extern struct c3600_nm_driver dev_c3600_leopard_2fe_driver;
306 extern struct c3600_nm_driver dev_c3600_nm_16esw_driver;
307
308 #endif

  ViewVC Help
Powered by ViewVC 1.1.26