/[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 23 by dpavlin, Mon Oct 8 16:19:37 2007 UTC revision 24 by dpavlin, Mon Oct 8 16:19:56 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: emul.c,v 1.247 2006/02/04 12:27:12 debug Exp $   *  $Id: emul.c,v 1.254 2006/06/22 13:22:40 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 105  static void add_dump_points(struct machi Line 104  static void add_dump_points(struct machi
104                          uint64_t addr;                          uint64_t addr;
105                          int res = get_symbol_addr(&m->symbol_context,                          int res = get_symbol_addr(&m->symbol_context,
106                              m->breakpoint_string[i], &addr);                              m->breakpoint_string[i], &addr);
107                          if (!res)                          if (!res) {
108                                  fprintf(stderr,                                  fprintf(stderr,
109                                      "WARNING! Breakpoint '%s' could not be"                                      "ERROR! Breakpoint '%s' could not be"
110                                          " parsed\n",                                          " parsed\n",
111                                      m->breakpoint_string[i]);                                      m->breakpoint_string[i]);
112                          else {                          } else {
113                                  dp = addr;                                  dp = addr;
114                                  string_flag = 1;                                  string_flag = 1;
115                          }                          }
# Line 940  void emul_machine_setup(struct machine * Line 939  void emul_machine_setup(struct machine *
939          if (m->arch == ARCH_ALPHA)          if (m->arch == ARCH_ALPHA)
940                  m->arch_pagesize = 8192;                  m->arch_pagesize = 8192;
941    
         if (m->arch != ARCH_MIPS)  
                 m->bintrans_enable = 0;  
   
942          machine_memsize_fix(m);          machine_memsize_fix(m);
943    
944          /*          /*
# Line 990  void emul_machine_setup(struct machine * Line 986  void emul_machine_setup(struct machine *
986          }          }
987          memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus);          memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus);
988    
         /*  Initialize dynamic binary translation, if available:  */  
         if (m->bintrans_enable)  
                 bintrans_init(m, m->memory);  
   
989          debug("cpu0");          debug("cpu0");
990          if (m->ncpus > 1)          if (m->ncpus > 1)
991                  debug(" .. cpu%i", m->ncpus - 1);                  debug(" .. cpu%i", m->ncpus - 1);
992          debug(": ");          debug(": ");
993          for (i=0; i<m->ncpus; i++) {          for (i=0; i<m->ncpus; i++) {
994                  m->cpus[i] = cpu_new(m->memory, m, i, m->cpu_name);                  m->cpus[i] = cpu_new(m->memory, m, i, m->cpu_name);
995                  if (m->bintrans_enable)                  if (m->cpus[i] == NULL) {
996                          bintrans_init_cpu(m->cpus[i]);                          fprintf(stderr, "Unable to create CPU object. "
997                                "Aborting.");
998                            exit(1);
999                    }
1000          }          }
1001          debug("\n");          debug("\n");
1002    
# Line 1012  void emul_machine_setup(struct machine * Line 1007  void emul_machine_setup(struct machine *
1007                  m->cpus[m->ncpus] = cpu_new(m->memory, m,                  m->cpus[m->ncpus] = cpu_new(m->memory, m,
1008                      0  /*  use 0 here to show info with debug()  */,                      0  /*  use 0 here to show info with debug()  */,
1009                      "Allegrex" /*  TODO  */);                      "Allegrex" /*  TODO  */);
                 if (m->bintrans_enable)  
                         bintrans_init_cpu(m->cpus[m->ncpus]);  
1010                  debug("\n");                  debug("\n");
1011                  m->ncpus ++;                  m->ncpus ++;
1012          }          }
# Line 1355  void emul_machine_setup(struct machine * Line 1348  void emul_machine_setup(struct machine *
1348    
1349          symbol_recalc_sizes(&m->symbol_context);          symbol_recalc_sizes(&m->symbol_context);
1350    
         if (m->max_random_cycles_per_chunk > 0)  
                 debug("using random cycle chunks (1 to %i cycles)\n",  
                     m->max_random_cycles_per_chunk);  
   
1351          /*  Special hack for ARC/SGI emulation:  */          /*  Special hack for ARC/SGI emulation:  */
1352          if ((m->machine_type == MACHINE_ARC ||          if ((m->machine_type == MACHINE_ARC ||
1353              m->machine_type == MACHINE_SGI) && m->prom_emulation)              m->machine_type == MACHINE_SGI) && m->prom_emulation)
# Line 1493  struct emul *emul_create_from_configfile Line 1482  struct emul *emul_create_from_configfile
1482  {  {
1483          int iadd = DEBUG_INDENTATION;          int iadd = DEBUG_INDENTATION;
1484          struct emul *e = emul_new(fname);          struct emul *e = emul_new(fname);
         FILE *f;  
         char buf[128];  
         size_t len;  
1485    
1486          debug("Creating emulation from configfile \"%s\":\n", fname);          debug("Creating emulation from configfile \"%s\":\n", fname);
1487          debug_indentation(iadd);          debug_indentation(iadd);
1488    
1489          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);  
         }  
1490    
         /*  Restart from beginning:  */  
         rewind(f);  
   
         emul_parse_config(e, f);  
   
         fclose(f);  
1491          debug_indentation(-iadd);          debug_indentation(-iadd);
1492          return e;          return e;
1493  }  }
# Line 1616  void emul_run(struct emul **emuls, int n Line 1585  void emul_run(struct emul **emuls, int n
1585                                  continue;                                  continue;
1586    
1587                          for (j=0; j<e->n_machines; j++) {                          for (j=0; j<e->n_machines; j++) {
1588                                    if (e->machines[j]->gdb.port > 0)
1589                                            debugger_gdb_check_incoming(
1590                                                e->machines[j]);
1591    
1592                                  /*  TODO: cpu_run() is a strange name, since                                  /*  TODO: cpu_run() is a strange name, since
1593                                      there can be multiple cpus in a machine  */                                      there can be multiple cpus in a machine  */
1594                                  anything = cpu_run(e, e->machines[j]);                                  anything = cpu_run(e, e->machines[j]);

Legend:
Removed from v.23  
changed lines
  Added in v.24

  ViewVC Help
Powered by ViewVC 1.1.26