<> <> <> 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; 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; <> tsViewer, topViewer: Viewer; tsOut: STREAM; 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] ]; <<>> <> 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]; <> 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 ]; <<>> <> 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 ]; <<>> <> 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]]; <> 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; }; <<* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> Commander.Register["SoftcardTool", SoftcardTool]; END.