/[dynamips]/upstream/dynamips-0.2.7-RC2/dev_c3745.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 /upstream/dynamips-0.2.7-RC2/dev_c3745.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Sat Oct 6 16:24:54 2007 UTC (12 years, 2 months ago) by dpavlin
File MIME type: text/plain
File size: 8410 byte(s)
dynamips-0.2.7-RC2

1 dpavlin 4 /*
2     * Cisco 3745 simulation platform.
3     * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4     *
5     * Generic Cisco 3745 routines and definitions (EEPROM,...).
6     */
7    
8     #ifndef __DEV_C3745_H__
9     #define __DEV_C3745_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 C3745 parameters */
22     #define C3745_DEFAULT_RAM_SIZE 128
23     #define C3745_DEFAULT_ROM_SIZE 2
24     #define C3745_DEFAULT_NVRAM_SIZE 128
25     #define C3745_DEFAULT_CONF_REG 0x2102
26     #define C3745_DEFAULT_CLOCK_DIV 8
27     #define C3745_DEFAULT_RAM_MMAP 1
28     #define C3745_DEFAULT_DISK0_SIZE 16
29     #define C3745_DEFAULT_DISK1_SIZE 0
30     #define C3745_DEFAULT_IOMEM_SIZE 5 /* Percents! */
31    
32 dpavlin 8 /* 3745 characteritics: 4 NM, 3 WIC, 2 AIM */
33 dpavlin 4 #define C3745_MAX_NM_BAYS 5
34    
35     /* C3745 DUART Interrupt */
36     #define C3745_DUART_IRQ 5
37    
38     /* C3745 Network I/O Interrupt */
39     #define C3745_NETIO_IRQ 2
40    
41     /* C3745 GT64k DMA/Timer Interrupt */
42     #define C3745_GT96K_IRQ 3
43    
44     /* C3745 External Interrupt */
45     #define C3745_EXT_IRQ 6
46    
47 dpavlin 8 /* Network IRQ */
48     #define C3745_NETIO_IRQ_BASE 32
49     #define C3745_NETIO_IRQ_PORT_BITS 2
50     #define C3745_NETIO_IRQ_PORT_MASK ((1 << C3745_NETIO_IRQ_PORT_BITS) - 1)
51     #define C3745_NETIO_IRQ_PER_SLOT (1 << C3745_NETIO_IRQ_PORT_BITS)
52     #define C3745_NETIO_IRQ_END \
53     (C3745_NETIO_IRQ_BASE + (C3745_MAX_NM_BAYS * C3745_NETIO_IRQ_PER_SLOT) - 1)
54    
55 dpavlin 4 /* C3745 common device addresses */
56     #define C3745_GT96K_ADDR 0x24000000ULL
57     #define C3745_IOFPGA_ADDR 0x1fa00000ULL
58     #define C3745_DUART_ADDR 0x3c100000ULL
59     #define C3745_BITBUCKET_ADDR 0x1ec00000ULL
60     #define C3745_ROM_ADDR 0x1fc00000ULL
61     #define C3745_SLOT0_ADDR 0x30000000ULL
62     #define C3745_SLOT1_ADDR 0x32000000ULL
63     #define C3745_PCI_IO_ADDR 0x100000000ULL
64    
65     /* Offset of simulated NVRAM in ROM flash */
66     #define C3745_NVRAM_OFFSET 0xB0000
67     #define C3745_NVRAM_SIZE 0x20000
68    
69     /* Reserved space for ROM in NVRAM */
70     #define C3745_NVRAM_ROM_RES_SIZE 2048
71    
72     /* C3745 ELF Platform ID */
73     #define C3745_ELF_MACHINE_ID 0xFF /* ??? */
74    
75     /* C3745 router */
76     typedef struct c3745_router c3745_t;
77    
78     /* Prototype of NM driver initialization function */
79     typedef int (*c3745_nm_init_fn)(c3745_t *router,char *name,u_int nm_bay);
80    
81     /* Prototype of NM driver shutdown function */
82     typedef int (*c3745_nm_shutdown_fn)(c3745_t *router,u_int nm_bay);
83    
84     /* Prototype of NM NIO set function */
85     typedef int (*c3745_nm_set_nio_fn)(c3745_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 (*c3745_nm_unset_nio_fn)(c3745_t *router,u_int nm_bay,
90     u_int port_id);
91    
92     /* Prototype of NM NIO show info function */
93     typedef int (*c3745_nm_show_info_fn)(c3745_t *router,u_int nm_bay);
94    
95     /* C3745 Network Module Driver */
96     struct c3745_nm_driver {
97     char *dev_type;
98     int supported;
99     int wic_slots;
100     c3745_nm_init_fn nm_init;
101     c3745_nm_shutdown_fn nm_shutdown;
102     c3745_nm_set_nio_fn nm_set_nio;
103     c3745_nm_unset_nio_fn nm_unset_nio;
104     c3745_nm_show_info_fn nm_show_info;
105    
106     /* TODO: WAN Interface Cards (WIC) */
107     };
108    
109     /* C3745 NIO binding to a slot/port */
110     struct c3745_nio_binding {
111     netio_desc_t *nio;
112     u_int port_id;
113     struct c3745_nio_binding *prev,*next;
114     };
115    
116     /* C3745 NM bay */
117     struct c3745_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 c3745_nm_driver *nm_driver; /* NM Driver */
123     void *drv_info; /* Private driver info */
124     struct c3745_nio_binding *nio_list; /* NIO bindings to ports */
125     };
126    
127     /* C3745 router */
128     struct c3745_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 c3745_iofpga_data *iofpga_data;
140    
141 dpavlin 4 /* Chassis information */
142     struct c3745_nm_bay nm_bay[C3745_MAX_NM_BAYS];
143     m_uint8_t oir_status;
144    
145     /*
146     * System EEPROMs.
147     * It can be modified to change the chassis MAC address.
148     */
149     struct cisco_eeprom sys_eeprom[3];
150 dpavlin 8 struct nmc93cX6_group sys_eeprom_group;
151 dpavlin 4
152     /* Network Module EEPROMs */
153 dpavlin 8 struct nmc93cX6_group nm_eeprom_group[4];
154 dpavlin 4 };
155    
156     /* Create a new router instance */
157     c3745_t *c3745_create_instance(char *name,int instance_id);
158    
159     /* Delete a router instance */
160     int c3745_delete_instance(char *name);
161    
162     /* Delete all router instances */
163     int c3745_delete_all_instances(void);
164    
165     /* Save configuration of a C3745 instance */
166     void c3745_save_config(c3745_t *router,FILE *fd);
167    
168     /* Save configurations of all C3745 instances */
169     void c3745_save_config_all(FILE *fd);
170    
171 dpavlin 8 /* Get network IRQ for specified slot/port */
172     u_int c3745_net_irq_for_slot_port(u_int slot,u_int port);
173    
174 dpavlin 4 /* Set NM EEPROM definition */
175     int c3745_nm_set_eeprom(c3745_t *router,u_int nm_bay,
176     const struct cisco_eeprom *eeprom);
177    
178     /* Unset NM EEPROM definition (empty bay) */
179     int c3745_nm_unset_eeprom(c3745_t *router,u_int nm_bay);
180    
181     /* Check if a bay has a Network Module */
182     int c3745_nm_check_eeprom(c3745_t *router,u_int nm_bay);
183    
184     /* Get bay info */
185     struct c3745_nm_bay *c3745_nm_get_info(c3745_t *router,u_int nm_bay);
186    
187     /* Get NM type */
188     char *c3745_nm_get_type(c3745_t *router,u_int nm_bay);
189    
190     /* Get driver info about the specified slot */
191     void *c3745_nm_get_drvinfo(c3745_t *router,u_int nm_bay);
192    
193     /* Set driver info for the specified slot */
194     int c3745_nm_set_drvinfo(c3745_t *router,u_int nm_bay,void *drv_info);
195    
196     /* Add a NM binding */
197     int c3745_nm_add_binding(c3745_t *router,char *dev_type,u_int nm_bay);
198    
199     /* Remove a NM binding */
200     int c3745_nm_remove_binding(c3745_t *router,u_int nm_bay);
201    
202     /* Find a NIO binding */
203     struct c3745_nio_binding *
204     c3745_nm_find_nio_binding(c3745_t *router,u_int nm_bay,u_int port_id);
205    
206     /* Add a network IO binding */
207     int c3745_nm_add_nio_binding(c3745_t *router,u_int nm_bay,u_int port_id,
208     char *nio_name);
209    
210     /* Remove a NIO binding */
211     int c3745_nm_remove_nio_binding(c3745_t *router,u_int nm_bay,u_int port_id);
212    
213     /* Remove all NIO bindings for the specified NM */
214     int c3745_nm_remove_all_nio_bindings(c3745_t *router,u_int nm_bay);
215    
216     /* Enable a Network IO descriptor for a Network Module */
217     int c3745_nm_enable_nio(c3745_t *router,u_int nm_bay,u_int port_id);
218    
219     /* Disable Network IO descriptor of a Network Module */
220     int c3745_nm_disable_nio(c3745_t *router,u_int nm_bay,u_int port_id);
221    
222     /* Enable all NIO of the specified NM */
223     int c3745_nm_enable_all_nio(c3745_t *router,u_int nm_bay);
224    
225     /* Disable all NIO of the specified NM */
226     int c3745_nm_disable_all_nio(c3745_t *router,u_int nm_bay);
227    
228     /* Initialize a Network Module */
229     int c3745_nm_init(c3745_t *router,u_int nm_bay);
230    
231     /* Shutdown a Network Module */
232     int c3745_nm_shutdown(c3745_t *router,u_int nm_bay);
233    
234     /* Shutdown all NM of a router */
235     int c3745_nm_shutdown_all(c3745_t *router);
236    
237     /* Show info about all NMs */
238     int c3745_nm_show_all_info(c3745_t *router);
239    
240     /* Create a Network Module (command line) */
241     int c3745_cmd_nm_create(c3745_t *router,char *str);
242    
243     /* Add a Network IO descriptor binding (command line) */
244     int c3745_cmd_add_nio(c3745_t *router,char *str);
245    
246     /* Show the list of available NM drivers */
247     void c3745_nm_show_drivers(void);
248    
249     /* Set chassis MAC address */
250     int c3745_chassis_set_mac_addr(c3745_t *router,char *mac_addr);
251    
252     /* Show C3745 hardware info */
253     void c3745_show_hardware(c3745_t *router);
254    
255     /* Initialize default parameters for a C3745 */
256     void c3745_init_defaults(c3745_t *router);
257    
258     /* Initialize the C3745 Platform */
259     int c3745_init_platform(c3745_t *router);
260    
261     /* Initialize a Cisco 3745 instance */
262     int c3745_init_instance(c3745_t *router);
263    
264     /* Stop a Cisco 3745 instance */
265     int c3745_stop_instance(c3745_t *router);
266    
267     /* Initialize EEPROM groups */
268     void c3745_init_eeprom_groups(c3745_t *router);
269    
270     /* dev_c3745_iofpga_init() */
271     int dev_c3745_iofpga_init(c3745_t *router,m_uint64_t paddr,m_uint32_t len);
272    
273     /* NM drivers */
274     extern struct c3745_nm_driver dev_c3745_nm_1fe_tx_driver;
275     extern struct c3745_nm_driver dev_c3745_gt96100_fe_driver;
276     extern struct c3745_nm_driver dev_c3745_nm_4t_driver;
277     extern struct c3745_nm_driver dev_c3745_nm_16esw_driver;
278    
279     #endif

  ViewVC Help
Powered by ViewVC 1.1.26