/[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

Annotation of /trunk/dev_c3600.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Sat Oct 6 16:01:44 2007 UTC (12 years, 1 month ago) by dpavlin
Original Path: upstream/dynamips-0.2.5/dev_c3600.h
File MIME type: text/plain
File size: 8841 byte(s)
import 0.2.5 from upstream

1 dpavlin 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 "nmc93c46.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     /* C3600 common device addresses */
52     #define C3600_GT64K_ADDR 0x14000000ULL
53     #define C3600_IOFPGA_ADDR 0x1e800000ULL
54     #define C3600_DUART_ADDR 0x1e840000ULL
55     #define C3600_BITBUCKET_ADDR 0x1ec00000ULL
56     #define C3600_NVRAM_ADDR 0x1fe00000ULL
57     #define C3600_ROM_ADDR 0x1fc00000ULL
58     #define C3600_BOOTFLASH_ADDR 0x30000000ULL
59     #define C3600_PCI_IO_ADDR 0x100000000ULL
60    
61     /* Reserved space for ROM in NVRAM */
62     #define C3600_NVRAM_ROM_RES_SIZE 2048
63    
64     /* C3600 ELF Platform ID */
65     #define C3620_ELF_MACHINE_ID 0x1e
66     #define C3640_ELF_MACHINE_ID 0x1e
67     //#define C3660_ELF_MACHINE_ID ????
68    
69     /* C3600 router */
70     typedef struct c3600_router c3600_t;
71    
72     /* C3600 EEPROM */
73     struct c3600_eeprom {
74     char *name;
75     m_uint16_t *data;
76     u_int len;
77     };
78    
79     /* Prototype of chassis driver initialization function */
80     typedef int (*c3600_chassis_init_fn)(c3600_t *router);
81    
82     /* Prototype of NM driver initialization function */
83     typedef int (*c3600_nm_init_fn)(c3600_t *router,char *name,u_int nm_bay);
84    
85     /* Prototype of PA driver shutdown function */
86     typedef int (*c3600_nm_shutdown_fn)(c3600_t *router,u_int nm_bay);
87    
88     /* Prototype of PA NIO set function */
89     typedef int (*c3600_nm_set_nio_fn)(c3600_t *router,u_int nm_bay,u_int port_id,
90     netio_desc_t *nio);
91    
92     /* Prototype of PA NIO unset function */
93     typedef int (*c3600_nm_unset_nio_fn)(c3600_t *router,u_int nm_bay,
94     u_int port_id);
95    
96     /* C3600 Network Module Driver */
97     struct c3600_nm_driver {
98     char *dev_type;
99     int supported;
100     int wic_slots;
101     c3600_nm_init_fn nm_init;
102     c3600_nm_shutdown_fn nm_shutdown;
103     c3600_nm_set_nio_fn nm_set_nio;
104     c3600_nm_unset_nio_fn nm_unset_nio;
105    
106     /* TODO: WAN Interface Cards (WIC) */
107     };
108    
109     /* C3600 NIO binding to a slot/port */
110     struct c3600_nio_binding {
111     netio_desc_t *nio;
112     u_int port_id;
113     struct c3600_nio_binding *prev,*next;
114     };
115    
116     /* C3600 NM bay */
117     struct c3600_nm_bay {
118     char *dev_name; /* Device name */
119     char *dev_type; /* Device Type */
120     struct pci_bus *pci_map; /* PCI bus */
121     m_uint16_t *eeprom_data; /* NM EEPROM data */
122     u_int eeprom_data_len; /* NM EEPROM data length */
123     struct c3600_nm_driver *nm_driver; /* NM Driver */
124     void *drv_info; /* Private driver info */
125     struct c3600_nio_binding *nio_list; /* NIO bindings to ports */
126     };
127    
128     /* C3600 Chassis Driver */
129     struct c3600_chassis_driver {
130     char *chassis_type;
131     int chassis_id;
132     int supported;
133     c3600_chassis_init_fn chassis_init;
134     m_uint16_t *mb_eeprom;
135     u_int mb_eeprom_len;
136     };
137    
138     /* C3600 router */
139     struct c3600_router {
140     /* Chassis MAC address */
141     n_eth_addr_t mac_addr;
142    
143     /* Associated VM instance */
144     vm_instance_t *vm;
145    
146     /* IO memory size to be passed to Smart Init */
147     u_int nm_iomem_size;
148    
149     /* Chassis information */
150     struct c3600_chassis_driver *chassis_driver;
151     struct c3600_nm_bay nm_bay[C3600_MAX_NM_BAYS];
152     m_uint8_t oir_status;
153    
154     /*
155     * Mainboard EEPROM.
156     * It can be modified to change the chassis MAC address.
157     */
158     m_uint16_t mb_eeprom_data[64];
159     struct nmc93c46_eeprom_def mb_eeprom;
160     struct nmc93c46_group mb_eeprom_group;
161    
162     /* Network Module EEPROMs (3620/3640) */
163     struct nmc93c46_eeprom_def nm_eeprom;
164     struct nmc93c46_group nm_eeprom_group;
165    
166     /* Cisco 3660 NM EEPROMs */
167     struct nmc93c46_eeprom_def c3660_nm_eeprom_def[C3600_MAX_NM_BAYS];
168     struct nmc93c46_group c3660_nm_eeprom_group[C3600_MAX_NM_BAYS];
169     };
170    
171     /* Create a new router instance */
172     c3600_t *c3600_create_instance(char *name,int instance_id);
173    
174     /* Delete a router instance */
175     int c3600_delete_instance(char *name);
176    
177     /* Delete all router instances */
178     int c3600_delete_all_instances(void);
179    
180     /* Save configuration of a C3600 instance */
181     void c3600_save_config(c3600_t *router,FILE *fd);
182    
183     /* Save configurations of all C3600 instances */
184     void c3600_save_config_all(FILE *fd);
185    
186     /* Set NM EEPROM definition */
187     int c3600_nm_set_eeprom(c3600_t *router,u_int nm_bay,
188     const struct c3600_eeprom *eeprom);
189    
190     /* Unset NM EEPROM definition (empty bay) */
191     int c3600_nm_unset_eeprom(c3600_t *router,u_int nm_bay);
192    
193     /* Check if a bay has a Network Module */
194     int c3600_nm_check_eeprom(c3600_t *router,u_int nm_bay);
195    
196     /* Get bay info */
197     struct c3600_nm_bay *c3600_nm_get_info(c3600_t *router,u_int nm_bay);
198    
199     /* Get NM type */
200     char *c3600_nm_get_type(c3600_t *router,u_int nm_bay);
201    
202     /* Get driver info about the specified slot */
203     void *c3600_nm_get_drvinfo(c3600_t *router,u_int nm_bay);
204    
205     /* Set driver info for the specified slot */
206     int c3600_nm_set_drvinfo(c3600_t *router,u_int nm_bay,void *drv_info);
207    
208     /* Add a NM binding */
209     int c3600_nm_add_binding(c3600_t *router,char *dev_type,u_int nm_bay);
210    
211     /* Remove a NM binding */
212     int c3600_nm_remove_binding(c3600_t *router,u_int nm_bay);
213    
214     /* Find a NIO binding */
215     struct c3600_nio_binding *
216     c3600_nm_find_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id);
217    
218     /* Add a network IO binding */
219     int c3600_nm_add_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id,
220     char *nio_name);
221    
222     /* Remove a NIO binding */
223     int c3600_nm_remove_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id);
224    
225     /* Remove all NIO bindings for the specified NM */
226     int c3600_nm_remove_all_nio_bindings(c3600_t *router,u_int nm_bay);
227    
228     /* Enable a Network IO descriptor for a Network Module */
229     int c3600_nm_enable_nio(c3600_t *router,u_int nm_bay,u_int port_id);
230    
231     /* Disable Network IO descriptor of a Network Module */
232     int c3600_nm_disable_nio(c3600_t *router,u_int nm_bay,u_int port_id);
233    
234     /* Enable all NIO of the specified NM */
235     int c3600_nm_enable_all_nio(c3600_t *router,u_int nm_bay);
236    
237     /* Disable all NIO of the specified NM */
238     int c3600_nm_disable_all_nio(c3600_t *router,u_int nm_bay);
239    
240     /* Initialize a Network Module */
241     int c3600_nm_init(c3600_t *router,u_int nm_bay);
242    
243     /* Shutdown a Network Module */
244     int c3600_nm_shutdown(c3600_t *router,u_int nm_bay);
245    
246     /* Shutdown all NM of a router */
247     int c3600_nm_shutdown_all(c3600_t *router);
248    
249     /* Create a Network Module (command line) */
250     int c3600_cmd_nm_create(c3600_t *router,char *str);
251    
252     /* Add a Network IO descriptor binding (command line) */
253     int c3600_cmd_add_nio(c3600_t *router,char *str);
254    
255     /* Show the list of available NM drivers */
256     void c3600_nm_show_drivers(void);
257    
258     /* Set chassis MAC address */
259     int c3600_chassis_set_mac_addr(c3600_t *router,char *mac_addr);
260    
261     /* Set the chassis type */
262     int c3600_chassis_set_type(c3600_t *router,char *chassis_type);
263    
264     /* Get the chassis ID */
265     int c3600_chassis_get_id(c3600_t *router);
266    
267     /* Show the list of available chassis drivers */
268     void c3600_chassis_show_drivers(void);
269    
270     /* Show C3600 hardware info */
271     void c3600_show_hardware(c3600_t *router);
272    
273     /* Initialize default parameters for a C3600 */
274     void c3600_init_defaults(c3600_t *router);
275    
276     /* Initialize the C3600 Platform */
277     int c3600_init_platform(c3600_t *router);
278    
279     /* Initialize a Cisco 3600 instance */
280     int c3600_init_instance(c3600_t *router);
281    
282     /* Stop a Cisco 3600 instance */
283     int c3600_stop_instance(c3600_t *router);
284    
285     /* Initialize EEPROM groups */
286     void c3600_init_eeprom_groups(c3600_t *router);
287    
288     /* dev_c3600_iofpga_init() */
289     int dev_c3600_iofpga_init(c3600_t *router,m_uint64_t paddr,m_uint32_t len);
290    
291     /* NM drivers */
292     extern struct c3600_nm_driver dev_c3600_nm_1e_driver;
293     extern struct c3600_nm_driver dev_c3600_nm_4e_driver;
294     extern struct c3600_nm_driver dev_c3600_nm_1fe_tx_driver;
295     extern struct c3600_nm_driver dev_c3600_nm_4t_driver;
296     extern struct c3600_nm_driver dev_c3600_leopard_2fe_driver;
297    
298     #endif

  ViewVC Help
Powered by ViewVC 1.1.26