1 |
dpavlin |
4 |
/* |
2 |
dpavlin |
8 |
* Cisco router simulation platform. |
3 |
dpavlin |
4 |
* 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 |
dpavlin |
8 |
#include "nmc93cX6.h" |
18 |
dpavlin |
4 |
#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 |
dpavlin |
11 |
#define C3725_MAX_NM_BAYS 3 |
34 |
|
|
#define C3725_MAX_WIC_BAYS 3 |
35 |
dpavlin |
4 |
|
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 |
dpavlin |
8 |
/* Network IRQ */ |
49 |
|
|
#define C3725_NETIO_IRQ_BASE 32 |
50 |
dpavlin |
9 |
#define C3725_NETIO_IRQ_PORT_BITS 2 |
51 |
dpavlin |
8 |
#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 |
dpavlin |
11 |
(C3725_NETIO_IRQ_BASE + (C3725_MAX_NM_BAYS * C3725_NETIO_IRQ_PER_SLOT) - 1) |
55 |
dpavlin |
8 |
|
56 |
dpavlin |
4 |
/* 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 |
dpavlin |
11 |
#define C3725_DUART_ADDR 0x3c100000ULL |
64 |
|
|
#define C3725_WIC_ADDR 0x3c200000ULL |
65 |
|
|
#define C3725_BSWAP_ADDR 0xc0000000ULL |
66 |
dpavlin |
4 |
#define C3725_PCI_IO_ADDR 0x100000000ULL |
67 |
|
|
|
68 |
dpavlin |
11 |
/* WIC interval in address space */ |
69 |
|
|
#define C3725_WIC_SIZE 0x2000 |
70 |
|
|
|
71 |
dpavlin |
4 |
/* Offset of simulated NVRAM in ROM flash */ |
72 |
|
|
#define C3725_NVRAM_OFFSET 0xE0000 |
73 |
|
|
#define C3725_NVRAM_SIZE 0xE000 |
74 |
|
|
|
75 |
|
|
/* Reserved space for ROM in NVRAM */ |
76 |
|
|
#define C3725_NVRAM_ROM_RES_SIZE 2048 |
77 |
|
|
|
78 |
|
|
/* C3725 ELF Platform ID */ |
79 |
dpavlin |
11 |
#define C3725_ELF_MACHINE_ID 0x61 |
80 |
dpavlin |
4 |
|
81 |
dpavlin |
11 |
#define VM_C3725(vm) ((c3725_t *)vm->hw_data) |
82 |
|
|
|
83 |
dpavlin |
4 |
/* 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 |
|
|
/* Associated VM instance */ |
92 |
|
|
vm_instance_t *vm; |
93 |
|
|
|
94 |
dpavlin |
11 |
/* GT96100 data */ |
95 |
|
|
struct gt_data *gt_data; |
96 |
dpavlin |
4 |
|
97 |
dpavlin |
8 |
/* I/O FPGA */ |
98 |
|
|
struct c3725_iofpga_data *iofpga_data; |
99 |
|
|
|
100 |
dpavlin |
4 |
/* Chassis information */ |
101 |
|
|
m_uint8_t oir_status; |
102 |
|
|
|
103 |
|
|
/* |
104 |
|
|
* Mainboard EEPROM. |
105 |
|
|
* It can be modified to change the chassis MAC address. |
106 |
|
|
*/ |
107 |
|
|
struct cisco_eeprom mb_eeprom; |
108 |
dpavlin |
8 |
struct nmc93cX6_group mb_eeprom_group; |
109 |
dpavlin |
4 |
|
110 |
|
|
/* Network Module EEPROMs */ |
111 |
dpavlin |
8 |
struct nmc93cX6_group nm_eeprom_group[2]; |
112 |
dpavlin |
4 |
}; |
113 |
|
|
|
114 |
dpavlin |
11 |
/* Get WIC device address for the specified onboard port */ |
115 |
|
|
int c3725_get_onboard_wic_addr(u_int slot,m_uint64_t *phys_addr); |
116 |
dpavlin |
4 |
|
117 |
dpavlin |
11 |
/* Set EEPROM for the specified slot */ |
118 |
|
|
int c3725_set_slot_eeprom(c3725_t *router,u_int slot, |
119 |
|
|
struct cisco_eeprom *eeprom); |
120 |
dpavlin |
4 |
|
121 |
dpavlin |
8 |
/* Get network IRQ for specified slot/port */ |
122 |
|
|
u_int c3725_net_irq_for_slot_port(u_int slot,u_int port); |
123 |
|
|
|
124 |
dpavlin |
4 |
/* Get PCI device for the specified NM bay */ |
125 |
|
|
int c3725_nm_get_pci_device(u_int nm_bay); |
126 |
|
|
|
127 |
|
|
/* Set chassis MAC address */ |
128 |
|
|
int c3725_chassis_set_mac_addr(c3725_t *router,char *mac_addr); |
129 |
|
|
|
130 |
|
|
/* Show C3725 hardware info */ |
131 |
|
|
void c3725_show_hardware(c3725_t *router); |
132 |
|
|
|
133 |
dpavlin |
11 |
/* Initialize EEPROM groups */ |
134 |
|
|
void c3725_init_eeprom_groups(c3725_t *router); |
135 |
dpavlin |
4 |
|
136 |
dpavlin |
11 |
/* Register the c3725 platform */ |
137 |
|
|
int c3725_platform_register(void); |
138 |
dpavlin |
4 |
|
139 |
dpavlin |
11 |
/* Hypervisor C3725 initialization */ |
140 |
|
|
extern int hypervisor_c3725_init(vm_platform_t *platform); |
141 |
dpavlin |
4 |
|
142 |
dpavlin |
11 |
/* NM drivers */ |
143 |
|
|
extern struct cisco_card_driver dev_c3725_nm_1fe_tx_driver; |
144 |
|
|
extern struct cisco_card_driver dev_c3725_gt96100_fe_driver; |
145 |
|
|
extern struct cisco_card_driver dev_c3725_nm_4t_driver; |
146 |
|
|
extern struct cisco_card_driver dev_c3725_nm_16esw_driver; |
147 |
|
|
extern struct cisco_card_driver dev_c3725_nm_nam_driver; |
148 |
|
|
extern struct cisco_card_driver dev_c3725_nm_cids_driver; |
149 |
dpavlin |
4 |
|
150 |
dpavlin |
11 |
/* WIC drivers */ |
151 |
|
|
extern struct cisco_card_driver *dev_c3725_mb_wic_drivers[]; |
152 |
dpavlin |
4 |
|
153 |
|
|
#endif |