diff --git a/src/escan.l b/src/escan.l index e3582bc..3384f83 100644 --- a/src/escan.l +++ b/src/escan.l @@ -153,13 +153,13 @@ static REG getVal(struct isym *psym) { switch (psym->type) { case SINGLE_SYM: - return psym->getFn(viewPid); + return psym->getFn1(viewPid); case REGSET_SYM: - return psym->getFn(viewPid, psym->ndx); + return psym->getFn2(viewPid, psym->ndx); case BITF_SYM: - return (psym->getFn(viewPid) << (63 - psym->start)) >> (64 - psym->len); + return (psym->getFn1(viewPid) << (63 - psym->start)) >> (64 - psym->len); case RS_BITF_SYM: - return (psym->getFn(viewPid, psym->ndx) << (63 - psym->start)) >> (64 - psym->len); + return (psym->getFn2(viewPid, psym->ndx) << (63 - psym->start)) >> (64 - psym->len); default: return 0; } diff --git a/src/ssDDM.c b/src/ssDDM.c index 3739f44..ebaddb7 100644 --- a/src/ssDDM.c +++ b/src/ssDDM.c @@ -133,8 +133,8 @@ BOOL valAssign(unsigned argc, char *argv[]) switch (sym.type) { case SINGLE_SYM: - if (sym.setFn) { - if (!sym.setFn(0, val)) { + if (sym.setFn2) { + if (!sym.setFn2(0, val)) { cmdErr("Attempt to modify symbol failed\n"); return NO; } @@ -144,8 +144,8 @@ BOOL valAssign(unsigned argc, char *argv[]) } break; case REGSET_SYM: - if (sym.setFn) { - if (!sym.setFn(0, sym.ndx, val)) { + if (sym.setFn3) { + if (!sym.setFn3(0, sym.ndx, val)) { cmdErr("Attempt to modify symbol failed\n"); return NO; } @@ -155,13 +155,13 @@ BOOL valAssign(unsigned argc, char *argv[]) } break; case BITF_SYM: - if (sym.setFn) { - REG oldval = sym.getFn(0), mask; + if (sym.setFn2) { + REG oldval = sym.getFn1(0), mask; mask = ONES(sym.len) << (sym.start - (sym.len - 1)); val <<= sym.start - (sym.len - 1); val = (oldval & ~mask) | (val & mask); - if (!sym.setFn(0, val)) { + if (!sym.setFn2(0, val)) { cmdErr("Attempt to modify symbol failed\n"); return NO; } @@ -171,13 +171,13 @@ BOOL valAssign(unsigned argc, char *argv[]) } break; case RS_BITF_SYM: - if (sym.setFn) { - REG oldval = sym.getFn(0, sym.ndx), mask; + if (sym.setFn3) { + REG oldval = sym.getFn2(0, sym.ndx), mask; mask = ONES(sym.len) << (sym.start - (sym.len - 1)); val <<= sym.start - (sym.len - 1); val = (oldval & ~mask) | (val & mask); - if (!sym.setFn(0, sym.ndx, val)) { + if (!sym.setFn3(0, sym.ndx, val)) { cmdErr("Attempt to modify symbol failed\n"); return NO; } diff --git a/src/ssDSym.c b/src/ssDSym.c index d26b798..a4c682b 100644 --- a/src/ssDSym.c +++ b/src/ssDSym.c @@ -125,21 +125,21 @@ static void isymChk(const char *sname) * into the internal symbol table. *---------------------------------------------------------------------------*/ -static void isymIns1(const char *sname, PGetFn gf, PSetFn sf, int dbase) +static void isymIns1(const char *sname, PGetFn1 gf, PSetFn2 sf, int dbase) { isymChk(sname); - isymtbl[topisym].getFn = gf; - isymtbl[topisym].setFn = sf; + isymtbl[topisym].getFn1 = gf; + isymtbl[topisym].setFn2 = sf; isymtbl[topisym].type = SINGLE_SYM; isymtbl[topisym].dbase = dbase; topisym++; } -static void isymIns2(const char *sname, PGetFn gf, PSetFn sf, int dbase, int ndx) +static void isymIns2(const char *sname, PGetFn2 gf, PSetFn3 sf, int dbase, int ndx) { isymChk(sname); - isymtbl[topisym].getFn = gf; - isymtbl[topisym].setFn = sf; + isymtbl[topisym].getFn2 = gf; + isymtbl[topisym].setFn3 = sf; isymtbl[topisym].type = REGSET_SYM; if (ndx >= 0) { /* specific register in a register set */ isymtbl[topisym].ndx = ndx; @@ -155,12 +155,12 @@ static void isymIns2(const char *sname, PGetFn gf, PSetFn sf, int dbase, int ndx /* len is bit-field length, start is the little-endian bit number of the left edge of the field */ -static void isymIns3(const char *sname, PGetFn gf, PSetFn sf, int dbase, +static void isymIns3(const char *sname, PGetFn1 gf, PSetFn2 sf, int dbase, unsigned start, unsigned len) { isymChk(sname); - isymtbl[topisym].getFn = gf; - isymtbl[topisym].setFn = sf; + isymtbl[topisym].getFn1 = gf; + isymtbl[topisym].setFn2 = sf; isymtbl[topisym].type = BITF_SYM; isymtbl[topisym].len = len; isymtbl[topisym].start = start; @@ -168,12 +168,12 @@ static void isymIns3(const char *sname, PGetFn gf, PSetFn sf, int dbase, topisym++; } -static void isymIns4(const char *sname, PGetFn gf, PSetFn sf, int dbase, unsigned ndx, +static void isymIns4(const char *sname, PGetFn2 gf, PSetFn3 sf, int dbase, unsigned ndx, unsigned start, unsigned len) { isymChk(sname); - isymtbl[topisym].getFn = gf; - isymtbl[topisym].setFn = sf; + isymtbl[topisym].getFn2 = gf; + isymtbl[topisym].setFn3 = sf; isymtbl[topisym].type = RS_BITF_SYM; isymtbl[topisym].ndx = ndx; isymtbl[topisym].len = len; @@ -214,6 +214,23 @@ struct isym *isymVLkp(const char *sname) return NULL; } +/* Wrappers to match types for the fetcher. + * TODO: extract 0-getters into it's own symbol type. + */ + +#define MK_ACCESSOR_01(wrapper, orig) \ +static REG wrapper(int unused) \ +{ \ + (void)unused; \ + return orig(); \ +} + + +MK_ACCESSOR_01(getTotalCycles1, getTotalCycles); +MK_ACCESSOR_01(getTotalInsts1, getTotalInsts); +MK_ACCESSOR_01(getTotalFaults1, getTotalFaults); +MK_ACCESSOR_01(getExited1, getExited); + /*--------------------------------------------------------------------------- * internalSymbol$Init - Initialize the internal symbol table. *---------------------------------------------------------------------------*/ @@ -503,14 +520,14 @@ void isymInit(void) isymIns4("eflags.pf", arGet, arSet, HEXEXP, EFLAGS_ID, 2, 1); isymIns4("eflags.cf", arGet, arSet, HEXEXP, EFLAGS_ID, 0, 1); - isymIns1("$insts$", getTotalInsts, NULL, DECEXP); - isymIns1("$cycles$", getTotalCycles, NULL, DECEXP); - isymIns1("$faults$", getTotalFaults, NULL, DECEXP); + isymIns1("$insts$", getTotalInsts1, NULL, DECEXP); + isymIns1("$cycles$", getTotalCycles1, NULL, DECEXP); + isymIns1("$faults$", getTotalFaults1, NULL, DECEXP); #ifdef NEW_MP isymIns1("$pid$", getCurPid, NULL, DECEXP); #endif isymIns1("$heap$", heapGet, NULL, HEXEXP); - isymIns1("$exited$", getExited, NULL, HEXEXP); + isymIns1("$exited$", getExited1, NULL, HEXEXP); qsort((void *)isymtbl, topisym, sizeof (struct isym), cmpisym); #if 0 diff --git a/src/state.c b/src/state.c index ca4a4e2..0f8430a 100644 --- a/src/state.c +++ b/src/state.c @@ -605,7 +605,7 @@ BOOL grSet(int proc, int i, REG val) return YES; } -BOOL grNatSet(int proc, int i, BOOL nat) +BOOL grNatSet(int proc, int i, REG nat) { REG val; BOOL old; @@ -643,7 +643,7 @@ BOOL phyGrSet(int proc, int i, REG val) return YES; } -BOOL phyGrNatSet(int proc, int i, BOOL nat) +BOOL phyGrNatSet(int proc, int i, REG nat) { if (!i && nat) return NO; @@ -681,7 +681,7 @@ BOOL frSignSet(int proc, int i, REG val) return YES; } -BOOL frExpSet(int proc, int i, WORD exp) +BOOL frExpSet(int proc, int i, REG exp) { FREG fr; BYTE sign; @@ -697,7 +697,7 @@ BOOL frExpSet(int proc, int i, WORD exp) return YES; } -BOOL frMantSet(int proc, int i, DWORD mant) +BOOL frMantSet(int proc, int i, REG mant) { FREG fr; BYTE sign; @@ -771,7 +771,7 @@ BOOL phyFrMantSet(int proc, int i, DWORD mant) return YES; } -BOOL prSet(int proc, int i, BOOL val) +BOOL prSet(int proc, int i, REG val) { if (!i && !val) return NO; @@ -950,7 +950,7 @@ BOOL bkrSet(int proc, int i, REG val) return YES; } -BOOL bkrNatSet(int proc, int i, BOOL nat) +BOOL bkrNatSet(int proc, int i, REG nat) { #ifdef NEW_MP mpState[proc].bankedGrs_[i].nat = nat & 1; diff --git a/src/state.h b/src/state.h index cf2106b..7c84e23 100644 --- a/src/state.h +++ b/src/state.h @@ -570,16 +570,16 @@ void cfmSet(int cproc, REG val); BOOL frSignSet(int cproc, int i, REG val); /* Sets the exponent field of virtual FR[i] for cproc */ -BOOL frExpSet(int cproc, int i, WORD exp); +BOOL frExpSet(int cproc, int i, REG exp); /* Sets the mantissa field of virtual FR[i] for cproc */ -BOOL frMantSet(int cproc, int i, DWORD mant); +BOOL frMantSet(int cproc, int i, REG mant); /* Sets the ip for cproc */ BOOL ipSet(int cproc, REG val); /* Sets the virtual GR[i].nat for cproc */ -BOOL grNatSet(int cproc, int i, BOOL nat); +BOOL grNatSet(int cproc, int i, REG nat); /* Sets the virtual GR[i] for cproc */ BOOL grSet(int cproc, int i, REG val); @@ -594,7 +594,7 @@ BOOL phyFrExpSet(int cproc, int i, WORD exp); BOOL phyFrMantSet(int cproc, int i, DWORD mant); /* Sets the physical GR[i].nat for cproc */ -BOOL phyGrNatSet(int cproc, int i, BOOL nat); +BOOL phyGrNatSet(int cproc, int i, REG nat); /* Sets the physical GR[i] for cproc */ BOOL phyGrSet(int cproc, int i, REG val); @@ -603,7 +603,7 @@ BOOL phyGrSet(int cproc, int i, REG val); BOOL phyPrSet(int cproc, int i, BOOL val); /* Sets the virtual PR[i] for cproc */ -BOOL prSet(int cproc, int i, BOOL val); +BOOL prSet(int cproc, int i, REG val); /* Sets the psr for cproc */ BOOL psrSet(int cproc, REG val); @@ -646,7 +646,7 @@ BOOL crSet(int cproc, int i, REG val); BOOL bkrSet(int cproc, int i, REG val); /* Sets the banked GR[i].nat for cproc */ -BOOL bkrNatSet(int cproc, int i, BOOL val); +BOOL bkrNatSet(int cproc, int i, REG val); /* Sets RR[i] for cproc */ BOOL rrSet(int cproc, int i, REG val); diff --git a/src/ui.h b/src/ui.h index b767c89..57d239e 100644 --- a/src/ui.h +++ b/src/ui.h @@ -24,8 +24,10 @@ typedef enum { * Internal symbol interface *-------------------------------------------------------------------------*/ -typedef REG (*PGetFn)(/* TODO: add prototype here */); -typedef BOOL (*PSetFn)(/* TODO: add prototype here */); +typedef REG (*PGetFn1)(int); +typedef REG (*PGetFn2)(int, int); +typedef BOOL (*PSetFn2)(int, REG); +typedef BOOL (*PSetFn3)(int, int, REG); typedef enum { SINGLE_SYM, @@ -54,8 +56,13 @@ typedef enum { struct isym { char name[NAMLEN]; /* internal symbol name */ Symtyp type; /* internal symbol type */ - PGetFn getFn; - PSetFn setFn; + + PGetFn1 getFn1; + PGetFn2 getFn2; + + PSetFn2 setFn2; + PSetFn3 setFn3; + void *pval; BOOL readonly; /* is symbol read-only */ unsigned len; /* subfield length (len == 0 => not a subfld) */