/[dynamips]/upstream/dynamips-0.2.6-RC3/dev_c7200.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.6-RC3/dev_c7200.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Sat Oct 6 16:06:49 2007 UTC (14 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 10581 byte(s)
dynamips-0.2.6-RC3

1 dpavlin 1 /*
2     * Cisco 7200 (Predator) simulation platform.
3     * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4     *
5     * Generic Cisco 7200 routines and definitions (EEPROM,...).
6     *
7     * Notes on IRQs (see "show stack"):
8     *
9     * - triggering IRQ 3: we get indefinitely (for each slot):
10     * "Error: Unexpected NM Interrupt received from slot: 6"
11     *
12     * - triggering IRQ 4: GT64010 reg access: probably "DMA/Timer Interrupt"
13     *
14     * - triggering IRQ 6: we get (probably "OIR/Error Interrupt")
15     * %ERR-1-PERR: PCI bus parity error
16     * %ERR-1-SERR: PCI bus system/parity error
17     * %ERR-1-FATAL: Fatal error interrupt, No reloading
18     * err_stat=0x0, err_enable=0x0, mgmt_event=0xFFFFFFFF
19     *
20     */
21    
22     #ifndef __DEV_C7200_H__
23     #define __DEV_C7200_H__
24    
25     #include <pthread.h>
26    
27     #include "utils.h"
28     #include "net.h"
29     #include "device.h"
30     #include "pci_dev.h"
31     #include "nmc93c46.h"
32     #include "net_io.h"
33     #include "vm.h"
34    
35     /* Default C7200 parameters */
36     #define C7200_DEFAULT_NPE_TYPE "npe-200"
37     #define C7200_DEFAULT_MIDPLANE "vxr"
38     #define C7200_DEFAULT_RAM_SIZE 256
39     #define C7200_DEFAULT_ROM_SIZE 4
40     #define C7200_DEFAULT_NVRAM_SIZE 128
41     #define C7200_DEFAULT_CONF_REG 0x2102
42     #define C7200_DEFAULT_CLOCK_DIV 4
43     #define C7200_DEFAULT_RAM_MMAP 1
44     #define C7200_DEFAULT_DISK0_SIZE 64
45     #define C7200_DEFAULT_DISK1_SIZE 0
46    
47     /* 6 slots + 1 I/O card */
48     #define C7200_MAX_PA_BAYS 7
49    
50     /* C7200 DUART Interrupt */
51     #define C7200_DUART_IRQ 5
52    
53     /* C7200 Network I/O Interrupt */
54     #define C7200_NETIO_IRQ 2
55    
56     /* C7200 PA Management Interrupt handler */
57     #define C7200_PA_MGMT_IRQ 3
58    
59     /* C7200 GT64k DMA/Timer Interrupt */
60     #define C7200_GT64K_IRQ 4
61    
62     /* C7200 Error/OIR Interrupt */
63     #define C7200_OIR_IRQ 6
64    
65     /* C7200 base ram limit (256 Mb) */
66     #define C7200_BASE_RAM_LIMIT 256
67    
68     /* C7200 common device addresses */
69     #define C7200_GT64K_ADDR 0x14000000ULL
70     #define C7200_GT64K_SEC_ADDR 0x15000000ULL
71     #define C7200_BOOTFLASH_ADDR 0x1a000000ULL
72     #define C7200_NVRAM_ADDR 0x1e000000ULL
73     #define C7200_NPEG1_NVRAM_ADDR 0x1e400000ULL
74     #define C7200_MPFPGA_ADDR 0x1e800000ULL
75     #define C7200_IOFPGA_ADDR 0x1e840000ULL
76     #define C7200_BITBUCKET_ADDR 0x1f000000ULL
77     #define C7200_ROM_ADDR 0x1fc00000ULL
78     #define C7200_IOMEM_ADDR 0x20000000ULL
79     #define C7200_SRAM_ADDR 0x4b000000ULL
80     #define C7200_PCI_IO_ADDR 0x100000000ULL
81    
82     /* Reserved space for ROM in NVRAM */
83     #define C7200_NVRAM_ROM_RES_SIZE 2048
84    
85     /* C7200 physical address bus mask: keep only the lower 33 bits */
86     #define C7200_ADDR_BUS_MASK 0x1ffffffffULL
87    
88     /* C7200 ELF Platform ID */
89     #define C7200_ELF_MACHINE_ID 0x19
90    
91     /* C7200 router */
92     typedef struct c7200_router c7200_t;
93    
94     /* Prototype of NPE driver initialization function */
95     typedef int (*c7200_npe_init_fn)(c7200_t *router);
96    
97     /* Prototype of PA driver initialization function */
98     typedef int (*c7200_pa_init_fn)(c7200_t *router,char *name,u_int pa_bay);
99    
100     /* Prototype of PA driver shutdown function */
101     typedef int (*c7200_pa_shutdown_fn)(c7200_t *router,u_int pa_bay);
102    
103     /* Prototype of PA NIO set function */
104     typedef int (*c7200_pa_set_nio_fn)(c7200_t *router,u_int pa_bay,u_int port_id,
105     netio_desc_t *nio);
106    
107     /* Prototype of PA NIO unset function */
108     typedef int (*c7200_pa_unset_nio_fn)(c7200_t *router,u_int pa_bay,
109     u_int port_id);
110    
111 dpavlin 2 /* Prototype of NM NIO show info function */
112     typedef int (*c7200_pa_show_info_fn)(c7200_t *router,u_int pa_bay);
113    
114 dpavlin 1 /* C7200 Port Adapter Driver */
115     struct c7200_pa_driver {
116     char *dev_type;
117     int supported;
118     c7200_pa_init_fn pa_init;
119     c7200_pa_shutdown_fn pa_shutdown;
120     c7200_pa_set_nio_fn pa_set_nio;
121     c7200_pa_unset_nio_fn pa_unset_nio;
122 dpavlin 2 c7200_pa_show_info_fn pa_show_info;
123 dpavlin 1 };
124    
125     /* C7200 NIO binding to a slot/port */
126     struct c7200_nio_binding {
127     netio_desc_t *nio;
128     u_int port_id;
129     struct c7200_nio_binding *prev,*next;
130     };
131    
132     /* C7200 PA bay */
133     struct c7200_pa_bay {
134     char *dev_name; /* Device Name */
135     char *dev_type; /* Device Type */
136 dpavlin 3 struct cisco_eeprom eeprom; /* PA EEPROM */
137 dpavlin 1 struct pci_bus *pci_map; /* PCI bus */
138     struct c7200_pa_driver *pa_driver; /* PA driver */
139     void *drv_info; /* Private driver info */
140     struct c7200_nio_binding *nio_list; /* NIO bindings to ports */
141     };
142    
143     /* C7200 NPE Driver */
144     struct c7200_npe_driver {
145     char *npe_type;
146     c7200_npe_init_fn npe_init;
147     int max_ram_size;
148     int supported;
149     m_uint64_t nvram_addr;
150     int clpd6729_pci_bus;
151     int clpd6729_pci_dev;
152     int dec21140_pci_bus;
153     int dec21140_pci_dev;
154     };
155    
156     /* C7200 router */
157     struct c7200_router {
158     /* Midplane type (standard,VXR) and chassis MAC address */
159     char *midplane_type;
160     int midplane_version;
161     n_eth_addr_t mac_addr;
162    
163     /* Associated VM instance */
164     vm_instance_t *vm;
165    
166     /* NPE and PA information */
167     struct c7200_npe_driver *npe_driver;
168     struct c7200_pa_bay pa_bay[C7200_MAX_PA_BAYS];
169     m_uint8_t oir_status;
170    
171     /* Hidden I/O bridge hack to support PCMCIA */
172     struct pci_bridge *io_pci_bridge;
173     struct pci_bus *pcmcia_bus;
174    
175     /* Midplane EEPROM can be modified to change the chassis MAC address... */
176 dpavlin 3 struct cisco_eeprom cpu_eeprom,mp_eeprom,pem_eeprom;
177 dpavlin 1
178     struct nmc93c46_group sys_eeprom_g1; /* EEPROMs for CPU and Midplane */
179     struct nmc93c46_group sys_eeprom_g2; /* EEPROM for PEM */
180     struct nmc93c46_group pa_eeprom_g1; /* EEPROMs for bays 0, 1, 3, 4 */
181     struct nmc93c46_group pa_eeprom_g2; /* EEPROMs for bays 2, 5, 6 */
182     };
183    
184     /* Initialize EEPROM groups */
185     void c7200_init_eeprom_groups(c7200_t *router);
186    
187     /* Create a new router instance */
188     c7200_t *c7200_create_instance(char *name,int instance_id);
189    
190     /* Delete a router instance */
191     int c7200_delete_instance(char *name);
192    
193     /* Delete all router instances */
194     int c7200_delete_all_instances(void);
195    
196     /* Save configuration of a C7200 instance */
197     void c7200_save_config(c7200_t *router,FILE *fd);
198    
199     /* Save configurations of all C7200 instances */
200     void c7200_save_config_all(FILE *fd);
201    
202     /* Set PA EEPROM definition */
203     int c7200_pa_set_eeprom(c7200_t *router,u_int pa_bay,
204 dpavlin 3 const struct cisco_eeprom *eeprom);
205 dpavlin 1
206     /* Unset PA EEPROM definition (empty bay) */
207     int c7200_pa_unset_eeprom(c7200_t *router,u_int pa_bay);
208    
209     /* Check if a bay has a port adapter */
210     int c7200_pa_check_eeprom(c7200_t *router,u_int pa_bay);
211    
212     /* Get bay info */
213     struct c7200_pa_bay *c7200_pa_get_info(c7200_t *router,u_int pa_bay);
214    
215     /* Get PA type */
216     char *c7200_pa_get_type(c7200_t *router,u_int pa_bay);
217    
218     /* Get driver info about the specified slot */
219     void *c7200_pa_get_drvinfo(c7200_t *router,u_int pa_bay);
220    
221     /* Set driver info for the specified slot */
222     int c7200_pa_set_drvinfo(c7200_t *router,u_int pa_bay,void *drv_info);
223    
224     /* Add a PA binding */
225     int c7200_pa_add_binding(c7200_t *router,char *dev_type,u_int pa_bay);
226    
227     /* Remove a PA binding */
228     int c7200_pa_remove_binding(c7200_t *router,u_int pa_bay);
229    
230     /* Find a NIO binding */
231     struct c7200_nio_binding *
232     c7200_pa_find_nio_binding(c7200_t *router,u_int pa_bay,u_int port_id);
233    
234     /* Add a network IO binding */
235     int c7200_pa_add_nio_binding(c7200_t *router,u_int pa_bay,u_int port_id,
236     char *nio_name);
237    
238     /* Remove a NIO binding */
239     int c7200_pa_remove_nio_binding(c7200_t *router,u_int pa_bay,u_int port_id);
240    
241     /* Remove all NIO bindings for the specified PA */
242     int c7200_pa_remove_all_nio_bindings(c7200_t *router,u_int pa_bay);
243    
244     /* Enable a Network IO descriptor for a Port Adapter */
245     int c7200_pa_enable_nio(c7200_t *router,u_int pa_bay,u_int port_id);
246    
247     /* Disable Network IO descriptor of a Port Adapter */
248     int c7200_pa_disable_nio(c7200_t *router,u_int pa_bay,u_int port_id);
249    
250     /* Enable all NIO of the specified PA */
251     int c7200_pa_enable_all_nio(c7200_t *router,u_int pa_bay);
252    
253     /* Disable all NIO of the specified PA */
254     int c7200_pa_disable_all_nio(c7200_t *router,u_int pa_bay);
255    
256     /* Initialize a Port Adapter */
257     int c7200_pa_init(c7200_t *router,u_int pa_bay);
258    
259     /* Shutdown a Port Adapter */
260     int c7200_pa_shutdown(c7200_t *router,u_int pa_bay);
261    
262     /* Shutdown all PA of a router */
263     int c7200_pa_shutdown_all(c7200_t *router);
264    
265 dpavlin 2 /* Show info about all NMs */
266     int c7200_pa_show_all_info(c7200_t *router);
267    
268 dpavlin 1 /* Create a Port Adapter (command line) */
269     int c7200_cmd_pa_create(c7200_t *router,char *str);
270    
271     /* Add a Network IO descriptor binding (command line) */
272     int c7200_cmd_add_nio(c7200_t *router,char *str);
273    
274     /* Show the list of available PA drivers */
275     void c7200_pa_show_drivers(void);
276    
277     /* Get an NPE driver */
278     struct c7200_npe_driver *c7200_npe_get_driver(char *npe_type);
279    
280     /* Set the NPE type */
281     int c7200_npe_set_type(c7200_t *router,char *npe_type);
282    
283     /* Show the list of available NPE drivers */
284     void c7200_npe_show_drivers(void);
285    
286     /* Set Midplane type */
287     int c7200_midplane_set_type(c7200_t *router,char *midplane_type);
288    
289     /* Set chassis MAC address */
290     int c7200_midplane_set_mac_addr(c7200_t *router,char *mac_addr);
291    
292     /* Show C7200 hardware info */
293     void c7200_show_hardware(c7200_t *router);
294    
295     /* Initialize default parameters for a C7200 */
296     void c7200_init_defaults(c7200_t *router);
297    
298     /* Initialize the C7200 Platform */
299     int c7200_init_platform(c7200_t *router);
300    
301     /* Boot the IOS image */
302     int c7200_boot_ios(c7200_t *router);
303    
304     /* Initialize a Cisco 7200 instance */
305     int c7200_init_instance(c7200_t *router);
306    
307     /* Stop a Cisco 7200 instance */
308     int c7200_stop_instance(c7200_t *router);
309    
310     /* Trigger an OIR event */
311     int c7200_trigger_oir_event(c7200_t *router,u_int slot_mask);
312    
313     /* Initialize a new PA while the virtual router is online (OIR) */
314     int c7200_pa_init_online(c7200_t *router,u_int pa_bay);
315    
316     /* Stop a PA while the virtual router is online (OIR) */
317     int c7200_pa_stop_online(c7200_t *router,u_int pa_bay);
318    
319     /* dev_c7200_iofpga_init() */
320     int dev_c7200_iofpga_init(c7200_t *router,m_uint64_t paddr,m_uint32_t len);
321    
322     /* dev_mpfpga_init() */
323     int dev_c7200_mpfpga_init(c7200_t *router,m_uint64_t paddr,m_uint32_t len);
324    
325     /* PA drivers */
326     extern struct c7200_pa_driver dev_c7200_io_fe_driver;
327     extern struct c7200_pa_driver dev_c7200_pa_fe_tx_driver;
328     extern struct c7200_pa_driver dev_c7200_pa_4e_driver;
329     extern struct c7200_pa_driver dev_c7200_pa_8e_driver;
330     extern struct c7200_pa_driver dev_c7200_pa_4t_driver;
331     extern struct c7200_pa_driver dev_c7200_pa_8t_driver;
332     extern struct c7200_pa_driver dev_c7200_pa_a1_driver;
333     extern struct c7200_pa_driver dev_c7200_pa_pos_oc3_driver;
334     extern struct c7200_pa_driver dev_c7200_pa_4b_driver;
335 dpavlin 4 extern struct c7200_pa_driver dev_c7200_pa_mc8te1_driver;
336 dpavlin 1
337     #endif

  ViewVC Help
Powered by ViewVC 1.1.26