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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Sat Oct 6 16:24:54 2007 UTC (16 years, 5 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.7-RC2/dev_c2600.h
File MIME type: text/plain
File size: 9036 byte(s)
dynamips-0.2.7-RC2

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 dpavlin 8 #include "nmc93cX6.h"
18 dpavlin 7 #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 dpavlin 8 /* Network IRQ */
50     #define C2600_NETIO_IRQ_BASE 32
51     #define C2600_NETIO_IRQ_PORT_BITS 2
52     #define C2600_NETIO_IRQ_PORT_MASK ((1 << C2600_NETIO_IRQ_PORT_BITS) - 1)
53     #define C2600_NETIO_IRQ_PER_SLOT (1 << C2600_NETIO_IRQ_PORT_BITS)
54     #define C2600_NETIO_IRQ_END \
55     (C2600_NETIO_IRQ_BASE + (C2600_MAX_NM_BAYS * C2600_NETIO_IRQ_PER_SLOT) - 1)
56    
57 dpavlin 7 /* C2600 common device addresses */
58     #define C2600_IOFPGA_ADDR 0x67400000ULL
59     #define C2600_NVRAM_ADDR 0x67c00000ULL
60     #define C2600_FLASH_ADDR 0x60000000ULL
61     #define C2600_PCICTRL_ADDR 0x68000000ULL
62     #define C2600_MPC860_ADDR 0x68010000ULL
63     #define C2600_DUART_ADDR 0xffe00000ULL
64     #define C2600_ROM_ADDR 0xfff00000ULL
65    
66     /* Reserved space for ROM in NVRAM */
67     #define C2600_NVRAM_ROM_RES_SIZE 2048
68    
69     /* C2600 ELF Platform ID */
70     #define C2600_ELF_MACHINE_ID 0x2b
71    
72     /* C2600 router */
73     typedef struct c2600_router c2600_t;
74    
75     /* Prototype of NM driver initialization function */
76     typedef int (*c2600_nm_init_fn)(c2600_t *router,char *name,u_int nm_bay);
77    
78     /* Prototype of NM driver shutdown function */
79     typedef int (*c2600_nm_shutdown_fn)(c2600_t *router,u_int nm_bay);
80    
81     /* Prototype of NM NIO set function */
82     typedef int (*c2600_nm_set_nio_fn)(c2600_t *router,u_int nm_bay,u_int port_id,
83     netio_desc_t *nio);
84    
85     /* Prototype of NM NIO unset function */
86     typedef int (*c2600_nm_unset_nio_fn)(c2600_t *router,u_int nm_bay,
87     u_int port_id);
88    
89     /* Prototype of NM NIO show info function */
90     typedef int (*c2600_nm_show_info_fn)(c2600_t *router,u_int nm_bay);
91    
92     /* C2600 Network Module Driver */
93     struct c2600_nm_driver {
94     char *dev_type;
95     int supported;
96     int wic_slots;
97     c2600_nm_init_fn nm_init;
98     c2600_nm_shutdown_fn nm_shutdown;
99     c2600_nm_set_nio_fn nm_set_nio;
100     c2600_nm_unset_nio_fn nm_unset_nio;
101     c2600_nm_show_info_fn nm_show_info;
102    
103     /* TODO: WAN Interface Cards (WIC) */
104     };
105    
106     /* C2600 NIO binding to a slot/port */
107     struct c2600_nio_binding {
108     netio_desc_t *nio;
109     u_int port_id;
110     struct c2600_nio_binding *prev,*next;
111     };
112    
113     /* C2600 NM bay */
114     struct c2600_nm_bay {
115     char *dev_name; /* Device name */
116     char *dev_type; /* Device Type */
117     struct cisco_eeprom eeprom; /* NM EEPROM */
118     struct pci_bus *pci_map; /* PCI bus */
119     struct c2600_nm_driver *nm_driver; /* NM Driver */
120     void *drv_info; /* Private driver info */
121     struct c2600_nio_binding *nio_list; /* NIO bindings to ports */
122     };
123    
124     /* C2600 router */
125     struct c2600_router {
126     /* Mainboard type (2610, 2611, etc) */
127     char *mainboard_type;
128    
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 c2600_iofpga_data *iofpga_data;
140    
141 dpavlin 7 /* Chassis information */
142     struct c2600_nm_bay nm_bay[C2600_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 7
152     /* Network Module EEPROM */
153 dpavlin 8 struct nmc93cX6_group nm_eeprom_group;
154 dpavlin 7
155     /* MPC860 device private data */
156     struct mpc860_data *mpc_data;
157     };
158    
159     /* Create a new router instance */
160     c2600_t *c2600_create_instance(char *name,int instance_id);
161    
162     /* Delete a router instance */
163     int c2600_delete_instance(char *name);
164    
165     /* Delete all router instances */
166     int c2600_delete_all_instances(void);
167    
168     /* Save configuration of a C2600 instance */
169     void c2600_save_config(c2600_t *router,FILE *fd);
170    
171     /* Save configurations of all C2600 instances */
172     void c2600_save_config_all(FILE *fd);
173    
174 dpavlin 8 /* Get network IRQ for specified slot/port */
175     u_int c2600_net_irq_for_slot_port(u_int slot,u_int port);
176    
177 dpavlin 7 /* Show all available mainboards */
178     void c2600_mainboard_show_drivers(void);
179    
180     /* Set NM EEPROM definition */
181     int c2600_nm_set_eeprom(c2600_t *router,u_int nm_bay,
182     const struct cisco_eeprom *eeprom);
183    
184     /* Unset NM EEPROM definition (empty bay) */
185     int c2600_nm_unset_eeprom(c2600_t *router,u_int nm_bay);
186    
187     /* Check if a bay has a Network Module */
188     int c2600_nm_check_eeprom(c2600_t *router,u_int nm_bay);
189    
190     /* Get bay info */
191     struct c2600_nm_bay *c2600_nm_get_info(c2600_t *router,u_int nm_bay);
192    
193     /* Get NM type */
194     char *c2600_nm_get_type(c2600_t *router,u_int nm_bay);
195    
196     /* Get driver info about the specified slot */
197     void *c2600_nm_get_drvinfo(c2600_t *router,u_int nm_bay);
198    
199     /* Set driver info for the specified slot */
200     int c2600_nm_set_drvinfo(c2600_t *router,u_int nm_bay,void *drv_info);
201    
202     /* Add a NM binding */
203     int c2600_nm_add_binding(c2600_t *router,char *dev_type,u_int nm_bay);
204    
205     /* Remove a NM binding */
206     int c2600_nm_remove_binding(c2600_t *router,u_int nm_bay);
207    
208     /* Find a NIO binding */
209     struct c2600_nio_binding *
210     c2600_nm_find_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id);
211    
212     /* Add a network IO binding */
213     int c2600_nm_add_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id,
214     char *nio_name);
215    
216     /* Remove a NIO binding */
217     int c2600_nm_remove_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id);
218    
219     /* Remove all NIO bindings for the specified NM */
220     int c2600_nm_remove_all_nio_bindings(c2600_t *router,u_int nm_bay);
221    
222     /* Enable a Network IO descriptor for a Network Module */
223     int c2600_nm_enable_nio(c2600_t *router,u_int nm_bay,u_int port_id);
224    
225     /* Disable Network IO descriptor of a Network Module */
226     int c2600_nm_disable_nio(c2600_t *router,u_int nm_bay,u_int port_id);
227    
228     /* Enable all NIO of the specified NM */
229     int c2600_nm_enable_all_nio(c2600_t *router,u_int nm_bay);
230    
231     /* Disable all NIO of the specified NM */
232     int c2600_nm_disable_all_nio(c2600_t *router,u_int nm_bay);
233    
234     /* Initialize a Network Module */
235     int c2600_nm_init(c2600_t *router,u_int nm_bay);
236    
237     /* Shutdown a Network Module */
238     int c2600_nm_shutdown(c2600_t *router,u_int nm_bay);
239    
240     /* Shutdown all NM of a router */
241     int c2600_nm_shutdown_all(c2600_t *router);
242    
243     /* Show info about all NMs */
244     int c2600_nm_show_all_info(c2600_t *router);
245    
246     /* Create a Network Module (command line) */
247     int c2600_cmd_nm_create(c2600_t *router,char *str);
248    
249     /* Add a Network IO descriptor binding (command line) */
250     int c2600_cmd_add_nio(c2600_t *router,char *str);
251    
252     /* Show the list of available NM drivers */
253     void c2600_nm_show_drivers(void);
254    
255     /* Set mainboard type */
256     int c2600_mainboard_set_type(c2600_t *router,char *mainboard_type);
257    
258     /* Set chassis MAC address */
259     int c2600_chassis_set_mac_addr(c2600_t *router,char *mac_addr);
260    
261     /* Show C2600 hardware info */
262     void c2600_show_hardware(c2600_t *router);
263    
264     /* Initialize default parameters for a C2600 */
265     void c2600_init_defaults(c2600_t *router);
266    
267     /* Initialize the C2600 Platform */
268     int c2600_init_platform(c2600_t *router);
269    
270     /* Initialize a Cisco 2600 instance */
271     int c2600_init_instance(c2600_t *router);
272    
273     /* Stop a Cisco 2600 instance */
274     int c2600_stop_instance(c2600_t *router);
275    
276     /* Initialize EEPROM groups */
277     void c2600_init_eeprom_groups(c2600_t *router);
278    
279     /* Create the c2600 PCI controller device */
280     int dev_c2600_pci_init(vm_instance_t *vm,char *name,
281     m_uint64_t paddr,m_uint32_t len,
282     struct pci_bus *bus);
283    
284     /* dev_c2600_iofpga_init() */
285     int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len);
286    
287     /* NM drivers */
288     extern struct c2600_nm_driver dev_c2600_mb1e_eth_driver;
289     extern struct c2600_nm_driver dev_c2600_mb2e_eth_driver;
290     extern struct c2600_nm_driver dev_c2600_mb1fe_eth_driver;
291     extern struct c2600_nm_driver dev_c2600_mb2fe_eth_driver;
292    
293     extern struct c2600_nm_driver dev_c2600_nm_1e_driver;
294     extern struct c2600_nm_driver dev_c2600_nm_4e_driver;
295     extern struct c2600_nm_driver dev_c2600_nm_1fe_tx_driver;
296     extern struct c2600_nm_driver dev_c2600_nm_16esw_driver;
297    
298     #endif

  ViewVC Help
Powered by ViewVC 1.1.26