| 1 |
/* |
| 2 |
* Cisco 3600 simulation platform. |
| 3 |
* Copyright (c) 2006 Christophe Fillot ([email protected]) |
| 4 |
* Patched by Jeremy Grossmann for the GNS3 project (www.gns3.net) |
| 5 |
* |
| 6 |
* Generic Cisco 3600 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 "dynamips.h" |
| 18 |
#include "memory.h" |
| 19 |
#include "device.h" |
| 20 |
#include "pci_io.h" |
| 21 |
#include "dev_gt.h" |
| 22 |
#include "cisco_eeprom.h" |
| 23 |
#include "dev_rom.h" |
| 24 |
#include "dev_c3600.h" |
| 25 |
#include "dev_c3600_iofpga.h" |
| 26 |
#include "dev_c3600_bay.h" |
| 27 |
#include "dev_vtty.h" |
| 28 |
#include "registry.h" |
| 29 |
#include "fs_nvram.h" |
| 30 |
|
| 31 |
/* ======================================================================== */ |
| 32 |
/* EEPROM definitions */ |
| 33 |
/* ======================================================================== */ |
| 34 |
|
| 35 |
/* Cisco 3620 mainboard EEPROM */ |
| 36 |
static m_uint16_t eeprom_c3620_mainboard_data[64] = { |
| 37 |
0x0001, 0x0000, 0x0000, 0x0000, 0x0AFF, 0x7318, 0x5011, 0x0020, |
| 38 |
0xFF10, 0x45C5, 0xA0FF, 0x9904, 0x19FF, 0xFFFF, 0xFFFF, 0x0002, |
| 39 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 40 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 41 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 42 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 43 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 44 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 45 |
}; |
| 46 |
|
| 47 |
struct cisco_eeprom eeprom_c3620_mainboard = { |
| 48 |
"C3620 Mainboard", |
| 49 |
eeprom_c3620_mainboard_data, |
| 50 |
sizeof(eeprom_c3620_mainboard_data)/2, |
| 51 |
}; |
| 52 |
|
| 53 |
/* Cisco 3640 mainboard EEPROM */ |
| 54 |
static m_uint16_t eeprom_c3640_mainboard_data[64] = { |
| 55 |
0x0001, 0x0000, 0x0000, 0x0000, 0x0AFF, 0x7316, 0x8514, 0x0040, |
| 56 |
0xFF10, 0x45C5, 0xA1FF, 0x0102, 0x22FF, 0xFFFF, 0xFFFF, 0x0002, |
| 57 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 58 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 59 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 60 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 61 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 62 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 63 |
}; |
| 64 |
|
| 65 |
struct cisco_eeprom eeprom_c3640_mainboard = { |
| 66 |
"C3640 Mainboard", |
| 67 |
eeprom_c3640_mainboard_data, |
| 68 |
sizeof(eeprom_c3640_mainboard_data)/2, |
| 69 |
}; |
| 70 |
|
| 71 |
/* Cisco 3660 backplane EEPROM */ |
| 72 |
static m_uint16_t eeprom_c3660_backplane_data[64] = { |
| 73 |
0x04FF, 0x4000, 0xC841, 0x0100, 0xC046, 0x0320, 0x0012, 0x8402, |
| 74 |
0x4243, 0x3080, 0x0000, 0x0000, 0x0202, 0xC18B, 0x4841, 0x4430, |
| 75 |
0x3434, 0x3431, 0x3135, 0x4A03, 0x0081, 0x0000, 0x0000, 0x0400, |
| 76 |
0xC28B, 0x4654, 0x5830, 0x3934, 0x3557, 0x304D, 0x59C3, 0x0600, |
| 77 |
0x044D, 0x0EC2, 0xD043, 0x0070, 0xC408, 0x0000, 0x0000, 0x0000, |
| 78 |
0x0000, 0x851C, 0x0A5B, 0x0201, 0x06FF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 79 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 80 |
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
| 81 |
}; |
| 82 |
|
| 83 |
struct cisco_eeprom eeprom_c3660_backplane = { |
| 84 |
"C3660 Backplane", |
| 85 |
eeprom_c3660_backplane_data, |
| 86 |
sizeof(eeprom_c3660_backplane_data)/2, |
| 87 |
}; |
| 88 |
|
| 89 |
/* ======================================================================== */ |
| 90 |
/* Chassis Drivers */ |
| 91 |
/* ======================================================================== */ |
| 92 |
static int c3620_init(c3600_t *router); |
| 93 |
static int c3640_init(c3600_t *router); |
| 94 |
static int c3660_init(c3600_t *router); |
| 95 |
|
| 96 |
static struct c3600_chassis_driver chassis_drivers[] = { |
| 97 |
{ "3620" , 3620, 1, c3620_init, &eeprom_c3620_mainboard }, |
| 98 |
{ "3640" , 3640, 1, c3640_init, &eeprom_c3640_mainboard }, |
| 99 |
{ "3660" , 3660, 1, c3660_init, &eeprom_c3660_backplane }, |
| 100 |
{ NULL , -1, 0, NULL, NULL }, |
| 101 |
}; |
| 102 |
|
| 103 |
/* ======================================================================== */ |
| 104 |
/* Network Module Drivers */ |
| 105 |
/* ======================================================================== */ |
| 106 |
static struct cisco_card_driver *nm_drivers[] = { |
| 107 |
&dev_c3600_nm_1e_driver, |
| 108 |
&dev_c3600_nm_4e_driver, |
| 109 |
&dev_c3600_nm_1fe_tx_driver, |
| 110 |
&dev_c3600_nm_4t_driver, |
| 111 |
&dev_c3600_leopard_2fe_driver, |
| 112 |
&dev_c3600_nm_16esw_driver, |
| 113 |
NULL, |
| 114 |
}; |
| 115 |
|
| 116 |
/* ======================================================================== */ |
| 117 |
/* Cisco 3600 router instances */ |
| 118 |
/* ======================================================================== */ |
| 119 |
|
| 120 |
/* Initialize default parameters for a C3600 */ |
| 121 |
static void c3600_init_defaults(c3600_t *router); |
| 122 |
|
| 123 |
/* Directly extract the configuration from the NVRAM device */ |
| 124 |
static int c3600_nvram_extract_config(vm_instance_t *vm,u_char **startup_config,size_t *startup_len,u_char **private_config,size_t *private_len) |
| 125 |
{ |
| 126 |
int ret; |
| 127 |
|
| 128 |
ret = generic_nvram_extract_config(vm, "nvram", vm->nvram_rom_space, 0, 0, FS_NVRAM_FORMAT_DEFAULT, startup_config, startup_len, private_config, private_len); |
| 129 |
|
| 130 |
return(ret); |
| 131 |
} |
| 132 |
|
| 133 |
/* Directly push the IOS configuration to the NVRAM device */ |
| 134 |
static int c3600_nvram_push_config(vm_instance_t *vm,u_char *startup_config,size_t startup_len,u_char *private_config,size_t private_len) |
| 135 |
{ |
| 136 |
int ret; |
| 137 |
|
| 138 |
ret = generic_nvram_push_config(vm, "nvram", vm->nvram_size*1024, vm->nvram_rom_space, 0, 0, FS_NVRAM_FORMAT_DEFAULT, startup_config, startup_len, private_config, private_len); |
| 139 |
|
| 140 |
return(ret); |
| 141 |
} |
| 142 |
|
| 143 |
/* Create a new router instance */ |
| 144 |
static int c3600_create_instance(vm_instance_t *vm) |
| 145 |
{ |
| 146 |
c3600_t *router; |
| 147 |
|
| 148 |
if (!(router = malloc(sizeof(*router)))) { |
| 149 |
fprintf(stderr,"C3600 '%s': Unable to create new instance!\n",vm->name); |
| 150 |
return(-1); |
| 151 |
} |
| 152 |
|
| 153 |
memset(router,0,sizeof(*router)); |
| 154 |
router->vm = vm; |
| 155 |
vm->hw_data = router; |
| 156 |
|
| 157 |
c3600_init_defaults(router); |
| 158 |
return(0); |
| 159 |
} |
| 160 |
|
| 161 |
/* Free resources used by a router instance */ |
| 162 |
static int c3600_delete_instance(vm_instance_t *vm) |
| 163 |
{ |
| 164 |
c3600_t *router = VM_C3600(vm); |
| 165 |
int i; |
| 166 |
|
| 167 |
/* Stop all CPUs */ |
| 168 |
if (vm->cpu_group != NULL) { |
| 169 |
vm_stop(vm); |
| 170 |
|
| 171 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 172 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 173 |
return(FALSE); |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
/* Remove NIO bindings */ |
| 178 |
for(i=0;i<vm->nr_slots;i++) |
| 179 |
vm_slot_remove_all_nio_bindings(vm,i); |
| 180 |
|
| 181 |
/* Shutdown all Network Modules */ |
| 182 |
vm_slot_shutdown_all(vm); |
| 183 |
|
| 184 |
/* Free mainboard EEPROM */ |
| 185 |
cisco_eeprom_free(&router->mb_eeprom); |
| 186 |
|
| 187 |
/* Free all resources used by VM */ |
| 188 |
vm_free(vm); |
| 189 |
|
| 190 |
/* Free the router structure */ |
| 191 |
free(router); |
| 192 |
return(TRUE); |
| 193 |
} |
| 194 |
|
| 195 |
/* Save configuration of a C3600 instance */ |
| 196 |
static void c3600_save_config(vm_instance_t *vm,FILE *fd) |
| 197 |
{ |
| 198 |
c3600_t *router = VM_C3600(vm); |
| 199 |
|
| 200 |
fprintf(fd,"c3600 set_chassis %s %s\n\n", |
| 201 |
vm->name,router->chassis_driver->chassis_type); |
| 202 |
} |
| 203 |
|
| 204 |
/* Set EEPROM for the specified slot */ |
| 205 |
int c3600_set_slot_eeprom(c3600_t *router,u_int slot, |
| 206 |
struct cisco_eeprom *eeprom) |
| 207 |
{ |
| 208 |
if (slot >= C3600_MAX_NM_BAYS) |
| 209 |
return(-1); |
| 210 |
|
| 211 |
router->c3660_nm_eeprom_group[slot].eeprom[0] = eeprom; |
| 212 |
return(0); |
| 213 |
} |
| 214 |
|
| 215 |
/* Get slot/port corresponding to specified network IRQ */ |
| 216 |
static inline void |
| 217 |
c3600_net_irq_get_slot_port(u_int irq,u_int *slot,u_int *port) |
| 218 |
{ |
| 219 |
irq -= C3600_NETIO_IRQ_BASE; |
| 220 |
*port = irq & C3600_NETIO_IRQ_PORT_MASK; |
| 221 |
*slot = irq >> C3600_NETIO_IRQ_PORT_BITS; |
| 222 |
} |
| 223 |
|
| 224 |
/* Get network IRQ for specified slot/port */ |
| 225 |
u_int c3600_net_irq_for_slot_port(u_int slot,u_int port) |
| 226 |
{ |
| 227 |
u_int irq; |
| 228 |
|
| 229 |
irq = (slot << C3600_NETIO_IRQ_PORT_BITS) + port; |
| 230 |
irq += C3600_NETIO_IRQ_BASE; |
| 231 |
|
| 232 |
return(irq); |
| 233 |
} |
| 234 |
|
| 235 |
/* Get a chassis driver */ |
| 236 |
struct c3600_chassis_driver *c3600_chassis_get_driver(char *chassis_type) |
| 237 |
{ |
| 238 |
int i; |
| 239 |
|
| 240 |
for(i=0;chassis_drivers[i].chassis_type;i++) |
| 241 |
if (!strcmp(chassis_drivers[i].chassis_type,chassis_type)) |
| 242 |
return(&chassis_drivers[i]); |
| 243 |
|
| 244 |
return NULL; |
| 245 |
} |
| 246 |
|
| 247 |
/* Set the system id or processor board id in the eeprom */ |
| 248 |
int c3600_set_system_id(c3600_t *router,char *id) |
| 249 |
{ |
| 250 |
/* 11 characters is enough. Array is 20 long */ |
| 251 |
strncpy(router->board_id,id,13); |
| 252 |
/* Make sure it is null terminated */ |
| 253 |
router->board_id[13] = 0x00; |
| 254 |
c3600_refresh_systemid(router); |
| 255 |
return 0; |
| 256 |
} |
| 257 |
int c3600_refresh_systemid(c3600_t *router) |
| 258 |
{ |
| 259 |
if (router->board_id[0] == 0x00) return(0); |
| 260 |
m_uint8_t buf[11]; |
| 261 |
|
| 262 |
if (!strcmp("3660",router->chassis_driver->chassis_type)) { |
| 263 |
parse_board_id(buf,router->board_id,11); |
| 264 |
cisco_eeprom_set_region(&router->mb_eeprom ,50,buf,11); |
| 265 |
} else { |
| 266 |
parse_board_id(buf,router->board_id,4); |
| 267 |
cisco_eeprom_set_region(&router->mb_eeprom ,16,buf,4); |
| 268 |
} |
| 269 |
return (0); |
| 270 |
} |
| 271 |
|
| 272 |
/* Set the base MAC address of the chassis */ |
| 273 |
static int c3600_burn_mac_addr(c3600_t *router,n_eth_addr_t *addr) |
| 274 |
{ |
| 275 |
m_uint8_t eeprom_ver; |
| 276 |
size_t offset; |
| 277 |
|
| 278 |
/* Read EEPROM format version */ |
| 279 |
cisco_eeprom_get_byte(&router->mb_eeprom,0,&eeprom_ver); |
| 280 |
|
| 281 |
switch(eeprom_ver) { |
| 282 |
case 0: |
| 283 |
cisco_eeprom_set_region(&router->mb_eeprom,2,addr->eth_addr_byte,6); |
| 284 |
break; |
| 285 |
|
| 286 |
case 4: |
| 287 |
if (!cisco_eeprom_v4_find_field(&router->mb_eeprom,0xC3,&offset)) { |
| 288 |
cisco_eeprom_set_region(&router->mb_eeprom,offset, |
| 289 |
addr->eth_addr_byte,6); |
| 290 |
} |
| 291 |
break; |
| 292 |
|
| 293 |
default: |
| 294 |
vm_error(router->vm,"c3600_burn_mac_addr: unable to handle " |
| 295 |
"EEPROM version %u\n",eeprom_ver); |
| 296 |
return(-1); |
| 297 |
} |
| 298 |
|
| 299 |
return(0); |
| 300 |
} |
| 301 |
|
| 302 |
/* Set chassis MAC address */ |
| 303 |
int c3600_chassis_set_mac_addr(c3600_t *router,char *mac_addr) |
| 304 |
{ |
| 305 |
if (parse_mac_addr(&router->mac_addr,mac_addr) == -1) { |
| 306 |
vm_error(router->vm,"unable to parse MAC address '%s'.\n",mac_addr); |
| 307 |
return(-1); |
| 308 |
} |
| 309 |
|
| 310 |
/* Set the chassis base MAC address */ |
| 311 |
c3600_burn_mac_addr(router,&router->mac_addr); |
| 312 |
return(0); |
| 313 |
} |
| 314 |
|
| 315 |
/* Set the chassis type */ |
| 316 |
int c3600_chassis_set_type(c3600_t *router,char *chassis_type) |
| 317 |
{ |
| 318 |
struct c3600_chassis_driver *driver; |
| 319 |
|
| 320 |
if (router->vm->status == VM_STATUS_RUNNING) { |
| 321 |
vm_error(router->vm,"unable to change chassis type when online.\n"); |
| 322 |
return(-1); |
| 323 |
} |
| 324 |
|
| 325 |
if (!(driver = c3600_chassis_get_driver(chassis_type))) { |
| 326 |
vm_error(router->vm,"unknown chassis type '%s'.\n",chassis_type); |
| 327 |
return(-1); |
| 328 |
} |
| 329 |
|
| 330 |
router->chassis_driver = driver; |
| 331 |
|
| 332 |
/* Copy the mainboard EEPROM */ |
| 333 |
if (cisco_eeprom_copy(&router->mb_eeprom,driver->eeprom) == -1) { |
| 334 |
vm_error(router->vm,"unable to set chassis EEPROM '%s'.\n",chassis_type); |
| 335 |
return(-1); |
| 336 |
} |
| 337 |
|
| 338 |
/* Set the chassis base MAC address */ |
| 339 |
c3600_burn_mac_addr(router,&router->mac_addr); |
| 340 |
|
| 341 |
/* The motherboard has 2 integrated FastEthernet ports on a 3660 */ |
| 342 |
if (driver->chassis_id == 3660) { |
| 343 |
vm_slot_remove_binding(router->vm,0,0); |
| 344 |
vm_slot_add_binding(router->vm,"Leopard-2FE",0,0); |
| 345 |
} |
| 346 |
c3600_refresh_systemid(router); |
| 347 |
return(0); |
| 348 |
} |
| 349 |
|
| 350 |
/* Get the chassis ID */ |
| 351 |
int c3600_chassis_get_id(c3600_t *router) |
| 352 |
{ |
| 353 |
if (router->chassis_driver) |
| 354 |
return(router->chassis_driver->chassis_id); |
| 355 |
|
| 356 |
return(-1); |
| 357 |
} |
| 358 |
|
| 359 |
/* Show the list of available chassis drivers */ |
| 360 |
static void c3600_chassis_show_drivers(void) |
| 361 |
{ |
| 362 |
int i; |
| 363 |
|
| 364 |
printf("Available C3600 chassis drivers:\n"); |
| 365 |
|
| 366 |
for(i=0;chassis_drivers[i].chassis_type;i++) { |
| 367 |
printf(" * %s %s\n", |
| 368 |
chassis_drivers[i].chassis_type, |
| 369 |
!chassis_drivers[i].supported ? "(NOT WORKING)" : ""); |
| 370 |
} |
| 371 |
|
| 372 |
printf("\n"); |
| 373 |
} |
| 374 |
|
| 375 |
/* Create the main PCI bus for a GT64010 based system */ |
| 376 |
static int c3600_init_gt64010(c3600_t *router) |
| 377 |
{ |
| 378 |
if (!(router->vm->pci_bus[0] = pci_bus_create("PCI bus",0))) { |
| 379 |
vm_error(router->vm,"unable to create PCI data.\n"); |
| 380 |
return(-1); |
| 381 |
} |
| 382 |
|
| 383 |
return(dev_gt64010_init(router->vm,"gt64010",C3600_GT64K_ADDR,0x1000, |
| 384 |
C3600_GT64K_IRQ)); |
| 385 |
} |
| 386 |
|
| 387 |
/* Create the two main PCI busses for a GT64120 based system */ |
| 388 |
static int c3600_init_gt64120(c3600_t *router) |
| 389 |
{ |
| 390 |
vm_instance_t *vm = router->vm; |
| 391 |
|
| 392 |
vm->pci_bus[0] = pci_bus_create("PCI bus #0",0); |
| 393 |
vm->pci_bus[1] = pci_bus_create("PCI bus #1",0); |
| 394 |
|
| 395 |
if (!vm->pci_bus[0] || !vm->pci_bus[1]) { |
| 396 |
vm_error(router->vm,"unable to create PCI data.\n"); |
| 397 |
return(-1); |
| 398 |
} |
| 399 |
|
| 400 |
return(dev_gt64120_init(vm,"gt64120",C3600_GT64K_ADDR,0x1000, |
| 401 |
C3600_GT64K_IRQ)); |
| 402 |
} |
| 403 |
|
| 404 |
/* Initialize a Cisco 3620 */ |
| 405 |
static int c3620_init(c3600_t *router) |
| 406 |
{ |
| 407 |
vm_instance_t *vm = router->vm; |
| 408 |
int i; |
| 409 |
|
| 410 |
/* Set the processor type: R4700 */ |
| 411 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R4700); |
| 412 |
|
| 413 |
/* Initialize the Galileo GT-64010 PCI controller */ |
| 414 |
if (c3600_init_gt64010(router) == -1) |
| 415 |
return(-1); |
| 416 |
|
| 417 |
/* Initialize PCI map (no PCI bridge for this chassis) */ |
| 418 |
for(i=0;i<C3600_MAX_NM_BAYS;i++) |
| 419 |
vm->slots_pci_bus[i] = vm->pci_bus[0]; |
| 420 |
|
| 421 |
vm->elf_machine_id = C3620_ELF_MACHINE_ID; |
| 422 |
return(0); |
| 423 |
} |
| 424 |
|
| 425 |
/* Initialize a Cisco 3640 */ |
| 426 |
static int c3640_init(c3600_t *router) |
| 427 |
{ |
| 428 |
vm_instance_t *vm = router->vm; |
| 429 |
struct nm_bay_info *bay; |
| 430 |
int i; |
| 431 |
|
| 432 |
/* Set the processor type: R4700 */ |
| 433 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R4700); |
| 434 |
|
| 435 |
/* Initialize the Galileo GT-64010 PCI controller */ |
| 436 |
if (c3600_init_gt64010(router) == -1) |
| 437 |
return(-1); |
| 438 |
|
| 439 |
/* Create the NM PCI busses */ |
| 440 |
vm->pci_bus_pool[0] = pci_bus_create("NM Slots 0,2",-1); |
| 441 |
vm->pci_bus_pool[1] = pci_bus_create("NM Slots 1,3",-1); |
| 442 |
|
| 443 |
/* Initialize PCI map and PCI bridges */ |
| 444 |
for(i=0;i<=3;i++) { |
| 445 |
bay = c3600_nm_get_bay_info(3640,i); |
| 446 |
|
| 447 |
/* Map the NM PCI bus */ |
| 448 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i & 1]; |
| 449 |
|
| 450 |
if (bay && (bay->pci_bridge_device != -1)) |
| 451 |
dev_dec21052_init(vm->pci_bus[0],bay->pci_bridge_device, |
| 452 |
vm->slots_pci_bus[i]); |
| 453 |
} |
| 454 |
|
| 455 |
vm->elf_machine_id = C3640_ELF_MACHINE_ID; |
| 456 |
return(0); |
| 457 |
} |
| 458 |
|
| 459 |
/* Initialize a Cisco 3660 */ |
| 460 |
static int c3660_init(c3600_t *router) |
| 461 |
{ |
| 462 |
vm_instance_t *vm = router->vm; |
| 463 |
struct nm_bay_info *bay; |
| 464 |
char bus_name[128]; |
| 465 |
int i; |
| 466 |
|
| 467 |
/* Set the processor type: R5271 */ |
| 468 |
mips64_set_prid(CPU_MIPS64(vm->boot_cpu),MIPS_PRID_R527x); |
| 469 |
|
| 470 |
/* Initialize the Galileo GT-64120 PCI controller */ |
| 471 |
if (c3600_init_gt64120(router) == -1) |
| 472 |
return(-1); |
| 473 |
|
| 474 |
/* Create the NM PCI busses */ |
| 475 |
for(i=1;i<=6;i++) { |
| 476 |
snprintf(bus_name,sizeof(bus_name),"NM Slot %d",i); |
| 477 |
vm->pci_bus_pool[i] = pci_bus_create(bus_name,-1); |
| 478 |
} |
| 479 |
|
| 480 |
/* Slot 0 is mapped to the first bus of GT64120 */ |
| 481 |
vm->slots_pci_bus[0] = vm->pci_bus[0]; |
| 482 |
|
| 483 |
/* Initialize PCI map and PCI bridges */ |
| 484 |
for(i=1;i<C3600_MAX_NM_BAYS;i++) { |
| 485 |
bay = c3600_nm_get_bay_info(3660,i); |
| 486 |
|
| 487 |
/* Map the NM PCI bus */ |
| 488 |
vm->slots_pci_bus[i] = vm->pci_bus_pool[i]; |
| 489 |
|
| 490 |
/* Slots 1-6 are mapped to the second bus of GT64120 */ |
| 491 |
if (bay && (bay->pci_bridge_device != -1)) |
| 492 |
dev_dec21152_init(vm->pci_bus[1],bay->pci_bridge_device, |
| 493 |
vm->slots_pci_bus[i]); |
| 494 |
} |
| 495 |
|
| 496 |
vm->elf_machine_id = C3660_ELF_MACHINE_ID; |
| 497 |
return(0); |
| 498 |
} |
| 499 |
|
| 500 |
/* Show C3600 hardware info */ |
| 501 |
void c3600_show_hardware(c3600_t *router) |
| 502 |
{ |
| 503 |
vm_instance_t *vm = router->vm; |
| 504 |
|
| 505 |
printf("C3600 instance '%s' (id %d):\n",vm->name,vm->instance_id); |
| 506 |
|
| 507 |
printf(" VM Status : %d\n",vm->status); |
| 508 |
printf(" RAM size : %u Mb\n",vm->ram_size); |
| 509 |
printf(" NVRAM size : %u Kb\n",vm->nvram_size); |
| 510 |
printf(" Chassis : %s\n",router->chassis_driver->chassis_type); |
| 511 |
printf(" IOS image : %s\n\n",vm->ios_image); |
| 512 |
|
| 513 |
if (vm->debug_level > 0) { |
| 514 |
dev_show_list(vm); |
| 515 |
pci_dev_show_list(vm->pci_bus[0]); |
| 516 |
pci_dev_show_list(vm->pci_bus[1]); |
| 517 |
printf("\n"); |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
/* Initialize default parameters for a C3600 */ |
| 522 |
static void c3600_init_defaults(c3600_t *router) |
| 523 |
{ |
| 524 |
vm_instance_t *vm = router->vm; |
| 525 |
n_eth_addr_t *m; |
| 526 |
m_uint16_t pid; |
| 527 |
|
| 528 |
/* Set platform slots characteristics */ |
| 529 |
vm->nr_slots = C3600_MAX_NM_BAYS; |
| 530 |
vm->slots_type = CISCO_CARD_TYPE_NM; |
| 531 |
vm->slots_drivers = nm_drivers; |
| 532 |
|
| 533 |
pid = (m_uint16_t)getpid(); |
| 534 |
|
| 535 |
/* Generate a chassis MAC address based on the instance ID */ |
| 536 |
m = &router->mac_addr; |
| 537 |
m->eth_addr_byte[0] = vm_get_mac_addr_msb(vm); |
| 538 |
m->eth_addr_byte[1] = vm->instance_id & 0xFF; |
| 539 |
m->eth_addr_byte[2] = pid >> 8; |
| 540 |
m->eth_addr_byte[3] = pid & 0xFF; |
| 541 |
m->eth_addr_byte[4] = 0x00; |
| 542 |
m->eth_addr_byte[5] = 0x00; |
| 543 |
router->board_id[0] = 0x00; |
| 544 |
|
| 545 |
c3600_init_eeprom_groups(router); |
| 546 |
c3600_chassis_set_type(router,C3600_DEFAULT_CHASSIS); |
| 547 |
|
| 548 |
vm->ram_mmap = C3600_DEFAULT_RAM_MMAP; |
| 549 |
vm->ram_size = C3600_DEFAULT_RAM_SIZE; |
| 550 |
vm->rom_size = C3600_DEFAULT_ROM_SIZE; |
| 551 |
vm->nvram_size = C3600_DEFAULT_NVRAM_SIZE; |
| 552 |
vm->conf_reg_setup = C3600_DEFAULT_CONF_REG; |
| 553 |
vm->clock_divisor = C3600_DEFAULT_CLOCK_DIV; |
| 554 |
vm->nvram_rom_space = C3600_NVRAM_ROM_RES_SIZE; |
| 555 |
vm->nm_iomem_size = C3600_DEFAULT_IOMEM_SIZE; |
| 556 |
|
| 557 |
vm->pcmcia_disk_size[0] = C3600_DEFAULT_DISK0_SIZE; |
| 558 |
vm->pcmcia_disk_size[1] = C3600_DEFAULT_DISK1_SIZE; |
| 559 |
} |
| 560 |
|
| 561 |
/* Initialize the C3600 Platform */ |
| 562 |
static int c3600_init_platform(c3600_t *router) |
| 563 |
{ |
| 564 |
vm_instance_t *vm = router->vm; |
| 565 |
cpu_mips_t *cpu; |
| 566 |
cpu_gen_t *gen; |
| 567 |
vm_obj_t *obj; |
| 568 |
|
| 569 |
/* Copy config register setup into "active" config register */ |
| 570 |
vm->conf_reg = vm->conf_reg_setup; |
| 571 |
|
| 572 |
/* Create Console and AUX ports */ |
| 573 |
vm_init_vtty(vm); |
| 574 |
|
| 575 |
/* Create a CPU group */ |
| 576 |
vm->cpu_group = cpu_group_create("System CPU"); |
| 577 |
|
| 578 |
/* Initialize the virtual MIPS processor */ |
| 579 |
if (!(gen = cpu_create(vm,CPU_TYPE_MIPS64,0))) { |
| 580 |
vm_error(vm,"unable to create CPU!\n"); |
| 581 |
return(-1); |
| 582 |
} |
| 583 |
|
| 584 |
cpu = CPU_MIPS64(gen); |
| 585 |
|
| 586 |
/* Add this CPU to the system CPU group */ |
| 587 |
cpu_group_add(vm->cpu_group,gen); |
| 588 |
vm->boot_cpu = gen; |
| 589 |
|
| 590 |
/* Initialize the IRQ routing vectors */ |
| 591 |
vm->set_irq = mips64_vm_set_irq; |
| 592 |
vm->clear_irq = mips64_vm_clear_irq; |
| 593 |
|
| 594 |
/* Mark the Network IO interrupt as high priority */ |
| 595 |
cpu->irq_idle_preempt[C3600_NETIO_IRQ] = TRUE; |
| 596 |
cpu->irq_idle_preempt[C3600_GT64K_IRQ] = TRUE; |
| 597 |
cpu->irq_idle_preempt[C3600_DUART_IRQ] = TRUE; |
| 598 |
|
| 599 |
/* Copy some parameters from VM to CPU (idle PC, ...) */ |
| 600 |
cpu->idle_pc = vm->idle_pc; |
| 601 |
|
| 602 |
if (vm->timer_irq_check_itv) |
| 603 |
cpu->timer_irq_check_itv = vm->timer_irq_check_itv; |
| 604 |
|
| 605 |
/* Get chassis specific driver */ |
| 606 |
if (!router->chassis_driver) { |
| 607 |
vm_error(vm,"no chassis defined.\n"); |
| 608 |
return(-1); |
| 609 |
} |
| 610 |
|
| 611 |
/* Remote emulator control */ |
| 612 |
dev_remote_control_init(vm,0x16000000,0x1000); |
| 613 |
|
| 614 |
/* Bootflash (8 Mb) */ |
| 615 |
dev_bootflash_init(vm,"bootflash","c3600-bootflash-8mb", |
| 616 |
C3600_BOOTFLASH_ADDR); |
| 617 |
|
| 618 |
/* NVRAM and calendar */ |
| 619 |
dev_nvram_init(vm,"nvram", |
| 620 |
C3600_NVRAM_ADDR,vm->nvram_size*1024,&vm->conf_reg); |
| 621 |
|
| 622 |
/* Bit-bucket zone */ |
| 623 |
dev_zero_init(vm,"zero",C3600_BITBUCKET_ADDR,0xc00000); |
| 624 |
|
| 625 |
/* IO FPGA */ |
| 626 |
if (dev_c3600_iofpga_init(router,C3600_IOFPGA_ADDR,0x40000) == -1) |
| 627 |
return(-1); |
| 628 |
|
| 629 |
if (!(obj = vm_object_find(router->vm,"io_fpga"))) |
| 630 |
return(-1); |
| 631 |
|
| 632 |
router->iofpga_data = obj->data; |
| 633 |
|
| 634 |
/* PCI IO space */ |
| 635 |
if (!(vm->pci_io_space = pci_io_data_init(vm,C3600_PCI_IO_ADDR))) |
| 636 |
return(-1); |
| 637 |
|
| 638 |
/* Initialize the chassis */ |
| 639 |
if (router->chassis_driver->chassis_init(router) == -1) |
| 640 |
return(-1); |
| 641 |
|
| 642 |
/* Initialize RAM */ |
| 643 |
vm_ram_init(vm,0x00000000ULL); |
| 644 |
|
| 645 |
/* Initialize ROM */ |
| 646 |
if (!vm->rom_filename) { |
| 647 |
/* use embedded ROM */ |
| 648 |
dev_rom_init(vm,"rom",C3600_ROM_ADDR,vm->rom_size*1048576, |
| 649 |
mips64_microcode,mips64_microcode_len); |
| 650 |
} else { |
| 651 |
/* use alternate ROM */ |
| 652 |
dev_ram_init(vm,"rom",TRUE,TRUE,NULL,FALSE, |
| 653 |
C3600_ROM_ADDR,vm->rom_size*1048576); |
| 654 |
} |
| 655 |
|
| 656 |
/* Initialize the NS16552 DUART */ |
| 657 |
dev_ns16552_init(vm,C3600_DUART_ADDR,0x1000,3,C3600_DUART_IRQ, |
| 658 |
vm->vtty_con,vm->vtty_aux); |
| 659 |
|
| 660 |
/* Cirrus Logic PD6729 (PCI-to-PCMCIA host adapter) */ |
| 661 |
dev_clpd6729_init(vm,vm->pci_bus[0],20,vm->pci_io_space,0x4402,0x4403); |
| 662 |
|
| 663 |
/* Initialize Network Modules */ |
| 664 |
if (vm_slot_init_all(vm) == -1) |
| 665 |
return(-1); |
| 666 |
|
| 667 |
/* Show device list */ |
| 668 |
c3600_show_hardware(router); |
| 669 |
return(0); |
| 670 |
} |
| 671 |
|
| 672 |
/* Boot the IOS image */ |
| 673 |
static int c3600_boot_ios(c3600_t *router) |
| 674 |
{ |
| 675 |
vm_instance_t *vm = router->vm; |
| 676 |
cpu_mips_t *cpu; |
| 677 |
|
| 678 |
if (!vm->boot_cpu) |
| 679 |
return(-1); |
| 680 |
|
| 681 |
/* Suspend CPU activity since we will restart directly from ROM */ |
| 682 |
vm_suspend(vm); |
| 683 |
|
| 684 |
/* Check that CPU activity is really suspended */ |
| 685 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 686 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 687 |
return(-1); |
| 688 |
} |
| 689 |
|
| 690 |
/* Reset the boot CPU */ |
| 691 |
cpu = CPU_MIPS64(vm->boot_cpu); |
| 692 |
mips64_reset(cpu); |
| 693 |
|
| 694 |
/* Load IOS image */ |
| 695 |
if (mips64_load_elf_image(cpu,vm->ios_image, |
| 696 |
(vm->ghost_status == VM_GHOST_RAM_USE), |
| 697 |
&vm->ios_entry_point) < 0) |
| 698 |
{ |
| 699 |
vm_error(vm,"failed to load Cisco IOS image '%s'.\n",vm->ios_image); |
| 700 |
return(-1); |
| 701 |
} |
| 702 |
|
| 703 |
/* Launch the simulation */ |
| 704 |
printf("\nC3600 '%s': starting simulation (CPU0 PC=0x%llx), " |
| 705 |
"JIT %sabled.\n", |
| 706 |
vm->name,cpu->pc,vm->jit_use ? "en":"dis"); |
| 707 |
|
| 708 |
vm_log(vm,"C3600_BOOT", |
| 709 |
"starting instance (CPU0 PC=0x%llx,idle_pc=0x%llx,JIT %s)\n", |
| 710 |
cpu->pc,cpu->idle_pc,vm->jit_use ? "on":"off"); |
| 711 |
|
| 712 |
/* Start main CPU */ |
| 713 |
if (vm->ghost_status != VM_GHOST_RAM_GENERATE) { |
| 714 |
vm->status = VM_STATUS_RUNNING; |
| 715 |
cpu_start(vm->boot_cpu); |
| 716 |
} else { |
| 717 |
vm->status = VM_STATUS_SHUTDOWN; |
| 718 |
} |
| 719 |
return(0); |
| 720 |
} |
| 721 |
|
| 722 |
/* Set an IRQ */ |
| 723 |
static void c3600_set_irq(vm_instance_t *vm,u_int irq) |
| 724 |
{ |
| 725 |
c3600_t *router = VM_C3600(vm); |
| 726 |
cpu_mips_t *cpu0 = CPU_MIPS64(vm->boot_cpu); |
| 727 |
u_int slot,port; |
| 728 |
|
| 729 |
switch(irq) { |
| 730 |
case 0 ... 7: |
| 731 |
mips64_set_irq(cpu0,irq); |
| 732 |
|
| 733 |
if (cpu0->irq_idle_preempt[irq]) |
| 734 |
cpu_idle_break_wait(cpu0->gen); |
| 735 |
break; |
| 736 |
|
| 737 |
case C3600_NETIO_IRQ_BASE ... C3600_NETIO_IRQ_END: |
| 738 |
c3600_net_irq_get_slot_port(irq,&slot,&port); |
| 739 |
dev_c3600_iofpga_net_set_irq(router->iofpga_data,slot,port); |
| 740 |
break; |
| 741 |
} |
| 742 |
} |
| 743 |
|
| 744 |
/* Clear an IRQ */ |
| 745 |
static void c3600_clear_irq(vm_instance_t *vm,u_int irq) |
| 746 |
{ |
| 747 |
c3600_t *router = VM_C3600(vm); |
| 748 |
cpu_mips_t *cpu0 = CPU_MIPS64(vm->boot_cpu); |
| 749 |
u_int slot,port; |
| 750 |
|
| 751 |
switch(irq) { |
| 752 |
case 0 ... 7: |
| 753 |
mips64_clear_irq(cpu0,irq); |
| 754 |
break; |
| 755 |
|
| 756 |
case C3600_NETIO_IRQ_BASE ... C3600_NETIO_IRQ_END: |
| 757 |
c3600_net_irq_get_slot_port(irq,&slot,&port); |
| 758 |
dev_c3600_iofpga_net_clear_irq(router->iofpga_data,slot,port); |
| 759 |
break; |
| 760 |
} |
| 761 |
} |
| 762 |
|
| 763 |
/* Initialize a Cisco 3600 instance */ |
| 764 |
static int c3600_init_instance(vm_instance_t *vm) |
| 765 |
{ |
| 766 |
c3600_t *router = VM_C3600(vm); |
| 767 |
m_uint32_t rom_entry_point; |
| 768 |
cpu_mips_t *cpu0; |
| 769 |
|
| 770 |
if (!vm->ios_image) { |
| 771 |
vm_error(vm,"no Cisco IOS image defined."); |
| 772 |
return(-1); |
| 773 |
} |
| 774 |
|
| 775 |
/* Initialize the C3600 platform */ |
| 776 |
if (c3600_init_platform(router) == -1) { |
| 777 |
vm_error(vm,"unable to initialize the platform hardware.\n"); |
| 778 |
return(-1); |
| 779 |
} |
| 780 |
|
| 781 |
/* IRQ routing */ |
| 782 |
vm->set_irq = c3600_set_irq; |
| 783 |
vm->clear_irq = c3600_clear_irq; |
| 784 |
|
| 785 |
/* Load IOS configuration files */ |
| 786 |
if (vm->ios_startup_config != NULL || vm->ios_private_config != NULL) { |
| 787 |
vm_nvram_push_config(vm,vm->ios_startup_config,vm->ios_private_config); |
| 788 |
vm->conf_reg &= ~0x40; |
| 789 |
} |
| 790 |
|
| 791 |
/* Load ROM (ELF image or embedded) */ |
| 792 |
cpu0 = CPU_MIPS64(vm->boot_cpu); |
| 793 |
rom_entry_point = (m_uint32_t)MIPS_ROM_PC; |
| 794 |
|
| 795 |
if ((vm->rom_filename != NULL) && |
| 796 |
(mips64_load_elf_image(cpu0,vm->rom_filename,0,&rom_entry_point) < 0)) |
| 797 |
{ |
| 798 |
vm_error(vm,"unable to load alternate ROM '%s', " |
| 799 |
"fallback to embedded ROM.\n\n",vm->rom_filename); |
| 800 |
vm->rom_filename = NULL; |
| 801 |
} |
| 802 |
|
| 803 |
/* Load symbol file */ |
| 804 |
if (vm->sym_filename) { |
| 805 |
mips64_sym_load_file(cpu0,vm->sym_filename); |
| 806 |
cpu0->sym_trace = 1; |
| 807 |
} |
| 808 |
|
| 809 |
return(c3600_boot_ios(router)); |
| 810 |
} |
| 811 |
|
| 812 |
/* Stop a Cisco 3600 instance */ |
| 813 |
static int c3600_stop_instance(vm_instance_t *vm) |
| 814 |
{ |
| 815 |
printf("\nC3600 '%s': stopping simulation.\n",vm->name); |
| 816 |
vm_log(vm,"C3600_STOP","stopping simulation.\n"); |
| 817 |
|
| 818 |
/* Stop all CPUs */ |
| 819 |
if (vm->cpu_group != NULL) { |
| 820 |
vm_stop(vm); |
| 821 |
|
| 822 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 823 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 824 |
return(-1); |
| 825 |
} |
| 826 |
} |
| 827 |
|
| 828 |
/* Free resources that were used during execution to emulate hardware */ |
| 829 |
vm_slot_shutdown_all(vm); |
| 830 |
vm_hardware_shutdown(vm); |
| 831 |
return(0); |
| 832 |
} |
| 833 |
|
| 834 |
static m_uint16_t c3660_oir_masks[C3600_MAX_NM_BAYS] = { |
| 835 |
0x0000, |
| 836 |
0x0900, /* slot 1 */ |
| 837 |
0x0009, /* slot 2 */ |
| 838 |
0x0A00, /* slot 3 */ |
| 839 |
0x000A, /* slot 4 */ |
| 840 |
0x0C00, /* slot 5 */ |
| 841 |
0x000C, /* slot 6 */ |
| 842 |
}; |
| 843 |
|
| 844 |
/* Trigger an OIR event (3660 only) */ |
| 845 |
static int c3600_trigger_oir_event(c3600_t *router,u_int nm_bay) |
| 846 |
{ |
| 847 |
if (nm_bay >= C3600_MAX_NM_BAYS) |
| 848 |
return(-1); |
| 849 |
|
| 850 |
router->oir_status = c3660_oir_masks[nm_bay]; |
| 851 |
vm_set_irq(router->vm,C3600_EXT_IRQ); |
| 852 |
return(0); |
| 853 |
} |
| 854 |
|
| 855 |
/* Initialize a new NM while the virtual router is online (OIR) */ |
| 856 |
static int c3600_nm_init_online(vm_instance_t *vm,u_int slot,u_int subslot) |
| 857 |
{ |
| 858 |
if (!slot) { |
| 859 |
vm_error(vm,"OIR not supported on slot 0.\n"); |
| 860 |
return(-1); |
| 861 |
} |
| 862 |
|
| 863 |
/* |
| 864 |
* Suspend CPU activity while adding new hardware (since we change the |
| 865 |
* memory maps). |
| 866 |
*/ |
| 867 |
vm_suspend(vm); |
| 868 |
|
| 869 |
/* Check that CPU activity is really suspended */ |
| 870 |
if (cpu_group_sync_state(vm->cpu_group) == -1) { |
| 871 |
vm_error(vm,"unable to sync with system CPUs.\n"); |
| 872 |
return(-1); |
| 873 |
} |
| 874 |
|
| 875 |
/* Add the new hardware elements */ |
| 876 |
if (vm_slot_init(vm,slot) == -1) |
| 877 |
return(-1); |
| 878 |
|
| 879 |
/* Resume normal operations */ |
| 880 |
vm_resume(vm); |
| 881 |
|
| 882 |
/* Now, we can safely trigger the OIR event */ |
| 883 |
c3600_trigger_oir_event(VM_C3600(vm),slot); |
| 884 |
return(0); |
| 885 |
} |
| 886 |
|
| 887 |
/* Stop a NM while the virtual router is online (OIR) */ |
| 888 |
static int c3600_nm_stop_online(vm_instance_t *vm,u_int slot,u_int subslot) |
| 889 |
{ |
| 890 |
if (!slot) { |
| 891 |
vm_error(vm,"OIR not supported on slot 0.\n"); |
| 892 |
return(-1); |
| 893 |
} |
| 894 |
|
| 895 |
/* The NM driver must be initialized */ |
| 896 |
if (!vm_slot_get_card_ptr(vm,slot)) { |
| 897 |
vm_error(vm,"trying to shut down empty slot %u.\n",slot); |
| 898 |
return(-1); |
| 899 |
} |
| 900 |
|
| 901 |
/* Disable all NIOs to stop traffic forwarding */ |
| 902 |
vm_slot_disable_all_nio(vm,slot); |
| 903 |
|
| 904 |
/* We can safely trigger the OIR event */ |
| 905 |
c3600_trigger_oir_event(VM_C3600(vm),slot); |
| 906 |
|
| 907 |
/* |
| 908 |
* Suspend CPU activity while removing the hardware (since we change the |
| 909 |
* memory maps). |
| 910 |
*/ |
| 911 |
vm_suspend(vm); |
| 912 |
|
| 913 |
/* Device removal */ |
| 914 |
if (vm_slot_shutdown(vm,slot) != 0) |
| 915 |
vm_error(vm,"unable to shutdown slot %u.\n",slot); |
| 916 |
|
| 917 |
/* Resume normal operations */ |
| 918 |
vm_resume(vm); |
| 919 |
return(0); |
| 920 |
} |
| 921 |
|
| 922 |
/* Get MAC address MSB */ |
| 923 |
static u_int c3600_get_mac_addr_msb(void) |
| 924 |
{ |
| 925 |
return(0xCC); |
| 926 |
} |
| 927 |
|
| 928 |
/* Parse specific options for the Cisco 3600 platform */ |
| 929 |
static int c3600_cli_parse_options(vm_instance_t *vm,int option) |
| 930 |
{ |
| 931 |
c3600_t *router = VM_C3600(vm); |
| 932 |
|
| 933 |
switch(option) { |
| 934 |
/* IO memory reserved for NMs (in percents!) */ |
| 935 |
case OPT_IOMEM_SIZE: |
| 936 |
vm->nm_iomem_size = 0x8000 | atoi(optarg); |
| 937 |
break; |
| 938 |
|
| 939 |
/* Chassis type */ |
| 940 |
case 't': |
| 941 |
c3600_chassis_set_type(router,optarg); |
| 942 |
break; |
| 943 |
|
| 944 |
/* Set the base MAC address */ |
| 945 |
case 'm': |
| 946 |
if (!c3600_chassis_set_mac_addr(router,optarg)) |
| 947 |
printf("MAC address set to '%s'.\n",optarg); |
| 948 |
break; |
| 949 |
|
| 950 |
/* Set the System ID */ |
| 951 |
case 'I': |
| 952 |
if (!c3600_set_system_id(router,optarg)) |
| 953 |
printf("System ID set to '%s'.\n",optarg); |
| 954 |
break; |
| 955 |
|
| 956 |
|
| 957 |
/* Unknown option */ |
| 958 |
default: |
| 959 |
return(-1); |
| 960 |
} |
| 961 |
|
| 962 |
return(0); |
| 963 |
} |
| 964 |
|
| 965 |
/* Show specific CLI options */ |
| 966 |
static void c3600_cli_show_options(vm_instance_t *vm) |
| 967 |
{ |
| 968 |
printf(" -t <chassis_type> : Select Chassis type (default: \"%s\")\n" |
| 969 |
" --iomem-size <val> : IO memory (in percents, default: %u)\n" |
| 970 |
" -p <nm_desc> : Define a Network Module\n" |
| 971 |
" -I <serialno> : Set Processor Board Serial Number\n" |
| 972 |
" -s <nm_nio> : Bind a Network IO interface to a " |
| 973 |
"Network Module\n", |
| 974 |
C3600_DEFAULT_CHASSIS,vm->nm_iomem_size); |
| 975 |
} |
| 976 |
|
| 977 |
/* Platform definition */ |
| 978 |
static vm_platform_t c3600_platform = { |
| 979 |
"c3600", "C3600", "3600", |
| 980 |
c3600_create_instance, |
| 981 |
c3600_delete_instance, |
| 982 |
c3600_init_instance, |
| 983 |
c3600_stop_instance, |
| 984 |
c3600_nm_init_online, |
| 985 |
c3600_nm_stop_online, |
| 986 |
c3600_nvram_extract_config, |
| 987 |
c3600_nvram_push_config, |
| 988 |
c3600_get_mac_addr_msb, |
| 989 |
c3600_save_config, |
| 990 |
c3600_cli_parse_options, |
| 991 |
c3600_cli_show_options, |
| 992 |
c3600_chassis_show_drivers, |
| 993 |
}; |
| 994 |
|
| 995 |
/* Register the c3600 platform */ |
| 996 |
int c3600_platform_register(void) |
| 997 |
{ |
| 998 |
if (vm_platform_register(&c3600_platform) == -1) |
| 999 |
return(-1); |
| 1000 |
|
| 1001 |
return(hypervisor_c3600_init(&c3600_platform)); |
| 1002 |
} |