Text preview for : DiskKD.mesa_Oct77.pdf part of xerox DiskKD.mesa Oct77 xerox mesa 3.0_1977 listing DiskKD.mesa_Oct77.pdf
Back to : DiskKD.mesa_Oct77.pdf | Home
diskkd.mESA 24-0CT-77 18:19:56 Page 1
-- DiskKO.Mesa Edited by Sandman on August 23, 1977 9:42 PM
DIRECTORY
AltoOefs: FROM "altodefs",
AltoFileDefs: FROM "altofiledefs",
BootDefs: FROM "bootdefs",
OirectoryOefs: FROM "directorydefs",
DiskDefs: FROM "diskdefs",
DiskKDDefs: FROM "diskkddefs",
InlineOefs: FROM "inlinedefs",
ImageDefs: FROM "imagedefs",
SegmentDefs: FROM "segmentdefs":
DEFINITIONS FROM AltoDefs, AltoFileOefs, SegmentOefs:
OiskKD: PROGRAM
IMPORTS BootOefs, Oirp~toryOefs, OiskOefs, ImageOefs, SegmentOefs EXPORTS OiskKOOefs :
BEGIN
InitializeOiskKD: PUBLIC PROCEDURE =
BEGIN
pages: PageCount:
IF NDirectoryOefs.OirectoryLookup[@diskKO.file.fp, nameKO, FALSE]
THEN SIGNAL FileNameError[nameKD]:
MoveFileSegment[diskKD, OefaultBase, 1]:
OpenOiskKO[]:
OiskOefs.SetDisk[@kd.disk]:
pages ~ (kd.size+PageSize-l)/PageSize:
[] ~ CloseOiskKO[]:
MoveFileSegment[diskKD, DefaultBase, pages]:
RETURN
END:
OpenDiskKO: PROCEDURE =
BEGIN
IF NdiskKD.swappedin THEN
BEGIN SwapIn[diskKD]:
kd ~ FileSegmentAddress[diskKO]:
kd.changed ~ 0:
END
ELSE swapKO.proc ~ CantSwap:
RETURN
END:
UpdateOiskKD: PUBLIC PROCEDURE
BEGIN
IF diskKD.swappedin
AND kd.changed#O THEN
BEGIN
diskKD.write ~ TRUE;
SwapUp[diskKD]:
diskKD.write ~ FALSE:
kd.changed ~ 0:
END:
RETURN
END:
CloseOiskKO: PUBLIC PROCEDURE RETURNS [BOOLEAN]
BEGIN
IF NdiskKD.swappedin THEN RETURN[FALSf]:
swapKO.proc ~ CantSwap; UpdateDiskKO[]:
Un10ck[diskKD]: SwapOut[diskKO]:
RETURN[TRUE]
END:
CleanupDiskKD: PUBLIC ImageDefs.C1eanupProcedure
BEGIN
SElECT why FROM
Finish. Abort. OutLd =) [ ] ~ CloseDiskKD[]:
Save =)
We depend on MakeImage to call C10seDiskKO when
il has finished allocating the image file pages.
Logically. il should also call ResetOisk at this
lime. but it can't do that unli1 lhe Reslore.
Reslore =)
diskkd.mESA 24-0CT-77 18:19:66 Page 2
We depend on MakeImage to call InitializeDiskKD
as soon as the image file starts up so that the
Real to Virtual disk address map can be set up.
ENDCASE:
RETURN
END:
AllOnes: WORD = 1777778:
NewSN: PUBLIC PROCEDURE RETURNS [sn:SN] =
BEGIN OpenDiskKD[]:
IF (kd. lastSN.part2 ~ kd.lastSN.part2+1) = 0
THEN kd. lastSN.partl ~ kd.lastSN.partl+l:
sn ~ kd.lastSN: kd.changed ~ AllOnes:
swapKD.proc ~ CloseDiskKD:
RETURN
END:
BitAddress: TYPE = RECORD [word:[0 .. 7777B). bit:[0 .. 17B]]:
DiskFull: PUBLIC SIGNAL = CODE:
AssignDiskPage: PUBLIC PROCEDURE [da:vDA]
RETURNS [vDA] =
BEGIN OPEN InlineDefs:
oneb it: WORD:
ba. wa: CARDINAL:
w: POINTER TO WORD:
base: BitAddress LOOPHOLE[da+l]:
baseWa: CARDINAL ~ base.word:
baseBa: CARDINAL ~ base.bit:
OpenD i skKD[]:
DO ENABLE UNWIND =) swapKD.proc ~ CloseDiskKD:
FOR wa IN [baseWa .. kd.size) DO
IF (w ~ @kd.table[wa])~ # AllOnes THEN
FOR ba IN [baseBa .. wordlength) DO
onebit ~ BITSHIFT[100000B.-ba]:
IF BITAND[w~.onebit]=O THEN
BEGIN
w~ ~ BITOR[w~.onebit):
kd.changed ~ AllOnes:
swapKD.proc ~ CloseDiskKD:
RETURN[vDA[wa*wordlength+ba]]:
END:
ENDLOOP:
baseBa ~ 0:
ENDLOOP:
IF baseWa=O THEN SIGNAL DiskFull:
baseWa ~ 0:
ENDLOOP;
END:
ReleaseDiskPage: PUBLIC PROCEDURE [v:vDA]
BEGIN OPEN InlineDefs:
word: POINTER TO WORD:
OpenDiskKD[]:
word ~ @kd.table[LOOPHOLE[v.BitAddress].word]:
word~ ~ BITANO[wordt.
BITNOT[BITSItIFT[lOOOOOB. -LOOPHOLE[v .Bi tAddress]. bit]]]:
kd.changed ~ All0nes:
swapKD.proc ~ CloseDiskKD:
RETURN
END;
CountrreeOiskPages: PUBLIC PROCrOURF RETURNS [count: CARDINAL]
BrGIN OPEN Inl ineOefs:
ba. wa: CAROINAL:
onebit: WORO:
word: POINTER TO WORD:
count ~ 0;
OpenO i skKO[];
rOil wa IN [0 .. kd.sile) DO
Ir (word ~ @kd.table[wa])t # AllOnes TH[N
rOR ba IN [0 .. wordlength) 00
oneblL ~ BITSItIFT[100000B.-ba]:
diskkd.mESA 24-0CT-77 18:19:56 Page 3
IF BITAND[word~,onebit]=O THEN count ~ count+1;
ENDLOOP;
ENDLOOP;
swapKD.proc ~ CloseDiskKD;
RETURN
END;
-- Main Body
kd: POINTER TO KD;
swapKD: SwapStrategy;
diskKD: FileSegmentHandle;
cleanupKD: ImageDefs.CleanupItem;
nameKD: STRING = "DiskDescriptor.";
swapKD.proc ~ CantSwap;
cleanupKD.proc ~ CleanupDiskKD;
diskKD ~ NewFileSegment[BootDefs.BootFile[Read+Write],DefaultBase,1,Read];
AddSwapStrategy(@swapKD];
ImageDefs.AddCleanupProcedure[@cleanupKD];
InitializeDiskKD[];
-- Should we support running without a DiskDescriptor?
END.