Added the rest of the framework for instrumenting the emulator.

git-svn-id: http://www.cdkersey.com/harp/harptool@32 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
chad 2011-10-19 02:13:13 +00:00
parent 85b40db3d1
commit 15774083d0
4 changed files with 81 additions and 61 deletions

View file

@ -90,7 +90,9 @@ void Core::step() {
bool Core::interrupt(Word r0) {
if (!interruptEnable) return false;
//cout << "Interrupt: " << r0 << '\n';
#ifdef EMU_INSTRUMENTATION
#error TODO: instrument Harp::Core::interrupt()
#endif
shadowActiveThreads = activeThreads;
shadowInterruptEnable = interruptEnable; /* For traps. */

View file

@ -35,12 +35,17 @@ namespace Harp {
AC_NONE, AC_2REG, AC_2IMM, AC_3REG, AC_3PREG, AC_3IMM, AC_3REGSRC,
AC_1IMM, AC_1REG, AC_3IMMSRC, AC_PREG_REG, AC_2PREG
};
enum InstType {
ITYPE_NULL, ITYPE_INTBASIC, ITYPE_INTMUL, ITYPE_INTDIV, ITYPE_STACK, ITYPE_BR,
ITYPE_CALL, ITYPE_RET, ITYPE_TRAP, ITYPE_FPBASIC, ITYPE_FPMUL, ITYPE_FPDIV
};
// We build a table of instruction information out of this.
static struct InstTableEntry {
const char *opString;
bool controlFlow, relAddress, allSrcArgs, privileged;
ArgClass argClass;
InstType iType;
} instTable[];
Instruction() :

View file

@ -16,66 +16,66 @@ using namespace std;
enum. */
Instruction::InstTableEntry Instruction::instTable[] = {
//str cflow relad allsrc priv argcl
{"nop", false, false, false, false, AC_NONE },
{"di", false, false, false, true, AC_NONE },
{"ei", false, false, false, true, AC_NONE },
{"tlbadd", false, false, true, true, AC_3REGSRC },
{"tlbflush", false, false, false, true, AC_NONE },
{"neg", false, false, false, false, AC_2REG },
{"not", false, false, false, false, AC_2REG },
{"and", false, false, false, false, AC_3REG },
{"or", false, false, false, false, AC_3REG },
{"xor", false, false, false, false, AC_3REG },
{"add", false, false, false, false, AC_3REG },
{"sub", false, false, false, false, AC_3REG },
{"mul", false, false, false, false, AC_3REG },
{"div", false, false, false, false, AC_3REG },
{"mod", false, false, false, false, AC_3REG },
{"shl", false, false, false, false, AC_3REG },
{"shr", false, false, false, false, AC_3REG },
{"andi", false, false, false, false, AC_3IMM },
{"ori", false, false, false, false, AC_3IMM },
{"xori", false, false, false, false, AC_3IMM },
{"addi", false, false, false, false, AC_3IMM },
{"subi", false, false, false, false, AC_3IMM },
{"muli", false, false, false, false, AC_3IMM },
{"divi", false, false, false, false, AC_3IMM },
{"modi", false, false, false, false, AC_3IMM },
{"shli", false, false, false, false, AC_3IMM },
{"shri", false, false, false, false, AC_3IMM },
{"jali", true, true, false, false, AC_2IMM },
{"jalr", true, false, false, false, AC_2REG },
{"jmpi", true, true, true, false, AC_1IMM },
{"jmpr", true, false, true, false, AC_1REG },
{"clone", true, false, false, false, AC_1REG },
{"jalis", true, true, false, false, AC_3IMM },
{"jalrs", true, false, false, false, AC_3REG },
{"jmprt", true, false, true, false, AC_1REG },
{"ld", false, false, false, false, AC_3IMM },
{"st", false, false, true, false, AC_3IMMSRC },
{"ldi", false, false, false, false, AC_2IMM },
{"rtop", false, false, false, false, AC_PREG_REG},
{"andp", false, false, false, false, AC_3PREG },
{"orp", false, false, false, false, AC_3PREG },
{"xorp", false, false, false, false, AC_3PREG },
{"notp", false, false, false, false, AC_3PREG },
{"isneg", false, false, false, false, AC_PREG_REG},
{"iszero", false, false, false, false, AC_PREG_REG},
{"halt", false, false, false, true, AC_NONE },
{"trap", true, false, false, false, AC_NONE },
{"jmpru", false, false, false, true, AC_1REG },
{"skep", false, false, false, true, AC_1REG },
{"reti", true, false, false, true, AC_NONE },
{"tlbrm", false, false, false, true, AC_1REG },
{"itof", false, false, false, false, AC_2REG },
{"ftoi", false, false, false, false, AC_2REG },
{"fadd", false, false, false, false, AC_3REG },
{"fsub", false, false, false, false, AC_3REG },
{"fmul", false, false, false, false, AC_3REG },
{"fdiv", false, false, false, false, AC_3REG },
{"fneg", false, false, false, false, AC_2REG },
{NULL,false,false,false,false,AC_NONE}/////////////// End of table.
//str cflow relad allsrc priv argcl itype
{"nop", false, false, false, false, AC_NONE, ITYPE_NULL },
{"di", false, false, false, true, AC_NONE, ITYPE_NULL },
{"ei", false, false, false, true, AC_NONE, ITYPE_NULL },
{"tlbadd", false, false, true, true, AC_3REGSRC, ITYPE_NULL },
{"tlbflush", false, false, false, true, AC_NONE, ITYPE_NULL },
{"neg", false, false, false, false, AC_2REG, ITYPE_INTBASIC},
{"not", false, false, false, false, AC_2REG, ITYPE_INTBASIC},
{"and", false, false, false, false, AC_3REG, ITYPE_INTBASIC},
{"or", false, false, false, false, AC_3REG, ITYPE_INTBASIC},
{"xor", false, false, false, false, AC_3REG, ITYPE_INTBASIC},
{"add", false, false, false, false, AC_3REG, ITYPE_INTBASIC},
{"sub", false, false, false, false, AC_3REG, ITYPE_INTBASIC},
{"mul", false, false, false, false, AC_3REG, ITYPE_INTMUL },
{"div", false, false, false, false, AC_3REG, ITYPE_INTDIV },
{"mod", false, false, false, false, AC_3REG, ITYPE_INTDIV },
{"shl", false, false, false, false, AC_3REG, ITYPE_INTBASIC},
{"shr", false, false, false, false, AC_3REG, ITYPE_INTBASIC},
{"andi", false, false, false, false, AC_3IMM, ITYPE_INTBASIC},
{"ori", false, false, false, false, AC_3IMM, ITYPE_INTBASIC},
{"xori", false, false, false, false, AC_3IMM, ITYPE_INTBASIC},
{"addi", false, false, false, false, AC_3IMM, ITYPE_INTBASIC},
{"subi", false, false, false, false, AC_3IMM, ITYPE_INTBASIC},
{"muli", false, false, false, false, AC_3IMM, ITYPE_INTMUL },
{"divi", false, false, false, false, AC_3IMM, ITYPE_INTDIV },
{"modi", false, false, false, false, AC_3IMM, ITYPE_INTDIV },
{"shli", false, false, false, false, AC_3IMM, ITYPE_INTBASIC},
{"shri", false, false, false, false, AC_3IMM, ITYPE_INTBASIC},
{"jali", true, true, false, false, AC_2IMM, ITYPE_CALL },
{"jalr", true, false, false, false, AC_2REG, ITYPE_CALL },
{"jmpi", true, true, true, false, AC_1IMM, ITYPE_BR },
{"jmpr", true, false, true, false, AC_1REG, ITYPE_RET },
{"clone", true, false, false, false, AC_1REG, ITYPE_NULL },
{"jalis", true, true, false, false, AC_3IMM, ITYPE_CALL },
{"jalrs", true, false, false, false, AC_3REG, ITYPE_CALL },
{"jmprt", true, false, true, false, AC_1REG, ITYPE_RET },
{"ld", false, false, false, false, AC_3IMM, ITYPE_NULL },
{"st", false, false, true, false, AC_3IMMSRC, ITYPE_NULL },
{"ldi", false, false, false, false, AC_2IMM, ITYPE_NULL },
{"rtop", false, false, false, false, AC_PREG_REG, ITYPE_NULL },
{"andp", false, false, false, false, AC_3PREG, ITYPE_INTBASIC},
{"orp", false, false, false, false, AC_3PREG, ITYPE_INTBASIC},
{"xorp", false, false, false, false, AC_3PREG, ITYPE_INTBASIC},
{"notp", false, false, false, false, AC_3PREG, ITYPE_INTBASIC},
{"isneg", false, false, false, false, AC_PREG_REG, ITYPE_INTBASIC},
{"iszero", false, false, false, false, AC_PREG_REG, ITYPE_INTBASIC},
{"halt", false, false, false, true, AC_NONE, ITYPE_NULL },
{"trap", true, false, false, false, AC_NONE, ITYPE_TRAP },
{"jmpru", false, false, false, true, AC_1REG, ITYPE_RET },
{"skep", false, false, false, true, AC_1REG, ITYPE_NULL },
{"reti", true, false, false, true, AC_NONE, ITYPE_RET },
{"tlbrm", false, false, false, true, AC_1REG, ITYPE_NULL },
{"itof", false, false, false, false, AC_2REG, ITYPE_FPBASIC },
{"ftoi", false, false, false, false, AC_2REG, ITYPE_FPBASIC },
{"fadd", false, false, false, false, AC_3REG, ITYPE_FPBASIC },
{"fsub", false, false, false, false, AC_3REG, ITYPE_FPBASIC },
{"fmul", false, false, false, false, AC_3REG, ITYPE_FPMUL },
{"fdiv", false, false, false, false, AC_3REG, ITYPE_FPDIV },
{"fneg", false, false, false, false, AC_2REG, ITYPE_FPBASIC },
{NULL,false,false,false,false,AC_NONE,ITYPE_NULL}/////// End of table.
};
ostream &Harp::operator<<(ostream& os, Instruction &inst) {
@ -102,6 +102,10 @@ ostream &Harp::operator<<(ostream& os, Instruction &inst) {
}
void Instruction::executeOn(Core &c) {
#ifdef EMU_INSTRUMENTATION
#error TODO: instrument Harp::Instruction::executeOn()
#endif
/* If I try to execute a privileged instruction in user mode, throw an
exception 3. */
if (instTable[op].privileged && !c.supervisorMode) {

View file

@ -110,6 +110,9 @@ MemoryUnit::TLBEntry MemoryUnit::tlbLookup(Addr vAddr, Word flagMask) {
}
Word MemoryUnit::read(Addr vAddr, bool sup) {
#ifdef EMU_INSTRUMENTATION
#error TODO: instrument Harp::MemoryUnit::read()
#endif
Word flagMask = sup?8:1;
TLBEntry t = tlbLookup(vAddr, flagMask);
Addr pAddr = t.pfn*pageSize + vAddr%pageSize;
@ -117,6 +120,9 @@ Word MemoryUnit::read(Addr vAddr, bool sup) {
}
Word MemoryUnit::fetch(Addr vAddr, bool sup) {
#ifdef EMU_INSTRUMENTATION
#error TODO: instrument Harp::MemoryUnit::fetch()
#endif
Word flagMask = sup?32:4;
TLBEntry t = tlbLookup(vAddr, flagMask);
Addr pAddr = t.pfn*pageSize + vAddr%pageSize;
@ -124,6 +130,9 @@ Word MemoryUnit::fetch(Addr vAddr, bool sup) {
}
void MemoryUnit::write(Addr vAddr, Word w, bool sup) {
#ifdef EMU_INSTRUMENTATION
#error TODO: instrument Harp::MemoryUnit::write()
#endif
Word flagMask = sup?16:2;
TLBEntry t = tlbLookup(vAddr, flagMask);
Addr pAddr = t.pfn*pageSize + vAddr%pageSize;