| 1 |
/* |
| 2 |
* Cisco 3745 simulation platform. |
| 3 |
* Copyright (c) 2006 Christophe Fillot ([email protected]) |
| 4 |
* |
| 5 |
* Generic Cisco 3745 routines and definitions (EEPROM,...). |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef __DEV_C3745_H__ |
| 9 |
#define __DEV_C3745_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 "dev_gt.h" |
| 19 |
#include "net_io.h" |
| 20 |
#include "vm.h" |
| 21 |
|
| 22 |
/* Default C3745 parameters */ |
| 23 |
#define C3745_DEFAULT_RAM_SIZE 128 |
| 24 |
#define C3745_DEFAULT_ROM_SIZE 2 |
| 25 |
#define C3745_DEFAULT_NVRAM_SIZE 304 |
| 26 |
#define C3745_DEFAULT_CONF_REG 0x2102 |
| 27 |
#define C3745_DEFAULT_CLOCK_DIV 8 |
| 28 |
#define C3745_DEFAULT_RAM_MMAP 1 |
| 29 |
#define C3745_DEFAULT_DISK0_SIZE 16 |
| 30 |
#define C3745_DEFAULT_DISK1_SIZE 0 |
| 31 |
#define C3745_DEFAULT_IOMEM_SIZE 5 /* Percents! */ |
| 32 |
|
| 33 |
/* 3745 characteritics: 4 NM (+ motherboard), 3 WIC, 2 AIM */ |
| 34 |
#define C3745_MAX_NM_BAYS 5 |
| 35 |
#define C3745_MAX_WIC_BAYS 3 |
| 36 |
|
| 37 |
/* C3745 DUART Interrupt */ |
| 38 |
#define C3745_DUART_IRQ 5 |
| 39 |
|
| 40 |
/* C3745 Network I/O Interrupt */ |
| 41 |
#define C3745_NETIO_IRQ 2 |
| 42 |
|
| 43 |
/* C3745 GT64k DMA/Timer Interrupt */ |
| 44 |
#define C3745_GT96K_IRQ 3 |
| 45 |
|
| 46 |
/* C3745 External Interrupt */ |
| 47 |
#define C3745_EXT_IRQ 6 |
| 48 |
|
| 49 |
/* Network IRQ */ |
| 50 |
#define C3745_NETIO_IRQ_BASE 32 |
| 51 |
#define C3745_NETIO_IRQ_PORT_BITS 2 |
| 52 |
#define C3745_NETIO_IRQ_PORT_MASK ((1 << C3745_NETIO_IRQ_PORT_BITS) - 1) |
| 53 |
#define C3745_NETIO_IRQ_PER_SLOT (1 << C3745_NETIO_IRQ_PORT_BITS) |
| 54 |
#define C3745_NETIO_IRQ_END \ |
| 55 |
(C3745_NETIO_IRQ_BASE + (C3745_MAX_NM_BAYS * C3745_NETIO_IRQ_PER_SLOT) - 1) |
| 56 |
|
| 57 |
/* C3745 common device addresses */ |
| 58 |
#define C3745_BITBUCKET_ADDR 0x1ec00000ULL |
| 59 |
#define C3745_IOFPGA_ADDR 0x1fa00000ULL |
| 60 |
#define C3745_ROM_ADDR 0x1fc00000ULL |
| 61 |
#define C3745_GT96K_ADDR 0x24000000ULL |
| 62 |
#define C3745_SLOT0_ADDR 0x30000000ULL |
| 63 |
#define C3745_SLOT1_ADDR 0x32000000ULL |
| 64 |
#define C3745_DUART_ADDR 0x3c100000ULL |
| 65 |
#define C3745_WIC_ADDR 0x3c200000ULL |
| 66 |
#define C3745_BSWAP_ADDR 0xc0000000ULL |
| 67 |
#define C3745_PCI_IO_ADDR 0x100000000ULL |
| 68 |
|
| 69 |
/* WIC interval in address space */ |
| 70 |
#define C3745_WIC_SIZE 0x2000 |
| 71 |
|
| 72 |
/* Offset of simulated NVRAM in ROM flash */ |
| 73 |
#define C3745_NVRAM_OFFSET 0xB0000 |
| 74 |
#define C3745_NVRAM_SIZE 0x4C000 // with backup |
| 75 |
|
| 76 |
/* Reserved space for ROM in NVRAM */ |
| 77 |
#define C3745_NVRAM_ROM_RES_SIZE 0 |
| 78 |
|
| 79 |
/* C3745 ELF Platform ID */ |
| 80 |
#define C3745_ELF_MACHINE_ID 0x69 |
| 81 |
|
| 82 |
#define VM_C3745(vm) ((c3745_t *)vm->hw_data) |
| 83 |
|
| 84 |
/* C3745 router */ |
| 85 |
typedef struct c3745_router c3745_t; |
| 86 |
|
| 87 |
/* C3745 router */ |
| 88 |
struct c3745_router { |
| 89 |
/* Chassis MAC address */ |
| 90 |
n_eth_addr_t mac_addr; |
| 91 |
|
| 92 |
char board_id[20]; |
| 93 |
|
| 94 |
/* Associated VM instance */ |
| 95 |
vm_instance_t *vm; |
| 96 |
|
| 97 |
/* GT96100 data */ |
| 98 |
struct gt_data *gt_data; |
| 99 |
|
| 100 |
/* I/O FPGA */ |
| 101 |
struct c3745_iofpga_data *iofpga_data; |
| 102 |
|
| 103 |
/* OIR status */ |
| 104 |
m_uint8_t oir_status; |
| 105 |
|
| 106 |
/* |
| 107 |
* System EEPROMs. |
| 108 |
* It can be modified to change the chassis MAC address. |
| 109 |
*/ |
| 110 |
struct cisco_eeprom sys_eeprom[3]; |
| 111 |
struct nmc93cX6_group sys_eeprom_group; |
| 112 |
|
| 113 |
/* Network Module EEPROMs */ |
| 114 |
struct nmc93cX6_group nm_eeprom_group[4]; |
| 115 |
}; |
| 116 |
|
| 117 |
/* Get WIC device address for the specified onboard port */ |
| 118 |
int c3745_get_onboard_wic_addr(u_int slot,m_uint64_t *phys_addr); |
| 119 |
|
| 120 |
/* Set EEPROM for the specified slot */ |
| 121 |
int c3745_set_slot_eeprom(c3745_t *router,u_int slot, |
| 122 |
struct cisco_eeprom *eeprom); |
| 123 |
|
| 124 |
/* Get network IRQ for specified slot/port */ |
| 125 |
u_int c3745_net_irq_for_slot_port(u_int slot,u_int port); |
| 126 |
|
| 127 |
/* Set chassis MAC address */ |
| 128 |
int c3745_chassis_set_mac_addr(c3745_t *router,char *mac_addr); |
| 129 |
|
| 130 |
/* Set the system id */ |
| 131 |
int c3745_set_system_id(c3745_t *router,char *id); |
| 132 |
|
| 133 |
/* Burn the system id into the appropriate eeprom if possible */ |
| 134 |
int c3745_refresh_systemid(c3745_t *router); |
| 135 |
|
| 136 |
/* Show C3745 hardware info */ |
| 137 |
void c3745_show_hardware(c3745_t *router); |
| 138 |
|
| 139 |
/* Initialize EEPROM groups */ |
| 140 |
void c3745_init_eeprom_groups(c3745_t *router); |
| 141 |
|
| 142 |
/* dev_c3745_iofpga_init() */ |
| 143 |
int dev_c3745_iofpga_init(c3745_t *router,m_uint64_t paddr,m_uint32_t len); |
| 144 |
|
| 145 |
/* Register the c3745 platform */ |
| 146 |
int c3745_platform_register(void); |
| 147 |
|
| 148 |
/* Hypervisor C3745 initialization */ |
| 149 |
extern int hypervisor_c3745_init(vm_platform_t *platform); |
| 150 |
|
| 151 |
/* NM drivers */ |
| 152 |
extern struct cisco_card_driver dev_c3745_nm_1fe_tx_driver; |
| 153 |
extern struct cisco_card_driver dev_c3745_gt96100_fe_driver; |
| 154 |
extern struct cisco_card_driver dev_c3745_nm_4t_driver; |
| 155 |
extern struct cisco_card_driver dev_c3745_nm_16esw_driver; |
| 156 |
extern struct cisco_card_driver dev_c3745_nmd_36esw_driver; |
| 157 |
extern struct cisco_card_driver dev_c3745_nm_nam_driver; |
| 158 |
extern struct cisco_card_driver dev_c3745_nm_cids_driver; |
| 159 |
|
| 160 |
/* WIC drivers */ |
| 161 |
extern struct cisco_card_driver *dev_c3745_mb_wic_drivers[]; |
| 162 |
|
| 163 |
#endif |