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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

18.1
date     87.05.20.16.03.03;  author bayes;  state Exp;
branches ;
next     17.1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.1
date     86.06.30.17.07.57;  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
@$page$

module IRamigo; {amigo initialization routines}

import
  sysglobals, bkgnd, discHPIB, CSamigo;

export
  procedure verify          (uep: uep_type; nsectors: unsigned16);
  procedure init_with_d_bits(uep: uep_type);
  procedure format          (uep: uep_type; intlve, d_byte: byte; override: boolean);

implement {IRamigo}

procedure verify(uep: uep_type; nsectors: unsigned16);
  var
    verify_cmd_buf:
      packed record
	ftcb: ftcb_type;
	sector_count: unsigned16;
      end;
  begin {verify}
    verify_cmd_buf.sector_count := nsectors;
    issue_cmd(uep, verify_cmd, verify_cmd_buf.ftcb);
  end; {verify}

procedure init_with_d_bits(uep: uep_type);
  var
    init_cmd_buf: ftcb_type;
    dummy_byte: packed record  b: byte;  end;
  const
    receive_data_sec = 0;
  begin {init_with_d_bits}
    issue_cmd(uep, init_d_cmd, init_cmd_buf);
    HPIBwait_for_ppol(uep);
    dummy_byte.b := 0;
    HPIBshort_msge_out(uep, receive_data_sec, addr(dummy_byte), sizeof(dummy_byte));
  end; {init_with_d_bits}

procedure format(uep: uep_type; intlve, d_byte: byte; override: boolean);
  var
    format_cmd_buf:
      packed record
	ftcb: ftcb_type;
	f: boolean;      { override old format bit }
	ttttttt: 0..127; { wanted format type      }
	int: byte;       { interleave factor       }
	db: byte;        { data byte               }
      end;
  begin {format}
    with format_cmd_buf do
      begin
	f := override;
	ttttttt := 2;   {HP format always}
	int := intlve;
	db := d_byte
      end; {with}
    issue_cmd(uep, format_cmd, format_cmd_buf.ftcb);
  end; {format}

end; {IRamigo}


module Hminit;

import
  sysglobals, bkgnd, discHPIB, CSamigo, IRamigo, midecs;

export
  function Hintdata: interleave_data;
  function Nintdata(uep: uep_type): interleave_data;
  function Hphydata(uep: uep_type): physical_data;
  procedure Hminitialize(uep: uep_type; intlve: shortint);

implement {Hminit}


function Hintdata: interleave_data;
  const
    intdata = interleave_data
      [ min: 1,         {minimum interleave factor}
	max: 29,        {maximum interleave factor}
	def: 2 ];       {default interleave factor}
  begin {Hintdata}
    Hintdata := intdata;
  end; {Hintdata}


function Nintdata(uep: uep_type): interleave_data;
  const
    intdata = interleave_data
      [ min: 1,         {minimum interleave factor}
	max: 15,        {maximum interleave factor}
	def: 3 ];       {default interleave factor}
  begin {Nintdata}
    Nintdata := intdata;
    if uep^.devid<>0 then  {this is actually a Sparrow...}
      Nintdata.def := 2;   {which performs best at this interleave}
  end; {Nintdata}


function Hphydata(uep: uep_type): physical_data;
  var
    map: map_type;
    phydata: physical_data;
  begin {Hphydata}
    get_map(uep, map);
    with map, phydata do
      begin
	nspm := trk_per_cyl;    {number of surfaces per medium}
	ntps := cyl_per_med;    {number of tracks/surface}
	nspt := sec_per_trk;    {number of sectors per track}
      end; {with}
    Hphydata := phydata;
  end; {Hphydata}
$page$

procedure Hminitialize(uep: uep_type; intlve: shortint);

  var
    status_bytes: status_type;
    map: map_type;
    tracks_per_medium: shortint;

  procedure confirm_preeoi;
    begin {confirm_preeoi}
      with bip_type(uep^.dvrtemp)^ do
	if (escapecode=-10) and (iores=zbadhardware)
	  then iores := inoerror
	  else escape(escapecode);
    end; {confirm_preeoi}

  procedure check_status;
    begin {check_status}
      status(uep, status_bytes);
      case status_bytes.s1 of
	{"acceptable" errors}
	  uncorrectable_data_error,
	  head_sector_compare_error,
	  access_not_ready_during_data_operation:
	      {acceptable; do not escape};
	{error requiring status 2 check}
	  drive_attention:
	      if not status_bytes.c then ioresc_bkgnd(uep, zinitfail);
	{other errors}
	  otherwise ioresc_bkgnd(uep, zinitfail)
      end; {case}
    end; {check_status}


  procedure init_9895_913X_Chinook;
    const
      testpasses = 4;               {number of test passes       }
      max_bt = 4;                   {maximum number of bad tracks}
    type
      test_pattern_type = packed array[1..testpasses] of byte;
    const
      test_pattern = test_pattern_type
	[ 198,    {$C6 or 1100011011000110}
	   99,    {$63 or 0110001101100011}
	  219,    {$DB or 1101101111011011}
	  136 ];  {$88 or 1000100010001000}
    var
      bt_count: shortint;
      test_pass: shortint;
      verify_starting_track: shortint;
      verify_pass_complete: boolean;
      bt_already_logged: boolean;
      bad_track: shortint;
      bt_index: shortint;
      bt_table: array[1..max_bt] of shortint;
$page$

    begin {init_9895_913X_Chinook}
      bt_count := 0;
      for test_pass := 1 to testpasses do
	begin
	  format(uep, 1, test_pattern[test_pass], true);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	  verify_starting_track := 0;
	  repeat
	    seek(uep, verify_starting_track*map.sec_per_trk);
	    HPIBwait_for_ppol(uep);
	    verify(uep, (tracks_per_medium+max_bt-verify_starting_track)*map.sec_per_trk);
	    HPIBwait_for_ppol(uep);
	    if dsj(uep)=0 then
	      verify_pass_complete := true
	    else
	      begin
		check_status;
		bad_track := logical_addr(uep) div map.sec_per_trk;
		bt_already_logged := false;  {initial assumption}
		for bt_index := 1 to bt_count do
		  if bt_table[bt_index]=bad_track then bt_already_logged := true;
		if not bt_already_logged then  {log it}
		  begin
		    if bt_count>=max_bt then ioresc_bkgnd(uep, zinitfail);
		    bt_count := bt_count+1;
		    bt_table[bt_count] := bad_track;
		  end;
		verify_starting_track := bad_track+1;
		verify_pass_complete := verify_starting_track>=tracks_per_medium+max_bt;
	      end {else}
	  until verify_pass_complete;
	end; {for}

      for bt_index := 1 to bt_count do {set all d-bits on the bad tracks}
	begin
	  seek(uep, bt_table[bt_index]*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  init_with_d_bits(uep);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	end;

      format(uep, intlve, 0, false);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
      seek(uep, 0);
      HPIBwait_for_ppol(uep);
      verify(uep, tracks_per_medium*map.sec_per_trk);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
    end; {init_9895_913X_Chinook}
$page$

  procedure init_913X_ABC;

    var
      verify_pass: shortint;
      csvp: shortint;  {consecutive successful verify passes}
      verify_starting_track: shortint;
      verify_pass_complete: boolean;

    const
      min_vp = 5;       {minimum # of verify passes}
      max_vp = 15;      {maxmimum # of verify passes}
      min_csvp = 2;     {minimum # of consecutive successful verify passes}

    begin {init_913X_ABC}

      format(uep, intlve, 0, true);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);

      verify_pass := 0;
      csvp := 0;

      repeat

	verify_pass := verify_pass+1;
	verify_starting_track := 0;

	repeat
	  seek(uep, verify_starting_track*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  verify(uep, (tracks_per_medium-verify_starting_track)*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)=0 then
	    verify_pass_complete := true
	  else
	    begin
	      check_status;
	      verify_starting_track := logical_addr(uep) div map.sec_per_trk+1;
	      init_with_d_bits(uep);
	      HPIBwait_for_ppol(uep);
	      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	      verify_pass_complete := verify_starting_track>=tracks_per_medium;
	    end {else}
	until verify_pass_complete;

	if verify_starting_track=0 {i.e., successful verify pass}
	  then csvp := csvp+1
	  else csvp := 0;

      until ((verify_pass>=min_vp) and (csvp>=min_csvp)) or (verify_pass>=max_vp);

      if csvp<min_csvp then ioresc_bkgnd(uep, zinitfail);

    end; {init_913X_ABC}
$page$

begin {Hminitialize}
  try
    allocate_bkgnd_info(uep);

    try
      status(uep, status_bytes);
    recover
      begin
	confirm_preeoi;
	if dsj(uep)=2 then ioresc_bkgnd(uep, zmediumchanged)
	else ioresc_bkgnd(uep, zbadhardware);
      end; {recover}

    with status_bytes do
      begin
	if f then ioresc_bkgnd(uep, zmediumchanged);
	if ss<>0 then ioresc_bkgnd(uep, znomedium);
	if w then ioresc_bkgnd(uep, zprotected);
      end; {with}

    get_map(uep, map);
    with map do
      tracks_per_medium := trk_per_cyl*cyl_per_med;

    case device(uep) of
      HP9895, HP8290X:          init_9895_913X_Chinook;
      HP913X_A..HP913X_C:       init_913X_ABC;
      otherwise                 ioresc_bkgnd(uep, zcatchall);
    end; {case}

    deallocate_bkgnd_info(uep);

  recover
    begin
      abort_bkgnd_process(uep);
      ioresult := uep^.dvrtemp;
      uep^.dvrtemp := ord(inoerror);  {report the error only once}
      escape(-10);
    end; {recover}

end; {Hminitialize}

end {Hminit}


@


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


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 328
$page$

module IRamigo; {amigo initialization routines}

import
  sysglobals, bkgnd, discHPIB, CSamigo;

export
  procedure verify          (uep: uep_type; nsectors: unsigned16);
  procedure init_with_d_bits(uep: uep_type);
  procedure format          (uep: uep_type; intlve, d_byte: byte; override: boolean);

implement {IRamigo}

procedure verify(uep: uep_type; nsectors: unsigned16);
  var
    verify_cmd_buf:
      packed record
	ftcb: ftcb_type;
	sector_count: unsigned16;
      end;
  begin {verify}
    verify_cmd_buf.sector_count := nsectors;
    issue_cmd(uep, verify_cmd, verify_cmd_buf.ftcb);
  end; {verify}

procedure init_with_d_bits(uep: uep_type);
  var
    init_cmd_buf: ftcb_type;
    dummy_byte: packed record  b: byte;  end;
  const
    receive_data_sec = 0;
  begin {init_with_d_bits}
    issue_cmd(uep, init_d_cmd, init_cmd_buf);
    HPIBwait_for_ppol(uep);
    dummy_byte.b := 0;
    HPIBshort_msge_out(uep, receive_data_sec, addr(dummy_byte), sizeof(dummy_byte));
  end; {init_with_d_bits}

procedure format(uep: uep_type; intlve, d_byte: byte; override: boolean);
  var
    format_cmd_buf:
      packed record
	ftcb: ftcb_type;
	f: boolean;      { override old format bit }
	ttttttt: 0..127; { wanted format type      }
	int: byte;       { interleave factor       }
	db: byte;        { data byte               }
      end;
  begin {format}
    with format_cmd_buf do
      begin
	f := override;
	ttttttt := 2;   {HP format always}
	int := intlve;
	db := d_byte
      end; {with}
    issue_cmd(uep, format_cmd, format_cmd_buf.ftcb);
  end; {format}

end; {IRamigo}


module Hminit;

import
  sysglobals, bkgnd, discHPIB, CSamigo, IRamigo, midecs;

export
  function Hintdata: interleave_data;
  function Nintdata(uep: uep_type): interleave_data;
  function Hphydata(uep: uep_type): physical_data;
  procedure Hminitialize(uep: uep_type; intlve: shortint);

implement {Hminit}


function Hintdata: interleave_data;
  const
    intdata = interleave_data
      [ min: 1,         {minimum interleave factor}
	max: 29,        {maximum interleave factor}
	def: 2 ];       {default interleave factor}
  begin {Hintdata}
    Hintdata := intdata;
  end; {Hintdata}


function Nintdata(uep: uep_type): interleave_data;
  const
    intdata = interleave_data
      [ min: 1,         {minimum interleave factor}
	max: 15,        {maximum interleave factor}
	def: 3 ];       {default interleave factor}
  begin {Nintdata}
    Nintdata := intdata;
    if uep^.devid<>0 then  {this is actually a Sparrow...}
      Nintdata.def := 2;   {which performs best at this interleave}
  end; {Nintdata}


function Hphydata(uep: uep_type): physical_data;
  var
    map: map_type;
    phydata: physical_data;
  begin {Hphydata}
    get_map(uep, map);
    with map, phydata do
      begin
	nspm := trk_per_cyl;    {number of surfaces per medium}
	ntps := cyl_per_med;    {number of tracks/surface}
	nspt := sec_per_trk;    {number of sectors per track}
      end; {with}
    Hphydata := phydata;
  end; {Hphydata}
$page$

procedure Hminitialize(uep: uep_type; intlve: shortint);

  var
    status_bytes: status_type;
    map: map_type;
    tracks_per_medium: shortint;

  procedure confirm_preeoi;
    begin {confirm_preeoi}
      with bip_type(uep^.dvrtemp)^ do
	if (escapecode=-10) and (iores=zbadhardware)
	  then iores := inoerror
	  else escape(escapecode);
    end; {confirm_preeoi}

  procedure check_status;
    begin {check_status}
      status(uep, status_bytes);
      case status_bytes.s1 of
	{"acceptable" errors}
	  uncorrectable_data_error,
	  head_sector_compare_error,
	  access_not_ready_during_data_operation:
	      {acceptable; do not escape};
	{error requiring status 2 check}
	  drive_attention:
	      if not status_bytes.c then ioresc_bkgnd(uep, zinitfail);
	{other errors}
	  otherwise ioresc_bkgnd(uep, zinitfail)
      end; {case}
    end; {check_status}


  procedure init_9895_913X_Chinook;
    const
      testpasses = 4;               {number of test passes       }
      max_bt = 4;                   {maximum number of bad tracks}
    type
      test_pattern_type = packed array[1..testpasses] of byte;
    const
      test_pattern = test_pattern_type
	[ 198,    {$C6 or 1100011011000110}
	   99,    {$63 or 0110001101100011}
	  219,    {$DB or 1101101111011011}
	  136 ];  {$88 or 1000100010001000}
    var
      bt_count: shortint;
      test_pass: shortint;
      verify_starting_track: shortint;
      verify_pass_complete: boolean;
      bt_already_logged: boolean;
      bad_track: shortint;
      bt_index: shortint;
      bt_table: array[1..max_bt] of shortint;
$page$

    begin {init_9895_913X_Chinook}
      bt_count := 0;
      for test_pass := 1 to testpasses do
	begin
	  format(uep, 1, test_pattern[test_pass], true);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	  verify_starting_track := 0;
	  repeat
	    seek(uep, verify_starting_track*map.sec_per_trk);
	    HPIBwait_for_ppol(uep);
	    verify(uep, (tracks_per_medium+max_bt-verify_starting_track)*map.sec_per_trk);
	    HPIBwait_for_ppol(uep);
	    if dsj(uep)=0 then
	      verify_pass_complete := true
	    else
	      begin
		check_status;
		bad_track := logical_addr(uep) div map.sec_per_trk;
		bt_already_logged := false;  {initial assumption}
		for bt_index := 1 to bt_count do
		  if bt_table[bt_index]=bad_track then bt_already_logged := true;
		if not bt_already_logged then  {log it}
		  begin
		    if bt_count>=max_bt then ioresc_bkgnd(uep, zinitfail);
		    bt_count := bt_count+1;
		    bt_table[bt_count] := bad_track;
		  end;
		verify_starting_track := bad_track+1;
		verify_pass_complete := verify_starting_track>=tracks_per_medium+max_bt;
	      end {else}
	  until verify_pass_complete;
	end; {for}

      for bt_index := 1 to bt_count do {set all d-bits on the bad tracks}
	begin
	  seek(uep, bt_table[bt_index]*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  init_with_d_bits(uep);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	end;

      format(uep, intlve, 0, false);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
      seek(uep, 0);
      HPIBwait_for_ppol(uep);
      verify(uep, tracks_per_medium*map.sec_per_trk);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
    end; {init_9895_913X_Chinook}
$page$

  procedure init_913X_ABC;

    var
      verify_pass: shortint;
      csvp: shortint;  {consecutive successful verify passes}
      verify_starting_track: shortint;
      verify_pass_complete: boolean;

    const
      min_vp = 5;       {minimum # of verify passes}
      max_vp = 15;      {maxmimum # of verify passes}
      min_csvp = 2;     {minimum # of consecutive successful verify passes}

    begin {init_913X_ABC}

      format(uep, intlve, 0, true);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);

      verify_pass := 0;
      csvp := 0;

      repeat

	verify_pass := verify_pass+1;
	verify_starting_track := 0;

	repeat
	  seek(uep, verify_starting_track*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  verify(uep, (tracks_per_medium-verify_starting_track)*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)=0 then
	    verify_pass_complete := true
	  else
	    begin
	      check_status;
	      verify_starting_track := logical_addr(uep) div map.sec_per_trk+1;
	      init_with_d_bits(uep);
	      HPIBwait_for_ppol(uep);
	      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	      verify_pass_complete := verify_starting_track>=tracks_per_medium;
	    end {else}
	until verify_pass_complete;

	if verify_starting_track=0 {i.e., successful verify pass}
	  then csvp := csvp+1
	  else csvp := 0;

      until ((verify_pass>=min_vp) and (csvp>=min_csvp)) or (verify_pass>=max_vp);

      if csvp<min_csvp then ioresc_bkgnd(uep, zinitfail);

    end; {init_913X_ABC}
$page$

begin {Hminitialize}
  try
    allocate_bkgnd_info(uep);

    try
      status(uep, status_bytes);
    recover
      begin
	confirm_preeoi;
	if dsj(uep)=2 then ioresc_bkgnd(uep, zmediumchanged)
	else ioresc_bkgnd(uep, zbadhardware);
      end; {recover}

    with status_bytes do
      begin
	if f then ioresc_bkgnd(uep, zmediumchanged);
	if ss<>0 then ioresc_bkgnd(uep, znomedium);
	if w then ioresc_bkgnd(uep, zprotected);
      end; {with}

    get_map(uep, map);
    with map do
      tracks_per_medium := trk_per_cyl*cyl_per_med;

    case device(uep) of
      HP9895, HP8290X:          init_9895_913X_Chinook;
      HP913X_A..HP913X_C:       init_913X_ABC;
      otherwise                 ioresc_bkgnd(uep, zcatchall);
    end; {case}

    deallocate_bkgnd_info(uep);

  recover
    begin
      abort_bkgnd_process(uep);
      ioresult := uep^.dvrtemp;
      uep^.dvrtemp := ord(inoerror);  {report the error only once}
      escape(-10);
    end; {recover}

end; {Hminitialize}

end {Hminit}


@


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


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


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


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@a0 328
$page$

module IRamigo; {amigo initialization routines}

import
  sysglobals, bkgnd, discHPIB, CSamigo;

export
  procedure verify          (uep: uep_type; nsectors: unsigned16);
  procedure init_with_d_bits(uep: uep_type);
  procedure format          (uep: uep_type; intlve, d_byte: byte; override: boolean);

implement {IRamigo}

procedure verify(uep: uep_type; nsectors: unsigned16);
  var
    verify_cmd_buf:
      packed record
	ftcb: ftcb_type;
	sector_count: unsigned16;
      end;
  begin {verify}
    verify_cmd_buf.sector_count := nsectors;
    issue_cmd(uep, verify_cmd, verify_cmd_buf.ftcb);
  end; {verify}

procedure init_with_d_bits(uep: uep_type);
  var
    init_cmd_buf: ftcb_type;
    dummy_byte: packed record  b: byte;  end;
  const
    receive_data_sec = 0;
  begin {init_with_d_bits}
    issue_cmd(uep, init_d_cmd, init_cmd_buf);
    HPIBwait_for_ppol(uep);
    dummy_byte.b := 0;
    HPIBshort_msge_out(uep, receive_data_sec, addr(dummy_byte), sizeof(dummy_byte));
  end; {init_with_d_bits}

procedure format(uep: uep_type; intlve, d_byte: byte; override: boolean);
  var
    format_cmd_buf:
      packed record
	ftcb: ftcb_type;
	f: boolean;      { override old format bit }
	ttttttt: 0..127; { wanted format type      }
	int: byte;       { interleave factor       }
	db: byte;        { data byte               }
      end;
  begin {format}
    with format_cmd_buf do
      begin
	f := override;
	ttttttt := 2;   {HP format always}
	int := intlve;
	db := d_byte
      end; {with}
    issue_cmd(uep, format_cmd, format_cmd_buf.ftcb);
  end; {format}

end; {IRamigo}


module Hminit;

import
  sysglobals, bkgnd, discHPIB, CSamigo, IRamigo, midecs;

export
  function Hintdata: interleave_data;
  function Nintdata(uep: uep_type): interleave_data;
  function Hphydata(uep: uep_type): physical_data;
  procedure Hminitialize(uep: uep_type; intlve: shortint);

implement {Hminit}


function Hintdata: interleave_data;
  const
    intdata = interleave_data
      [ min: 1,         {minimum interleave factor}
	max: 29,        {maximum interleave factor}
	def: 2 ];       {default interleave factor}
  begin {Hintdata}
    Hintdata := intdata;
  end; {Hintdata}


function Nintdata(uep: uep_type): interleave_data;
  const
    intdata = interleave_data
      [ min: 1,         {minimum interleave factor}
	max: 15,        {maximum interleave factor}
	def: 3 ];       {default interleave factor}
  begin {Nintdata}
    Nintdata := intdata;
    if uep^.devid<>0 then  {this is actually a Sparrow...}
      Nintdata.def := 2;   {which performs best at this interleave}
  end; {Nintdata}


function Hphydata(uep: uep_type): physical_data;
  var
    map: map_type;
    phydata: physical_data;
  begin {Hphydata}
    get_map(uep, map);
    with map, phydata do
      begin
	nspm := trk_per_cyl;    {number of surfaces per medium}
	ntps := cyl_per_med;    {number of tracks/surface}
	nspt := sec_per_trk;    {number of sectors per track}
      end; {with}
    Hphydata := phydata;
  end; {Hphydata}
$page$

procedure Hminitialize(uep: uep_type; intlve: shortint);

  var
    status_bytes: status_type;
    map: map_type;
    tracks_per_medium: shortint;

  procedure confirm_preeoi;
    begin {confirm_preeoi}
      with bip_type(uep^.dvrtemp)^ do
	if (escapecode=-10) and (iores=zbadhardware)
	  then iores := inoerror
	  else escape(escapecode);
    end; {confirm_preeoi}

  procedure check_status;
    begin {check_status}
      status(uep, status_bytes);
      case status_bytes.s1 of
	{"acceptable" errors}
	  uncorrectable_data_error,
	  head_sector_compare_error,
	  access_not_ready_during_data_operation:
	      {acceptable; do not escape};
	{error requiring status 2 check}
	  drive_attention:
	      if not status_bytes.c then ioresc_bkgnd(uep, zinitfail);
	{other errors}
	  otherwise ioresc_bkgnd(uep, zinitfail)
      end; {case}
    end; {check_status}


  procedure init_9895_913X_Chinook;
    const
      testpasses = 4;               {number of test passes       }
      max_bt = 4;                   {maximum number of bad tracks}
    type
      test_pattern_type = packed array[1..testpasses] of byte;
    const
      test_pattern = test_pattern_type
	[ 198,    {$C6 or 1100011011000110}
	   99,    {$63 or 0110001101100011}
	  219,    {$DB or 1101101111011011}
	  136 ];  {$88 or 1000100010001000}
    var
      bt_count: shortint;
      test_pass: shortint;
      verify_starting_track: shortint;
      verify_pass_complete: boolean;
      bt_already_logged: boolean;
      bad_track: shortint;
      bt_index: shortint;
      bt_table: array[1..max_bt] of shortint;
$page$

    begin {init_9895_913X_Chinook}
      bt_count := 0;
      for test_pass := 1 to testpasses do
	begin
	  format(uep, 1, test_pattern[test_pass], true);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	  verify_starting_track := 0;
	  repeat
	    seek(uep, verify_starting_track*map.sec_per_trk);
	    HPIBwait_for_ppol(uep);
	    verify(uep, (tracks_per_medium+max_bt-verify_starting_track)*map.sec_per_trk);
	    HPIBwait_for_ppol(uep);
	    if dsj(uep)=0 then
	      verify_pass_complete := true
	    else
	      begin
		check_status;
		bad_track := logical_addr(uep) div map.sec_per_trk;
		bt_already_logged := false;  {initial assumption}
		for bt_index := 1 to bt_count do
		  if bt_table[bt_index]=bad_track then bt_already_logged := true;
		if not bt_already_logged then  {log it}
		  begin
		    if bt_count>=max_bt then ioresc_bkgnd(uep, zinitfail);
		    bt_count := bt_count+1;
		    bt_table[bt_count] := bad_track;
		  end;
		verify_starting_track := bad_track+1;
		verify_pass_complete := verify_starting_track>=tracks_per_medium+max_bt;
	      end {else}
	  until verify_pass_complete;
	end; {for}

      for bt_index := 1 to bt_count do {set all d-bits on the bad tracks}
	begin
	  seek(uep, bt_table[bt_index]*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  init_with_d_bits(uep);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	end;

      format(uep, intlve, 0, false);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
      seek(uep, 0);
      HPIBwait_for_ppol(uep);
      verify(uep, tracks_per_medium*map.sec_per_trk);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
    end; {init_9895_913X_Chinook}
$page$

  procedure init_913X_ABC;

    var
      verify_pass: shortint;
      csvp: shortint;  {consecutive successful verify passes}
      verify_starting_track: shortint;
      verify_pass_complete: boolean;

    const
      min_vp = 5;       {minimum # of verify passes}
      max_vp = 15;      {maxmimum # of verify passes}
      min_csvp = 2;     {minimum # of consecutive successful verify passes}

    begin {init_913X_ABC}

      format(uep, intlve, 0, true);
      HPIBwait_for_ppol(uep);
      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);

      verify_pass := 0;
      csvp := 0;

      repeat

	verify_pass := verify_pass+1;
	verify_starting_track := 0;

	repeat
	  seek(uep, verify_starting_track*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  verify(uep, (tracks_per_medium-verify_starting_track)*map.sec_per_trk);
	  HPIBwait_for_ppol(uep);
	  if dsj(uep)=0 then
	    verify_pass_complete := true
	  else
	    begin
	      check_status;
	      verify_starting_track := logical_addr(uep) div map.sec_per_trk+1;
	      init_with_d_bits(uep);
	      HPIBwait_for_ppol(uep);
	      if dsj(uep)<>0 then ioresc_bkgnd(uep, zinitfail);
	      verify_pass_complete := verify_starting_track>=tracks_per_medium;
	    end {else}
	until verify_pass_complete;

	if verify_starting_track=0 {i.e., successful verify pass}
	  then csvp := csvp+1
	  else csvp := 0;

      until ((verify_pass>=min_vp) and (csvp>=min_csvp)) or (verify_pass>=max_vp);

      if csvp<min_csvp then ioresc_bkgnd(uep, zinitfail);

    end; {init_913X_ABC}
$page$

begin {Hminitialize}
  try
    allocate_bkgnd_info(uep);

    try
      status(uep, status_bytes);
    recover
      begin
	confirm_preeoi;
	if dsj(uep)=2 then ioresc_bkgnd(uep, zmediumchanged)
	else ioresc_bkgnd(uep, zbadhardware);
      end; {recover}

    with status_bytes do
      begin
	if f then ioresc_bkgnd(uep, zmediumchanged);
	if ss<>0 then ioresc_bkgnd(uep, znomedium);
	if w then ioresc_bkgnd(uep, zprotected);
      end; {with}

    get_map(uep, map);
    with map do
      tracks_per_medium := trk_per_cyl*cyl_per_med;

    case device(uep) of
      HP9895, HP8290X:          init_9895_913X_Chinook;
      HP913X_A..HP913X_C:       init_913X_ABC;
      otherwise                 ioresc_bkgnd(uep, zcatchall);
    end; {case}

    deallocate_bkgnd_info(uep);

  recover
    begin
      abort_bkgnd_process(uep);
      ioresult := uep^.dvrtemp;
      uep^.dvrtemp := ord(inoerror);  {report the error only once}
      escape(-10);
    end; {recover}

end; {Hminitialize}

end {Hminit}


@


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


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
@Auto bump revision for PAWS 3.2h
@
text
@@


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


1.1
log
@Initial revision
@
text
@@
