DIRECTORY
Commander USING [CommandProc, Handle, Register],
Convert USING [Error, IntFromRope],
FS USING [SetKeep],
IO,
Rope,
Buttons USING [Button, ButtonProc, Create],
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;
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 ← 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, wy: sib.wy, wh: entryHeight, scrollable: FALSE ],
proc: FreqSelectProc ];
sib ← freqSelectText ← ViewerTools.MakeNewTextViewer[
info: [parent: topViewer, wx: sib.wx+sib.ww+xFudge, wy: sib.wy,
ww: 40, 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, wy: sib.wy,
ww: 40, 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, wy: sib.wy,
ww: 40, wh: entryHeight, border: FALSE, scrollable: FALSE]];
the rest of the viewer
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];
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"];
};
ReadControlBits: ClickProc = {
which: SoftcardOps.ControlBit;
name: ROPE;
val: BOOL;
[which, name] ← SelectControlBit[];
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[];
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[];
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 => ERROR;
};
ReadStatusBits: ClickProc = {
which: SoftcardOps.StatusBit;
name: ROPE;
val: BOOL;
[which, name] ← SelectStatusBit[];
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 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 => ERROR;
};
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];
};
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;
};