/[dynamips]/upstream/dynamips-0.2.7-RC2/dynamips.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /upstream/dynamips-0.2.7-RC2/dynamips.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC3/dynamips.c revision 4 by dpavlin, Sat Oct 6 16:06:49 2007 UTC upstream/dynamips-0.2.7-RC2/dynamips.c revision 8 by dpavlin, Sat Oct 6 16:24:54 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   * Cisco 7200 (Predator) simulation platform.   * Cisco router simulation platform.
3   * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)   * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr)
4   *   *
5   * Many thanks to Nicolas Szalay for his patch   * Many thanks to Nicolas Szalay for his patch
# Line 20  Line 20 
20  #include <assert.h>  #include <assert.h>
21  #include <getopt.h>  #include <getopt.h>
22    
 #include ARCH_INC_FILE  
   
23  #include "dynamips.h"  #include "dynamips.h"
24  #include "mips64.h"  #include "cpu.h"
25  #include "mips64_exec.h"  #include "mips64_exec.h"
26    #include "mips64_jit.h"
27    #include "ppc32_exec.h"
28    #include "ppc32_jit.h"
29  #include "dev_c7200.h"  #include "dev_c7200.h"
30  #include "dev_c3600.h"  #include "dev_c3600.h"
31  #include "dev_c2691.h"  #include "dev_c2691.h"
32  #include "dev_c3725.h"  #include "dev_c3725.h"
33  #include "dev_c3745.h"  #include "dev_c3745.h"
34    #include "dev_c2600.h"
35    #include "dev_msfc1.h"
36    #include "ppc32_vmtest.h"
37  #include "dev_vtty.h"  #include "dev_vtty.h"
38  #include "ptask.h"  #include "ptask.h"
39  #include "timer.h"  #include "timer.h"
# Line 55  Line 59 
59  /* Software version */  /* Software version */
60  const char *sw_version = DYNAMIPS_VERSION"-"JIT_ARCH;  const char *sw_version = DYNAMIPS_VERSION"-"JIT_ARCH;
61    
62    /* Software version tag */
63    const char *sw_version_tag = "2007030219";
64    
65  /* Hypervisor */  /* Hypervisor */
66  int hypervisor_mode = 0;  int hypervisor_mode = 0;
67  int hypervisor_tcp_port = 0;  int hypervisor_tcp_port = 0;
# Line 151  static void show_usage(int argc,char *ar Line 158  static void show_usage(int argc,char *ar
158  {  {
159     u_int def_ram_size,def_rom_size,def_nvram_size;     u_int def_ram_size,def_rom_size,def_nvram_size;
160     u_int def_conf_reg,def_clock_div;     u_int def_conf_reg,def_clock_div;
161     u_int def_disk0_size,def_disk1_size;     u_int def_disk0_size = 0,def_disk1_size = 0;
162     u_int def_nm_iomem_size = 0;     u_int def_nm_iomem_size = 0;
163    
164     switch(platform) {     switch(platform) {
# Line 204  static void show_usage(int argc,char *ar Line 211  static void show_usage(int argc,char *ar
211           def_disk1_size = C3745_DEFAULT_DISK1_SIZE;           def_disk1_size = C3745_DEFAULT_DISK1_SIZE;
212           def_nm_iomem_size = C3745_DEFAULT_IOMEM_SIZE;           def_nm_iomem_size = C3745_DEFAULT_IOMEM_SIZE;
213           break;           break;
214          case VM_TYPE_C2600:
215             def_ram_size   = C2600_DEFAULT_RAM_SIZE;
216             def_rom_size   = C2600_DEFAULT_ROM_SIZE;
217             def_nvram_size = C2600_DEFAULT_NVRAM_SIZE;
218             def_conf_reg   = C2600_DEFAULT_CONF_REG;
219             def_clock_div  = C2600_DEFAULT_CLOCK_DIV;
220             def_disk0_size = C2600_DEFAULT_DISK0_SIZE;
221             def_disk1_size = C2600_DEFAULT_DISK1_SIZE;
222             def_nm_iomem_size = C2600_DEFAULT_IOMEM_SIZE;
223             break;
224          case VM_TYPE_MSFC1:
225             def_ram_size   = MSFC1_DEFAULT_RAM_SIZE;
226             def_rom_size   = MSFC1_DEFAULT_ROM_SIZE;
227             def_nvram_size = MSFC1_DEFAULT_NVRAM_SIZE;
228             def_conf_reg   = MSFC1_DEFAULT_CONF_REG;
229             def_clock_div  = MSFC1_DEFAULT_CLOCK_DIV;
230             break;
231          case VM_TYPE_PPC32_TEST:
232             def_ram_size   = PPC32_VMTEST_DEFAULT_RAM_SIZE;
233        default:        default:
234           fprintf(stderr,"show_usage: invalid platform.\n");           fprintf(stderr,"show_usage: invalid platform.\n");
235           return;           return;
# Line 235  static void show_usage(int argc,char *ar Line 261  static void show_usage(int argc,char *ar
261            "  -X                 : Do not use a file to simulate RAM (faster)\n"            "  -X                 : Do not use a file to simulate RAM (faster)\n"
262            "  -G <ghost_file>    : Use a ghost file to simulate RAM\n"            "  -G <ghost_file>    : Use a ghost file to simulate RAM\n"
263            "  -g <ghost_file>    : Generate a ghost RAM file\n"            "  -g <ghost_file>    : Generate a ghost RAM file\n"
264              "  --sparse-mem       : Use sparse memory\n"
265            "  -R <rom_file>      : Load an alternate ROM (default: embedded)\n"            "  -R <rom_file>      : Load an alternate ROM (default: embedded)\n"
266            "  -k <clock_div>     : Set the clock divisor (default: %d)\n"            "  -k <clock_div>     : Set the clock divisor (default: %d)\n"
267            "\n"            "\n"
# Line 298  static void show_usage(int argc,char *ar Line 325  static void show_usage(int argc,char *ar
325                  "Network Module\n",                  "Network Module\n",
326                  def_nm_iomem_size);                  def_nm_iomem_size);
327           break;           break;
328    
329          case VM_TYPE_C2600:
330             printf("  --iomem-size <val> : IO memory (in percents, default: %u)\n"
331                    "  -p <nm_desc>       : Define a Network Module\n"
332                    "  -s <nm_nio>        : Bind a Network IO interface to a "
333                    "Network Module\n",
334                    def_nm_iomem_size);
335             break;
336    
337          case VM_TYPE_MSFC1:
338             printf("  -s <pa_nio>        : Bind a Network IO interface to a "
339                    "Port Adapter\n");
340             break;
341    
342     }     }
343    
344     printf("\n"     printf("\n"
# Line 388  static void show_usage(int argc,char *ar Line 429  static void show_usage(int argc,char *ar
429           /* Show the possible NM drivers */           /* Show the possible NM drivers */
430           c3745_nm_show_drivers();           c3745_nm_show_drivers();
431           break;           break;
432    
433          case VM_TYPE_C2600:
434             printf("<nm_desc> format:\n"
435                    "   \"slot:nm_driver\"\n"
436                    "\n");
437    
438             printf("<nm_nio> format:\n"
439                    "   \"slot:port:netio_type{:netio_parameters}\"\n"
440                    "\n");
441    
442             /* Show the possible chassis types for C2600 platform */
443             c2600_mainboard_show_drivers();
444    
445             /* Show the possible NM drivers */
446             c2600_nm_show_drivers();
447             break;
448     }     }
449        
450     /* Show the possible NETIO types */     /* Show the possible NETIO types */
# Line 435  static int cli_get_platform_type(int arg Line 492  static int cli_get_platform_type(int arg
492           vm_type = VM_TYPE_C3725;           vm_type = VM_TYPE_C3725;
493        else if (!strcmp(str,"3745"))        else if (!strcmp(str,"3745"))
494           vm_type = VM_TYPE_C3745;           vm_type = VM_TYPE_C3745;
495          else if (!strcmp(str,"2600"))
496             vm_type = VM_TYPE_C2600;
497          else if (!strcmp(str,"MSFC1"))
498             vm_type = VM_TYPE_MSFC1;
499          else if (!strcmp(str,"PPC32_TEST"))
500             vm_type = VM_TYPE_PPC32_TEST;
501        else        else
502           fprintf(stderr,"Invalid platform type '%s'\n",str);           fprintf(stderr,"Invalid platform type '%s'\n",str);
503     }     }
# Line 450  static int cli_get_platform_type(int arg Line 513  static int cli_get_platform_type(int arg
513  #define OPT_TIMER_ITV   0x104  #define OPT_TIMER_ITV   0x104
514  #define OPT_VM_DEBUG    0x105  #define OPT_VM_DEBUG    0x105
515  #define OPT_IOMEM_SIZE  0x106  #define OPT_IOMEM_SIZE  0x106
516    #define OPT_SPARSE_MEM  0x107
517    
518  static struct option cmd_line_lopts[] = {  static struct option cmd_line_lopts[] = {
519     { "disk0"      , 1, NULL, OPT_DISK0_SIZE },     { "disk0"      , 1, NULL, OPT_DISK0_SIZE },
# Line 459  static struct option cmd_line_lopts[] = Line 523  static struct option cmd_line_lopts[] =
523     { "timer-itv"  , 1, NULL, OPT_TIMER_ITV },     { "timer-itv"  , 1, NULL, OPT_TIMER_ITV },
524     { "vm-debug"   , 1, NULL, OPT_VM_DEBUG },     { "vm-debug"   , 1, NULL, OPT_VM_DEBUG },
525     { "iomem-size" , 1, NULL, OPT_IOMEM_SIZE },     { "iomem-size" , 1, NULL, OPT_IOMEM_SIZE },
526       { "sparse-mem" , 0, NULL, OPT_SPARSE_MEM },
527     { NULL         , 0, NULL, 0 },     { NULL         , 0, NULL, 0 },
528  };  };
529    
# Line 623  static int cli_parse_c3745_options(vm_in Line 688  static int cli_parse_c3745_options(vm_in
688     return(0);     return(0);
689  }  }
690    
691    /* Parse specific options for the Cisco 2600 platform */
692    static int cli_parse_c2600_options(vm_instance_t *vm,int option)
693    {
694       c2600_t *router;
695    
696       router = VM_C2600(vm);
697    
698       switch(option) {
699          /* IO memory reserved for NMs (in percents!) */
700          case OPT_IOMEM_SIZE:
701             router->nm_iomem_size = 0x8000 | atoi(optarg);
702             break;
703    
704          /* Mainboard type */
705          case 't':
706             c2600_mainboard_set_type(router,optarg);
707             break;
708    
709          /* NM settings */
710          case 'p':
711             return(c2600_cmd_nm_create(router,optarg));
712    
713          /* NM NIO settings */
714          case 's':
715             return(c2600_cmd_add_nio(router,optarg));
716    
717          /* Unknown option */
718          default:
719             return(-1);
720       }
721    
722       return(0);
723    }
724    
725    /* Parse specific options for the MSFC1 platform */
726    static int cli_parse_msfc1_options(vm_instance_t *vm,int option)
727    {
728       msfc1_t *router;
729    
730       router = VM_MSFC1(vm);
731    
732       switch(option) {
733          /* PA NIO settings */
734          case 's':
735             return(msfc1_cmd_add_nio(router,optarg));
736    
737          /* Unknown option */
738          default:
739             return(-1);
740       }
741    
742       return(0);
743    }
744    
745  /* Create a router instance */  /* Create a router instance */
746  static vm_instance_t *cli_create_instance(char *name,int platform_type,  static vm_instance_t *cli_create_instance(char *name,int platform_type,
747                                            int instance_id)                                            int instance_id)
748  {  {
749       vm_instance_t *vm;
750     c7200_t *c7200;     c7200_t *c7200;
751     c3600_t *c3600;     c3600_t *c3600;
752     c2691_t *c2691;     c2691_t *c2691;
753     c3725_t *c3725;     c3725_t *c3725;
754     c3745_t *c3745;     c3745_t *c3745;
755       c2600_t *c2600;
756       msfc1_t *msfc1;
757    
758     switch(platform_type) {     switch(platform_type) {
759        case VM_TYPE_C7200:        case VM_TYPE_C7200:
# Line 669  static vm_instance_t *cli_create_instanc Line 791  static vm_instance_t *cli_create_instanc
791           }           }
792           return(c3745->vm);           return(c3745->vm);
793    
794          case VM_TYPE_C2600:
795             if (!(c2600 = c2600_create_instance(name,instance_id))) {
796                fprintf(stderr,"C2600: unable to create instance!\n");
797                return NULL;
798             }
799             return(c2600->vm);
800    
801          case VM_TYPE_MSFC1:
802             if (!(msfc1 = msfc1_create_instance(name,instance_id))) {
803                fprintf(stderr,"MSFC1: unable to create instance!\n");
804                return NULL;
805             }
806             return(msfc1->vm);
807    
808          case VM_TYPE_PPC32_TEST:
809             if (!(vm = ppc32_vmtest_create_instance(name,instance_id))) {
810                fprintf(stderr,"PPC32_TEST: unable to create instance!\n");
811                return NULL;
812             }
813             return(vm);
814    
815        default:        default:
816           fprintf(stderr,"Unknown platform type '%d'!\n",platform_type);           fprintf(stderr,"Unknown platform type '%d'!\n",platform_type);
817           return NULL;           return NULL;
# Line 786  static int parse_std_cmd_line(int argc,c Line 929  static int parse_std_cmd_line(int argc,c
929              vm->ghost_status = VM_GHOST_RAM_GENERATE;              vm->ghost_status = VM_GHOST_RAM_GENERATE;
930              break;              break;
931    
932             /* Use sparse memory */
933             case OPT_SPARSE_MEM:
934                vm->sparse_mem = TRUE;
935                break;
936    
937           /* Alternate ROM */           /* Alternate ROM */
938           case 'R':           case 'R':
939              vm->rom_filename = optarg;              vm->rom_filename = optarg;
# Line 927  static int parse_std_cmd_line(int argc,c Line 1075  static int parse_std_cmd_line(int argc,c
1075                case VM_TYPE_C3745:                case VM_TYPE_C3745:
1076                    res = cli_parse_c3745_options(vm,option);                    res = cli_parse_c3745_options(vm,option);
1077                    break;                    break;
1078                  case VM_TYPE_C2600:
1079                      res = cli_parse_c2600_options(vm,option);
1080                      break;
1081                  case VM_TYPE_MSFC1:
1082                      res = cli_parse_msfc1_options(vm,option);
1083                      break;
1084              }              }
1085    
1086              if (res == -1)              if (res == -1)
# Line 1014  void dynamips_reset(void) Line 1168  void dynamips_reset(void)
1168     c2691_delete_all_instances();     c2691_delete_all_instances();
1169     c3725_delete_all_instances();     c3725_delete_all_instances();
1170     c3745_delete_all_instances();     c3745_delete_all_instances();
1171       c2600_delete_all_instances();
1172       msfc1_delete_all_instances();
1173       ppc32_vmtest_delete_all_instances();
1174    
1175     /* Delete ATM and Frame-Relay switches + bridges */     /* Delete ATM and Frame-Relay switches + bridges */
1176     netio_bridge_delete_all();     netio_bridge_delete_all();
# Line 1039  int main(int argc,char *argv[]) Line 1196  int main(int argc,char *argv[])
1196     atexit(profiler_savestat);     atexit(profiler_savestat);
1197  #endif  #endif
1198    
1199     printf("Cisco 7200 Simulation Platform (version %s)\n",sw_version);     printf("Cisco Router Simulation Platform (version %s)\n",sw_version);
1200     printf("Copyright (c) 2005,2006 Christophe Fillot.\n");     printf("Copyright (c) 2005-2007 Christophe Fillot.\n");
1201     printf("Build date: %s %s\n\n",__DATE__,__TIME__);     printf("Build date: %s %s\n\n",__DATE__,__TIME__);
1202    
1203     /* Initialize timers */     /* Initialize timers */
# Line 1078  int main(int argc,char *argv[]) Line 1235  int main(int argc,char *argv[])
1235     /* Create instruction lookup tables */     /* Create instruction lookup tables */
1236     mips64_jit_create_ilt();     mips64_jit_create_ilt();
1237     mips64_exec_create_ilt();     mips64_exec_create_ilt();
1238       ppc32_jit_create_ilt();
1239       ppc32_exec_create_ilt();
1240    
1241     setup_signals();     setup_signals();
1242    
# Line 1102  int main(int argc,char *argv[]) Line 1261  int main(int argc,char *argv[])
1261           case VM_TYPE_C3745:           case VM_TYPE_C3745:
1262              res = c3745_init_instance(VM_C3745(vm));              res = c3745_init_instance(VM_C3745(vm));
1263              break;              break;
1264             case VM_TYPE_C2600:
1265                res = c2600_init_instance(VM_C2600(vm));
1266                break;
1267             case VM_TYPE_MSFC1:
1268                res = msfc1_init_instance(VM_MSFC1(vm));
1269                break;
1270             case VM_TYPE_PPC32_TEST:
1271                res = ppc32_vmtest_init_instance(vm);
1272                break;
1273           default:           default:
1274              res = -1;              res = -1;
1275        }        }
# Line 1111  int main(int argc,char *argv[]) Line 1279  int main(int argc,char *argv[])
1279           exit(EXIT_FAILURE);           exit(EXIT_FAILURE);
1280        }        }
1281    
1282  #if DEBUG_PERF_COUNTER  #if (DEBUG_INSN_PERF_CNT > 0) || (DEBUG_BLOCK_PERF_CNT > 0)
1283        {        {
1284           m_uint64_t prev = 0,delta;           m_uint64_t counter,prev = 0,delta;
1285           while(vm->status == VM_STATUS_RUNNING) {           while(vm->status == VM_STATUS_RUNNING) {
1286              delta = vm->boot_cpu->perf_counter - prev;              counter = cpu_get_perf_counter(vm->boot_cpu);
1287              prev = vm->boot_cpu->perf_counter;              delta = counter - prev;
1288                prev = counter;
1289              printf("delta = %llu\n",delta);              printf("delta = %llu\n",delta);
1290              sleep(1);              sleep(1);
1291           }           }

Legend:
Removed from v.4  
changed lines
  Added in v.8

  ViewVC Help
Powered by ViewVC 1.1.26