Debian Codegraph @

common/dev_c3725.h

raw
1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2006 Christophe Fillot ([email protected])
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 "nmc93cX6.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 112
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 #define C3725_MAX_WIC_BAYS 3
35
36 /* C3725 DUART Interrupt */
37 #define C3725_DUART_IRQ 5
38
39 /* C3725 Network I/O Interrupt */
40 #define C3725_NETIO_IRQ 2
41
42 /* C3725 GT64k DMA/Timer Interrupt */
43 #define C3725_GT96K_IRQ 3
44
45 /* C3725 External Interrupt */
46 #define C3725_EXT_IRQ 6
47
48 /* Network IRQ */
49 #define C3725_NETIO_IRQ_BASE 32
50 #define C3725_NETIO_IRQ_PORT_BITS 2
51 #define C3725_NETIO_IRQ_PORT_MASK ((1 << C3725_NETIO_IRQ_PORT_BITS) - 1)
52 #define C3725_NETIO_IRQ_PER_SLOT (1 << C3725_NETIO_IRQ_PORT_BITS)
53 #define C3725_NETIO_IRQ_END \
54 (C3725_NETIO_IRQ_BASE + (C3725_MAX_NM_BAYS * C3725_NETIO_IRQ_PER_SLOT) - 1)
55
56 /* C3725 common device addresses */
57 #define C3725_GT96K_ADDR 0x14000000ULL
58 #define C3725_IOFPGA_ADDR 0x1e800000ULL
59 #define C3725_BITBUCKET_ADDR 0x1ec00000ULL
60 #define C3725_ROM_ADDR 0x1fc00000ULL
61 #define C3725_SLOT0_ADDR 0x30000000ULL
62 #define C3725_SLOT1_ADDR 0x32000000ULL
63 #define C3725_DUART_ADDR 0x3c100000ULL
64 #define C3725_WIC_ADDR 0x3c200000ULL
65 #define C3725_BSWAP_ADDR 0xc0000000ULL
66 #define C3725_PCI_IO_ADDR 0x100000000ULL
67
68 /* WIC interval in address space */
69 #define C3725_WIC_SIZE 0x2000
70
71 /* Offset of simulated NVRAM in ROM flash */
72 #define C3725_NVRAM_OFFSET 0xE0000
73 #define C3725_NVRAM_SIZE 0x1C000 // with backup
74
75 /* Reserved space for ROM in NVRAM */
76 #define C3725_NVRAM_ROM_RES_SIZE 0
77
78 /* C3725 ELF Platform ID */
79 #define C3725_ELF_MACHINE_ID 0x61
80
81 #define VM_C3725(vm) ((c3725_t *)vm->hw_data)
82
83 /* C3725 router */
84 typedef struct c3725_router c3725_t;
85
86 /* C3725 router */
87 struct c3725_router {
88 /* Chassis MAC address */
89 n_eth_addr_t mac_addr;
90
91 char board_id[20];
92
93 /* Associated VM instance */
94 vm_instance_t *vm;
95
96 /* GT96100 data */
97 struct gt_data *gt_data;
98
99 /* I/O FPGA */
100 struct c3725_iofpga_data *iofpga_data;
101
102 /* Chassis information */
103 m_uint8_t oir_status;
104
105 /*
106 * Mainboard EEPROM.
107 * It can be modified to change the chassis MAC address.
108 */
109 struct cisco_eeprom mb_eeprom;
110 struct nmc93cX6_group mb_eeprom_group;
111
112 /* Network Module EEPROMs */
113 struct nmc93cX6_group nm_eeprom_group[2];
114 };
115
116 /* Get WIC device address for the specified onboard port */
117 int c3725_get_onboard_wic_addr(u_int slot,m_uint64_t *phys_addr);
118
119 /* Set EEPROM for the specified slot */
120 int c3725_set_slot_eeprom(c3725_t *router,u_int slot,
121 struct cisco_eeprom *eeprom);
122
123 /* Get network IRQ for specified slot/port */
124 u_int c3725_net_irq_for_slot_port(u_int slot,u_int port);
125
126 /* Get PCI device for the specified NM bay */
127 int c3725_nm_get_pci_device(u_int nm_bay);
128
129 /* Set chassis MAC address */
130 int c3725_chassis_set_mac_addr(c3725_t *router,char *mac_addr);
131
132 /* Set the system id */
133 int c3725_set_system_id(c3725_t *router,char *id);
134
135 /* Burn the system id into the appropriate eeprom if possible */
136 int c3725_refresh_systemid(c3725_t *router);
137
138 /* Show C3725 hardware info */
139 void c3725_show_hardware(c3725_t *router);
140
141 /* Initialize EEPROM groups */
142 void c3725_init_eeprom_groups(c3725_t *router);
143
144 /* Register the c3725 platform */
145 int c3725_platform_register(void);
146
147 /* Hypervisor C3725 initialization */
148 extern int hypervisor_c3725_init(vm_platform_t *platform);
149
150 /* NM drivers */
151 extern struct cisco_card_driver dev_c3725_nm_1fe_tx_driver;
152 extern struct cisco_card_driver dev_c3725_gt96100_fe_driver;
153 extern struct cisco_card_driver dev_c3725_nm_4t_driver;
154 extern struct cisco_card_driver dev_c3725_nm_16esw_driver;
155 extern struct cisco_card_driver dev_c3725_nmd_36esw_driver;
156 extern struct cisco_card_driver dev_c3725_nm_nam_driver;
157 extern struct cisco_card_driver dev_c3725_nm_cids_driver;
158
159 /* WIC drivers */
160 extern struct cisco_card_driver *dev_c3725_mb_wic_drivers[];
161
162 #endif