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

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

revision 27 by dpavlin, Mon Oct 8 16:20:10 2007 UTC revision 28 by dpavlin, Mon Oct 8 16:20:26 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu.c,v 1.344 2006/06/24 21:47:22 debug Exp $   *  $Id: cpu.c,v 1.348 2006/07/20 21:52:59 debug Exp $
29   *   *
30   *  Common routines for CPU emulation. (Not specific to any CPU type.)   *  Common routines for CPU emulation. (Not specific to any CPU type.)
31   */   */
# Line 42  Line 42 
42  #include "misc.h"  #include "misc.h"
43    
44    
 extern int quiet_mode;  
   
45  static struct cpu_family *first_cpu_family = NULL;  static struct cpu_family *first_cpu_family = NULL;
46    
47    
# Line 389  void cpu_run_deinit(struct machine *mach Line 387  void cpu_run_deinit(struct machine *mach
387          int te;          int te;
388    
389          /*          /*
390           *  Two last ticks of every hardware device.  This will allow           *  Two last ticks of every hardware device.  This will allow e.g.
391           *  framebuffers to draw the last updates to the screen before           *  framebuffers to draw the last updates to the screen before halting.
392           *  halting.           *
393             *  TODO: This should be refactored when redesigning the mainbus
394             *        concepts!
395           */           */
396          for (te=0; te<machine->n_tick_entries; te++) {          for (te=0; te<machine->n_tick_entries; te++) {
397                  machine->tick_func[te](machine->cpus[0],                  machine->tick_func[te](machine->cpus[0],
# Line 400  void cpu_run_deinit(struct machine *mach Line 400  void cpu_run_deinit(struct machine *mach
400                      machine->tick_extra[te]);                      machine->tick_extra[te]);
401          }          }
402    
403          debug("cpu_run_deinit(): All CPUs halted.\n");          if (machine->show_nr_of_instructions)
   
         if (machine->show_nr_of_instructions || !quiet_mode)  
404                  cpu_show_cycles(machine, 1);                  cpu_show_cycles(machine, 1);
405    
406          fflush(stdout);          fflush(stdout);
# Line 440  void cpu_show_cycles(struct machine *mac Line 438  void cpu_show_cycles(struct machine *mac
438          if (mseconds - mseconds_last == 0)          if (mseconds - mseconds_last == 0)
439                  mseconds ++;                  mseconds ++;
440    
441          ninstrs = machine->ncycles_since_gettimeofday;          ninstrs = machine->ninstrs_since_gettimeofday;
442    
443          if (machine->automatic_clock_adjustment) {          if (machine->automatic_clock_adjustment) {
444                  static int first_adjustment = 1;                  static int first_adjustment = 1;
# Line 472  void cpu_show_cycles(struct machine *mac Line 470  void cpu_show_cycles(struct machine *mac
470          if (!machine->show_nr_of_instructions && !forced)          if (!machine->show_nr_of_instructions && !forced)
471                  goto do_return;                  goto do_return;
472    
473          printf("[ %"PRIi64" instrs", (int64_t)machine->ncycles);          printf("[ %"PRIi64" instrs", (int64_t)machine->ninstrs);
474    
475          if (!machine->automatic_clock_adjustment) {          if (!machine->automatic_clock_adjustment) {
476                  d = machine->emulated_hz / 1000;                  d = machine->emulated_hz / 1000;
477                  if (d < 1)                  if (d < 1)
478                          d = 1;                          d = 1;
479                  ms = machine->ncycles / d;                  ms = machine->ninstrs / d;
480                  h = ms / 3600000;                  h = ms / 3600000;
481                  ms -= 3600000 * h;                  ms -= 3600000 * h;
482                  m = ms / 60000;                  m = ms / 60000;
# Line 525  do_return: Line 523  do_return:
523   */   */
524  void cpu_run_init(struct machine *machine)  void cpu_run_init(struct machine *machine)
525  {  {
526          int ncpus = machine->ncpus;          machine->ninstrs_flush = 0;
527          int te;          machine->ninstrs = 0;
528            machine->ninstrs_show = 0;
         machine->a_few_cycles = 1048576;  
         machine->ncycles_flush = 0;  
         machine->ncycles = 0;  
         machine->ncycles_show = 0;  
   
         /*  
          *  Instead of doing { one cycle, check hardware ticks }, we  
          *  can do { n cycles, check hardware ticks }, as long as  
          *  n is at most as much as the lowest number of cycles/tick  
          *  for any hardware device.  
          */  
         for (te=0; te<machine->n_tick_entries; te++) {  
                 if (machine->ticks_reset_value[te] < machine->a_few_cycles)  
                         machine->a_few_cycles = machine->ticks_reset_value[te];  
         }  
   
         machine->a_few_cycles >>= 1;  
         if (machine->a_few_cycles < 1)  
                 machine->a_few_cycles = 1;  
   
         if (ncpus > 1)  
                 machine->a_few_cycles = 1;  
   
         /*  debug("cpu_run_init(): a_few_cycles = %i\n",  
             machine->a_few_cycles);  */  
529    
530          /*  For performance measurement:  */          /*  For performance measurement:  */
531          gettimeofday(&machine->starttime, NULL);          gettimeofday(&machine->starttime, NULL);
532          machine->ncycles_since_gettimeofday = 0;          machine->ninstrs_since_gettimeofday = 0;
533  }  }
534    
535    
# Line 678  void cpu_init(void) Line 651  void cpu_init(void)
651          add_cpu_family(sparc_cpu_family_init, ARCH_SPARC);          add_cpu_family(sparc_cpu_family_init, ARCH_SPARC);
652  #endif  #endif
653    
654    #ifdef ENABLE_TRANSPUTER
655            add_cpu_family(transputer_cpu_family_init, ARCH_TRANSPUTER);
656    #endif
657    
658  #ifdef ENABLE_X86  #ifdef ENABLE_X86
659          add_cpu_family(x86_cpu_family_init, ARCH_X86);          add_cpu_family(x86_cpu_family_init, ARCH_X86);
660  #endif  #endif

Legend:
Removed from v.27  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26