| 1 |
/* |
| 2 |
* Cisco 3600 simulation platform. |
| 3 |
* Copyright (c) 2006 Christophe Fillot ([email protected]) |
| 4 |
* |
| 5 |
* Generic Cisco 3600 routines and definitions (EEPROM,...). |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef __DEV_C3600_H__ |
| 9 |
#define __DEV_C3600_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 C3600 parameters */ |
| 22 |
#define C3600_DEFAULT_CHASSIS "3640" |
| 23 |
#define C3600_DEFAULT_RAM_SIZE 128 |
| 24 |
#define C3600_DEFAULT_ROM_SIZE 2 |
| 25 |
#define C3600_DEFAULT_NVRAM_SIZE 128 |
| 26 |
#define C3600_DEFAULT_CONF_REG 0x2102 |
| 27 |
#define C3600_DEFAULT_CLOCK_DIV 4 |
| 28 |
#define C3600_DEFAULT_RAM_MMAP 1 |
| 29 |
#define C3600_DEFAULT_DISK0_SIZE 0 |
| 30 |
#define C3600_DEFAULT_DISK1_SIZE 0 |
| 31 |
#define C3600_DEFAULT_IOMEM_SIZE 5 /* Percents! */ |
| 32 |
|
| 33 |
/* 6 NM slots for the 3660 + integrated FastEthernet ports */ |
| 34 |
#define C3600_MAX_NM_BAYS 7 |
| 35 |
|
| 36 |
/* C3600 DUART Interrupt */ |
| 37 |
#define C3600_DUART_IRQ 5 |
| 38 |
|
| 39 |
/* C3600 Network I/O Interrupt */ |
| 40 |
#define C3600_NETIO_IRQ 2 |
| 41 |
|
| 42 |
/* C3600 GT64k DMA/Timer Interrupt */ |
| 43 |
#define C3600_GT64K_IRQ 4 |
| 44 |
|
| 45 |
/* C3600 External Interrupt */ |
| 46 |
#define C3600_EXT_IRQ 6 |
| 47 |
|
| 48 |
/* C3600 NM Management Interrupt handler */ |
| 49 |
#define C3600_NM_MGMT_IRQ 3 |
| 50 |
|
| 51 |
/* Network IRQ */ |
| 52 |
#define C3600_NETIO_IRQ_BASE 32 |
| 53 |
#define C3600_NETIO_IRQ_PORT_BITS 2 |
| 54 |
#define C3600_NETIO_IRQ_PORT_MASK ((1 << C3600_NETIO_IRQ_PORT_BITS) - 1) |
| 55 |
#define C3600_NETIO_IRQ_PER_SLOT (1 << C3600_NETIO_IRQ_PORT_BITS) |
| 56 |
#define C3600_NETIO_IRQ_END \ |
| 57 |
(C3600_NETIO_IRQ_BASE + (C3600_MAX_NM_BAYS * C3600_NETIO_IRQ_PER_SLOT) - 1) |
| 58 |
|
| 59 |
/* C3600 common device addresses */ |
| 60 |
#define C3600_GT64K_ADDR 0x14000000ULL |
| 61 |
#define C3600_IOFPGA_ADDR 0x1e800000ULL |
| 62 |
#define C3600_DUART_ADDR 0x1e840000ULL |
| 63 |
#define C3600_BITBUCKET_ADDR 0x1ec00000ULL |
| 64 |
#define C3600_NVRAM_ADDR 0x1fe00000ULL |
| 65 |
#define C3600_ROM_ADDR 0x1fc00000ULL |
| 66 |
#define C3600_BOOTFLASH_ADDR 0x30000000ULL |
| 67 |
#define C3600_PCI_IO_ADDR 0x100000000ULL |
| 68 |
|
| 69 |
/* Reserved space for ROM in NVRAM */ |
| 70 |
#define C3600_NVRAM_ROM_RES_SIZE 2048 |
| 71 |
|
| 72 |
/* C3600 ELF Platform ID */ |
| 73 |
#define C3620_ELF_MACHINE_ID 0x1e |
| 74 |
#define C3640_ELF_MACHINE_ID 0x1e |
| 75 |
#define C3660_ELF_MACHINE_ID 0x34 |
| 76 |
|
| 77 |
#define VM_C3600(vm) ((c3600_t *)vm->hw_data) |
| 78 |
|
| 79 |
/* C3600 router */ |
| 80 |
typedef struct c3600_router c3600_t; |
| 81 |
|
| 82 |
/* Prototype of chassis driver initialization function */ |
| 83 |
typedef int (*c3600_chassis_init_fn)(c3600_t *router); |
| 84 |
|
| 85 |
/* C3600 Chassis Driver */ |
| 86 |
struct c3600_chassis_driver { |
| 87 |
char *chassis_type; |
| 88 |
int chassis_id; |
| 89 |
int supported; |
| 90 |
c3600_chassis_init_fn chassis_init; |
| 91 |
struct cisco_eeprom *eeprom; |
| 92 |
}; |
| 93 |
|
| 94 |
/* C3600 router */ |
| 95 |
struct c3600_router { |
| 96 |
/* Chassis MAC address */ |
| 97 |
n_eth_addr_t mac_addr; |
| 98 |
|
| 99 |
char board_id[20]; |
| 100 |
|
| 101 |
/* Associated VM instance */ |
| 102 |
vm_instance_t *vm; |
| 103 |
|
| 104 |
/* I/O FPGA */ |
| 105 |
struct c3600_iofpga_data *iofpga_data; |
| 106 |
|
| 107 |
/* Chassis information */ |
| 108 |
struct c3600_chassis_driver *chassis_driver; |
| 109 |
m_uint16_t oir_status; |
| 110 |
|
| 111 |
/* |
| 112 |
* Mainboard EEPROM. |
| 113 |
* It can be modified to change the chassis MAC address. |
| 114 |
*/ |
| 115 |
struct cisco_eeprom mb_eeprom; |
| 116 |
struct nmc93cX6_group mb_eeprom_group; |
| 117 |
|
| 118 |
/* Network Module EEPROMs (3620/3640) */ |
| 119 |
struct nmc93cX6_group nm_eeprom_group; |
| 120 |
|
| 121 |
/* Cisco 3660 NM EEPROMs */ |
| 122 |
struct nmc93cX6_group c3660_nm_eeprom_group[C3600_MAX_NM_BAYS]; |
| 123 |
}; |
| 124 |
|
| 125 |
/* Set EEPROM for the specified slot */ |
| 126 |
int c3600_set_slot_eeprom(c3600_t *router,u_int slot, |
| 127 |
struct cisco_eeprom *eeprom); |
| 128 |
|
| 129 |
/* Get network IRQ for specified slot/port */ |
| 130 |
u_int c3600_net_irq_for_slot_port(u_int slot,u_int port); |
| 131 |
|
| 132 |
/* Show the list of available NM drivers */ |
| 133 |
void c3600_nm_show_drivers(void); |
| 134 |
|
| 135 |
/* Set chassis MAC address */ |
| 136 |
int c3600_chassis_set_mac_addr(c3600_t *router,char *mac_addr); |
| 137 |
|
| 138 |
/* Set the system id */ |
| 139 |
int c3600_set_system_id(c3600_t *router,char *id); |
| 140 |
|
| 141 |
/* Burn the system id into the appropriate eeprom if possible */ |
| 142 |
int c3600_refresh_systemid(c3600_t *router); |
| 143 |
|
| 144 |
/* Set the chassis type */ |
| 145 |
int c3600_chassis_set_type(c3600_t *router,char *chassis_type); |
| 146 |
|
| 147 |
/* Get the chassis ID */ |
| 148 |
int c3600_chassis_get_id(c3600_t *router); |
| 149 |
|
| 150 |
/* Show C3600 hardware info */ |
| 151 |
void c3600_show_hardware(c3600_t *router); |
| 152 |
|
| 153 |
/* Initialize EEPROM groups */ |
| 154 |
void c3600_init_eeprom_groups(c3600_t *router); |
| 155 |
|
| 156 |
/* dev_c3600_iofpga_init() */ |
| 157 |
int dev_c3600_iofpga_init(c3600_t *router,m_uint64_t paddr,m_uint32_t len); |
| 158 |
|
| 159 |
/* Register the c3600 platform */ |
| 160 |
int c3600_platform_register(void); |
| 161 |
|
| 162 |
/* Hypervisor C3600 initialization */ |
| 163 |
extern int hypervisor_c3600_init(vm_platform_t *platform); |
| 164 |
|
| 165 |
/* NM drivers */ |
| 166 |
extern struct cisco_card_driver dev_c3600_nm_1e_driver; |
| 167 |
extern struct cisco_card_driver dev_c3600_nm_4e_driver; |
| 168 |
extern struct cisco_card_driver dev_c3600_nm_1fe_tx_driver; |
| 169 |
extern struct cisco_card_driver dev_c3600_nm_4t_driver; |
| 170 |
extern struct cisco_card_driver dev_c3600_leopard_2fe_driver; |
| 171 |
extern struct cisco_card_driver dev_c3600_nm_16esw_driver; |
| 172 |
extern struct cisco_card_driver dev_c3600_nmd_36esw_driver; |
| 173 |
|
| 174 |
#endif |