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


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

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

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

55.1
date     91.08.25.10.22.25;  author jwh;  state Exp;
branches ;
next     54.1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

23.1
date     87.08.26.10.26.20;  author bayes;  state Exp;
branches ;
next     22.2;

22.2
date     87.08.25.19.29.25;  author jws;  state Exp;
branches ;
next     22.1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.1
date     86.06.30.15.01.48;  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
@					      (*

 (c) Copyright Hewlett-Packard Company, 1985.
All rights are reserved.  Copying or other
reproduction of this program except for archival
purposes is prohibited without the prior
written consent of Hewlett-Packard Company.


	    RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government
is subject to restrictions as set forth in
paragraph (b) (3) (B) of the Rights in Technical
Data and Computer Software clause in
DAR 7-104.9(a).

HEWLETT-PACKARD COMPANY
Fort Collins, Colorado                         *)


$MODCAL ON$
$PARTIAL_EVAL ON$
$STACKCHECK ON$
$RANGE OFF$
$DEBUG OFF$
$OVFLCHECK OFF$
$PAGE$
$SEARCH 'IOLIB:KERNEL'$

(************************************************************************)
(*                                                                      *)
(*      RELEASED        VERSION         3.1                             *)
(*                                                                      *)
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      IOLIB           DC_DRIVERS                                      *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      library      -  IOLIB                                           *)
(*      name         -  DC_DRIVERS                                      *)
(*      module(s)    -  init_dc                                         *)
(*                   -  extd                                            *)
(*                                                                      *)
(*      author       -  Tim Mikkelsen                                   *)
(*      phone        -  303-226-3800   ext. 2910                        *)
(*                                                                      *)
(*      date         -  Oct  20 , 1981                                  *)
(*      update       -  Aug  11 , 1983 by J Schmidt                     *)
(*      release      -  Jul  12 , 1985                                  *)
(*                                                                      *)
(*      source       -  IOLIB:DC_DRV.TEXT                               *)
(*      object       -  IOLIB:DC_DRV.CODE                               *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      BUG FIX HISTORY         - after release 1.0                     *)
(*                                                                      *)
(*                                                                      *)
(*      BUG #   BY  / ON        LOC             DESCRIPTION             *)
(*      -----   -----------     --------------  ----------------------  *)
(*                                                                      *)
(*      1283    T Mikkelsen     idc_wtc         IOCONTROL(s,0,1) gives  *)
(*              01/08/82                        error, but should work. *)
(*                                              IOCONTROL(s,513,x)      *)
(*                                              would give an error.    *)
(*                                                                      *)
(*      zzzz    T Mikkelsen     idc_init        An error during init    *)
(*              06/16/82        init_dc         can blow away the work  *)
(*                                              station.                *)
(*                                                                      *)
(*      bbbb    T Mikkelsen     init_dc         No bug sheet.           *)
(*              07/12/82                        Setting up a machine    *)
(*                                              number ID if card is a  *)
(*                                              Ganglia.                *)
(*                                                                      *)
(*      cccc    T Mikkelsen     init_dc         No bug sheet.           *)
(*              08/16/82        intdc           Hunting for 98629 and   *)
(*                                              98628_dsndl.            *)
(*                                              See IODECLARATIONS also.*)
(*                                                                      *)
(*      367     T Mikkelsen     dc_initialize   Allow eXecute of driver *)
(*              09/22/82                        and have it install     *)
(*                                              itself in the system.   *)
(*                                                                      *)
(*      uuuu    T Mikkelsen     init_dc         Differentiate between   *)
(*              09/28/82                        628 and 629 card for    *)
(*                                              the card type.          *)
(*                                              See IODECLARATIONS also.*)
(*                                                                      *)
(*              J Schmidt       init_dc         Remove machine # setup  *)
(************************************************************************)
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      This is the source code for an external procedures library      *)
(*      to be used for general purpose interfacing on the HP 9826.      *)
(*                                                                      *)
(*      The library consists of 3 primary sets of modules -             *)
(*                                                                      *)
(*              1.      KERNEL modules                                  *)
(*              2.      driver modules                                  *)
(*              3.      IOLIB  modules                                  *)
(*                                                                      *)
(*      The KERNEL modules consist of the following modules -           *)
(*                                                                      *)
(*              1.      iodeclarations  ( contains static r/w space )   *)
(*              2.      iocomasm                                        *)
(*              3.      general_0       ( initialization & low level    *)
(*                                        routines like ioread/iowrite) *)
(*      The KERNEL modules also have an executable program segement     *)
(*      that gets executed at the time it is loaded.  This program      *)
(*      initializes the static read/write memory.  This program also    *)
(*      allocates the temporary storage for any card that exists -      *)
(*      independent of whether there is or is not a driver for it.      *)
(*                                                                      *)
(*      The driver modules consist of the actual assembly or PASCAL     *)
(*      routines that deal with a specific interface card.  There is    *)
(*      also an executable program segment for each driver module.      *)
(*      This program searches the select code table in the static r/w   *)
(*      initialized by the KERNEL general_0 module for all select codes *)
(*      that have the right interface card ( HPIB drivers will search   *)
(*      for the 98624 interface ).  This program will then set up the   *)
(*      driver tables to point to the correct drivers.                  *)
(*                                                                      *)
(*      The rest of the IOLIB modules are high-level modules that are   *)
(*      used by an end user in his/her application program.             *)
(*                                                                      *)
(*      The KERNEL and some set of driver modules will exist in the     *)
(*      SYSTEM.INITLIB file as object code ( not EXPORT text ).  The    *)
(*      export text will reside on the SYSTEM.LIBRARY file.  The rest   *)
(*      of the library will reside on the SYSTEM.LIBRARY.               *)
(*                                                                      *)
(************************************************************************)
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      REFERENCES :                                                    *)
(*                                                                      *)
(*                                                                      *)
(*      1.  9826 I/O Designers Guide            ( Loyd Nelson )         *)
(*                                                                      *)
(*      2.  68000 Manual                        ( Motorola )            *)
(*                                                                      *)
(*      3.  Pascal alpha site ERS               ( Roger Ison )          *)
(*                                                                      *)
(*      4.  Pascal I/O Library ERS              ( Tim Mikkelsen )       *)
(*                                                                      *)
(*      5.  9826 HPL EIO & IOD listings         ( Bob Hallissy )        *)
(*                                                                      *)
(*      6.  9826 HPL Misc. I/O Doc.             ( Bob Hallissy )        *)
(*                                                                      *)
(*      7.  9826 card documentation             ( Mfg. Specs. )         *)
(*                                                                      *)
(*      8.  Pascal I/O Library IRS              ( Tim Mikkelsen )       *)
(*                                                                      *)
(*      9.  98628 Data comm documentation       ( Carl Dierschow )      *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
$PAGE$
PROGRAM dc_initialize ( INPUT , OUTPUT );
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      DATA COMM DRIVERS                                               *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
EXTERNAL MODULE extdc;
	{ by      Tim Mikkelsen
	  date    10/20/81
	  update  11/03/81

	  purpose This module is a declaration of the importation text for
		  the external drivers.

	  note    The assembly language code that is imported needs to be
		  called 'extdc'.  The routines need to be called
		  'extdc_@@@@@@@@@@@@'
	}

IMPORT  sysglobals, iodeclarations;

EXPORT

  PROCEDURE alvinit        ( temp : ANYPTR );
  PROCEDURE alvinisr       ( temp : PISRIB );
  PROCEDURE enter_data     ( temp : ANYPTR ;  x     : ANYPTR ;
					      VAR c: INTEGER );
  PROCEDURE output_data    ( temp : ANYPTR ;  x     : ANYPTR ;
					      cnt   : INTEGER );
  PROCEDURE output_end     ( temp : ANYPTR );
  PROCEDURE direct_status  ( temp : ANYPTR ;  reg   : io_word;
					      VAR x : io_word);
  PROCEDURE direct_control ( temp : ANYPTR ;  reg   : io_word;
					      val   : io_word );
  PROCEDURE control_bfd    ( temp : ANYPTR ;  reg   : io_word;
					      val   : io_word );
  PROCEDURE start_tfr_in   ( temp : ANYPTR );
  PROCEDURE start_tfr_out  ( temp : ANYPTR );

END; { of extdc }
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      DATA COMM DRIVERS                                               *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
MODULE intdc;
	{ by      Tim Mikkelsen
	  date    10/20/81
	  update  08/16/82

	  purpose This module contains the internal drivers.

	}

IMPORT  sysglobals ,
	iodeclarations ;

EXPORT

  TYPE  dc_err_type     = PACKED ARRAY                          { zzzz TM 6/16/82 }
			  [minrealisc..maxrealisc] OF io_word ; { zzzz TM 6/16/82 }
	dc_err_ptr      = ^dc_err_type ;                        { zzzz TM 6/16/82 }

  VAR   dc_init_fault   : BOOLEAN ;                             { zzzz TM 6/16/82 }
	dc_error        : dc_err_ptr ;                          { zzzz TM 6/16/82 }

  PROCEDURE idc_init  ( temp : ANYPTR );
  PROCEDURE idc_isr   ( temp : PISRIB );
  PROCEDURE idc_rdb   ( temp : ANYPTR ;  VAR x : CHAR);
  PROCEDURE idc_wtb   ( temp : ANYPTR ;  val   : CHAR);
  PROCEDURE idc_rdw   ( temp : ANYPTR ;  VAR x : io_word);
  PROCEDURE idc_wtw   ( temp : ANYPTR ;  val   : io_word);
  PROCEDURE idc_rds   ( temp : ANYPTR ;  reg   : io_word;
					 VAR x : io_word);
  PROCEDURE idc_wtc   ( temp : ANYPTR ;  reg   : io_word;
					 val   : io_word );
  PROCEDURE idc_tfr   ( temp : ANYPTR ;  bcb   : ANYPTR );

IMPLEMENT


  IMPORT  isr ,
	  general_0 ,
	  extdc ;

  PROCEDURE idc_init  ( temp : ANYPTR );
  VAR dummyword     : io_word;
      dummy_isc     : INTEGER;                                  { bbbb TM 7/12/82 }
  BEGIN
    control_bfd ( temp , 0 , 1 );

    dummy_isc := io_find_isc(temp);                             { bbbb TM 7/12/82 }

    { make sure card is still async }

    direct_status( temp , 3 , dummyword );
    WITH isc_table[ dummy_isc ] DO BEGIN
      card_id := hp_datacomm;                                   {      TM 7/8/82 }
      IF dummyword = 1 THEN card_id := hp98628_async;           {      TM 7/8/82 }
      IF dummyword = 2 THEN card_id := hp98628_dsndl;           { cccc TM 8/16/82 }
    END; { of WITH DO BEGIN }                                   {      TM 7/8/82 }

    IF dc_init_fault                                            { zzzz TM 6/16/82 }
      THEN BEGIN                                                { zzzz TM 6/16/82 }
	IF dc_error^[dummy_isc]<>0                              { zzzz TM 6/16/82 }
	  THEN BEGIN                                            { zzzz TM 6/16/82 }
	    io_escape(dc_error^[dummy_isc],                     { zzzz TM 6/16/82 }
		      dummy_isc);                               { zzzz TM 6/16/82 }
	  END; { of IF dc_error <> 0 }                          { zzzz TM 6/16/82 }
      END; { of IF dc_init_fault }                              { zzzz TM 6/16/82 }

    { set up Ganglia card ID }                                  { bbbb TM 7/12/82 }
    IF ioread_byte(dummy_isc,HEX('402F'))=3                     { bbbb TM 7/12/82 }
      THEN BEGIN                                                { bbbb TM 7/12/82 }
	{ card is ganglia }                                     { bbbb TM 7/12/82 }
	isc_table[ dummy_isc ].card_id := hp98629;              { cccc TM 8/16/82 }
       {  iowrite_byte(dummy_isc ,                              { bbbb TM 7/12/82 }
       {    HEX('4061')  , io_model_number DIV 256 );           { bbbb TM 7/12/82 }
       { iowrite_byte(dummy_isc ,                               { bbbb TM 7/12/82 }
       {    HEX('4061')  + 2 , io_model_number MOD 256 );       { bbbb TM 7/12/82 }
      END; { of IF }                                            { bbbb TM 7/12/82 }


  END; { of idc_init }



  PROCEDURE idc_isr   ( temp : PISRIB );
  BEGIN
    alvinisr( temp );
  END; { of idc_isr }



  PROCEDURE idc_rdb   ( temp : ANYPTR ;  VAR x : CHAR);
  VAR count : INTEGER;
  BEGIN
    { this can escape with an eod escape }
    count := 1;
    enter_data( temp , ADDR(x) , count );
  END; { of idc_rdb }



  PROCEDURE idc_wtb   ( temp : ANYPTR ;  val   : CHAR);
  BEGIN
    { this can escape with an eod escape }
    output_data( temp , ADDR(val) , 1 );
  END; { of idc_wtb }



  PROCEDURE idc_rdw   ( temp : ANYPTR ;  VAR x : io_word);
  VAR count : INTEGER;
  BEGIN
    { this can escape with an eod escape }
    count := 2;
    enter_data( temp , ADDR(x) , count );
  END; { of idc_rdw }



  PROCEDURE idc_wtw   ( temp : ANYPTR ;  val   : io_word);
  BEGIN
    { this can escape with an eod escape }
    output_data( temp , ADDR(val) , 2 );
  END; { of idc_wtw }



  PROCEDURE idc_rds   ( temp : ANYPTR ;  reg   : io_word;
					 VAR x : io_word);
  BEGIN
    direct_status ( temp , reg , x );
  END; { of idc_rds }



  PROCEDURE idc_wtc   ( temp : ANYPTR ;  reg   : io_word;
					 val   : io_word );
  VAR dummyword     : io_word;
  BEGIN
    { range of valid registers -

      000-127   buffered control
      257-383   direct   control
      512       abrt tfr in
      513       abrt tfr out

    }

    IF ( ( reg >= 257 ) AND ( reg <= 383 ) ) OR
	 ( reg =  512 ) OR  ( reg =  513 )            { bug 1283 - TM:1/8/82}

      THEN BEGIN

	direct_control ( temp , reg-256 , val );

      END
      ELSE BEGIN

	IF ( ( reg >= 000 ) AND ( reg <= 127 ) )      { bug 1283 - TM:1/8/82}
	  THEN BEGIN

	    control_bfd ( temp , reg , val );

	    IF ( reg = 0 )
	      THEN BEGIN

		{ make sure card is still async }

		direct_status( temp , 3 , dummyword );
		WITH isc_table[ io_find_isc(temp) ] DO
		IF dummyword = 1 THEN card_id := hp98628_async
				 ELSE card_id := hp_datacomm;
	      END; { of IF reg=0 }

	  END
	  ELSE BEGIN

	    io_escape(ioe_misc,io_find_isc(temp));

	  END; { of IF reg<=127 }

      END; { of IF >=257 }

  END; { of idc_wtc }



  PROCEDURE idc_tfr   ( temp : ANYPTR ;  bcb   : ANYPTR );
  VAR b_info : ^buf_info_type;
      io_isc : type_isc ;
      tmpptr : pio_tmp_ptr;
      tmpcnt : INTEGER ;
      mycount: INTEGER ;
      done   : BOOLEAN ;
  BEGIN
    b_info := ANYPTR( bcb );
    tmpptr := ANYPTR( temp );
    io_isc := tmpptr^.my_isc ;
    WITH b_info^ DO BEGIN

      IF ( usr_tfr  = serial_DMA )  OR
	 ( usr_tfr  = overlap_DMA ) OR
	 ( b_w_mode = TRUE )            { word }
	THEN BEGIN
	  { error }
	  IF direction = from_memory
	    THEN tmpptr^.out_bufptr := NIL
	    ELSE tmpptr^.in_bufptr  := NIL;
	  io_escape( ioe_bad_tfr , io_isc );
	END;

      { mark buffer busy }

      active_isc   := io_isc ;


      IF usr_tfr < overlap_INTR
	THEN BEGIN
	  { serial transfer - handled here }
	  IF direction = from_memory
	    THEN BEGIN

	      { serial output tfr }

	      output_data ( temp , buf_empty , term_count );

	      buf_empty := ANYPTR( INTEGER(buf_empty) + term_count);
	      term_count:= 0;

	      IF end_mode THEN output_end( temp );

	    END
	    ELSE BEGIN

	      { serial input tfr }

	      done := false;
	      mycount := term_count;   { tfr size }
	      REPEAT
		IF term_char = -1
		  THEN BEGIN
		    { serial input - no term }
		    TRY
		      enter_data( temp , buf_fill , mycount );
		      term_count := term_count - mycount;
		      buf_fill   := ANYPTR( INTEGER(buf_fill) + mycount);

		      done := TRUE;

		    RECOVER BEGIN
		      IF ( escapecode = ioescapecode ) AND
			 ( ioe_result = ioe_eod_seen ) AND
			 ( ioe_isc    = io_isc )
			THEN BEGIN
			  term_count := term_count - mycount;
			  buf_fill   := ANYPTR( INTEGER(buf_fill) + mycount);
			  mycount    := term_count;
			  IF end_mode
			    THEN BEGIN
			      done := TRUE;
			    END; { of IF end_mode }
			END
			ELSE BEGIN
			  escape(escapecode);
			END; { of IF }
		    END; { of TRY RECOVER BEGIN }
		  END
		  ELSE BEGIN
		    { serial input - termination }
		    TRY

		      REPEAT
			tmpcnt :=1 ;
			enter_data( temp , buf_fill , tmpcnt );
			buf_fill   := ANYPTR( INTEGER(buf_fill) + 1 );
			term_count := term_count -1;
		      UNTIL ( term_count = 0 ) OR
			    ( CHARPTR(INTEGER(buf_fill)-1)^=CHR(term_char)) ;

		      done := TRUE;

		    RECOVER BEGIN
		      IF ( escapecode = ioescapecode ) AND
			 ( ioe_result = ioe_eod_seen ) AND
			 ( ioe_isc    = io_isc )
			THEN BEGIN

			  { I use tmpcnt because the eod may or may not have
			    been caught with the character }

			  term_count := term_count - tmpcnt;
			  buf_fill   := ANYPTR( INTEGER(buf_fill) + tmpcnt );
			  IF end_mode
			    THEN BEGIN
			      done := TRUE;
			    END; { of IF end_mode }
			END
			ELSE BEGIN
			  escape(escapecode);
			END; { of IF }
		    END; { of TRY RECOVER BEGIN }
		  END; { of IF term_char }
	      UNTIL done;

	    END; { of IF direction }


	  { mark buffer not busy }

	  IF direction = from_memory
	    THEN tmpptr^.out_bufptr := NIL
	    ELSE tmpptr^.in_bufptr  := NIL;
	  active_isc  := no_isc;
	  drv_tmp_ptr := NIL;

	  IF eot_proc.dummy_pr <> NIL                   {JPC 02/22/82}
	    THEN BEGIN
	      { call user eot procedure }
	      CALL ( eot_proc.real_proc, eot_parm );    {JPC 02/22/82}
	    END; { of IF }


	END
	ELSE BEGIN

	  { overlap transfer - handled by drivers }

	  IF direction = to_memory
	    THEN BEGIN

	      start_tfr_in ( temp );

	    END
	    ELSE BEGIN

	      start_tfr_out ( temp );

	    END; { of IF direction }

	END; { of IF overlap }
    END; { of WITH b_info }
  END; { of idc_tfr }


END; { of intdc }
$PAGE$


MODULE init_dc;
	{ by      Tim Mikkelsen
	  date    10/20/81
	  update  08/11/83 by J Schmidt -- vers number only

	  purpose This module initializes the data comm drivers.

	}


IMPORT    iodeclarations ;

EXPORT


  VAR
    dc_drivers    : drv_table_type;

  PROCEDURE io_init_dc;



IMPLEMENT


  IMPORT  sysglobals ,
	  isr ,
	  general_0 ,
	  extdc ,
	  intdc ;

  PROCEDURE io_init_dc;
  VAR
    io_isc        : type_isc;
    dummyword     : io_word;
    io_lvl        : io_byte;

  BEGIN

    io_revid := io_revid + ' S3.2';     { SERIAL revision added 2/5/82 TM }

    { set up the driver tables }

    WITH dc_drivers DO BEGIN
      dc_drivers := dummy_drivers ;
      iod_init  := idc_init;
      iod_isr   := idc_isr;
      iod_rdb   := idc_rdb;
      iod_wtb   := idc_wtb;
      iod_rdw   := idc_rdw;
      iod_wtw   := idc_wtw;
      iod_rds   := idc_rds;
      iod_wtc   := idc_wtc;
      iod_tfr   := idc_tfr;
    END; { of WITH }


    { set up drivers for the interfaces }

    FOR io_isc:=iominisc TO iomaxisc DO
      WITH isc_table[io_isc] DO BEGIN

	IF ( card_id = hp98628_async ) OR
	   ( card_id = hp98628_dsndl ) OR
	   ( card_id = hp98629 )
	  THEN BEGIN
	    card_id   := hp_datacomm;
	    card_type := serial_card;                           { uuuu TM 9/28/82 }
	  END;

	IF card_id = hp_datacomm
	  THEN BEGIN

	    io_drv_ptr:=ADDR(dc_drivers);

	    { if the card exists then link in an ISR for it }
	    { ??? - what happens if an ISR fires during init }

	    io_lvl:=((ioread_byte(io_isc,3) DIV 16) MOD 4)+3;
	    IF io_tmp_ptr^.myisrib.INTREGADDR <> NIL
	      THEN BEGIN
		{ if isr exists then unlink it }
		ISRUNLINK(io_lvl ,                      { level         }
		    ADDR(io_tmp_ptr^.myisrib));         { isrib info    }
	      END; { of IF }

	    PERMISRLINK(io_drv_ptr^.iod_isr,            { isr           }
		    ANYPTR(INTEGER(card_ptr)+3),        { card address  }
		    192,                                { intr. mask    }
		    192,                                { intr. value   }
		    io_lvl,                             { level         }
		    ADDR(io_tmp_ptr^.myisrib));         { isrib info    }
	  END; { of IF card_type = hp_datacomm }

    END; { of FOR io_isc WITH isc_table[io_isc] BEGIN }


    { call the actual driver initialization }

    dc_init_fault := FALSE;           { set fault flag            zzzz TM 6/16/82 }
    FOR io_isc:=iominisc TO iomaxisc DO
      WITH isc_table[io_isc] DO
      IF card_id = hp_datacomm
	THEN BEGIN

	  TRY                                                   { zzzz TM 6/16/82 }

	    alvinit( io_tmp_ptr );

	    direct_status( io_tmp_ptr , 3 , dummyword );
	    IF dummyword = 1 THEN card_id := hp98628_async;
	    IF dummyword = 2 THEN card_id := hp98628_dsndl;     { cccc TM 8/16/82 }

	    { set up Ganglia card ID }                          { bbbb TM 7/16/82 }
	    IF ioread_byte(io_isc,HEX('402F'))=3                { bbbb TM 7/16/82 }
	      THEN BEGIN                                        { bbbb TM 7/16/82 }
		{ card is ganglia }                             { bbbb TM 7/16/82 }
		card_id   := hp98629;                           { cccc TM 8/16/82 }
		card_type := srm_card;                          { uuuu TM 9/28/82 }
	       {iowrite_byte(io_isc ,                           { bbbb TM 7/16/82 }
		 {HEX('4061')  , io_model_number DIV 256 );     { bbbb TM 7/16/82 }
	       {iowrite_byte(io_isc ,                           { bbbb TM 7/16/82 }
		 {HEX('4061')  + 2 , io_model_number MOD 256 ); { bbbb TM 7/16/82 }
	      END; { of IF }                                    { bbbb TM 7/16/82 }

	  RECOVER BEGIN                                         { zzzz TM 6/16/82 }

	    IF ESCAPECODE<>ioescapecode THEN ESCAPE(ESCAPECODE);{ zzzz TM 6/16/82 }
	    IF ioe_isc <> io_isc        THEN ESCAPE(ESCAPECODE);{ zzzz TM 6/16/82 }

	    IF NOT dc_init_fault                                { zzzz TM 6/16/82 }
	      THEN BEGIN                                        { zzzz TM 6/16/82 }
		dc_init_fault := TRUE ;                         { zzzz TM 6/16/82 }
		NEW(dc_error);                  { get space   } { zzzz TM 6/16/82 }
		FOR dummyword:=minrealisc TO maxrealisc DO      { zzzz TM 6/16/82 }
		  dc_error^[dummyword]:=0;      { clear space } { zzzz TM 6/16/82 }
	      END; { of IF NOT dc_init_fault }                  { zzzz TM 6/16/82 }

	    dc_error^[io_isc] := ioe_result;    { set this err} { zzzz TM 6/16/82 }

	  END; { of RECOVER BEGIN }                             { zzzz TM 6/16/82 }

	END; { of WITH IF }

  END; { of io_init_dc }

END; { of MODULE init_dc }
$PAGE$

IMPORT    init_dc ,
	  LOADER ;                                              { 367  TM 9/22/82 }


BEGIN
  io_init_dc;
  MARKUSER;                                                     { 367  TM 9/22/82 }
END. { of dc_initialize }
@


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


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 725
					      (*

 (c) Copyright Hewlett-Packard Company, 1985.
All rights are reserved.  Copying or other
reproduction of this program except for archival
purposes is prohibited without the prior
written consent of Hewlett-Packard Company.


	    RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government
is subject to restrictions as set forth in
paragraph (b) (3) (B) of the Rights in Technical
Data and Computer Software clause in
DAR 7-104.9(a).

HEWLETT-PACKARD COMPANY
Fort Collins, Colorado                         *)


$MODCAL ON$
$PARTIAL_EVAL ON$
$STACKCHECK ON$
$RANGE OFF$
$DEBUG OFF$
$OVFLCHECK OFF$
$PAGE$
$SEARCH 'IOLIB:KERNEL'$

(************************************************************************)
(*                                                                      *)
(*      RELEASED        VERSION         3.1                             *)
(*                                                                      *)
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      IOLIB           DC_DRIVERS                                      *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      library      -  IOLIB                                           *)
(*      name         -  DC_DRIVERS                                      *)
(*      module(s)    -  init_dc                                         *)
(*                   -  extd                                            *)
(*                                                                      *)
(*      author       -  Tim Mikkelsen                                   *)
(*      phone        -  303-226-3800   ext. 2910                        *)
(*                                                                      *)
(*      date         -  Oct  20 , 1981                                  *)
(*      update       -  Aug  11 , 1983 by J Schmidt                     *)
(*      release      -  Jul  12 , 1985                                  *)
(*                                                                      *)
(*      source       -  IOLIB:DC_DRV.TEXT                               *)
(*      object       -  IOLIB:DC_DRV.CODE                               *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      BUG FIX HISTORY         - after release 1.0                     *)
(*                                                                      *)
(*                                                                      *)
(*      BUG #   BY  / ON        LOC             DESCRIPTION             *)
(*      -----   -----------     --------------  ----------------------  *)
(*                                                                      *)
(*      1283    T Mikkelsen     idc_wtc         IOCONTROL(s,0,1) gives  *)
(*              01/08/82                        error, but should work. *)
(*                                              IOCONTROL(s,513,x)      *)
(*                                              would give an error.    *)
(*                                                                      *)
(*      zzzz    T Mikkelsen     idc_init        An error during init    *)
(*              06/16/82        init_dc         can blow away the work  *)
(*                                              station.                *)
(*                                                                      *)
(*      bbbb    T Mikkelsen     init_dc         No bug sheet.           *)
(*              07/12/82                        Setting up a machine    *)
(*                                              number ID if card is a  *)
(*                                              Ganglia.                *)
(*                                                                      *)
(*      cccc    T Mikkelsen     init_dc         No bug sheet.           *)
(*              08/16/82        intdc           Hunting for 98629 and   *)
(*                                              98628_dsndl.            *)
(*                                              See IODECLARATIONS also.*)
(*                                                                      *)
(*      367     T Mikkelsen     dc_initialize   Allow eXecute of driver *)
(*              09/22/82                        and have it install     *)
(*                                              itself in the system.   *)
(*                                                                      *)
(*      uuuu    T Mikkelsen     init_dc         Differentiate between   *)
(*              09/28/82                        628 and 629 card for    *)
(*                                              the card type.          *)
(*                                              See IODECLARATIONS also.*)
(*                                                                      *)
(*              J Schmidt       init_dc         Remove machine # setup  *)
(************************************************************************)
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      This is the source code for an external procedures library      *)
(*      to be used for general purpose interfacing on the HP 9826.      *)
(*                                                                      *)
(*      The library consists of 3 primary sets of modules -             *)
(*                                                                      *)
(*              1.      KERNEL modules                                  *)
(*              2.      driver modules                                  *)
(*              3.      IOLIB  modules                                  *)
(*                                                                      *)
(*      The KERNEL modules consist of the following modules -           *)
(*                                                                      *)
(*              1.      iodeclarations  ( contains static r/w space )   *)
(*              2.      iocomasm                                        *)
(*              3.      general_0       ( initialization & low level    *)
(*                                        routines like ioread/iowrite) *)
(*      The KERNEL modules also have an executable program segement     *)
(*      that gets executed at the time it is loaded.  This program      *)
(*      initializes the static read/write memory.  This program also    *)
(*      allocates the temporary storage for any card that exists -      *)
(*      independent of whether there is or is not a driver for it.      *)
(*                                                                      *)
(*      The driver modules consist of the actual assembly or PASCAL     *)
(*      routines that deal with a specific interface card.  There is    *)
(*      also an executable program segment for each driver module.      *)
(*      This program searches the select code table in the static r/w   *)
(*      initialized by the KERNEL general_0 module for all select codes *)
(*      that have the right interface card ( HPIB drivers will search   *)
(*      for the 98624 interface ).  This program will then set up the   *)
(*      driver tables to point to the correct drivers.                  *)
(*                                                                      *)
(*      The rest of the IOLIB modules are high-level modules that are   *)
(*      used by an end user in his/her application program.             *)
(*                                                                      *)
(*      The KERNEL and some set of driver modules will exist in the     *)
(*      SYSTEM.INITLIB file as object code ( not EXPORT text ).  The    *)
(*      export text will reside on the SYSTEM.LIBRARY file.  The rest   *)
(*      of the library will reside on the SYSTEM.LIBRARY.               *)
(*                                                                      *)
(************************************************************************)
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      REFERENCES :                                                    *)
(*                                                                      *)
(*                                                                      *)
(*      1.  9826 I/O Designers Guide            ( Loyd Nelson )         *)
(*                                                                      *)
(*      2.  68000 Manual                        ( Motorola )            *)
(*                                                                      *)
(*      3.  Pascal alpha site ERS               ( Roger Ison )          *)
(*                                                                      *)
(*      4.  Pascal I/O Library ERS              ( Tim Mikkelsen )       *)
(*                                                                      *)
(*      5.  9826 HPL EIO & IOD listings         ( Bob Hallissy )        *)
(*                                                                      *)
(*      6.  9826 HPL Misc. I/O Doc.             ( Bob Hallissy )        *)
(*                                                                      *)
(*      7.  9826 card documentation             ( Mfg. Specs. )         *)
(*                                                                      *)
(*      8.  Pascal I/O Library IRS              ( Tim Mikkelsen )       *)
(*                                                                      *)
(*      9.  98628 Data comm documentation       ( Carl Dierschow )      *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
$PAGE$
PROGRAM dc_initialize ( INPUT , OUTPUT );
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      DATA COMM DRIVERS                                               *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
EXTERNAL MODULE extdc;
	{ by      Tim Mikkelsen
	  date    10/20/81
	  update  11/03/81

	  purpose This module is a declaration of the importation text for
		  the external drivers.

	  note    The assembly language code that is imported needs to be
		  called 'extdc'.  The routines need to be called
		  'extdc_@@@@@@@@@@@@'
	}

IMPORT  sysglobals, iodeclarations;

EXPORT

  PROCEDURE alvinit        ( temp : ANYPTR );
  PROCEDURE alvinisr       ( temp : PISRIB );
  PROCEDURE enter_data     ( temp : ANYPTR ;  x     : ANYPTR ;
					      VAR c: INTEGER );
  PROCEDURE output_data    ( temp : ANYPTR ;  x     : ANYPTR ;
					      cnt   : INTEGER );
  PROCEDURE output_end     ( temp : ANYPTR );
  PROCEDURE direct_status  ( temp : ANYPTR ;  reg   : io_word;
					      VAR x : io_word);
  PROCEDURE direct_control ( temp : ANYPTR ;  reg   : io_word;
					      val   : io_word );
  PROCEDURE control_bfd    ( temp : ANYPTR ;  reg   : io_word;
					      val   : io_word );
  PROCEDURE start_tfr_in   ( temp : ANYPTR );
  PROCEDURE start_tfr_out  ( temp : ANYPTR );

END; { of extdc }
$PAGE$
(************************************************************************)
(*                                                                      *)
(*                                                                      *)
(*      DATA COMM DRIVERS                                               *)
(*                                                                      *)
(*                                                                      *)
(************************************************************************)
MODULE intdc;
	{ by      Tim Mikkelsen
	  date    10/20/81
	  update  08/16/82

	  purpose This module contains the internal drivers.

	}

IMPORT  sysglobals ,
	iodeclarations ;

EXPORT

  TYPE  dc_err_type     = PACKED ARRAY                          { zzzz TM 6/16/82 }
			  [minrealisc..maxrealisc] OF io_word ; { zzzz TM 6/16/82 }
	dc_err_ptr      = ^dc_err_type ;                        { zzzz TM 6/16/82 }

  VAR   dc_init_fault   : BOOLEAN ;                             { zzzz TM 6/16/82 }
	dc_error        : dc_err_ptr ;                          { zzzz TM 6/16/82 }

  PROCEDURE idc_init  ( temp : ANYPTR );
  PROCEDURE idc_isr   ( temp : PISRIB );
  PROCEDURE idc_rdb   ( temp : ANYPTR ;  VAR x : CHAR);
  PROCEDURE idc_wtb   ( temp : ANYPTR ;  val   : CHAR);
  PROCEDURE idc_rdw   ( temp : ANYPTR ;  VAR x : io_word);
  PROCEDURE idc_wtw   ( temp : ANYPTR ;  val   : io_word);
  PROCEDURE idc_rds   ( temp : ANYPTR ;  reg   : io_word;
					 VAR x : io_word);
  PROCEDURE idc_wtc   ( temp : ANYPTR ;  reg   : io_word;
					 val   : io_word );
  PROCEDURE idc_tfr   ( temp : ANYPTR ;  bcb   : ANYPTR );

IMPLEMENT


  IMPORT  isr ,
	  general_0 ,
	  extdc ;

  PROCEDURE idc_init  ( temp : ANYPTR );
  VAR dummyword     : io_word;
      dummy_isc     : INTEGER;                                  { bbbb TM 7/12/82 }
  BEGIN
    control_bfd ( temp , 0 , 1 );

    dummy_isc := io_find_isc(temp);                             { bbbb TM 7/12/82 }

    { make sure card is still async }

    direct_status( temp , 3 , dummyword );
    WITH isc_table[ dummy_isc ] DO BEGIN
      card_id := hp_datacomm;                                   {      TM 7/8/82 }
      IF dummyword = 1 THEN card_id := hp98628_async;           {      TM 7/8/82 }
      IF dummyword = 2 THEN card_id := hp98628_dsndl;           { cccc TM 8/16/82 }
    END; { of WITH DO BEGIN }                                   {      TM 7/8/82 }

    IF dc_init_fault                                            { zzzz TM 6/16/82 }
      THEN BEGIN                                                { zzzz TM 6/16/82 }
	IF dc_error^[dummy_isc]<>0                              { zzzz TM 6/16/82 }
	  THEN BEGIN                                            { zzzz TM 6/16/82 }
	    io_escape(dc_error^[dummy_isc],                     { zzzz TM 6/16/82 }
		      dummy_isc);                               { zzzz TM 6/16/82 }
	  END; { of IF dc_error <> 0 }                          { zzzz TM 6/16/82 }
      END; { of IF dc_init_fault }                              { zzzz TM 6/16/82 }

    { set up Ganglia card ID }                                  { bbbb TM 7/12/82 }
    IF ioread_byte(dummy_isc,HEX('402F'))=3                     { bbbb TM 7/12/82 }
      THEN BEGIN                                                { bbbb TM 7/12/82 }
	{ card is ganglia }                                     { bbbb TM 7/12/82 }
	isc_table[ dummy_isc ].card_id := hp98629;              { cccc TM 8/16/82 }
       {  iowrite_byte(dummy_isc ,                              { bbbb TM 7/12/82 }
       {    HEX('4061')  , io_model_number DIV 256 );           { bbbb TM 7/12/82 }
       { iowrite_byte(dummy_isc ,                               { bbbb TM 7/12/82 }
       {    HEX('4061')  + 2 , io_model_number MOD 256 );       { bbbb TM 7/12/82 }
      END; { of IF }                                            { bbbb TM 7/12/82 }


  END; { of idc_init }



  PROCEDURE idc_isr   ( temp : PISRIB );
  BEGIN
    alvinisr( temp );
  END; { of idc_isr }



  PROCEDURE idc_rdb   ( temp : ANYPTR ;  VAR x : CHAR);
  VAR count : INTEGER;
  BEGIN
    { this can escape with an eod escape }
    count := 1;
    enter_data( temp , ADDR(x) , count );
  END; { of idc_rdb }



  PROCEDURE idc_wtb   ( temp : ANYPTR ;  val   : CHAR);
  BEGIN
    { this can escape with an eod escape }
    output_data( temp , ADDR(val) , 1 );
  END; { of idc_wtb }



  PROCEDURE idc_rdw   ( temp : ANYPTR ;  VAR x : io_word);
  VAR count : INTEGER;
  BEGIN
    { this can escape with an eod escape }
    count := 2;
    enter_data( temp , ADDR(x) , count );
  END; { of idc_rdw }



  PROCEDURE idc_wtw   ( temp : ANYPTR ;  val   : io_word);
  BEGIN
    { this can escape with an eod escape }
    output_data( temp , ADDR(val) , 2 );
  END; { of idc_wtw }



  PROCEDURE idc_rds   ( temp : ANYPTR ;  reg   : io_word;
					 VAR x : io_word);
  BEGIN
    direct_status ( temp , reg , x );
  END; { of idc_rds }



  PROCEDURE idc_wtc   ( temp : ANYPTR ;  reg   : io_word;
					 val   : io_word );
  VAR dummyword     : io_word;
  BEGIN
    { range of valid registers -

      000-127   buffered control
      257-383   direct   control
      512       abrt tfr in
      513       abrt tfr out

    }

    IF ( ( reg >= 257 ) AND ( reg <= 383 ) ) OR
	 ( reg =  512 ) OR  ( reg =  513 )            { bug 1283 - TM:1/8/82}

      THEN BEGIN

	direct_control ( temp , reg-256 , val );

      END
      ELSE BEGIN

	IF ( ( reg >= 000 ) AND ( reg <= 127 ) )      { bug 1283 - TM:1/8/82}
	  THEN BEGIN

	    control_bfd ( temp , reg , val );

	    IF ( reg = 0 )
	      THEN BEGIN

		{ make sure card is still async }

		direct_status( temp , 3 , dummyword );
		WITH isc_table[ io_find_isc(temp) ] DO
		IF dummyword = 1 THEN card_id := hp98628_async
				 ELSE card_id := hp_datacomm;
	      END; { of IF reg=0 }

	  END
	  ELSE BEGIN

	    io_escape(ioe_misc,io_find_isc(temp));

	  END; { of IF reg<=127 }

      END; { of IF >=257 }

  END; { of idc_wtc }



  PROCEDURE idc_tfr   ( temp : ANYPTR ;  bcb   : ANYPTR );
  VAR b_info : ^buf_info_type;
      io_isc : type_isc ;
      tmpptr : pio_tmp_ptr;
      tmpcnt : INTEGER ;
      mycount: INTEGER ;
      done   : BOOLEAN ;
  BEGIN
    b_info := ANYPTR( bcb );
    tmpptr := ANYPTR( temp );
    io_isc := tmpptr^.my_isc ;
    WITH b_info^ DO BEGIN

      IF ( usr_tfr  = serial_DMA )  OR
	 ( usr_tfr  = overlap_DMA ) OR
	 ( b_w_mode = TRUE )            { word }
	THEN BEGIN
	  { error }
	  IF direction = from_memory
	    THEN tmpptr^.out_bufptr := NIL
	    ELSE tmpptr^.in_bufptr  := NIL;
	  io_escape( ioe_bad_tfr , io_isc );
	END;

      { mark buffer busy }

      active_isc   := io_isc ;


      IF usr_tfr < overlap_INTR
	THEN BEGIN
	  { serial transfer - handled here }
	  IF direction = from_memory
	    THEN BEGIN

	      { serial output tfr }

	      output_data ( temp , buf_empty , term_count );

	      buf_empty := ANYPTR( INTEGER(buf_empty) + term_count);
	      term_count:= 0;

	      IF end_mode THEN output_end( temp );

	    END
	    ELSE BEGIN

	      { serial input tfr }

	      done := false;
	      mycount := term_count;   { tfr size }
	      REPEAT
		IF term_char = -1
		  THEN BEGIN
		    { serial input - no term }
		    TRY
		      enter_data( temp , buf_fill , mycount );
		      term_count := term_count - mycount;
		      buf_fill   := ANYPTR( INTEGER(buf_fill) + mycount);

		      done := TRUE;

		    RECOVER BEGIN
		      IF ( escapecode = ioescapecode ) AND
			 ( ioe_result = ioe_eod_seen ) AND
			 ( ioe_isc    = io_isc )
			THEN BEGIN
			  term_count := term_count - mycount;
			  buf_fill   := ANYPTR( INTEGER(buf_fill) + mycount);
			  mycount    := term_count;
			  IF end_mode
			    THEN BEGIN
			      done := TRUE;
			    END; { of IF end_mode }
			END
			ELSE BEGIN
			  escape(escapecode);
			END; { of IF }
		    END; { of TRY RECOVER BEGIN }
		  END
		  ELSE BEGIN
		    { serial input - termination }
		    TRY

		      REPEAT
			tmpcnt :=1 ;
			enter_data( temp , buf_fill , tmpcnt );
			buf_fill   := ANYPTR( INTEGER(buf_fill) + 1 );
			term_count := term_count -1;
		      UNTIL ( term_count = 0 ) OR
			    ( CHARPTR(INTEGER(buf_fill)-1)^=CHR(term_char)) ;

		      done := TRUE;

		    RECOVER BEGIN
		      IF ( escapecode = ioescapecode ) AND
			 ( ioe_result = ioe_eod_seen ) AND
			 ( ioe_isc    = io_isc )
			THEN BEGIN

			  { I use tmpcnt because the eod may or may not have
			    been caught with the character }

			  term_count := term_count - tmpcnt;
			  buf_fill   := ANYPTR( INTEGER(buf_fill) + tmpcnt );
			  IF end_mode
			    THEN BEGIN
			      done := TRUE;
			    END; { of IF end_mode }
			END
			ELSE BEGIN
			  escape(escapecode);
			END; { of IF }
		    END; { of TRY RECOVER BEGIN }
		  END; { of IF term_char }
	      UNTIL done;

	    END; { of IF direction }


	  { mark buffer not busy }

	  IF direction = from_memory
	    THEN tmpptr^.out_bufptr := NIL
	    ELSE tmpptr^.in_bufptr  := NIL;
	  active_isc  := no_isc;
	  drv_tmp_ptr := NIL;

	  IF eot_proc.dummy_pr <> NIL                   {JPC 02/22/82}
	    THEN BEGIN
	      { call user eot procedure }
	      CALL ( eot_proc.real_proc, eot_parm );    {JPC 02/22/82}
	    END; { of IF }


	END
	ELSE BEGIN

	  { overlap transfer - handled by drivers }

	  IF direction = to_memory
	    THEN BEGIN

	      start_tfr_in ( temp );

	    END
	    ELSE BEGIN

	      start_tfr_out ( temp );

	    END; { of IF direction }

	END; { of IF overlap }
    END; { of WITH b_info }
  END; { of idc_tfr }


END; { of intdc }
$PAGE$


MODULE init_dc;
	{ by      Tim Mikkelsen
	  date    10/20/81
	  update  08/11/83 by J Schmidt -- vers number only

	  purpose This module initializes the data comm drivers.

	}


IMPORT    iodeclarations ;

EXPORT


  VAR
    dc_drivers    : drv_table_type;

  PROCEDURE io_init_dc;



IMPLEMENT


  IMPORT  sysglobals ,
	  isr ,
	  general_0 ,
	  extdc ,
	  intdc ;

  PROCEDURE io_init_dc;
  VAR
    io_isc        : type_isc;
    dummyword     : io_word;
    io_lvl        : io_byte;

  BEGIN

    io_revid := io_revid + ' S3.2';     { SERIAL revision added 2/5/82 TM }

    { set up the driver tables }

    WITH dc_drivers DO BEGIN
      dc_drivers := dummy_drivers ;
      iod_init  := idc_init;
      iod_isr   := idc_isr;
      iod_rdb   := idc_rdb;
      iod_wtb   := idc_wtb;
      iod_rdw   := idc_rdw;
      iod_wtw   := idc_wtw;
      iod_rds   := idc_rds;
      iod_wtc   := idc_wtc;
      iod_tfr   := idc_tfr;
    END; { of WITH }


    { set up drivers for the interfaces }

    FOR io_isc:=iominisc TO iomaxisc DO
      WITH isc_table[io_isc] DO BEGIN

	IF ( card_id = hp98628_async ) OR
	   ( card_id = hp98628_dsndl ) OR
	   ( card_id = hp98629 )
	  THEN BEGIN
	    card_id   := hp_datacomm;
	    card_type := serial_card;                           { uuuu TM 9/28/82 }
	  END;

	IF card_id = hp_datacomm
	  THEN BEGIN

	    io_drv_ptr:=ADDR(dc_drivers);

	    { if the card exists then link in an ISR for it }
	    { ??? - what happens if an ISR fires during init }

	    io_lvl:=((ioread_byte(io_isc,3) DIV 16) MOD 4)+3;
	    IF io_tmp_ptr^.myisrib.INTREGADDR <> NIL
	      THEN BEGIN
		{ if isr exists then unlink it }
		ISRUNLINK(io_lvl ,                      { level         }
		    ADDR(io_tmp_ptr^.myisrib));         { isrib info    }
	      END; { of IF }

	    PERMISRLINK(io_drv_ptr^.iod_isr,            { isr           }
		    ANYPTR(INTEGER(card_ptr)+3),        { card address  }
		    192,                                { intr. mask    }
		    192,                                { intr. value   }
		    io_lvl,                             { level         }
		    ADDR(io_tmp_ptr^.myisrib));         { isrib info    }
	  END; { of IF card_type = hp_datacomm }

    END; { of FOR io_isc WITH isc_table[io_isc] BEGIN }


    { call the actual driver initialization }

    dc_init_fault := FALSE;           { set fault flag            zzzz TM 6/16/82 }
    FOR io_isc:=iominisc TO iomaxisc DO
      WITH isc_table[io_isc] DO
      IF card_id = hp_datacomm
	THEN BEGIN

	  TRY                                                   { zzzz TM 6/16/82 }

	    alvinit( io_tmp_ptr );

	    direct_status( io_tmp_ptr , 3 , dummyword );
	    IF dummyword = 1 THEN card_id := hp98628_async;
	    IF dummyword = 2 THEN card_id := hp98628_dsndl;     { cccc TM 8/16/82 }

	    { set up Ganglia card ID }                          { bbbb TM 7/16/82 }
	    IF ioread_byte(io_isc,HEX('402F'))=3                { bbbb TM 7/16/82 }
	      THEN BEGIN                                        { bbbb TM 7/16/82 }
		{ card is ganglia }                             { bbbb TM 7/16/82 }
		card_id   := hp98629;                           { cccc TM 8/16/82 }
		card_type := srm_card;                          { uuuu TM 9/28/82 }
	       {iowrite_byte(io_isc ,                           { bbbb TM 7/16/82 }
		 {HEX('4061')  , io_model_number DIV 256 );     { bbbb TM 7/16/82 }
	       {iowrite_byte(io_isc ,                           { bbbb TM 7/16/82 }
		 {HEX('4061')  + 2 , io_model_number MOD 256 ); { bbbb TM 7/16/82 }
	      END; { of IF }                                    { bbbb TM 7/16/82 }

	  RECOVER BEGIN                                         { zzzz TM 6/16/82 }

	    IF ESCAPECODE<>ioescapecode THEN ESCAPE(ESCAPECODE);{ zzzz TM 6/16/82 }
	    IF ioe_isc <> io_isc        THEN ESCAPE(ESCAPECODE);{ zzzz TM 6/16/82 }

	    IF NOT dc_init_fault                                { zzzz TM 6/16/82 }
	      THEN BEGIN                                        { zzzz TM 6/16/82 }
		dc_init_fault := TRUE ;                         { zzzz TM 6/16/82 }
		NEW(dc_error);                  { get space   } { zzzz TM 6/16/82 }
		FOR dummyword:=minrealisc TO maxrealisc DO      { zzzz TM 6/16/82 }
		  dc_error^[dummyword]:=0;      { clear space } { zzzz TM 6/16/82 }
	      END; { of IF NOT dc_init_fault }                  { zzzz TM 6/16/82 }

	    dc_error^[io_isc] := ioe_result;    { set this err} { zzzz TM 6/16/82 }

	  END; { of RECOVER BEGIN }                             { zzzz TM 6/16/82 }

	END; { of WITH IF }

  END; { of io_init_dc }

END; { of MODULE init_dc }
$PAGE$

IMPORT    init_dc ,
	  LOADER ;                                              { 367  TM 9/22/82 }


BEGIN
  io_init_dc;
  MARKUSER;                                                     { 367  TM 9/22/82 }
END. { of dc_initialize }
@


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


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


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.2
log
@Pws2unix automatic delta on Tue Aug 25 18:23:33 MDT 1987
@
text
@@


22.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@d608 1
a608 1
    io_revid := io_revid + ' S3.1';     { SERIAL revision added 2/5/82 TM }
@


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
@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
@@
