head     56.3;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


56.3
date     93.01.27.13.23.36;  author jwh;  state Exp;
branches ;
next     56.2;

56.2
date     93.01.27.12.03.36;  author jwh;  state Exp;
branches ;
next     56.1;

56.1
date     91.11.05.09.59.41;  author jwh;  state Exp;
branches ;
next     55.4;

55.4
date     91.10.09.09.49.57;  author jwh;  state Exp;
branches ;
next     55.3;

55.3
date     91.10.02.09.24.41;  author jwh;  state Exp;
branches ;
next     55.2;

55.2
date     91.09.30.09.52.43;  author jwh;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.34.39;  author jwh;  state Exp;
branches ;
next     54.3;

54.3
date     91.08.21.12.41.57;  author jwh;  state Exp;
branches ;
next     54.2;

54.2
date     91.08.06.11.42.04;  author jwh;  state Exp;
branches ;
next     54.1;

54.1
date     91.03.18.15.34.52;  author jwh;  state Exp;
branches ;
next     53.1;

53.1
date     91.03.11.19.34.34;  author jwh;  state Exp;
branches ;
next     52.1;

52.1
date     91.02.19.09.20.43;  author jwh;  state Exp;
branches ;
next     51.1;

51.1
date     91.01.30.16.19.12;  author jwh;  state Exp;
branches ;
next     50.1;

50.1
date     90.10.29.16.33.08;  author jwh;  state Exp;
branches ;
next     49.1;

49.1
date     90.08.14.14.16.51;  author jwh;  state Exp;
branches ;
next     48.1;

48.1
date     90.07.26.11.23.23;  author jwh;  state Exp;
branches ;
next     47.1;

47.1
date     90.05.14.11.09.28;  author dew;  state Exp;
branches ;
next     46.1;

46.1
date     90.05.07.08.56.25;  author jwh;  state Exp;
branches ;
next     45.1;

45.1
date     90.04.19.16.04.36;  author jwh;  state Exp;
branches ;
next     44.1;

44.1
date     90.04.01.22.22.05;  author jwh;  state Exp;
branches ;
next     43.2;

43.2
date     90.03.26.15.56.46;  author dew;  state Exp;
branches ;
next     43.1;

43.1
date     90.03.20.14.14.26;  author jwh;  state Exp;
branches ;
next     42.1;

42.1
date     90.01.23.17.58.27;  author jwh;  state Exp;
branches ;
next     41.1;

41.1
date     89.12.22.11.40.19;  author jwh;  state Exp;
branches ;
next     40.3;

40.3
date     89.12.21.15.10.12;  author jwh;  state Exp;
branches ;
next     40.2;

40.2
date     89.10.24.14.02.09;  author dew;  state Exp;
branches ;
next     40.1;

40.1
date     89.09.29.12.01.27;  author jwh;  state Exp;
branches ;
next     39.1;

39.1
date     89.09.26.16.46.23;  author dew;  state Exp;
branches ;
next     1.1;

1.1
date     89.09.14.14.00.33;  author dew;  state Exp;
branches ;
next     ;


desc
@SMINIT is the SCSI Medium INITialize routine.
@


56.3
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@module Sminit;

import
  sysglobals, midecs, bkgnd, SCSILIB;

export
  function HAVE_TEAC_FLOPPY_DRIVE(pUnit : uep_type) : boolean;
  function HAVE_QUANTUM_DRIVE(pUnit : uep_type) : boolean;
  procedure Sgetinitparms(pUnit : uep_type);
  function Sdevicename(pUnit: uep_type; var saved_ioresult: integer): string255;
  function Sintdata:interleave_data;
  function Sphydata(uep: uep_type): physical_data;
  procedure Sminitialize(pUnit: uep_type; interleave_factor: shortint);
  { procedure Sink_Teac(pUnit : uep_type); }
implement {Sminit}
type unsgn8 = 0..255;

       ms_array_type = packed array [0 .. 255] of char;
       page_code_type = 0..63;

       format_cmd_type = packed record
			   op_code : byte;
			   lunit   : 0..7;
			   fmtdata : boolean;
			   cmplst  : boolean;
			   dlf     : 0..7;
			   v0      : byte;
			   il_msb  : byte;
			   il_lsb  : byte;
			   v1      : 0..3;
			   rsvd    : 0..15;
			   flag    : boolean;
			   link    : boolean;
			 end;


      mode_sense_cmd_type = packed record
			   op_code : byte;
			   lunit   : 0..7;
			   pad0    : 0..31;
			   pcf     : 0..3;
			   pg_code : 0..hex('3f');
			   pad1    : byte;
			   reqlen  : byte;
			   pad2    : byte;
			 end;

     mode_sense_data_type = packed record
			   ms_len  : byte;
			   medtype : byte;
			   wp      : boolean;
			   rsvd1   : 0 .. 127;
			   bd_len  : byte;
			   ms_data : ms_array_type;
			 end;

     page_header_type = packed record
		      r1 : boolean;
		      r2 : boolean;
		      PageCode : page_code_type;
		      PageLen : byte;
		      awre : boolean;
		      arre : boolean;
		      rest : 0..63;
		      last_byte : byte;
		    end;
     pPageType = ^page_header_type;

type the_page_byte = packed record
    case boolean of
    FALSE :(r1 : boolean;
	    r2 : boolean;
	    pcode : 0..63);
    TRUE :(bite : char);
     end;

const
	mode_sense_cmd_const = mode_sense_cmd_type[
			   op_code : hex('1a'),
			   lunit   : 0,
			   pad0    : 0,
			   pcf     : 0,
			   pg_code : hex('3f'),
			   pad1    : 0,
			   reqlen  : 255,
			   pad2    : 0];

	    format_cmd_const = format_cmd_type[
			   op_code:hex('04'),
			   lunit:0,
			   fmtdata:false,
			   cmplst:false,
			   dlf:0,
			   v0:0,
			   il_msb:0,
			   il_lsb:0,
			   v1:0,
			   rsvd:0,
			   flag:false,
			   link:false];


       mode_select_cmd_const = mode_select_cmd_type[
			   op_code : hex('15'),
			   lunit   : 0,
			   pf      : 0,
			   rsvd1   : 0,
			   sp      : 0,
			   rsvd2   : 0,
			   rsvd3   : 0,
			   reqlen  : 36,
			   pad2    : 0];

{ Global to SMINIT : }

var formatting_option_byte : unsgn8;
    formatting_option_supported : boolean;
    sector_size_desired : integer;
    cylinders_desired : integer;
    high_density : boolean;
    My_Page:pPageType;
    length : integer;
    page_number : integer;
    from : mode_sense_data_type;
    page_one_holder : packed array[0..7] of char;


procedure LocScsiSBInit(pSB:PtrSessionBlockType; pUnit:uep_type);
var
	DAV:DeviceAddressVectorsType;
begin
	with pUnit^ do
	begin
		DAV.sc := sc;
		DAV.ba := ba;
		DAV.du := du;
		DAV.dv := dv;
	end;
	ScsiSBInit(pSB, addr(DAV));
end;

function give_me_page_index(which : integer) : integer;
var
	i,TotBytes:integer;
	TotLen:integer;
	look : the_page_byte;
begin
  give_me_page_index := -1;
  TotLen := from.ms_len - from.bd_len - 3;
  i := from.bd_len; { position i past the descriptor block }
  look.bite := from.ms_data[i];
  while ((TotLen > 0) and (look.PCode <> which)) do
     begin
      TotLen := TotLen - (ord(from.ms_data[i+1]) + 2);
      i := i + ord(from.ms_data[i+1]) + 2;
      look.bite := from.ms_data[i];
     end;
  if look.pcode = which then
    give_me_page_index := i;
end;

function HAVE_TEAC_FLOPPY_DRIVE(pUnit : uep_type) : boolean;
VAR
DevType, AnsiVersion:integer;
Removable:boolean;
s:string255;
sb:SessionBlockType;

begin
   HAVE_TEAC_FLOPPY_DRIVE := FALSE;
   LocScsiSBInit(addr(sb), pUnit);
   ScsiDevInfo(addr(sb), DevType, AnsiVersion, Removable, s);
   if strlen(s) >= 4 then
      if ((s[1] = 'T') and (s[2] = 'E') and (s[3] = 'A')
	   and (s[4] = 'C')) then
	     HAVE_TEAC_FLOPPY_DRIVE := TRUE;
end;

function HAVE_QUANTUM_DRIVE(pUnit : uep_type) : boolean;
VAR
DevType, AnsiVersion:integer;
Removable:boolean;
s:string255;
sb:SessionBlockType;

begin
   HAVE_QUANTUM_DRIVE := FALSE;
   LocScsiSBInit(addr(sb), pUnit);
   ScsiDevInfo(addr(sb), DevType, AnsiVersion, Removable, s);
   if strlen(s) >= 7 then
      if ((s[1] = 'Q') and (s[2] = 'U') and (s[3] = 'A')
	   and (s[4] = 'N') and (s[5] = 'T')
	   and (s[6] = 'U') and (s[7] = 'M'))
	   then
	     HAVE_QUANTUM_DRIVE := TRUE;
end;

procedure allow_modification(prompt: string255; var parm: unsgn8;
			      maxparm: unsgn8);
  var
    response: string255;
    newparm, i: integer;
    modification_ok: boolean;
  begin {allow_modification}
    repeat
      write(prompt, ' (defaults to ', parm:1, ') ');
      readln(response);
      modification_ok := strlen(response)=0;
      if not modification_ok then
	try
	  strread(response, 1, i, newparm);
	  modification_ok := (i=strlen(response)+1) and (newparm>=0)
		   and (newparm<=maxparm);
	  if modification_ok then
	    parm := newparm;
	recover
	  if not (-escapecode in [8, 10]) then escape(escapecode);
    until modification_ok;
  end; {allow_modification}




function Sdevicename(pUnit:uep_type; var saved_ioresult:integer):string255;
var
	sb:SessionBlockType;
	DevType, AnsiVersion:integer;
	Removable:boolean;
	s:string255;
begin
	LocScsiSBInit(addr(sb), pUnit);
	ScsiDevInfo(addr(sb), DevType, AnsiVersion, Removable, s);
	Sdevicename := s;
	if saved_ioresult=ord(inoerror) then  {report to miui}
		saved_ioresult := ioresult;
end;

function Sintdata:interleave_data;
begin
	Sintdata.min := 0;
	Sintdata.def := 0;
	Sintdata.max := 255;
end;


function Sphydata(uep: uep_type): physical_data;
var
	sb:SessionBlockType;
	NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders:integer;
	saveior : integer;
begin
	LocScsiSBInit(addr(sb), uep);
	ScsiDiscSize(addr(sb), NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders);
	if ioresult = ord(inoerror) then
	begin
		{
		  now convert ScsiDiscSize parms to physical_data parms.
		  NOTE:
			nspt = number of 256 byte sectors(Blocks) per track
			nspm = number of surfaces per media
			ntps = number of tracks per surface
		}
		if NumBytesBlock >= 256 then {block sizes are in powers of 2 so following is o.k.}
			Sphydata.nspt := (NumBytesBlock Div 256) * NumBlocksTrack
		else
			Sphydata.nspt := NumBlocksTrack Div (256 Div NumBytesBlock);
		Sphydata.nspm := NumTracksCylinder;
		Sphydata.ntps := NumCylinders;
	end;
end;

{======================================================================}
procedure InitModeSense(pSB:PtrSessionBlockType;
			pDB : PtrModeSenseDataType ;
			var sector_size : integer);
 type tricky_as_hell = record
     case boolean of
     FALSE: (i : integer);
     TRUE:  (c1,c2,c3,c4 : char);
  end;

 var mscmd : mode_sense_cmd_type;
     msdata : mode_sense_data_type;
     iotemp : integer;
     grab_it : tricky_as_hell;
     my_ptr : ^mode_sense_data_type;

 { Makes a call to ScsiHandleSession to query the controller }
begin
  grab_it.i := 0;
  mscmd := mode_sense_cmd_const;
  mscmd.lunit := pSB^.LUN;
  iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      pDB, { addr(msdata),} sizeof(msdata), false,
			      nil, 0, false);

  if iotemp <> 0 then  { allow one retry ????? }
     iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      pDB, { addr(msdata),} sizeof(msdata), false,
			      nil, 0, false);

  if iotemp = 0 then
    begin
     my_ptr := anyptr(pDB);
     grab_it.c2 := my_ptr^.ms_data[5];
     grab_it.c3 := my_ptr^.ms_data[6];
     grab_it.c4 := my_ptr^.ms_data[7];
     sector_size := grab_it.i;
   end
  else
    sector_size := 666; { sector from HELL  !!!! }
  if iotemp <> 0 then
     ioresult := iotemp; { ?????????? }
end;
{==========================================================================}
procedure SimpleModeSelect(pSB:PtrSessionBlockType;
			   pDB : PtrModeSelectDataType;
			   which_page : integer);

 var mscmd : mode_select_cmd_type;
     iotemp : integer;
     fake : mode_sense_data_type;
 begin
     pDB^.ms_len := 0;
     pDB^.wp := false;
     pDB^.rsvd1 := 0;
     pDB^.medtype := 0;
     pDB^.ms_data[8] := chr(which_page);  { JAB said so }
     pDB^.bd_len := 8;
     mscmd := mode_select_cmd_const;
     mscmd.reqlen := 20; { 4 + 8 + 8 }

     mscmd.lunit := pSB^.LUN;
     iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 20, false);

      IF IOTEMP <> 0 THEN   { allow one re-try ?????}
	iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 20 , false);

     if iotemp <> 0 then
	ioresult := iotemp; { ?????????? }

end;
{==========================================================================}

procedure NewModeSelect(pSB:PtrSessionBlockType;
			pDB : PtrModeSelectDataType ;
			 sector_size : integer;
			 cylinders : integer;
			 density : byte);

 type tricky_as_hell = record
     case boolean of
     FALSE: (i : integer);
     TRUE:  (c1,c2,c3,c4 : char);
  end;
 var mscmd : mode_select_cmd_type;
     msdata : mode_select_data_type;
     iotemp : integer;
     cram_it : tricky_as_hell;
     brute_force : packed array [0..255] of char;
     counter : integer;
begin
      { GET RID OF PAGE 1 : }
      for counter := 8 to 39 do
	pDB^.ms_data[counter] := pDB^.ms_data[counter+8];  { shift down }

     mscmd := mode_select_cmd_const;
     mscmd.reqlen := 44; { 4 + 8 + 32 }
     pDB^.ms_data[8] := chr(5);  { force page code }

     pDB^.ms_data[0] := chr(density);  { 1 or 2 }

     { Don't set the number of sectors - just let it float : }
     { pDB^.ms_data[1] := chr(0);
     pDB^.ms_data[2] := chr(2464 DIV 256);
     pDB^.ms_data[3] := chr(2464 MOD 256); }

     pDB^.ms_data[6] := chr(sector_size DIV 256);
     pDB^.ms_data[7] := chr(sector_size MOD 256);

     pDB^.ms_data[16] := chr(0);
     pDB^.ms_data[17] := chr(cylinders); { 77 or 80 cylinders }

     cram_it.i := sector_size;
     pDB^.ms_data[14] := cram_it.c3;
     pDB^.ms_data[15] := cram_it.c4;

     pDB^.ms_len := 0;
     pDB^.wp := false;
     pDB^.rsvd1 := 0;
     pDB^.medtype := 0;
     pDB^.bd_len := 8;

     mscmd.lunit := pSB^.LUN;
     iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 44 {sizeof(msdata)} , false);

      IF IOTEMP <> 0 THEN   { allow one re-try ?????}
	iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 44 {sizeof(msdata)} , false);

     if iotemp <> 0 then
	ioresult := iotemp;
end;

{==========================================================================}

procedure Sgetinitparms(pUnit : uep_type);
{ For use with the MACE SCSI Teac drive only }
  label 666;
  var
    sb:SessionBlockType;
    ch: char;
    sense_size : integer;
    msdata : mode_sense_data_type;

  begin {Sgetinitparms}
	LocScsiSBInit(addr(sb), pUnit);

	high_density := FALSE;
	sector_size_desired := 256;
	cylinders_desired := 77;
	formatting_option_byte := 0;
	formatting_option_supported := TRUE;
	if formatting_option_supported then
	  begin
	    666:
	    writeln;
	    allow_modification('Formatting option?',
	       formatting_option_byte, 239);
	    case formatting_option_byte of
	       0,1 : sector_size_desired := 256; { cyl total = 77 }
		2  : sector_size_desired := 512; { cyl total = 77 }
		3  : sector_size_desired := 1024; { cyl total = 77 }
		16 : begin
		      sector_size_desired := 512; { cyl total = 80 }
		      cylinders_desired := 80;
		     end;
	      otherwise
		begin
		  writeln('Allowable Options : 0, 1, 2, 3, or 16');
		  GOTO 666;
		end;
	     end; { case }

	  end; {if}

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);
       NewModeSelect(addr(SB),addr(msdata),sector_size_desired,80,2);
       if ioresult <> ord(inoerror) then
	  escape(-10);

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);
       if msdata.medtype = 136 then high_density := TRUE;

       { Forces update of this value (which is sector size) : }

      pUnit^.dvrtemp := 0;


  end; {Sgetinitparms}

{================================================================}

procedure FormatTrack(pSB:PtrSessionBlockType;
			InterLeave:s_short;
			logical_block_address:integer);
var
	saveDoNotDisconnect:boolean;
	ftcmd:format_cmd_type;
begin
	with pSB^ do
		if Overlap then
			ioresult := ord(zbadmode)
		else
		begin
			ftcmd := format_cmd_const;
			ftcmd.op_code := hex('06');
			ftcmd.lunit := LUN;

			ftcmd.v0 := logical_block_address Div HEX('100');
			ftcmd.il_msb := logical_block_address MOD HEX('100');

			ftcmd.il_lsb := Interleave Mod HEX('100');
			saveDoNotDisconnect := DoNotDisconnect;
			DoNotDisconnect := false;
			ioresult    := ScsiHandleSession(pSB,
						    addr(ftcmd), sizeof(ftcmd),
						    nil, 0, false,
						    nil, 0, false);
			DoNotDisconnect := saveDoNotDisconnect;
		end;
end;

{===================================================================}

procedure Sminitialize(pUnit: uep_type; interleave_factor: shortint);
VAR
    sb:SessionBlockType;
    sense_size : integer;
    msdata : mode_sense_data_type;

procedure erase_teac_and_select;
var base_of_78 : integer;
    sectors_per_track : integer;
    waste_em : integer;
    multiplier : integer;

begin
  multiplier := 1;
  if high_density then multiplier := 2;

  if cylinders_desired = 77 then { Option 0-1, or 2, or 3 }
   begin
	 case formatting_option_byte of
	  0,1 : begin
		 base_of_78 := 2464*multiplier;
		 sectors_per_track := 16*multiplier;
		end;
	   2  : begin
		 base_of_78 := 1386*multiplier;
		 sectors_per_track := 9*multiplier;
		end;
	   3  : begin
		 base_of_78 := 770*multiplier;
		 sectors_per_track := 5*multiplier;
		end;
	   otherwise escape(-10);
	  end; { case }

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);

       NewModeSelect(addr(SB),addr(msdata),
		       sector_size_desired DIV 2,80,1);
       if ioresult <> ord(inoerror) then
	BEGIN
	  escape(-10); END;

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);

       for waste_em := 0 to 5 do
	begin
	  FormatTrack(addr(sb), interleave_factor,
			  base_of_78 + waste_em*sectors_per_track);
	    if ioresult <> ord(inoerror) then
	     BEGIN
		escape(-10); end;
	end;

       { Now select the parameters the disk is really supposed to have : }

       NewModeSelect(addr(SB),addr(msdata),sector_size_desired,
			   cylinders_desired,2);
       if ioresult <> ord(inoerror) then
	BEGIN
	  escape(-10); END;



   end { cylinders_desired = 77 }
   else
     base_of_78 := 1440*multiplier; { really 81 not 78, in this case }

      pUnit^.dvrtemp := 0;
      pUnit^.umaxbytes := base_of_78*sector_size_desired;

end;

{====================================================================}
procedure set_arre_and_awre; { and FDPE if QUANTUM drive }
LABEL 666;
type awre_grab = packed record
     case boolean of
     FALSE: (bite : char);
     TRUE: (awre : boolean;
	    arre : boolean;
	    rest : 0..63);
       end;
type fdpe_grab = packed record
     case boolean of
     FALSE: (bite : char);
     TRUE: (rsvd1 : 0..16;
	     fdpe : boolean;
	    rest : 0..8);
       end;
var the_page : integer;
    count : integer;
    well : the_page_byte;
    check_awre : awre_grab;
    check_fdpe : fdpe_grab;
    saveioresult : integer;

begin
  saveioresult := ioresult;
  InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  GOTO 666;
  { get page one ... }
  from := msdata; { so "give_me_page_index" will work }
  the_page := give_me_page_index(1);
  if the_page = -1 { could not find } then GOTO 666;
  check_awre.bite := msdata.ms_data[the_page+2];
  if ((check_awre.awre = FALSE)  or (check_awre.arre = FALSE)) then
   begin { try to set 'em to TRUE }
    check_awre.awre := TRUE; check_awre.arre := TRUE;
    msdata.ms_data[the_page+2] := check_awre.bite;

    SimpleModeSelect(addr(SB),addr(msdata),1);
     if ioresult <> ord(inoerror) then
       GOTO 666;

    InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  GOTO 666;
   end; { HAD to SET AWRE and ARRE }

  if have_quantum_drive(pUNit) then
   begin { set the FDPE bit in page 57 before formatting }
    the_page := give_me_page_index(57);
    if the_page <> -1 then { actually found it }
     begin
      well.bite := msdata.ms_data[the_page];
      check_fdpe.bite := msdata.ms_data[the_page+2];

      if check_fdpe.fdpe = FALSE then
       begin { try to set it }
	check_fdpe.fdpe := TRUE;
	msdata.ms_data[the_page+2] := check_fdpe.bite;
	for count := 0 to 7 do { write over the page after bd }
	   msdata.ms_data[count+8] := msdata.ms_data[the_page+count];
	SimpleModeSelect(addr(SB),addr(msdata),57);
	if ioresult <> ord(inoerror) then
	      GOTO 666;
      end; { try to set it }
    end; { the_page <> -1 }
   end;  { have QUANTUM drive }
     666: ioresult := saveioresult;  { restore ... }
end;
{====================================================================}

begin
       LocScsiSBInit(addr(sb), pUnit);


       if NOT have_teac_floppy_drive(pUnit) then { hard disk }
	{ try setting AWRE and ARRE bits }
	{ and FDPE bit if QUANTUM, before formatting }
	    set_arre_and_awre;

      ScsiDiscFormat(addr(sb), interleave_factor);
      if ioresult <> ord(inoerror) then
		escape(-10);

       if have_teac_floppy_drive(pUnit) then
	 erase_teac_and_select;
end;


end {SMINIT}
@


56.2
log
@
pws2rcs automatic delta on Wed Jan 27 11:57:27 MST 1993
@
text
@d1 683
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 683
module Sminit;

import
  sysglobals, midecs, bkgnd, SCSILIB;

export
  function HAVE_TEAC_FLOPPY_DRIVE(pUnit : uep_type) : boolean;
  function HAVE_QUANTUM_DRIVE(pUnit : uep_type) : boolean;
  procedure Sgetinitparms(pUnit : uep_type);
  function Sdevicename(pUnit: uep_type; var saved_ioresult: integer): string255;
  function Sintdata:interleave_data;
  function Sphydata(uep: uep_type): physical_data;
  procedure Sminitialize(pUnit: uep_type; interleave_factor: shortint);
  { procedure Sink_Teac(pUnit : uep_type); }
implement {Sminit}
type unsgn8 = 0..255;

       ms_array_type = packed array [0 .. 255] of char;
       page_code_type = 0..63;

       format_cmd_type = packed record
			   op_code : byte;
			   lunit   : 0..7;
			   fmtdata : boolean;
			   cmplst  : boolean;
			   dlf     : 0..7;
			   v0      : byte;
			   il_msb  : byte;
			   il_lsb  : byte;
			   v1      : 0..3;
			   rsvd    : 0..15;
			   flag    : boolean;
			   link    : boolean;
			 end;


      mode_sense_cmd_type = packed record
			   op_code : byte;
			   lunit   : 0..7;
			   pad0    : 0..31;
			   pcf     : 0..3;
			   pg_code : 0..hex('3f');
			   pad1    : byte;
			   reqlen  : byte;
			   pad2    : byte;
			 end;

     mode_sense_data_type = packed record
			   ms_len  : byte;
			   medtype : byte;
			   wp      : boolean;
			   rsvd1   : 0 .. 127;
			   bd_len  : byte;
			   ms_data : ms_array_type;
			 end;

     page_header_type = packed record
		      r1 : boolean;
		      r2 : boolean;
		      PageCode : page_code_type;
		      PageLen : byte;
		      awre : boolean;
		      arre : boolean;
		      rest : 0..63;
		      last_byte : byte;
		    end;
     pPageType = ^page_header_type;

type the_page_byte = packed record
    case boolean of
    FALSE :(r1 : boolean;
	    r2 : boolean;
	    pcode : 0..63);
    TRUE :(bite : char);
     end;

const
	mode_sense_cmd_const = mode_sense_cmd_type[
			   op_code : hex('1a'),
			   lunit   : 0,
			   pad0    : 0,
			   pcf     : 0,
			   pg_code : hex('3f'),
			   pad1    : 0,
			   reqlen  : 255,
			   pad2    : 0];

	    format_cmd_const = format_cmd_type[
			   op_code:hex('04'),
			   lunit:0,
			   fmtdata:false,
			   cmplst:false,
			   dlf:0,
			   v0:0,
			   il_msb:0,
			   il_lsb:0,
			   v1:0,
			   rsvd:0,
			   flag:false,
			   link:false];


       mode_select_cmd_const = mode_select_cmd_type[
			   op_code : hex('15'),
			   lunit   : 0,
			   pf      : 0,
			   rsvd1   : 0,
			   sp      : 0,
			   rsvd2   : 0,
			   rsvd3   : 0,
			   reqlen  : 36,
			   pad2    : 0];

{ Global to SMINIT : }

var formatting_option_byte : unsgn8;
    formatting_option_supported : boolean;
    sector_size_desired : integer;
    cylinders_desired : integer;
    high_density : boolean;
    My_Page:pPageType;
    length : integer;
    page_number : integer;
    from : mode_sense_data_type;
    page_one_holder : packed array[0..7] of char;


procedure LocScsiSBInit(pSB:PtrSessionBlockType; pUnit:uep_type);
var
	DAV:DeviceAddressVectorsType;
begin
	with pUnit^ do
	begin
		DAV.sc := sc;
		DAV.ba := ba;
		DAV.du := du;
		DAV.dv := dv;
	end;
	ScsiSBInit(pSB, addr(DAV));
end;

function give_me_page_index(which : integer) : integer;
var
	i,TotBytes:integer;
	TotLen:integer;
	look : the_page_byte;
begin
  give_me_page_index := -1;
  TotLen := from.ms_len - from.bd_len - 3;
  i := from.bd_len; { position i past the descriptor block }
  look.bite := from.ms_data[i];
  while ((TotLen > 0) and (look.PCode <> which)) do
     begin
      TotLen := TotLen - (ord(from.ms_data[i+1]) + 2);
      i := i + ord(from.ms_data[i+1]) + 2;
      look.bite := from.ms_data[i];
     end;
  if look.pcode = which then
    give_me_page_index := i;
end;

function HAVE_TEAC_FLOPPY_DRIVE(pUnit : uep_type) : boolean;
VAR
DevType, AnsiVersion:integer;
Removable:boolean;
s:string255;
sb:SessionBlockType;

begin
   HAVE_TEAC_FLOPPY_DRIVE := FALSE;
   LocScsiSBInit(addr(sb), pUnit);
   ScsiDevInfo(addr(sb), DevType, AnsiVersion, Removable, s);
   if strlen(s) >= 4 then
      if ((s[1] = 'T') and (s[2] = 'E') and (s[3] = 'A')
	   and (s[4] = 'C')) then
	     HAVE_TEAC_FLOPPY_DRIVE := TRUE;
end;

function HAVE_QUANTUM_DRIVE(pUnit : uep_type) : boolean;
VAR
DevType, AnsiVersion:integer;
Removable:boolean;
s:string255;
sb:SessionBlockType;

begin
   HAVE_QUANTUM_DRIVE := FALSE;
   LocScsiSBInit(addr(sb), pUnit);
   ScsiDevInfo(addr(sb), DevType, AnsiVersion, Removable, s);
   if strlen(s) >= 7 then
      if ((s[1] = 'Q') and (s[2] = 'U') and (s[3] = 'A')
	   and (s[4] = 'N') and (s[5] = 'T')
	   and (s[6] = 'U') and (s[7] = 'M'))
	   then
	     HAVE_QUANTUM_DRIVE := TRUE;
end;

procedure allow_modification(prompt: string255; var parm: unsgn8;
			      maxparm: unsgn8);
  var
    response: string255;
    newparm, i: integer;
    modification_ok: boolean;
  begin {allow_modification}
    repeat
      write(prompt, ' (defaults to ', parm:1, ') ');
      readln(response);
      modification_ok := strlen(response)=0;
      if not modification_ok then
	try
	  strread(response, 1, i, newparm);
	  modification_ok := (i=strlen(response)+1) and (newparm>=0)
		   and (newparm<=maxparm);
	  if modification_ok then
	    parm := newparm;
	recover
	  if not (-escapecode in [8, 10]) then escape(escapecode);
    until modification_ok;
  end; {allow_modification}




function Sdevicename(pUnit:uep_type; var saved_ioresult:integer):string255;
var
	sb:SessionBlockType;
	DevType, AnsiVersion:integer;
	Removable:boolean;
	s:string255;
begin
	LocScsiSBInit(addr(sb), pUnit);
	ScsiDevInfo(addr(sb), DevType, AnsiVersion, Removable, s);
	Sdevicename := s;
	if saved_ioresult=ord(inoerror) then  {report to miui}
		saved_ioresult := ioresult;
end;

function Sintdata:interleave_data;
begin
	Sintdata.min := 0;
	Sintdata.def := 0;
	Sintdata.max := 255;
end;


function Sphydata(uep: uep_type): physical_data;
var
	sb:SessionBlockType;
	NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders:integer;
	saveior : integer;
begin
	LocScsiSBInit(addr(sb), uep);
	ScsiDiscSize(addr(sb), NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders);
	if ioresult = ord(inoerror) then
	begin
		{
		  now convert ScsiDiscSize parms to physical_data parms.
		  NOTE:
			nspt = number of 256 byte sectors(Blocks) per track
			nspm = number of surfaces per media
			ntps = number of tracks per surface
		}
		if NumBytesBlock >= 256 then {block sizes are in powers of 2 so following is o.k.}
			Sphydata.nspt := (NumBytesBlock Div 256) * NumBlocksTrack
		else
			Sphydata.nspt := NumBlocksTrack Div (256 Div NumBytesBlock);
		Sphydata.nspm := NumTracksCylinder;
		Sphydata.ntps := NumCylinders;
	end;
end;

{======================================================================}
procedure InitModeSense(pSB:PtrSessionBlockType;
			pDB : PtrModeSenseDataType ;
			var sector_size : integer);
 type tricky_as_hell = record
     case boolean of
     FALSE: (i : integer);
     TRUE:  (c1,c2,c3,c4 : char);
  end;

 var mscmd : mode_sense_cmd_type;
     msdata : mode_sense_data_type;
     iotemp : integer;
     grab_it : tricky_as_hell;
     my_ptr : ^mode_sense_data_type;

 { Makes a call to ScsiHandleSession to query the controller }
begin
  grab_it.i := 0;
  mscmd := mode_sense_cmd_const;
  mscmd.lunit := pSB^.LUN;
  iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      pDB, { addr(msdata),} sizeof(msdata), false,
			      nil, 0, false);

  if iotemp <> 0 then  { allow one retry ????? }
     iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      pDB, { addr(msdata),} sizeof(msdata), false,
			      nil, 0, false);

  if iotemp = 0 then
    begin
     my_ptr := anyptr(pDB);
     grab_it.c2 := my_ptr^.ms_data[5];
     grab_it.c3 := my_ptr^.ms_data[6];
     grab_it.c4 := my_ptr^.ms_data[7];
     sector_size := grab_it.i;
   end
  else
    sector_size := 666; { sector from HELL  !!!! }
  if iotemp <> 0 then
     ioresult := iotemp; { ?????????? }
end;
{==========================================================================}
procedure SimpleModeSelect(pSB:PtrSessionBlockType;
			   pDB : PtrModeSelectDataType;
			   which_page : integer);

 var mscmd : mode_select_cmd_type;
     iotemp : integer;
     fake : mode_sense_data_type;
 begin
     pDB^.ms_len := 0;
     pDB^.wp := false;
     pDB^.rsvd1 := 0;
     pDB^.medtype := 0;
     pDB^.ms_data[8] := chr(which_page);  { JAB said so }
     pDB^.bd_len := 8;
     mscmd := mode_select_cmd_const;
     mscmd.reqlen := 20; { 4 + 8 + 8 }

     mscmd.lunit := pSB^.LUN;
     iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 20, false);

      IF IOTEMP <> 0 THEN   { allow one re-try ?????}
	iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 20 , false);

     if iotemp <> 0 then
	ioresult := iotemp; { ?????????? }

end;
{==========================================================================}

procedure NewModeSelect(pSB:PtrSessionBlockType;
			pDB : PtrModeSelectDataType ;
			 sector_size : integer;
			 cylinders : integer;
			 density : byte);

 type tricky_as_hell = record
     case boolean of
     FALSE: (i : integer);
     TRUE:  (c1,c2,c3,c4 : char);
  end;
 var mscmd : mode_select_cmd_type;
     msdata : mode_select_data_type;
     iotemp : integer;
     cram_it : tricky_as_hell;
     brute_force : packed array [0..255] of char;
     counter : integer;
begin
      { GET RID OF PAGE 1 : }
      for counter := 8 to 39 do
	pDB^.ms_data[counter] := pDB^.ms_data[counter+8];  { shift down }

     mscmd := mode_select_cmd_const;
     mscmd.reqlen := 44; { 4 + 8 + 32 }
     pDB^.ms_data[8] := chr(5);  { force page code }

     pDB^.ms_data[0] := chr(density);  { 1 or 2 }

     { Don't set the number of sectors - just let it float : }
     { pDB^.ms_data[1] := chr(0);
     pDB^.ms_data[2] := chr(2464 DIV 256);
     pDB^.ms_data[3] := chr(2464 MOD 256); }

     pDB^.ms_data[6] := chr(sector_size DIV 256);
     pDB^.ms_data[7] := chr(sector_size MOD 256);

     pDB^.ms_data[16] := chr(0);
     pDB^.ms_data[17] := chr(cylinders); { 77 or 80 cylinders }

     cram_it.i := sector_size;
     pDB^.ms_data[14] := cram_it.c3;
     pDB^.ms_data[15] := cram_it.c4;

     pDB^.ms_len := 0;
     pDB^.wp := false;
     pDB^.rsvd1 := 0;
     pDB^.medtype := 0;
     pDB^.bd_len := 8;

     mscmd.lunit := pSB^.LUN;
     iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 44 {sizeof(msdata)} , false);

      IF IOTEMP <> 0 THEN   { allow one re-try ?????}
	iotemp := ScsiHandleSession(pSB,
			      addr(mscmd), sizeof(mscmd),
			      { addr(msdata)} nil, 0, {sizeof(msdata), }
				    false,
			      pDB, 44 {sizeof(msdata)} , false);

     if iotemp <> 0 then
	ioresult := iotemp;
end;

{==========================================================================}

procedure Sgetinitparms(pUnit : uep_type);
{ For use with the MACE SCSI Teac drive only }
  label 666;
  var
    sb:SessionBlockType;
    ch: char;
    sense_size : integer;
    msdata : mode_sense_data_type;

  begin {Sgetinitparms}
	LocScsiSBInit(addr(sb), pUnit);

	high_density := FALSE;
	sector_size_desired := 256;
	cylinders_desired := 77;
	formatting_option_byte := 0;
	formatting_option_supported := TRUE;
	if formatting_option_supported then
	  begin
	    666:
	    writeln;
	    allow_modification('Formatting option?',
	       formatting_option_byte, 239);
	    case formatting_option_byte of
	       0,1 : sector_size_desired := 256; { cyl total = 77 }
		2  : sector_size_desired := 512; { cyl total = 77 }
		3  : sector_size_desired := 1024; { cyl total = 77 }
		16 : begin
		      sector_size_desired := 512; { cyl total = 80 }
		      cylinders_desired := 80;
		     end;
	      otherwise
		begin
		  writeln('Allowable Options : 0, 1, 2, 3, or 16');
		  GOTO 666;
		end;
	     end; { case }

	  end; {if}

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);
       NewModeSelect(addr(SB),addr(msdata),sector_size_desired,80,2);
       if ioresult <> ord(inoerror) then
	  escape(-10);

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);
       if msdata.medtype = 136 then high_density := TRUE;

       { Forces update of this value (which is sector size) : }

      pUnit^.dvrtemp := 0;


  end; {Sgetinitparms}

{================================================================}

procedure FormatTrack(pSB:PtrSessionBlockType;
			InterLeave:s_short;
			logical_block_address:integer);
var
	saveDoNotDisconnect:boolean;
	ftcmd:format_cmd_type;
begin
	with pSB^ do
		if Overlap then
			ioresult := ord(zbadmode)
		else
		begin
			ftcmd := format_cmd_const;
			ftcmd.op_code := hex('06');
			ftcmd.lunit := LUN;

			ftcmd.v0 := logical_block_address Div HEX('100');
			ftcmd.il_msb := logical_block_address MOD HEX('100');

			ftcmd.il_lsb := Interleave Mod HEX('100');
			saveDoNotDisconnect := DoNotDisconnect;
			DoNotDisconnect := false;
			ioresult    := ScsiHandleSession(pSB,
						    addr(ftcmd), sizeof(ftcmd),
						    nil, 0, false,
						    nil, 0, false);
			DoNotDisconnect := saveDoNotDisconnect;
		end;
end;

{===================================================================}

procedure Sminitialize(pUnit: uep_type; interleave_factor: shortint);
VAR
    sb:SessionBlockType;
    sense_size : integer;
    msdata : mode_sense_data_type;

procedure erase_teac_and_select;
var base_of_78 : integer;
    sectors_per_track : integer;
    waste_em : integer;
    multiplier : integer;

begin
  multiplier := 1;
  if high_density then multiplier := 2;

  if cylinders_desired = 77 then { Option 0-1, or 2, or 3 }
   begin
	 case formatting_option_byte of
	  0,1 : begin
		 base_of_78 := 2464*multiplier;
		 sectors_per_track := 16*multiplier;
		end;
	   2  : begin
		 base_of_78 := 1386*multiplier;
		 sectors_per_track := 9*multiplier;
		end;
	   3  : begin
		 base_of_78 := 770*multiplier;
		 sectors_per_track := 5*multiplier;
		end;
	   otherwise escape(-10);
	  end; { case }

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);

       NewModeSelect(addr(SB),addr(msdata),
		       sector_size_desired DIV 2,80,1);
       if ioresult <> ord(inoerror) then
	BEGIN
	  escape(-10); END;

       InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  escape(-10);

       for waste_em := 0 to 5 do
	begin
	  FormatTrack(addr(sb), interleave_factor,
			  base_of_78 + waste_em*sectors_per_track);
	    if ioresult <> ord(inoerror) then
	     BEGIN
		escape(-10); end;
	end;

       { Now select the parameters the disk is really supposed to have : }

       NewModeSelect(addr(SB),addr(msdata),sector_size_desired,
			   cylinders_desired,2);
       if ioresult <> ord(inoerror) then
	BEGIN
	  escape(-10); END;



   end { cylinders_desired = 77 }
   else
     base_of_78 := 1440*multiplier; { really 81 not 78, in this case }

      pUnit^.dvrtemp := 0;
      pUnit^.umaxbytes := base_of_78*sector_size_desired;

end;

{====================================================================}
procedure set_arre_and_awre; { and FDPE if QUANTUM drive }
LABEL 666;
type awre_grab = packed record
     case boolean of
     FALSE: (bite : char);
     TRUE: (awre : boolean;
	    arre : boolean;
	    rest : 0..63);
       end;
type fdpe_grab = packed record
     case boolean of
     FALSE: (bite : char);
     TRUE: (rsvd1 : 0..16;
	     fdpe : boolean;
	    rest : 0..8);
       end;
var the_page : integer;
    count : integer;
    well : the_page_byte;
    check_awre : awre_grab;
    check_fdpe : fdpe_grab;
    saveioresult : integer;

begin
  saveioresult := ioresult;
  InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  GOTO 666;
  { get page one ... }
  from := msdata; { so "give_me_page_index" will work }
  the_page := give_me_page_index(1);
  if the_page = -1 { could not find } then GOTO 666;
  check_awre.bite := msdata.ms_data[the_page+2];
  if ((check_awre.awre = FALSE)  or (check_awre.arre = FALSE)) then
   begin { try to set 'em to TRUE }
    check_awre.awre := TRUE; check_awre.arre := TRUE;
    msdata.ms_data[the_page+2] := check_awre.bite;

    SimpleModeSelect(addr(SB),addr(msdata),1);
     if ioresult <> ord(inoerror) then
       GOTO 666;

    InitModeSense(addr(SB),ADDR(msdata),sense_size);
       if ioresult <> ord(inoerror) then
	  GOTO 666;
   end; { HAD to SET AWRE and ARRE }

  if have_quantum_drive(pUNit) then
   begin { set the FDPE bit in page 57 before formatting }
    the_page := give_me_page_index(57);
    if the_page <> -1 then { actually found it }
     begin
      well.bite := msdata.ms_data[the_page];
      check_fdpe.bite := msdata.ms_data[the_page+2];

      if check_fdpe.fdpe = FALSE then
       begin { try to set it }
	check_fdpe.fdpe := TRUE;
	msdata.ms_data[the_page+2] := check_fdpe.bite;
	for count := 0 to 7 do { write over the page after bd }
	   msdata.ms_data[count+8] := msdata.ms_data[the_page+count];
	SimpleModeSelect(addr(SB),addr(msdata),57);
	if ioresult <> ord(inoerror) then
	      GOTO 666;
      end; { try to set it }
    end; { the_page <> -1 }
   end;  { have QUANTUM drive }
     666: ioresult := saveioresult;  { restore ... }
end;
{====================================================================}

begin
       LocScsiSBInit(addr(sb), pUnit);


       if NOT have_teac_floppy_drive(pUnit) then { hard disk }
	{ try setting AWRE and ARRE bits }
	{ and FDPE bit if QUANTUM, before formatting }
	    set_arre_and_awre;

      ScsiDiscFormat(addr(sb), interleave_factor);
      if ioresult <> ord(inoerror) then
		escape(-10);

       if have_teac_floppy_drive(pUnit) then
	 erase_teac_and_select;
end;


end {SMINIT}
@


55.4
log
@Added the stuff to set (try to) the AWRE and ARRE bits in mode select
page 1 on all hard drives, and also to set (try to) the FDPE bit in
page 57 (mode select page) for the QUANTUM drives. JWH 10/10/91.
@
text
@@


55.3
log
@Changes routine erase_teac_and_select to set umaxbytes in the unit
table, and also changed NewModeSelect to just let the sector number
field to "float" (the cylinder total is what matters). JWH 10/2/91.
@
text
@d8 1
d18 3
d54 1
a54 1
			   ms_data : packed array [ 0 .. 255 ] of char;
d60 1
a60 1
		      PageCode : 0..63;
d62 5
a66 1
		      end;
d69 8
d121 5
d142 19
a162 1

d173 4
a176 2
   if ((s[1] = 'T') and (s[2] = 'E') and (s[3] = 'A') and (s[4] = 'C')) then
      HAVE_TEAC_FLOPPY_DRIVE := TRUE;
d179 19
d250 1
d318 37
d356 1
a356 1
			 pDB : PtrModeSelectDataType;
d373 1
a373 4
     { writeln('NEW MODE SELECTING : ');
     writeln('sector size : ',sector_size,' cylinders : ',cylinders,
	     ' density : ',density); }
      { GET RID OF PAGE 1 : ???? }
d379 1
a379 1
     pDB^.ms_data[8] := chr(5);  { JAB said so }
a403 3
     { writeln('NEW MODE SELECTING <<<<<<<<<<<<<<<<<< : ',
	     ord(pDB^.ms_data[0])); }

d419 1
a419 1
	ioresult := iotemp; { ?????????? }
a475 10
       { DEBUG ONLY !!! : }
       { writeln('before formatting, size is : ',sense_size);
       writeln('and cylinders are : ',ord(msdata.ms_data[25]));
       writeln('and high_density is : ',high_density); }

       { if unitable^[43].letter = 'S' then
	     unitable^[43].dvrtemp := 0;
       if unitable^[3].letter = 'S' then
	     unitable^[3].dvrtemp := 0; }

a558 1
	  { WRITELN('FIRST NEW MODE SELECT FAILED'); }
a560 2


a564 5
       { DEBUG ONLY !!! :
       writeln('before ERASING , sector size is : ',sense_size);
       writeln('and cylinders are : ',ord(msdata.ms_data[25]));
       writeln('and density code is   : ',ord(msdata.ms_data[0])); }

a570 1
	      { writeln('format track failed'); }
a579 1
	  { WRITELN('2ND NEW MODE SELECT FAILED'); }
d593 24
d618 48
a667 5
       { if have_teac_floppy_drive(pUnit) then
	begin
	 InitModeSense(addr(SB),ADDR(msdata),sense_size);
	  if ioresult <> ord(inoerror) then
	  escape(-10);
d669 4
a672 3
	  writeln('before ACTUALLY FORMATTING, sector size is : ',sense_size);
	  writeln('and cylinders are : ',ord(msdata.ms_data[25]));
	  writeln('and density code is   : ',ord(msdata.ms_data[0]));
a673 2
	end;  { have teac floppy drive }

a679 2


@


55.2
log
@Changes to bring SMINIT up to beta site (Wyko) version.
@
text
@d275 3
d287 3
a289 1
     pDB^.ms_data[1] := chr(0);
d291 2
a292 1
     pDB^.ms_data[3] := chr(2464 MOD 256);
a509 1
   end; { cylinders_desired = 77 }
d511 8
d534 1
a534 1
	end; } { have teac floppy drive }
@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@d17 14
d32 1
d72 13
d86 1
d237 2
a238 2
  if iotemp <> 0 then { allow one retry }
    iotemp := ScsiHandleSession(pSB,
d242 1
d256 2
a257 3

{======================================================================}
procedure InitModeSelect(pSB:PtrSessionBlockType;
d260 3
a262 1
			 cylinders : integer);
d275 3
a278 3
      for counter := 0 to 31 do
	pDB^.ms_data[counter] := pDB^.ms_data[counter+16]; { shift down }

d280 2
a281 1
     pDB^.ms_data[0] := chr(5);  { JAB said so }
d283 6
a288 2
     pDB^.ms_data[8] := chr(0);
     pDB^.ms_data[9] := chr(cylinders); { 77 or 80 cylinders }
d290 3
d294 2
a295 2
     pDB^.ms_data[6] := cram_it.c3;
     pDB^.ms_data[7] := cram_it.c4;
d301 1
a301 1
     pDB^.bd_len := 0;
d303 2
d311 1
a311 1
			      pDB, 36 {sizeof(msdata)} , false);
d313 1
a313 1
     IF IOTEMP <> 0 THEN  { allow one re-try }
d318 1
a318 1
			      pDB, 36 {sizeof(msdata)} , false);
a325 9
{ procedure Sink_Teac(pUnit : uep_type);
var sb : SessionBlockType;
begin
  LocScsiSBInit(addr(sb), pUnit);
  SyncTeac(addr(sb));
end; }

{==========================================================================}

d327 1
a327 1

d369 1
a369 1
       InitModeSelect(addr(SB),ADDR(msdata),sector_size_desired,cylinders_desired);
d378 2
a379 2
       { DEBUG ONLY !!! :
       writeln('before formatting, size is : ',sense_size);
d383 1
a383 1
       if unitable^[43].letter = 'S' then
d386 1
a386 1
	     unitable^[3].dvrtemp := 0;
d388 1
d390 3
d395 34
d434 5
d442 2
a443 1
	LocScsiSBInit(addr(sb), pUnit);
d445 18
a462 1
       { DEBUG ONLY !!! :
d467 6
a472 2
       writeln('before formatting, size is : ',sense_size);
       writeln('and cylinders are : ',ord(msdata.ms_data[25])); }
d475 48
d527 3
a529 14
      if have_teac_floppy_drive(pUnit) then
       begin
	 multiplier := 1;
	 if high_density then multiplier := 2;
	 case formatting_option_byte of
	  0,1 : unitable^[3].umaxbytes := 630784*multiplier;
	   2  : unitable^[3].umaxbytes := 709632*multiplier;
	   3  : unitable^[3].umaxbytes := 788480*multiplier;
	   16 : unitable^[3].umaxbytes := 737280*multiplier;
	   otherwise escape(-10);
	     end; { case }
	    if unitable^[43].letter = 'S' then
	     unitable^[43].umaxbytes := unitable^[3].umaxbytes;
       end; { have TEAC }
@


54.3
log
@
pws2rcs automatic delta on Wed Aug 21 12:27:56 MDT 1991
@
text
@@


54.2
log
@Changes for TEAC.
@
text
@d13 1
a13 2
  procedure Sink_Teac(pUnit : uep_type);

d75 1
d285 1
a285 1
procedure Sink_Teac(pUnit : uep_type);
d290 1
a290 1
end;
d306 1
d344 1
d346 4
a349 2
       { writeln('before formatting, size is : ',sense_size);
       writeln('and cylinders are : ',ord(msdata.ms_data[25])); }
d356 1
a358 2
{==========================================================================}

d361 5
a365 1
	sb:SessionBlockType;
d369 4
d374 6
a379 2
	 ScsiDiscFormat(addr(sb), interleave_factor);
	 if ioresult <> ord(inoerror) then
d382 14
a395 2
	 { if have_teac_floppy_drive(pUnit) then
	    Sink_Teac(pUnit); }
@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@d7 2
d13 1
d16 1
d19 59
d92 43
d182 174
d357 1
a357 1
var
d361 4
a364 2
	ScsiDiscFormat(addr(sb), interleave_factor);
	if ioresult <> ord(inoerror) then
d366 4
d371 1
@


53.1
log
@Automatic bump of revision number for PWS version 3.24B
@
text
@@


52.1
log
@Automatic bump of revision number for PWS version 3.24A
@
text
@@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@@


50.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


49.1
log
@Automatic bump of revision number for PWS version 3.24b
@
text
@@


48.1
log
@Automatic bump of revision number for PWS version 3.24a
@
text
@@


47.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


46.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


45.1
log
@Automatic bump of revision number for PWS version 3.23C
@
text
@@


44.1
log
@Automatic bump of revision number for PWS version 3.23B
@
text
@@


43.2
log
@Updated ScsiSBInit call to reflect new interface.
@
text
@@


43.1
log
@Automatic bump of revision number for PWS version 3.23aA
@
text
@d15 13
d36 1
a36 1
	ScsiSBInit(addr(sb), pUnit);
d56 1
a56 1
	ScsiSBInit(addr(sb), uep);
d80 1
a80 1
	ScsiSBInit(addr(sb), pUnit);
@


42.1
log
@Automatic bump of revision number for PWS version 3.23e
@
text
@@


41.1
log
@Automatic bump of revision number for PWS version 3.23d
@
text
@@


40.3
log
@
pws2rcs automatic delta on Thu Dec 21 14:54:59 MST 1989
@
text
@@


40.2
log
@Update MEDIAINIT to work with new programmer's interface definition.

This should not have to change again.
@
text
@d4 1
a4 1
  sysglobals, midecs, bkgnd, SCSIIF;
@


40.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@d4 1
a4 1
  sysglobals, midecs, bkgnd, SCSI_DEFS, SCSIIF;
d44 1
a44 1
	ScsiDiskSize(addr(sb), NumBytesBlock, NumBlocksTrack, NumTracksCylinder, NumCylinders);
d48 1
a48 1
		  now convert ScsiDiskSize parms to physical_data parms.
d68 1
a68 1
	ScsiFormat(addr(sb), interleave_factor);
@


39.1
log
@Automatic bump of revision number for PWS version 3.23b
@
text
@@


1.1
log
@Initial revision
@
text
@@
