head     56.3;
access   paws bayes jws quist brad dew jwh;
symbols  ;
locks    ; strict;
comment  @# @;


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

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

56.1
date     91.11.05.09.55.42;  author jwh;  state Exp;
branches ;
next     55.1;

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

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

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

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

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

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

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

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

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

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

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

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

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

44.1
date     90.04.01.22.18.16;  author jwh;  state Exp;
branches ;
next     43.1;

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

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

41.1
date     89.12.22.11.37.23;  author jwh;  state Exp;
branches ;
next     40.1;

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

39.1
date     89.09.26.16.43.14;  author dew;  state Exp;
branches ;
next     38.1;

38.1
date     89.08.29.11.35.13;  author jwh;  state Exp;
branches ;
next     37.1;

37.1
date     89.05.12.11.49.01;  author dew;  state Exp;
branches ;
next     36.1;

36.1
date     89.02.06.10.26.39;  author dew;  state Exp;
branches ;
next     35.1;

35.1
date     89.02.02.13.42.12;  author dew;  state Exp;
branches ;
next     34.1;

34.1
date     89.01.23.16.17.24;  author jwh;  state Exp;
branches ;
next     33.1;

33.1
date     89.01.16.11.48.51;  author dew;  state Exp;
branches ;
next     32.1;

32.1
date     89.01.10.11.58.08;  author bayes;  state Exp;
branches ;
next     31.1;

31.1
date     88.12.14.18.18.59;  author bayes;  state Exp;
branches ;
next     30.1;

30.1
date     88.12.09.13.56.03;  author dew;  state Exp;
branches ;
next     29.1;

29.1
date     88.10.31.15.40.38;  author bayes;  state Exp;
branches ;
next     28.1;

28.1
date     88.10.06.11.06.54;  author dew;  state Exp;
branches ;
next     27.1;

27.1
date     88.09.29.11.49.38;  author bayes;  state Exp;
branches ;
next     26.1;

26.1
date     88.09.28.13.38.20;  author bayes;  state Exp;
branches ;
next     25.1;

25.1
date     88.03.02.09.43.58;  author bayes;  state Exp;
branches ;
next     24.1;

24.1
date     87.08.31.10.14.41;  author jws;  state Exp;
branches ;
next     23.1;

23.1
date     87.08.26.11.00.11;  author bayes;  state Exp;
branches ;
next     22.1;

22.1
date     87.08.17.11.39.46;  author bayes;  state Exp;
branches ;
next     21.1;

21.1
date     87.08.12.14.23.53;  author bayes;  state Exp;
branches ;
next     20.1;

20.1
date     87.07.30.11.35.29;  author bayes;  state Exp;
branches ;
next     19.1;

19.1
date     87.06.01.08.49.35;  author jws;  state Exp;
branches ;
next     18.1;

18.1
date     87.05.20.15.54.59;  author bayes;  state Exp;
branches ;
next     17.2;

17.2
date     87.05.15.14.26.47;  author bayes;  state Exp;
branches ;
next     17.1;

17.1
date     87.04.30.10.58.51;  author jws;  state Exp;
branches ;
next     16.1;

16.1
date     87.04.26.16.09.11;  author jws;  state Exp;
branches ;
next     15.1;

15.1
date     87.04.13.09.49.37;  author jws;  state Exp;
branches ;
next     14.1;

14.1
date     87.04.01.15.59.07;  author jws;  state Exp;
branches ;
next     13.1;

13.1
date     87.02.28.18.52.30;  author jws;  state Exp;
branches ;
next     12.1;

12.1
date     87.02.02.13.46.02;  author jws;  state Exp;
branches ;
next     11.1;

11.1
date     87.01.19.10.12.10;  author jws;  state Exp;
branches ;
next     10.1;

10.1
date     86.12.24.11.27.17;  author jws;  state Exp;
branches ;
next     9.1;

9.1
date     86.12.12.15.10.47;  author bayes;  state Exp;
branches ;
next     8.1;

8.1
date     86.11.27.12.20.38;  author jws;  state Exp;
branches ;
next     7.1;

7.1
date     86.11.20.14.32.00;  author hal;  state Exp;
branches ;
next     6.1;

6.1
date     86.11.04.18.25.59;  author paws;  state Exp;
branches ;
next     5.1;

5.1
date     86.10.28.17.15.12;  author hal;  state Exp;
branches ;
next     4.1;

4.1
date     86.09.30.20.09.18;  author hal;  state Exp;
branches ;
next     3.1;

3.1
date     86.09.01.12.19.43;  author hal;  state Exp;
branches ;
next     2.1;

2.1
date     86.07.30.15.08.47;  author hal;  state Exp;
branches ;
next     1.1;

1.1
date     86.06.30.16.43.52;  author danm;  state tmp;
branches ;
next     ;


desc
@Base file for PWS 3.2 release.

@


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


import
  sysglobals, asm {, misc};


export

  procedure miniio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
  procedure ioresc(ioresult_value: iorsltwd);

  function iorval: iorsltwd;

implement


var
  most_recent_escapecode: shortint;  {for post-mortem diagnostic purposes only!!!}


procedure ioresc(ioresult_value: iorsltwd);
  begin {ioresc}
    ioresult := ord(ioresult_value);
    escape(-10)
  end; {ioresc}
$page$

function iorval: iorsltwd;

  type
    te = {table entry type}
      record
	b{basic error}: shortint;
	p{pascal error}: iorsltwd
      end;
    ect_type = {error conversion table type}
      array[1..29] of te;

  const
    error_conversion_table = ect_type[
      te[b: 1066, p:zinitfail      ],     {bad track 0, side 0            }
      te[b: 2066, p:zinitfail      ],     {more than 4 spares             }
      te[b: 3066, p:zbadhardware   ],     {write fault or lost data       }
      te[b: 4066, p:znomedium      ],     {timeout during init            }
      te[b: 1080, p:znomedium      ],     {no media or door open          }
      te[b: 2080, p:znomedium      ],     {no media or door open          }
      te[b: 3080, p:znomedium      ],     {no media or door open          }
      te[b: 8080, p:zmediumchanged ],     {media changed                  }
      te[b: 9080, p:znomedium      ],     {media changed during operation }
      te[b: 1081, p:znoblock       ],     {track not found                }
      te[b: 2081, p:zbadhardware   ],     {restore error                  }
      te[b: 3081, p:zbadhardware   ],     {track 0 not found after reset  }
      te[b: 4081, p:zbadhardware   ],     {read lost data error           }
      te[b: 5081, p:zbadhardware   ],     {write lost data error or fault }
      te[b: 6081, p:zbadhardware   ],     {address lost data error        }
      te[b: 7081, p:znoblock       ],     {address CRC error during write }
      te[b: 1083, p:zprotected     ],     {write protect error            }
      te[b: 2083, p:zprotected     ],     {write protect error            }
      te[b: 1084, p:znoblock       ],     {read record not found/d bit set}
      te[b: 2084, p:znoblock       ],     {write record not found         }
      te[b: 3084, p:znoblock       ],     {address (track) not found      }
      te[b: 1087, p:znoblock       ],     {address CRC error              }
      te[b: 1088, p:zbadblock      ],     {read CRC error                 }
      te[b: 6090, p:zstrangei      ],     {unexpected interrupt           }
      te[b: 7090, p:zstrangei      ],     {INT during wrt trk handshaking }
      te[b: 8090, p:znomedium      ],     {timeout waiting for interrupt  }
      te[b: 9090, p:zcatchall      ],     {INT mask > 2 (flpy locked out) }
      te[b:11090, p:zbadhardware   ],     {timeout; floppy not responding }
      te[b: 1082, p:znodevice      ] ];   {2nd drive not present          }

  var
    i: shortint;

  begin {iorval}
    most_recent_escapecode := escapecode;  {for post-mortem diagnostic purposes only!!!}
    iorval := inoerror;  {value returned if unrecognized}
    for i := 1 to 29 do
      with error_conversion_table[i] do
	if escapecode=b then iorval := p;
  end; {iorval}
$page$

procedure miniio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
  const
    bootrev1 = chr(255);

  type
    uep_type = ^unitentry;      {SFB}

  var
    bootrevflag[318]: char;
    minidrive[-301]: packed record num: 0..255 end;
    buf: charptr;
  { uep: ^unitentry; { SFB }
    uep: uep_type;   { SFB }


  procedure clear_unit;
    begin {clear_unit}
      try
	f_pwr_on;
      recover
	if iorval<>inoerror
	  then ioresc(iorval)
	  else escape(escapecode);
    end; {clear_unit}

  { This procedure is called instead of just clearing umediavalid on
  { uep. The idea now is to clear umediavalid on all units which
  { deal with the same medium. This is necessary for HFS support, so
  { that when unit #3 detects medium changed, #43 also sees it, and
  { gets a chance to invalidate caches. CS80 TM has always done this.
  { The code is stolen and hacked from CS80.
  { SFB
  }
  procedure clr_umediavalid(uep: uep_type);
    var
      lun: unitnum;
      scanner_uep: uep_type;
    begin {clr_umediavalid}
      for lun := 1 to maxunit do
	begin
	  scanner_uep := addr(unitable^[lun]);
	  if (scanner_uep^.letter=uep^.letter) and
	     (scanner_uep^.sc = uep^.sc) and
	     (scanner_uep^.ba = uep^.ba) and
	     (scanner_uep^.du = uep^.du)
	     {don't qualify dv because all volumes ARE affected!}
	  then {clear umediavalid}
	    scanner_uep^.umediavalid := false;  {media possibly changed}
	end; {for}
    end; {clr_umediavalid}

  procedure transfer(sector: integer);

    var
      transfer_successful: boolean;
      whole_sectors: integer;
      whole_sector_bytes: integer;
      fubuffer[-558]: packed array[0..255] of byte;
      saved_escapecode: shortint;
      ior: iorsltwd;

    begin {transfer}

      repeat
	try

	  whole_sectors := length div 256;
	  if whole_sectors>0 then
	    begin
	      case request of
		readbytes, startread:
		  flpymread(whole_sectors, sector, buf^);
		writebytes, startwrite:
		  flpymwrite(whole_sectors, sector, buf^);
	      end; {case}
	      sector := sector+whole_sectors;
	      whole_sector_bytes := whole_sectors*256;
	      buf := addr(buf^, whole_sector_bytes);
	      length := length-whole_sector_bytes;
	    end; {if}

	  if length>0 then
	    case request of
	      readbytes, startread:
		begin
		  flpyread(sector, fubuffer);
		  moveleft(fubuffer, buf^, length);
		end;
	      writebytes, startwrite:
		begin
		  moveleft(buf^, fubuffer, length);
		  flpy_wrt(sector, fubuffer);
		end;
	    end; {case}

	  transfer_successful := true;

	recover
	  begin
	    ior := iorval;
	    if ior=inoerror then {unrecognized escapecode}
	      begin
		saved_escapecode := escapecode;
		try
		  f_pwr_on;
		recover
		  {do nothing};
		escape(saved_escapecode);
	      end
	    else if ior=zmediumchanged then
	      begin
	      { uep^.umediavalid := false; { upgraded for 3.2. SFB }
		clr_umediavalid(uep);   { SFB }
		if uep^.ureportchange then
		  ioresc(ior);
		transfer_successful := false;  {retry}
	      end {with}
	    else
	      ioresc(ior);
	  end; {recover}

      until transfer_successful;

    end; {transfer}
  $page$

  begin {miniio}
    uep := addr(unitable^[fp^.funit]);
    if uep^.offline then
      ioresult := ord(znodevice)
    else
      begin
	{ lockup; }
	try
	  if bootrevflag=bootrev1 then
	    if uep^.du=0 then {ok}
	    else ioresc(znodevice)
	  else
	    if uep^.du in [0,1] then minidrive.num := uep^.du
	    else ioresc(znodevice);

	  case request of
	    clearunit:
	      clear_unit;

	    unitstatus:
	      fp^.fbusy := false;

	    flush:
	      {do nothing};

	    readbytes, writebytes, startread, startwrite:
	      begin
		if uep^.ureportchange and not uep^.umediavalid then
		  ioresc(zmediumchanged);
		buf := addr(buffer);
		if (position mod 256<>0) or odd(integer(buf)) then
		  ioresc(zbadmode);
		if (position<0) or (length<0) or (position+length>fp^.fpeof) then
		  ioresc(ieof);
		transfer((position+fp^.fileid+uep^.byteoffset) div 256);
	      end;

	    otherwise
	      ioresc(ibadrequest);
	  end; {case}

	  ioresc(inoerror);  {set ioresult & perform lockdown}
	recover
	  begin
	    { lockdown; }
	    if escapecode<>-10 then escape(escapecode);
	    if request in [startread, startwrite] then call (fp^.feot, fp);
	  end; {recover}
      end; {else}
  end; {miniio}

end {mini}

@


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


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


import
  sysglobals, asm {, misc};


export

  procedure miniio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
  procedure ioresc(ioresult_value: iorsltwd);

  function iorval: iorsltwd;

implement


var
  most_recent_escapecode: shortint;  {for post-mortem diagnostic purposes only!!!}


procedure ioresc(ioresult_value: iorsltwd);
  begin {ioresc}
    ioresult := ord(ioresult_value);
    escape(-10)
  end; {ioresc}
$page$

function iorval: iorsltwd;

  type
    te = {table entry type}
      record
	b{basic error}: shortint;
	p{pascal error}: iorsltwd
      end;
    ect_type = {error conversion table type}
      array[1..29] of te;

  const
    error_conversion_table = ect_type[
      te[b: 1066, p:zinitfail      ],     {bad track 0, side 0            }
      te[b: 2066, p:zinitfail      ],     {more than 4 spares             }
      te[b: 3066, p:zbadhardware   ],     {write fault or lost data       }
      te[b: 4066, p:znomedium      ],     {timeout during init            }
      te[b: 1080, p:znomedium      ],     {no media or door open          }
      te[b: 2080, p:znomedium      ],     {no media or door open          }
      te[b: 3080, p:znomedium      ],     {no media or door open          }
      te[b: 8080, p:zmediumchanged ],     {media changed                  }
      te[b: 9080, p:znomedium      ],     {media changed during operation }
      te[b: 1081, p:znoblock       ],     {track not found                }
      te[b: 2081, p:zbadhardware   ],     {restore error                  }
      te[b: 3081, p:zbadhardware   ],     {track 0 not found after reset  }
      te[b: 4081, p:zbadhardware   ],     {read lost data error           }
      te[b: 5081, p:zbadhardware   ],     {write lost data error or fault }
      te[b: 6081, p:zbadhardware   ],     {address lost data error        }
      te[b: 7081, p:znoblock       ],     {address CRC error during write }
      te[b: 1083, p:zprotected     ],     {write protect error            }
      te[b: 2083, p:zprotected     ],     {write protect error            }
      te[b: 1084, p:znoblock       ],     {read record not found/d bit set}
      te[b: 2084, p:znoblock       ],     {write record not found         }
      te[b: 3084, p:znoblock       ],     {address (track) not found      }
      te[b: 1087, p:znoblock       ],     {address CRC error              }
      te[b: 1088, p:zbadblock      ],     {read CRC error                 }
      te[b: 6090, p:zstrangei      ],     {unexpected interrupt           }
      te[b: 7090, p:zstrangei      ],     {INT during wrt trk handshaking }
      te[b: 8090, p:znomedium      ],     {timeout waiting for interrupt  }
      te[b: 9090, p:zcatchall      ],     {INT mask > 2 (flpy locked out) }
      te[b:11090, p:zbadhardware   ],     {timeout; floppy not responding }
      te[b: 1082, p:znodevice      ] ];   {2nd drive not present          }

  var
    i: shortint;

  begin {iorval}
    most_recent_escapecode := escapecode;  {for post-mortem diagnostic purposes only!!!}
    iorval := inoerror;  {value returned if unrecognized}
    for i := 1 to 29 do
      with error_conversion_table[i] do
	if escapecode=b then iorval := p;
  end; {iorval}
$page$

procedure miniio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
  const
    bootrev1 = chr(255);

  type
    uep_type = ^unitentry;      {SFB}

  var
    bootrevflag[318]: char;
    minidrive[-301]: packed record num: 0..255 end;
    buf: charptr;
  { uep: ^unitentry; { SFB }
    uep: uep_type;   { SFB }


  procedure clear_unit;
    begin {clear_unit}
      try
	f_pwr_on;
      recover
	if iorval<>inoerror
	  then ioresc(iorval)
	  else escape(escapecode);
    end; {clear_unit}

  { This procedure is called instead of just clearing umediavalid on
  { uep. The idea now is to clear umediavalid on all units which
  { deal with the same medium. This is necessary for HFS support, so
  { that when unit #3 detects medium changed, #43 also sees it, and
  { gets a chance to invalidate caches. CS80 TM has always done this.
  { The code is stolen and hacked from CS80.
  { SFB
  }
  procedure clr_umediavalid(uep: uep_type);
    var
      lun: unitnum;
      scanner_uep: uep_type;
    begin {clr_umediavalid}
      for lun := 1 to maxunit do
	begin
	  scanner_uep := addr(unitable^[lun]);
	  if (scanner_uep^.letter=uep^.letter) and
	     (scanner_uep^.sc = uep^.sc) and
	     (scanner_uep^.ba = uep^.ba) and
	     (scanner_uep^.du = uep^.du)
	     {don't qualify dv because all volumes ARE affected!}
	  then {clear umediavalid}
	    scanner_uep^.umediavalid := false;  {media possibly changed}
	end; {for}
    end; {clr_umediavalid}

  procedure transfer(sector: integer);

    var
      transfer_successful: boolean;
      whole_sectors: integer;
      whole_sector_bytes: integer;
      fubuffer[-558]: packed array[0..255] of byte;
      saved_escapecode: shortint;
      ior: iorsltwd;

    begin {transfer}

      repeat
	try

	  whole_sectors := length div 256;
	  if whole_sectors>0 then
	    begin
	      case request of
		readbytes, startread:
		  flpymread(whole_sectors, sector, buf^);
		writebytes, startwrite:
		  flpymwrite(whole_sectors, sector, buf^);
	      end; {case}
	      sector := sector+whole_sectors;
	      whole_sector_bytes := whole_sectors*256;
	      buf := addr(buf^, whole_sector_bytes);
	      length := length-whole_sector_bytes;
	    end; {if}

	  if length>0 then
	    case request of
	      readbytes, startread:
		begin
		  flpyread(sector, fubuffer);
		  moveleft(fubuffer, buf^, length);
		end;
	      writebytes, startwrite:
		begin
		  moveleft(buf^, fubuffer, length);
		  flpy_wrt(sector, fubuffer);
		end;
	    end; {case}

	  transfer_successful := true;

	recover
	  begin
	    ior := iorval;
	    if ior=inoerror then {unrecognized escapecode}
	      begin
		saved_escapecode := escapecode;
		try
		  f_pwr_on;
		recover
		  {do nothing};
		escape(saved_escapecode);
	      end
	    else if ior=zmediumchanged then
	      begin
	      { uep^.umediavalid := false; { upgraded for 3.2. SFB }
		clr_umediavalid(uep);   { SFB }
		if uep^.ureportchange then
		  ioresc(ior);
		transfer_successful := false;  {retry}
	      end {with}
	    else
	      ioresc(ior);
	  end; {recover}

      until transfer_successful;

    end; {transfer}
  $page$

  begin {miniio}
    uep := addr(unitable^[fp^.funit]);
    if uep^.offline then
      ioresult := ord(znodevice)
    else
      begin
	{ lockup; }
	try
	  if bootrevflag=bootrev1 then
	    if uep^.du=0 then {ok}
	    else ioresc(znodevice)
	  else
	    if uep^.du in [0,1] then minidrive.num := uep^.du
	    else ioresc(znodevice);

	  case request of
	    clearunit:
	      clear_unit;

	    unitstatus:
	      fp^.fbusy := false;

	    flush:
	      {do nothing};

	    readbytes, writebytes, startread, startwrite:
	      begin
		if uep^.ureportchange and not uep^.umediavalid then
		  ioresc(zmediumchanged);
		buf := addr(buffer);
		if (position mod 256<>0) or odd(integer(buf)) then
		  ioresc(zbadmode);
		if (position<0) or (length<0) or (position+length>fp^.fpeof) then
		  ioresc(ieof);
		transfer((position+fp^.fileid+uep^.byteoffset) div 256);
	      end;

	    otherwise
	      ioresc(ibadrequest);
	  end; {case}

	  ioresc(inoerror);  {set ioresult & perform lockdown}
	recover
	  begin
	    { lockdown; }
	    if escapecode<>-10 then escape(escapecode);
	    if request in [startread, startwrite] then call (fp^.feot, fp);
	  end; {recover}
      end; {else}
  end; {miniio}

end {mini}

@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@@


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


54.2
log
@
pws2rcs automatic delta on Wed Aug 21 09:35:48 MDT 1991
@
text
@d1 264
@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@a0 264
module mini;


import
  sysglobals, asm {, misc};


export

  procedure miniio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
  procedure ioresc(ioresult_value: iorsltwd);

  function iorval: iorsltwd;

implement


var
  most_recent_escapecode: shortint;  {for post-mortem diagnostic purposes only!!!}


procedure ioresc(ioresult_value: iorsltwd);
  begin {ioresc}
    ioresult := ord(ioresult_value);
    escape(-10)
  end; {ioresc}
$page$

function iorval: iorsltwd;

  type
    te = {table entry type}
      record
	b{basic error}: shortint;
	p{pascal error}: iorsltwd
      end;
    ect_type = {error conversion table type}
      array[1..29] of te;

  const
    error_conversion_table = ect_type[
      te[b: 1066, p:zinitfail      ],     {bad track 0, side 0            }
      te[b: 2066, p:zinitfail      ],     {more than 4 spares             }
      te[b: 3066, p:zbadhardware   ],     {write fault or lost data       }
      te[b: 4066, p:znomedium      ],     {timeout during init            }
      te[b: 1080, p:znomedium      ],     {no media or door open          }
      te[b: 2080, p:znomedium      ],     {no media or door open          }
      te[b: 3080, p:znomedium      ],     {no media or door open          }
      te[b: 8080, p:zmediumchanged ],     {media changed                  }
      te[b: 9080, p:znomedium      ],     {media changed during operation }
      te[b: 1081, p:znoblock       ],     {track not found                }
      te[b: 2081, p:zbadhardware   ],     {restore error                  }
      te[b: 3081, p:zbadhardware   ],     {track 0 not found after reset  }
      te[b: 4081, p:zbadhardware   ],     {read lost data error           }
      te[b: 5081, p:zbadhardware   ],     {write lost data error or fault }
      te[b: 6081, p:zbadhardware   ],     {address lost data error        }
      te[b: 7081, p:znoblock       ],     {address CRC error during write }
      te[b: 1083, p:zprotected     ],     {write protect error            }
      te[b: 2083, p:zprotected     ],     {write protect error            }
      te[b: 1084, p:znoblock       ],     {read record not found/d bit set}
      te[b: 2084, p:znoblock       ],     {write record not found         }
      te[b: 3084, p:znoblock       ],     {address (track) not found      }
      te[b: 1087, p:znoblock       ],     {address CRC error              }
      te[b: 1088, p:zbadblock      ],     {read CRC error                 }
      te[b: 6090, p:zstrangei      ],     {unexpected interrupt           }
      te[b: 7090, p:zstrangei      ],     {INT during wrt trk handshaking }
      te[b: 8090, p:znomedium      ],     {timeout waiting for interrupt  }
      te[b: 9090, p:zcatchall      ],     {INT mask > 2 (flpy locked out) }
      te[b:11090, p:zbadhardware   ],     {timeout; floppy not responding }
      te[b: 1082, p:znodevice      ] ];   {2nd drive not present          }

  var
    i: shortint;

  begin {iorval}
    most_recent_escapecode := escapecode;  {for post-mortem diagnostic purposes only!!!}
    iorval := inoerror;  {value returned if unrecognized}
    for i := 1 to 29 do
      with error_conversion_table[i] do
	if escapecode=b then iorval := p;
  end; {iorval}
$page$

procedure miniio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
  const
    bootrev1 = chr(255);

  type
    uep_type = ^unitentry;      {SFB}

  var
    bootrevflag[318]: char;
    minidrive[-301]: packed record num: 0..255 end;
    buf: charptr;
  { uep: ^unitentry; { SFB }
    uep: uep_type;   { SFB }


  procedure clear_unit;
    begin {clear_unit}
      try
	f_pwr_on;
      recover
	if iorval<>inoerror
	  then ioresc(iorval)
	  else escape(escapecode);
    end; {clear_unit}

  { This procedure is called instead of just clearing umediavalid on
  { uep. The idea now is to clear umediavalid on all units which
  { deal with the same medium. This is necessary for HFS support, so
  { that when unit #3 detects medium changed, #43 also sees it, and
  { gets a chance to invalidate caches. CS80 TM has always done this.
  { The code is stolen and hacked from CS80.
  { SFB
  }
  procedure clr_umediavalid(uep: uep_type);
    var
      lun: unitnum;
      scanner_uep: uep_type;
    begin {clr_umediavalid}
      for lun := 1 to maxunit do
	begin
	  scanner_uep := addr(unitable^[lun]);
	  if (scanner_uep^.letter=uep^.letter) and
	     (scanner_uep^.sc = uep^.sc) and
	     (scanner_uep^.ba = uep^.ba) and
	     (scanner_uep^.du = uep^.du)
	     {don't qualify dv because all volumes ARE affected!}
	  then {clear umediavalid}
	    scanner_uep^.umediavalid := false;  {media possibly changed}
	end; {for}
    end; {clr_umediavalid}

  procedure transfer(sector: integer);

    var
      transfer_successful: boolean;
      whole_sectors: integer;
      whole_sector_bytes: integer;
      fubuffer[-558]: packed array[0..255] of byte;
      saved_escapecode: shortint;
      ior: iorsltwd;

    begin {transfer}

      repeat
	try

	  whole_sectors := length div 256;
	  if whole_sectors>0 then
	    begin
	      case request of
		readbytes, startread:
		  flpymread(whole_sectors, sector, buf^);
		writebytes, startwrite:
		  flpymwrite(whole_sectors, sector, buf^);
	      end; {case}
	      sector := sector+whole_sectors;
	      whole_sector_bytes := whole_sectors*256;
	      buf := addr(buf^, whole_sector_bytes);
	      length := length-whole_sector_bytes;
	    end; {if}

	  if length>0 then
	    case request of
	      readbytes, startread:
		begin
		  flpyread(sector, fubuffer);
		  moveleft(fubuffer, buf^, length);
		end;
	      writebytes, startwrite:
		begin
		  moveleft(buf^, fubuffer, length);
		  flpy_wrt(sector, fubuffer);
		end;
	    end; {case}

	  transfer_successful := true;

	recover
	  begin
	    ior := iorval;
	    if ior=inoerror then {unrecognized escapecode}
	      begin
		saved_escapecode := escapecode;
		try
		  f_pwr_on;
		recover
		  {do nothing};
		escape(saved_escapecode);
	      end
	    else if ior=zmediumchanged then
	      begin
	      { uep^.umediavalid := false; { upgraded for 3.2. SFB }
		clr_umediavalid(uep);   { SFB }
		if uep^.ureportchange then
		  ioresc(ior);
		transfer_successful := false;  {retry}
	      end {with}
	    else
	      ioresc(ior);
	  end; {recover}

      until transfer_successful;

    end; {transfer}
  $page$

  begin {miniio}
    uep := addr(unitable^[fp^.funit]);
    if uep^.offline then
      ioresult := ord(znodevice)
    else
      begin
	{ lockup; }
	try
	  if bootrevflag=bootrev1 then
	    if uep^.du=0 then {ok}
	    else ioresc(znodevice)
	  else
	    if uep^.du in [0,1] then minidrive.num := uep^.du
	    else ioresc(znodevice);

	  case request of
	    clearunit:
	      clear_unit;

	    unitstatus:
	      fp^.fbusy := false;

	    flush:
	      {do nothing};

	    readbytes, writebytes, startread, startwrite:
	      begin
		if uep^.ureportchange and not uep^.umediavalid then
		  ioresc(zmediumchanged);
		buf := addr(buffer);
		if (position mod 256<>0) or odd(integer(buf)) then
		  ioresc(zbadmode);
		if (position<0) or (length<0) or (position+length>fp^.fpeof) then
		  ioresc(ieof);
		transfer((position+fp^.fileid+uep^.byteoffset) div 256);
	      end;

	    otherwise
	      ioresc(ibadrequest);
	  end; {case}

	  ioresc(inoerror);  {set ioresult & perform lockdown}
	recover
	  begin
	    { lockdown; }
	    if escapecode<>-10 then escape(escapecode);
	    if request in [startread, startwrite] then call (fp^.feot, fp);
	  end; {recover}
      end; {else}
  end; {miniio}

end {mini}

@


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.1
log
@Automatic bump of revision number for PWS version 3.23aA
@
text
@@


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.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


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


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


37.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


36.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


35.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


34.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


33.1
log
@Automatic bump of revision number for PWS version 3.22D
@
text
@@


32.1
log
@Automatic bump of revision number for PWS version 3.22C
@
text
@@


31.1
log
@Automatic bump of revision number for PWS version 3.22B
@
text
@@


30.1
log
@Automatic bump of revision number for PWS version 3.22A
@
text
@@


29.1
log
@Automatic bump of revision number for PWS version 3.22b
@
text
@@


28.1
log
@Automatic bump of revision number for PWS version 3.3b
@
text
@@


27.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


26.1
log
@Automatic bump of revision number for PWS version 3.3 Synch
@
text
@@


25.1
log
@Automatic bump of revision number for PWS version 3.2Y
@
text
@@


24.1
log
@Automatic bump of revision number for PWS version 3.2
@
text
@@


23.1
log
@Automatic bump of revision number for PWS version 3.2P
@
text
@@


22.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@@


21.1
log
@Automatic bump of revision number for PWS version 3.2M
@
text
@@


20.1
log
@Automatic bump of revision number for PWS version 3.2L
@
text
@@


19.1
log
@Automatic bump of revision number for PWS version 3.2K
@
text
@@


18.1
log
@Automatic bump of revision number for PWS version 3.2J
@
text
@@


17.2
log
@Added code to set umediavalid false on all same_medium units, when
setting umediavalid on one. See hfsupport, procedure check_disk_status
@
text
@@


17.1
log
@Automatic bump of revision number for PWS version 3.2I+
@
text
@d90 3
d97 2
a98 1
    uep: ^unitentry;
d100 1
d111 25
d197 2
a198 1
		uep^.umediavalid := false;
@


16.1
log
@Automatic bump of revision number for PWS version 3.2I
@
text
@@


15.1
log
@Automatic bump of revision number for PWS version 3.2H
@
text
@@


14.1
log
@Automatic bump of revision number for PWS version 3.2G
@
text
@@


13.1
log
@Automatic bump of revision number for PWS version 3.2F
@
text
@@


12.1
log
@Automatic bump of revision number for PWS version 3.2E
@
text
@@


11.1
log
@Automatic bump of revision number for PWS version 3.2D
@
text
@@


10.1
log
@Automatic bump of revision number for PWS version 3.2C
@
text
@@


9.1
log
@Automatic bump of revision number for PWS version 3.2B
@
text
@@


8.1
log
@Automatic bump of revision number for PWS version 3.2A
@
text
@@


7.1
log
@Automatic bump of revision number for PWS version 3.2l
@
text
@@


6.1
log
@Automatic bump of revision number for PWS version 3.2k
@
text
@@


5.1
log
@Automatic bump of revision number for PWS version 3.2j
@
text
@@


4.1
log
@Automatic bump of revision number for PWS version 3.2i
@
text
@@


3.1
log
@Automatic bump of revision number for PWS version 3.2h
@
text
@@


2.1
log
@Auto bump rev number to 2.1 for sys 3.2e.
@
text
@@


1.1
log
@Initial revision
@
text
@@
