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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [sim/] [command.c] - Diff between revs 246 and 275

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

Rev 246 Rev 275
Line 14... Line 14...
#include "except.h"
#include "except.h"
#include "command.h"
#include "command.h"
#include "asm.h"
#include "asm.h"
#include "disasm.h"
#include "disasm.h"
#include "cpu.h"
#include "cpu.h"
 
#include "trace.h"
#include "mmu.h"
#include "mmu.h"
#include "memory.h"
#include "memory.h"
#include "timer.h"
#include "timer.h"
#include "dspkbd.h"
#include "dspkbd.h"
#include "serial.h"
#include "serial.h"
Line 58... Line 59...
  cPrintf("  d       dump memory\n");
  cPrintf("  d       dump memory\n");
  cPrintf("  mw      show/set memory word\n");
  cPrintf("  mw      show/set memory word\n");
  cPrintf("  mh      show/set memory halfword\n");
  cPrintf("  mh      show/set memory halfword\n");
  cPrintf("  mb      show/set memory byte\n");
  cPrintf("  mb      show/set memory byte\n");
  cPrintf("  t       show/set TLB contents\n");
  cPrintf("  t       show/set TLB contents\n");
 
  cPrintf("  l       list trace buffer\n");
  cPrintf("  i       initialize hardware\n");
  cPrintf("  i       initialize hardware\n");
  cPrintf("  q       quit simulator\n");
  cPrintf("  q       quit simulator\n");
  cPrintf("type 'help <cmd>' to get help for <cmd>\n");
  cPrintf("type 'help <cmd>' to get help for <cmd>\n");
}
}
 
 
Line 162... Line 164...
  cPrintf("  t  <i> f <data>   set TLB contents at <i> to frame <data>\n");
  cPrintf("  t  <i> f <data>   set TLB contents at <i> to frame <data>\n");
}
}
 
 
 
 
static void help15(void) {
static void help15(void) {
  cPrintf("  i                 initialize hardware\n");
  cPrintf("  l                 list 16 trace entries starting at -16\n");
 
  cPrintf("  l <i>             list 16 trace entries starting at <i>\n");
 
  cPrintf("  l <i> <cnt>       list <cnt> trace entries starting at <i>\n");
}
}
 
 
 
 
static void help16(void) {
static void help16(void) {
  cPrintf("  q                 quit simulator\n");
  cPrintf("  i                 initialize hardware\n");
}
}
 
 
 
 
static char *cause[32] = {
static void help17(void) {
  /*  0 */  "serial line 0 xmt interrupt",
  cPrintf("  q                 quit simulator\n");
  /*  1 */  "serial line 0 rcv interrupt",
 
  /*  2 */  "serial line 1 xmt interrupt",
 
  /*  3 */  "serial line 1 rcv interrupt",
 
  /*  4 */  "keyboard interrupt",
 
  /*  5 */  "unknown interrupt",
 
  /*  6 */  "unknown interrupt",
 
  /*  7 */  "unknown interrupt",
 
  /*  8 */  "disk interrupt",
 
  /*  9 */  "unknown interrupt",
 
  /* 10 */  "unknown interrupt",
 
  /* 11 */  "unknown interrupt",
 
  /* 12 */  "unknown interrupt",
 
  /* 13 */  "unknown interrupt",
 
  /* 14 */  "timer 0 interrupt",
 
  /* 15 */  "timer 1 interrupt",
 
  /* 16 */  "bus timeout exception",
 
  /* 17 */  "illegal instruction exception",
 
  /* 18 */  "privileged instruction exception",
 
  /* 19 */  "divide instruction exception",
 
  /* 20 */  "trap instruction exception",
 
  /* 21 */  "TLB miss exception",
 
  /* 22 */  "TLB write exception",
 
  /* 23 */  "TLB invalid exception",
 
  /* 24 */  "illegal address exception",
 
  /* 25 */  "privileged address exception",
 
  /* 26 */  "unknown exception",
 
  /* 27 */  "unknown exception",
 
  /* 28 */  "unknown exception",
 
  /* 29 */  "unknown exception",
 
  /* 30 */  "unknown exception",
 
  /* 31 */  "unknown exception"
 
};
 
 
 
 
 
static char *exceptionToString(int exception) {
 
  if (exception < 0 ||
 
      exception >= sizeof(cause)/sizeof(cause[0])) {
 
    error("exception number out of bounds");
 
  }
 
  return cause[exception];
 
}
}
 
 
 
 
static Bool getHexNumber(char *str, Word *valptr) {
static Bool getHexNumber(char *str, Word *valptr) {
  char *end;
  char *end;
Line 848... Line 812...
    help14();
    help14();
  }
  }
}
}
 
 
 
 
 
static void doList(char *tokens[], int n) {
 
  int start, count, stop;
 
  int back;
 
 
 
  if (n == 1) {
 
    start = 16;
 
    count = 16;
 
  } else if (n == 2) {
 
    if (!getDecNumber(tokens[1], &start) || start >= 0) {
 
      cPrintf("illegal trace buffer index (must be < 0)\n");
 
      return;
 
    }
 
    start = -start;
 
    count = 16;
 
  } else if (n == 3) {
 
    if (!getDecNumber(tokens[1], &start) || start >= 0) {
 
      cPrintf("illegal trace buffer index (must be < 0)\n");
 
      return;
 
    }
 
    start = -start;
 
    if (!getDecNumber(tokens[2], &count) || count <= 0) {
 
      cPrintf("illegal trace buffer count (must be > 0)\n");
 
      return;
 
    }
 
  } else {
 
    help15();
 
    return;
 
  }
 
  if (start > TRACE_BUF_SIZE) {
 
    start = TRACE_BUF_SIZE;
 
  }
 
  stop = start - count;
 
  if (stop < 0) {
 
    stop = 0;
 
  }
 
  for (back = start; back > stop; back--) {
 
    cPrintf("trace[%5d]:  %s\n", -back, traceShow(back));
 
  }
 
}
 
 
 
 
static void doInit(char *tokens[], int n) {
static void doInit(char *tokens[], int n) {
  if (n == 1) {
  if (n == 1) {
    timerReset();
    timerReset();
    displayReset();
    displayReset();
    keyboardReset();
    keyboardReset();
Line 862... Line 867...
    graphReset();
    graphReset();
    memoryReset();
    memoryReset();
    mmuReset();
    mmuReset();
    cpuReset();
    cpuReset();
  } else {
  } else {
    help15();
    help16();
  }
  }
}
}
 
 
 
 
static void doQuit(char *tokens[], int n) {
static void doQuit(char *tokens[], int n) {
  if (n == 1) {
  if (n == 1) {
    quit = true;
    quit = true;
  } else {
  } else {
    help16();
    help17();
  }
  }
}
}
 
 
 
 
Command commands[] = {
Command commands[] = {
Line 892... Line 897...
  { "d",    help10, doDump       },
  { "d",    help10, doDump       },
  { "mw",   help11, doMemoryWord },
  { "mw",   help11, doMemoryWord },
  { "mh",   help12, doMemoryHalf },
  { "mh",   help12, doMemoryHalf },
  { "mb",   help13, doMemoryByte },
  { "mb",   help13, doMemoryByte },
  { "t",    help14, doTLB        },
  { "t",    help14, doTLB        },
  { "i",    help15, doInit       },
  { "l",    help15, doList       },
  { "q",    help16, doQuit       },
  { "i",    help16, doInit       },
 
  { "q",    help17, doQuit       },
};
};
 
 
int numCommands = sizeof(commands) / sizeof(commands[0]);
int numCommands = sizeof(commands) / sizeof(commands[0]);
 
 
 
 

powered by: WebSVN 2.1.0

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