/[gxemul]/trunk/src/main.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 /trunk/src/main.c

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

revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC revision 44 by dpavlin, Mon Oct 8 16:22:56 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: main.c,v 1.284 2006/09/19 10:50:08 debug Exp $   *  $Id: main.c,v 1.311 2007/06/28 14:58:38 debug Exp $
29   */   */
30    
31  #include <stdio.h>  #include <stdio.h>
# Line 45  Line 45 
45  #include "misc.h"  #include "misc.h"
46  #include "settings.h"  #include "settings.h"
47  #include "timer.h"  #include "timer.h"
48    #include "useremul.h"
49    
50    
51  extern volatile int single_step;  extern int single_step;
52  extern int force_debugger_at_exit;  extern int force_debugger_at_exit;
53    
54  extern int optind;  extern int optind;
# Line 59  int extra_argc; Line 60  int extra_argc;
60  char **extra_argv;  char **extra_argv;
61  char *progname;  char *progname;
62    
63  int skip_srandom_call = 0;  size_t dyntrans_cache_size = DEFAULT_DYNTRANS_CACHE_SIZE;
64    static int skip_srandom_call = 0;
65    
66    
67  /*****************************************************************************  /*****************************************************************************
# Line 194  void internal_w(char *arg) Line 196  void internal_w(char *arg)
196   */   */
197  static void usage(int longusage)  static void usage(int longusage)
198  {  {
199          printf("GXemul");          printf("GXemul "VERSION"    Copyright (C) 2003-2007  Anders Gavare\n");
 #ifdef VERSION  
         printf(" " VERSION);  
 #endif  
         printf("    Copyright (C) 2003-2006  Anders Gavare\n");  
200          printf("Read the source code and/or documentation for "          printf("Read the source code and/or documentation for "
201              "other Copyright messages.\n");              "other Copyright messages.\n");
202    
203          printf("\nusage: %s [machine, other, and general options] [file "          printf("\nusage: %s [machine, other, and general options] [file "
204              "[...]]\n", progname);              "[...]]\n", progname);
205          printf("   or  %s [general options] @configfile\n", progname);          printf("   or  %s [general options] @configfile\n", progname);
 #ifdef UNSTABLE_DEVEL  
206          printf("   or  %s [userland, other, and general options] file "          printf("   or  %s [userland, other, and general options] file "
207              "[args ...]\n", progname);              "[args ...]\n", progname);
 #endif  
208    
209          if (!longusage) {          if (!longusage) {
210                  printf("\nRun  %s -h  for help on command line options.\n",                  printf("\nRun  %s -h  for help on command line options.\n",
# Line 236  static void usage(int longusage) Line 232  static void usage(int longusage)
232          printf("                gH;S;  set geometry to H heads and S"          printf("                gH;S;  set geometry to H heads and S"
233              " sectors-per-track\n");              " sectors-per-track\n");
234          printf("                i      IDE\n");          printf("                i      IDE\n");
235            printf("                oOFS;  set base offset to OFS (for ISO9660"
236                " filesystems)\n");
237          printf("                r      read-only (don't allow changes to the"          printf("                r      read-only (don't allow changes to the"
238              " file)\n");              " file)\n");
239          printf("                s      SCSI\n");          printf("                s      SCSI\n");
240          printf("                t      tape\n");          printf("                t      tape\n");
241            printf("                V      add an overlay\n");
242          printf("                0-7    force a specific ID\n");          printf("                0-7    force a specific ID\n");
         printf("  -G port   listen to gdb remote connections on this port\n");  
243          printf("  -I hz     set the main cpu frequency to hz (not used by "          printf("  -I hz     set the main cpu frequency to hz (not used by "
244              "all combinations\n            of machines and guest OSes)");              "all combinations\n            of machines and guest OSes)\n");
245          printf("  -i        display each instruction as it is executed\n");          printf("  -i        display each instruction as it is executed\n");
246          printf("  -J        disable dyntrans instruction combinations\n");          printf("  -J        disable dyntrans instruction combinations\n");
247          printf("  -j name   set the name of the kernel; for DECstation "          printf("  -j name   set the name of the kernel; for DECstation "
# Line 284  static void usage(int longusage) Line 282  static void usage(int longusage)
282          printf("                d    disable statistics gathering at "          printf("                d    disable statistics gathering at "
283              "startup\n");              "startup\n");
284          printf("                o    overwrite instead of append\n");          printf("                o    overwrite instead of append\n");
285            printf("  -T        halt on non-existant memory accesses\n");
286          printf("  -t        show function trace tree\n");          printf("  -t        show function trace tree\n");
287          printf("  -U        enable slow_serial_interrupts_hack_for_linux\n");          printf("  -U        enable slow_serial_interrupts_hack_for_linux\n");
288  #ifdef WITH_X11  #ifdef WITH_X11
# Line 299  static void usage(int longusage) Line 298  static void usage(int longusage)
298          printf("  -z disp   add disp as an X11 display to use for "          printf("  -z disp   add disp as an X11 display to use for "
299              "framebuffers\n");              "framebuffers\n");
300    
 #ifdef UNSTABLE_DEVEL  
301          printf("\nUserland options:\n");          printf("\nUserland options:\n");
302          printf("  -u emul   userland-only (syscall) emulation (use -H to"          printf("  -u emul   userland-only (syscall) emulation (use -H to"
303              " get a list of\n            available emulation modes)\n");              " get a list of\n            available emulation modes)\n");
 #endif  
304    
305          printf("\nGeneral options:\n");          printf("\nGeneral options:\n");
306          printf("  -c cmd    add cmd as a command to run before starting "          printf("  -c cmd    add cmd as a command to run before starting "
# Line 312  static void usage(int longusage) Line 309  static void usage(int longusage)
309          printf("  -H        display a list of possible CPU and "          printf("  -H        display a list of possible CPU and "
310              "machine types\n");              "machine types\n");
311          printf("  -h        display this help message\n");          printf("  -h        display this help message\n");
312            printf("  -k n      set dyntrans translation caches to n MB (default"
313                " size is %i MB)\n", DEFAULT_DYNTRANS_CACHE_SIZE / 1048576);
314          printf("  -K        force the debugger to be entered at the end "          printf("  -K        force the debugger to be entered at the end "
315              "of a simulation\n");              "of a simulation\n");
316          printf("  -q        quiet mode (don't print startup messages)\n");          printf("  -q        quiet mode (don't print startup messages)\n");
# Line 327  static void usage(int longusage) Line 326  static void usage(int longusage)
326              "To load a raw binary into memory, add \"address:\" in front "              "To load a raw binary into memory, add \"address:\" in front "
327              "of the filename,\n"              "of the filename,\n"
328              "or \"address:skiplen:\" or \"address:skiplen:initialpc:\".\n"              "or \"address:skiplen:\" or \"address:skiplen:initialpc:\".\n"
329              "Examples:\n"              "\nExamples:\n"
330              "    0xbfc00000:rom.bin                    for a raw ROM image\n"              "    0xbfc00000:rom.bin                    for a raw ROM image\n"
331              "    0xbfc00000:0x100:rom.bin              for an image with "              "    0xbfc00000:0x100:rom.bin              for an image with "
332              "0x100 bytes header\n"              "0x100 bytes header\n"
333              "    0xbfc00000:0x100:0xbfc00884:rom.bin   "              "    0xbfc00000:0x100:0xbfc00884:rom.bin   "
334              "start with pc=0xbfc00884\n");              "start with pc=0xbfc00884\n\n");
335  }  }
336    
337    
# Line 349  int get_cmd_args(int argc, char *argv[], Line 348  int get_cmd_args(int argc, char *argv[],
348          char *type = NULL, *subtype = NULL;          char *type = NULL, *subtype = NULL;
349          int n_cpus_set = 0;          int n_cpus_set = 0;
350          int msopts = 0;         /*  Machine-specific options used  */          int msopts = 0;         /*  Machine-specific options used  */
351          struct machine *m = emul_add_machine(emul, "default");          struct machine *m = emul_add_machine(emul, NULL);
352    
353          char *opts =          char *opts =
354              "C:c:Dd:E:e:G:HhI:iJj:KM:Nn:Oo:p:QqRrSs:tU"              "C:c:Dd:E:e:HhI:iJj:k:KM:Nn:Oo:p:QqRrSs:TtUu:VvW:"
 #ifdef UNSTABLE_DEVEL  
             "u:"  
 #endif  
             "VvW:"  
355  #ifdef WITH_X11  #ifdef WITH_X11
356              "XxY:"              "XxY:"
357  #endif  #endif
# Line 365  int get_cmd_args(int argc, char *argv[], Line 360  int get_cmd_args(int argc, char *argv[],
360          while ((ch = getopt(argc, argv, opts)) != -1) {          while ((ch = getopt(argc, argv, opts)) != -1) {
361                  switch (ch) {                  switch (ch) {
362                  case 'C':                  case 'C':
363                          m->cpu_name = strdup(optarg);                          CHECK_ALLOCATION(m->cpu_name = strdup(optarg));
364                          msopts = 1;                          msopts = 1;
365                          break;                          break;
366                  case 'c':                  case 'c':
367                          emul->n_debugger_cmds ++;                          emul->n_debugger_cmds ++;
368                          emul->debugger_cmds = realloc(emul->debugger_cmds,                          CHECK_ALLOCATION(emul->debugger_cmds =
369                              emul->n_debugger_cmds * sizeof(char *));                              realloc(emul->debugger_cmds,
370                          if (emul->debugger_cmds == NULL) {                              emul->n_debugger_cmds * sizeof(char *)));
371                                  fatal("out of memory\n");                          CHECK_ALLOCATION(emul->debugger_cmds[emul->
372                                  exit(1);                              n_debugger_cmds-1] = strdup(optarg));
                         }  
                         emul->debugger_cmds[emul->n_debugger_cmds-1] =  
                             strdup(optarg);  
373                          break;                          break;
374                  case 'D':                  case 'D':
375                          skip_srandom_call = 1;                          skip_srandom_call = 1;
# Line 385  int get_cmd_args(int argc, char *argv[], Line 377  int get_cmd_args(int argc, char *argv[],
377                  case 'd':                  case 'd':
378                          /*  diskimage_add() is called further down  */                          /*  diskimage_add() is called further down  */
379                          (*n_diskimagesp) ++;                          (*n_diskimagesp) ++;
380                          (*diskimagesp) = realloc(*diskimagesp,                          CHECK_ALLOCATION( (*diskimagesp) =
381                              sizeof(char *) * (*n_diskimagesp));                              realloc(*diskimagesp,
382                          if (*diskimagesp == NULL) {                              sizeof(char *) * (*n_diskimagesp)) );
383                                  fprintf(stderr, "out of memory\n");                          CHECK_ALLOCATION( (*diskimagesp)[(*n_diskimagesp) - 1] =
384                                  exit(1);                              strdup(optarg) );
                         }  
                         (*diskimagesp)[(*n_diskimagesp) - 1] = strdup(optarg);  
385                          using_switch_d = 1;                          using_switch_d = 1;
386                          msopts = 1;                          msopts = 1;
387                          break;                          break;
# Line 411  int get_cmd_args(int argc, char *argv[], Line 401  int get_cmd_args(int argc, char *argv[],
401                          subtype = optarg;                          subtype = optarg;
402                          msopts = 1;                          msopts = 1;
403                          break;                          break;
                 case 'G':  
                         m->gdb.port = atoi(optarg);  
                         if (m->gdb.port < 1 || m->gdb.port > 65535) {  
                                 fprintf(stderr, "Invalid debugger port %i.\n",  
                                     m->gdb.port);  
                                 exit(1);  
                         }  
                         /*  Note: implicit -V  */  
                         single_step = ENTER_SINGLE_STEPPING;  
                         msopts = 1;  
                         break;  
404                  case 'H':                  case 'H':
405                          machine_list_available_types_and_cpus();                          machine_list_available_types_and_cpus();
406                          exit(1);                          exit(1);
# Line 441  int get_cmd_args(int argc, char *argv[], Line 420  int get_cmd_args(int argc, char *argv[],
420                          msopts = 1;                          msopts = 1;
421                          break;                          break;
422                  case 'j':                  case 'j':
423                          m->boot_kernel_filename = strdup(optarg);                          CHECK_ALLOCATION(m->boot_kernel_filename =
424                          if (m->boot_kernel_filename == NULL) {                              strdup(optarg));
425                                  fprintf(stderr, "out of memory\n");                          msopts = 1;
426                            break;
427                    case 'k':
428                            dyntrans_cache_size = atoi(optarg) * 1048576;
429                            if (dyntrans_cache_size < 1) {
430                                    fprintf(stderr, "The dyntrans cache size must"
431                                        " be at least 1 MB.\n");
432                                  exit(1);                                  exit(1);
433                          }                          }
                         msopts = 1;  
434                          break;                          break;
435                  case 'K':                  case 'K':
436                          force_debugger_at_exit = 1;                          force_debugger_at_exit = 1;
# Line 469  int get_cmd_args(int argc, char *argv[], Line 453  int get_cmd_args(int argc, char *argv[],
453                          msopts = 1;                          msopts = 1;
454                          break;                          break;
455                  case 'o':                  case 'o':
456                          m->boot_string_argument = strdup(optarg);                          CHECK_ALLOCATION(m->boot_string_argument =
457                          if (m->boot_string_argument == NULL) {                              strdup(optarg));
                                 fprintf(stderr, "out of memory\n");  
                                 exit(1);  
                         }  
458                          msopts = 1;                          msopts = 1;
459                          break;                          break;
460                  case 'p':                  case 'p':
461                          if (m->n_breakpoints >= MAX_BREAKPOINTS) {                          machine_add_breakpoint_string(m, optarg);
                                 fprintf(stderr, "too many breakpoints\n");  
                                 exit(1);  
                         }  
                         m->breakpoint_string[m->n_breakpoints] = strdup(optarg);  
                         if (m->breakpoint_string[m->n_breakpoints] == NULL) {  
                                 fprintf(stderr, "out of memory\n");  
                                 exit(1);  
                         }  
                         m->breakpoint_flags[m->n_breakpoints] = 0;  
                         m->n_breakpoints ++;  
462                          msopts = 1;                          msopts = 1;
463                          break;                          break;
464                  case 'Q':                  case 'Q':
# Line 513  int get_cmd_args(int argc, char *argv[], Line 484  int get_cmd_args(int argc, char *argv[],
484                          machine_statistics_init(m, optarg);                          machine_statistics_init(m, optarg);
485                          msopts = 1;                          msopts = 1;
486                          break;                          break;
487                    case 'T':
488                            m->halt_on_nonexistant_memaccess = 1;
489                            msopts = 1;
490                            break;
491                  case 't':                  case 't':
492                          m->show_trace_tree = 1;                          m->show_trace_tree = 1;
493                          msopts = 1;                          msopts = 1;
# Line 522  int get_cmd_args(int argc, char *argv[], Line 497  int get_cmd_args(int argc, char *argv[],
497                          msopts = 1;                          msopts = 1;
498                          break;                          break;
499                  case 'u':                  case 'u':
500                          m->userland_emul = strdup(optarg);                          CHECK_ALLOCATION(m->userland_emul = strdup(optarg));
                         if (m->userland_emul == NULL) {  
                                 fprintf(stderr, "out of memory\n");  
                                 exit(1);  
                         }  
501                          m->machine_type = MACHINE_USERLAND;                          m->machine_type = MACHINE_USERLAND;
502                          msopts = 1;                          msopts = 1;
503                          break;                          break;
# Line 540  int get_cmd_args(int argc, char *argv[], Line 511  int get_cmd_args(int argc, char *argv[],
511                          internal_w(optarg);                          internal_w(optarg);
512                          exit(0);                          exit(0);
513                  case 'X':                  case 'X':
514                          m->use_x11 = 1;                          m->x11_md.in_use = 1;
515                          msopts = 1;                          msopts = 1;
516                          /*  FALL-THROUGH  */                          /*  FALL-THROUGH  */
517                  case 'x':                  case 'x':
518                          console_allow_slaves(1);                          console_allow_slaves(1);
519                          break;                          break;
520                  case 'Y':                  case 'Y':
521                          m->x11_scaledown = atoi(optarg);                          m->x11_md.scaledown = atoi(optarg);
522                          if (m->x11_scaledown < -1) {                          if (m->x11_md.scaledown < -1) {
523                                  m->x11_scaleup = - m->x11_scaledown;                                  m->x11_md.scaleup = - m->x11_md.scaledown;
524                                  m->x11_scaledown = 1;                                  m->x11_md.scaledown = 1;
525                          }                          }
526                          if (m->x11_scaledown < 1) {                          if (m->x11_md.scaledown < 1) {
527                                  fprintf(stderr, "Invalid scaledown value.\n");                                  fprintf(stderr, "Invalid scaledown value.\n");
528                                  exit(1);                                  exit(1);
529                          }                          }
# Line 564  int get_cmd_args(int argc, char *argv[], Line 535  int get_cmd_args(int argc, char *argv[],
535                          msopts = 1;                          msopts = 1;
536                          break;                          break;
537                  case 'z':                  case 'z':
538                          m->x11_n_display_names ++;                          m->x11_md.n_display_names ++;
539                          m->x11_display_names = realloc(                          CHECK_ALLOCATION(m->x11_md.display_names = realloc(
540                              m->x11_display_names,                              m->x11_md.display_names,
541                              m->x11_n_display_names * sizeof(char *));                              m->x11_md.n_display_names * sizeof(char *)));
542                          if (m->x11_display_names == NULL) {                          CHECK_ALLOCATION(m->x11_md.display_names[
543                                  fprintf(stderr, "out of memory\n");                              m->x11_md.n_display_names-1] = strdup(optarg));
                                 exit(1);  
                         }  
                         m->x11_display_names[m->x11_n_display_names-1] =  
                             strdup(optarg);  
                         if (m->x11_display_names  
                             [m->x11_n_display_names-1] == NULL) {  
                                 fprintf(stderr, "out of memory\n");  
                                 exit(1);  
                         }  
544                          msopts = 1;                          msopts = 1;
545                          break;                          break;
546                  default:                  default:
# Line 663  int get_cmd_args(int argc, char *argv[], Line 625  int get_cmd_args(int argc, char *argv[],
625                  else                  else
626                          s2 ++;                          s2 ++;
627    
628                  m->boot_kernel_filename = strdup(s2);                  CHECK_ALLOCATION(m->boot_kernel_filename = strdup(s2));
                 if (m->boot_kernel_filename == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
629          }          }
630    
631          if (m->n_gfx_cards < 0 || m->n_gfx_cards > 3) {          if (m->n_gfx_cards < 0 || m->n_gfx_cards > 3) {
# Line 675  int get_cmd_args(int argc, char *argv[], Line 633  int get_cmd_args(int argc, char *argv[],
633                  exit(1);                  exit(1);
634          }          }
635    
636          if (!using_switch_Z && !m->use_x11)          if (!using_switch_Z && !m->x11_md.in_use)
637                  m->n_gfx_cards = 0;                  m->n_gfx_cards = 0;
638    
639          return 0;          return 0;
# Line 700  int main(int argc, char *argv[]) Line 658  int main(int argc, char *argv[])
658          const int constant_no = 0;          const int constant_no = 0;
659          const int constant_false = 0;          const int constant_false = 0;
660    
661          struct emul **emuls;          struct emul *emul;
662            int config_file = 0;
663    
664          char **diskimages = NULL;          char **diskimages = NULL;
665          int n_diskimages = 0;          int n_diskimages = 0;
         int n_emuls;  
666          int i;          int i;
667    
668    
# Line 727  int main(int argc, char *argv[]) Line 686  int main(int argc, char *argv[])
686          settings_add(global_settings, "false", 0, SETTINGS_TYPE_INT,          settings_add(global_settings, "false", 0, SETTINGS_TYPE_INT,
687              SETTINGS_FORMAT_BOOL, (void *)&constant_false);              SETTINGS_FORMAT_BOOL, (void *)&constant_false);
688    
689            /*  Read-only settings:  */
690          settings_add(global_settings, "single_step", 0,          settings_add(global_settings, "single_step", 0,
691              SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, (void *)&single_step);              SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO, (void *)&single_step);
692    
693            /*  Read/write settings:  */
694          settings_add(global_settings, "force_debugger_at_exit", 1,          settings_add(global_settings, "force_debugger_at_exit", 1,
695              SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO,              SETTINGS_TYPE_INT, SETTINGS_FORMAT_YESNO,
696              (void *)&force_debugger_at_exit);              (void *)&force_debugger_at_exit);
# Line 745  int main(int argc, char *argv[]) Line 707  int main(int argc, char *argv[])
707          timer_init();          timer_init();
708          useremul_init();          useremul_init();
709    
710          emuls = malloc(sizeof(struct emul *));          /*  Create a simple emulation setup:  */
711          if (emuls == NULL) {          emul = emul_new(NULL);
712                  fprintf(stderr, "out of memory\n");          settings_add(global_settings, "emul", 1,
713                  exit(1);              SETTINGS_TYPE_SUBSETTINGS, 0, emul->settings);
         }  
714    
715          /*  Allocate space for a simple emul setup:  */          get_cmd_args(argc, argv, emul, &diskimages, &n_diskimages);
         n_emuls = 1;  
         emuls[0] = emul_new(NULL);  
         if (emuls[0] == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
         settings_add(global_settings, "emul[0]", 1,  
             SETTINGS_TYPE_SUBSETTINGS, 0, emuls[0]->settings);  
   
         get_cmd_args(argc, argv, emuls[0], &diskimages, &n_diskimages);  
716    
717          if (!skip_srandom_call) {          if (!skip_srandom_call) {
718                  struct timeval tv;                  struct timeval tv;
# Line 770  int main(int argc, char *argv[]) Line 721  int main(int argc, char *argv[])
721          }          }
722    
723          /*  Print startup message:  */          /*  Print startup message:  */
724          debug("GXemul");          debug("GXemul "VERSION"    Copyright (C) 2003-2007  Anders Gavare\n"
725  #ifdef VERSION              "Read the source code and/or documentation for other Copyright "
726          debug(" " VERSION);              "messages.\n\n");
 #endif  
         debug("    Copyright (C) 2003-2006  Anders Gavare\n");  
         debug("Read the source code and/or documentation for "  
             "other Copyright messages.\n\n");  
   
         if (emuls[0]->machines[0]->machine_type == MACHINE_NONE) {  
                 n_emuls --;  
         } else {  
                 for (i=0; i<n_diskimages; i++)  
                         diskimage_add(emuls[0]->machines[0], diskimages[i]);  
         }  
727    
728          /*  Simple initialization, from command line arguments:  */          /*  Simple initialization, from command line arguments:  */
729          if (n_emuls > 0) {          if (emul->machines[0]->machine_type != MACHINE_NONE) {
730                    for (i=0; i<n_diskimages; i++)
731                            diskimage_add(emul->machines[0], diskimages[i]);
732    
733                  /*  Make sure that there are no configuration files as well:  */                  /*  Make sure that there are no configuration files as well:  */
734                  for (i=1; i<argc; i++)                  for (i=1; i<argc; i++)
735                          if (argv[i][0] == '@') {                          if (argv[i][0] == '@') {
# Line 799  int main(int argc, char *argv[]) Line 742  int main(int argc, char *argv[])
742                          }                          }
743    
744                  /*  Initialize one emul:  */                  /*  Initialize one emul:  */
745                  emul_simple_init(emuls[0]);                  emul_simple_init(emul);
746          }          }
747    
748          /*  Initialize emulations from config files:  */          /*  Initialize an emulation from a config file:  */
749          for (i=1; i<argc; i++) {          for (i=1; i<argc; i++) {
750                  if (argv[i][0] == '@') {                  if (argv[i][0] == '@') {
                         char tmpstr[50];  
751                          char *s = argv[i] + 1;                          char *s = argv[i] + 1;
752                          if (strlen(s) == 0 && i+1 < argc &&  
753                              argv[i+1][0] != '@') {                          if (config_file) {
754                                  i++;                                  fprintf(stderr, "More than one configuration "
755                                  s = argv[i];                                      "file cannot be used.\n");
                         }  
                         n_emuls ++;  
                         emuls = realloc(emuls, sizeof(struct emul *) * n_emuls);  
                         if (emuls == NULL) {  
                                 fprintf(stderr, "out of memory\n");  
756                                  exit(1);                                  exit(1);
757                          }                          }
758    
759                          /*  Always allow slave xterms when using multiple                          if (strlen(s) == 0 && i+1 < argc && *argv[i+1] != '@')
760                              emulations:  */                                  s = argv[++i];
761    
762                            /*  Always allow slave xterms:  */
763                          console_allow_slaves(1);                          console_allow_slaves(1);
764    
765                          /*  Destroy the temporary emuls[0], since it will                          /*  Destroy the temporary emul, since it will
766                              be overwritten:  */                              be overwritten:  */
767                          if (n_emuls == 1) {                          if (emul != NULL) {
768                                  emul_destroy(emuls[0]);                                  emul_destroy(emul);
769                                  settings_remove(global_settings, "emul[0]");                                  settings_remove(global_settings, "emul");
770                                    emul = NULL;
771                          }                          }
772    
773                          emuls[n_emuls - 1] =                          emul = emul_create_from_configfile(s);
774                              emul_create_from_configfile(s);  
775                            settings_add(global_settings, "emul", 1,
776                                SETTINGS_TYPE_SUBSETTINGS, 0, emul->settings);
777    
778                          snprintf(tmpstr, sizeof(tmpstr), "emul[%i]", n_emuls-1);                          config_file = 1;
                         settings_add(global_settings, tmpstr, 1,  
                             SETTINGS_TYPE_SUBSETTINGS, 0,  
                             emuls[n_emuls-1]->settings);  
779                  }                  }
780          }          }
781    
782          if (n_emuls == 0) {          if (emul->n_machines == 0) {
783                  fprintf(stderr, "No emulations defined. Maybe you forgot to "                  fprintf(stderr, "No emulations defined. Maybe you forgot to "
784                      "use -E xx and/or -e yy, to specify\nthe machine type."                      "use -E xx and/or -e yy, to specify\nthe machine type."
785                      " For example:\n\n    %s -e 3max -d disk.img\n\n"                      " For example:\n\n    %s -e 3max -d disk.img\n\n"
# Line 853  int main(int argc, char *argv[]) Line 792  int main(int argc, char *argv[])
792          console_warn_if_slaves_are_needed(1);          console_warn_if_slaves_are_needed(1);
793    
794    
795          /*  Run all emulations:  */          /*  Run the emulation:  */
796          emul_run(emuls, n_emuls);          emul_run(emul);
797    
798    
799          /*          /*
# Line 863  int main(int argc, char *argv[]) Line 802  int main(int argc, char *argv[])
802    
803          console_deinit();          console_deinit();
804    
805          for (i=0; i<n_emuls; i++)          emul_destroy(emul);
                 emul_destroy(emuls[i]);  
806    
807          settings_remove_all(global_settings);          settings_remove_all(global_settings);
808          settings_destroy(global_settings);          settings_destroy(global_settings);

Legend:
Removed from v.32  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.26