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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Sat Oct 6 16:29:14 2007 UTC (16 years, 5 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.7/dev_c3725.h
File MIME type: text/plain
File size: 8391 byte(s)
dynamips-0.2.7

1 dpavlin 4 /*
2 dpavlin 8 * Cisco router simulation platform.
3 dpavlin 4 * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4     *
5     * Generic Cisco 3725 routines and definitions (EEPROM,...).
6     */
7    
8     #ifndef __DEV_C3725_H__
9     #define __DEV_C3725_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 dpavlin 8 #include "nmc93cX6.h"
18 dpavlin 4 #include "net_io.h"
19     #include "vm.h"
20    
21     /* Default C3725 parameters */
22     #define C3725_DEFAULT_RAM_SIZE 128
23     #define C3725_DEFAULT_ROM_SIZE 2
24     #define C3725_DEFAULT_NVRAM_SIZE 128
25     #define C3725_DEFAULT_CONF_REG 0x2102
26     #define C3725_DEFAULT_CLOCK_DIV 8
27     #define C3725_DEFAULT_RAM_MMAP 1
28     #define C3725_DEFAULT_DISK0_SIZE 16
29     #define C3725_DEFAULT_DISK1_SIZE 0
30     #define C3725_DEFAULT_IOMEM_SIZE 5 /* Percents! */
31    
32     /* 3725 characteritics: 2 NM, 3 WIC, 2 AIM */
33     #define C3725_MAX_NM_BAYS 3
34    
35     /* C3725 DUART Interrupt */
36     #define C3725_DUART_IRQ 5
37    
38     /* C3725 Network I/O Interrupt */
39     #define C3725_NETIO_IRQ 2
40    
41     /* C3725 GT64k DMA/Timer Interrupt */
42     #define C3725_GT96K_IRQ 3
43    
44     /* C3725 External Interrupt */
45     #define C3725_EXT_IRQ 6
46    
47 dpavlin 8 /* Network IRQ */
48     #define C3725_NETIO_IRQ_BASE 32
49 dpavlin 9 #define C3725_NETIO_IRQ_PORT_BITS 2
50 dpavlin 8 #define C3725_NETIO_IRQ_PORT_MASK ((1 << C3725_NETIO_IRQ_PORT_BITS) - 1)
51     #define C3725_NETIO_IRQ_PER_SLOT (1 << C3725_NETIO_IRQ_PORT_BITS)
52     #define C3725_NETIO_IRQ_END \
53     (C3725_NETIO_IRQ_BASE + (C3725_MAX_NM_BAYS * C3725_NETIO_IRQ_PER_SLOT) - 1)
54    
55 dpavlin 4 /* C3725 common device addresses */
56     #define C3725_GT96K_ADDR 0x14000000ULL
57     #define C3725_IOFPGA_ADDR 0x1e800000ULL
58     #define C3725_DUART_ADDR 0x3c100000ULL
59     #define C3725_BITBUCKET_ADDR 0x1ec00000ULL
60     #define C3725_ROM_ADDR 0x1fc00000ULL
61     #define C3725_SLOT0_ADDR 0x30000000ULL
62     #define C3725_SLOT1_ADDR 0x32000000ULL
63     #define C3725_PCI_IO_ADDR 0x100000000ULL
64    
65     /* Offset of simulated NVRAM in ROM flash */
66     #define C3725_NVRAM_OFFSET 0xE0000
67     #define C3725_NVRAM_SIZE 0xE000
68    
69     /* Reserved space for ROM in NVRAM */
70     #define C3725_NVRAM_ROM_RES_SIZE 2048
71    
72     /* C3725 ELF Platform ID */
73     #define C3725_ELF_MACHINE_ID 0xFF /* ??? */
74    
75     /* C3725 router */
76     typedef struct c3725_router c3725_t;
77    
78     /* Prototype of NM driver initialization function */
79     typedef int (*c3725_nm_init_fn)(c3725_t *router,char *name,u_int nm_bay);
80    
81     /* Prototype of NM driver shutdown function */
82     typedef int (*c3725_nm_shutdown_fn)(c3725_t *router,u_int nm_bay);
83    
84     /* Prototype of NM NIO set function */
85     typedef int (*c3725_nm_set_nio_fn)(c3725_t *router,u_int nm_bay,u_int port_id,
86     netio_desc_t *nio);
87    
88     /* Prototype of NM NIO unset function */
89     typedef int (*c3725_nm_unset_nio_fn)(c3725_t *router,u_int nm_bay,
90     u_int port_id);
91    
92     /* Prototype of NM NIO show info function */
93     typedef int (*c3725_nm_show_info_fn)(c3725_t *router,u_int nm_bay);
94    
95     /* C3725 Network Module Driver */
96     struct c3725_nm_driver {
97     char *dev_type;
98     int supported;
99     int wic_slots;
100     c3725_nm_init_fn nm_init;
101     c3725_nm_shutdown_fn nm_shutdown;
102     c3725_nm_set_nio_fn nm_set_nio;
103     c3725_nm_unset_nio_fn nm_unset_nio;
104     c3725_nm_show_info_fn nm_show_info;
105    
106     /* TODO: WAN Interface Cards (WIC) */
107     };
108    
109     /* C3725 NIO binding to a slot/port */
110     struct c3725_nio_binding {
111     netio_desc_t *nio;
112     u_int port_id;
113     struct c3725_nio_binding *prev,*next;
114     };
115    
116     /* C3725 NM bay */
117     struct c3725_nm_bay {
118     char *dev_name; /* Device name */
119     char *dev_type; /* Device Type */
120     struct cisco_eeprom eeprom; /* NM EEPROM */
121     struct pci_bus *pci_map; /* PCI bus */
122     struct c3725_nm_driver *nm_driver; /* NM Driver */
123     void *drv_info; /* Private driver info */
124     struct c3725_nio_binding *nio_list; /* NIO bindings to ports */
125     };
126    
127     /* C3725 router */
128     struct c3725_router {
129     /* Chassis MAC address */
130     n_eth_addr_t mac_addr;
131    
132     /* Associated VM instance */
133     vm_instance_t *vm;
134    
135     /* IO memory size to be passed to Smart Init */
136     u_int nm_iomem_size;
137    
138 dpavlin 8 /* I/O FPGA */
139     struct c3725_iofpga_data *iofpga_data;
140    
141 dpavlin 4 /* Chassis information */
142     struct c3725_nm_bay nm_bay[C3725_MAX_NM_BAYS];
143     m_uint8_t oir_status;
144    
145     /*
146     * Mainboard EEPROM.
147     * It can be modified to change the chassis MAC address.
148     */
149     struct cisco_eeprom mb_eeprom;
150 dpavlin 8 struct nmc93cX6_group mb_eeprom_group;
151 dpavlin 4
152     /* Network Module EEPROMs */
153 dpavlin 8 struct nmc93cX6_group nm_eeprom_group[2];
154 dpavlin 4 };
155    
156     /* Create a new router instance */
157     c3725_t *c3725_create_instance(char *name,int instance_id);
158    
159     /* Delete a router instance */
160     int c3725_delete_instance(char *name);
161    
162     /* Delete all router instances */
163     int c3725_delete_all_instances(void);
164    
165     /* Save configuration of a C3725 instance */
166     void c3725_save_config(c3725_t *router,FILE *fd);
167    
168     /* Save configurations of all C3725 instances */
169     void c3725_save_config_all(FILE *fd);
170    
171 dpavlin 8 /* Get network IRQ for specified slot/port */
172     u_int c3725_net_irq_for_slot_port(u_int slot,u_int port);
173    
174 dpavlin 4 /* Get PCI device for the specified NM bay */
175     int c3725_nm_get_pci_device(u_int nm_bay);
176    
177     /* Set NM EEPROM definition */
178     int c3725_nm_set_eeprom(c3725_t *router,u_int nm_bay,
179     const struct cisco_eeprom *eeprom);
180    
181     /* Unset NM EEPROM definition (empty bay) */
182     int c3725_nm_unset_eeprom(c3725_t *router,u_int nm_bay);
183    
184     /* Check if a bay has a Network Module */
185     int c3725_nm_check_eeprom(c3725_t *router,u_int nm_bay);
186    
187     /* Get bay info */
188     struct c3725_nm_bay *c3725_nm_get_info(c3725_t *router,u_int nm_bay);
189    
190     /* Get NM type */
191     char *c3725_nm_get_type(c3725_t *router,u_int nm_bay);
192    
193     /* Get driver info about the specified slot */
194     void *c3725_nm_get_drvinfo(c3725_t *router,u_int nm_bay);
195    
196     /* Set driver info for the specified slot */
197     int c3725_nm_set_drvinfo(c3725_t *router,u_int nm_bay,void *drv_info);
198    
199     /* Add a NM binding */
200     int c3725_nm_add_binding(c3725_t *router,char *dev_type,u_int nm_bay);
201    
202     /* Remove a NM binding */
203     int c3725_nm_remove_binding(c3725_t *router,u_int nm_bay);
204    
205     /* Find a NIO binding */
206     struct c3725_nio_binding *
207     c3725_nm_find_nio_binding(c3725_t *router,u_int nm_bay,u_int port_id);
208    
209     /* Add a network IO binding */
210     int c3725_nm_add_nio_binding(c3725_t *router,u_int nm_bay,u_int port_id,
211     char *nio_name);
212    
213     /* Remove a NIO binding */
214     int c3725_nm_remove_nio_binding(c3725_t *router,u_int nm_bay,u_int port_id);
215    
216     /* Remove all NIO bindings for the specified NM */
217     int c3725_nm_remove_all_nio_bindings(c3725_t *router,u_int nm_bay);
218    
219     /* Enable a Network IO descriptor for a Network Module */
220     int c3725_nm_enable_nio(c3725_t *router,u_int nm_bay,u_int port_id);
221    
222     /* Disable Network IO descriptor of a Network Module */
223     int c3725_nm_disable_nio(c3725_t *router,u_int nm_bay,u_int port_id);
224    
225     /* Enable all NIO of the specified NM */
226     int c3725_nm_enable_all_nio(c3725_t *router,u_int nm_bay);
227    
228     /* Disable all NIO of the specified NM */
229     int c3725_nm_disable_all_nio(c3725_t *router,u_int nm_bay);
230    
231     /* Initialize a Network Module */
232     int c3725_nm_init(c3725_t *router,u_int nm_bay);
233    
234     /* Shutdown a Network Module */
235     int c3725_nm_shutdown(c3725_t *router,u_int nm_bay);
236    
237     /* Shutdown all NM of a router */
238     int c3725_nm_shutdown_all(c3725_t *router);
239    
240     /* Show info about all NMs */
241     int c3725_nm_show_all_info(c3725_t *router);
242    
243     /* Create a Network Module (command line) */
244     int c3725_cmd_nm_create(c3725_t *router,char *str);
245    
246     /* Add a Network IO descriptor binding (command line) */
247     int c3725_cmd_add_nio(c3725_t *router,char *str);
248    
249     /* Show the list of available NM drivers */
250     void c3725_nm_show_drivers(void);
251    
252     /* Set chassis MAC address */
253     int c3725_chassis_set_mac_addr(c3725_t *router,char *mac_addr);
254    
255     /* Show C3725 hardware info */
256     void c3725_show_hardware(c3725_t *router);
257    
258     /* Initialize default parameters for a C3725 */
259     void c3725_init_defaults(c3725_t *router);
260    
261     /* Initialize the C3725 Platform */
262     int c3725_init_platform(c3725_t *router);
263    
264     /* Initialize a Cisco 3725 instance */
265     int c3725_init_instance(c3725_t *router);
266    
267     /* Stop a Cisco 3725 instance */
268     int c3725_stop_instance(c3725_t *router);
269    
270     /* Initialize EEPROM groups */
271     void c3725_init_eeprom_groups(c3725_t *router);
272    
273     /* NM drivers */
274     extern struct c3725_nm_driver dev_c3725_nm_1fe_tx_driver;
275     extern struct c3725_nm_driver dev_c3725_gt96100_fe_driver;
276     extern struct c3725_nm_driver dev_c3725_nm_4t_driver;
277     extern struct c3725_nm_driver dev_c3725_nm_16esw_driver;
278    
279     #endif

  ViewVC Help
Powered by ViewVC 1.1.26