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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations)
Sat Oct 6 16:06:49 2007 UTC (12 years, 2 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.6-RC3/dev_c3725.h
File MIME type: text/plain
File size: 7977 byte(s)
dynamips-0.2.6-RC3

1 dpavlin 4 /*
2     * Cisco 3725 simulation platform.
3     * 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     #include "nmc93c46.h"
18     #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     /* C3725 common device addresses */
48     #define C3725_GT96K_ADDR 0x14000000ULL
49     #define C3725_IOFPGA_ADDR 0x1e800000ULL
50     #define C3725_DUART_ADDR 0x3c100000ULL
51     #define C3725_BITBUCKET_ADDR 0x1ec00000ULL
52     #define C3725_ROM_ADDR 0x1fc00000ULL
53     #define C3725_SLOT0_ADDR 0x30000000ULL
54     #define C3725_SLOT1_ADDR 0x32000000ULL
55     #define C3725_PCI_IO_ADDR 0x100000000ULL
56    
57     /* Offset of simulated NVRAM in ROM flash */
58     #define C3725_NVRAM_OFFSET 0xE0000
59     #define C3725_NVRAM_SIZE 0xE000
60    
61     /* Reserved space for ROM in NVRAM */
62     #define C3725_NVRAM_ROM_RES_SIZE 2048
63    
64     /* C3725 ELF Platform ID */
65     #define C3725_ELF_MACHINE_ID 0xFF /* ??? */
66    
67     /* C3725 router */
68     typedef struct c3725_router c3725_t;
69    
70     /* Prototype of NM driver initialization function */
71     typedef int (*c3725_nm_init_fn)(c3725_t *router,char *name,u_int nm_bay);
72    
73     /* Prototype of NM driver shutdown function */
74     typedef int (*c3725_nm_shutdown_fn)(c3725_t *router,u_int nm_bay);
75    
76     /* Prototype of NM NIO set function */
77     typedef int (*c3725_nm_set_nio_fn)(c3725_t *router,u_int nm_bay,u_int port_id,
78     netio_desc_t *nio);
79    
80     /* Prototype of NM NIO unset function */
81     typedef int (*c3725_nm_unset_nio_fn)(c3725_t *router,u_int nm_bay,
82     u_int port_id);
83    
84     /* Prototype of NM NIO show info function */
85     typedef int (*c3725_nm_show_info_fn)(c3725_t *router,u_int nm_bay);
86    
87     /* C3725 Network Module Driver */
88     struct c3725_nm_driver {
89     char *dev_type;
90     int supported;
91     int wic_slots;
92     c3725_nm_init_fn nm_init;
93     c3725_nm_shutdown_fn nm_shutdown;
94     c3725_nm_set_nio_fn nm_set_nio;
95     c3725_nm_unset_nio_fn nm_unset_nio;
96     c3725_nm_show_info_fn nm_show_info;
97    
98     /* TODO: WAN Interface Cards (WIC) */
99     };
100    
101     /* C3725 NIO binding to a slot/port */
102     struct c3725_nio_binding {
103     netio_desc_t *nio;
104     u_int port_id;
105     struct c3725_nio_binding *prev,*next;
106     };
107    
108     /* C3725 NM bay */
109     struct c3725_nm_bay {
110     char *dev_name; /* Device name */
111     char *dev_type; /* Device Type */
112     struct cisco_eeprom eeprom; /* NM EEPROM */
113     struct pci_bus *pci_map; /* PCI bus */
114     struct c3725_nm_driver *nm_driver; /* NM Driver */
115     void *drv_info; /* Private driver info */
116     struct c3725_nio_binding *nio_list; /* NIO bindings to ports */
117     };
118    
119     /* C3725 router */
120     struct c3725_router {
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 c3725_nm_bay nm_bay[C3725_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 EEPROMs */
142     struct nmc93c46_group nm_eeprom_group[2];
143     };
144    
145     /* Create a new router instance */
146     c3725_t *c3725_create_instance(char *name,int instance_id);
147    
148     /* Delete a router instance */
149     int c3725_delete_instance(char *name);
150    
151     /* Delete all router instances */
152     int c3725_delete_all_instances(void);
153    
154     /* Save configuration of a C3725 instance */
155     void c3725_save_config(c3725_t *router,FILE *fd);
156    
157     /* Save configurations of all C3725 instances */
158     void c3725_save_config_all(FILE *fd);
159    
160     /* Get PCI device for the specified NM bay */
161     int c3725_nm_get_pci_device(u_int nm_bay);
162    
163     /* Set NM EEPROM definition */
164     int c3725_nm_set_eeprom(c3725_t *router,u_int nm_bay,
165     const struct cisco_eeprom *eeprom);
166    
167     /* Unset NM EEPROM definition (empty bay) */
168     int c3725_nm_unset_eeprom(c3725_t *router,u_int nm_bay);
169    
170     /* Check if a bay has a Network Module */
171     int c3725_nm_check_eeprom(c3725_t *router,u_int nm_bay);
172    
173     /* Get bay info */
174     struct c3725_nm_bay *c3725_nm_get_info(c3725_t *router,u_int nm_bay);
175    
176     /* Get NM type */
177     char *c3725_nm_get_type(c3725_t *router,u_int nm_bay);
178    
179     /* Get driver info about the specified slot */
180     void *c3725_nm_get_drvinfo(c3725_t *router,u_int nm_bay);
181    
182     /* Set driver info for the specified slot */
183     int c3725_nm_set_drvinfo(c3725_t *router,u_int nm_bay,void *drv_info);
184    
185     /* Add a NM binding */
186     int c3725_nm_add_binding(c3725_t *router,char *dev_type,u_int nm_bay);
187    
188     /* Remove a NM binding */
189     int c3725_nm_remove_binding(c3725_t *router,u_int nm_bay);
190    
191     /* Find a NIO binding */
192     struct c3725_nio_binding *
193     c3725_nm_find_nio_binding(c3725_t *router,u_int nm_bay,u_int port_id);
194    
195     /* Add a network IO binding */
196     int c3725_nm_add_nio_binding(c3725_t *router,u_int nm_bay,u_int port_id,
197     char *nio_name);
198    
199     /* Remove a NIO binding */
200     int c3725_nm_remove_nio_binding(c3725_t *router,u_int nm_bay,u_int port_id);
201    
202     /* Remove all NIO bindings for the specified NM */
203     int c3725_nm_remove_all_nio_bindings(c3725_t *router,u_int nm_bay);
204    
205     /* Enable a Network IO descriptor for a Network Module */
206     int c3725_nm_enable_nio(c3725_t *router,u_int nm_bay,u_int port_id);
207    
208     /* Disable Network IO descriptor of a Network Module */
209     int c3725_nm_disable_nio(c3725_t *router,u_int nm_bay,u_int port_id);
210    
211     /* Enable all NIO of the specified NM */
212     int c3725_nm_enable_all_nio(c3725_t *router,u_int nm_bay);
213    
214     /* Disable all NIO of the specified NM */
215     int c3725_nm_disable_all_nio(c3725_t *router,u_int nm_bay);
216    
217     /* Initialize a Network Module */
218     int c3725_nm_init(c3725_t *router,u_int nm_bay);
219    
220     /* Shutdown a Network Module */
221     int c3725_nm_shutdown(c3725_t *router,u_int nm_bay);
222    
223     /* Shutdown all NM of a router */
224     int c3725_nm_shutdown_all(c3725_t *router);
225    
226     /* Show info about all NMs */
227     int c3725_nm_show_all_info(c3725_t *router);
228    
229     /* Create a Network Module (command line) */
230     int c3725_cmd_nm_create(c3725_t *router,char *str);
231    
232     /* Add a Network IO descriptor binding (command line) */
233     int c3725_cmd_add_nio(c3725_t *router,char *str);
234    
235     /* Show the list of available NM drivers */
236     void c3725_nm_show_drivers(void);
237    
238     /* Set chassis MAC address */
239     int c3725_chassis_set_mac_addr(c3725_t *router,char *mac_addr);
240    
241     /* Show C3725 hardware info */
242     void c3725_show_hardware(c3725_t *router);
243    
244     /* Initialize default parameters for a C3725 */
245     void c3725_init_defaults(c3725_t *router);
246    
247     /* Initialize the C3725 Platform */
248     int c3725_init_platform(c3725_t *router);
249    
250     /* Initialize a Cisco 3725 instance */
251     int c3725_init_instance(c3725_t *router);
252    
253     /* Stop a Cisco 3725 instance */
254     int c3725_stop_instance(c3725_t *router);
255    
256     /* Initialize EEPROM groups */
257     void c3725_init_eeprom_groups(c3725_t *router);
258    
259     /* dev_c3725_iofpga_init() */
260     int dev_c3725_iofpga_init(c3725_t *router,m_uint64_t paddr,m_uint32_t len);
261    
262     /* NM drivers */
263     extern struct c3725_nm_driver dev_c3725_nm_1fe_tx_driver;
264     extern struct c3725_nm_driver dev_c3725_gt96100_fe_driver;
265     extern struct c3725_nm_driver dev_c3725_nm_4t_driver;
266     extern struct c3725_nm_driver dev_c3725_nm_16esw_driver;
267    
268     #endif

  ViewVC Help
Powered by ViewVC 1.1.26