| 1 |
/* |
| 2 |
* Cisco router simulation platform. |
| 3 |
* Copyright (c) 2006 Christophe Fillot ([email protected]) |
| 4 |
* |
| 5 |
* Generic Cisco 1700 routines and definitions (EEPROM,...). |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef __DEV_C1700_H__ |
| 9 |
#define __DEV_C1700_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 "dev_mpc860.h" |
| 20 |
#include "vm.h" |
| 21 |
|
| 22 |
/* Default C1700 parameters */ |
| 23 |
#define C1700_DEFAULT_MAINBOARD "1720" |
| 24 |
#define C1700_DEFAULT_RAM_SIZE 64 |
| 25 |
#define C1700_DEFAULT_ROM_SIZE 2 |
| 26 |
#define C1700_DEFAULT_NVRAM_SIZE 32 |
| 27 |
#define C1700_DEFAULT_CONF_REG 0x2102 |
| 28 |
#define C1700_DEFAULT_CLOCK_DIV 8 |
| 29 |
#define C1700_DEFAULT_RAM_MMAP 1 |
| 30 |
#define C1700_DEFAULT_DISK0_SIZE 0 |
| 31 |
#define C1700_DEFAULT_DISK1_SIZE 0 |
| 32 |
#define C1700_DEFAULT_IOMEM_SIZE 15 /* Percents! */ |
| 33 |
|
| 34 |
/* 1700 characteristics: only mainboard (considered as fake NM) */ |
| 35 |
#define C1700_MAX_NM_BAYS 1 |
| 36 |
#define C1700_MAX_WIC_BAYS 2 |
| 37 |
|
| 38 |
/* C1700 Virtual Timer Interrupt */ |
| 39 |
#define C1700_VTIMER_IRQ 0 |
| 40 |
|
| 41 |
/* C1700 DUART Interrupt */ |
| 42 |
#define C1700_DUART_IRQ 1 |
| 43 |
|
| 44 |
/* C1700 Network I/O Interrupt */ |
| 45 |
#define C1700_NETIO_IRQ 2 |
| 46 |
|
| 47 |
/* C1700 PA Management Interrupt */ |
| 48 |
#define C1700_PA_MGMT_IRQ 3 |
| 49 |
|
| 50 |
/* Network IRQ */ |
| 51 |
#define C1700_NETIO_IRQ_BASE 32 |
| 52 |
#define C1700_NETIO_IRQ_PORT_BITS 2 |
| 53 |
#define C1700_NETIO_IRQ_PORT_MASK ((1 << C1700_NETIO_IRQ_PORT_BITS) - 1) |
| 54 |
#define C1700_NETIO_IRQ_PER_SLOT (1 << C1700_NETIO_IRQ_PORT_BITS) |
| 55 |
#define C1700_NETIO_IRQ_END \ |
| 56 |
(C1700_NETIO_IRQ_BASE + (C1700_MAX_NM_BAYS * C1700_NETIO_IRQ_PER_SLOT) - 1) |
| 57 |
|
| 58 |
/* C1700 common device addresses */ |
| 59 |
#define C1700_FLASH_ADDR 0x60000000ULL |
| 60 |
#define C1700_NVRAM_ADDR 0x68000000ULL |
| 61 |
#define C1700_IOFPGA_ADDR 0x68020000ULL |
| 62 |
#define C1700_WIC_ADDR 0x68030000ULL |
| 63 |
#define C1700_DUART_ADDR 0x68050000ULL |
| 64 |
#define C1700_MPC860_ADDR 0xff000000ULL |
| 65 |
#define C1700_ROM_ADDR 0xfff00000ULL |
| 66 |
|
| 67 |
/* WIC interval in address space */ |
| 68 |
#define C1700_WIC_SIZE 0x1000 |
| 69 |
|
| 70 |
/* Reserved space for ROM in NVRAM */ |
| 71 |
#define C1700_NVRAM_ROM_RES_SIZE 2048 |
| 72 |
|
| 73 |
/* C1700 ELF Platform ID */ |
| 74 |
#define C1700_ELF_MACHINE_ID 0x33 |
| 75 |
|
| 76 |
#define VM_C1700(vm) ((c1700_t *)vm->hw_data) |
| 77 |
|
| 78 |
/* C1700 router */ |
| 79 |
typedef struct c1700_router c1700_t; |
| 80 |
|
| 81 |
/* C1700 router */ |
| 82 |
struct c1700_router { |
| 83 |
/* Mainboard type (2610, 2611, etc) */ |
| 84 |
char *mainboard_type; |
| 85 |
|
| 86 |
/* Chassis MAC address */ |
| 87 |
n_eth_addr_t mac_addr; |
| 88 |
|
| 89 |
char board_id[20]; |
| 90 |
|
| 91 |
/* Associated VM instance */ |
| 92 |
vm_instance_t *vm; |
| 93 |
|
| 94 |
/* I/O FPGA */ |
| 95 |
struct c1700_iofpga_data *iofpga_data; |
| 96 |
|
| 97 |
/* |
| 98 |
* Mainboard EEPROM. |
| 99 |
* It can be modified to change the chassis MAC address. |
| 100 |
*/ |
| 101 |
struct cisco_eeprom mb_eeprom; |
| 102 |
struct nmc93cX6_group mb_eeprom_group; |
| 103 |
|
| 104 |
/* Network Module EEPROM */ |
| 105 |
struct nmc93cX6_group nm_eeprom_group; |
| 106 |
|
| 107 |
/* MPC860 device private data */ |
| 108 |
struct mpc860_data *mpc_data; |
| 109 |
}; |
| 110 |
|
| 111 |
/* Get WIC device address for the specified onboard port */ |
| 112 |
int c1700_get_onboard_wic_addr(u_int slot,m_uint64_t *phys_addr); |
| 113 |
|
| 114 |
/* Set EEPROM for the specified slot */ |
| 115 |
int c1700_set_slot_eeprom(c1700_t *router,u_int slot, |
| 116 |
struct cisco_eeprom *eeprom); |
| 117 |
|
| 118 |
/* Get network IRQ for specified slot/port */ |
| 119 |
u_int c1700_net_irq_for_slot_port(u_int slot,u_int port); |
| 120 |
|
| 121 |
/* Set mainboard type */ |
| 122 |
int c1700_mainboard_set_type(c1700_t *router,char *mainboard_type); |
| 123 |
|
| 124 |
/* Set chassis MAC address */ |
| 125 |
int c1700_chassis_set_mac_addr(c1700_t *router,char *mac_addr); |
| 126 |
|
| 127 |
/* Set the system id */ |
| 128 |
int c1700_set_system_id(c1700_t *router,char *id); |
| 129 |
|
| 130 |
/* Burn the system id into the appropriate eeprom if possible */ |
| 131 |
int c1700_refresh_systemid(c1700_t *router); |
| 132 |
|
| 133 |
/* Show C1700 hardware info */ |
| 134 |
void c1700_show_hardware(c1700_t *router); |
| 135 |
|
| 136 |
/* Initialize EEPROM groups */ |
| 137 |
void c1700_init_eeprom_groups(c1700_t *router); |
| 138 |
|
| 139 |
/* dev_c1700_iofpga_init() */ |
| 140 |
int dev_c1700_iofpga_init(c1700_t *router,m_uint64_t paddr,m_uint32_t len); |
| 141 |
|
| 142 |
/* Register the c1700 platform */ |
| 143 |
int c1700_platform_register(void); |
| 144 |
|
| 145 |
/* Hypervisor C1700 initialization */ |
| 146 |
extern int hypervisor_c1700_init(vm_platform_t *platform); |
| 147 |
|
| 148 |
/* c1700 Motherboard drivers */ |
| 149 |
extern struct cisco_card_driver dev_c1700_mb_eth_driver; |
| 150 |
extern struct cisco_card_driver dev_c1710_mb_eth_driver; |
| 151 |
|
| 152 |
/* WIC drivers */ |
| 153 |
extern struct cisco_card_driver *dev_c1700_mb_wic_drivers[]; |
| 154 |
|
| 155 |
#endif |