SoftcardTool.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Willie-Sue, February 10, 1987 3:49:21 pm PST
DIRECTORY
Commander USING [CommandProc, Handle, Register],
Convert USING [Error, IntFromRope],
FS USING [SetKeep],
IO,
Rope,
Buttons USING [Button, ButtonProc, Create, ReLabel],
Containers USING [ChildXBound, ChildYBound],
Labels USING [Create],
Menus USING [ClickProc],
PopUpSelection USING [Request],
Rules USING [Create],
RuntimeError USING [BoundsFault],
TypeScript USING [Create],
ViewerClasses USING [Viewer, ViewerRec],
ViewerIO USING [CreateViewerStreams],
ViewerOps USING [CreateViewer],
ViewerTools USING [GetContents, MakeNewTextViewer, SetContents, SetSelection],
SoftcardOps;
SoftcardTool: CEDAR MONITOR
IMPORTS
Commander, Convert, FS, IO, PopUpSelection, RuntimeError,
Buttons, Containers, Labels, Rules, TypeScript, ViewerIO, ViewerOps, ViewerTools,
SoftcardOps
= BEGIN OPEN IO;
STREAM: TYPE = IO.STREAM;
ROPE: TYPE = Rope.ROPE;
Viewer: TYPE = ViewerClasses.Viewer;
ClickProc: TYPE = Menus.ClickProc;
entryHeight: INTEGER = 14;
xFudge: INTEGER = 4;
variables
tsViewer, topViewer: Viewer;
tsOut: STREAM;
runOrStopButton: Viewer;
runChoice: ROPE = " DragonRun ";
stopChoice: ROPE = " DragonStop ";
unknownChoice: ROPE = " Unknown ";
dragonState: DragonState ← unknown;
connectionText: Viewer;
freqSelectText: Viewer;
phaseAdjustText: Viewer;
delayText: Viewer;
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
MakeControlWindow: PROC[name, tsLogFile: ROPE] RETURNS [STREAM] = {
IF topViewer = NIL OR topViewer.destroyed THEN {
y: INTEGER;
sib: Viewer;
topViewer ← ViewerOps.CreateViewer[
flavor: $Container,
info: [name: name, iconic: FALSE, scrollable: FALSE] ];
line 1 of Buttons
sib ← Buttons.Create[
info: [ name: " EstablishConnection ", parent: topViewer,
 wx: 3, wy: 4, wh: entryHeight, border: TRUE, scrollable: FALSE],
proc: OpenConnectionProc ];
sib ← Buttons.Create[
info: [ name: " CloseConnection ", parent: topViewer,
 wx: sib.wx+sib.ww+1, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: CloseConnectionProc ];
sib ← Buttons.Create[
info: [ name: "Host:", parent: topViewer,
 wx: sib.wx+sib.ww+10, wy: sib.wy, wh: entryHeight,
 border: FALSE, scrollable: FALSE],
proc: ConnectionTextProc ];
sib ← connectionText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge, wy: sib.wy,
 ww: 1000, wh: entryHeight, border: FALSE, scrollable: TRUE]];
Containers.ChildXBound[topViewer, sib];
line 2 of Buttons - ControlBits
sib ← Labels.Create[
info: [ name: " ControlBits ", parent: topViewer,
 wx: 3, wy: sib.wy + sib.wh + 2, wh: entryHeight,
 border: FALSE, scrollable: FALSE]
];
sib ← Buttons.Create[
info: [ name: " Read ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: ReadControlBits ];
sib ← Buttons.Create[
info: [name: " Set ", parent: topViewer,
 wx: sib.wx+sib.ww+1, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE ],
proc: SetControlBits ];
sib ← Buttons.Create[
info: [name: " Reset ", parent: topViewer,
wx: sib.wx+sib.ww+1, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE ],
proc: ResetControlBits ];
line 3 of Buttons - StatusBits
sib ← Labels.Create[
info: [ name: " StatusBits ", parent: topViewer,
 wx: 3, wy: sib.wy + sib.wh + 2, wh: entryHeight,
 border: FALSE, scrollable: FALSE]
];
sib ← Buttons.Create[
info: [ name: " Read ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: ReadStatusBits ];
sib ← Buttons.Create[
info: [name: " Reset ", parent: topViewer,
wx: sib.wx+sib.ww+1, wy: sib.wy, wh: entryHeight,
border: TRUE, scrollable: FALSE ],
proc: ResetStatusBits ];
line 4 of Buttons
sib ← Labels.Create[
info: [ name: " ClockControl ", parent: topViewer,
 wx: 3, wy: sib.wy+sib.wh+2, wh: entryHeight, border: FALSE, scrollable: FALSE]
];
sib ← Buttons.Create[
info: [name: "Read", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
proc: ReadClockControl ];
sib ← Buttons.Create[
info: [name: "Write", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
proc: WriteClockControl ];
sib ← Buttons.Create[
info: [name: "FreqSelect [0..3]", parent: topViewer,
wx: sib.wx+sib.ww+xFudge+1, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
proc: FreqSelectProc ];
sib ← freqSelectText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 20, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: "PhaseAdjust [0..7]", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
proc: PhaseAdjustProc ];
sib ← phaseAdjustText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 20, wh: entryHeight, border: FALSE, scrollable: FALSE]];
sib ← Buttons.Create[
info: [name: "Delay [0..7]", parent: topViewer,
wx: sib.wx+sib.ww+xFudge, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
proc: DelayProc ];
sib ← delayText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge+2, wy: sib.wy,
 ww: 20, wh: entryHeight, border: FALSE, scrollable: FALSE]];
line 5 of Buttons
sib ← runOrStopButton ← Buttons.Create[
info: [ name: unknownChoice, parent: topViewer,
 wx: 3, wy: sib.wy + sib.wh + 2, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: RunOrStopProc ];
line 6 of Buttons - miscellaneous
sib ← Buttons.Create[
info: [ name: " ResetBoard ", parent: topViewer,
 wx: 3, wy: sib.wy + sib.wh + 2, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: ResetProc ];
sib ← Buttons.Create[
info: [ name: " ReadClock ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: ReadClockProc ];
sib ← Buttons.Create[
info: [ name: " EUPBusData ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: EUPBusDataProc ];
sib ← Buttons.Create[
info: [ name: " IFUPBusData ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: IFUPBusDataProc ];
sib ← Buttons.Create[
info: [ name: " EUPBusCmd ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: EUPBusCmdProc ];
sib ← Buttons.Create[
info: [ name: " IFUPBusCmd ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: IFUPBusCmdProc ];
line 7 of Buttons - miscellaneous
sib ← Buttons.Create[
info: [ name: " ResetEUCacheStateMachine ", parent: topViewer,
 wx: 3, wy: sib.wy + sib.wh + 2, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: ResetEUCacheStateProc ];
sib ← Buttons.Create[
info: [ name: " ResetIFUCacheStateMachine ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: ResetIFUCacheStateProc ];
sib ← Buttons.Create[
info: [ name: " ResetCounter ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: ResetCounterProc ];
line 8 of Buttons - miscellaneous
sib ← Buttons.Create[
info: [ name: " DisableEUCache ", parent: topViewer,
 wx: 3, wy: sib.wy + sib.wh + 2, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: DisableEUCacheProc ];
sib ← Buttons.Create[
info: [ name: " DisableIFUCache ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: DisableIFUCacheProc ];
sib ← Buttons.Create[
info: [ name: " FlushEUCache ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: FlushEUCacheProc ];
sib ← Buttons.Create[
info: [ name: " FlushIFUCache ", parent: topViewer,
 wx: sib.wx+sib.ww+5, wy: sib.wy, wh: entryHeight,
 border: TRUE, scrollable: FALSE],
proc: FlushIFUCacheProc ];
the rest of the viewer - typescript
sib ← Rules.Create[
info: [parent: topViewer, wy: sib.wy+sib.wh+1, ww: topViewer.ww, wh: 2]];
Containers.ChildXBound[topViewer, sib];
y ← sib.wy+sib.wh+4;
tsViewer ← TypeScript.Create[
info: [parent: topViewer, ww: sib.cw, wy: y, wh: topViewer.ch - y, border: FALSE] ];
Containers.ChildYBound[topViewer, tsViewer];
Containers.ChildXBound[topViewer, tsViewer];
tsOut ← ViewerIO.CreateViewerStreams[NIL, tsViewer, tsLogFile, FALSE].out;
FS.SetKeep[tsLogFile, 6];
tsOut.PutF["\tTypescript on file: %g\n", IO.rope[tsLogFile]];
tsOut.Flush[];
};
topViewer.inhibitDestroy ← TRUE;
RETURN[tsOut];
};
OpenConnectionProc: ClickProc = {
name: ROPE = ViewerTools.GetContents[connectionText];
ok: BOOL = SoftcardOps.EstablishConnection[name];
isRunning: BOOL = SoftcardOps.REadControlBit[dragonRun];
IF isRunning THEN {
Buttons.ReLabel[runOrStopButton, stopChoice];
dragonState ← running;
}
ELSE {
Buttons.ReLabel[runOrStopButton, runChoice];
dragonState ← stopped;
};
IF ok THEN tsOut.PutF["Connection to %g has been established\n", IO.rope[name]]
ELSE
tsOut.PutF["Could not establish connection with %g has \n", IO.rope[name]];
};
CloseConnectionProc: ClickProc = {
SoftcardOps.CloseConnection[];
tsOut.PutRope["Connection has been closed\n\n"];
Buttons.ReLabel[runOrStopButton, unknownChoice];
dragonState ← unknown;
};
ReadControlBits: ClickProc = {
which: SoftcardOps.ControlBit;
name: ROPE;
val: BOOL;
[which, name] ← SelectControlBit[];
IF name = NIL THEN RETURN;
val ← SoftcardOps.ReadControlBit[which];
tsOut.PutF[" %g is %g\n", IO.rope[name], IO.bool[val] ];
};
SetControlBits: ClickProc = {
which: SoftcardOps.ControlBit;
name: ROPE;
prev: BOOL;
[which, name] ← SelectControlBit[];
IF name = NIL THEN RETURN;
prev ← SoftcardOps.SetControlBit[which];
tsOut.PutF[" %g has been set: previous value was %g\n", IO.rope[name], IO.bool[prev] ];
};
ResetControlBits: ClickProc = {
which: SoftcardOps.ControlBit;
name: ROPE;
prev: BOOL;
[which, name] ← SelectControlBit[];
IF name = NIL THEN RETURN;
prev ← SoftcardOps.ResetControlBit[which];
tsOut.PutF[" %g has been reset: previous value was %g\n", IO.rope[name], IO.bool[prev] ];
};
controlBitList: LIST OF ROPE = LIST[
"resetDragon", "notInterruptDragonToIOP", "interruptDragonToMesa", "dragonRun", "dragonStep", "writeParity", "virtualMemAccessIOP", "virtualMemAccessMesa", "virtualMemAccessIFU", "virtualMemAccessEU", "resetIFUCacheStateMachine", "notResetIFUCache", "ifuBreakpointEnabled", "resetEUCacheStateMachine", "notResetEUCache", "euBreakpointEnabled", "iopIntToDragon", "mesaIntToDragon", "notResetCounter"];
SelectControlBit: PROC RETURNS[SoftcardOps.ControlBit, ROPE] = {
which: INT = PopUpSelection.Request[
header: "ControlBit",
choice: controlBitList];
SELECT which FROM
1 => RETURN[resetDragon, "resetDragon"];
2 => RETURN[notInterruptDragonToIOP, "notInterruptDragonToIOP"];
3 => RETURN[interruptDragonToMesa, "interruptDragonToMesa"];
4 => RETURN[dragonRun, "dragonRun"];
5 => RETURN[dragonStep, "dragonStep"];
6 => RETURN[writeParity, "writeParity"];
7 => RETURN[virtualMemAccessIOP, "virtualMemAccessIOP"];
8 => RETURN[virtualMemAccessMesa, "virtualMemAccessMesa"];
9 => RETURN[virtualMemAccessIFU, "virtualMemAccessIFU"];
10 => RETURN[virtualMemAccessEU, "virtualMemAccessEU"];
11 => RETURN[resetIFUCacheStateMachine, "resetIFUCacheStateMachine"];
12 => RETURN[notResetIFUCache, "notResetIFUCache"];
13 => RETURN[ifuBreakpointEnabled, "ifuBreakpointEnabled"];
14 => RETURN[resetEUCacheStateMachine, "resetEUCacheStateMachine"];
15 => RETURN[notResetEUCache, "notResetEUCache"];
16 => RETURN[euBreakpointEnabled, "euBreakpointEnabled"];
17 => RETURN[iopIntToDragon, "iopIntToDragon"];
18 => RETURN[mesaIntToDragon, "mesaIntToDragon"];
19 => RETURN[notResetCounter, "notResetCounter"];
ENDCASE => RETURN[resetDragon, NIL];
};
ReadStatusBits: ClickProc = {
which: SoftcardOps.StatusBit;
name: ROPE;
val: BOOL;
[which, name] ← SelectStatusBit[];
IF name = NIL THEN RETURN;
val ← SoftcardOps.ReadStatusBit[which];
tsOut.PutF[" %g is %g\n", IO.rope[name], IO.bool[val] ];
};
ResetStatusBits: ClickProc = {
which: SoftcardOps.StatusBit;
name: ROPE;
prev: BOOL;
[which, name] ← SelectStatusBit[];
IF name = NIL THEN RETURN;
IF which = dOutIFU OR which = dOutEU OR which = phaseA THEN
tsOut.PutF["Cannot reset %g\n", IO.rope[name] ]
ELSE {
prev ← SoftcardOps.ResetStatusBit[which];
tsOut.PutF[" %g has been reset: previous value was %g\n",
IO.rope[name], IO.bool[prev] ];
};
};
statusBitList: LIST OF ROPE = LIST[
"dOutIFU", "dOutEU", "phaseA", "periodicIntToDragon", "notMemoryError", "euBkptReached", "ifuBkptReached", "mapError"];
SelectStatusBit: PROC RETURNS[SoftcardOps.StatusBit, ROPE] = {
which: INT = PopUpSelection.Request[
header: "StatusBit",
choice: statusBitList];
SELECT which FROM
1 => RETURN[dOutIFU, "dOutIFU"];
2 => RETURN[dOutEU, "dOutEU"];
3 => RETURN[phaseA, "phaseA"];
4 => RETURN[periodicIntToDragon, "periodicIntToDragon"];
5 => RETURN[notMemoryError, "notMemoryError"];
6 => RETURN[euBkptReached, "euBkptReached"];
7 => RETURN[ifuBkptReached, "ifuBkptReached"];
8 => RETURN[mapError, "mapError"];
ENDCASE => RETURN[dOutIFU, NIL];
};
ReadClockControl: ClickProc = {
current: SoftcardOps.ClockControl = SoftcardOps.ReadClockControl[];
tsOut.PutF[
" Current value of clock control is: [freqSelect: %g, phaseAdjust: %g, delay: %g]\n",
IO.int[current.freqSelect], IO.int[current.phaseAdjust], IO.int[current.delay] ];
ViewerTools.SetContents[freqSelectText, IO.PutFR[NIL, IO.int[current.freqSelect]] ];
ViewerTools.SetContents[phaseAdjustText, IO.PutFR[NIL, IO.int[current.freqSelect]] ];
ViewerTools.SetContents[delayText, IO.PutFR[NIL, IO.int[current.delay]] ];
};
WriteClockControl: ClickProc = {
ENABLE RuntimeError.BoundsFault => GOTO oops;
new: SoftcardOps.ClockControl;
new.freqSelect ← GetAsInt[freqSelectText];
new.freqSelect ← GetAsInt[phaseAdjustText];
new.delay ← GetAsInt[delayText];
SoftcardOps.WriteClockControl[new];
tsOut.PutRope[" New value of clockControl has been set\n"];
EXITS
oops => tsOut.PutRope["Boundsfault doing clockcontrol - not done\n"];
};
GetAsInt: PROC[who: Viewer] RETURNS[val: INT] = {
rope: ROPE = ViewerTools.GetContents[who];
val ← -1;
val ← Convert.IntFromRope[rope ! Convert.Error => CONTINUE];
};
RunOrStopProc: ClickProc = {
IF dragonState = unknown THEN {
tsOut.PutRope[" Dragon state is unknown - can't change\n"];
RETURN
};
IF dragonState = running THEN {
SoftcardOps.DragonStop[];
Buttons.ReLabel[runOrStopButton, runChoice];
dragonState ← stopped;
}
ELSE {
SoftcardOps.DragonRun[];
Buttons.ReLabel[runOrStopButton, stopChoice];
dragonState ← running;
};
};
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.ReadEUPBusCmd[];
tsOut.PutF[" EUPBusCmd: [userMode: %g, unspecifiedAsYet: %xH\n",
IO.bool[val.userMode], IO.int[val.unspecifiedAsYet] ];
};
IFUPBusCmdProc: ClickProc = {
val: SoftcardOps.IFUPBusCmd = SoftcardOps.ReadIFUPCmdData[];
tsOut.PutF[" IFUPBusCmd: %g\n", IO.rope[IF 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"];
};
FlushEUCacheProc: ClickProc = {
SoftcardOps.FlushEUCache[];
tsOut.PutRope[" FlushEUCache has been done\n"];
};
FlushIFUCacheProc: ClickProc = {
SoftcardOps.FlushIFUCache[];
tsOut.PutRope[" FlushIFUCache has been done\n"];
};
ConnectionTextProc: ClickProc =
{ ViewerTools.SetSelection[connectionText, NIL] };
FreqSelectProc: ClickProc =
{ ViewerTools.SetSelection[freqSelectText, NIL] };
PhaseAdjustProc: ClickProc =
{ ViewerTools.SetSelection[phaseAdjustText, NIL] };
DelayProc: ClickProc =
{ ViewerTools.SetSelection[delayText, NIL] };
SoftcardTool: Commander.CommandProc = {
[] ← MakeControlWindow["SoftcardTool","///temp/SoftcardTool.log"];
topViewer.inhibitDestroy ← FALSE;
};
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Commander.Register["SoftcardTool", SoftcardTool];
END.