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

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

revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 26 by dpavlin, Mon Oct 8 16:20:10 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2006  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: emul.c,v 1.238 2005/11/19 18:53:06 debug Exp $   *  $Id: emul.c,v 1.255 2006/06/24 19:52:27 debug Exp $
29   *   *
30   *  Emulation startup and misc. routines.   *  Emulation startup and misc. routines.
31   */   */
# Line 39  Line 39 
39  #include <unistd.h>  #include <unistd.h>
40    
41  #include "arcbios.h"  #include "arcbios.h"
 #include "bintrans.h"  
42  #include "cpu.h"  #include "cpu.h"
43  #include "emul.h"  #include "emul.h"
44  #include "console.h"  #include "console.h"
# Line 56  Line 55 
55  #include "x11.h"  #include "x11.h"
56    
57    
 extern int force_debugger_at_exit;  
   
58  extern int extra_argc;  extern int extra_argc;
59  extern char **extra_argv;  extern char **extra_argv;
60    
61  extern int verbose;  extern int verbose;
62  extern int quiet_mode;  extern int quiet_mode;
63    extern int force_debugger_at_exit;
64    extern int single_step;
65    extern int old_show_trace_tree;
66    extern int old_instruction_trace;
67    extern int old_quiet_mode;
68    extern int quiet_mode;
69    
70  extern struct emul *debugger_emul;  extern struct emul *debugger_emul;
71  extern struct diskimage *diskimages[];  extern struct diskimage *diskimages[];
# Line 70  extern struct diskimage *diskimages[]; Line 73  extern struct diskimage *diskimages[];
73  static char *diskimage_types[] = DISKIMAGE_TYPES;  static char *diskimage_types[] = DISKIMAGE_TYPES;
74    
75    
76    static void print_separator(void)
77    {
78            int i = 79;
79            while (i-- > 0)
80                    debug("-");
81            debug("\n");
82    }
83    
84    
85  /*  /*
86   *  add_dump_points():   *  add_dump_points():
87   *   *
# Line 96  static void add_dump_points(struct machi Line 108  static void add_dump_points(struct machi
108                          uint64_t addr;                          uint64_t addr;
109                          int res = get_symbol_addr(&m->symbol_context,                          int res = get_symbol_addr(&m->symbol_context,
110                              m->breakpoint_string[i], &addr);                              m->breakpoint_string[i], &addr);
111                          if (!res)                          if (!res) {
112                                  fprintf(stderr,                                  fprintf(stderr,
113                                      "WARNING! Breakpoint '%s' could not be"                                      "ERROR! Breakpoint '%s' could not be"
114                                          " parsed\n",                                          " parsed\n",
115                                      m->breakpoint_string[i]);                                      m->breakpoint_string[i]);
116                          else {                          } else {
117                                  dp = addr;                                  dp = addr;
118                                  string_flag = 1;                                  string_flag = 1;
119                          }                          }
# Line 152  static int iso_load_bootblock(struct mac Line 164  static int iso_load_bootblock(struct mac
164          int *n_loadp, char ***load_namesp)          int *n_loadp, char ***load_namesp)
165  {  {
166          char str[35];          char str[35];
167          int filenr, i, ofs, dirlen, res = 0, res2, iadd = 4;          int filenr, i, ofs, dirlen, res = 0, res2, iadd = DEBUG_INDENTATION;
168          int found_dir;          int found_dir;
169          uint64_t dirofs;          uint64_t dirofs;
170          uint64_t fileofs, filelen;          uint64_t fileofs, filelen;
# Line 161  static int iso_load_bootblock(struct mac Line 173  static int iso_load_bootblock(struct mac
173          char *p, *filename_orig;          char *p, *filename_orig;
174          char *filename = strdup(cpu->machine->boot_kernel_filename);          char *filename = strdup(cpu->machine->boot_kernel_filename);
175          unsigned char *filebuf = NULL;          unsigned char *filebuf = NULL;
176          char *tmpfilename = NULL;          char *tmpfname = NULL;
177          char **new_array;          char **new_array;
178          int tmpfile_handle;          int tmpfile_handle;
179    
# Line 207  static int iso_load_bootblock(struct mac Line 219  static int iso_load_bootblock(struct mac
219                  fatal("WARNING: Root directory length mismatch?\n");                  fatal("WARNING: Root directory length mismatch?\n");
220    
221          dirofs = (int64_t)(buf[0x8c] + (buf[0x8d] << 8) + (buf[0x8e] << 16) +          dirofs = (int64_t)(buf[0x8c] + (buf[0x8d] << 8) + (buf[0x8e] << 16) +
222              (buf[0x8f] << 24)) * 2048;              ((uint64_t)buf[0x8f] << 24)) * 2048;
223    
224          /*  debug("root = %i bytes at 0x%llx\n", dirlen, (long long)dirofs);  */          /*  debug("root = %i bytes at 0x%llx\n", dirlen, (long long)dirofs);  */
225    
# Line 228  static int iso_load_bootblock(struct mac Line 240  static int iso_load_bootblock(struct mac
240          dp = dirbuf; filenr = 1;          dp = dirbuf; filenr = 1;
241          p = NULL;          p = NULL;
242          while (dp < dirbuf + dirlen) {          while (dp < dirbuf + dirlen) {
243                  int i, nlen = dp[0];                  size_t i, nlen = dp[0];
244                  int x = dp[2] + (dp[3] << 8) + (dp[4] << 16) + (dp[5] << 24);                  int x = dp[2] + (dp[3] << 8) + (dp[4] << 16) +
245                        ((uint64_t)dp[5] << 24);
246                  int y = dp[6] + (dp[7] << 8);                  int y = dp[6] + (dp[7] << 8);
247                  char direntry[65];                  char direntry[65];
248    
# Line 299  static int iso_load_bootblock(struct mac Line 312  static int iso_load_bootblock(struct mac
312          }          }
313    
314          for (;;) {          for (;;) {
315                  int len, i;                  size_t len, i;
316    
317                  /*  Too close to another sector? Then realign.  */                  /*  Too close to another sector? Then realign.  */
318                  if ((dirofs & 2047) + 70 > 2047) {                  if ((dirofs & 2047) + 70 > 2047) {
# Line 364  static int iso_load_bootblock(struct mac Line 377  static int iso_load_bootblock(struct mac
377          }          }
378    
379          fileofs = match_entry[2] + (match_entry[3] << 8) +          fileofs = match_entry[2] + (match_entry[3] << 8) +
380              (match_entry[4] << 16) + (match_entry[5] << 24);              (match_entry[4] << 16) + ((uint64_t)match_entry[5] << 24);
381          filelen = match_entry[10] + (match_entry[11] << 8) +          filelen = match_entry[10] + (match_entry[11] << 8) +
382              (match_entry[12] << 16) + (match_entry[13] << 24);              (match_entry[12] << 16) + ((uint64_t)match_entry[13] << 24);
383          fileofs *= 2048;          fileofs *= 2048;
384    
385          /*  debug("filelen=%llx fileofs=%llx\n", (long long)filelen,          /*  debug("filelen=%llx fileofs=%llx\n", (long long)filelen,
# Line 379  static int iso_load_bootblock(struct mac Line 392  static int iso_load_bootblock(struct mac
392                  goto ret;                  goto ret;
393          }          }
394    
395          tmpfilename = strdup("/tmp/gxemul.XXXXXXXXXXXX");          tmpfname = strdup("/tmp/gxemul.XXXXXXXXXXXX");
   
         debug("extracting %lli bytes into %s\n",  
             (long long)filelen, tmpfilename);  
396    
397          res2 = diskimage_access(m, disk_id, disk_type, 0, fileofs, filebuf,          res2 = diskimage_access(m, disk_id, disk_type, 0, fileofs, filebuf,
398              filelen);              filelen);
# Line 391  static int iso_load_bootblock(struct mac Line 401  static int iso_load_bootblock(struct mac
401                  goto ret;                  goto ret;
402          }          }
403    
404          tmpfile_handle = mkstemp(tmpfilename);          tmpfile_handle = mkstemp(tmpfname);
405          if (tmpfile_handle < 0) {          if (tmpfile_handle < 0) {
406                  fatal("could not create %s\n", tmpfilename);                  fatal("could not create %s\n", tmpfname);
407                  exit(1);                  exit(1);
408          }          }
409          write(tmpfile_handle, filebuf, filelen);          write(tmpfile_handle, filebuf, filelen);
410          close(tmpfile_handle);          close(tmpfile_handle);
411    
412            debug("extracted %lli bytes into %s\n", (long long)filelen, tmpfname);
413    
414          /*  Add the temporary filename to the load_namesp array:  */          /*  Add the temporary filename to the load_namesp array:  */
415          (*n_loadp)++;          (*n_loadp)++;
416          new_array = malloc(sizeof(char *) * (*n_loadp));          new_array = malloc(sizeof(char *) * (*n_loadp));
# Line 412  static int iso_load_bootblock(struct mac Line 424  static int iso_load_bootblock(struct mac
424          /*  This adds a Backspace char in front of the filename; this          /*  This adds a Backspace char in front of the filename; this
425              is a special hack which causes the file to be removed once              is a special hack which causes the file to be removed once
426              it has been loaded.  */              it has been loaded.  */
427          tmpfilename = realloc(tmpfilename, strlen(tmpfilename) + 2);          tmpfname = realloc(tmpfname, strlen(tmpfname) + 2);
428          memmove(tmpfilename + 1, tmpfilename, strlen(tmpfilename) + 1);          memmove(tmpfname + 1, tmpfname, strlen(tmpfname) + 1);
429          tmpfilename[0] = 8;          tmpfname[0] = 8;
430    
431          (*load_namesp)[*n_loadp - 1] = tmpfilename;          (*load_namesp)[*n_loadp - 1] = tmpfname;
432    
433          res = 1;          res = 1;
434    
# Line 469  static int apple_load_bootblock(struct m Line 481  static int apple_load_bootblock(struct m
481                  int ofs = 0x200 * (partnr + 1);                  int ofs = 0x200 * (partnr + 1);
482                  if (partnr == 0)                  if (partnr == 0)
483                          n_partitions = buf[ofs + 7];                          n_partitions = buf[ofs + 7];
484                  start = (buf[ofs + 8] << 24) + (buf[ofs + 9] << 16) +                  start = ((uint64_t)buf[ofs + 8] << 24) + (buf[ofs + 9] << 16) +
485                      (buf[ofs + 10] << 8) + buf[ofs + 11];                      (buf[ofs + 10] << 8) + buf[ofs + 11];
486                  length = (buf[ofs + 12] << 24) + (buf[ofs + 13] << 16) +                  length = ((uint64_t)buf[ofs+12] << 24) + (buf[ofs + 13] << 16) +
487                      (buf[ofs + 14] << 8) + buf[ofs + 15];                      (buf[ofs + 14] << 8) + buf[ofs + 15];
488    
489                  debug("partition %i: '%s', type '%s', start %i, length %i\n",                  debug("partition %i: '%s', type '%s', start %i, length %i\n",
# Line 526  static int load_bootblock(struct machine Line 538  static int load_bootblock(struct machine
538                  return 0;                  return 0;
539    
540          switch (m->machine_type) {          switch (m->machine_type) {
541          case MACHINE_DEC:          case MACHINE_PMAX:
542                  /*                  /*
543                   *  The first few bytes of a disk contains information about                   *  The first few bytes of a disk contains information about
544                   *  where the bootblock(s) are located. (These are all 32-bit                   *  where the bootblock(s) are located. (These are all 32-bit
# Line 547  static int load_bootblock(struct machine Line 559  static int load_bootblock(struct machine
559                      minibuf, sizeof(minibuf));                      minibuf, sizeof(minibuf));
560    
561                  bootblock_loadaddr = minibuf[0x10] + (minibuf[0x11] << 8)                  bootblock_loadaddr = minibuf[0x10] + (minibuf[0x11] << 8)
562                    + (minibuf[0x12] << 16) + (minibuf[0x13] << 24);                    + (minibuf[0x12] << 16) + ((uint64_t)minibuf[0x13] << 24);
563    
564                  /*  Convert loadaddr to uncached:  */                  /*  Convert loadaddr to uncached:  */
565                  if ((bootblock_loadaddr & 0xf0000000ULL) != 0x80000000 &&                  if ((bootblock_loadaddr & 0xf0000000ULL) != 0x80000000 &&
# Line 558  static int load_bootblock(struct machine Line 570  static int load_bootblock(struct machine
570                  bootblock_loadaddr |= 0xffffffffa0000000ULL;                  bootblock_loadaddr |= 0xffffffffa0000000ULL;
571    
572                  bootblock_pc = minibuf[0x14] + (minibuf[0x15] << 8)                  bootblock_pc = minibuf[0x14] + (minibuf[0x15] << 8)
573                    + (minibuf[0x16] << 16) + (minibuf[0x17] << 24);                    + (minibuf[0x16] << 16) + ((uint64_t)minibuf[0x17] << 24);
574    
575                  bootblock_pc &= 0x0fffffffULL;                  bootblock_pc &= 0x0fffffffULL;
576                  bootblock_pc |= 0xffffffffa0000000ULL;                  bootblock_pc |= 0xffffffffa0000000ULL;
# Line 579  static int load_bootblock(struct machine Line 591  static int load_bootblock(struct machine
591                          }                          }
592    
593                          n_blocks = minibuf[0] + (minibuf[1] << 8)                          n_blocks = minibuf[0] + (minibuf[1] << 8)
594                            + (minibuf[2] << 16) + (minibuf[3] << 24);                            + (minibuf[2] << 16) + ((uint64_t)minibuf[3] << 24);
595    
596                          bootblock_offset = (minibuf[4] + (minibuf[5] << 8)                          bootblock_offset = (minibuf[4] + (minibuf[5] << 8) +
597                            + (minibuf[6] << 16) + (minibuf[7] << 24)) * 512;                            (minibuf[6]<<16) + ((uint64_t)minibuf[7]<<24)) * 512;
598    
599                          if (n_blocks < 1)                          if (n_blocks < 1)
600                                  break;                                  break;
# Line 903  static void add_arc_components(struct ma Line 915  static void add_arc_components(struct ma
915  void emul_machine_setup(struct machine *m, int n_load, char **load_names,  void emul_machine_setup(struct machine *m, int n_load, char **load_names,
916          int n_devices, char **device_names)          int n_devices, char **device_names)
917  {  {
         struct emul *emul;  
918          struct cpu *cpu;          struct cpu *cpu;
919          int i, iadd=4;          int i, iadd = DEBUG_INDENTATION;
920          uint64_t memory_amount, entrypoint = 0, gp = 0, toc = 0;          uint64_t memory_amount, entrypoint = 0, gp = 0, toc = 0;
921          int byte_order;          int byte_order;
922    
         emul = m->emul;  
   
923          debug("machine \"%s\":\n", m->name);          debug("machine \"%s\":\n", m->name);
924          debug_indentation(iadd);          debug_indentation(iadd);
925    
# Line 934  void emul_machine_setup(struct machine * Line 943  void emul_machine_setup(struct machine *
943          if (m->arch == ARCH_ALPHA)          if (m->arch == ARCH_ALPHA)
944                  m->arch_pagesize = 8192;                  m->arch_pagesize = 8192;
945    
         if (m->arch != ARCH_MIPS)  
                 m->bintrans_enable = 0;  
   
946          machine_memsize_fix(m);          machine_memsize_fix(m);
947    
948          /*          /*
# Line 984  void emul_machine_setup(struct machine * Line 990  void emul_machine_setup(struct machine *
990          }          }
991          memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus);          memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus);
992    
         /*  Initialize dynamic binary translation, if available:  */  
         if (m->bintrans_enable)  
                 bintrans_init(m, m->memory);  
   
993          debug("cpu0");          debug("cpu0");
994          if (m->ncpus > 1)          if (m->ncpus > 1)
995                  debug(" .. cpu%i", m->ncpus - 1);                  debug(" .. cpu%i", m->ncpus - 1);
996          debug(": ");          debug(": ");
997          for (i=0; i<m->ncpus; i++) {          for (i=0; i<m->ncpus; i++) {
998                  m->cpus[i] = cpu_new(m->memory, m, i, m->cpu_name);                  m->cpus[i] = cpu_new(m->memory, m, i, m->cpu_name);
999                  if (m->bintrans_enable)                  if (m->cpus[i] == NULL) {
1000                          bintrans_init_cpu(m->cpus[i]);                          fprintf(stderr, "Unable to create CPU object. "
1001                                "Aborting.");
1002                            exit(1);
1003                    }
1004          }          }
1005          debug("\n");          debug("\n");
1006    
# Line 1006  void emul_machine_setup(struct machine * Line 1011  void emul_machine_setup(struct machine *
1011                  m->cpus[m->ncpus] = cpu_new(m->memory, m,                  m->cpus[m->ncpus] = cpu_new(m->memory, m,
1012                      0  /*  use 0 here to show info with debug()  */,                      0  /*  use 0 here to show info with debug()  */,
1013                      "Allegrex" /*  TODO  */);                      "Allegrex" /*  TODO  */);
                 if (m->bintrans_enable)  
                         bintrans_init_cpu(m->cpus[m->ncpus]);  
1014                  debug("\n");                  debug("\n");
1015                  m->ncpus ++;                  m->ncpus ++;
1016          }          }
# Line 1063  void emul_machine_setup(struct machine * Line 1066  void emul_machine_setup(struct machine *
1066          }          }
1067    
1068          diskimage_dump_info(m);          diskimage_dump_info(m);
1069            console_debug_dump(m);
1070    
1071          /*  Load files (ROM code, boot code, ...) into memory:  */          /*  Load files (ROM code, boot code, ...) into memory:  */
1072          if (n_load == 0) {          if (n_load == 0) {
# Line 1341  void emul_machine_setup(struct machine * Line 1345  void emul_machine_setup(struct machine *
1345          add_dump_points(m);          add_dump_points(m);
1346    
1347          /*  TODO: This is MIPS-specific!  */          /*  TODO: This is MIPS-specific!  */
1348          if (m->machine_type == MACHINE_DEC &&          if (m->machine_type == MACHINE_PMAX &&
1349              cpu->cd.mips.cpu_type.mmu_model == MMU3K)              cpu->cd.mips.cpu_type.mmu_model == MMU3K)
1350                  add_symbol_name(&m->symbol_context,                  add_symbol_name(&m->symbol_context,
1351                      0x9fff0000, 0x10000, "r2k3k_cache", 0, 0);                      0x9fff0000, 0x10000, "r2k3k_cache", 0, 0);
1352    
1353          symbol_recalc_sizes(&m->symbol_context);          symbol_recalc_sizes(&m->symbol_context);
1354    
         if (m->max_random_cycles_per_chunk > 0)  
                 debug("using random cycle chunks (1 to %i cycles)\n",  
                     m->max_random_cycles_per_chunk);  
   
1355          /*  Special hack for ARC/SGI emulation:  */          /*  Special hack for ARC/SGI emulation:  */
1356          if ((m->machine_type == MACHINE_ARC ||          if ((m->machine_type == MACHINE_ARC ||
1357              m->machine_type == MACHINE_SGI) && m->prom_emulation)              m->machine_type == MACHINE_SGI) && m->prom_emulation)
1358                  add_arc_components(m);                  add_arc_components(m);
1359    
   
 #if 0  
 if (m->machine_type == MACHINE_IQ80321) {  
         store_32bit_word(cpu, 0xc0200000, 0);  
         store_32bit_word(cpu, 0xc0200004, 0xd0000000);  
 }  
 #endif  
   
   
1360          debug("starting cpu%i at ", m->bootstrap_cpu);          debug("starting cpu%i at ", m->bootstrap_cpu);
1361          switch (m->arch) {          switch (m->arch) {
1362    
# Line 1409  if (m->machine_type == MACHINE_IQ80321) Line 1400  if (m->machine_type == MACHINE_IQ80321)
1400                  break;                  break;
1401    
1402          default:          default:
1403                  debug("0x%016llx", (long long)cpu->pc);                  if (cpu->is_32bit)
1404                            debug("0x%08x", (int)cpu->pc);
1405                    else
1406                            debug("0x%016llx", (long long)cpu->pc);
1407          }          }
1408          debug("\n");          debug("\n");
1409    
# Line 1424  if (m->machine_type == MACHINE_IQ80321) Line 1418  if (m->machine_type == MACHINE_IQ80321)
1418   */   */
1419  void emul_dumpinfo(struct emul *e)  void emul_dumpinfo(struct emul *e)
1420  {  {
1421          int j, nm, iadd = 4;          int j, nm, iadd = DEBUG_INDENTATION;
1422    
1423          if (e->net != NULL)          if (e->net != NULL)
1424                  net_dumpinfo(e->net);                  net_dumpinfo(e->net);
# Line 1453  void emul_dumpinfo(struct emul *e) Line 1447  void emul_dumpinfo(struct emul *e)
1447   */   */
1448  void emul_simple_init(struct emul *emul)  void emul_simple_init(struct emul *emul)
1449  {  {
1450          int iadd=4;          int iadd = DEBUG_INDENTATION;
1451          struct machine *m;          struct machine *m;
1452    
1453          if (emul->n_machines != 1) {          if (emul->n_machines != 1) {
# Line 1490  void emul_simple_init(struct emul *emul) Line 1484  void emul_simple_init(struct emul *emul)
1484   */   */
1485  struct emul *emul_create_from_configfile(char *fname)  struct emul *emul_create_from_configfile(char *fname)
1486  {  {
1487          int iadd = 4;          int iadd = DEBUG_INDENTATION;
1488          struct emul *e = emul_new(fname);          struct emul *e = emul_new(fname);
         FILE *f;  
         char buf[128];  
         size_t len;  
1489    
1490          debug("Creating emulation from configfile \"%s\":\n", fname);          debug("Creating emulation from configfile \"%s\":\n", fname);
1491          debug_indentation(iadd);          debug_indentation(iadd);
1492    
1493          f = fopen(fname, "r");          emul_parse_config(e, fname);
         if (f == NULL) {  
                 perror(fname);  
                 exit(1);  
         }  
   
         /*  Read header: (must be !!gxemul)  */  
         len = fread(buf, 1, 8, f);  
         if (len != 8 || strncmp(buf, "!!gxemul", 8) != 0) {  
                 fprintf(stderr, "%s: must start with '!!gxemul'\n", fname);  
                 exit(1);  
         }  
   
         /*  Restart from beginning:  */  
         rewind(f);  
   
         emul_parse_config(e, f);  
1494    
         fclose(f);  
1495          debug_indentation(-iadd);          debug_indentation(-iadd);
1496          return e;          return e;
1497  }  }
# Line 1544  void emul_run(struct emul **emuls, int n Line 1518  void emul_run(struct emul **emuls, int n
1518    
1519          atexit(fix_console);          atexit(fix_console);
1520    
         i = 79;  
         while (i-- > 0)  
                 debug("-");  
         debug("\n\n");  
   
1521          /*  Initialize the interactive debugger:  */          /*  Initialize the interactive debugger:  */
1522          debugger_init(emuls, n_emuls);          debugger_init(emuls, n_emuls);
1523    
1524            /*  Run any additional debugger commands before starting:  */
1525            for (i=0; i<n_emuls; i++) {
1526                    struct emul *emul = emuls[i];
1527                    if (emul->n_debugger_cmds > 0) {
1528                            int j;
1529                            if (i == 0)
1530                                    print_separator();
1531                            for (j = 0; j < emul->n_debugger_cmds; j ++) {
1532                                    debug("> %s\n", emul->debugger_cmds[j]);
1533                                    debugger_execute_cmd(emul->debugger_cmds[j],
1534                                        strlen(emul->debugger_cmds[j]));
1535                            }
1536                    }
1537            }
1538    
1539            print_separator();
1540            debug("\n");
1541    
1542    
1543          /*          /*
1544           *  console_init_main() makes sure that the terminal is in a           *  console_init_main() makes sure that the terminal is in a
1545           *  reasonable state.           *  reasonable state.
# Line 1593  void emul_run(struct emul **emuls, int n Line 1581  void emul_run(struct emul **emuls, int n
1581          while (go) {          while (go) {
1582                  go = 0;                  go = 0;
1583    
1584                  x11_check_event(emuls, n_emuls);                  /*  Flush X11 and serial console output every now and then:  */
1585                    if (emuls[0]->machines[0]->ncycles >
1586                  for (i=0; i<n_emuls; i++) {                      emuls[0]->machines[0]->ncycles_flush + (1<<18)) {
1587                          e = emuls[i];                          x11_check_event(emuls, n_emuls);
1588                          if (e == NULL)                          console_flush();
1589                                  continue;                          emuls[0]->machines[0]->ncycles_flush =
1590                                emuls[0]->machines[0]->ncycles;
1591                          for (j=0; j<e->n_machines; j++) {                  }
1592                                  /*  TODO: cpu_run() is a strange name, since  
1593                                      there can be multiple cpus in a machine  */                  if (emuls[0]->machines[0]->ncycles >
1594                                  anything = cpu_run(e, e->machines[j]);                      emuls[0]->machines[0]->ncycles_show + (1<<25)) {
1595                                  if (anything)                          emuls[0]->machines[0]->ncycles_since_gettimeofday +=
1596                                          go = 1;                              (emuls[0]->machines[0]->ncycles -
1597                          }                               emuls[0]->machines[0]->ncycles_show);
1598                            cpu_show_cycles(emuls[0]->machines[0], 0);
1599                            emuls[0]->machines[0]->ncycles_show =
1600                                emuls[0]->machines[0]->ncycles;
1601                    }
1602    
1603                    if (single_step == ENTER_SINGLE_STEPPING) {
1604                            /*  TODO: Cleanup!  */
1605                            old_instruction_trace =
1606                                emuls[0]->machines[0]->instruction_trace;
1607                            old_quiet_mode = quiet_mode;
1608                            old_show_trace_tree =
1609                                emuls[0]->machines[0]->show_trace_tree;
1610                            emuls[0]->machines[0]->instruction_trace = 1;
1611                            emuls[0]->machines[0]->show_trace_tree = 1;
1612                            quiet_mode = 0;
1613                            single_step = SINGLE_STEPPING;
1614                    }
1615    
1616                    if (single_step == SINGLE_STEPPING)
1617                            debugger();
1618    
1619                    e = emuls[0];   /*  Note: Only 1 emul supported now.  */
1620    
1621                    for (j=0; j<e->n_machines; j++) {
1622                            if (e->machines[j]->gdb.port > 0)
1623                                    debugger_gdb_check_incoming(e->machines[j]);
1624    
1625                            anything = machine_run(e->machines[j]);
1626                            if (anything)
1627                                    go = 1;
1628                  }                  }
1629          }          }
1630    

Legend:
Removed from v.20  
changed lines
  Added in v.26

  ViewVC Help
Powered by ViewVC 1.1.26