| 1 |
/* |
| 2 |
* Cisco router simulation platform. |
| 3 |
* Copyright (c) 2005,2006 Christophe Fillot ([email protected]) |
| 4 |
* Patched by Jeremy Grossmann for the GNS3 project (www.gns3.net) |
| 5 |
* |
| 6 |
* Generic Cisco 7200 routines and definitions (EEPROM,...). |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <stdio.h> |
| 10 |
#include <stdlib.h> |
| 11 |
#include <string.h> |
| 12 |
#include <unistd.h> |
| 13 |
#include <sys/types.h> |
| 14 |
#include <assert.h> |
| 15 |
|
| 16 |
#include "cpu.h" |
| 17 |
#include "vm.h" |
| 18 |
#include "dynamips.h" |
| 19 |
#include "memory.h" |
| 20 |
#include "ppc32_mem.h" |
| 21 |
#include "device.h" |
| 22 |
#include "pci_io.h" |
| 23 |
#include "dev_gt.h" |
| 24 |
#include "dev_mv64460.h" |
| 25 |
#include "cisco_eeprom.h" |
| 26 |
#include "dev_rom.h" |
| 27 |
#include "dev_c7200.h" |
| 28 |
#include "dev_c7200_mpfpga.h" |
| 29 |
#include "dev_vtty.h" |
| 30 |
#include "registry.h" |
| 31 |
#include "net.h" |
| 32 |
#include "fs_nvram.h" |
| 33 |
|
| 34 |
/* ======================================================================== */ |
| 35 |
/* CPU EEPROM definitions */ |
| 36 |
/* ======================================================================== */ |
| 37 |
|
| 38 |
/* NPE-100 */ |
| 39 |
static m_uint16_t eeprom_cpu_npe100_data[16] = { |
| 40 |
0x0135, 0x0203, 0xff10, 0x45C5, 0x4906, 0x0004, 0x0000, 0x0000, |
| 41 |
0x6000, 0x0000, 0x9901, 0x0600, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 42 |
}; |
| 43 |
|
| 44 |
/* NPE-150 */ |
| 45 |
static m_uint16_t eeprom_cpu_npe150_data[16] = { |
| 46 |
0x0115, 0x0203, 0xff10, 0x45C5, 0x4906, 0x0004, 0x0000, 0x0000, |
| 47 |
0x6000, 0x0000, 0x9901, 0x0600, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 48 |
}; |
| 49 |
|
| 50 |
/* NPE-175 */ |
| 51 |
static m_uint16_t eeprom_cpu_npe175_data[16] = { |
| 52 |
0x01C2, 0x0203, 0xff10, 0x45C5, 0x4906, 0x0004, 0x0000, 0x0000, |
| 53 |
0x6000, 0x0000, 0x9901, 0x0600, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 54 |
}; |
| 55 |
|
| 56 |
/* NPE-200 */ |
| 57 |
static m_uint16_t eeprom_cpu_npe200_data[16] = { |
| 58 |
0x0169, 0x0200, 0xff10, 0x45C5, 0x4909, 0x8902, 0x0000, 0x0000, |
| 59 |
0x6800, 0x0000, 0x9710, 0x2200, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 60 |
}; |
| 61 |
|
| 62 |
/* NPE-225 (same as NPE-175) */ |
| 63 |
static m_uint16_t eeprom_cpu_npe225_data[16] = { |
| 64 |
0x01C2, 0x0203, 0xff10, 0x45C5, 0x4906, 0x0004, 0x0000, 0x0000, |
| 65 |
0x6000, 0x0000, 0x9901, 0x0600, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 66 |
}; |
| 67 |
|
| 68 |
/* NPE-300 */ |
| 69 |
static m_uint16_t eeprom_cpu_npe300_data[16] = { |
| 70 |
0x01AE, 0x0402, 0xff10, 0x45C5, 0x490D, 0x5108, 0x0000, 0x0000, |
| 71 |
0x5000, 0x0000, 0x0012, 0x1000, 0x0000, 0xFFFF, 0xFFFF, 0xFF00, |
| 72 |
}; |
| 73 |
|
| 74 |
/* NPE-400 */ |
| 75 |
static m_uint16_t eeprom_cpu_npe400_data[64] = { |
| 76 |
0x04FF, 0x4001, 0xF841, 0x0100, 0xC046, 0x0320, 0x001F, 0xC802, |
| 77 |
0x8249, 0x14BC, 0x0242, 0x4230, 0xC18B, 0x3131, 0x3131, 0x3131, |
| 78 |
0x3131, 0x0000, 0x0004, 0x0002, 0x0285, 0x1C0F, 0xF602, 0xCB87, |
| 79 |
0x4E50, 0x452D, 0x3430, 0x3080, 0x0000, 0x0000, 0xFFFF, 0xFFFF, |
| 80 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 81 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 82 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 83 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 84 |
}; |
| 85 |
|
| 86 |
/* NPE-G1 */ |
| 87 |
static m_uint16_t eeprom_cpu_npeg1_data[64] = { |
| 88 |
0x04FF, 0x4003, 0x5B41, 0x0200, 0xC046, 0x0320, 0x0049, 0xD00B, |
| 89 |
0x8249, 0x1B4C, 0x0B42, 0x4130, 0xC18B, 0x3131, 0x3131, 0x3131, |
| 90 |
0x3131, 0x0000, 0x0004, 0x0002, 0x0985, 0x1C13, 0xDA09, 0xCB86, |
| 91 |
0x4E50, 0x452D, 0x4731, 0x8000, 0x0000, 0x00FF, 0xFFFF, 0xFFFF, |
| 92 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 93 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 94 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 95 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 96 |
}; |
| 97 |
|
| 98 |
/* NPE-G2 */ |
| 99 |
static m_uint16_t eeprom_cpu_npeg2_data[64] = { |
| 100 |
0x04FF, 0x4004, 0xCA41, 0x0201, 0x8744, 0x19BC, 0x0182, 0x4928, |
| 101 |
0x5901, 0x42FF, 0xFFC1, 0x8B43, 0x534A, 0x3039, 0x3435, 0x3239, |
| 102 |
0x3237, 0x0400, 0x0201, 0x851C, 0x1DA2, 0x01CB, 0x864E, 0x5045, |
| 103 |
0x2D47, 0x3280, 0x0000, 0x0000, 0x8956, 0x3031, 0x2DFF, 0xFFFF, |
| 104 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 105 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 106 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 107 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x15FF, |
| 108 |
}; |
| 109 |
/* |
| 110 |
* CPU EEPROM array. |
| 111 |
*/ |
| 112 |
static struct cisco_eeprom c7200_cpu_eeprom[] = { |
| 113 |
{ "npe-100", eeprom_cpu_npe100_data, sizeof(eeprom_cpu_npe100_data)/2 }, |
| 114 |
{ "npe-150", eeprom_cpu_npe150_data, sizeof(eeprom_cpu_npe150_data)/2 }, |
| 115 |
{ "npe-175", eeprom_cpu_npe175_data, sizeof(eeprom_cpu_npe175_data)/2 }, |
| 116 |
{ "npe-200", eeprom_cpu_npe200_data, sizeof(eeprom_cpu_npe200_data)/2 }, |
| 117 |
{ "npe-225", eeprom_cpu_npe225_data, sizeof(eeprom_cpu_npe225_data)/2 }, |
| 118 |
{ "npe-300", eeprom_cpu_npe300_data, sizeof(eeprom_cpu_npe300_data)/2 }, |
| 119 |
{ "npe-400", eeprom_cpu_npe400_data, sizeof(eeprom_cpu_npe400_data)/2 }, |
| 120 |
{ "npe-g1" , eeprom_cpu_npeg1_data , sizeof(eeprom_cpu_npeg1_data)/2 }, |
| 121 |
{ "npe-g2" , eeprom_cpu_npeg2_data , sizeof(eeprom_cpu_npeg2_data)/2 }, |
| 122 |
{ NULL, NULL, 0 }, |
| 123 |
}; |
| 124 |
|
| 125 |
/* ======================================================================== */ |
| 126 |
/* Midplane EEPROM definitions */ |
| 127 |
/* ======================================================================== */ |
| 128 |
|
| 129 |
/* Standard Midplane EEPROM contents */ |
| 130 |
static m_uint16_t eeprom_midplane_data[32] = { |
| 131 |
0x0106, 0x0101, 0xff10, 0x45C5, 0x4906, 0x0303, 0xFFFF, 0xFFFF, |
| 132 |
0xFFFF, 0x0400, 0x0000, 0x0000, 0x4C09, 0x10B0, 0xFFFF, 0x00FF, |
| 133 |
0x0000, 0x0000, 0x6335, 0x8B28, 0x631D, 0x0000, 0x608E, 0x6D1C, |
| 134 |
0x62BB, 0x0000, 0x6335, 0x8B28, 0x0000, 0x0000, 0x6335, 0x8B28, |
| 135 |
}; |
| 136 |
|
| 137 |
/* VXR Midplane EEPROM contents */ |
| 138 |
static m_uint16_t eeprom_vxr_midplane_data[32] = { |
| 139 |
0x0106, 0x0201, 0xff10, 0x45C5, 0x4906, 0x0303, 0xFFFF, 0xFFFF, |
| 140 |
0xFFFF, 0x0400, 0x0000, 0x0000, 0x4C09, 0x10B0, 0xFFFF, 0x00FF, |
| 141 |
0x0000, 0x0000, 0x6335, 0x8B28, 0x631D, 0x0000, 0x608E, 0x6D1C, |
| 142 |
0x62BB, 0x0000, 0x6335, 0x8B28, 0x0000, 0x0000, 0x6335, 0x8B28, |
| 143 |
}; |
| 144 |
|
| 145 |
/* |
| 146 |
* Midplane EEPROM array. |
| 147 |
*/ |
| 148 |
static struct cisco_eeprom c7200_midplane_eeprom[] = { |
| 149 |
{ "std", eeprom_midplane_data, sizeof(eeprom_midplane_data)/2 }, |
| 150 |
{ "vxr", eeprom_vxr_midplane_data, sizeof(eeprom_vxr_midplane_data)/2 }, |
| 151 |
{ NULL, NULL, 0 }, |
| 152 |
}; |
| 153 |
|
| 154 |
/* ======================================================================== */ |
| 155 |
/* PEM EEPROM definitions (for NPE-175 and NPE-225) */ |
| 156 |
/* ======================================================================== */ |
| 157 |
|
| 158 |
/* NPE-175 */ |
| 159 |
static m_uint16_t eeprom_pem_npe175_data[16] = { |
| 160 |
0x01C3, 0x0100, 0xFFFF, 0xFFFF, 0x490D, 0x8A04, 0x0000, 0x0000, |
| 161 |
0x5000, 0x0000, 0x9906, 0x0400, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, |
| 162 |
}; |
| 163 |
|
| 164 |
/* NPE-225 */ |
| 165 |
static m_uint16_t eeprom_pem_npe225_data[16] = { |
| 166 |
0x01D5, 0x0100, 0xFFFF, 0xFFFF, 0x490D, 0x8A04, 0x0000, 0x0000, |
| 167 |
0x5000, 0x0000, 0x9906, 0x0400, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, |
| 168 |
}; |
| 169 |
|
| 170 |
/* |
| 171 |
* PEM EEPROM array. |
| 172 |
*/ |
| 173 |
static struct cisco_eeprom c7200_pem_eeprom[] = { |
| 174 |
{ "npe-175", eeprom_pem_npe175_data, sizeof(eeprom_pem_npe175_data)/2 }, |
| 175 |
{ "npe-225", eeprom_pem_npe225_data, sizeof(eeprom_pem_npe225_data)/2 }, |
| 176 |
{ NULL, NULL, 0 }, |
| 177 |
}; |
| 178 |
|
| 179 |
/* ======================================================================== */ |
| 180 |
/* Port Adapter Drivers */ |
| 181 |
/* ======================================================================== */ |
| 182 |
static struct cisco_card_driver *pa_drivers[] = { |
| 183 |
&dev_c7200_npeg2_driver, |
| 184 |
&dev_c7200_iocard_fe_driver, |
| 185 |
&dev_c7200_iocard_2fe_driver, |
| 186 |
&dev_c7200_iocard_ge_e_driver, |
| 187 |
&dev_c7200_pa_fe_tx_driver, |
| 188 |
&dev_c7200_pa_2fe_tx_driver, |
| 189 |
&dev_c7200_pa_ge_driver, |
| 190 |
&dev_c7200_pa_4e_driver, |
| 191 |
&dev_c7200_pa_8e_driver, |
| 192 |
&dev_c7200_pa_4t_driver, |
| 193 |
&dev_c7200_pa_8t_driver, |
| 194 |
&dev_c7200_pa_a1_driver, |
| 195 |
&dev_c7200_pa_pos_oc3_driver, |
| 196 |
&dev_c7200_pa_4b_driver, |
| 197 |
&dev_c7200_pa_mc8te1_driver, |
| 198 |
&dev_c7200_jcpa_driver, |
| 199 |
NULL, |
| 200 |
}; |
| 201 |
|
| 202 |
/* ======================================================================== */ |
| 203 |
/* NPE Drivers */ |
| 204 |
/* ======================================================================== */ |
| 205 |
#define DECLARE_NPE(type) \ |
| 206 |
int (c7200_init_##type)(c7200_t *router) |
| 207 |
|
| 208 |
DECLARE_NPE(npe100); |
| 209 |
DECLARE_NPE(npe150); |
| 210 |
DECLARE_NPE(npe175); |
| 211 |
DECLARE_NPE(npe200); |
| 212 |
DECLARE_NPE(npe225); |
| 213 |
DECLARE_NPE(npe300); |
| 214 |
DECLARE_NPE(npe400); |
| 215 |
DECLARE_NPE(npeg1); |
| 216 |
DECLARE_NPE(npeg2); |
| 217 |
|
| 218 |
static struct c7200_npe_driver npe_drivers[] = { |
| 219 |
{ "npe-100" , C7200_NPE_FAMILY_MIPS, c7200_init_npe100, 256, 1, |
| 220 |
C7200_NVRAM_ADDR, TRUE, 0, 5, 0, 6 }, |
| 221 |
{ "npe-150" , C7200_NPE_FAMILY_MIPS, c7200_init_npe150, 256, 1, |
| 222 |
C7200_NVRAM_ADDR, TRUE, 0, 5, 0, 6 }, |
| 223 |
{ "npe-175" , C7200_NPE_FAMILY_MIPS, c7200_init_npe175, 256, 1, |
| 224 |
C7200_NVRAM_ADDR, TRUE, 2, 16, 1, 0 }, |
| 225 |
{ "npe-200" , C7200_NPE_FAMILY_MIPS, c7200_init_npe200, 256, 1, |
| 226 |
C7200_NVRAM_ADDR, TRUE, 0, 5, 0, 6 }, |
| 227 |
{ "npe-225" , C7200_NPE_FAMILY_MIPS, c7200_init_npe225, 256, 1, |
| 228 |
C7200_NVRAM_ADDR, TRUE, 2, 16, 1, 0 }, |
| 229 |
{ "npe-300" , C7200_NPE_FAMILY_MIPS, c7200_init_npe300, 256, 1, |
| 230 |
C7200_NVRAM_ADDR, TRUE, 2, 16, 1, 0 }, |
| 231 |
{ "npe-400" , C7200_NPE_FAMILY_MIPS, c7200_init_npe400, 512, 1, |
| 232 |
C7200_NVRAM_ADDR, TRUE, 2, 16, 1, 0 }, |
| 233 |
{ "npe-g1" , C7200_NPE_FAMILY_MIPS, c7200_init_npeg1, 1024, 0, |
| 234 |
C7200_G1_NVRAM_ADDR, FALSE, 17, 16, 16, 0 }, |
| 235 |
{ "npe-g2" , C7200_NPE_FAMILY_PPC , c7200_init_npeg2, 1024, 0, |
| 236 |
C7200_G2_NVRAM_ADDR, FALSE, 17, 16, 16, 0 }, |
| 237 |
{ NULL, -1, NULL, -1, -1, 0, -1, -1, -1, -1 }, |
| 238 |
}; |
| 239 |
|
| 240 |
/* ======================================================================== */ |
| 241 |
/* Cisco 7200 router instances */ |
| 242 |
/* ======================================================================== */ |
| 243 |
|
| 244 |
/* Initialize default parameters for a C7200 */ |
| 245 |
static void c7200_init_defaults(c7200_t *router); |
| 246 |
|
| 247 |
/* Directly extract the configuration from the NVRAM device */ |
| 248 |
static int c7200_nvram_extract_config(vm_instance_t *vm,u_char **startup_config,size_t *startup_len,u_char **private_config,size_t *private_len) |
| 249 |
{ |
| 250 |
int ret; |
| 251 |
|
| 252 |
ret = generic_nvram_extract_config(vm, "nvram", vm->nvram_rom_space, 0, VM_C7200(vm)->npe_driver->nvram_addr + vm->nvram_rom_space, FS_NVRAM_FORMAT_ABSOLUTE, startup_config, startup_len, private_config, private_len); |
| 253 |
|
| 254 |
return(ret); |
| 255 |
} |
| 256 |
|
| 257 |
/* Directly push the IOS configuration to the NVRAM device */ |
| 258 |
static int c7200_nvram_push_config(vm_instance_t *vm,u_char *startup_config,size_t startup_len,u_char *private_config,size_t private_len) |
| 259 |
{ |
| 260 |
int ret; |
| 261 |
|
| 262 |
ret = generic_nvram_push_config(vm, "nvram", vm->nvram_size*1024, vm->nvram_rom_space, 0, VM_C7200(vm)->npe_driver->nvram_addr + vm->nvram_rom_space, FS_NVRAM_FORMAT_ABSOLUTE, startup_config, startup_len, private_config, private_len); |
| 263 |
|
| 264 |
return(ret); |
| 265 |
} |
| 266 |
|
| 267 |
/* Get an EEPROM for a given NPE model */ |
| 268 |
static const struct cisco_eeprom *c7200_get_cpu_eeprom(char *npe_name) |
| 269 |
{ |
| 270 |
return(cisco_eeprom_find(c7200_cpu_eeprom,npe_name)); |
| 271 |
} |
| 272 |
|
| 273 |
/* Get an EEPROM for a given midplane model */ |
| 274 |
static const struct cisco_eeprom * |
| 275 |
c7200_get_midplane_eeprom(char *midplane_name) |
| 276 |
{ |
| 277 |
return(cisco_eeprom_find(c7200_midplane_eeprom,midplane_name)); |
| 278 |
} |
| 279 |
|
| 280 |
/* Get a PEM EEPROM for a given NPE model */ |
| 281 |
static const struct cisco_eeprom *c7200_get_pem_eeprom(char *npe_name) |
| 282 |
{ |
| 283 |
return(cisco_eeprom_find(c7200_pem_eeprom,npe_name)); |
| 284 |
} |
| 285 |
|
| 286 |
/* Set the base MAC address of the chassis */ |
| 287 |
static int c7200_burn_mac_addr(c7200_t *router,n_eth_addr_t *addr) |
| 288 |
{ |
| 289 |
m_uint8_t eeprom_ver; |
| 290 |
|
| 291 |
/* Read EEPROM format version */ |
| 292 |
cisco_eeprom_get_byte(&router->mp_eeprom,0,&eeprom_ver); |
| 293 |
|
| 294 |
if (eeprom_ver != 1) { |
| 295 |
vm_error(router->vm,"c7200_burn_mac_addr: unable to handle " |
| 296 |
"EEPROM version %u\n",eeprom_ver); |
| 297 |
return(-1); |
| 298 |
} |
| 299 |
|
| 300 |
cisco_eeprom_set_region(&router->mp_eeprom,12,addr->eth_addr_byte,6); |
| 301 |
return(0); |
| 302 |
} |
| 303 |
|
| 304 |
/* Free specific hardware resources used by C7200 */ |
| 305 |
static void c7200_free_hw_ressources(c7200_t *router) |
| 306 |
{ |
| 307 |
/* Shutdown all Port Adapters */ |
| 308 |
vm_slot_shutdown_all(router->vm); |
| 309 |
|
| 310 |
/* Inactivate the PCMCIA bus */ |
| 311 |
router->pcmcia_bus = NULL; |
| 312 |
|
| 313 |
/* Remove the hidden I/O bridge */ |
| 314 |
if (router->io_pci_bridge != NULL) { |
| 315 |
pci_bridge_remove(router->io_pci_bridge); |
| 316 |
router->io_pci_bridge = NULL; |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
/* Create a new router instance */ |
| 321 |
static int c7200_create_instance(vm_instance_t *vm) |
| 322 |
{ |
| 323 |
c7200_t *router; |
| 324 |
|
| 325 |
if (!(router = malloc(sizeof(*router)))) { |
| 326 |
fprintf(stderr,"C7200 '%s': Unable to create new instance!\n",vm->name); |
| 327 |
return(-1); |
| 328 |
} |
| 329 |
|
| 330 |
memset(router,0,sizeof(*router)); |
| 331 |
router->vm = vm; |
| 332 |
router->npe400_ram_size = C7200_DEFAULT_RAM_SIZE; |
| 333 |
vm->hw_data = router; |
| 334 |
vm->elf_machine_id = C7200_ELF_MACHINE_ID; |
| 335 |
|
| 336 |
c7200_init_defaults(router); |
| 337 |
return(0); |
| 338 |
} |
| 339 |
|
| 340 |
/* Free resources used by a router instance */ |
| 341 |
static int c7200_delete_instance(vm_instance_t *vm) |
| 342 |
{ |
| 343 |
c7200_t *router = VM_C7200(vm); |
| 344 |
int i; |
| 345 |
|
| 346 |
/* Stop all CPUs */ |
| 347 |
if (vm->cpu_group != NULL) { |
| 348 |
vm_stop(vm); |
| 349 |
|
| 350 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 351 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 352 |
return(FALSE); |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
/* Remove NIO bindings */ |
| 357 |
for(i=0;i<vm->nr_slots;i++) |
| 358 |
vm_slot_remove_all_nio_bindings(vm,i); |
| 359 |
|
| 360 |
/* Free specific HW resources */ |
| 361 |
c7200_free_hw_ressources(router); |
| 362 |
|
| 363 |
/* Free EEPROMs */ |
| 364 |
cisco_eeprom_free(&router->cpu_eeprom); |
| 365 |
cisco_eeprom_free(&router->mp_eeprom); |
| 366 |
cisco_eeprom_free(&router->pem_eeprom); |
| 367 |
|
| 368 |
/* Free all resources used by VM */ |
| 369 |
vm_free(vm); |
| 370 |
|
| 371 |
/* Free the router structure */ |
| 372 |
free(router); |
| 373 |
return(TRUE); |
| 374 |
} |
| 375 |
|
| 376 |
/* Save configuration of a C7200 instance */ |
| 377 |
static void c7200_save_config(vm_instance_t *vm,FILE *fd) |
| 378 |
{ |
| 379 |
c7200_t *router = VM_C7200(vm); |
| 380 |
|
| 381 |
fprintf(fd,"c7200 set_npe %s %s\n",vm->name,router->npe_driver->npe_type); |
| 382 |
fprintf(fd,"c7200 set_midplane %s %s\n\n",vm->name,router->midplane_type); |
| 383 |
} |
| 384 |
|
| 385 |
/* Returns TRUE if the specified card in slot 0 is an I/O card */ |
| 386 |
int c7200_slot0_iocard_present(c7200_t *router) |
| 387 |
{ |
| 388 |
struct cisco_eeprom *eeprom; |
| 389 |
m_uint8_t eeprom_ver,data[2]; |
| 390 |
m_uint16_t card_type; |
| 391 |
size_t offset; |
| 392 |
|
| 393 |
if (!(eeprom = router->pa_eeprom_g1.eeprom[0])) |
| 394 |
return(FALSE); |
| 395 |
|
| 396 |
/* Read EEPROM format version */ |
| 397 |
card_type = 0; |
| 398 |
cisco_eeprom_get_byte(eeprom,0,&eeprom_ver); |
| 399 |
|
| 400 |
switch(eeprom_ver) { |
| 401 |
case 1: |
| 402 |
cisco_eeprom_get_byte(eeprom,0,&data[0]); |
| 403 |
cisco_eeprom_get_byte(eeprom,1,&data[1]); |
| 404 |
card_type = ((m_uint16_t)data[0] << 8) | data[1]; |
| 405 |
break; |
| 406 |
|
| 407 |
case 4: |
| 408 |
if (!cisco_eeprom_v4_find_field(eeprom,0x40,&offset)) { |
| 409 |
cisco_eeprom_get_byte(eeprom,offset,&data[0]); |
| 410 |
cisco_eeprom_get_byte(eeprom,offset+1,&data[1]); |
| 411 |
card_type = ((m_uint16_t)data[0] << 8) | data[1]; |
| 412 |
} |
| 413 |
break; |
| 414 |
} |
| 415 |
|
| 416 |
/* jacket card is not an i/o card */ |
| 417 |
if (card_type == 0x0511) |
| 418 |
return(FALSE); |
| 419 |
|
| 420 |
/* by default, if there is something, consider it as an i/o card */ |
| 421 |
return(TRUE); |
| 422 |
} |
| 423 |
|
| 424 |
/* Set EEPROM for the specified slot */ |
| 425 |
int c7200_set_slot_eeprom(c7200_t *router,u_int slot, |
| 426 |
struct cisco_eeprom *eeprom) |
| 427 |
{ |
| 428 |
if (slot >= C7200_MAX_PA_BAYS) |
| 429 |
return(-1); |
| 430 |
|
| 431 |
switch(slot) { |
| 432 |
/* Group 1: bays 0, 1, 3, 4 */ |
| 433 |
case 0: |
| 434 |
router->pa_eeprom_g1.eeprom[0] = eeprom; |
| 435 |
break; |
| 436 |
case 1: |
| 437 |
router->pa_eeprom_g1.eeprom[1] = eeprom; |
| 438 |
break; |
| 439 |
case 3: |
| 440 |
router->pa_eeprom_g1.eeprom[2] = eeprom; |
| 441 |
break; |
| 442 |
case 4: |
| 443 |
router->pa_eeprom_g1.eeprom[3] = eeprom; |
| 444 |
break; |
| 445 |
|
| 446 |
/* Group 2: bays 2, 5, 6 */ |
| 447 |
case 2: |
| 448 |
router->pa_eeprom_g2.eeprom[0] = eeprom; |
| 449 |
break; |
| 450 |
case 5: |
| 451 |
router->pa_eeprom_g2.eeprom[1] = eeprom; |
| 452 |
break; |
| 453 |
case 6: |
| 454 |
router->pa_eeprom_g2.eeprom[2] = eeprom; |
| 455 |
break; |
| 456 |
|
| 457 |
/* Group 3: bay 7 */ |
| 458 |
case 7: |
| 459 |
router->pa_eeprom_g3.eeprom[0] = eeprom; |
| 460 |
break; |
| 461 |
} |
| 462 |
|
| 463 |
return(0); |
| 464 |
} |
| 465 |
|
| 466 |
/* Network IRQ distribution */ |
| 467 |
struct net_irq_distrib { |
| 468 |
u_int reg; |
| 469 |
u_int offset; |
| 470 |
}; |
| 471 |
|
| 472 |
static struct net_irq_distrib net_irq_dist[C7200_MAX_PA_BAYS] = { |
| 473 |
{ 0, 0 }, /* Slot 0: reg 0x10, 0x000000XX */ |
| 474 |
{ 0, 8 }, /* Slot 1: reg 0x10, 0x0000XX00 */ |
| 475 |
{ 1, 8 }, /* Slot 2: reg 0x18, 0x0000XX00 */ |
| 476 |
{ 0, 24 }, /* Slot 3: reg 0x10, 0xXX000000 */ |
| 477 |
{ 0, 16 }, /* Slot 4: reg 0x10, 0x00XX0000 */ |
| 478 |
{ 1, 24 }, /* Slot 5: reg 0x18, 0xXX000000 */ |
| 479 |
{ 1, 16 }, /* Slot 6: reg 0x18, 0x00XX0000 */ |
| 480 |
{ 2, 24 }, /* Slot 7: reg 0x294, 0xXX000000 */ |
| 481 |
}; |
| 482 |
|
| 483 |
/* Get register offset for the specified slot */ |
| 484 |
u_int dev_c7200_net_get_reg_offset(u_int slot) |
| 485 |
{ |
| 486 |
return(net_irq_dist[slot].offset); |
| 487 |
} |
| 488 |
|
| 489 |
/* Update network interrupt status */ |
| 490 |
void dev_c7200_net_update_irq(c7200_t *router) |
| 491 |
{ |
| 492 |
int i,status = 0; |
| 493 |
|
| 494 |
for(i=0;i<3;i++) |
| 495 |
status |= router->net_irq_status[i] & router->net_irq_mask[i]; |
| 496 |
|
| 497 |
if (status) { |
| 498 |
vm_set_irq(router->vm,C7200_NETIO_IRQ); |
| 499 |
} else { |
| 500 |
vm_clear_irq(router->vm,C7200_NETIO_IRQ); |
| 501 |
} |
| 502 |
} |
| 503 |
|
| 504 |
/* Trigger a Network IRQ for the specified slot/port */ |
| 505 |
void dev_c7200_net_set_irq(c7200_t *router,u_int slot,u_int port) |
| 506 |
{ |
| 507 |
struct net_irq_distrib *irq_dist; |
| 508 |
|
| 509 |
#if DEBUG_NET_IRQ |
| 510 |
vm_log(router->vm,"C7200","setting NetIRQ for slot %u port %u\n", |
| 511 |
slot,port); |
| 512 |
#endif |
| 513 |
irq_dist = &net_irq_dist[slot]; |
| 514 |
router->net_irq_status[irq_dist->reg] |= 1 << (irq_dist->offset + port); |
| 515 |
dev_c7200_net_update_irq(router); |
| 516 |
} |
| 517 |
|
| 518 |
/* Clear a Network IRQ for the specified slot/port */ |
| 519 |
void dev_c7200_net_clear_irq(c7200_t *router,u_int slot,u_int port) |
| 520 |
{ |
| 521 |
struct net_irq_distrib *irq_dist; |
| 522 |
|
| 523 |
#if DEBUG_NET_IRQ |
| 524 |
vm_log(router->vm,"C7200","clearing NetIRQ for slot %u port %u\n", |
| 525 |
slot,port); |
| 526 |
#endif |
| 527 |
irq_dist = &net_irq_dist[slot]; |
| 528 |
router->net_irq_status[irq_dist->reg] &= ~(1 << (irq_dist->offset + port)); |
| 529 |
dev_c7200_net_update_irq(router); |
| 530 |
} |
| 531 |
|
| 532 |
/* Get slot/port corresponding to specified network IRQ */ |
| 533 |
static inline void |
| 534 |
c7200_net_irq_get_slot_port(u_int irq,u_int *slot,u_int *port) |
| 535 |
{ |
| 536 |
irq -= C7200_NETIO_IRQ_BASE; |
| 537 |
*port = irq & C7200_NETIO_IRQ_PORT_MASK; |
| 538 |
*slot = irq >> C7200_NETIO_IRQ_PORT_BITS; |
| 539 |
} |
| 540 |
|
| 541 |
/* Get network IRQ for specified slot/port */ |
| 542 |
u_int c7200_net_irq_for_slot_port(u_int slot,u_int port) |
| 543 |
{ |
| 544 |
u_int irq; |
| 545 |
|
| 546 |
irq = (slot << C7200_NETIO_IRQ_PORT_BITS) + port; |
| 547 |
irq += C7200_NETIO_IRQ_BASE; |
| 548 |
|
| 549 |
return(irq); |
| 550 |
} |
| 551 |
|
| 552 |
/* Set NPE eeprom definition */ |
| 553 |
static int c7200_npe_set_eeprom(c7200_t *router) |
| 554 |
{ |
| 555 |
const struct cisco_eeprom *eeprom; |
| 556 |
|
| 557 |
if (!(eeprom = c7200_get_cpu_eeprom(router->npe_driver->npe_type))) { |
| 558 |
vm_error(router->vm,"unknown NPE \"%s\" (internal error)!\n", |
| 559 |
router->npe_driver->npe_type); |
| 560 |
return(-1); |
| 561 |
} |
| 562 |
|
| 563 |
if (cisco_eeprom_copy(&router->cpu_eeprom,eeprom) == -1) { |
| 564 |
vm_error(router->vm,"unable to set NPE EEPROM.\n"); |
| 565 |
return(-1); |
| 566 |
} |
| 567 |
|
| 568 |
return(0); |
| 569 |
} |
| 570 |
|
| 571 |
/* Set PEM eeprom definition */ |
| 572 |
static int c7200_pem_set_eeprom(c7200_t *router) |
| 573 |
{ |
| 574 |
const struct cisco_eeprom *eeprom; |
| 575 |
|
| 576 |
if (!(eeprom = c7200_get_pem_eeprom(router->npe_driver->npe_type))) { |
| 577 |
vm_error(router->vm,"no PEM EEPROM found for NPE type \"%s\"!\n", |
| 578 |
router->npe_driver->npe_type); |
| 579 |
return(-1); |
| 580 |
} |
| 581 |
|
| 582 |
if (cisco_eeprom_copy(&router->pem_eeprom,eeprom) == -1) { |
| 583 |
vm_error(router->vm,"unable to set PEM EEPROM.\n"); |
| 584 |
return(-1); |
| 585 |
} |
| 586 |
|
| 587 |
return(0); |
| 588 |
} |
| 589 |
|
| 590 |
/* Get an NPE driver */ |
| 591 |
struct c7200_npe_driver *c7200_npe_get_driver(char *npe_type) |
| 592 |
{ |
| 593 |
int i; |
| 594 |
|
| 595 |
for(i=0;npe_drivers[i].npe_type;i++) |
| 596 |
if (!strcmp(npe_drivers[i].npe_type,npe_type)) |
| 597 |
return(&npe_drivers[i]); |
| 598 |
|
| 599 |
return NULL; |
| 600 |
} |
| 601 |
|
| 602 |
/* Set the NPE type */ |
| 603 |
int c7200_npe_set_type(c7200_t *router,char *npe_type) |
| 604 |
{ |
| 605 |
struct c7200_npe_driver *driver; |
| 606 |
|
| 607 |
if (router->vm->status == VM_STATUS_RUNNING) { |
| 608 |
vm_error(router->vm,"unable to change NPE type when online.\n"); |
| 609 |
return(-1); |
| 610 |
} |
| 611 |
|
| 612 |
if (!(driver = c7200_npe_get_driver(npe_type))) { |
| 613 |
vm_error(router->vm,"unknown NPE type '%s'.\n",npe_type); |
| 614 |
return(-1); |
| 615 |
} |
| 616 |
|
| 617 |
router->npe_driver = driver; |
| 618 |
|
| 619 |
if (c7200_npe_set_eeprom(router) == -1) { |
| 620 |
vm_error(router->vm,"unable to find NPE '%s' EEPROM!\n", |
| 621 |
router->npe_driver->npe_type); |
| 622 |
return(-1); |
| 623 |
} |
| 624 |
|
| 625 |
#if 0 /* FIXME - for a later release */ |
| 626 |
/* Use a C7200-IO-FE by default in slot 0 if an I/O card is required */ |
| 627 |
if (driver->iocard_required) { |
| 628 |
vm_slot_add_binding(router->vm,"C7200-IO-FE",0,0); |
| 629 |
vm_slot_set_flag(router->vm,0,0,CISCO_CARD_FLAG_OVERRIDE); |
| 630 |
} |
| 631 |
#endif |
| 632 |
c7200_refresh_systemid(router); |
| 633 |
return(0); |
| 634 |
} |
| 635 |
|
| 636 |
/* Show the list of available NPE drivers */ |
| 637 |
static void c7200_npe_show_drivers(void) |
| 638 |
{ |
| 639 |
int i; |
| 640 |
|
| 641 |
printf("Available C7200 NPE drivers:\n"); |
| 642 |
|
| 643 |
for(i=0;npe_drivers[i].npe_type;i++) { |
| 644 |
printf(" * %s %s\n", |
| 645 |
npe_drivers[i].npe_type, |
| 646 |
!npe_drivers[i].supported ? "(NOT WORKING)" : ""); |
| 647 |
} |
| 648 |
|
| 649 |
printf("\n"); |
| 650 |
} |
| 651 |
|
| 652 |
/* Set Midplane type */ |
| 653 |
int c7200_midplane_set_type(c7200_t *router,char *midplane_type) |
| 654 |
{ |
| 655 |
const struct cisco_eeprom *eeprom; |
| 656 |
m_uint8_t version; |
| 657 |
|
| 658 |
if (router->vm->status == VM_STATUS_RUNNING) { |
| 659 |
vm_error(router->vm,"unable to change Midplane type when online.\n"); |
| 660 |
return(-1); |
| 661 |
} |
| 662 |
|
| 663 |
/* Set EEPROM */ |
| 664 |
if (!(eeprom = c7200_get_midplane_eeprom(midplane_type))) { |
| 665 |
vm_error(router->vm,"unknown Midplane \"%s\"!\n",midplane_type); |
| 666 |
return(-1); |
| 667 |
} |
| 668 |
|
| 669 |
/* Copy the midplane EEPROM */ |
| 670 |
if (cisco_eeprom_copy(&router->mp_eeprom,eeprom) == -1) { |
| 671 |
vm_error(router->vm,"unable to set midplane EEPROM.\n"); |
| 672 |
return(-1); |
| 673 |
} |
| 674 |
|
| 675 |
/* Set the chassis base MAC address */ |
| 676 |
c7200_burn_mac_addr(router,&router->mac_addr); |
| 677 |
|
| 678 |
/* Get the midplane version */ |
| 679 |
cisco_eeprom_get_byte(&router->mp_eeprom,2,&version); |
| 680 |
router->midplane_version = version; |
| 681 |
router->midplane_type = eeprom->name; |
| 682 |
c7200_refresh_systemid(router); |
| 683 |
return(0); |
| 684 |
} |
| 685 |
|
| 686 |
/* Set the system id or processor board id in the eeprom */ |
| 687 |
int c7200_set_system_id(c7200_t *router,char *id) |
| 688 |
{ |
| 689 |
// 11 characters is enough. Array is 20 long |
| 690 |
strncpy(router->board_id,id,13); |
| 691 |
// Make sure it is null terminated |
| 692 |
router->board_id[13] = 0x00; |
| 693 |
c7200_refresh_systemid(router); |
| 694 |
return 0; |
| 695 |
} |
| 696 |
int c7200_refresh_systemid(c7200_t *router) |
| 697 |
{ |
| 698 |
//fprintf(stderr,"Starting mp dump\n"); |
| 699 |
//cisco_eeprom_dump(&router->mp_eeprom); |
| 700 |
//fprintf(stderr,"Starting cpu dump\n"); |
| 701 |
//cisco_eeprom_dump(&router->cpu_eeprom); |
| 702 |
|
| 703 |
if (router->board_id[0] == 0x00) return(0); |
| 704 |
|
| 705 |
m_uint8_t buf[11]; |
| 706 |
if ( (!strcmp("npe-100",router->npe_driver->npe_type)) |
| 707 |
||(!strcmp("npe-140",router->npe_driver->npe_type)) |
| 708 |
||(!strcmp("npe-175",router->npe_driver->npe_type)) |
| 709 |
||(!strcmp("npe-200",router->npe_driver->npe_type)) |
| 710 |
||(!strcmp("npe-225",router->npe_driver->npe_type)) |
| 711 |
||(!strcmp("npe-300",router->npe_driver->npe_type))) |
| 712 |
{ |
| 713 |
//parse_board_id(buf,"4279256517",4); |
| 714 |
parse_board_id(buf,router->board_id,4); |
| 715 |
cisco_eeprom_set_region(&router->mp_eeprom ,4,buf,4); |
| 716 |
cisco_eeprom_set_region(&router->cpu_eeprom,4,buf,4); |
| 717 |
//fprintf(stderr,"Starting post mp dump\n"); |
| 718 |
//cisco_eeprom_dump(&router->mp_eeprom); |
| 719 |
//fprintf(stderr,"Starting post cpu dump\n"); |
| 720 |
//cisco_eeprom_dump(&router->cpu_eeprom); |
| 721 |
return (0); |
| 722 |
} |
| 723 |
return (-1); |
| 724 |
} |
| 725 |
|
| 726 |
/* Set chassis MAC address */ |
| 727 |
int c7200_midplane_set_mac_addr(c7200_t *router,char *mac_addr) |
| 728 |
{ |
| 729 |
if (parse_mac_addr(&router->mac_addr,mac_addr) == -1) { |
| 730 |
vm_error(router->vm,"unable to parse MAC address '%s'.\n",mac_addr); |
| 731 |
return(-1); |
| 732 |
} |
| 733 |
|
| 734 |
/* Set the chassis base MAC address */ |
| 735 |
c7200_burn_mac_addr(router,&router->mac_addr); |
| 736 |
return(0); |
| 737 |
} |
| 738 |
|
| 739 |
/* Create the main PCI bus for a GT64010 based system */ |
| 740 |
static int c7200_init_gt64010(c7200_t *router) |
| 741 |
{ |
| 742 |
vm_instance_t *vm = router->vm; |
| 743 |
|
| 744 |
if (!(vm->pci_bus[0] = pci_bus_create("MB0/MB1/MB2",0))) { |
| 745 |
vm_error(vm,"unable to create PCI data.\n"); |
| 746 |
return(-1); |
| 747 |
} |
| 748 |
|
| 749 |
return(dev_gt64010_init(vm,"gt64010",C7200_GT64K_ADDR,0x1000, |
| 750 |
C7200_GT64K_IRQ)); |
| 751 |
} |
| 752 |
|
| 753 |
/* Create the two main PCI busses for a GT64120 based system */ |
| 754 |
static int c7200_init_gt64120(c7200_t *router) |
| 755 |
{ |
| 756 |
vm_instance_t *vm = router->vm; |
| 757 |
|
| 758 |
vm->pci_bus[0] = pci_bus_create("MB0/MB1",0); |
| 759 |
vm->pci_bus[1] = pci_bus_create("MB2",0); |
| 760 |
|
| 761 |
if (!vm->pci_bus[0] || !vm->pci_bus[1]) { |
| 762 |
vm_error(vm,"unable to create PCI data.\n"); |
| 763 |
return(-1); |
| 764 |
} |
| 765 |
|
| 766 |
return(dev_gt64120_init(vm,"gt64120",C7200_GT64K_ADDR,0x1000, |
| 767 |
C7200_GT64K_IRQ)); |
| 768 |
} |
| 769 |
|
| 770 |
/* Create the two main PCI busses for a dual GT64120 system */ |
| 771 |
static int c7200_init_dual_gt64120(c7200_t *router) |
| 772 |
{ |
| 773 |
vm_instance_t *vm = router->vm; |
| 774 |
|
| 775 |
vm->pci_bus[0] = pci_bus_create("MB0/MB1",0); |
| 776 |
vm->pci_bus[1] = pci_bus_create("MB2",0); |
| 777 |
|
| 778 |
if (!vm->pci_bus[0] || !vm->pci_bus[1]) { |
| 779 |
vm_error(vm,"unable to create PCI data.\n",vm->name); |
| 780 |
return(-1); |
| 781 |
} |
| 782 |
|
| 783 |
/* Initialize the first GT64120 at 0x14000000 */ |
| 784 |
if (dev_gt64120_init(vm,"gt64120(1)",C7200_GT64K_ADDR,0x1000, |
| 785 |
C7200_GT64K_IRQ) == -1) |
| 786 |
return(-1); |
| 787 |
|
| 788 |
/* Initialize the second GT64120 at 0x15000000 */ |
| 789 |
if (dev_gt64120_init(vm,"gt64120(2)",C7200_GT64K_SEC_ADDR,0x1000, |
| 790 |
C7200_GT64K_IRQ) == -1) |
| 791 |
return(-1); |
| 792 |
|
| 793 |
return(0); |
| 794 |
} |
| 795 |
|
| 796 |
/* Create the two main PCI busses for a MV64460 based system */ |
| 797 |
static int c7200_init_mv64460(c7200_t *router) |
| 798 |
{ |
| 799 |
vm_instance_t *vm = router->vm; |
| 800 |
|
| 801 |
vm->pci_bus[0] = pci_bus_create("MB0/MB1",3); |
| 802 |
vm->pci_bus[1] = pci_bus_create("MB2",0); |
| 803 |
|
| 804 |
if (!vm->pci_bus[0] || !vm->pci_bus[1]) { |
| 805 |
vm_error(vm,"unable to create PCI data.\n"); |
| 806 |
return(-1); |
| 807 |
} |
| 808 |
|
| 809 |
return(dev_mv64460_init(vm,"mv64460",C7200_G2_MV64460_ADDR,0x10000)); |
| 810 |
} |
| 811 |
|
| 812 |
/* Create the PA PCI busses */ |
| 813 |
static int c7200_pa_create_pci_busses(c7200_t *router) |
| 814 |
{ |
| 815 |
vm_instance_t *vm = router->vm; |
| 816 |
char bus_name[128]; |
| 817 |
int i; |
| 818 |
|
| 819 |
for(i=1;i<C7200_MAX_PA_BAYS;i++) { |
| 820 |
snprintf(bus_name,sizeof(bus_name),"PA Slot %d",i); |
| 821 |
vm->pci_bus_pool[i] = pci_bus_create(bus_name,-1); |
| 822 |
|
| 823 |
if (!vm->pci_bus_pool[i]) |
| 824 |
return(-1); |
| 825 |
} |
| 826 |
|
| 827 |
return(0); |
| 828 |
} |
| 829 |
|
| 830 |
/* Create a PA bridge, depending on the midplane */ |
| 831 |
static int c7200_pa_init_pci_bridge(c7200_t *router,u_int pa_bay, |
| 832 |
struct pci_bus *pci_bus,int pci_device) |
| 833 |
{ |
| 834 |
struct pci_bus *pa_bus; |
| 835 |
|
| 836 |
pa_bus = router->vm->slots_pci_bus[pa_bay]; |
| 837 |
|
| 838 |
switch(router->midplane_version) { |
| 839 |
case 0: |
| 840 |
case 1: |
| 841 |
dev_dec21050_init(pci_bus,pci_device,pa_bus); |
| 842 |
break; |
| 843 |
default: |
| 844 |
dev_dec21150_init(pci_bus,pci_device,pa_bus); |
| 845 |
} |
| 846 |
return(0); |
| 847 |
} |
| 848 |
|
| 849 |
/* |
| 850 |
* Hidden "I/O" PCI bridge hack for PCMCIA controller. |
| 851 |
* |
| 852 |
* On NPE-175, NPE-225, NPE-300 and NPE-400, PCMCIA controller is |
| 853 |
* identified on PCI as Bus=2,Device=16. On NPE-G1, this is Bus=17,Device=16. |
| 854 |
* |
| 855 |
* However, I don't understand how the bridging between PCI bus 1 and 2 |
| 856 |
* is done (16 and 17 on NPE-G1). |
| 857 |
* |
| 858 |
* Maybe I'm missing something about PCI-to-PCI bridge mechanism, or there |
| 859 |
* is a special hidden device that does the job silently (it should be |
| 860 |
* visible on the PCI bus...) |
| 861 |
* |
| 862 |
* BTW, it works. |
| 863 |
*/ |
| 864 |
static int |
| 865 |
c7200_create_io_pci_bridge(c7200_t *router,struct pci_bus *parent_bus) |
| 866 |
{ |
| 867 |
vm_instance_t *vm = router->vm; |
| 868 |
|
| 869 |
/* Create the PCI bus where the PCMCIA controller will seat */ |
| 870 |
if (!(vm->pci_bus_pool[16] = pci_bus_create("I/O secondary bus",-1))) |
| 871 |
return(-1); |
| 872 |
|
| 873 |
/* Create the hidden bridge with "special" handling... */ |
| 874 |
if (!(router->io_pci_bridge = pci_bridge_add(parent_bus))) |
| 875 |
return(-1); |
| 876 |
|
| 877 |
router->io_pci_bridge->skip_bus_check = TRUE; |
| 878 |
pci_bridge_map_bus(router->io_pci_bridge,vm->pci_bus_pool[16]); |
| 879 |
|
| 880 |
router->pcmcia_bus = vm->pci_bus_pool[16]; |
| 881 |
return(0); |
| 882 |
} |
| 883 |
|
| 884 |
/* Initialize an NPE-100 board */ |
| 885 |
int c7200_init_npe100(c7200_t *router) |
| 886 |
{ |
| 887 |
vm_instance_t *vm = router->vm; |
| 888 |
int i; |
| 889 |
|
| 890 |
/* Set the processor type: R4600 */ |
| 891 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R4600); |
| 892 |
|
| 893 |
/* Initialize the Galileo GT-64010 system controller */ |
| 894 |
if (c7200_init_gt64010(router) == -1) |
| 895 |
return(-1); |
| 896 |
|
| 897 |
/* PCMCIA controller is on bus 0 */ |
| 898 |
router->pcmcia_bus = vm->pci_bus[0]; |
| 899 |
|
| 900 |
/* Initialize the PA PCI busses */ |
| 901 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 902 |
return(-1); |
| 903 |
|
| 904 |
/* Create PCI busses for PA Bays 1,3,5 and PA Bays 2,4,6 */ |
| 905 |
vm->pci_bus_pool[24] = pci_bus_create("PA Slots 1,3,5",-1); |
| 906 |
vm->pci_bus_pool[25] = pci_bus_create("PA Slots 2,4,6",-1); |
| 907 |
|
| 908 |
/* PCI bridges (MB0/MB1, MB0/MB2) */ |
| 909 |
dev_dec21050_init(vm->pci_bus[0],1,NULL); |
| 910 |
dev_dec21050_init(vm->pci_bus[0],2,vm->pci_bus_pool[24]); |
| 911 |
dev_dec21050_init(vm->pci_bus[0],3,NULL); |
| 912 |
dev_dec21050_init(vm->pci_bus[0],4,vm->pci_bus_pool[25]); |
| 913 |
|
| 914 |
/* Map the PA PCI busses */ |
| 915 |
vm->slots_pci_bus[0] = vm->pci_bus[0]; |
| 916 |
|
| 917 |
for(i=1;i<C7200_MAX_PA_BAYS;i++) |
| 918 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 919 |
|
| 920 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 921 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus_pool[24],1); |
| 922 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus_pool[24],2); |
| 923 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus_pool[24],3); |
| 924 |
|
| 925 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus_pool[25],1); |
| 926 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus_pool[25],2); |
| 927 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus_pool[25],3); |
| 928 |
return(0); |
| 929 |
} |
| 930 |
|
| 931 |
/* Initialize an NPE-150 board */ |
| 932 |
int c7200_init_npe150(c7200_t *router) |
| 933 |
{ |
| 934 |
vm_instance_t *vm = router->vm; |
| 935 |
m_uint32_t bank_size; |
| 936 |
int i; |
| 937 |
|
| 938 |
/* Set the processor type: R4700 */ |
| 939 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R4700); |
| 940 |
|
| 941 |
/* Initialize the Galileo GT-64010 system controller */ |
| 942 |
if (c7200_init_gt64010(router) == -1) |
| 943 |
return(-1); |
| 944 |
|
| 945 |
/* PCMCIA controller is on bus 0 */ |
| 946 |
router->pcmcia_bus = vm->pci_bus[0]; |
| 947 |
|
| 948 |
/* Initialize the PA PCI busses */ |
| 949 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 950 |
return(-1); |
| 951 |
|
| 952 |
/* Create PCI busses for PA Bays 1,3,5 and PA Bays 2,4,6 */ |
| 953 |
vm->pci_bus_pool[24] = pci_bus_create("PA Slots 1,3,5",-1); |
| 954 |
vm->pci_bus_pool[25] = pci_bus_create("PA Slots 2,4,6",-1); |
| 955 |
|
| 956 |
/* PCI bridges (MB0/MB1, MB0/MB2) */ |
| 957 |
dev_dec21050_init(vm->pci_bus[0],1,NULL); |
| 958 |
dev_dec21050_init(vm->pci_bus[0],2,vm->pci_bus_pool[24]); |
| 959 |
dev_dec21050_init(vm->pci_bus[0],3,NULL); |
| 960 |
dev_dec21050_init(vm->pci_bus[0],4,vm->pci_bus_pool[25]); |
| 961 |
|
| 962 |
/* Map the PA PCI busses */ |
| 963 |
vm->slots_pci_bus[0] = vm->pci_bus[0]; |
| 964 |
|
| 965 |
for(i=1;i<C7200_MAX_PA_BAYS;i++) |
| 966 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 967 |
|
| 968 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 969 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus_pool[24],1); |
| 970 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus_pool[24],2); |
| 971 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus_pool[24],3); |
| 972 |
|
| 973 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus_pool[25],1); |
| 974 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus_pool[25],2); |
| 975 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus_pool[25],3); |
| 976 |
|
| 977 |
/* Packet SRAM: 1 Mb */ |
| 978 |
bank_size = 0x80000; |
| 979 |
|
| 980 |
dev_c7200_sram_init(vm,"sram0",C7200_SRAM_ADDR,bank_size, |
| 981 |
vm->pci_bus_pool[24],0); |
| 982 |
|
| 983 |
dev_c7200_sram_init(vm,"sram1",C7200_SRAM_ADDR+bank_size,bank_size, |
| 984 |
vm->pci_bus_pool[25],0); |
| 985 |
return(0); |
| 986 |
} |
| 987 |
|
| 988 |
/* Initialize an NPE-175 board */ |
| 989 |
int c7200_init_npe175(c7200_t *router) |
| 990 |
{ |
| 991 |
vm_instance_t *vm = router->vm; |
| 992 |
int i; |
| 993 |
|
| 994 |
/* Set the processor type: R5271 */ |
| 995 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R527x); |
| 996 |
|
| 997 |
/* Initialize the Galileo GT-64120 PCI controller */ |
| 998 |
if (c7200_init_gt64120(router) == -1) |
| 999 |
return(-1); |
| 1000 |
|
| 1001 |
/* Initialize the PA PCI busses */ |
| 1002 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 1003 |
return(-1); |
| 1004 |
|
| 1005 |
/* Create PCI bus for PA Bay 0 (I/O Card, PCMCIA, Interfaces) */ |
| 1006 |
vm->pci_bus_pool[0] = pci_bus_create("PA Slot 0",-1); |
| 1007 |
|
| 1008 |
/* PCI bridge for I/O card device on MB0 */ |
| 1009 |
dev_dec21150_init(vm->pci_bus[0],1,vm->pci_bus_pool[0]); |
| 1010 |
|
| 1011 |
/* Create the hidden "I/O" PCI bridge for PCMCIA controller */ |
| 1012 |
c7200_create_io_pci_bridge(router,vm->pci_bus_pool[0]); |
| 1013 |
|
| 1014 |
/* Map the PA PCI busses */ |
| 1015 |
for(i=0;i<C7200_MAX_PA_BAYS;i++) |
| 1016 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 1017 |
|
| 1018 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 1019 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus[0],7); |
| 1020 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus[0],8); |
| 1021 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus[0],9); |
| 1022 |
|
| 1023 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus[1],7); |
| 1024 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus[1],8); |
| 1025 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus[1],9); |
| 1026 |
|
| 1027 |
/* Enable PEM EEPROM */ |
| 1028 |
c7200_pem_set_eeprom(router); |
| 1029 |
return(0); |
| 1030 |
} |
| 1031 |
|
| 1032 |
/* Initialize an NPE-200 board */ |
| 1033 |
int c7200_init_npe200(c7200_t *router) |
| 1034 |
{ |
| 1035 |
vm_instance_t *vm = router->vm; |
| 1036 |
m_uint32_t bank_size; |
| 1037 |
int i; |
| 1038 |
|
| 1039 |
/* Set the processor type: R5000 */ |
| 1040 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R5000); |
| 1041 |
|
| 1042 |
/* Initialize the Galileo GT-64010 PCI controller */ |
| 1043 |
if (c7200_init_gt64010(router) == -1) |
| 1044 |
return(-1); |
| 1045 |
|
| 1046 |
/* PCMCIA controller is on bus 0 */ |
| 1047 |
router->pcmcia_bus = vm->pci_bus[0]; |
| 1048 |
|
| 1049 |
/* Initialize the PA PCI busses */ |
| 1050 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 1051 |
return(-1); |
| 1052 |
|
| 1053 |
/* Create PCI busses for PA Bays 1,3,5 and PA Bays 2,4,6 */ |
| 1054 |
vm->pci_bus_pool[24] = pci_bus_create("PA Slots 1,3,5",-1); |
| 1055 |
vm->pci_bus_pool[25] = pci_bus_create("PA Slots 2,4,6",-1); |
| 1056 |
|
| 1057 |
/* PCI bridges (MB0/MB1, MB0/MB2) */ |
| 1058 |
dev_dec21050_init(vm->pci_bus[0],1,NULL); |
| 1059 |
dev_dec21050_init(vm->pci_bus[0],2,vm->pci_bus_pool[24]); |
| 1060 |
dev_dec21050_init(vm->pci_bus[0],3,NULL); |
| 1061 |
dev_dec21050_init(vm->pci_bus[0],4,vm->pci_bus_pool[25]); |
| 1062 |
|
| 1063 |
/* Map the PA PCI busses */ |
| 1064 |
vm->slots_pci_bus[0] = vm->pci_bus[0]; |
| 1065 |
|
| 1066 |
for(i=1;i<C7200_MAX_PA_BAYS;i++) |
| 1067 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 1068 |
|
| 1069 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 1070 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus_pool[24],1); |
| 1071 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus_pool[24],2); |
| 1072 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus_pool[24],3); |
| 1073 |
|
| 1074 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus_pool[25],1); |
| 1075 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus_pool[25],2); |
| 1076 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus_pool[25],3); |
| 1077 |
|
| 1078 |
/* Packet SRAM: 4 Mb */ |
| 1079 |
bank_size = 0x200000; |
| 1080 |
|
| 1081 |
dev_c7200_sram_init(vm,"sram0",C7200_SRAM_ADDR,bank_size, |
| 1082 |
vm->pci_bus_pool[24],0); |
| 1083 |
|
| 1084 |
dev_c7200_sram_init(vm,"sram1",C7200_SRAM_ADDR+bank_size,bank_size, |
| 1085 |
vm->pci_bus_pool[25],0); |
| 1086 |
return(0); |
| 1087 |
} |
| 1088 |
|
| 1089 |
/* Initialize an NPE-225 board */ |
| 1090 |
int c7200_init_npe225(c7200_t *router) |
| 1091 |
{ |
| 1092 |
vm_instance_t *vm = router->vm; |
| 1093 |
int i; |
| 1094 |
|
| 1095 |
/* Set the processor type: R5271 */ |
| 1096 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R527x); |
| 1097 |
|
| 1098 |
/* Initialize the Galileo GT-64120 PCI controller */ |
| 1099 |
if (c7200_init_gt64120(router) == -1) |
| 1100 |
return(-1); |
| 1101 |
|
| 1102 |
/* Initialize the PA PCI busses */ |
| 1103 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 1104 |
return(-1); |
| 1105 |
|
| 1106 |
/* Create PCI bus for PA Bay 0 (I/O Card, PCMCIA, Interfaces) */ |
| 1107 |
vm->pci_bus_pool[0] = pci_bus_create("PA Slot 0",-1); |
| 1108 |
|
| 1109 |
/* PCI bridge for I/O card device on MB0 */ |
| 1110 |
dev_dec21150_init(vm->pci_bus[0],1,vm->pci_bus_pool[0]); |
| 1111 |
|
| 1112 |
/* Create the hidden "I/O" PCI bridge for PCMCIA controller */ |
| 1113 |
c7200_create_io_pci_bridge(router,vm->pci_bus_pool[0]); |
| 1114 |
|
| 1115 |
/* Map the PA PCI busses */ |
| 1116 |
for(i=0;i<C7200_MAX_PA_BAYS;i++) |
| 1117 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 1118 |
|
| 1119 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 1120 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus[0],7); |
| 1121 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus[0],8); |
| 1122 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus[0],9); |
| 1123 |
|
| 1124 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus[1],7); |
| 1125 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus[1],8); |
| 1126 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus[1],9); |
| 1127 |
|
| 1128 |
/* Enable PEM EEPROM */ |
| 1129 |
c7200_pem_set_eeprom(router); |
| 1130 |
return(0); |
| 1131 |
} |
| 1132 |
|
| 1133 |
/* Initialize an NPE-300 board */ |
| 1134 |
int c7200_init_npe300(c7200_t *router) |
| 1135 |
{ |
| 1136 |
vm_instance_t *vm = router->vm; |
| 1137 |
int i; |
| 1138 |
|
| 1139 |
/* Set the processor type: R7000 */ |
| 1140 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R7000); |
| 1141 |
|
| 1142 |
/* 32 Mb of I/O memory */ |
| 1143 |
vm->iomem_size = 32; |
| 1144 |
dev_ram_init(vm,"iomem",vm->ram_mmap,TRUE,NULL,vm->sparse_mem, |
| 1145 |
C7200_IOMEM_ADDR,32*1048576); |
| 1146 |
|
| 1147 |
/* Initialize the two Galileo GT-64120 system controllers */ |
| 1148 |
if (c7200_init_dual_gt64120(router) == -1) |
| 1149 |
return(-1); |
| 1150 |
|
| 1151 |
/* Initialize the PA PCI busses */ |
| 1152 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 1153 |
return(-1); |
| 1154 |
|
| 1155 |
/* Create PCI bus for PA Bay 0 (I/O Card, PCMCIA, Interfaces) */ |
| 1156 |
vm->pci_bus_pool[0] = pci_bus_create("PA Slot 0",-1); |
| 1157 |
|
| 1158 |
/* Create PCI busses for PA Bays 1,3,5 and PA Bays 2,4,6 */ |
| 1159 |
vm->pci_bus_pool[24] = pci_bus_create("PA Slots 1,3,5",-1); |
| 1160 |
vm->pci_bus_pool[25] = pci_bus_create("PA Slots 2,4,6",-1); |
| 1161 |
|
| 1162 |
/* PCI bridge for I/O card device on MB0 */ |
| 1163 |
dev_dec21150_init(vm->pci_bus[0],1,vm->pci_bus_pool[0]); |
| 1164 |
|
| 1165 |
/* Create the hidden "I/O" PCI bridge for PCMCIA controller */ |
| 1166 |
c7200_create_io_pci_bridge(router,vm->pci_bus_pool[0]); |
| 1167 |
|
| 1168 |
/* PCI bridges for PA PCI "Head" Busses */ |
| 1169 |
dev_dec21150_init(vm->pci_bus[0],2,vm->pci_bus_pool[24]); |
| 1170 |
dev_dec21150_init(vm->pci_bus[1],1,vm->pci_bus_pool[25]); |
| 1171 |
|
| 1172 |
/* Map the PA PCI busses */ |
| 1173 |
for(i=0;i<C7200_MAX_PA_BAYS;i++) |
| 1174 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 1175 |
|
| 1176 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 1177 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus_pool[24],1); |
| 1178 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus_pool[24],2); |
| 1179 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus_pool[24],3); |
| 1180 |
|
| 1181 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus_pool[25],1); |
| 1182 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus_pool[25],2); |
| 1183 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus_pool[25],3); |
| 1184 |
return(0); |
| 1185 |
} |
| 1186 |
|
| 1187 |
/* Initialize an NPE-400 board */ |
| 1188 |
int c7200_init_npe400(c7200_t *router) |
| 1189 |
{ |
| 1190 |
vm_instance_t *vm = router->vm; |
| 1191 |
int i; |
| 1192 |
|
| 1193 |
/* Set the processor type: R7000 */ |
| 1194 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R7000); |
| 1195 |
|
| 1196 |
/* |
| 1197 |
* Add supplemental memory (as "iomem") if we have more than 256 Mb. |
| 1198 |
*/ |
| 1199 |
if (VM_C7200(vm)->npe400_ram_size > C7200_BASE_RAM_LIMIT) { |
| 1200 |
vm->iomem_size = VM_C7200(vm)->npe400_ram_size - C7200_BASE_RAM_LIMIT; |
| 1201 |
vm->ram_size = C7200_BASE_RAM_LIMIT; |
| 1202 |
dev_ram_init(vm,"iomem",vm->ram_mmap,TRUE,NULL,vm->sparse_mem, |
| 1203 |
C7200_IOMEM_ADDR,vm->iomem_size*1048576); |
| 1204 |
} |
| 1205 |
else { |
| 1206 |
vm->iomem_size = 0; |
| 1207 |
} |
| 1208 |
|
| 1209 |
/* Initialize the Galileo GT-64120 system controller */ |
| 1210 |
if (c7200_init_gt64120(router) == -1) |
| 1211 |
return(-1); |
| 1212 |
|
| 1213 |
/* Initialize the PA PCI busses */ |
| 1214 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 1215 |
return(-1); |
| 1216 |
|
| 1217 |
/* Create PCI bus for PA Bay 0 (I/O Card, PCMCIA, Interfaces) */ |
| 1218 |
vm->pci_bus_pool[0] = pci_bus_create("PA Slot 0",-1); |
| 1219 |
|
| 1220 |
/* PCI bridge for I/O card device on MB0 */ |
| 1221 |
dev_dec21050_init(vm->pci_bus[0],1,vm->pci_bus_pool[0]); |
| 1222 |
|
| 1223 |
/* Create the hidden "I/O" PCI bridge for PCMCIA controller */ |
| 1224 |
c7200_create_io_pci_bridge(router,vm->pci_bus_pool[0]); |
| 1225 |
|
| 1226 |
/* Map the PA PCI busses */ |
| 1227 |
for(i=0;i<C7200_MAX_PA_BAYS;i++) |
| 1228 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 1229 |
|
| 1230 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 1231 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus[0],7); |
| 1232 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus[0],8); |
| 1233 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus[0],9); |
| 1234 |
|
| 1235 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus[1],7); |
| 1236 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus[1],8); |
| 1237 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus[1],9); |
| 1238 |
return(0); |
| 1239 |
} |
| 1240 |
|
| 1241 |
/* Initialize an NPE-G1 board (XXX not working) */ |
| 1242 |
int c7200_init_npeg1(c7200_t *router) |
| 1243 |
{ |
| 1244 |
vm_instance_t *vm = router->vm; |
| 1245 |
int i; |
| 1246 |
|
| 1247 |
/* Just some tests */ |
| 1248 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_BCM1250); |
| 1249 |
vm->pci_bus[0] = pci_bus_create("HT/PCI bus",0); |
| 1250 |
|
| 1251 |
/* SB-1 System control devices */ |
| 1252 |
dev_sb1_init(vm); |
| 1253 |
|
| 1254 |
/* SB-1 I/O devices */ |
| 1255 |
dev_sb1_io_init(vm,C7200_DUART_IRQ); |
| 1256 |
|
| 1257 |
/* SB-1 PCI bus configuration zone */ |
| 1258 |
dev_sb1_pci_init(vm,"pci_cfg",0xFE000000ULL); |
| 1259 |
|
| 1260 |
/* Initialize the PA PCI busses */ |
| 1261 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 1262 |
return(-1); |
| 1263 |
|
| 1264 |
/* Create PCI bus for PA Bay 0 (I/O Card, PCMCIA, Interfaces) */ |
| 1265 |
vm->pci_bus_pool[0] = pci_bus_create("PA Slot 0",-1); |
| 1266 |
|
| 1267 |
/* Create PCI busses for PA Bays 1,3,5 and PA Bays 2,4,6 */ |
| 1268 |
vm->pci_bus_pool[24] = pci_bus_create("PA Slots 1,3,5",-1); |
| 1269 |
vm->pci_bus_pool[25] = pci_bus_create("PA Slots 2,4,6",-1); |
| 1270 |
|
| 1271 |
/* HyperTransport/PCI bridges */ |
| 1272 |
dev_ap1011_init(vm->pci_bus_pool[28],0,NULL); |
| 1273 |
dev_ap1011_init(vm->pci_bus_pool[28],1,vm->pci_bus_pool[24]); |
| 1274 |
dev_ap1011_init(vm->pci_bus_pool[28],2,vm->pci_bus_pool[25]); |
| 1275 |
|
| 1276 |
/* PCI bridge for I/O card device on MB0 */ |
| 1277 |
dev_dec21150_init(vm->pci_bus[0],3,vm->pci_bus_pool[0]); |
| 1278 |
|
| 1279 |
/* Create the hidden "I/O" PCI bridge for PCMCIA controller */ |
| 1280 |
c7200_create_io_pci_bridge(router,vm->pci_bus_pool[0]); |
| 1281 |
|
| 1282 |
/* Map the PA PCI busses */ |
| 1283 |
vm->slots_pci_bus[0] = vm->pci_bus[0]; |
| 1284 |
|
| 1285 |
for(i=1;i<C7200_MAX_PA_BAYS;i++) |
| 1286 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 1287 |
|
| 1288 |
/* PCI bridges for PA Bays 1 to 6 */ |
| 1289 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus_pool[24],1); |
| 1290 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus_pool[24],2); |
| 1291 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus_pool[24],3); |
| 1292 |
|
| 1293 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus_pool[25],1); |
| 1294 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus_pool[25],2); |
| 1295 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus_pool[25],3); |
| 1296 |
return(0); |
| 1297 |
} |
| 1298 |
|
| 1299 |
/* Initialize an NPE-G2 board (XXX not working) */ |
| 1300 |
int c7200_init_npeg2(c7200_t *router) |
| 1301 |
{ |
| 1302 |
vm_instance_t *vm = router->vm; |
| 1303 |
int i; |
| 1304 |
|
| 1305 |
/* Set the processor type: PowerPC G4 */ |
| 1306 |
ppc32_set_pvr(CPU_PPC32(vm->boot_cpu),0x80040201); |
| 1307 |
|
| 1308 |
/* Initialize the PA PCI busses */ |
| 1309 |
if (c7200_pa_create_pci_busses(router) == -1) |
| 1310 |
return(-1); |
| 1311 |
|
| 1312 |
/* Create PCI bus for PA Bay 0 (I/O Card, PCMCIA, Interfaces) */ |
| 1313 |
vm->pci_bus_pool[0] = pci_bus_create("PA Slot 0",-1); |
| 1314 |
|
| 1315 |
/* PCI bridge for I/O card device on MB0 */ |
| 1316 |
dev_plx6520cb_init(vm->pci_bus[1],3,vm->pci_bus_pool[0]); |
| 1317 |
|
| 1318 |
/* Create PCI busses for PA Bays 1,3,5 and PA Bays 2,4,6 */ |
| 1319 |
vm->pci_bus_pool[24] = pci_bus_create("PA Slots 1,3,5",-1); |
| 1320 |
vm->pci_bus_pool[25] = pci_bus_create("PA Slots 2,4,6",-1); |
| 1321 |
|
| 1322 |
dev_plx6520cb_init(vm->pci_bus[0],1,vm->pci_bus_pool[24]); |
| 1323 |
dev_plx6520cb_init(vm->pci_bus[0],2,vm->pci_bus_pool[25]); |
| 1324 |
|
| 1325 |
/* Create the hidden "I/O" PCI bridge for PCMCIA controller */ |
| 1326 |
c7200_create_io_pci_bridge(router,vm->pci_bus_pool[0]); |
| 1327 |
|
| 1328 |
/* Map the PA PCI busses */ |
| 1329 |
vm->slots_pci_bus[0] = vm->pci_bus_pool[0]; |
| 1330 |
|
| 1331 |
for(i=1;i<C7200_MAX_PA_BAYS;i++) |
| 1332 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 1333 |
|
| 1334 |
/* PCI bridges for PA Bays 1 to 7 */ |
| 1335 |
c7200_pa_init_pci_bridge(router,1,vm->pci_bus_pool[24],1); |
| 1336 |
c7200_pa_init_pci_bridge(router,3,vm->pci_bus_pool[24],2); |
| 1337 |
c7200_pa_init_pci_bridge(router,5,vm->pci_bus_pool[24],3); |
| 1338 |
|
| 1339 |
c7200_pa_init_pci_bridge(router,2,vm->pci_bus_pool[25],1); |
| 1340 |
c7200_pa_init_pci_bridge(router,4,vm->pci_bus_pool[25],2); |
| 1341 |
c7200_pa_init_pci_bridge(router,6,vm->pci_bus_pool[25],3); |
| 1342 |
|
| 1343 |
c7200_pa_init_pci_bridge(router,7,vm->pci_bus_pool[0],8); |
| 1344 |
|
| 1345 |
|
| 1346 |
#if 0 /* too late at this stage... */ |
| 1347 |
/* Add a fake slot (8) for NPE-G2 Ethernet ports */ |
| 1348 |
if (vm_slot_add_binding(router->vm,"NPE-G2",8,0) == -1) |
| 1349 |
printf("unable to set slot 8\n"); |
| 1350 |
#endif |
| 1351 |
|
| 1352 |
return(0); |
| 1353 |
} |
| 1354 |
|
| 1355 |
/* Show C7200 hardware info */ |
| 1356 |
void c7200_show_hardware(c7200_t *router) |
| 1357 |
{ |
| 1358 |
vm_instance_t *vm = router->vm; |
| 1359 |
|
| 1360 |
printf("C7200 instance '%s' (id %d):\n",vm->name,vm->instance_id); |
| 1361 |
|
| 1362 |
printf(" VM Status : %d\n",vm->status); |
| 1363 |
printf(" RAM size : %u Mb\n",vm->ram_size); |
| 1364 |
printf(" IOMEM size : %u Mb\n",vm->iomem_size); |
| 1365 |
printf(" NVRAM size : %u Kb\n",vm->nvram_size); |
| 1366 |
printf(" NPE model : %s\n",router->npe_driver->npe_type); |
| 1367 |
printf(" Midplane : %s\n",router->midplane_type); |
| 1368 |
printf(" IOS image : %s\n\n",vm->ios_image); |
| 1369 |
|
| 1370 |
if (vm->debug_level > 0) { |
| 1371 |
dev_show_list(vm); |
| 1372 |
pci_dev_show_list(vm->pci_bus[0]); |
| 1373 |
pci_dev_show_list(vm->pci_bus[1]); |
| 1374 |
printf("\n"); |
| 1375 |
} |
| 1376 |
} |
| 1377 |
|
| 1378 |
/* Initialize default parameters for a C7200 */ |
| 1379 |
static void c7200_init_defaults(c7200_t *router) |
| 1380 |
{ |
| 1381 |
vm_instance_t *vm = router->vm; |
| 1382 |
n_eth_addr_t *m; |
| 1383 |
m_uint16_t pid; |
| 1384 |
|
| 1385 |
/* Set platform slots characteristics */ |
| 1386 |
vm->nr_slots = C7200_MAX_PA_BAYS; |
| 1387 |
vm->slots_type = CISCO_CARD_TYPE_PA; |
| 1388 |
vm->slots_drivers = pa_drivers; |
| 1389 |
|
| 1390 |
pid = (m_uint16_t)getpid(); |
| 1391 |
|
| 1392 |
/* Generate a chassis MAC address based on the instance ID */ |
| 1393 |
m = &router->mac_addr; |
| 1394 |
m->eth_addr_byte[0] = vm_get_mac_addr_msb(vm); |
| 1395 |
m->eth_addr_byte[1] = vm->instance_id & 0xFF; |
| 1396 |
m->eth_addr_byte[2] = pid >> 8; |
| 1397 |
m->eth_addr_byte[3] = pid & 0xFF; |
| 1398 |
m->eth_addr_byte[4] = 0x00; |
| 1399 |
m->eth_addr_byte[5] = 0x00; |
| 1400 |
|
| 1401 |
router->board_id[0] = 0x00; |
| 1402 |
|
| 1403 |
c7200_init_sys_eeprom_groups(router); |
| 1404 |
c7200_init_mp_eeprom_groups(router); |
| 1405 |
c7200_npe_set_type(router,C7200_DEFAULT_NPE_TYPE); |
| 1406 |
c7200_midplane_set_type(router,C7200_DEFAULT_MIDPLANE); |
| 1407 |
|
| 1408 |
vm->ram_mmap = C7200_DEFAULT_RAM_MMAP; |
| 1409 |
vm->ram_size = C7200_DEFAULT_RAM_SIZE; |
| 1410 |
vm->rom_size = C7200_DEFAULT_ROM_SIZE; |
| 1411 |
vm->nvram_size = C7200_DEFAULT_NVRAM_SIZE; |
| 1412 |
vm->iomem_size = 0; |
| 1413 |
vm->conf_reg_setup = C7200_DEFAULT_CONF_REG; |
| 1414 |
vm->clock_divisor = C7200_DEFAULT_CLOCK_DIV; |
| 1415 |
vm->nvram_rom_space = C7200_NVRAM_ROM_RES_SIZE; |
| 1416 |
|
| 1417 |
vm->pcmcia_disk_size[0] = C7200_DEFAULT_DISK0_SIZE; |
| 1418 |
vm->pcmcia_disk_size[1] = C7200_DEFAULT_DISK1_SIZE; |
| 1419 |
} |
| 1420 |
|
| 1421 |
/* Run the checklist */ |
| 1422 |
static int c7200_checklist(c7200_t *router) |
| 1423 |
{ |
| 1424 |
struct vm_instance *vm = router->vm; |
| 1425 |
int res = 0; |
| 1426 |
|
| 1427 |
res += vm_object_check(vm,"ram"); |
| 1428 |
res += vm_object_check(vm,"rom"); |
| 1429 |
res += vm_object_check(vm,"nvram"); |
| 1430 |
res += vm_object_check(vm,"zero"); |
| 1431 |
|
| 1432 |
if (res < 0) |
| 1433 |
vm_error(vm,"incomplete initialization (no memory?)\n"); |
| 1434 |
|
| 1435 |
return(res); |
| 1436 |
} |
| 1437 |
|
| 1438 |
/* Initialize Port Adapters */ |
| 1439 |
static int c7200_init_platform_pa(c7200_t *router) |
| 1440 |
{ |
| 1441 |
#if 1 /* FIXME - for a later release */ |
| 1442 |
/* Use a C7200-IO-FE by default in slot 0 if an I/O card is required */ |
| 1443 |
if (router->npe_driver->iocard_required && !vm_slot_active(router->vm,0,0)) |
| 1444 |
vm_slot_add_binding(router->vm,"C7200-IO-FE",0,0); |
| 1445 |
#endif |
| 1446 |
|
| 1447 |
return(vm_slot_init_all(router->vm)); |
| 1448 |
} |
| 1449 |
|
| 1450 |
/* Initialize the C7200 Platform (MIPS) */ |
| 1451 |
static int c7200m_init_platform(c7200_t *router) |
| 1452 |
{ |
| 1453 |
struct vm_instance *vm = router->vm; |
| 1454 |
cpu_mips_t *cpu0; |
| 1455 |
cpu_gen_t *gen0; |
| 1456 |
|
| 1457 |
/* Copy config register setup into "active" config register */ |
| 1458 |
vm->conf_reg = vm->conf_reg_setup; |
| 1459 |
|
| 1460 |
/* Create Console and AUX ports */ |
| 1461 |
vm_init_vtty(vm); |
| 1462 |
|
| 1463 |
/* Check that the amount of RAM is valid */ |
| 1464 |
if (vm->ram_size > router->npe_driver->max_ram_size) { |
| 1465 |
vm_error(vm,"%u is not a valid RAM size for this NPE. " |
| 1466 |
"Fallback to %u Mb.\n\n", |
| 1467 |
vm->ram_size,router->npe_driver->max_ram_size); |
| 1468 |
|
| 1469 |
vm->ram_size = router->npe_driver->max_ram_size; |
| 1470 |
} |
| 1471 |
|
| 1472 |
/* Create a CPU group */ |
| 1473 |
vm->cpu_group = cpu_group_create("System CPU"); |
| 1474 |
|
| 1475 |
/* Initialize the virtual MIPS processor */ |
| 1476 |
if (!(gen0 = cpu_create(vm,CPU_TYPE_MIPS64,0))) { |
| 1477 |
vm_error(vm,"unable to create CPU0!\n"); |
| 1478 |
return(-1); |
| 1479 |
} |
| 1480 |
|
| 1481 |
cpu0 = CPU_MIPS64(gen0); |
| 1482 |
|
| 1483 |
/* Add this CPU to the system CPU group */ |
| 1484 |
cpu_group_add(vm->cpu_group,gen0); |
| 1485 |
vm->boot_cpu = gen0; |
| 1486 |
|
| 1487 |
/* Initialize the IRQ routing vectors */ |
| 1488 |
vm->set_irq = mips64_vm_set_irq; |
| 1489 |
vm->clear_irq = mips64_vm_clear_irq; |
| 1490 |
|
| 1491 |
/* Mark the Network IO interrupt as high priority */ |
| 1492 |
cpu0->irq_idle_preempt[C7200_NETIO_IRQ] = TRUE; |
| 1493 |
cpu0->irq_idle_preempt[C7200_GT64K_IRQ] = TRUE; |
| 1494 |
|
| 1495 |
/* Copy some parameters from VM to CPU0 (idle PC, ...) */ |
| 1496 |
cpu0->idle_pc = vm->idle_pc; |
| 1497 |
|
| 1498 |
if (vm->timer_irq_check_itv) |
| 1499 |
cpu0->timer_irq_check_itv = vm->timer_irq_check_itv; |
| 1500 |
|
| 1501 |
/* |
| 1502 |
* On the C7200, bit 33 of physical addresses is used to bypass L2 cache. |
| 1503 |
* We clear it systematically. |
| 1504 |
*/ |
| 1505 |
cpu0->addr_bus_mask = C7200_ADDR_BUS_MASK; |
| 1506 |
|
| 1507 |
/* Remote emulator control */ |
| 1508 |
dev_remote_control_init(vm,0x16000000,0x1000); |
| 1509 |
|
| 1510 |
/* Bootflash (8 Mb) */ |
| 1511 |
dev_bootflash_init(vm,"bootflash","c7200-bootflash-8mb", |
| 1512 |
C7200_BOOTFLASH_ADDR); |
| 1513 |
|
| 1514 |
/* NVRAM and calendar */ |
| 1515 |
dev_nvram_init(vm,"nvram",router->npe_driver->nvram_addr, |
| 1516 |
vm->nvram_size*1024,&vm->conf_reg); |
| 1517 |
|
| 1518 |
/* Bit-bucket zone */ |
| 1519 |
dev_zero_init(vm,"zero",C7200_BITBUCKET_ADDR,0xc00000); |
| 1520 |
|
| 1521 |
/* Initialize the NPE board */ |
| 1522 |
if (router->npe_driver->npe_init(router) == -1) |
| 1523 |
return(-1); |
| 1524 |
|
| 1525 |
/* Initialize RAM */ |
| 1526 |
vm_ram_init(vm,0x00000000ULL); |
| 1527 |
|
| 1528 |
/* Initialize ROM */ |
| 1529 |
if (!vm->rom_filename) { |
| 1530 |
/* use embedded ROM */ |
| 1531 |
dev_rom_init(vm,"rom",C7200_ROM_ADDR,vm->rom_size*1048576, |
| 1532 |
mips64_microcode,mips64_microcode_len); |
| 1533 |
} else { |
| 1534 |
/* use alternate ROM */ |
| 1535 |
dev_ram_init(vm,"rom",TRUE,TRUE,NULL,FALSE, |
| 1536 |
C7200_ROM_ADDR,vm->rom_size*1048576); |
| 1537 |
} |
| 1538 |
|
| 1539 |
/* Byte swapping */ |
| 1540 |
dev_bswap_init(vm,"mem_bswap",C7200_BSWAP_ADDR,1024*1048576,0x00000000ULL); |
| 1541 |
|
| 1542 |
/* PCI IO space */ |
| 1543 |
if (!(vm->pci_io_space = pci_io_data_init(vm,C7200_PCI_IO_ADDR))) |
| 1544 |
return(-1); |
| 1545 |
|
| 1546 |
/* Cirrus Logic PD6729 (PCI-to-PCMCIA host adapter) */ |
| 1547 |
dev_clpd6729_init(vm,router->pcmcia_bus, |
| 1548 |
router->npe_driver->clpd6729_pci_dev, |
| 1549 |
vm->pci_io_space,0x402,0x403); |
| 1550 |
|
| 1551 |
/* Initialize the Port Adapters */ |
| 1552 |
if (c7200_init_platform_pa(router) == -1) |
| 1553 |
return(-1); |
| 1554 |
|
| 1555 |
/* Verify the check list */ |
| 1556 |
if (c7200_checklist(router) == -1) |
| 1557 |
return(-1); |
| 1558 |
|
| 1559 |
/* Midplane FPGA */ |
| 1560 |
dev_c7200_mpfpga_init(router,C7200_MPFPGA_ADDR,0x1000); |
| 1561 |
|
| 1562 |
/* IO FPGA */ |
| 1563 |
if (dev_c7200_iofpga_init(router,C7200_IOFPGA_ADDR,0x1000) == -1) |
| 1564 |
return(-1); |
| 1565 |
|
| 1566 |
/* Show device list */ |
| 1567 |
c7200_show_hardware(router); |
| 1568 |
return(0); |
| 1569 |
} |
| 1570 |
|
| 1571 |
/* Initialize the C7200 Platform (PowerPC) */ |
| 1572 |
static int c7200p_init_platform(c7200_t *router) |
| 1573 |
{ |
| 1574 |
struct vm_instance *vm = router->vm; |
| 1575 |
cpu_ppc_t *cpu0; |
| 1576 |
cpu_gen_t *gen0; |
| 1577 |
vm_obj_t *obj; |
| 1578 |
|
| 1579 |
/* Copy config register setup into "active" config register */ |
| 1580 |
vm->conf_reg = vm->conf_reg_setup; |
| 1581 |
|
| 1582 |
/* Create Console and AUX ports */ |
| 1583 |
vm_init_vtty(vm); |
| 1584 |
|
| 1585 |
/* Check that the amount of RAM is valid */ |
| 1586 |
if (vm->ram_size > router->npe_driver->max_ram_size) { |
| 1587 |
vm_error(vm,"%u is not a valid RAM size for this NPE. " |
| 1588 |
"Fallback to %u Mb.\n\n", |
| 1589 |
vm->ram_size,router->npe_driver->max_ram_size); |
| 1590 |
|
| 1591 |
vm->ram_size = router->npe_driver->max_ram_size; |
| 1592 |
} |
| 1593 |
|
| 1594 |
/* Create a CPU group */ |
| 1595 |
vm->cpu_group = cpu_group_create("System CPU"); |
| 1596 |
|
| 1597 |
/* Initialize the virtual PowerPC processor */ |
| 1598 |
if (!(gen0 = cpu_create(vm,CPU_TYPE_PPC32,0))) { |
| 1599 |
vm_error(vm,"unable to create CPU0!\n"); |
| 1600 |
return(-1); |
| 1601 |
} |
| 1602 |
|
| 1603 |
cpu0 = CPU_PPC32(gen0); |
| 1604 |
|
| 1605 |
/* Add this CPU to the system CPU group */ |
| 1606 |
cpu_group_add(vm->cpu_group,gen0); |
| 1607 |
vm->boot_cpu = gen0; |
| 1608 |
|
| 1609 |
/* Mark the Network IO interrupt as high priority */ |
| 1610 |
vm->irq_idle_preempt[C7200_NETIO_IRQ] = TRUE; |
| 1611 |
|
| 1612 |
/* Copy some parameters from VM to CPU0 (idle PC, ...) */ |
| 1613 |
cpu0->idle_pc = vm->idle_pc; |
| 1614 |
|
| 1615 |
if (vm->timer_irq_check_itv) |
| 1616 |
cpu0->timer_irq_check_itv = vm->timer_irq_check_itv; |
| 1617 |
|
| 1618 |
/* Initialize the Marvell MV-64460 system controller */ |
| 1619 |
if (c7200_init_mv64460(router) == -1) |
| 1620 |
return(-1); |
| 1621 |
|
| 1622 |
if (!(obj = vm_object_find(router->vm,"mv64460"))) |
| 1623 |
return(-1); |
| 1624 |
|
| 1625 |
router->mv64460_sysctr = obj->data; |
| 1626 |
|
| 1627 |
/* Remote emulator control */ |
| 1628 |
dev_remote_control_init(vm,0xf6000000,0x1000); |
| 1629 |
|
| 1630 |
/* Bootflash (64 Mb) */ |
| 1631 |
dev_bootflash_init(vm,"bootflash","c7200-bootflash-64mb", |
| 1632 |
C7200_G2_BOOTFLASH_ADDR); |
| 1633 |
|
| 1634 |
/* NVRAM and calendar */ |
| 1635 |
vm->nvram_size = C7200_G2_NVRAM_SIZE / 1024; |
| 1636 |
dev_nvram_init(vm,"nvram",router->npe_driver->nvram_addr, |
| 1637 |
C7200_G2_NVRAM_SIZE,&vm->conf_reg); |
| 1638 |
|
| 1639 |
/* Initialize the NPE board */ |
| 1640 |
if (router->npe_driver->npe_init(router) == -1) |
| 1641 |
return(-1); |
| 1642 |
|
| 1643 |
/* Initialize RAM */ |
| 1644 |
vm_ram_init(vm,0x00000000ULL); |
| 1645 |
|
| 1646 |
/* Initialize ROM */ |
| 1647 |
if (!vm->rom_filename) { |
| 1648 |
/* use embedded ROM */ |
| 1649 |
dev_rom_init(vm,"rom",C7200_G2_ROM_ADDR,vm->rom_size*1048576, |
| 1650 |
ppc32_microcode,ppc32_microcode_len); |
| 1651 |
} else { |
| 1652 |
/* use alternate ROM */ |
| 1653 |
dev_ram_init(vm,"rom",TRUE,TRUE,NULL,FALSE, |
| 1654 |
C7200_G2_ROM_ADDR,vm->rom_size*1048576); |
| 1655 |
} |
| 1656 |
|
| 1657 |
/* Byte swapping - FIXME */ |
| 1658 |
dev_bswap_init(vm,"mem_bswap0",C7200_G2_BSWAP_ADDR,32*1048576, |
| 1659 |
0x00000000ULL); |
| 1660 |
//dev_bswap_init(vm,"mem_bswap0",C7200_G2_BSWAP_ADDR+0x10000000,32*1048576, |
| 1661 |
// 0x00000000ULL); |
| 1662 |
|
| 1663 |
/* PCI IO space */ |
| 1664 |
if (!(vm->pci_io_space = pci_io_data_init(vm,C7200_G2_PCI_IO_ADDR))) |
| 1665 |
return(-1); |
| 1666 |
|
| 1667 |
/* Cirrus Logic PD6729 (PCI-to-PCMCIA host adapter) */ |
| 1668 |
dev_clpd6729_init(vm,router->pcmcia_bus, |
| 1669 |
router->npe_driver->clpd6729_pci_dev, |
| 1670 |
vm->pci_io_space,0x402,0x403); |
| 1671 |
|
| 1672 |
/* Initialize the Port Adapters */ |
| 1673 |
if (c7200_init_platform_pa(router) == -1) |
| 1674 |
return(-1); |
| 1675 |
|
| 1676 |
/* IO FPGA */ |
| 1677 |
if (dev_c7200_iofpga_init(router,C7200_G2_IOFPGA_ADDR,0x1000) == -1) |
| 1678 |
return(-1); |
| 1679 |
|
| 1680 |
/* MP FPGA */ |
| 1681 |
if (dev_c7200_mpfpga_init(router,C7200_G2_MPFPGA_ADDR,0x10000) == -1) |
| 1682 |
return(-1); |
| 1683 |
|
| 1684 |
/* |
| 1685 |
* If we have no i/o card in slot 0, the console is handled by |
| 1686 |
* the MV64460. |
| 1687 |
*/ |
| 1688 |
if (!c7200_slot0_iocard_present(router)) { |
| 1689 |
vm_log(vm,"CONSOLE","console managed by NPE-G2 board\n"); |
| 1690 |
mv64460_sdma_bind_vtty(router->mv64460_sysctr,0,vm->vtty_con); |
| 1691 |
mv64460_sdma_bind_vtty(router->mv64460_sysctr,1,vm->vtty_aux); |
| 1692 |
} |
| 1693 |
|
| 1694 |
/* Show device list */ |
| 1695 |
c7200_show_hardware(router); |
| 1696 |
return(0); |
| 1697 |
} |
| 1698 |
|
| 1699 |
/* Boot the IOS image (MIPS) */ |
| 1700 |
static int c7200m_boot_ios(c7200_t *router) |
| 1701 |
{ |
| 1702 |
vm_instance_t *vm = router->vm; |
| 1703 |
cpu_mips_t *cpu; |
| 1704 |
|
| 1705 |
if (!vm->boot_cpu) |
| 1706 |
return(-1); |
| 1707 |
|
| 1708 |
/* Suspend CPU activity since we will restart directly from ROM */ |
| 1709 |
vm_suspend(vm); |
| 1710 |
|
| 1711 |
/* Check that CPU activity is really suspended */ |
| 1712 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 1713 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 1714 |
return(-1); |
| 1715 |
} |
| 1716 |
|
| 1717 |
/* Reset the boot CPU */ |
| 1718 |
cpu = CPU_MIPS64(vm->boot_cpu); |
| 1719 |
mips64_reset(cpu); |
| 1720 |
|
| 1721 |
/* Load IOS image */ |
| 1722 |
if (mips64_load_elf_image(cpu,vm->ios_image, |
| 1723 |
(vm->ghost_status == VM_GHOST_RAM_USE), |
| 1724 |
&vm->ios_entry_point) < 0) |
| 1725 |
{ |
| 1726 |
vm_error(vm,"failed to load Cisco IOS image '%s'.\n",vm->ios_image); |
| 1727 |
return(-1); |
| 1728 |
} |
| 1729 |
|
| 1730 |
/* Launch the simulation */ |
| 1731 |
printf("\nC7200 '%s': starting simulation (CPU0 PC=0x%llx), " |
| 1732 |
"JIT %sabled.\n", |
| 1733 |
vm->name,cpu->pc,vm->jit_use ? "en":"dis"); |
| 1734 |
|
| 1735 |
vm_log(vm,"C7200_BOOT", |
| 1736 |
"starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n", |
| 1737 |
cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off"); |
| 1738 |
|
| 1739 |
/* Start main CPU */ |
| 1740 |
if (vm->ghost_status != VM_GHOST_RAM_GENERATE) { |
| 1741 |
vm->status = VM_STATUS_RUNNING; |
| 1742 |
cpu_start(vm->boot_cpu); |
| 1743 |
} else { |
| 1744 |
vm->status = VM_STATUS_SHUTDOWN; |
| 1745 |
} |
| 1746 |
return(0); |
| 1747 |
} |
| 1748 |
|
| 1749 |
/* Boot the IOS image (PowerPC) */ |
| 1750 |
static int c7200p_boot_ios(c7200_t *router) |
| 1751 |
{ |
| 1752 |
vm_instance_t *vm = router->vm; |
| 1753 |
cpu_ppc_t *cpu; |
| 1754 |
|
| 1755 |
if (!vm->boot_cpu) |
| 1756 |
return(-1); |
| 1757 |
|
| 1758 |
/* Suspend CPU activity since we will restart directly from ROM */ |
| 1759 |
vm_suspend(vm); |
| 1760 |
|
| 1761 |
/* Check that CPU activity is really suspended */ |
| 1762 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 1763 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 1764 |
return(-1); |
| 1765 |
} |
| 1766 |
|
| 1767 |
/* Reset the boot CPU */ |
| 1768 |
cpu = CPU_PPC32(vm->boot_cpu); |
| 1769 |
ppc32_reset(cpu); |
| 1770 |
|
| 1771 |
/* Load IOS image */ |
| 1772 |
if (ppc32_load_elf_image(cpu,vm->ios_image, |
| 1773 |
(vm->ghost_status == VM_GHOST_RAM_USE), |
| 1774 |
&vm->ios_entry_point) < 0) |
| 1775 |
{ |
| 1776 |
vm_error(vm,"failed to load Cisco IOS image '%s'.\n",vm->ios_image); |
| 1777 |
return(-1); |
| 1778 |
} |
| 1779 |
|
| 1780 |
/* Launch the simulation */ |
| 1781 |
printf("\nC7200P '%s': starting simulation (CPU0 IA=0x%8.8x), " |
| 1782 |
"JIT %sabled.\n", |
| 1783 |
vm->name,cpu->ia,vm->jit_use ? "en":"dis"); |
| 1784 |
|
| 1785 |
vm_log(vm,"C7200P_BOOT", |
| 1786 |
"starting instance (CPU0 IA=0x%8.8x,idle_pc=0x%8.8x,JIT %s)\n", |
| 1787 |
cpu->ia,cpu->idle_pc,vm->jit_use ? "on":"off"); |
| 1788 |
|
| 1789 |
/* Start main CPU */ |
| 1790 |
if (vm->ghost_status != VM_GHOST_RAM_GENERATE) { |
| 1791 |
vm->status = VM_STATUS_RUNNING; |
| 1792 |
cpu_start(vm->boot_cpu); |
| 1793 |
} else { |
| 1794 |
vm->status = VM_STATUS_SHUTDOWN; |
| 1795 |
} |
| 1796 |
return(0); |
| 1797 |
} |
| 1798 |
|
| 1799 |
/* Set an IRQ */ |
| 1800 |
static void c7200m_set_irq(vm_instance_t *vm,u_int irq) |
| 1801 |
{ |
| 1802 |
c7200_t *router = VM_C7200(vm); |
| 1803 |
cpu_mips_t *cpu0 = CPU_MIPS64(vm->boot_cpu); |
| 1804 |
u_int slot,port; |
| 1805 |
|
| 1806 |
switch(irq) { |
| 1807 |
case 0 ... 7: |
| 1808 |
mips64_set_irq(cpu0,irq); |
| 1809 |
|
| 1810 |
if (cpu0->irq_idle_preempt[irq]) |
| 1811 |
cpu_idle_break_wait(cpu0->gen); |
| 1812 |
break; |
| 1813 |
|
| 1814 |
case C7200_NETIO_IRQ_BASE ... C7200_NETIO_IRQ_END: |
| 1815 |
c7200_net_irq_get_slot_port(irq,&slot,&port); |
| 1816 |
dev_c7200_net_set_irq(router,slot,port); |
| 1817 |
break; |
| 1818 |
} |
| 1819 |
} |
| 1820 |
|
| 1821 |
/* Clear an IRQ */ |
| 1822 |
static void c7200m_clear_irq(vm_instance_t *vm,u_int irq) |
| 1823 |
{ |
| 1824 |
c7200_t *router = VM_C7200(vm); |
| 1825 |
cpu_mips_t *cpu0 = CPU_MIPS64(vm->boot_cpu); |
| 1826 |
u_int slot,port; |
| 1827 |
|
| 1828 |
switch(irq) { |
| 1829 |
case 0 ... 7: |
| 1830 |
mips64_clear_irq(cpu0,irq); |
| 1831 |
break; |
| 1832 |
|
| 1833 |
case C7200_NETIO_IRQ_BASE ... C7200_NETIO_IRQ_END: |
| 1834 |
c7200_net_irq_get_slot_port(irq,&slot,&port); |
| 1835 |
dev_c7200_net_clear_irq(router,slot,port); |
| 1836 |
break; |
| 1837 |
} |
| 1838 |
} |
| 1839 |
|
| 1840 |
/* Initialize a Cisco 7200 instance (MIPS) */ |
| 1841 |
static int c7200m_init_instance(c7200_t *router) |
| 1842 |
{ |
| 1843 |
vm_instance_t *vm = router->vm; |
| 1844 |
m_uint32_t rom_entry_point; |
| 1845 |
cpu_mips_t *cpu0; |
| 1846 |
|
| 1847 |
/* Initialize the C7200 platform */ |
| 1848 |
if (c7200m_init_platform(router) == -1) { |
| 1849 |
vm_error(vm,"unable to initialize the platform hardware.\n"); |
| 1850 |
return(-1); |
| 1851 |
} |
| 1852 |
|
| 1853 |
/* IRQ routing */ |
| 1854 |
vm->set_irq = c7200m_set_irq; |
| 1855 |
vm->clear_irq = c7200m_clear_irq; |
| 1856 |
|
| 1857 |
/* Load IOS configuration files */ |
| 1858 |
if (vm->ios_startup_config != NULL || vm->ios_private_config != NULL) { |
| 1859 |
vm_nvram_push_config(vm,vm->ios_startup_config,vm->ios_private_config); |
| 1860 |
vm->conf_reg &= ~0x40; |
| 1861 |
} |
| 1862 |
|
| 1863 |
/* Load ROM (ELF image or embedded) */ |
| 1864 |
cpu0 = CPU_MIPS64(vm->boot_cpu); |
| 1865 |
rom_entry_point = (m_uint32_t)MIPS_ROM_PC; |
| 1866 |
|
| 1867 |
if ((vm->rom_filename != NULL) && |
| 1868 |
(mips64_load_elf_image(cpu0,vm->rom_filename,0,&rom_entry_point) < 0)) |
| 1869 |
{ |
| 1870 |
vm_error(vm,"unable to load alternate ROM '%s', " |
| 1871 |
"fallback to embedded ROM.\n\n",vm->rom_filename); |
| 1872 |
vm->rom_filename = NULL; |
| 1873 |
} |
| 1874 |
|
| 1875 |
/* Load symbol file */ |
| 1876 |
if (vm->sym_filename) { |
| 1877 |
mips64_sym_load_file(cpu0,vm->sym_filename); |
| 1878 |
cpu0->sym_trace = 1; |
| 1879 |
} |
| 1880 |
|
| 1881 |
return(c7200m_boot_ios(router)); |
| 1882 |
} |
| 1883 |
|
| 1884 |
/* Set an IRQ */ |
| 1885 |
static void c7200p_set_irq(vm_instance_t *vm,u_int irq) |
| 1886 |
{ |
| 1887 |
c7200_t *router = VM_C7200(vm); |
| 1888 |
cpu_ppc_t *cpu0 = CPU_PPC32(vm->boot_cpu); |
| 1889 |
u_int slot,port; |
| 1890 |
|
| 1891 |
switch(irq) { |
| 1892 |
case C7200_VTIMER_IRQ: |
| 1893 |
ppc32_trigger_timer_irq(cpu0); |
| 1894 |
break; |
| 1895 |
case C7200_DUART_IRQ: |
| 1896 |
dev_mv64460_set_gpp_intr(router->mv64460_sysctr,10); |
| 1897 |
break; |
| 1898 |
case C7200_NETIO_IRQ: |
| 1899 |
dev_mv64460_set_gpp_intr(router->mv64460_sysctr,24); |
| 1900 |
break; |
| 1901 |
case C7200_PA_MGMT_IRQ: |
| 1902 |
dev_mv64460_set_gpp_intr(router->mv64460_sysctr,20); |
| 1903 |
break; |
| 1904 |
case C7200_OIR_IRQ: |
| 1905 |
dev_mv64460_set_gpp_intr(router->mv64460_sysctr,0); |
| 1906 |
break; |
| 1907 |
case C7200_NETIO_IRQ_BASE ... C7200_NETIO_IRQ_END: |
| 1908 |
c7200_net_irq_get_slot_port(irq,&slot,&port); |
| 1909 |
dev_c7200_net_set_irq(router,slot,port); |
| 1910 |
break; |
| 1911 |
} |
| 1912 |
|
| 1913 |
if (vm->irq_idle_preempt[irq]) |
| 1914 |
cpu_idle_break_wait(cpu0->gen); |
| 1915 |
} |
| 1916 |
|
| 1917 |
/* Clear an IRQ */ |
| 1918 |
static void c7200p_clear_irq(vm_instance_t *vm,u_int irq) |
| 1919 |
{ |
| 1920 |
c7200_t *router = VM_C7200(vm); |
| 1921 |
u_int slot,port; |
| 1922 |
|
| 1923 |
switch(irq) { |
| 1924 |
case C7200_DUART_IRQ: |
| 1925 |
dev_mv64460_clear_gpp_intr(router->mv64460_sysctr,10); |
| 1926 |
break; |
| 1927 |
case C7200_NETIO_IRQ: |
| 1928 |
dev_mv64460_clear_gpp_intr(router->mv64460_sysctr,24); |
| 1929 |
break; |
| 1930 |
case C7200_PA_MGMT_IRQ: |
| 1931 |
dev_mv64460_clear_gpp_intr(router->mv64460_sysctr,20); |
| 1932 |
break; |
| 1933 |
case C7200_OIR_IRQ: |
| 1934 |
dev_mv64460_clear_gpp_intr(router->mv64460_sysctr,0); |
| 1935 |
break; |
| 1936 |
case C7200_NETIO_IRQ_BASE ... C7200_NETIO_IRQ_END: |
| 1937 |
c7200_net_irq_get_slot_port(irq,&slot,&port); |
| 1938 |
dev_c7200_net_clear_irq(router,slot,port); |
| 1939 |
break; |
| 1940 |
} |
| 1941 |
} |
| 1942 |
|
| 1943 |
/* Initialize a Cisco 7200 instance (PowerPC) */ |
| 1944 |
static int c7200p_init_instance(c7200_t *router) |
| 1945 |
{ |
| 1946 |
vm_instance_t *vm = router->vm; |
| 1947 |
m_uint32_t rom_entry_point; |
| 1948 |
cpu_ppc_t *cpu0; |
| 1949 |
int i; |
| 1950 |
|
| 1951 |
/* Initialize the C7200 platform */ |
| 1952 |
if (c7200p_init_platform(router) == -1) { |
| 1953 |
vm_error(vm,"unable to initialize the platform hardware.\n"); |
| 1954 |
return(-1); |
| 1955 |
} |
| 1956 |
|
| 1957 |
/* IRQ routing */ |
| 1958 |
vm->set_irq = c7200p_set_irq; |
| 1959 |
vm->clear_irq = c7200p_clear_irq; |
| 1960 |
|
| 1961 |
/* Load ROM (ELF image or embedded) */ |
| 1962 |
cpu0 = CPU_PPC32(vm->boot_cpu); |
| 1963 |
rom_entry_point = (m_uint32_t)PPC32_ROM_START; |
| 1964 |
|
| 1965 |
if ((vm->rom_filename != NULL) && |
| 1966 |
(ppc32_load_elf_image(cpu0,vm->rom_filename,0,&rom_entry_point) < 0)) |
| 1967 |
{ |
| 1968 |
vm_error(vm,"unable to load alternate ROM '%s', " |
| 1969 |
"fallback to embedded ROM.\n\n",vm->rom_filename); |
| 1970 |
vm->rom_filename = NULL; |
| 1971 |
} |
| 1972 |
|
| 1973 |
/* Initialize the MMU (TEST) */ |
| 1974 |
for(i=0;i<PPC32_SR_NR;i++) |
| 1975 |
cpu0->sr[i] = i << 16; |
| 1976 |
|
| 1977 |
/* The page table takes 2 Mb of memory */ |
| 1978 |
vm->ram_res_size = 2; |
| 1979 |
ppc32_set_sdr1(cpu0,((vm->ram_size - 2) * 1048576) + 0x1F); |
| 1980 |
ppc32_init_page_table(cpu0); |
| 1981 |
ppc32_map_zone(cpu0,cpu0->sr[C7200_G2_BOOTFLASH_ADDR >> 28], |
| 1982 |
C7200_G2_BOOTFLASH_ADDR,C7200_G2_BOOTFLASH_ADDR, |
| 1983 |
64*1048576,0,0x02); |
| 1984 |
|
| 1985 |
ppc32_map_zone(cpu0,cpu0->sr[0xD8000000 >> 28], |
| 1986 |
0xD8000000,0xD8000000,0x400000,0,0x02); |
| 1987 |
ppc32_map_zone(cpu0,cpu0->sr[0xDC000000 >> 28], |
| 1988 |
0xDC000000,0xDC000000,0x400000,0,0x02); |
| 1989 |
|
| 1990 |
/* FIXME */ |
| 1991 |
ppc32_map_zone(cpu0,cpu0->sr[0xDF000000 >> 28], |
| 1992 |
0xDF000000,0xDF000000,0x400000,0,0x02); |
| 1993 |
|
| 1994 |
/* INST */ |
| 1995 |
cpu0->bat[PPC32_IBAT_IDX][0].reg[0] = 0x00007FFE; |
| 1996 |
cpu0->bat[PPC32_IBAT_IDX][0].reg[1] = 0x00000003; |
| 1997 |
|
| 1998 |
cpu0->bat[PPC32_IBAT_IDX][3].reg[0] = 0xF0001FFE; |
| 1999 |
cpu0->bat[PPC32_IBAT_IDX][3].reg[1] = 0xF0000003; |
| 2000 |
|
| 2001 |
/* DATA */ |
| 2002 |
cpu0->bat[PPC32_DBAT_IDX][0].reg[0] = 0x00007FFE; |
| 2003 |
cpu0->bat[PPC32_DBAT_IDX][0].reg[1] = 0x00000003; |
| 2004 |
|
| 2005 |
cpu0->bat[PPC32_DBAT_IDX][3].reg[0] = 0xF0001FFE; |
| 2006 |
cpu0->bat[PPC32_DBAT_IDX][3].reg[1] = 0xF0000003; |
| 2007 |
|
| 2008 |
return(c7200p_boot_ios(router)); |
| 2009 |
} |
| 2010 |
|
| 2011 |
/* Initialize a Cisco 7200 instance */ |
| 2012 |
static int c7200_init_instance(vm_instance_t *vm) |
| 2013 |
{ |
| 2014 |
c7200_t *router = VM_C7200(vm); |
| 2015 |
|
| 2016 |
switch(router->npe_driver->npe_family) { |
| 2017 |
case C7200_NPE_FAMILY_MIPS: |
| 2018 |
return(c7200m_init_instance(router)); |
| 2019 |
|
| 2020 |
case C7200_NPE_FAMILY_PPC: |
| 2021 |
return(c7200p_init_instance(router)); |
| 2022 |
|
| 2023 |
default: |
| 2024 |
vm_error(router->vm,"unsupported NPE family %d", |
| 2025 |
router->npe_driver->npe_family); |
| 2026 |
return(-1); |
| 2027 |
} |
| 2028 |
} |
| 2029 |
|
| 2030 |
/* Stop a Cisco 7200 instance */ |
| 2031 |
static int c7200_stop_instance(vm_instance_t *vm) |
| 2032 |
{ |
| 2033 |
printf("\nC7200 '%s': stopping simulation.\n",vm->name); |
| 2034 |
vm_log(vm,"C7200_STOP","stopping simulation.\n"); |
| 2035 |
|
| 2036 |
/* Stop all CPUs */ |
| 2037 |
if (vm->cpu_group != NULL) { |
| 2038 |
vm_stop(vm); |
| 2039 |
|
| 2040 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 2041 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 2042 |
return(-1); |
| 2043 |
} |
| 2044 |
} |
| 2045 |
|
| 2046 |
/* Free resources that were used during execution to emulate hardware */ |
| 2047 |
c7200_free_hw_ressources(VM_C7200(vm)); |
| 2048 |
vm_hardware_shutdown(vm); |
| 2049 |
return(0); |
| 2050 |
} |
| 2051 |
|
| 2052 |
/* Trigger an OIR event */ |
| 2053 |
static int c7200_trigger_oir_event(c7200_t *router,u_int slot) |
| 2054 |
{ |
| 2055 |
switch(slot) { |
| 2056 |
case 1 ... 6: |
| 2057 |
router->oir_status[0] = 1 << slot; |
| 2058 |
break; |
| 2059 |
case 7: |
| 2060 |
/* signal the OIR on slot 0, and set the "extended status" */ |
| 2061 |
router->oir_status[0] = 1 << 0; |
| 2062 |
router->oir_status[1] = 1 << 24; |
| 2063 |
break; |
| 2064 |
} |
| 2065 |
|
| 2066 |
vm_set_irq(router->vm,C7200_OIR_IRQ); |
| 2067 |
return(0); |
| 2068 |
} |
| 2069 |
|
| 2070 |
/* Initialize a new PA while the virtual router is online (OIR) */ |
| 2071 |
static int c7200_pa_init_online(vm_instance_t *vm,u_int slot,u_int subslot) |
| 2072 |
{ |
| 2073 |
if (!slot) { |
| 2074 |
vm_error(vm,"OIR not supported on slot 0.\n"); |
| 2075 |
return(-1); |
| 2076 |
} |
| 2077 |
|
| 2078 |
/* |
| 2079 |
* Suspend CPU activity while adding new hardware (since we change the |
| 2080 |
* memory maps). |
| 2081 |
*/ |
| 2082 |
vm_suspend(vm); |
| 2083 |
|
| 2084 |
/* Check that CPU activity is really suspended */ |
| 2085 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 2086 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 2087 |
return(-1); |
| 2088 |
} |
| 2089 |
|
| 2090 |
/* Add the new hardware elements */ |
| 2091 |
if (vm_slot_init(vm,slot) == -1) |
| 2092 |
return(-1); |
| 2093 |
|
| 2094 |
/* Resume normal operations */ |
| 2095 |
vm_resume(vm); |
| 2096 |
|
| 2097 |
/* Now, we can safely trigger the OIR event */ |
| 2098 |
c7200_trigger_oir_event(VM_C7200(vm),slot); |
| 2099 |
return(0); |
| 2100 |
} |
| 2101 |
|
| 2102 |
/* Stop a PA while the virtual router is online (OIR) */ |
| 2103 |
static int c7200_pa_stop_online(vm_instance_t *vm,u_int slot,u_int subslot) |
| 2104 |
{ |
| 2105 |
if (!slot) { |
| 2106 |
vm_error(vm,"OIR not supported on slot 0.\n"); |
| 2107 |
return(-1); |
| 2108 |
} |
| 2109 |
|
| 2110 |
/* The PA driver must be initialized */ |
| 2111 |
if (!vm_slot_get_card_ptr(vm,slot)) { |
| 2112 |
vm_error(vm,"trying to shut down empty slot %u.\n",slot); |
| 2113 |
return(-1); |
| 2114 |
} |
| 2115 |
|
| 2116 |
/* Disable all NIOs to stop traffic forwarding */ |
| 2117 |
vm_slot_disable_all_nio(vm,slot); |
| 2118 |
|
| 2119 |
/* We can safely trigger the OIR event */ |
| 2120 |
c7200_trigger_oir_event(VM_C7200(vm),slot); |
| 2121 |
|
| 2122 |
/* |
| 2123 |
* Suspend CPU activity while removing the hardware (since we change the |
| 2124 |
* memory maps). |
| 2125 |
*/ |
| 2126 |
vm_suspend(vm); |
| 2127 |
|
| 2128 |
/* Device removal */ |
| 2129 |
if (vm_slot_shutdown(vm,slot) != 0) |
| 2130 |
vm_error(vm,"unable to shutdown slot %u.\n",slot); |
| 2131 |
|
| 2132 |
/* Resume normal operations */ |
| 2133 |
vm_resume(vm); |
| 2134 |
return(0); |
| 2135 |
} |
| 2136 |
|
| 2137 |
/* Get MAC address MSB */ |
| 2138 |
static u_int c7200_get_mac_addr_msb(void) |
| 2139 |
{ |
| 2140 |
return(0xCA); |
| 2141 |
} |
| 2142 |
|
| 2143 |
/* Parse specific options for the Cisco 7200 platform */ |
| 2144 |
static int c7200_cli_parse_options(vm_instance_t *vm,int option) |
| 2145 |
{ |
| 2146 |
c7200_t *router = VM_C7200(vm); |
| 2147 |
|
| 2148 |
switch(option) { |
| 2149 |
/* NPE type */ |
| 2150 |
case 't': |
| 2151 |
c7200_npe_set_type(router,optarg); |
| 2152 |
break; |
| 2153 |
|
| 2154 |
/* Midplane type */ |
| 2155 |
case 'M': |
| 2156 |
c7200_midplane_set_type(router,optarg); |
| 2157 |
break; |
| 2158 |
|
| 2159 |
/* Set the base MAC address */ |
| 2160 |
case 'm': |
| 2161 |
if (!c7200_midplane_set_mac_addr(router,optarg)) |
| 2162 |
printf("MAC address set to '%s'.\n",optarg); |
| 2163 |
break; |
| 2164 |
|
| 2165 |
/* Set the System ID */ |
| 2166 |
case 'I': |
| 2167 |
if (!c7200_set_system_id(router,optarg)) |
| 2168 |
printf("System ID set to '%s'.\n",optarg); |
| 2169 |
break; |
| 2170 |
|
| 2171 |
/* Unknown option */ |
| 2172 |
default: |
| 2173 |
return(-1); |
| 2174 |
} |
| 2175 |
|
| 2176 |
return(0); |
| 2177 |
} |
| 2178 |
|
| 2179 |
/* Show specific CLI options */ |
| 2180 |
static void c7200_cli_show_options(vm_instance_t *vm) |
| 2181 |
{ |
| 2182 |
printf(" -t <npe_type> : Select NPE type (default: \"%s\")\n" |
| 2183 |
" -M <midplane> : Select Midplane (\"std\" or \"vxr\")\n" |
| 2184 |
" -p <pa_desc> : Define a Port Adapter\n" |
| 2185 |
" -s <pa_nio> : Bind a Network IO interface to a " |
| 2186 |
"Port Adapter\n" |
| 2187 |
" -I <serialno> : Set Processor Board Serial Number\n", |
| 2188 |
C7200_DEFAULT_NPE_TYPE); |
| 2189 |
} |
| 2190 |
|
| 2191 |
/* Platform definition */ |
| 2192 |
static vm_platform_t c7200_platform = { |
| 2193 |
"c7200", "C7200", "7200", |
| 2194 |
c7200_create_instance, |
| 2195 |
c7200_delete_instance, |
| 2196 |
c7200_init_instance, |
| 2197 |
c7200_stop_instance, |
| 2198 |
c7200_pa_init_online, |
| 2199 |
c7200_pa_stop_online, |
| 2200 |
c7200_nvram_extract_config, |
| 2201 |
c7200_nvram_push_config, |
| 2202 |
c7200_get_mac_addr_msb, |
| 2203 |
c7200_save_config, |
| 2204 |
c7200_cli_parse_options, |
| 2205 |
c7200_cli_show_options, |
| 2206 |
c7200_npe_show_drivers, |
| 2207 |
}; |
| 2208 |
|
| 2209 |
/* Register the c7200 platform */ |
| 2210 |
int c7200_platform_register(void) |
| 2211 |
{ |
| 2212 |
if (vm_platform_register(&c7200_platform) == -1) |
| 2213 |
return(-1); |
| 2214 |
|
| 2215 |
return(hypervisor_c7200_init(&c7200_platform)); |
| 2216 |
} |