1 |
dpavlin |
7 |
/* |
2 |
|
|
* Cisco router simulation platform. |
3 |
|
|
* Copyright (c) 2006 Christophe Fillot (cf@utc.fr) |
4 |
|
|
* |
5 |
|
|
* Generic Cisco 2600 routines and definitions (EEPROM,...). |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef __DEV_C2600_H__ |
9 |
|
|
#define __DEV_C2600_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 |
7 |
#include "net_io.h" |
19 |
|
|
#include "dev_mpc860.h" |
20 |
|
|
#include "vm.h" |
21 |
|
|
|
22 |
|
|
/* Default C2600 parameters */ |
23 |
|
|
#define C2600_DEFAULT_MAINBOARD "2610" |
24 |
|
|
#define C2600_DEFAULT_RAM_SIZE 64 |
25 |
|
|
#define C2600_DEFAULT_ROM_SIZE 2 |
26 |
|
|
#define C2600_DEFAULT_NVRAM_SIZE 128 |
27 |
|
|
#define C2600_DEFAULT_CONF_REG 0x2102 |
28 |
|
|
#define C2600_DEFAULT_CLOCK_DIV 8 |
29 |
|
|
#define C2600_DEFAULT_RAM_MMAP 1 |
30 |
|
|
#define C2600_DEFAULT_DISK0_SIZE 0 |
31 |
|
|
#define C2600_DEFAULT_DISK1_SIZE 0 |
32 |
|
|
#define C2600_DEFAULT_IOMEM_SIZE 15 /* Percents! */ |
33 |
|
|
|
34 |
dpavlin |
11 |
/* 2600 characteristics: 1 NM + mainboard, 2 onboard WIC slots */ |
35 |
|
|
#define C2600_MAX_NM_BAYS 2 |
36 |
|
|
#define C2600_MAX_WIC_BAYS 2 |
37 |
dpavlin |
7 |
|
38 |
|
|
/* C2600 Virtual Timer Interrupt */ |
39 |
|
|
#define C2600_VTIMER_IRQ 0 |
40 |
|
|
|
41 |
|
|
/* C2600 DUART Interrupt */ |
42 |
|
|
#define C2600_DUART_IRQ 1 |
43 |
|
|
|
44 |
|
|
/* C2600 Network I/O Interrupt */ |
45 |
|
|
#define C2600_NETIO_IRQ 2 |
46 |
|
|
|
47 |
|
|
/* C2600 PA Management Interrupt */ |
48 |
|
|
#define C2600_PA_MGMT_IRQ 3 |
49 |
|
|
|
50 |
dpavlin |
8 |
/* Network IRQ */ |
51 |
|
|
#define C2600_NETIO_IRQ_BASE 32 |
52 |
|
|
#define C2600_NETIO_IRQ_PORT_BITS 2 |
53 |
|
|
#define C2600_NETIO_IRQ_PORT_MASK ((1 << C2600_NETIO_IRQ_PORT_BITS) - 1) |
54 |
|
|
#define C2600_NETIO_IRQ_PER_SLOT (1 << C2600_NETIO_IRQ_PORT_BITS) |
55 |
|
|
#define C2600_NETIO_IRQ_END \ |
56 |
dpavlin |
11 |
(C2600_NETIO_IRQ_BASE + (C2600_MAX_NM_BAYS * C2600_NETIO_IRQ_PER_SLOT) - 1) |
57 |
dpavlin |
8 |
|
58 |
dpavlin |
7 |
/* C2600 common device addresses */ |
59 |
dpavlin |
11 |
#define C2600_FLASH_ADDR 0x60000000ULL |
60 |
|
|
#define C2600_WIC_ADDR 0x67000000ULL |
61 |
dpavlin |
7 |
#define C2600_IOFPGA_ADDR 0x67400000ULL |
62 |
|
|
#define C2600_NVRAM_ADDR 0x67c00000ULL |
63 |
|
|
#define C2600_PCICTRL_ADDR 0x68000000ULL |
64 |
|
|
#define C2600_MPC860_ADDR 0x68010000ULL |
65 |
|
|
#define C2600_DUART_ADDR 0xffe00000ULL |
66 |
|
|
#define C2600_ROM_ADDR 0xfff00000ULL |
67 |
|
|
|
68 |
dpavlin |
11 |
/* WIC interval in address space */ |
69 |
|
|
#define C2600_WIC_SIZE 0x400 |
70 |
|
|
|
71 |
dpavlin |
7 |
/* Reserved space for ROM in NVRAM */ |
72 |
|
|
#define C2600_NVRAM_ROM_RES_SIZE 2048 |
73 |
|
|
|
74 |
|
|
/* C2600 ELF Platform ID */ |
75 |
|
|
#define C2600_ELF_MACHINE_ID 0x2b |
76 |
|
|
|
77 |
dpavlin |
11 |
#define VM_C2600(vm) ((c2600_t *)vm->hw_data) |
78 |
|
|
|
79 |
dpavlin |
7 |
/* C2600 router */ |
80 |
|
|
typedef struct c2600_router c2600_t; |
81 |
|
|
|
82 |
|
|
/* C2600 router */ |
83 |
|
|
struct c2600_router { |
84 |
|
|
/* Mainboard type (2610, 2611, etc) */ |
85 |
|
|
char *mainboard_type; |
86 |
|
|
|
87 |
dpavlin |
11 |
/* Is the router a XM model ? */ |
88 |
|
|
int xm_model; |
89 |
|
|
|
90 |
dpavlin |
7 |
/* Chassis MAC address */ |
91 |
|
|
n_eth_addr_t mac_addr; |
92 |
|
|
|
93 |
|
|
/* Associated VM instance */ |
94 |
|
|
vm_instance_t *vm; |
95 |
|
|
|
96 |
dpavlin |
8 |
/* I/O FPGA */ |
97 |
|
|
struct c2600_iofpga_data *iofpga_data; |
98 |
|
|
|
99 |
dpavlin |
7 |
/* |
100 |
|
|
* Mainboard EEPROM. |
101 |
|
|
* It can be modified to change the chassis MAC address. |
102 |
|
|
*/ |
103 |
|
|
struct cisco_eeprom mb_eeprom; |
104 |
dpavlin |
8 |
struct nmc93cX6_group mb_eeprom_group; |
105 |
dpavlin |
7 |
|
106 |
|
|
/* Network Module EEPROM */ |
107 |
dpavlin |
8 |
struct nmc93cX6_group nm_eeprom_group; |
108 |
dpavlin |
7 |
|
109 |
|
|
/* MPC860 device private data */ |
110 |
|
|
struct mpc860_data *mpc_data; |
111 |
|
|
}; |
112 |
|
|
|
113 |
dpavlin |
11 |
/* Get WIC device address for the specified onboard port */ |
114 |
|
|
int c2600_get_onboard_wic_addr(u_int slot,m_uint64_t *phys_addr); |
115 |
dpavlin |
7 |
|
116 |
dpavlin |
11 |
/* Set EEPROM for the specified slot */ |
117 |
|
|
int c2600_set_slot_eeprom(c2600_t *router,u_int slot, |
118 |
|
|
struct cisco_eeprom *eeprom); |
119 |
dpavlin |
7 |
|
120 |
dpavlin |
8 |
/* Get network IRQ for specified slot/port */ |
121 |
|
|
u_int c2600_net_irq_for_slot_port(u_int slot,u_int port); |
122 |
|
|
|
123 |
dpavlin |
7 |
/* Set mainboard type */ |
124 |
|
|
int c2600_mainboard_set_type(c2600_t *router,char *mainboard_type); |
125 |
|
|
|
126 |
|
|
/* Set chassis MAC address */ |
127 |
|
|
int c2600_chassis_set_mac_addr(c2600_t *router,char *mac_addr); |
128 |
|
|
|
129 |
|
|
/* Show C2600 hardware info */ |
130 |
|
|
void c2600_show_hardware(c2600_t *router); |
131 |
|
|
|
132 |
|
|
/* Initialize EEPROM groups */ |
133 |
|
|
void c2600_init_eeprom_groups(c2600_t *router); |
134 |
|
|
|
135 |
|
|
/* Create the c2600 PCI controller device */ |
136 |
|
|
int dev_c2600_pci_init(vm_instance_t *vm,char *name, |
137 |
|
|
m_uint64_t paddr,m_uint32_t len, |
138 |
|
|
struct pci_bus *bus); |
139 |
|
|
|
140 |
|
|
/* dev_c2600_iofpga_init() */ |
141 |
|
|
int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len); |
142 |
|
|
|
143 |
dpavlin |
11 |
/* Register the c2600 platform */ |
144 |
|
|
int c2600_platform_register(void); |
145 |
|
|
|
146 |
|
|
/* Hypervisor C2600 initialization */ |
147 |
|
|
extern int hypervisor_c2600_init(vm_platform_t *platform); |
148 |
|
|
|
149 |
dpavlin |
7 |
/* NM drivers */ |
150 |
dpavlin |
11 |
extern struct cisco_card_driver dev_c2600_mb1e_eth_driver; |
151 |
|
|
extern struct cisco_card_driver dev_c2600_mb2e_eth_driver; |
152 |
|
|
extern struct cisco_card_driver dev_c2600_mb1fe_eth_driver; |
153 |
|
|
extern struct cisco_card_driver dev_c2600_mb2fe_eth_driver; |
154 |
dpavlin |
7 |
|
155 |
dpavlin |
11 |
extern struct cisco_card_driver dev_c2600_nm_1e_driver; |
156 |
|
|
extern struct cisco_card_driver dev_c2600_nm_4e_driver; |
157 |
|
|
extern struct cisco_card_driver dev_c2600_nm_1fe_tx_driver; |
158 |
|
|
extern struct cisco_card_driver dev_c2600_nm_16esw_driver; |
159 |
dpavlin |
7 |
|
160 |
dpavlin |
11 |
extern struct cisco_card_driver dev_c2600_nm_nam_driver; |
161 |
|
|
extern struct cisco_card_driver dev_c2600_nm_cids_driver; |
162 |
|
|
|
163 |
|
|
/* WIC drivers */ |
164 |
|
|
extern struct cisco_card_driver *dev_c2600_mb_wic_drivers[]; |
165 |
|
|
|
166 |
dpavlin |
7 |
#endif |