/[dynamips]/upstream/dynamips-0.2.6-RC3/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.6-RC3/dynamips.c

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

upstream/dynamips-0.2.6-RC2/dynamips.c revision 3 by dpavlin, Sat Oct 6 16:05:34 2007 UTC upstream/dynamips-0.2.6-RC3/dynamips.c revision 4 by dpavlin, Sat Oct 6 16:06:49 2007 UTC
# Line 27  Line 27 
27  #include "mips64_exec.h"  #include "mips64_exec.h"
28  #include "dev_c7200.h"  #include "dev_c7200.h"
29  #include "dev_c3600.h"  #include "dev_c3600.h"
30    #include "dev_c2691.h"
31    #include "dev_c3725.h"
32    #include "dev_c3745.h"
33  #include "dev_vtty.h"  #include "dev_vtty.h"
34  #include "ptask.h"  #include "ptask.h"
35  #include "timer.h"  #include "timer.h"
# Line 171  static void show_usage(int argc,char *ar Line 174  static void show_usage(int argc,char *ar
174           def_disk1_size = C3600_DEFAULT_DISK1_SIZE;           def_disk1_size = C3600_DEFAULT_DISK1_SIZE;
175           def_nm_iomem_size = C3600_DEFAULT_IOMEM_SIZE;           def_nm_iomem_size = C3600_DEFAULT_IOMEM_SIZE;
176           break;           break;
177          case VM_TYPE_C2691:
178             def_ram_size   = C2691_DEFAULT_RAM_SIZE;
179             def_rom_size   = C2691_DEFAULT_ROM_SIZE;
180             def_nvram_size = C2691_DEFAULT_NVRAM_SIZE;
181             def_conf_reg   = C2691_DEFAULT_CONF_REG;
182             def_clock_div  = C2691_DEFAULT_CLOCK_DIV;
183             def_disk0_size = C2691_DEFAULT_DISK0_SIZE;
184             def_disk1_size = C2691_DEFAULT_DISK1_SIZE;
185             def_nm_iomem_size = C2691_DEFAULT_IOMEM_SIZE;
186             break;
187          case VM_TYPE_C3725:
188             def_ram_size   = C3725_DEFAULT_RAM_SIZE;
189             def_rom_size   = C3725_DEFAULT_ROM_SIZE;
190             def_nvram_size = C3725_DEFAULT_NVRAM_SIZE;
191             def_conf_reg   = C3725_DEFAULT_CONF_REG;
192             def_clock_div  = C3725_DEFAULT_CLOCK_DIV;
193             def_disk0_size = C3725_DEFAULT_DISK0_SIZE;
194             def_disk1_size = C3725_DEFAULT_DISK1_SIZE;
195             def_nm_iomem_size = C3725_DEFAULT_IOMEM_SIZE;
196             break;
197          case VM_TYPE_C3745:
198             def_ram_size   = C3745_DEFAULT_RAM_SIZE;
199             def_rom_size   = C3745_DEFAULT_ROM_SIZE;
200             def_nvram_size = C3745_DEFAULT_NVRAM_SIZE;
201             def_conf_reg   = C3745_DEFAULT_CONF_REG;
202             def_clock_div  = C3745_DEFAULT_CLOCK_DIV;
203             def_disk0_size = C3745_DEFAULT_DISK0_SIZE;
204             def_disk1_size = C3745_DEFAULT_DISK1_SIZE;
205             def_nm_iomem_size = C3745_DEFAULT_IOMEM_SIZE;
206             break;
207        default:        default:
208           fprintf(stderr,"show_usage: invalid platform.\n");           fprintf(stderr,"show_usage: invalid platform.\n");
209           return;           return;
# Line 180  static void show_usage(int argc,char *ar Line 213  static void show_usage(int argc,char *ar
213        
214     printf("Available options:\n"     printf("Available options:\n"
215            "  -H <tcp_port>      : Run in hypervisor mode\n\n"            "  -H <tcp_port>      : Run in hypervisor mode\n\n"
216            "  -P <platform>      : Platform to emulate (7200 or 3600) "            "  -P <platform>      : Platform to emulate (7200, 3600, "
217              "2691, 3725 or 3745) "
218            "(default: 7200)\n\n"            "(default: 7200)\n\n"
219            "  -l <log_file>      : Set logging file (default is %s)\n"            "  -l <log_file>      : Set logging file (default is %s)\n"
220            "  -j                 : Disable the JIT compiler, very slow\n"            "  -j                 : Disable the JIT compiler, very slow\n"
# Line 199  static void show_usage(int argc,char *ar Line 233  static void show_usage(int argc,char *ar
233            "  -C <cfg_file>      : Import an IOS configuration file "            "  -C <cfg_file>      : Import an IOS configuration file "
234            "into NVRAM\n"            "into NVRAM\n"
235            "  -X                 : Do not use a file to simulate RAM (faster)\n"            "  -X                 : Do not use a file to simulate RAM (faster)\n"
236              "  -G <ghost_file>    : Use a ghost file to simulate RAM\n"
237              "  -g <ghost_file>    : Generate a ghost RAM file\n"
238            "  -R <rom_file>      : Load an alternate ROM (default: embedded)\n"            "  -R <rom_file>      : Load an alternate ROM (default: embedded)\n"
239            "  -k <clock_div>     : Set the clock divisor (default: %d)\n"            "  -k <clock_div>     : Set the clock divisor (default: %d)\n"
240            "\n"            "\n"
# Line 238  static void show_usage(int argc,char *ar Line 274  static void show_usage(int argc,char *ar
274                  "Network Module\n",                  "Network Module\n",
275                  C3600_DEFAULT_CHASSIS,def_nm_iomem_size);                  C3600_DEFAULT_CHASSIS,def_nm_iomem_size);
276           break;           break;
277    
278          case VM_TYPE_C2691:
279             printf("  --iomem-size <val> : IO memory (in percents, default: %u)\n"
280                    "  -p <nm_desc>       : Define a Network Module\n"
281                    "  -s <nm_nio>        : Bind a Network IO interface to a "
282                    "Network Module\n",
283                    def_nm_iomem_size);
284             break;
285    
286          case VM_TYPE_C3725:
287             printf("  --iomem-size <val> : IO memory (in percents, default: %u)\n"
288                    "  -p <nm_desc>       : Define a Network Module\n"
289                    "  -s <nm_nio>        : Bind a Network IO interface to a "
290                    "Network Module\n",
291                    def_nm_iomem_size);
292             break;
293    
294          case VM_TYPE_C3745:
295             printf("  --iomem-size <val> : IO memory (in percents, default: %u)\n"
296                    "  -p <nm_desc>       : Define a Network Module\n"
297                    "  -s <nm_nio>        : Bind a Network IO interface to a "
298                    "Network Module\n",
299                    def_nm_iomem_size);
300             break;
301     }     }
302    
303     printf("\n"     printf("\n"
# Line 286  static void show_usage(int argc,char *ar Line 346  static void show_usage(int argc,char *ar
346           /* Show the possible chassis types for C3600 platform */           /* Show the possible chassis types for C3600 platform */
347           c3600_chassis_show_drivers();           c3600_chassis_show_drivers();
348    
349           /* Show the possible PA drivers */           /* Show the possible NM drivers */
350           c3600_nm_show_drivers();           c3600_nm_show_drivers();
351           break;           break;
352    
353          case VM_TYPE_C2691:
354             printf("<nm_desc> format:\n"
355                    "   \"slot:nm_driver\"\n"
356                    "\n");
357    
358             printf("<nm_nio> format:\n"
359                    "   \"slot:port:netio_type{:netio_parameters}\"\n"
360                    "\n");
361    
362             /* Show the possible NM drivers */
363             c2691_nm_show_drivers();
364             break;
365    
366          case VM_TYPE_C3725:
367             printf("<nm_desc> format:\n"
368                    "   \"slot:nm_driver\"\n"
369                    "\n");
370    
371             printf("<nm_nio> format:\n"
372                    "   \"slot:port:netio_type{:netio_parameters}\"\n"
373                    "\n");
374    
375             /* Show the possible NM drivers */
376             c3725_nm_show_drivers();
377             break;
378    
379          case VM_TYPE_C3745:
380             printf("<nm_desc> format:\n"
381                    "   \"slot:nm_driver\"\n"
382                    "\n");
383    
384             printf("<nm_nio> format:\n"
385                    "   \"slot:port:netio_type{:netio_parameters}\"\n"
386                    "\n");
387    
388             /* Show the possible NM drivers */
389             c3745_nm_show_drivers();
390             break;
391     }     }
392        
393     /* Show the possible NETIO types */     /* Show the possible NETIO types */
# Line 330  static int cli_get_platform_type(int arg Line 429  static int cli_get_platform_type(int arg
429           vm_type = VM_TYPE_C3600;           vm_type = VM_TYPE_C3600;
430        else if (!strcmp(str,"7200"))        else if (!strcmp(str,"7200"))
431           vm_type = VM_TYPE_C7200;           vm_type = VM_TYPE_C7200;
432          else if (!strcmp(str,"2691"))
433             vm_type = VM_TYPE_C2691;
434          else if (!strcmp(str,"3725"))
435             vm_type = VM_TYPE_C3725;
436          else if (!strcmp(str,"3745"))
437             vm_type = VM_TYPE_C3745;
438        else        else
439           fprintf(stderr,"Invalid platform type '%s'\n",str);           fprintf(stderr,"Invalid platform type '%s'\n",str);
440     }     }
# Line 431  static int cli_parse_c3600_options(vm_in Line 536  static int cli_parse_c3600_options(vm_in
536     return(0);     return(0);
537  }  }
538    
539    /* Parse specific options for the Cisco 2691 platform */
540    static int cli_parse_c2691_options(vm_instance_t *vm,int option)
541    {
542       c2691_t *router;
543    
544       router = VM_C2691(vm);
545    
546       switch(option) {
547          /* IO memory reserved for NMs (in percents!) */
548          case OPT_IOMEM_SIZE:
549             router->nm_iomem_size = 0x8000 | atoi(optarg);
550             break;
551    
552          /* NM settings */
553          case 'p':
554             return(c2691_cmd_nm_create(router,optarg));
555    
556          /* NM NIO settings */
557          case 's':
558             return(c2691_cmd_add_nio(router,optarg));
559    
560          /* Unknown option */
561          default:
562             return(-1);
563       }
564    
565       return(0);
566    }
567    
568    /* Parse specific options for the Cisco 3725 platform */
569    static int cli_parse_c3725_options(vm_instance_t *vm,int option)
570    {
571       c3725_t *router;
572    
573       router = VM_C3725(vm);
574    
575       switch(option) {
576          /* IO memory reserved for NMs (in percents!) */
577          case OPT_IOMEM_SIZE:
578             router->nm_iomem_size = 0x8000 | atoi(optarg);
579             break;
580    
581          /* NM settings */
582          case 'p':
583             return(c3725_cmd_nm_create(router,optarg));
584    
585          /* NM NIO settings */
586          case 's':
587             return(c3725_cmd_add_nio(router,optarg));
588    
589          /* Unknown option */
590          default:
591             return(-1);
592       }
593    
594       return(0);
595    }
596    
597    /* Parse specific options for the Cisco 3745 platform */
598    static int cli_parse_c3745_options(vm_instance_t *vm,int option)
599    {
600       c3745_t *router;
601    
602       router = VM_C3745(vm);
603    
604       switch(option) {
605          /* IO memory reserved for NMs (in percents!) */
606          case OPT_IOMEM_SIZE:
607             router->nm_iomem_size = 0x8000 | atoi(optarg);
608             break;
609    
610          /* NM settings */
611          case 'p':
612             return(c3745_cmd_nm_create(router,optarg));
613    
614          /* NM NIO settings */
615          case 's':
616             return(c3745_cmd_add_nio(router,optarg));
617    
618          /* Unknown option */
619          default:
620             return(-1);
621       }
622    
623       return(0);
624    }
625    
626  /* Create a router instance */  /* Create a router instance */
627  static vm_instance_t *cli_create_instance(char *name,int platform_type,  static vm_instance_t *cli_create_instance(char *name,int platform_type,
628                                            int instance_id)                                            int instance_id)
629  {  {
630     c7200_t *c7200;     c7200_t *c7200;
631     c3600_t *c3600;     c3600_t *c3600;
632       c2691_t *c2691;
633       c3725_t *c3725;
634       c3745_t *c3745;
635    
636     switch(platform_type) {     switch(platform_type) {
637        case VM_TYPE_C7200:        case VM_TYPE_C7200:
# Line 453  static vm_instance_t *cli_create_instanc Line 648  static vm_instance_t *cli_create_instanc
648           }           }
649           return(c3600->vm);           return(c3600->vm);
650    
651          case VM_TYPE_C2691:
652             if (!(c2691 = c2691_create_instance(name,instance_id))) {
653                fprintf(stderr,"C2691: unable to create instance!\n");
654                return NULL;
655             }
656             return(c2691->vm);
657    
658          case VM_TYPE_C3725:
659             if (!(c3725 = c3725_create_instance(name,instance_id))) {
660                fprintf(stderr,"C3725: unable to create instance!\n");
661                return NULL;
662             }
663             return(c3725->vm);
664    
665          case VM_TYPE_C3745:
666             if (!(c3745 = c3745_create_instance(name,instance_id))) {
667                fprintf(stderr,"C3745: unable to create instance!\n");
668                return NULL;
669             }
670             return(c3745->vm);
671    
672        default:        default:
673           fprintf(stderr,"Unknown platform type '%d'!\n",platform_type);           fprintf(stderr,"Unknown platform type '%d'!\n",platform_type);
674           return NULL;           return NULL;
# Line 463  static vm_instance_t *cli_create_instanc Line 679  static vm_instance_t *cli_create_instanc
679  static int parse_std_cmd_line(int argc,char *argv[],int *platform)  static int parse_std_cmd_line(int argc,char *argv[],int *platform)
680  {  {
681     char *options_list =     char *options_list =
682        "r:o:n:c:m:l:C:i:jt:p:s:k:T:U:A:B:a:f:E:b:S:R:M:eXP:N:";        "r:o:n:c:m:l:C:i:jt:p:s:k:T:U:A:B:a:f:E:b:S:R:M:eXP:N:G:g:";
683     vm_instance_t *vm;     vm_instance_t *vm;
684     int instance_id;     int instance_id;
685     int res,option;     int res,option;
# Line 558  static int parse_std_cmd_line(int argc,c Line 774  static int parse_std_cmd_line(int argc,c
774              vm->ram_mmap = 0;              vm->ram_mmap = 0;
775              break;              break;
776    
777             /* Use a ghost file to simulate RAM */          
778             case 'G':
779                vm->ghost_ram_filename = strdup(optarg);
780                vm->ghost_status = VM_GHOST_RAM_USE;
781                break;
782    
783             /* Generate a ghost RAM image */
784             case 'g':
785                vm->ghost_ram_filename = strdup(optarg);
786                vm->ghost_status = VM_GHOST_RAM_GENERATE;
787                break;
788    
789           /* Alternate ROM */           /* Alternate ROM */
790           case 'R':           case 'R':
791              vm->rom_filename = optarg;              vm->rom_filename = optarg;
# Line 689  static int parse_std_cmd_line(int argc,c Line 917  static int parse_std_cmd_line(int argc,c
917                    break;                    break;
918                 case VM_TYPE_C3600:                 case VM_TYPE_C3600:
919                    res = cli_parse_c3600_options(vm,option);                    res = cli_parse_c3600_options(vm,option);
920                      break;              
921                   case VM_TYPE_C2691:
922                      res = cli_parse_c2691_options(vm,option);
923                      break;
924                   case VM_TYPE_C3725:
925                      res = cli_parse_c3725_options(vm,option);
926                      break;
927                  case VM_TYPE_C3745:
928                      res = cli_parse_c3745_options(vm,option);
929                    break;                    break;
930              }              }
931    
# Line 771  void dynamips_reset(void) Line 1008  void dynamips_reset(void)
1008  {  {
1009     printf("Shutdown in progress...\n");     printf("Shutdown in progress...\n");
1010    
1011     /* Delete all C7200 and C3600 instances */     /* Delete all virtual router instances */
1012     c7200_delete_all_instances();     c7200_delete_all_instances();
1013     c3600_delete_all_instances();     c3600_delete_all_instances();
1014       c2691_delete_all_instances();
1015       c3725_delete_all_instances();
1016       c3745_delete_all_instances();
1017    
1018     /* Delete ATM and Frame-Relay switches + bridges */     /* Delete ATM and Frame-Relay switches + bridges */
1019     netio_bridge_delete_all();     netio_bridge_delete_all();
# Line 800  int main(int argc,char *argv[]) Line 1040  int main(int argc,char *argv[])
1040  #endif  #endif
1041    
1042     printf("Cisco 7200 Simulation Platform (version %s)\n",sw_version);     printf("Cisco 7200 Simulation Platform (version %s)\n",sw_version);
1043     printf("Copyright (c) 2005,2006 Christophe Fillot.\n\n");     printf("Copyright (c) 2005,2006 Christophe Fillot.\n");
1044       printf("Build date: %s %s\n\n",__DATE__,__TIME__);
1045    
1046     /* Initialize timers */     /* Initialize timers */
1047     timer_init();     timer_init();
# Line 851  int main(int argc,char *argv[]) Line 1092  int main(int argc,char *argv[])
1092              break;              break;
1093           case VM_TYPE_C3600:           case VM_TYPE_C3600:
1094              res = c3600_init_instance(VM_C3600(vm));              res = c3600_init_instance(VM_C3600(vm));
1095                break;      
1096             case VM_TYPE_C2691:
1097                res = c2691_init_instance(VM_C2691(vm));
1098                break;
1099             case VM_TYPE_C3725:
1100                res = c3725_init_instance(VM_C3725(vm));
1101                break;
1102             case VM_TYPE_C3745:
1103                res = c3745_init_instance(VM_C3745(vm));
1104              break;              break;
1105           default:           default:
1106              res = -1;              res = -1;

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

  ViewVC Help
Powered by ViewVC 1.1.26