OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [tn_m001/] [or1ksim/] [toplevel.c] - Diff between revs 491 and 494

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 491 Rev 494
Line 38... Line 38...
 
 
#include "arch.h"
#include "arch.h"
#include "parse.h"
#include "parse.h"
#include "abstract.h"
#include "abstract.h"
#include "labels.h"
#include "labels.h"
#include "trace.h"
 
#include "execute.h"
#include "execute.h"
#include "sim-config.h"
#include "sim-config.h"
#include "spr_defs.h"
#include "spr_defs.h"
#include "dma.h"
#include "dma.h"
#include "vapi.h"
#include "vapi.h"
#include "gdbcomm.h"
#include "gdbcomm.h"
#include "debug_unit.h"
#include "debug_unit.h"
#include "coff.h"
#include "coff.h"
 
 
/* CVS revision number. */
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.55 $";
const char rcsrev[] = "$Revision: 1.56 $";
 
 
/* Continuos run versus single step tracing switch. */
/* Continuos run versus single step tracing switch. */
int cont_run;
int cont_run;
 
 
/* History of execution */
/* History of execution */
Line 319... Line 318...
  char *linestr;
  char *linestr;
  char item1[500], b2[500], prev_str[500] = "";
  char item1[500], b2[500], prev_str[500] = "";
  char *redirstr;
  char *redirstr;
  int hush = 0;
  int hush = 0;
  int first_prompt = 1;
  int first_prompt = 1;
  int trace_fd = 0;
 
 
 
  srand(getpid());
  srand(getpid());
  init_defconfig();
  init_defconfig();
  if (parse_args(argc, argv)) {
  if (parse_args(argc, argv)) {
    printf("Usage: %s [options] <filename>\n", argv[0]);
    printf("Usage: %s [options] <filename>\n", argv[0]);
Line 575... Line 573...
      set_stall_state (1);
      set_stall_state (1);
      config.sim.iprompt = 0;
      config.sim.iprompt = 0;
      cont_run = -1;
      cont_run = -1;
      hush = 1;
      hush = 1;
    } else
    } else
    if (!strcmp(item1, "trace")) { /* Added by CZ 210801 */
 
      char item2[256];
 
 
 
      strtoken(linestr, item2, 2);
 
      if(trace_fd) {
 
        close(trace_fd);
 
        trace_fd = 0;
 
      }
 
      if(strcmp(item2,"off")) /* if we're not being turned off */
 
        {
 
          if(item2[0])
 
            trace_fd = open(item2,O_CREAT | O_NOCTTY |
 
          O_TRUNC | O_WRONLY, 0644);
 
          else
 
            trace_fd = dup(1);
 
          if(trace_fd < 0) {
 
            perror(item2[0]?item2:"stdout");
 
            trace_fd = 0;
 
          }
 
        }
 
    } else
 
    if (strcmp(item1, "stats") == 0) { /* stats */
    if (strcmp(item1, "stats") == 0) { /* stats */
      char item2[20];
      char item2[20];
      int i = 0;
      int i = 0;
 
 
      strtoken(linestr, item2, 2);
      strtoken(linestr, item2, 2);
Line 622... Line 599...
      while (*s != ' ' && *s) s++;
      while (*s != ' ' && *s) s++;
      set_config_command (s);
      set_config_command (s);
    } else
    } else
      printf("%s: Unknown command.\n", linestr);
      printf("%s: Unknown command.\n", linestr);
 
 
 
 
    /* MM: 'run -1' means endless execution.  */
    /* MM: 'run -1' means endless execution.  */
    while(cont_run != 0) {
    while(cont_run != 0) {
      int debug_slowdown = DEBUG_SLOWDOWN;
      int debug_slowdown = DEBUG_SLOWDOWN;
      extern int cycle_delay;  /* Added by CZ 27/05/01. Set during exception. */
      extern int cycle_delay;  /* Added by CZ 27/05/01. Set during exception. */
 
 
Line 641... Line 617...
      }
      }
 
 
      if (!testsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME)) {
      if (!testsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME)) {
        pic_clock();
        pic_clock();
        if(cycle_delay <= 0) {
        if(cycle_delay <= 0) {
          unsigned int addr;
 
          if (cont_run > 0) cont_run--;
          if (cont_run > 0) cont_run--;
          if(fetch()) {
          if(fetch()) {
            printf ("Breakpoint hit.\n");
            printf ("Breakpoint hit.\n");
            cont_run = 0; /* memory breakpoint encountered */
            cont_run = 0; /* memory breakpoint encountered */
            break;
            break;
          }
          }
          addr = iqueue[0].insn_addr;
 
 
 
          /* If trace_fd is non zero, we want
          decode_execute(&iqueue[0]);
             to make sure that disassemble is called */
 
 
 
          decode_execute(&iqueue[0], trace_fd);
 
          if(trace_fd) {
 
            char sTemp[256];
 
            char sTemp2[256];
 
            unsigned long value;
 
            extern char *disassembled;
 
            extern unsigned long reg[];
 
 
 
            /* The objects passed to the
 
               trace command should not be
 
               hardcoded like this...instead
 
               what to dump should be passed
 
               on the command line.
 
 
 
               FIX THIS LATER...
 
            */
 
            value = (evalsim_mem8(0x306bc) << 24) +
 
              (evalsim_mem8(0x306bd) << 16) +
 
              (evalsim_mem8(0x306be) << 8)
 
              + evalsim_mem8(0x306bf);
 
 
 
            sprintf(sTemp,"0x%06x: %s",addr,disassembled);
 
            memset(sTemp2,' ',sizeof(sTemp2));
 
            strncpy(sTemp2,sTemp,strlen(sTemp));
 
            sprintf(&sTemp2[40],"<0x%08x,0x%08x> [0x%08x]\n",
 
                    reg[3],reg[4],value);
 
            write(trace_fd,sTemp2,strlen(sTemp2));
 
          }
 
          update_pc();
          update_pc();
          analysis();
          analysis();
          if (!hush)
          if (!hush)
            dumpreg();
            dumpreg();
        } else
        } else

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.