CreateLogical:
PUBLIC PROC [in, out:
STREAM] = {
name:
ROPE ←
IF File.FindVolumeFromName[IagoOps.clientVolName] =
NIL
THEN IagoOps.clientVolName
ELSE NIL;
size: INT;
p: PhysicalVolume.Physical;
free: INT;
HelpCreation:
PROC = {
IO.PutRope[out,
"? type a string which is not the same as the name of any existing volume"];
};
DO
name ← IagoOps.GetArg[
in: in,
out: out,
prompt: Rope.Cat["\nNew volume name: "],
default: name,
help: HelpCreation];
IF File.FindVolumeFromName[name] #
NIL
THEN IO.PutRope[out, " ... already exists"]
ELSE EXIT
ENDLOOP;
p ← IagoOps.GetPhysical[in, out];
IagoOps.ReservePages[in, out, p];
free ← PhysicalVolume.PhysicalInfo[p].free;
size ← IagoOps.GetSize[in: in, out: out, default: free, max: free];
IO.PutRope[out, "\nAre you sure? "];
IF IagoOps.Confirm[in, out]
THEN {
new: File.Volume ← NIL;
IO.PutRope[out, " ... "];
new ← FileExtra.CreateLogicalVolume[
id: IagoOps.NewID[], where: LIST[p], size: size, name: name];
IO.PutRope[out, " done"];
IagoOps.clientVolName ← name;
IO.PutRope[out,
"\nDo you want to use this as the debugger volume? "];
IF IagoOps.Confirm[in, out] THEN File.MarkDebugger[new, TRUE];
};
};
CreateUserWorld:
PUBLIC PROC [in, out:
STREAM] = {
Install:
PROC [where: File.Volume, which: File.VolumeFile[microcode..bootFile]] = {
wDir: ROPE = Rope.Cat["[]<", File.GetVolumeName[where], ">"];
remote: ROPE = IagoOps.RemoteRootFileName[which];
local: ROPE = IagoOps.LocalRootFileName[which];
fsFile: FS.OpenFile;
file: File.Handle;
createTime: BasicTime.GMT;
IO.PutF[out, "\nInstalling %g as %g%g ... ",
[rope[remote]], [rope[wDir]], [rope[local]] ];
FS.Copy[from: remote, to: local, wDir: wDir];
createTime ← FS.FileInfo[name: local, wDir: wDir].created;
fsFile ← FS.Open[name: local, lock: write, wDir: wDir];
file ← FSBackdoor.GetFileHandle[fsFile];
File.SetRoot[which, file];
FS.SetByteCountAndCreatedTime[file: fsFile, created: createTime];
FS.Close[fsFile];
IO.PutRope[out, "done"];
};
format, coCedar, protect: BOOL;
altoText: ROPE ← NIL;
myName: ROPE = PupDefs.GetMyName[];
systemHost: ROPE = DefaultRemoteNames.Get[].systemHost;
userHost: ROPE = DefaultRemoteNames.Get[].userHost;
d: Disk.Channel = Disk.NextChannel[NIL];
newP: PhysicalVolume.Physical;
newC, newD: File.Volume;
memImagePages:
INT ← MemImagePages[];
Room for a physical memory image plus possible junk
debuggerVMPages: INT ← MAX[16000, memImagePages];
debuggerVolumePages:
INT ← debuggerVMPages+8000+2*memImagePages;
room for debugger, debuggee, VM, the boot file, and junk
cedarVMPages:
INT ←
IF SystemVersion.machineType = dandelion
THEN
MAX[16000, memImagePages]
ELSE MAX[memImagePages, 20000];
IO.PutChar[out, '\n];
IagoOps.ReserveAltoRegions[in, out];
IF IagoOps.CheckAltoRegions[in, out]
THEN altoText ← " (excluding the Alto disk regions)";
IO.PutRope[out, "\n\nHas your disk already been formatted? (Confirm if the disk has previously been used for Cedar or Pilot, AND you have not reduced the amount of disk reserved for Alto volumes) "];
format ← NOT IagoOps.Confirm[in, out];
IO.PutRope[out, "\n\nDo you want to password-protect this disk? "];
protect ← IagoOps.Confirm[in, out];
IO.PutRope[out, "\n\nDo you want to have a debugger volume on this disk? "];
coCedar ← IagoOps.Confirm[in, out];
IO.PutRope[out, "\n\nI intend to perform the following operations:"];
IF format
THEN {
IO.PutRope[out, "\n - format the entire disk"];
IO.PutRope[out, altoText];
IO.PutChar[out, ';];
};
IO.PutF[out, "\n - create a new physical volume named \"%g\";", [rope[myName]] ];
IF coCedar
THEN
IO.PutF[out,
"\n - create a debugger volume named \"Debugger\" with a %g page VM;",
[integer[debuggerVMPages]]];
IO.PutF[out,
"\n - create a client volume named \"Cedar\" with a %g page VM;\n - install microcode, germ and boot files(s) from the release directory;\n - make the \"Cedar\" volume be the physical boot volume;\n - boot the volume(s) to initialize the software.\n", [integer[cedarVMPages]] ];
IF
NOT IagoOps.ConfirmDestruction[
in, out, Rope.Cat["the entire disk on drive RD0", altoText]]
THEN RETURN;
CloseFSVolumes[];
IO.PutChar[out, '\n];
IF format
THEN
TRUSTED {
DoFormatOrScan[in: in, out: out, d: d, format: TRUE, passes: 1] };
IO.PutRope[out, "\nCreating physical volume ... "];
newP ← FileExtra.CreatePhysicalVolume[where: d, name: myName, id: IagoOps.NewID[]];
IagoOps.ReservePages[in, out, newP];
[] ← UserCredentials.ChangeState[IF protect THEN name ELSE nameHint];
IO.PutRope[out, "done"];
IF coCedar
THEN {
IO.PutRope[out, "\nCreating logical volume \"Debugger\" ... "];
newD ← FileExtra.CreateLogicalVolume[id: IagoOps.NewID[], where:
LIST[newP],
size: debuggerVolumePages,
name: "Debugger"];
File.MarkDebugger[newD, TRUE];
IO.PutRope[out, "done. Erasing it ... "];
File.EraseVolume[newD];
IO.PutRope[out, "done"];
CreateVMFile[out, newD, debuggerVMPages];
Install[where: newD, which: bootFile];
};
IO.PutRope[out, "\nCreating logical volume \"Cedar\" ... "];
newC ← FileExtra.CreateLogicalVolume[
id: IagoOps.NewID[],
where: LIST[newP],
size: PhysicalVolume.PhysicalInfo[newP].free,
name: "Cedar"];
IO.PutRope[out, "done. Erasing it ... "];
File.EraseVolume[newC];
IO.PutRope[out, "done"];
CreateVMFile[out, newC, cedarVMPages];
Install[where: newC, which: microcode];
Install[where: newC, which: germ];
Install[where: newC, which: bootFile];
PhysicalVolume.SetPhysicalRoot[newC, microcode];
PhysicalVolume.SetPhysicalRoot[newC, germ];
PhysicalVolume.SetPhysicalRoot[newC, bootFile];
{
init: ROPE = IagoOps.InitialMicrocodeFileName[];
IO.PutRope[out, "\nInstalling "];
IO.PutRope[out, init];
IF DoInitialMicrocodeInstallation[out, d, init, "[]<Cedar>Temp>Initial.Microcode"]
THEN
[] ← Booting.Boot[
[logical[IF coCedar THEN newD ELSE newC]],
[d: Booting.switches[d]] ];
};
};
CreateVMFile:
PROC [out:
STREAM, v: File.Volume, size:
INT] = {
newFile: FS.OpenFile;
volName: ROPE = File.GetVolumeName[v];
vmName: ROPE = Rope.Cat["[]<", volName, ">", IagoOps.LocalRootFileName[VM]];
IO.PutF[out, "\nCreating %g ... ", [rope[vmName]] ];
newFile ← FSExtrasForIago.CreateVMBacking[name: vmName, pages: size];
File.SetRoot[VM, FSBackdoor.GetFileHandle[newFile]];
FS.Close[newFile];
IO.PutRope[out, "done"];
[] ← IagoOps.WriteRemoteNames[volName, NIL, NIL, out];
};