Floppy.mesa
Copyright Ó Xerox Corporation 1982, 1986, 1987. All rights reserved.
Tim Diebert: May 7, 1987 2:52:01 pm PDT
DIRECTORY
FS USING [OpenFile --, Type-- ],
Rope USING [ROPE];
Floppy: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE ~ Rope.ROPE;
File identifiers
FileID: TYPE = PRIVATE MACHINE DEPENDENT RECORD [a (0), b (1): WORD];
nullFileID: FileID = [0, 0];
FileHandle: TYPE = RECORD [volume: VolumeHandle, file: FileID];
Volume references
VolumeHandle: TYPE [2];
nullVolumeHandle: READONLY VolumeHandle;
File addressing
PageNumber: TYPE = LONG CARDINAL;
firstPageCount: PageNumber = 0;
lastPageCount: PageNumber = LAST[PageNumber];
PageCount: TYPE = PageNumber;
defaultPageCount: PageNumber = LAST[PageNumber];
Volume operations
Format: PROCEDURE [drive: CARDINAL, maxNumberOfFileListEntries: CARDINAL,
labelString: ROPE, density: Density ← default, sides: Sides ← default];
maxCharactersInLabel: CARDINAL = 40;
Density: TYPE = {single, double, default};
Sides: TYPE = {one, two, default};
Open: PROCEDURE [drive: CARDINAL ← 0] RETURNS [volume: VolumeHandle];
Close: PROCEDURE [volume: VolumeHandle];
GetAttributes: PROCEDURE [volume: VolumeHandle]
RETURNS [freeSpace: PageCount, largestBlock: PageCount, fileList: FileHandle,
rootFile: FileHandle, density: Density[single..double],
sides: Sides[one..two], maxFileListEntries: CARDINAL, labelString: ROPE];
GetDrive: PROCEDURE [volumeHandle: VolumeHandle] RETURNS [drive: CARDINAL];
Compact: PROCEDURE [volume: VolumeHandle];
Scavenge: PROCEDURE [volume: VolumeHandle] RETURNS [numberOfBadSectors: PageCount];
NewScavenge: PROCEDURE [drive: CARDINAL] RETURNS [okay: BOOLEAN];
GetNextBadSector: PROCEDURE [volume: VolumeHandle, oldIndex: CARDINAL]
RETURNS [newIndex: CARDINAL, file: FileHandle, page: PageNumber];
nullIndex: CARDINAL = LAST[CARDINAL];
SetRootFile: PROCEDURE [file: FileHandle];
Erase: PROCEDURE [drive: CARDINAL, maxNumberOfFileListEntries: CARDINAL,
labelString: ROPENIL];
File operations
CreateFile: PROCEDURE [volume: VolumeHandle, size: PageCount,
type: --File.Type-- CARDINAL] RETURNS [file: FileHandle];
DeleteFile: PROCEDURE [file: FileHandle];
Read: UNSAFE PROC [file: FileHandle, first: PageNumber, count: PageCount,
vm: LONG POINTER];
Write: UNSAFE PROC [file: FileHandle, first: PageNumber, count: PageCount,
vm: LONG POINTER];
CopyToFSFile: PROCEDURE [floppyFile: FileHandle, pilotFile: FS.OpenFile,
firstFloppyPage: PageNumber, firstFSPage: INT, count: PageCount ← defaultPageCount];
CopyFromFSFile: PROCEDURE [pilotFile: FS.OpenFile, floppyFile: FileHandle,
firstFSPage: INT, firstFloppyPage: PageNumber, count: PageCount ← defaultPageCount];
ReplaceBadSector: PROCEDURE [file: FileHandle, page: PageNumber]
RETURNS [readError: BOOLEAN];
GetFileAttributes: PROCEDURE [file: FileHandle]
RETURNS [size: PageCount, type: --File.Type-- CARDINAL];
GetNextFile: PROCEDURE [previousFile: FileHandle] RETURNS [nextFile: FileHandle];
Bootable floppies
CreateInitialMicrocodeFile: PROCEDURE [volume: VolumeHandle, size: PageCount,
type: --File.Type-- CARDINAL, startingPageNumber: PageNumber ← 1]
RETURNS [file: FileHandle];
SetBootFiles: PROCEDURE [volume: VolumeHandle, pilotMicrocode, diagnosticMicrocode, germ, pilotBootFile: BootFilePointer ← nullBootFilePointer];
GetBootFiles: PROCEDURE [volume: VolumeHandle]
RETURNS
[initialMicrocode, pilotMicrocode, diagnosticMicrocode, germ, pilotBootFile: BootFilePointer];
BootFilePointer: TYPE = RECORD [file: FileID, page: PageNumber];
nullBootFilePointer: BootFilePointer = [nullFileID, 0];
Floppy Images
MakeImage: PROCEDURE [floppyDrive: CARDINAL ← 0, imageFile: FS.OpenFile,
firstImagePage: INT];
CreateFloppyFromImage: PROCEDURE [floppyDrive: CARDINAL ← 0, imageFile: FS.OpenFile, firstImagePage: INT, reformatFloppy: BOOLEAN, floppyDensity: Density ← default,
floppySides: Sides ← default, numberOfFiles: CARDINAL ← 0,
newLabelString: ROPENIL];
PagesForImage: PROCEDURE [floppyDrive: CARDINAL ← 0] RETURNS [INT];
GetImageAttributes: PROCEDURE [imageFile: FS.OpenFile, firstImagePage: INT]
RETURNS [maxNumberOfFiles: CARDINAL, currentNumberOfFiles: CARDINAL,
density: Density[single..double], sides: Sides[one..two], name: ROPENIL];
Signals and errors
Error: ERROR [error: ErrorType];
ErrorType: TYPE = {badDisk, badSectors, cannotScavenge, endOfFile, fileListFull, fileNotFound, hardwareError, incompatibleSizes, invalidFormat, invalidPageNumber, invalidVolumeHandle, insufficientSpace, needsScavenging, noSuchDrive, notReady, notFormatted, onlyOneSide, onlySingleDensity, initialMicrocodeSpaceNotAvailable, stringTooShort, volumeNotOpen, writeInhibited, zeroSizeFile, fileListLengthTooShort, floppyImageInvalid, floppySpaceTooSmall, volumeOpen};
DataError: ERROR [file: FileHandle, page: PageNumber, vm: LONG POINTER];
AlreadyFormatted: SIGNAL [labelString: ROPE];
END...