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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 dpavlin 4 /*
2     * Cisco 2691 simulation platform.
3     * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4     *
5     * Generic Cisco 2691 routines and definitions (EEPROM,...).
6     */
7    
8     #ifndef __DEV_C2691_H__
9     #define __DEV_C2691_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 C2691 parameters */
22     #define C2691_DEFAULT_RAM_SIZE 128
23     #define C2691_DEFAULT_ROM_SIZE 2
24     #define C2691_DEFAULT_NVRAM_SIZE 128
25     #define C2691_DEFAULT_CONF_REG 0x2102
26     #define C2691_DEFAULT_CLOCK_DIV 8
27     #define C2691_DEFAULT_RAM_MMAP 1
28     #define C2691_DEFAULT_DISK0_SIZE 16
29     #define C2691_DEFAULT_DISK1_SIZE 0
30     #define C2691_DEFAULT_IOMEM_SIZE 5 /* Percents! */
31    
32     /* 2691 characteritics: 1 NM, 3 WIC, 2 AIM */
33     #define C2691_MAX_NM_BAYS 2
34    
35     /* C2691 DUART Interrupt */
36     #define C2691_DUART_IRQ 5
37    
38     /* C2691 Network I/O Interrupt */
39     #define C2691_NETIO_IRQ 2
40    
41     /* C2691 GT64k DMA/Timer Interrupt */
42     #define C2691_GT96K_IRQ 3
43    
44     /* C2691 External Interrupt */
45     #define C2691_EXT_IRQ 6
46    
47     /* C2691 common device addresses */
48     #define C2691_GT96K_ADDR 0x14000000ULL
49     #define C2691_IOFPGA_ADDR 0x1e800000ULL
50     #define C2691_DUART_ADDR 0x3c100000ULL
51     #define C2691_BITBUCKET_ADDR 0x1ec00000ULL
52     #define C2691_ROM_ADDR 0x1fc00000ULL
53     #define C2691_SLOT0_ADDR 0x30000000ULL
54     #define C2691_SLOT1_ADDR 0x32000000ULL
55     #define C2691_PCI_IO_ADDR 0x100000000ULL
56    
57     /* Offset of simulated NVRAM in ROM flash */
58     #define C2691_NVRAM_OFFSET 0xE0000
59     #define C2691_NVRAM_SIZE 0xE000
60    
61     /* Reserved space for ROM in NVRAM */
62     #define C2691_NVRAM_ROM_RES_SIZE 2048
63    
64     /* C2691 ELF Platform ID */
65     #define C2691_ELF_MACHINE_ID 0xFF /* ??? */
66    
67     /* C2691 router */
68     typedef struct c2691_router c2691_t;
69    
70     /* Prototype of NM driver initialization function */
71     typedef int (*c2691_nm_init_fn)(c2691_t *router,char *name,u_int nm_bay);
72    
73     /* Prototype of NM driver shutdown function */
74     typedef int (*c2691_nm_shutdown_fn)(c2691_t *router,u_int nm_bay);
75    
76     /* Prototype of NM NIO set function */
77     typedef int (*c2691_nm_set_nio_fn)(c2691_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 (*c2691_nm_unset_nio_fn)(c2691_t *router,u_int nm_bay,
82     u_int port_id);
83    
84     /* Prototype of NM NIO show info function */
85     typedef int (*c2691_nm_show_info_fn)(c2691_t *router,u_int nm_bay);
86    
87     /* C2691 Network Module Driver */
88     struct c2691_nm_driver {
89     char *dev_type;
90     int supported;
91     int wic_slots;
92     c2691_nm_init_fn nm_init;
93     c2691_nm_shutdown_fn nm_shutdown;
94     c2691_nm_set_nio_fn nm_set_nio;
95     c2691_nm_unset_nio_fn nm_unset_nio;
96     c2691_nm_show_info_fn nm_show_info;
97    
98     /* TODO: WAN Interface Cards (WIC) */
99     };
100    
101     /* C2691 NIO binding to a slot/port */
102     struct c2691_nio_binding {
103     netio_desc_t *nio;
104     u_int port_id;
105     struct c2691_nio_binding *prev,*next;
106     };
107    
108     /* C2691 NM bay */
109     struct c2691_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 c2691_nm_driver *nm_driver; /* NM Driver */
115     void *drv_info; /* Private driver info */
116     struct c2691_nio_binding *nio_list; /* NIO bindings to ports */
117     };
118    
119     /* C2691 router */
120     struct c2691_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 c2691_nm_bay nm_bay[C2691_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    
145     /* Create a new router instance */
146     c2691_t *c2691_create_instance(char *name,int instance_id);
147    
148     /* Delete a router instance */
149     int c2691_delete_instance(char *name);
150    
151     /* Delete all router instances */
152     int c2691_delete_all_instances(void);
153    
154     /* Save configuration of a C2691 instance */
155     void c2691_save_config(c2691_t *router,FILE *fd);
156    
157     /* Save configurations of all C2691 instances */
158     void c2691_save_config_all(FILE *fd);
159    
160     /* Set NM EEPROM definition */
161     int c2691_nm_set_eeprom(c2691_t *router,u_int nm_bay,
162     const struct cisco_eeprom *eeprom);
163    
164     /* Unset NM EEPROM definition (empty bay) */
165     int c2691_nm_unset_eeprom(c2691_t *router,u_int nm_bay);
166    
167     /* Check if a bay has a Network Module */
168     int c2691_nm_check_eeprom(c2691_t *router,u_int nm_bay);
169    
170     /* Get bay info */
171     struct c2691_nm_bay *c2691_nm_get_info(c2691_t *router,u_int nm_bay);
172    
173     /* Get NM type */
174     char *c2691_nm_get_type(c2691_t *router,u_int nm_bay);
175    
176     /* Get driver info about the specified slot */
177     void *c2691_nm_get_drvinfo(c2691_t *router,u_int nm_bay);
178    
179     /* Set driver info for the specified slot */
180     int c2691_nm_set_drvinfo(c2691_t *router,u_int nm_bay,void *drv_info);
181    
182     /* Add a NM binding */
183     int c2691_nm_add_binding(c2691_t *router,char *dev_type,u_int nm_bay);
184    
185     /* Remove a NM binding */
186     int c2691_nm_remove_binding(c2691_t *router,u_int nm_bay);
187    
188     /* Find a NIO binding */
189     struct c2691_nio_binding *
190     c2691_nm_find_nio_binding(c2691_t *router,u_int nm_bay,u_int port_id);
191    
192     /* Add a network IO binding */
193     int c2691_nm_add_nio_binding(c2691_t *router,u_int nm_bay,u_int port_id,
194     char *nio_name);
195    
196     /* Remove a NIO binding */
197     int c2691_nm_remove_nio_binding(c2691_t *router,u_int nm_bay,u_int port_id);
198    
199     /* Remove all NIO bindings for the specified NM */
200     int c2691_nm_remove_all_nio_bindings(c2691_t *router,u_int nm_bay);
201    
202     /* Enable a Network IO descriptor for a Network Module */
203     int c2691_nm_enable_nio(c2691_t *router,u_int nm_bay,u_int port_id);
204    
205     /* Disable Network IO descriptor of a Network Module */
206     int c2691_nm_disable_nio(c2691_t *router,u_int nm_bay,u_int port_id);
207    
208     /* Enable all NIO of the specified NM */
209     int c2691_nm_enable_all_nio(c2691_t *router,u_int nm_bay);
210    
211     /* Disable all NIO of the specified NM */
212     int c2691_nm_disable_all_nio(c2691_t *router,u_int nm_bay);
213    
214     /* Initialize a Network Module */
215     int c2691_nm_init(c2691_t *router,u_int nm_bay);
216    
217     /* Shutdown a Network Module */
218     int c2691_nm_shutdown(c2691_t *router,u_int nm_bay);
219    
220     /* Shutdown all NM of a router */
221     int c2691_nm_shutdown_all(c2691_t *router);
222    
223     /* Show info about all NMs */
224     int c2691_nm_show_all_info(c2691_t *router);
225    
226     /* Create a Network Module (command line) */
227     int c2691_cmd_nm_create(c2691_t *router,char *str);
228    
229     /* Add a Network IO descriptor binding (command line) */
230     int c2691_cmd_add_nio(c2691_t *router,char *str);
231    
232     /* Show the list of available NM drivers */
233     void c2691_nm_show_drivers(void);
234    
235     /* Set chassis MAC address */
236     int c2691_chassis_set_mac_addr(c2691_t *router,char *mac_addr);
237    
238     /* Show C2691 hardware info */
239     void c2691_show_hardware(c2691_t *router);
240    
241     /* Initialize default parameters for a C2691 */
242     void c2691_init_defaults(c2691_t *router);
243    
244     /* Initialize the C2691 Platform */
245     int c2691_init_platform(c2691_t *router);
246    
247     /* Initialize a Cisco 2691 instance */
248     int c2691_init_instance(c2691_t *router);
249    
250     /* Stop a Cisco 2691 instance */
251     int c2691_stop_instance(c2691_t *router);
252    
253     /* Initialize EEPROM groups */
254     void c2691_init_eeprom_groups(c2691_t *router);
255    
256     /* dev_c2691_iofpga_init() */
257     int dev_c2691_iofpga_init(c2691_t *router,m_uint64_t paddr,m_uint32_t len);
258    
259     /* NM drivers */
260     extern struct c2691_nm_driver dev_c2691_nm_1fe_tx_driver;
261     extern struct c2691_nm_driver dev_c2691_gt96100_fe_driver;
262     extern struct c2691_nm_driver dev_c2691_nm_4t_driver;
263     extern struct c2691_nm_driver dev_c2691_nm_16esw_driver;
264    
265     #endif

  ViewVC Help
Powered by ViewVC 1.1.26