DIRECTORY
Floppy USING [BootFilePointer, Density, FileID, nullFileID, PageCount, PageNumber, Sides, VolumeHandle],
FloppyChannel USING [Context, DiskAddress, Handle, SectorCount],
FloppyFormat USING [BadSpotSectors, FileList, ImplementedFileSize, Sector, SectorNine],
PrincOps USING [bitsPerWord, PageCount, wordsPerPage],
VM USING [Interval];
Bug: ERROR [type: BugType];
BugType:
TYPE = {
trackBufferLengthTooSmall, wrappedAroundFileIDs, invalidAddress, invalidBufferSize,
floppyVolumeTooLarge};
IOError: ERROR[countDone: CARDINAL];
DiskChanged: ERROR;
volumeTable: LONG POINTER TO ARRAY [0..0) OF VolumeDesc; -- indexed by device indexes.
VolumeDesc: TYPE = LONG POINTER TO VolumeDescObject;
VolumeDescObject:
TYPE =
MONITORED
RECORD [
open: BOOLEAN,
changeCount: CARDINAL, -- change count at last open
writeProtected: BOOLEAN, -- either physically or logically write protected
density: Floppy.Density[single..double],
sides: Floppy.Sides[one..two],
handle: FloppyChannel.Handle, -- handle on this particular instance of the floppy
numPages: Floppy.PageCount, -- count of the total number of pages on the volume
fileList: LONG POINTER TO FloppyFormat.FileList,
fileListSpace: VM.Interval, -- only allocated when the volume is open
sectorNine: LONG POINTER TO FloppyFormat.SectorNine,
badPageMap: LONG POINTER TO FloppyFormat.BadSpotSectors,
trackZeroSpace: VM.Interval,
allocationMap: LONG POINTER TO PACKED ARRAY [0..0) OF Allocation,
allocationMapSpace: VM.Interval -- only allocated when the volume is open
];
Allocation:
TYPE =
MACHINE
DEPENDENT {allocated (0), free (1), markerPage (2), badPage (3)};
If add more, change the next line!
allocationsPerPage: CARDINAL = (PrincOps.wordsPerPage*PrincOps.bitsPerWord)/2;
FileListType: -- File.Type -- CARDINAL = 0 -- CommonSoftwareFileTypes.tFileList -- ;
AccessFloppy: PROCEDURE [volumeDesc: VolumeDesc, buffer: LONG POINTER,
address: FloppyChannel.DiskAddress, count: CARDINAL, access: AccessMode];
AccessMode: TYPE = {read, write};
AddFile: PROCEDURE [volumeDesc: VolumeDesc, file: Floppy.FileID,
size: FloppyFormat.ImplementedFileSize, type: -- File.Type -- CARDINAL,
location: FloppyFormat.Sector];
AllocateFile: PROCEDURE [volumeDesc: VolumeDesc, bigSize: Floppy.PageCount,
type: -- File.Type -- CARDINAL, startPage: FloppyFormat.Sector,
id: Floppy.FileID ← Floppy.nullFileID]
RETURNS [startingSector: FloppyFormat.Sector, file: Floppy.FileID];
CloseVolume: PROCEDURE [volumeDesc: VolumeDesc];
CreateBuffer:
PROCEDURE [size: PrincOps.PageCount]
RETURNS [buffer:
VM.Interval];
CreateFileInternal:
PROCEDURE [volumeDesc: VolumeDesc, size: Floppy.PageCount,
type: -- File.Type -- CARDINAL, startSector: FloppyFormat.Sector,
id: Floppy.FileID ← Floppy.nullFileID]
RETURNS[fileID: Floppy.FileID, startPage: FloppyFormat.Sector];
CreateInitialMicrocodeInternal:
PROCEDURE [
volumeDesc: VolumeDesc, size: Floppy.PageCount, type: -- File.Type -- CARDINAL,
startingPageNumber: Floppy.PageNumber, id: Floppy.FileID ← Floppy.nullFileID]
RETURNS[file: Floppy.FileID];
FindFile: PROCEDURE [volumeDesc: VolumeDesc, file: Floppy.FileID]
RETURNS [address: FloppyFormat.Sector, type: -- File.Type -- CARDINAL,
size: FloppyFormat.ImplementedFileSize];
FirstDataSector: PROCEDURE [volumeDesc: VolumeDesc] RETURNS [FloppyFormat.Sector];
GetBootFileAddress: PROCEDURE [volumeDesc: VolumeDesc, bootFile: Floppy.BootFilePointer]
RETURNS [address: FloppyFormat.Sector];
GetFileID: PROCEDURE [volumeDesc: VolumeDesc] RETURNS [fileID: Floppy.FileID];
InitializeAllocationMap: PROCEDURE [volumeDesc: VolumeDesc];
IsDriveWriteProtected: PROCEDURE [volumeDesc: VolumeDesc]
RETURNS [writeProtected: BOOLEAN];
ReadFloppy: PROCEDURE [volumeDesc: VolumeDesc, buffer: LONG POINTER,
address: FloppyFormat.Sector, count: FloppyFormat.ImplementedFileSize];
RemoveFile: PROCEDURE [volumeDesc: VolumeDesc, file: Floppy.FileID];
SectorsPerTrack: PROCEDURE [handle: FloppyChannel.Handle,
context: FloppyChannel.Context] RETURNS [sectorsPerTrack: FloppyChannel.SectorCount];
SetBlock: PROCEDURE [p: LONG POINTER, length: CARDINAL, value: CARDINAL];
ValidateHandle: PROCEDURE[volume: Floppy.VolumeHandle]
RETURNS[volumeDesc: VolumeDesc];
ValidDrive: PROCEDURE [drive: CARDINAL] RETURNS [exists: BOOLEAN];
VolumeChanging: PROCEDURE [volumeDesc: VolumeDesc];
VolumeStable:
PROCEDURE [volumeDesc: VolumeDesc];
WordsToPages:
PROCEDURE [count:
LONG
CARDINAL]
RETURNS [
CARDINAL] =
INLINE
{RETURN [CARDINAL[(count+PrincOps.wordsPerPage-1)/PrincOps.wordsPerPage]]};
WriteFileList: PROCEDURE [volumeDesc: VolumeDesc];
WriteFloppy: PROCEDURE [volumeDesc: VolumeDesc, buffer: LONG POINTER,
address: FloppyFormat.Sector, count: FloppyFormat.ImplementedFileSize];
WriteSectorNine: PROCEDURE [volumeDesc: VolumeDesc];
END.