Text preview for : Swapper.mesa_Oct77.pdf part of xerox Swapper.mesa Oct77 xerox mesa 3.0_1977 listing Swapper.mesa_Oct77.pdf
Back to : Swapper.mesa_Oct77.pdf | Home
swapper.mESA 24"OCT~77 18:55:07 Page 1
~- Swapper.Mesa Edited by Sandman on October 6, 1977 7:19 AM
DIRECTORY
Al toDefs: FROM "altodefs",
AltoFileDefs: FROM "altofiledefs",
BooLDefs: FROM "booLdefs",
ControlDefs: FROM "controldefs",
DiskDefs: FROM "diskdefs",
FrameDefs: FROM "framedefs",
InlineOefs: FROM "inlinedefs",
MiscDefs: FROM "miscdefs",
ProcessDefs: FROM "processdefs",
SegmentDefs: FROM "segmentdefs";
DEFINITIONS FROM AltoDefs, AltoFileDefs. BootDefs. DiskDefs, SegmentDefs;
Swapper: PROGRAM [ffvmp, lfvmp: PageNumber]
IMPORTS SootDefs, FrruneOefs, SegmentDefs
EXPORTS RootDefs. DiskDefs. FrameDefs, MiscDefs, SegmentDefs
SHARES DiskDefs. SegmentDefs = BEGIN
nil: POINTER = LOOPHOLE[a];
driveNurnber: PUBLIC [0 .. 1]" 0;
sysdisk: DISK .. DISK[nDisks.nTracks.nHeads.nSectors];
disk: POINTER TO DISK = @sysdisk;
Zero: PUBLIC PROCEDURE [
p:POINTER, I:CARDINAL] =
BEGIN
IF 1=0 THEN RETURN; p... 0;
InlineDefs.COPY [
from:p, to:p+l. nwords:l-1];
RETURN
END;
SetDisk: PUBLIC PROCEDURE [
d:POINTER TO rtSK] =
BEGIN
diskt .. d.;
RETURN
END;
GetDisk: PUBLIC PROCEDURE
RETURNS [POINTER TO DISK] =
REGIN
RETURN[disk]
END;
ResetDisk: PUBLIC PROCEDURE
RETURNS [POINTER TO DISK]
BEGIN
diskt .. DISK[nDisks.nTracks.nHeads.nSectors];
RFTURN[disk]
END;
VirtualDA: PUBLIC PROCEDURf [da:DA] RETURNS [vDA] =
BFGIN
RETURN[IF da = DA[D.a.a.D.O] TllfN eorDA fLSf vDA [
((da.disk*disk.tracks+da.track)*disk.heads+
da.head)*disk.sectors+da.sector]];
[ND;
RealDA: PUBI IC PROCf[)URE [v:vDA] RrTURNS [da:DA]
BrGTN
i: CARDINAL" v;
da .. DA[D,D,D,O,D];
IF v II eorDA IlIfN
BrGIN
[i.da.sector] .. InlineDers.OIV~100[i,disk.sectors];
[I.ria.head] ... Inl ineDefs.O!VMOf)[ I.disk.heads);
[I.da.track] .. InlineDefs.DIV~lOD[i,disk.tracksJ;
[ i , da . dis k] .. 1111 in eDe f s .0 J VMOf)[ i , dis k . dis k s ] ;
Ir i II 0 TlirN da .. Illval idDA;
r ND;
RrTURN
["ND;
$wapper.mESA 24-QCT-77 18:56:07 Pane 2
sWilPPQr.mESA 24-0el-77 18:55:07 Page 3
-- Disk transfer "process"
Deseal: BYTE = 110B;
Des: ARRAY voe OF DC = [
oc[oeseal,DiskRead, DiskRead, oiskRead, 0,0], ReadHLD
De[oCseal,oiskCheck,OiskRead, oiskRead, 0,0], ReadLo
OC[oCseal,oiskCheck,Diskeheck,OtskRead, 0,0], ReadD
OC[OCseal,OiskWrite,DiskWrite,DiskWrite,O,O], WriteHLO
OC[OCseal,oiskCheck,DiskWrite,OiskWrite,O,O], Wr itelO
DC[DCseal,DiskCheck,OiskCheck,DiskWrite,O,O], WriteD
OC[DCseal,DiskCheck,OiskCheck,OiskCheck,l,O], SeekOnly
DC[OCseal,DiskCheck,Diskeheck,DiskCheck,O,O]]; OoNothing
nextDiskCommand: POINTER TO CBptr = LOOPHOLE[521B];
disk~tatus: POINTER TO DS = LOOPHOLE[522B];
lasloiskAddress: POINTER TO DA = LOOPHOLE[523B];
sectorlnterrupts: POINTER TO CARDINAL = LOOPHOLE[524B]:
oooiskCommand assumes that the version number in a FlO (and
in an FP) will never be used (is always one). It further
assumes that if fp is nil (zero), a freePageFIO was meant;
this allows the rest of the world to use short (3 word) FPs.
FreePageFIo: FlO = FIO[-l,SN[l,l,l,17777B,-1]];
NonZeroWaitCell: WORD ~ 1;
waitCell: POINTER TO WORD ~ @NonZeroWaitCell;
ResetWaitCell: PUBLIC PROCEDURE
BEGIN
waitCell ~ @NonZeroWaitCell;
END;
SetWaitCell: PUBLIC PROCEDURE [p: POINTER TO WORD] RETURNS [preval: POINTER TO WORD]
BEGIN
ProcessDefs.Disablelnterrupts[];
preval ~ waitCel1;
waitCell .. p;
Proeessoefs.Enablelnterrupts[];
RETURN;
END;
DoOiskCommand: PUBLIC PROCEDURE [arg:POINTER TO DDC]
BEGIN OPEN arg;
ptr, next, prev: CBptr;
la: POINTER TO DL;
zone: CBlptr = eb.zone;
eb.headerAddress .. @eb.header;
If (la .. cb.labelAddress) = nil THEN
cb. labelAddress ~ la .. @eb.label;
cb.dataAddress ~ ea;
IF cb.normalWakeups = 0 THEN eb.normalWakeups .. zone.normalWakeups;
IF cb.errorWakeups = 0 THEN eb.errorWakeups .. zone.errorWakeups;
If fp = nil THEN la.fileID .. FreePagefIO
ELSE IF fp 1/ NIL TIIEN la.fileID .. fID[l,fp.serial];
la.page ~ eb.page ~ page;
IF da II fillinOA TlIEN eb.header.diskAddress'" RealDA[da];
IF restore THEN cb.header.diskAddress.restore .. 1;
eb.eommand" DCs[action];
eb.command.exchange ~ driveNumber;
prev .. PrevCR[lone];
-- Put the command on the disk controller's queue
ProcessOers.DisableInterrupts[];
UNfIl waitCelH II a DO NULL rNDIOOP; -- Wait for Trident to finish
IF (nex t .. nex If) I skCommand r) II nil TllfN
BrGTN
DO ptr .. next; next .. ptr.nextCB;
Ir next = nil TIirN rXIT;
fNOIOOP;
ptr.nextCB .. cb;
[NO;
Take care or a possible race with disk controller. The dIsk
may have gone idle (perhaps due to an error) even as we were
add ing a command to the cha in. To make sure thal'e was 110
error, we check the status or the previous cb in this Lone.
swapper.mESA 24-0CT-77 18:55:07 Page 4
IF nextDiskCommand9 = nil THEN
SELECT MaskDS[prev.status. DSmaskStatus] FROM
DSfreeStatus, DSgoodStatus =) nextDiskCommand9 ~ cb;
ENDCASE:
ProcessDefs.Enablelnterrupts[]:
EnqueueCB[zone,cb];
RETURN
END;
swapper.mESA 24-0CT-77 18:55:07 Page 5
-- Disk command block queue
InitializeCBstorage: PUBLIC PROCEDURE [
zone:CBZptr, nCBs:CARDINAL, page:PageNumber, init:CBinit] =
BEGIN
cb: CBptr;
i: CARDINAL;
nq: CARDINAL = nCBs+1;
length: CARDINAL = SIZE[CBZ]+nCBs~(SIZE[CB]+SIZE[CBptr]);
queue: DESCRIPTOR FOR ARRAY OF CBptr ~
DESCRIPTOR[~zone.queueVec,nq];
cbVector: DESCRIPTOR FOR ARRAY OF CB ~
DESCRIPTOR[~zone.queueVec+SIZE[CBptr]