Iago2Impl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Willie-Sue, October 30, 1985 1:24:27 pm PST
Russ Atkinson (RRA) March 11, 1985 8:38:13 pm PST
DIRECTORY
Commander USING [CommandProc, Register],
BasicTime USING [TimeNotKnown],
EditedStream USING [Rubout],
ExtraIagoOps,
File USING [Error],
FS USING [Error],
IagoOps,
IO,
Loader USING [BCDBuildTime],
Process USING [Detach],
Rope,
ViewerClasses USING [Viewer],
ViewerIO USING [CreateViewerStreams, GetViewerFromStream];
Iago2Impl: CEDAR PROGRAM
IMPORTS Commander, BasicTime, EditedStream, ExtraIagoOps, File, FS, IagoOps, IO, Loader, Process, Rope, ViewerIO =
BEGIN OPEN ExtraIagoOps, File;
-- * * * * * * * * commands implementation * * * * * * * *
ReadBootFile: PROC[in, out: IO.STREAM] = {ReadSystemFile[in, out, bootFile]};
ReadCkptFile: PROC[in, out: IO.STREAM] = {ReadSystemFile[in, out, checkpoint]};
ReadUCodeFile: PROC[in, out: IO.STREAM] = {ReadSystemFile[in, out, microcode]};
ReadGermFile: PROC[in, out: IO.STREAM] = {ReadSystemFile[in, out, germ]};
ReadDebuggerFile: PROC[in, out: IO.STREAM] = {ReadSystemFile[in, out, debugger]};
ReadDebuggeeFile: PROC[in, out: IO.STREAM] = {ReadSystemFile[in, out, debuggee]};
ReadVMFile: PROC[in, out: IO.STREAM] = {ReadSystemFile[in, out, VM]};
DeleteBootFile: PROC[in, out: IO.STREAM] = {DeleteSystemFile[in, out, bootFile]};
DeleteCkptFile: PROC[in, out: IO.STREAM] = {DeleteSystemFile[in, out, checkpoint]};
DeleteUCodeFile: PROC[in, out: IO.STREAM] = {DeleteSystemFile[in, out, microcode]};
DeleteGermFile: PROC[in, out: IO.STREAM] = {DeleteSystemFile[in, out, germ]};
DeleteDebuggerFile: PROC[in, out: IO.STREAM] = {DeleteSystemFile[in, out, debugger]};
DeleteDebuggeeFile: PROC[in, out: IO.STREAM] = {DeleteSystemFile[in, out, debuggee]};
DeleteVMFile: PROC[in, out: IO.STREAM] = {DeleteSystemFile[in, out, VM]};
QuitCommand: PROC [in,out: IO.STREAM] = { ERROR ForceExit };
* * * * * * * Main
Main: PROC = {
in, out: IO.STREAM;
v: ViewerClasses.Viewer;
[in, out]← ViewerIO.CreateViewerStreams[name: "Iago2", backingFile: "///temp/Iago2.log"];
v← ViewerIO.GetViewerFromStream[in];
v.inhibitDestroy← TRUE;
out.PutF["Iago2 of %g, started at %g",
IO.time[Loader.BCDBuildTime[ExtraIagoOps.GetAddress]], IO.time[]];
out.PutRope["\n\nType \"?\" at any time if you need help.\n"];
DO
ENABLE {
ABORTED => EXIT;
EditedStream.Rubout => { IO.PutRope[out, " XXX"]; LOOP };
};
c: IagoOps.CommandInfo = IagoOps.GetCommand[in: in, out: out, diskReadable: TRUE];
exit, overwritten: BOOL;
[exit, overwritten] ← DoCommand[in, out, c];
IF exit THEN EXIT;
ENDLOOP;
IO.PutRope[out, "\nLeaving Iago2 ...\n"];
v.inhibitDestroy← FALSE;
in.Close[];
out.Close[];
};
DoCommand: PROC [in, out: IO.STREAM, c: IagoOps.CommandInfo] RETURNS [exit: BOOLFALSE, overwritten: BOOLFALSE] = {
ENABLE {
EditedStream.Rubout, IagoOps.Rubout => {
IO.PutRope[out, " XXX"];
GO TO leave
};
File.Error => {
IO.PutRope[out, " ... \n "];
IO.PutRope[out, IagoOps.FileError[why]];
GO TO leave
};
FS.Error => {
IO.PutRope[out, " ... \n "];
IO.PutRope[out,
IF error.explanation.Length[] # 0
THEN error.explanation
ELSE "FS.Error without a message: consult an expert"];
GO TO leave
};
BasicTime.TimeNotKnown => {
IO.PutRope[out, " ... I can't do that without knowing the current time."];
GO TO leave
};
ForceExit => {
exit ← TRUE;
GO TO leave
};
Overwritten => {
overwritten ← TRUE;
GO TO leave
};
};
c.commandProc[in, out];
EXITS leave => {};
};
ForceExit: ERROR = CODE;
Overwritten: ERROR = CODE;
Start: Commander.CommandProc = { TRUSTED {Process.Detach[FORK Main[]] } };
* * * * * * * start code ** register commands with Iago
IagoOps.RegisterCommand[[Loophole, "Convert octal or hex to decimal"]];
IagoOps.RegisterCommand[[AddPageToBadPageTable, "Add (Physical) Page To the BadPageTable"]];
IagoOps.RegisterCommand[[DescribeAllocated, "Describe Allocated Disk Pages"]];
IagoOps.RegisterCommand[[DescribeDiskPage, "Describe Disk Page"]];
IagoOps.RegisterCommand[[DescribeBadPages, "Describe Bad Pages"]];
IagoOps.RegisterCommand[[DescribeVolumePage, "Describe Volume Page"]];
IagoOps.RegisterCommand[[EnsureBadPagesInVAM, "Ensure Bad Pages are in VAM"]];
IagoOps.RegisterCommand[[ListBadPages, "List Bad Pages"]];
IagoOps.RegisterCommand[[MarkPageAllocated, "Mark (Logical) Page as Allocated"]];
IagoOps.RegisterCommand[[ReadDiskPages, "Read Disk Page(s)"]];
IagoOps.RegisterCommand[[ReadFilePages, "Read File Page(s)"]];
IagoOps.RegisterCommand[[ReadLogicalPages, "Read Logical Volume Page(s)"]];
IagoOps.RegisterCommand[[WriteDiskPage, "Re-Write one Disk Page"]];
IagoOps.RegisterCommand[[ReadNamedFile, "Read Named File"]];
IagoOps.RegisterCommand[[ShowDiskAddress, "Show Disk Address"]];
IagoOps.RegisterCommand[[ReadBootFile, "Read BootFile"]];
IagoOps.RegisterCommand[[ReadCkptFile, "Read Checkpoint File"]];
IagoOps.RegisterCommand[[ReadUCodeFile, "Read Microcode File"]];
IagoOps.RegisterCommand[[ReadGermFile, "Read Germ File"]];
IagoOps.RegisterCommand[[ReadDebuggerFile, "Read Debugger File"]];
IagoOps.RegisterCommand[[ReadDebuggeeFile, "Read Debuggee File"]];
IagoOps.RegisterCommand[[ReadVMFile, "Read VM File"]];
IagoOps.RegisterCommand[[DeleteBootFile, "Delete BootFile"]];
IagoOps.RegisterCommand[[DeleteCkptFile, "Delete Checkpoint File"]];
IagoOps.RegisterCommand[[DeleteUCodeFile, "Delete Microcode File"]];
IagoOps.RegisterCommand[[DeleteGermFile, "Delete Germ File"]];
IagoOps.RegisterCommand[[DeleteDebuggerFile, "Delete Debugger File"]];
IagoOps.RegisterCommand[[DeleteDebuggeeFile, "Delete Debuggee File"]];
IagoOps.RegisterCommand[[DeleteVMFile, "Delete VM File"]];
IagoOps.RegisterCommand[[QuitCommand, "Quit"]];
Commander.Register["Iago2", Start];
END.