SoftcardToolPeekPokeImpl:
CEDAR
PROGRAM
IMPORTS
Buttons, IO, ViewerTools,
SoftcardOps, SoftcardToolPrivate
EXPORTS
SoftcardToolPrivate
= BEGIN OPEN IO, SoftcardToolPrivate;
peekPokeAddrText: Viewer;
peekPokeValText: Viewer;
peekPokeShortLabel: Viewer;
isShort: BOOL ← TRUE;
dumpAddrText: Viewer;
dumpNumText: Viewer;
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
builds the miscellaneous buttons - sib is the last button created
BuildPeekPokeButtons:
PUBLIC
PROC[topViewer, sibx: Viewer]
RETURNS[Viewer] = {
sib: Viewer ← sibx;
line 6 of Buttons
sib ← Buttons.Create[
info: [ name: " Peek ", parent: topViewer,
wx: 3, wy: sib.wy+sib.wh+2, wh: entryHeight, border: TRUE, scrollable: FALSE],
proc: PeekProc ];
sib ← Buttons.Create[
info: [ name: " Poke ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE],
proc: PokeProc ];
sib ← peekPokeShortLabel ← Buttons.Create[
info: [ name: " short ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE],
proc: ShortOrLongProc ];
sib ← Buttons.Create[
info: [ name: " Addr: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE],
proc: PeekPokeAddrProc ];
sib ← peekPokeAddrText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy,
ww: 120, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [ name: " Val: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE],
proc: PeekPokeValProc ];
sib ← peekPokeValText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy,
ww: 300, wh: entryHeight, border: FALSE, scrollable: FALSE]];
line 7 of Buttons
sib ← Buttons.Create[
info: [ name: " DumpShort ", parent: topViewer,
wx: 3, wy: sib.wy+sib.wh+2, wh: entryHeight, border: TRUE, scrollable: FALSE],
proc: DumpShortProc ];
sib ← Buttons.Create[
info: [ name: " DumpLong ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE],
proc: DumpLongProc ];
sib ← Buttons.Create[
info: [ name: " Addr: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE],
proc: DumpAddrProc ];
sib ← dumpAddrText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy,
ww: 120, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [ name: " Num: ", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE],
proc: DumpNumProc ];
sib ← dumpNumText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+6, wy: sib.wy,
ww: 300, wh: entryHeight, border: FALSE, scrollable: FALSE]];
RETURN[sib];
};
PeekProc: ClickProc = {
addr: LONG CARDINAL = GetAsCard[peekPokeAddrText];
longVal: LONG CARDINAL;
BEGIN
ENABLE SoftcardOps.Error => {
tsOut.PutF[explanation];
GOTO exit
};
IF isShort
THEN longVal ← SoftcardOps.ReadShort[addr]
ELSE longVal ← SoftcardOps.ReadLong[addr];
EXITS exit => RETURN;
END;
tsOut.PutF[" The %g value of addr: %xH is %xH\n",
IO.rope[IF isShort THEN "short" ELSE "long"], IO.card[addr], IO.card[longVal] ];
ViewerTools.SetContents[peekPokeValText, IO.PutFR["%xH", IO.card[longVal]] ];
};
PokeProc: ClickProc = {
addr: LONG CARDINAL = GetAsCard[peekPokeAddrText];
longVal: LONG CARDINAL = GetAsCard[peekPokeValText];
BEGIN
ENABLE SoftcardOps.Error => {
tsOut.PutF[explanation];
GOTO exit
};
IF isShort
THEN {
shortVal: CARDINAL ← longVal;
SoftcardOps.WriteShort[addr, shortVal];
}
ELSE SoftcardOps.WriteLong[addr, longVal];
EXITS exit => RETURN;
END;
tsOut.PutF[" The %g value of addr: %xH has bbe set to %xH\n",
IO.rope[IF isShort THEN "short" ELSE "long"], IO.card[addr], IO.card[longVal] ];
};
ShortOrLongProc: ClickProc = {
IF isShort
THEN Buttons.ReLabel[peekPokeShortLabel, " long "]
ELSE Buttons.ReLabel[peekPokeShortLabel, " short "];
isShort ← ~isShort;
};
PeekPokeAddrProc: ClickProc =
{ ViewerTools.SetSelection[peekPokeAddrText, NIL] };
PeekPokeValProc: ClickProc =
{ ViewerTools.SetSelection[peekPokeValText, NIL] };
DumpShortProc: ClickProc = {
addr: LONG CARDINAL = GetAsCard[dumpAddrText];
num: LONG CARDINAL = GetAsCard[dumpNumText];
shortNum: CARDINAL ← num;
count: CARDINAL ← shortNum;
index: CARDINAL ← 0;
seq: SoftcardOps.SeqShort;
format: ROPE = " %04x";
BEGIN
ENABLE SoftcardOps.Error => {
tsOut.PutF[explanation];
GOTO exit
};
seq ← SoftcardOps.DumpShort[addr, shortNum];
EXITS exit => RETURN;
END;
tsOut.PutF["\n Dumping %g short numbers starting at addr: %xH\n",
IO.card[num], IO.card[addr] ];
WHILE count >= 8
DO
tsOut.PutF["%xH:", IO.card[addr+index] ];
FOR i:
CARDINAL
IN [0..8)
DO
tsOut.PutF[format, IO.card[seq[index+i]] ];
ENDLOOP;
tsOut.PutChar['\n];
index ← index + 8;
count ← count - 8;
ENDLOOP;
tsOut.PutF["%xH:", IO.card[addr+index] ];
FOR i:
CARDINAL
IN [0..count)
DO
tsOut.PutF[format, IO.card[seq[index+i]] ];
ENDLOOP;
tsOut.PutChar['\n];
};
DumpLongProc: ClickProc = {
};
DumpAddrProc: ClickProc =
{ ViewerTools.SetSelection[dumpAddrText, NIL] };
DumpNumProc: ClickProc =
{ ViewerTools.SetSelection[dumpNumText, NIL] };
ResetProc: ClickProc = { tsOut.PutRope[" Not yet implemented - ResetDragon\n"] };
ReadClockProc: ClickProc = {
val: LONG CARDINAL = SoftcardOps.ReadClock[];
tsOut.PutF[" Current clock reading is: %xH\n", IO.card[val] ];
};
EUPBusDataProc: ClickProc = {
val: LONG CARDINAL = SoftcardOps.ReadEUPBusData[];
tsOut.PutF[" EUPBusData: %xH\n", IO.card[val] ];
};
IFUPBusDataProc: ClickProc = {
val: LONG CARDINAL = SoftcardOps.ReadIFUPBusData[];
tsOut.PutF[" IFUPBusData: %xH\n", IO.card[val] ];
};
EUPBusCmdProc: ClickProc = {
val: SoftcardOps.EUPBusCmd = SoftcardOps.ReadEUCmd[];
tsOut.PutF[" EUPBusCmd: [userMode: %g, unspecifiedAsYet: %xH]\n",
IO.bool[val.userMode], IO.int[val.unspecifiedAsYet] ];
};
IFUPBusCmdProc: ClickProc = {
val: SoftcardOps.IFUPBusCmd = SoftcardOps.ReadIFUCmd[];
tsOut.PutF[" IFUPBusCmd: %g\n",
IO.rope[IF val = noAccess THEN "noAccess" ELSE "access"] ];
};
ResetEUCacheStateProc: ClickProc = {
SoftcardOps.ResetEUCacheStateMachine[];
tsOut.PutRope[" ResetEUCacheStateMachine has been done\n"];
};
ResetIFUCacheStateProc: ClickProc = {
SoftcardOps.ResetIFUCacheStateMachine[];
tsOut.PutRope[" ResetIFUCacheStateMachine has been done\n"];
};
ResetCounterProc: ClickProc = {
SoftcardOps.ResetCounter[];
tsOut.PutRope[" ResetCounter has been done\n"];
};
DisableEUCacheProc: ClickProc = {
SoftcardOps.DisableEUCache[];
tsOut.PutRope[" DisableEUCache has been done\n"];
};
DisableIFUCacheProc: ClickProc = {
SoftcardOps.DisableIFUCache[];
tsOut.PutRope[" DisableIFUCache has been done\n"];
};
FlushEUCache
Proc: ClickProc = {
SoftcardOps.FlushEUCache[];
tsOut.PutRope[" FlushEUCache has been done\n"];
};
FlushIFUCache
Proc: ClickProc = {
SoftcardOps.FlushIFUCache[];
tsOut.PutRope[" FlushIFUCache has been done\n"];
};