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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (hide annotations)
Sat Oct 6 16:26:06 2007 UTC (16 years, 5 months ago) by dpavlin
Original Path: upstream/dynamips-0.2.7-RC3/dev_c2691.h
File MIME type: text/plain
File size: 8402 byte(s)
dynamips-0.2.7-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 dpavlin 8 #include "nmc93cX6.h"
18 dpavlin 4 #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 dpavlin 8 /* Network IRQ */
48     #define C2691_NETIO_IRQ_BASE 32
49     #define C2691_NETIO_IRQ_PORT_BITS 3
50     #define C2691_NETIO_IRQ_PORT_MASK ((1 << C2691_NETIO_IRQ_PORT_BITS) - 1)
51     #define C2691_NETIO_IRQ_PER_SLOT (1 << C2691_NETIO_IRQ_PORT_BITS)
52     #define C2691_NETIO_IRQ_END \
53     (C2691_NETIO_IRQ_BASE + (C2691_MAX_NM_BAYS * C2691_NETIO_IRQ_PER_SLOT) - 1)
54    
55 dpavlin 4 /* C2691 common device addresses */
56     #define C2691_GT96K_ADDR 0x14000000ULL
57     #define C2691_IOFPGA_ADDR 0x1e800000ULL
58     #define C2691_DUART_ADDR 0x3c100000ULL
59     #define C2691_BITBUCKET_ADDR 0x1ec00000ULL
60     #define C2691_ROM_ADDR 0x1fc00000ULL
61     #define C2691_SLOT0_ADDR 0x30000000ULL
62     #define C2691_SLOT1_ADDR 0x32000000ULL
63     #define C2691_PCI_IO_ADDR 0x100000000ULL
64    
65     /* Offset of simulated NVRAM in ROM flash */
66     #define C2691_NVRAM_OFFSET 0xE0000
67     #define C2691_NVRAM_SIZE 0xE000
68    
69     /* Reserved space for ROM in NVRAM */
70     #define C2691_NVRAM_ROM_RES_SIZE 2048
71    
72     /* C2691 ELF Platform ID */
73     #define C2691_ELF_MACHINE_ID 0xFF /* ??? */
74    
75     /* C2691 router */
76     typedef struct c2691_router c2691_t;
77    
78     /* Prototype of NM driver initialization function */
79     typedef int (*c2691_nm_init_fn)(c2691_t *router,char *name,u_int nm_bay);
80    
81     /* Prototype of NM driver shutdown function */
82     typedef int (*c2691_nm_shutdown_fn)(c2691_t *router,u_int nm_bay);
83    
84     /* Prototype of NM NIO set function */
85     typedef int (*c2691_nm_set_nio_fn)(c2691_t *router,u_int nm_bay,u_int port_id,
86     netio_desc_t *nio);
87    
88     /* Prototype of NM NIO unset function */
89     typedef int (*c2691_nm_unset_nio_fn)(c2691_t *router,u_int nm_bay,
90     u_int port_id);
91    
92     /* Prototype of NM NIO show info function */
93     typedef int (*c2691_nm_show_info_fn)(c2691_t *router,u_int nm_bay);
94    
95     /* C2691 Network Module Driver */
96     struct c2691_nm_driver {
97     char *dev_type;
98     int supported;
99     int wic_slots;
100     c2691_nm_init_fn nm_init;
101     c2691_nm_shutdown_fn nm_shutdown;
102     c2691_nm_set_nio_fn nm_set_nio;
103     c2691_nm_unset_nio_fn nm_unset_nio;
104     c2691_nm_show_info_fn nm_show_info;
105    
106     /* TODO: WAN Interface Cards (WIC) */
107     };
108    
109     /* C2691 NIO binding to a slot/port */
110     struct c2691_nio_binding {
111     netio_desc_t *nio;
112     u_int port_id;
113     struct c2691_nio_binding *prev,*next;
114     };
115    
116     /* C2691 NM bay */
117     struct c2691_nm_bay {
118     char *dev_name; /* Device name */
119     char *dev_type; /* Device Type */
120     struct cisco_eeprom eeprom; /* NM EEPROM */
121     struct pci_bus *pci_map; /* PCI bus */
122     struct c2691_nm_driver *nm_driver; /* NM Driver */
123     void *drv_info; /* Private driver info */
124     struct c2691_nio_binding *nio_list; /* NIO bindings to ports */
125     };
126    
127     /* C2691 router */
128     struct c2691_router {
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 c2691_iofpga_data *iofpga_data;
140    
141 dpavlin 4 /* Chassis information */
142     struct c2691_nm_bay nm_bay[C2691_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 4
152     /* Network Module EEPROM */
153 dpavlin 8 struct nmc93cX6_group nm_eeprom_group;
154 dpavlin 4 };
155    
156     /* Create a new router instance */
157     c2691_t *c2691_create_instance(char *name,int instance_id);
158    
159     /* Delete a router instance */
160     int c2691_delete_instance(char *name);
161    
162     /* Delete all router instances */
163     int c2691_delete_all_instances(void);
164    
165     /* Save configuration of a C2691 instance */
166     void c2691_save_config(c2691_t *router,FILE *fd);
167    
168     /* Save configurations of all C2691 instances */
169     void c2691_save_config_all(FILE *fd);
170    
171 dpavlin 8 /* Get network IRQ for specified slot/port */
172     u_int c2691_net_irq_for_slot_port(u_int slot,u_int port);
173    
174 dpavlin 4 /* Set NM EEPROM definition */
175     int c2691_nm_set_eeprom(c2691_t *router,u_int nm_bay,
176     const struct cisco_eeprom *eeprom);
177    
178     /* Unset NM EEPROM definition (empty bay) */
179     int c2691_nm_unset_eeprom(c2691_t *router,u_int nm_bay);
180    
181     /* Check if a bay has a Network Module */
182     int c2691_nm_check_eeprom(c2691_t *router,u_int nm_bay);
183    
184     /* Get bay info */
185     struct c2691_nm_bay *c2691_nm_get_info(c2691_t *router,u_int nm_bay);
186    
187     /* Get NM type */
188     char *c2691_nm_get_type(c2691_t *router,u_int nm_bay);
189    
190     /* Get driver info about the specified slot */
191     void *c2691_nm_get_drvinfo(c2691_t *router,u_int nm_bay);
192    
193     /* Set driver info for the specified slot */
194     int c2691_nm_set_drvinfo(c2691_t *router,u_int nm_bay,void *drv_info);
195    
196     /* Add a NM binding */
197     int c2691_nm_add_binding(c2691_t *router,char *dev_type,u_int nm_bay);
198    
199     /* Remove a NM binding */
200     int c2691_nm_remove_binding(c2691_t *router,u_int nm_bay);
201    
202     /* Find a NIO binding */
203     struct c2691_nio_binding *
204     c2691_nm_find_nio_binding(c2691_t *router,u_int nm_bay,u_int port_id);
205    
206     /* Add a network IO binding */
207     int c2691_nm_add_nio_binding(c2691_t *router,u_int nm_bay,u_int port_id,
208     char *nio_name);
209    
210     /* Remove a NIO binding */
211     int c2691_nm_remove_nio_binding(c2691_t *router,u_int nm_bay,u_int port_id);
212    
213     /* Remove all NIO bindings for the specified NM */
214     int c2691_nm_remove_all_nio_bindings(c2691_t *router,u_int nm_bay);
215    
216     /* Enable a Network IO descriptor for a Network Module */
217     int c2691_nm_enable_nio(c2691_t *router,u_int nm_bay,u_int port_id);
218    
219     /* Disable Network IO descriptor of a Network Module */
220     int c2691_nm_disable_nio(c2691_t *router,u_int nm_bay,u_int port_id);
221    
222     /* Enable all NIO of the specified NM */
223     int c2691_nm_enable_all_nio(c2691_t *router,u_int nm_bay);
224    
225     /* Disable all NIO of the specified NM */
226     int c2691_nm_disable_all_nio(c2691_t *router,u_int nm_bay);
227    
228     /* Initialize a Network Module */
229     int c2691_nm_init(c2691_t *router,u_int nm_bay);
230    
231     /* Shutdown a Network Module */
232     int c2691_nm_shutdown(c2691_t *router,u_int nm_bay);
233    
234     /* Shutdown all NM of a router */
235     int c2691_nm_shutdown_all(c2691_t *router);
236    
237     /* Show info about all NMs */
238     int c2691_nm_show_all_info(c2691_t *router);
239    
240     /* Create a Network Module (command line) */
241     int c2691_cmd_nm_create(c2691_t *router,char *str);
242    
243     /* Add a Network IO descriptor binding (command line) */
244     int c2691_cmd_add_nio(c2691_t *router,char *str);
245    
246     /* Show the list of available NM drivers */
247     void c2691_nm_show_drivers(void);
248    
249     /* Set chassis MAC address */
250     int c2691_chassis_set_mac_addr(c2691_t *router,char *mac_addr);
251    
252     /* Show C2691 hardware info */
253     void c2691_show_hardware(c2691_t *router);
254    
255     /* Initialize default parameters for a C2691 */
256     void c2691_init_defaults(c2691_t *router);
257    
258     /* Initialize the C2691 Platform */
259     int c2691_init_platform(c2691_t *router);
260    
261     /* Initialize a Cisco 2691 instance */
262     int c2691_init_instance(c2691_t *router);
263    
264     /* Stop a Cisco 2691 instance */
265     int c2691_stop_instance(c2691_t *router);
266    
267     /* Initialize EEPROM groups */
268     void c2691_init_eeprom_groups(c2691_t *router);
269    
270     /* dev_c2691_iofpga_init() */
271     int dev_c2691_iofpga_init(c2691_t *router,m_uint64_t paddr,m_uint32_t len);
272    
273     /* NM drivers */
274     extern struct c2691_nm_driver dev_c2691_nm_1fe_tx_driver;
275     extern struct c2691_nm_driver dev_c2691_gt96100_fe_driver;
276     extern struct c2691_nm_driver dev_c2691_nm_4t_driver;
277     extern struct c2691_nm_driver dev_c2691_nm_16esw_driver;
278    
279     #endif

  ViewVC Help
Powered by ViewVC 1.1.26