-- FormatSA1000andSA4000.mesa
-- Last Edited by: Taft, May 22, 1983 4:28 pm

DIRECTORY
  PhysicalVolume USING [Handle, PageNumber],
  System USING [GreenwichMeanTime];

FormatSA1000andSA4000: DEFINITIONS =
BEGIN

DiskPageNumber: TYPE = PhysicalVolume.PageNumber;
FailureType: TYPE =
   {emptyFile, firstPageBad, flakeyPageFound, microcodeTooBig, other};

BadPage: SIGNAL [p: DiskPageNumber];
PassStarting: SIGNAL [pass: CARDINAL, operation: Operation];
Operation: TYPE = {write, read};

MicrocodeInstallFailure: SIGNAL [m: FailureType];
  -- Generated upon install error.  If resumed, InstallBootMicrocode
  -- will "eat" the remaining input (until NIL) and then return
  -- (this may be usefull for some protocols).
NotSA1000orSA4000: ERROR;
SA1000FormatTrackError: ERROR;
  -- add error about drive busy with Pilot Access????
SA1000FormatCylinderError: ERROR;  -- synomyn for Sa1000FormatTrackError.  goes away after Rubicon

Format, Scan: PROC [
  h: PhysicalVolume.Handle, firstPage: DiskPageNumber,
  count: LONG CARDINAL, passes: CARDINAL];
  -- Format Sa4000 (write headers, labels and data, verivy all) the drive
  -- or Scan (verify headers, read all labels and Data).  Do
  -- [firstPage..firstPage+count)
  -- If formatting SA1000, then firstPage must be the beginning of a
  --  track, and (lastPage-firstPage+1) MOD trackSize must = 0
  -- Raises BadPage[pageNumber] for each bad page found;
  -- raises PassStarting[passNumber] at the beginning of each pass.

IdentifyInitialMicrocode: PROCEDURE [h: PhysicalVolume.Handle, s: STRING]
  RETURNS [microcodeInstalled: BOOLEAN, time: System.GreenwichMeanTime];

InstallBootMicrocode: PROC [
  h: PhysicalVolume.Handle, getPage: PROC RETURNS[LONG POINTER]];
  -- Install boot microcode on disk.  Repeatedly calls NextPage until
  -- NIL is returned.  Copies the information out of the page and does
  -- the magic.  Pointer's page which must be resident and page
  -- aligned.

-- Location of fake alto volumes, etc.
SA1000pagesPerTrack: CARDINAL = 16;
SA1000startOfMicrocode: DiskPageNumber = 16;
SA1000lastPageOfMicrocode: DiskPageNumber = 127;
FirstSA1000PageForPilot: DiskPageNumber = 128;

SA4000startOfMicrocode: DiskPageNumber = 28;
SA4000lastPageOfMicrocode: DiskPageNumber = 223;
SA4000startOfModel44s: DiskPageNumber = 224;  -- first cylinder
SA4000Model44Count: TYPE = [0..4];

SA4000FirstPageForPilot: PROC [c: SA4000Model44Count]
    RETURNS [DiskPageNumber] =
  INLINE {RETURN[SA4000startOfModel44s + c*406*28]};
    -- each model 44 is 406 28 page tracks

END.


LOG
Time: May 30, 1980  6:41 PM	By: Forrest	Action: Eliminated Dependence on DiskChannel.  Added layout fake Alto volume info.Trimmed log to Amargosa.
Time: June 28, 1980  1:40 PM	By: Forrest	Action: Changed to use PhysicalVolume.Handle; Add SA1000.
Time: February 11, 1981  2:44 PM	By: Forrest	Action: Start changes to for SA1000 cylinder boundaries being really track boundaries.
21-Jun-82 18:15:36  Taft  Add IdentifyInitialMicrocode
May 22, 1983 4:28 pm  Taft  Add passes arg to Format, PassStarting signal.