Пример #1
0
int main(int argc,char *argv[])
{
   vm_instance_t *vm;

#ifdef PROFILE
   atexit(profiler_savestat);
#endif

   printf("Cisco Router Simulation Platform (version %s)\n",sw_version);
   printf("Copyright (c) 2005-2007 Christophe Fillot.\n");
   printf("Build date: %s %s\n\n",__DATE__,__TIME__);

   /* Register platforms */
   register_default_platforms();

   /* Initialize timers */
   timer_init();

   /* Initialize object registry */
   registry_init();
   
   /* Initialize ATM module (for HEC checksums) */
   atm_init();

   /* Initialize CRC functions */
   crc_init();

   /* Initialize NetIO code */
   netio_rxl_init();

   /* Initialize NetIO packet filters */
   netio_filter_load_all();

   /* Initialize VTTY code */
   vtty_init();
   
   /* Parse standard command line */
   if (!run_hypervisor(argc,argv))
      parse_std_cmd_line(argc,argv);

   /* Create general log file */
   create_log_file();

   /* Periodic tasks initialization */
   if (ptask_init(0) == -1)
      exit(EXIT_FAILURE);

   /* Create instruction lookup tables */
   mips64_jit_create_ilt();
   mips64_exec_create_ilt();
   ppc32_jit_create_ilt();
   ppc32_exec_create_ilt();
   
   setup_signals();

   if (!hypervisor_mode) {
      /* Initialize the default instance */
      vm = vm_acquire("default");
      assert(vm != NULL);

      if (vm->platform->init_instance(vm) == -1) {
         fprintf(stderr,"Unable to initialize router instance.\n");
         exit(EXIT_FAILURE);
      }

      /* Start GDB server before the image to allow debugging from
         the begining of it's execution */ 
      if (vm->gdb_server_running)
      {
        /* Stop main CPU */
        vm_suspend(vm);
//         cpu_stop(vm->boot_cpu);
      
        if (gdb_server_start_listener(vm) < 0) {
            fprintf(stderr,"GDB server unable to create TCP sockets.\n");
            exit(EXIT_FAILURE);
        }
      }

#if (DEBUG_INSN_PERF_CNT > 0) || (DEBUG_BLOCK_PERF_CNT > 0)
      {
         m_uint32_t counter,prev = 0,delta;
         while(vm->status == VM_STATUS_RUNNING) {
            counter = cpu_get_perf_counter(vm->boot_cpu);
            delta = counter - prev;
            prev = counter;
            printf("delta = %u\n",delta);
            sleep(1);
         }
      }
#else
      /* Start instance monitoring */
      vm_monitor(vm);
#endif

      // FIXME: remove this kludge
      if (vm->gdb_server_running)
      {
         //while (vm->gdb_conn->active)
         //   usleep(1000000);
         gdb_server_close_control_sockets();
      }

      /* Free resources used by instance */
      vm_release(vm);

   } else {
      hypervisor_tcp_server(hypervisor_ip_address,hypervisor_tcp_port);
   }

   dynamips_reset();
   close_log_file();
   return(0);
}
Пример #2
0
int main(int argc,char *argv[])
{
    vm_instance_t *vm;

#ifdef PROFILE
    atexit(profiler_savestat);
#endif

#ifdef USE_UNSTABLE
    printf("Cisco Router Simulation Platform (version %s/%s unstable)\n",
           sw_version,os_name);
#else
    printf("Cisco Router Simulation Platform (version %s/%s stable)\n",
           sw_version,os_name);
#endif

    printf("Copyright (c) 2005-2011 Christophe Fillot.\n");
    printf("Build date: %s %s\n\n",__DATE__,__TIME__);

    gen_uuid_init();

    /* Register platforms */
    register_default_platforms();

    /* Initialize timers */
    timer_init();

    /* Initialize object registry */
    registry_init();

    /* Initialize ATM module (for HEC checksums) */
    atm_init();

    /* Initialize CRC functions */
    crc_init();

    /* Initialize NetIO code */
    netio_rxl_init();

    /* Initialize NetIO packet filters */
    netio_filter_load_all();

    /* Initialize VTTY code */
    vtty_init();

    /* Parse standard command line */
    atexit(destroy_cmd_line_vars);
    if (!run_hypervisor(argc,argv))
        parse_std_cmd_line(argc,argv);

    /* Create general log file */
    create_log_file();

    /* Periodic tasks initialization */
    if (ptask_init(0) == -1)
        exit(EXIT_FAILURE);

    /* Create instruction lookup tables */
    mips64_jit_create_ilt();
    mips64_exec_create_ilt();
    ppc32_jit_create_ilt();
    ppc32_exec_create_ilt();

    setup_signals();

    if (!hypervisor_mode) {
        /* Initialize the default instance */
        vm = vm_acquire("default");
        assert(vm != NULL);

        if (vm_init_instance(vm) == -1) {
            fprintf(stderr,"Unable to initialize router instance.\n");
            exit(EXIT_FAILURE);
        }

#if (DEBUG_INSN_PERF_CNT > 0) || (DEBUG_BLOCK_PERF_CNT > 0)
        {
            m_uint32_t counter,prev = 0,delta;
            while(vm->status == VM_STATUS_RUNNING) {
                counter = cpu_get_perf_counter(vm->boot_cpu);
                delta = counter - prev;
                prev = counter;
                printf("delta = %u\n",delta);
                sleep(1);
            }
        }
#else
        /* Start instance monitoring */
        vm_monitor(vm);
#endif

        /* Free resources used by instance */
        vm_release(vm);
    } else {
        hypervisor_tcp_server(hypervisor_ip_address,hypervisor_tcp_port);
    }

    dynamips_reset();
    close_log_file();
    return(0);
}