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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations)
Sat Oct 6 16:23:47 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 8517 byte(s)
dynamips-0.2.7-RC1

1 dpavlin 7 /*
2     * Cisco router simulation platform.
3     * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4     *
5     * Generic Cisco 2600 routines and definitions (EEPROM,...).
6     */
7    
8     #ifndef __DEV_C2600_H__
9     #define __DEV_C2600_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 "dev_mpc860.h"
20     #include "vm.h"
21    
22     /* Default C2600 parameters */
23     #define C2600_DEFAULT_MAINBOARD "2610"
24     #define C2600_DEFAULT_RAM_SIZE 64
25     #define C2600_DEFAULT_ROM_SIZE 2
26     #define C2600_DEFAULT_NVRAM_SIZE 128
27     #define C2600_DEFAULT_CONF_REG 0x2102
28     #define C2600_DEFAULT_CLOCK_DIV 8
29     #define C2600_DEFAULT_RAM_MMAP 1
30     #define C2600_DEFAULT_DISK0_SIZE 0
31     #define C2600_DEFAULT_DISK1_SIZE 0
32     #define C2600_DEFAULT_IOMEM_SIZE 15 /* Percents! */
33    
34     /* 2600 characteristics: 1 NM + mainboard */
35     #define C2600_MAX_NM_BAYS 2
36    
37     /* C2600 Virtual Timer Interrupt */
38     #define C2600_VTIMER_IRQ 0
39    
40     /* C2600 DUART Interrupt */
41     #define C2600_DUART_IRQ 1
42    
43     /* C2600 Network I/O Interrupt */
44     #define C2600_NETIO_IRQ 2
45    
46     /* C2600 PA Management Interrupt */
47     #define C2600_PA_MGMT_IRQ 3
48    
49     /* C2600 common device addresses */
50     #define C2600_IOFPGA_ADDR 0x67400000ULL
51     #define C2600_NVRAM_ADDR 0x67c00000ULL
52     #define C2600_FLASH_ADDR 0x60000000ULL
53     #define C2600_PCICTRL_ADDR 0x68000000ULL
54     #define C2600_MPC860_ADDR 0x68010000ULL
55     #define C2600_DUART_ADDR 0xffe00000ULL
56     #define C2600_ROM_ADDR 0xfff00000ULL
57    
58     /* Reserved space for ROM in NVRAM */
59     #define C2600_NVRAM_ROM_RES_SIZE 2048
60    
61     /* C2600 ELF Platform ID */
62     #define C2600_ELF_MACHINE_ID 0x2b
63    
64     /* C2600 router */
65     typedef struct c2600_router c2600_t;
66    
67     /* Prototype of NM driver initialization function */
68     typedef int (*c2600_nm_init_fn)(c2600_t *router,char *name,u_int nm_bay);
69    
70     /* Prototype of NM driver shutdown function */
71     typedef int (*c2600_nm_shutdown_fn)(c2600_t *router,u_int nm_bay);
72    
73     /* Prototype of NM NIO set function */
74     typedef int (*c2600_nm_set_nio_fn)(c2600_t *router,u_int nm_bay,u_int port_id,
75     netio_desc_t *nio);
76    
77     /* Prototype of NM NIO unset function */
78     typedef int (*c2600_nm_unset_nio_fn)(c2600_t *router,u_int nm_bay,
79     u_int port_id);
80    
81     /* Prototype of NM NIO show info function */
82     typedef int (*c2600_nm_show_info_fn)(c2600_t *router,u_int nm_bay);
83    
84     /* C2600 Network Module Driver */
85     struct c2600_nm_driver {
86     char *dev_type;
87     int supported;
88     int wic_slots;
89     c2600_nm_init_fn nm_init;
90     c2600_nm_shutdown_fn nm_shutdown;
91     c2600_nm_set_nio_fn nm_set_nio;
92     c2600_nm_unset_nio_fn nm_unset_nio;
93     c2600_nm_show_info_fn nm_show_info;
94    
95     /* TODO: WAN Interface Cards (WIC) */
96     };
97    
98     /* C2600 NIO binding to a slot/port */
99     struct c2600_nio_binding {
100     netio_desc_t *nio;
101     u_int port_id;
102     struct c2600_nio_binding *prev,*next;
103     };
104    
105     /* C2600 NM bay */
106     struct c2600_nm_bay {
107     char *dev_name; /* Device name */
108     char *dev_type; /* Device Type */
109     struct cisco_eeprom eeprom; /* NM EEPROM */
110     struct pci_bus *pci_map; /* PCI bus */
111     struct c2600_nm_driver *nm_driver; /* NM Driver */
112     void *drv_info; /* Private driver info */
113     struct c2600_nio_binding *nio_list; /* NIO bindings to ports */
114     };
115    
116     /* C2600 router */
117     struct c2600_router {
118     /* Mainboard type (2610, 2611, etc) */
119     char *mainboard_type;
120    
121     /* Chassis MAC address */
122     n_eth_addr_t mac_addr;
123    
124     /* Associated VM instance */
125     vm_instance_t *vm;
126    
127     /* IO memory size to be passed to Smart Init */
128     u_int nm_iomem_size;
129    
130     /* Chassis information */
131     struct c2600_nm_bay nm_bay[C2600_MAX_NM_BAYS];
132     m_uint8_t oir_status;
133    
134     /*
135     * Mainboard EEPROM.
136     * It can be modified to change the chassis MAC address.
137     */
138     struct cisco_eeprom mb_eeprom;
139     struct nmc93c46_group mb_eeprom_group;
140    
141     /* Network Module EEPROM */
142     struct nmc93c46_group nm_eeprom_group;
143    
144     /* MPC860 device private data */
145     struct mpc860_data *mpc_data;
146     };
147    
148     /* Create a new router instance */
149     c2600_t *c2600_create_instance(char *name,int instance_id);
150    
151     /* Delete a router instance */
152     int c2600_delete_instance(char *name);
153    
154     /* Delete all router instances */
155     int c2600_delete_all_instances(void);
156    
157     /* Save configuration of a C2600 instance */
158     void c2600_save_config(c2600_t *router,FILE *fd);
159    
160     /* Save configurations of all C2600 instances */
161     void c2600_save_config_all(FILE *fd);
162    
163     /* Show all available mainboards */
164     void c2600_mainboard_show_drivers(void);
165    
166     /* Set NM EEPROM definition */
167     int c2600_nm_set_eeprom(c2600_t *router,u_int nm_bay,
168     const struct cisco_eeprom *eeprom);
169    
170     /* Unset NM EEPROM definition (empty bay) */
171     int c2600_nm_unset_eeprom(c2600_t *router,u_int nm_bay);
172    
173     /* Check if a bay has a Network Module */
174     int c2600_nm_check_eeprom(c2600_t *router,u_int nm_bay);
175    
176     /* Get bay info */
177     struct c2600_nm_bay *c2600_nm_get_info(c2600_t *router,u_int nm_bay);
178    
179     /* Get NM type */
180     char *c2600_nm_get_type(c2600_t *router,u_int nm_bay);
181    
182     /* Get driver info about the specified slot */
183     void *c2600_nm_get_drvinfo(c2600_t *router,u_int nm_bay);
184    
185     /* Set driver info for the specified slot */
186     int c2600_nm_set_drvinfo(c2600_t *router,u_int nm_bay,void *drv_info);
187    
188     /* Add a NM binding */
189     int c2600_nm_add_binding(c2600_t *router,char *dev_type,u_int nm_bay);
190    
191     /* Remove a NM binding */
192     int c2600_nm_remove_binding(c2600_t *router,u_int nm_bay);
193    
194     /* Find a NIO binding */
195     struct c2600_nio_binding *
196     c2600_nm_find_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id);
197    
198     /* Add a network IO binding */
199     int c2600_nm_add_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id,
200     char *nio_name);
201    
202     /* Remove a NIO binding */
203     int c2600_nm_remove_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id);
204    
205     /* Remove all NIO bindings for the specified NM */
206     int c2600_nm_remove_all_nio_bindings(c2600_t *router,u_int nm_bay);
207    
208     /* Enable a Network IO descriptor for a Network Module */
209     int c2600_nm_enable_nio(c2600_t *router,u_int nm_bay,u_int port_id);
210    
211     /* Disable Network IO descriptor of a Network Module */
212     int c2600_nm_disable_nio(c2600_t *router,u_int nm_bay,u_int port_id);
213    
214     /* Enable all NIO of the specified NM */
215     int c2600_nm_enable_all_nio(c2600_t *router,u_int nm_bay);
216    
217     /* Disable all NIO of the specified NM */
218     int c2600_nm_disable_all_nio(c2600_t *router,u_int nm_bay);
219    
220     /* Initialize a Network Module */
221     int c2600_nm_init(c2600_t *router,u_int nm_bay);
222    
223     /* Shutdown a Network Module */
224     int c2600_nm_shutdown(c2600_t *router,u_int nm_bay);
225    
226     /* Shutdown all NM of a router */
227     int c2600_nm_shutdown_all(c2600_t *router);
228    
229     /* Show info about all NMs */
230     int c2600_nm_show_all_info(c2600_t *router);
231    
232     /* Create a Network Module (command line) */
233     int c2600_cmd_nm_create(c2600_t *router,char *str);
234    
235     /* Add a Network IO descriptor binding (command line) */
236     int c2600_cmd_add_nio(c2600_t *router,char *str);
237    
238     /* Show the list of available NM drivers */
239     void c2600_nm_show_drivers(void);
240    
241     /* Set mainboard type */
242     int c2600_mainboard_set_type(c2600_t *router,char *mainboard_type);
243    
244     /* Set chassis MAC address */
245     int c2600_chassis_set_mac_addr(c2600_t *router,char *mac_addr);
246    
247     /* Show C2600 hardware info */
248     void c2600_show_hardware(c2600_t *router);
249    
250     /* Initialize default parameters for a C2600 */
251     void c2600_init_defaults(c2600_t *router);
252    
253     /* Initialize the C2600 Platform */
254     int c2600_init_platform(c2600_t *router);
255    
256     /* Initialize a Cisco 2600 instance */
257     int c2600_init_instance(c2600_t *router);
258    
259     /* Stop a Cisco 2600 instance */
260     int c2600_stop_instance(c2600_t *router);
261    
262     /* Initialize EEPROM groups */
263     void c2600_init_eeprom_groups(c2600_t *router);
264    
265     /* Create the c2600 PCI controller device */
266     int dev_c2600_pci_init(vm_instance_t *vm,char *name,
267     m_uint64_t paddr,m_uint32_t len,
268     struct pci_bus *bus);
269    
270     /* dev_c2600_iofpga_init() */
271     int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len);
272    
273     /* NM drivers */
274     extern struct c2600_nm_driver dev_c2600_mb1e_eth_driver;
275     extern struct c2600_nm_driver dev_c2600_mb2e_eth_driver;
276     extern struct c2600_nm_driver dev_c2600_mb1fe_eth_driver;
277     extern struct c2600_nm_driver dev_c2600_mb2fe_eth_driver;
278    
279     extern struct c2600_nm_driver dev_c2600_nm_1e_driver;
280     extern struct c2600_nm_driver dev_c2600_nm_4e_driver;
281     extern struct c2600_nm_driver dev_c2600_nm_1fe_tx_driver;
282     extern struct c2600_nm_driver dev_c2600_nm_16esw_driver;
283    
284     #endif

  ViewVC Help
Powered by ViewVC 1.1.26