ClusterParamsImpl.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
last modified by E. McCreight, March 11, 1986 12:03:44 pm PST
last modified by Curry, September 8, 1985 1:54:50 pm PDT
Herrmann, September 6, 1985 12:53:11 pm PDT
Initializes the Cluster Rosemary simulation parameters
DIRECTORY
Atom,
Basics,
CacheOps,
ClusterParams,
Commander,
Cucumber,
Dragon,
DragonRosemary,
DragOpsCross,
FS,
IO,
LizardRosemary,
Process,
RandomCode,
Rope,
RoseCreate,
RoseDisplayInsides,
RoseRun,
RoseTypes,
TypeScript,
ViewerClasses,
ViewerIO,
ViewRec;
ClusterParamsImpl: CEDAR PROGRAM
IMPORTS Atom, CacheOps, Commander, Cucumber, DragonRosemary, FS, IO, Process, RandomCode, RoseCreate, RoseDisplayInsides, RoseRun, TypeScript, ViewerIO, ViewRec
EXPORTS ClusterParams =
BEGIN OPEN ClusterParams;
vm:     PUBLIC CacheOps.VirtualMemory ← NIL;
randomBackground: PUBLIC Rope.ROPE     ← "RandomBackground.quad";
randomStartPC:  PUBLIC Dragon.Word    ← 102000H;
iCacheSkipRejects: PUBLIC BOOL       ← FALSE;
iCache:    PUBLIC CacheOps.Cache   ← NIL;
eCache:    PUBLIC CacheOps.Cache   ← NIL;
clusterLog:   PUBLIC IO.STREAM     ← IO.noWhereStream;
ifuLogRef:   PUBLIC REF IO.STREAM    ← NEW[IO.STREAM];
euLogRef:   PUBLIC REF IO.STREAM    ← NEW[IO.STREAM];
eCacheLogRef:  PUBLIC REF IO.STREAM    ← NEW[IO.STREAM];
lizardSimRef:   PUBLIC REF LizardRosemary.Simulation ←
NEW[LizardRosemary.Simulation];
clusterTestSim: RoseTypes.Simulation  ← NIL;
clusterDisplay: RoseDisplayInsides.Display ← NIL;
clusterBrower: ViewerClasses.Viewer  ← NIL;
clusterPanel:  PUBLIC REF ControlPanel ← NIL;
DoStartCluster: Commander.CommandProc = {
vm   ← CacheOps.NewVirtualMemory[];
iCache  ← CacheOps.NewCache[vm];
eCache  ← CacheOps.NewCache[vm];
clusterTestSim ← RoseCreate.CreateSim[steady: TRUE];
RoseCreate.CreateTest[
typeName: "Cluster",
rootName:  "ClusterRoot",
testName:  "T",
sim:   clusterTestSim,
decider:  RoseCreate.DecideFromFile["Cluster.expand"],
dual: FALSE ];
clusterDisplay ← RoseDisplayInsides.NewDisplay
[sim: clusterTestSim, info: [iconic: TRUE, name: "Cluster"]];
clusterLog ← clusterDisplay.log;
TypeScript.ChangeLooks[ViewerIO.GetViewerFromStream[clusterLog], 'f];
ifuLogRef^  ← clusterLog;
euLogRef^  ← clusterLog;
eCacheLogRef^ ← clusterLog;
clusterBrower ← RoseDisplayInsides.BrowseDisplay
[display:clusterDisplay, info: [iconic:TRUE, name:"Cluster Browser"]];
StartPanel[];
clusterPanel.diagnostic ← cmd.commandLine;
};
StartPanel: PROC = {
clusterPanel ← NEW[ControlPanel ← [ ckptFile: "Cluster.ckpt", errMsg: "", enaIFULog: TRUE ]];
[] ← ViewRec.ViewRef[
agg: clusterPanel,
label: "Dragon Panel ",specs: CONS[[
"cycle",   Value[val:NIL, visible:TRUE, dontAssign:TRUE]], CONS[[
"phase",   Value[val:NIL, visible:TRUE, dontAssign:TRUE]], CONS[[
"instrCount",  Value[val:NIL, visible:TRUE, dontAssign:TRUE]], NIL]]]] };
PanelCheck: PUBLIC PROC =
BEGIN
lastPanel: ControlPanel;
FOR firstPanelCheck: BOOLTRUE, FALSE DO
IF firstPanelCheck OR lastPanel.enaIFULog # clusterPanel.enaIFULog
THEN IF clusterPanel.enaIFULog
THEN ifuLogRef^ ← clusterLog
ELSE ifuLogRef^ ← IO.noWhereStream;
IF firstPanelCheck OR lastPanel.enaEULog # clusterPanel.enaEULog
THEN IF clusterPanel.enaEULog
THEN euLogRef^ ← clusterLog
ELSE euLogRef^ ← IO.noWhereStream;
IF firstPanelCheck OR lastPanel.enaECacheLog # clusterPanel.enaECacheLog
THEN IF clusterPanel.enaECacheLog
THEN eCacheLogRef^ ← clusterLog
ELSE eCacheLogRef^ ← IO.noWhereStream;
lastPanel ← clusterPanel^;
Process.Pause[Process.SecondsToTicks[1]];
ENDLOOP;
END;
Remark: PUBLIC PROC [message: IO.ROPE] =
{RoseRun.DisableableStop[Remark, message]};
CheckPoint: PUBLIC PROC [fileName: IO.ROPE, root: RoseTypes.Cell] =
BEGIN
file: IO.STREAMNIL;
clusterPanel.errMsg ← "Checkpointing...";
file ← FS.StreamOpen[fileName: fileName, accessOptions: create, keep: 2
! FS.Error => {clusterPanel.errMsg ← error.explanation; GOTO Punt} ];
TRUSTED BEGIN ENABLE ABORTED => GOTO Close;
Cucumber.Transfer[what: root, where: file, direction: out
! Cucumber.Error => {clusterPanel.errMsg ← msg; GOTO Close}];
Cucumber.Transfer[what: clusterPanel, where: file, direction: out
! Cucumber.Error => {clusterPanel.errMsg ← msg; GOTO Close}];
Cucumber.Transfer[what: Atom.GetProp[$Cluster, $RegStores], where: file, direction: out
! Cucumber.Error => {clusterPanel.errMsg ← msg; GOTO Close}];
clusterPanel.errMsg ← NIL;
EXITS Close => Remark["Checkpoint failed, OK to proceed or abort"];
END;
file.Close[ ! IO.Error, FS.Error => CONTINUE ];
EXITS Punt => Remark["Couldn't open checkpoint file, OK to proceed or abort"];
END;
RollBack: PUBLIC PROC [fileName: IO.ROPE, root: RoseTypes.Cell]
RETURNS [oldPanel: REF ControlPanel] =
BEGIN
file: IO.STREAMNIL;
oldPanel ← NEW[ControlPanel ← clusterPanel^];
clusterPanel.errMsg ← "Rolling back...";
file ← FS.StreamOpen[fileName: fileName
! FS.Error => {clusterPanel.errMsg ← error.explanation; GOTO Punt} ];
TRUSTED BEGIN
regStores: REF ANY;
Cucumber.Transfer[what: root, where: file, direction: in
! Cucumber.Error => {clusterPanel.errMsg ← msg; GOTO Close}];
Cucumber.Transfer[what: oldPanel, where: file, direction: in
! Cucumber.Error => {clusterPanel.errMsg ← msg; GOTO Close}];
Cucumber.Transfer[what: regStores, where: file, direction: in
! Cucumber.Error => {clusterPanel.errMsg ← msg; GOTO Close}];
Atom.PutProp[$Cluster, $RegStores, regStores];
clusterPanel.errMsg ← NIL;
EXITS Close =>
BEGIN
clusterPanel.errMsg ←
IO.PutFR["at %g: %g", IO.int[file.GetIndex[]], IO.rope[clusterPanel.errMsg]];
DragonRosemary.Assert[FALSE, "Rollback failed, recommend you abort"];
END;
END;
file.Close[];
EXITS Punt => Remark["Couldn't open rollback file, OK to proceed or abort"];
END;
InsertRandomProgramInVM: PUBLIC PROC[
vm: CacheOps.VirtualMemory,
seed: INT,
log: IO.STREAM] = {
nextByteAddr: Dragon.Word ← randomStartPC;
WriteOneCodeByte: PROC [byte: [0..255]] =
BEGIN
background: Basics.LongNumber;
CacheOps.SetFlags[c: eCache, address: nextByteAddr/4, mapped: TRUE, writeProtect: FALSE, dirty: FALSE];
background.lc ← CacheOps.Access[c: eCache, address: nextByteAddr/4].data;
SELECT nextByteAddr MOD 4 FROM
0 => background.hh ← byte;
1 => background.hl ← byte;
2 => background.lh ← byte;
3 => background.ll ← byte;
ENDCASE => ERROR;
CacheOps.Write[c: eCache, address: nextByteAddr/4, data: background.lc];
nextByteAddr ← nextByteAddr+1;
END;
CacheOps.VirtualMemoryFromFile[vm, randomBackground];
RandomCode.GenerateRandomProgramBytes[
initialByteAddress: randomStartPC,
randomSeed:   seed,
seeOneByte:   WriteOneCodeByte,
dribble:    log
];
eCache ← CacheOps.NewCache[eCache]; -- resets first free cycle, cache lines
};
Commander.Register["Cluster", DoStartCluster, "Cluster fires up a Rosemary simulation of a single-processor Dragon. Format is\n Cluster CodeFile.quad Expansion.expand\n"];
END.}