/[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 5 - (hide annotations)
Sat Oct 6 16:08:03 2007 UTC (12 years, 1 month ago) by dpavlin
Original Path: upstream/dynamips-0.2.6-RC4/dev_c3600.h
File MIME type: text/plain
File size: 8782 byte(s)
dynamips-0.2.6-RC4

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

  ViewVC Help
Powered by ViewVC 1.1.26