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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.1
date     86.06.30.15.08.37;  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
@	TTL IOLIB EXTG - GPIO DRIVERS
	PAGE
********************************************************************************
*
*       COPYRIGHT (C) 1985 BY HEWLETT-PACKARD COMPANY
*
********************************************************************************
*
*
*       IOLIB     EXTG
*
*
********************************************************************************
*
*
*
*       Library - IOLIB
*       Author  - Tim Mikkelsen
*       Phone   - 303-226-3800  ext. 2910
*
*       Purpose - This set of assembly language code is intended to be used as
*                 a PASCAL module for I/O drivers for use by the external I/O
*                 procedures library.
*
*                 Much of this code was taken from Andy Goris' HPL GPIO
*                 drivers.
*
*       Date    - 09/20/81
*       Update  - 04/26/84 BY J Schmidt
*       Release - 07/12/85
*
*
*       Source  - IOLIB:GPIO.TEXT
*       Object  - IOLIB:GPIO.CODE
*
*
********************************************************************************
*
*
*       RELEASED
*       VERSION         3.1
*
*
********************************************************************************
	PAGE
****************************************************************************
*                                                                          *
*                                                                          *
*      BUG FIX HISTORY         - after release 1.0                         *
*                                                                          *
*                                                                          *
*      BUG #   BY  / ON        LOC             DESCRIPTION                 *
*      -----   -----------     --------------  ----------------------      *
*                                                                          *
*      SPR836  T Mikkelsen     G_SET_PCT       a IOCONTROL(x,1,1); does    *
*              08/09/1982                      not set the PCTL line, it   *
*                                              resets the interface.       *
*                                                                          *
*      475     T Mikkelsen     all over        Change BSRs into JSRs to    *
*              09/17/1982                      allow re-placement of the   *
*                                              modules.  Also in HPIB and  *
*                                              Data comm modules.          *
*                                                                          *
*      507     T Mikkelsen     G_TFI           Did not do a trigger to the *
*              09/17/1982                      gpio card before a FHS tfr. *
*                                                                          *
*      508     T Mikkelsen     G_WTC           Typographical error in      *
*              09/17/1982                      write control to CTL0/1.    *
*                                                                          *
*      xxx     T Mikkelsen     G_TFR           Transfer should wait for    *
*              10/06/1982                      card to be ready ( ala the  *
*                                              HPL system ).               *
*                                                                          *
*      yyy     J Schmidt       G_INIT          Changes for timing on       *
*              8/1/83          G_WAIT          680xx UMM CPU boards        *
*              5/2/84          G_STSCHK                                    *
*                                                                          *
*       69     J Schmidt       G_WTC           Missing inst. in set CTL0/1 *
*    (3.0 QA)  4/26/84                                                     *
*                                                                          *
*    SPR12724  J Schmidt       G_TFR           Clear upper byte on byte    *
*              5/3/84                          transfers                   *
****************************************************************************
	PAGE
********************************************************************************
*
*
*       The following lines are used to tell the LINKER/LOADER what this module
*       looks like in PASCAL terms.
*
*       Note that it is possible to create assembly modules that are functions.
*       These routines are called through an indirect pointer using the CALL
*       facility which does NOT permit functions.
*
*       This module is called 'EXTG' ( upper or lower case - doesn't matter )
*       independent of the file name ( by use of the MNAME pseudo-op ).
*
*       All the externally used procedures are called 'EXTG_@@@@@@@@@@@@@@@@' in
*       this module.  If you are using assembly to access them use the
*       'EXTG_@@@@@@@@@@@@@@' name.  If you are using Pascal use the '@@@@@@@@@@@@@@'
*       name.
*
********************************************************************************
	MNAME EXTG
	SRC MODULE EXTG;
	SRC IMPORT iodeclarations;
	SRC EXPORT
	SRC        PROCEDURE eg_init  ( temp : ANYPTR );
	SRC        PROCEDURE eg_isr   ( temp : ANYPTR );
	SRC        PROCEDURE eg_rdb   ( temp : ANYPTR ;  VAR x : CHAR);
	SRC        PROCEDURE eg_wtb   ( temp : ANYPTR ;  val   : CHAR);
	SRC        PROCEDURE eg_rdw   ( temp : ANYPTR ;  VAR x : io_word);
	SRC        PROCEDURE eg_wtw   ( temp : ANYPTR ;  val   : io_word);
	SRC        PROCEDURE eg_rds   ( temp : ANYPTR ;  reg   : io_word;
	SRC                                              VAR x : io_word);
	SRC        PROCEDURE eg_wtc   ( temp : ANYPTR ;  reg   : io_word;
	SRC                                              val   : io_word );
	SRC        PROCEDURE eg_tfr   ( temp : ANYPTR ;  bcb   : ANYPTR );
	SRC        PROCEDURE eg_clr   ( temp : ANYPTR ;  line  : io_bit );
	SRC        PROCEDURE eg_set   ( temp : ANYPTR ;  line  : io_bit );
	SRC        PROCEDURE eg_test  ( temp : ANYPTR ;  line  : io_bit ;
	SRC                                              VAR x : BOOLEAN );
	SRC END; { of EXTG }
	PAGE
********************************************************************************
*
*       SYMBOLS FOR EXPORT AS PROCEDURE NAMES
*
********************************************************************************
	DEF EXTG_EXTG
	SPC 1
	DEF EXTG_EG_INIT
	DEF EXTG_EG_ISR,EXTG_EG_TDMA
	DEF EXTG_EG_RDB,EXTG_EG_WTB
	DEF EXTG_EG_RDW,EXTG_EG_WTW
	DEF EXTG_EG_RDS,EXTG_EG_WTC
	DEF EXTG_EG_TFR
	SPC 1
	DEF EXTG_EG_SET,EXTG_EG_CLR,EXTG_EG_TEST
	SPC 1
********************************************************************************
*
*       SYMBOLS FOR IMPORT
*
********************************************************************************
	REFA STBSY
	REFA STCLR
	REFA ITXFR
	REFA ABORT_IO
	REFA LOGINT
	REFA GETDMA
	REFA DROPDMA
	REFA TESTDMA
	REFA DMA_STBSY
	REFA WAIT_TFR
	REFA CHECK_TFR
	REFA CHECK_TIMER                                       yyyy JS 8/ 1/83
	REFA DELAY_TIMER                                       yyyy JS 8/ 1/83
*
*       change references to allow long jumps when the I/O      475 TM 9/17/82
*       modules get moved around                                475 TM 9/17/82
	LMODE STBSY                                             475 TM 9/17/82
	LMODE STCLR                                             475 TM 9/17/82
	LMODE ITXFR                                             475 TM 9/17/82
	LMODE ABORT_IO                                          475 TM 9/17/82
	LMODE LOGINT                                            475 TM 9/17/82
	LMODE GETDMA                                            475 TM 9/17/82
	LMODE DROPDMA                                           475 TM 9/17/82
	LMODE TESTDMA                                           475 TM 9/17/82
	LMODE DMA_STBSY                                         475 TM 9/17/82
	LMODE WAIT_TFR                                          475 TM 9/17/82
	LMODE CHECK_TFR                                         475 TM 9/17/82
	LMODE CHECK_TIMER                                      yyyy JS 8/ 1/83
	LMODE DELAY_TIMER                                      yyyy JS 8/ 1/83

	TTL IOLIB EXTG - COMMON DECLARATIONS AND EQUATES
	PAGE
	INCLUDE COMDCL
	TTL IOLIB EXTG - PASCAL ENTRY POINTS
********************************************************************************
*
*         PASCAL DRIVER ENTRY POINTS FOR GPIO CARDS
*
********************************************************************************
	  SPC 1
*
*         MODULE initialization
*
EXTG_EXTG EQU *
	  RTS
*
*         Driver initialization
*
EXTG_EG_INIT      EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_INIT
*
*         Interrupt service routine
*
EXTG_EG_ISR       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_ISR
*
*         HPIB DMA transfer termination routine
*
EXTG_EG_TDMA      EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_DMATERM
*
*         Read a byte
*
EXTG_EG_RDB       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_RDB         call read byte ( or word )
	  MOVE.B  D0,(A3)       save character
	  RTS
*
*         Write a byte
*
EXTG_EG_WTB       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.B  (SP)+,D0      get value           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_WTB         call write byte ( or word )
*
*         Read a word
*
EXTG_EG_RDW       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_RDB         call read byte ( or word )
	  MOVE.W  D0,(A3)       save word
	  RTS
*
*         Write a word
*
EXTG_EG_WTW       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D0      get word value
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_WTB         write the byte ( or word )
*
*         Read status
*
EXTG_EG_RDS       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVE.W  (SP)+,D1      get register number
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_RDS         get status
	  MOVE.W  D0,(A3)       save status info
	  RTS
*
*         Write control
*
EXTG_EG_WTC       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D0      get value
	  MOVE.W  (SP)+,D1      get register number
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_WTC         write control
*
*         Transfer
*
EXTG_EG_TFR       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get buffer control block address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_TFR         transfer
*
*         Set an GPIO line
*
EXTG_EG_SET       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D1      get line           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_SET         call set line
*
*         Clear an GPIO line
*
EXTG_EG_CLR       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D1      get line           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_CLR         clear the line
*
*         Test an GPIO line
*
EXTG_EG_TEST      EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVE.W  (SP)+,D1      get line           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_TEST        read status
	  MOVE.B  D0,(A3)       save character
	  RTS
	  TTL IOLIB EXTG - GPIO DRIVERS
	  PAGE
******************************************
*
*  GPIO INITIALIZATION
*
******************************************
G_INIT   EQU *
G_RESET  JSR     ABORT_IO                                       475 TM 9/17/82
	 MOVE.W  #-1,MA_W(A2)   the card is not addressable - so my addr =-1
	 MOVE.B  D0,1(A1)       Reset the GPIO card
	 MOVE.L  #40,-(SP)         Wait AT LEAST 15 microseconds
	 JSR     DELAY_TIMER    USE DELAY ROUTINE 40 uS       yyyy  JS  8/1/83
	 MOVE.B  #3,2(A1)
	 RTS
	 SPC     6
******************************************
*
*  IOFS
*
******************************************
G_IOFS   MOVEQ   #0,D0
	 BTST    #3,7(A1)    PSTS -> D0<0>
	 BEQ.S   G_IOFS1
	 MOVEQ   #1,D0
G_IOFS1  BTST    #0,(A1)     PFLG -> D0<1>
	 BEQ.S   G_IOFS2
	 ADDQ    #2,D0
G_IOFS2  RTS
	 PAGE
******************************************
*
*  wtb
*
******************************************
G_WTB    BSR.S   G_STSCHK    Check for PSTS
	 BSR.S   G_WAIT      Wait for FLG
	 MOVE.W  D0,4(A1)    Write the word
	 MOVE.B  D0,(A1)     wti 7,0  trigger output
	 RTS
	 SPC     3
******************************************
*
*  rdb
*
******************************************
G_RDB    BSR.S   G_STSCHK    Check for PSTS
	 BSR.S   G_WAIT
	 MOVE.W  4(A1),D0    Set I/O line for input
	 MOVE.B  D0,(A1)     wti 7,0  trigger input
	 BSR.S   G_WAIT      Wait for data to come in
	 MOVE.W  4(A1),D0
	 RTS
	 SPC     6
G_STSCHK BTST    #3,7(A1)    CHECK FOR PSTS OK    yyyy JS 8/1/83
	 BNE.S   G_STSRTS    IF OK THEN RETURN    yyyy JS 8/1/83
	 BTST    #TIMER_PRESENT,SYSFLAG2   TIMER EXISTS?  yyyy JS 8/1/83
	 BEQ.S   G_STS0B     YES, USE IT          yyyy JS 8/1/83
	 MOVE    D0,-(SP)    SAVE D0              yyyy JS 8/1/83
	 MOVE    #22000,D0   SETUP 100MS LOOP     yyyy JS 8/1/83
G_STS0   BTST    #3,7(A1)    Is PSTS O.K. ?
	 BEQ.S   G_STS1      No:  Give him 100 ms
	 MOVE    (SP)+,D0    Yes: Restore D0
G_STSRTS RTS
G_STS1   DBRA    D0,G_STS0   Decrement loop counter
	 BRA     CRD_DOWN    If counter expires, card is down
G_STS0B  MOVE.B  #1,-(SP)    SETUP TIMER RECORD   yyyy JS 8/1/83
	 MOVE.L  #100,-(SP)  LOOP FOR 100 MS      yyyy JS 8/1/83
G_STS0C  BTST    #3,7(A1)    PSTS SET ?           yyyy JS 8/1/83
	 BNE.S   G_STS1B     YES, RETURN          yyyy JS 8/1/83
	 PEA     (SP)        CHECK TIMER          yyyy JS 8/1/83
	 JSR     CHECK_TIMER  SEE IF 100MS GONE   yyyy JS 8/1/83
	 BPL     G_STS0C      NO, CHECK PSTS      yyyy JS 8/1/83
	 BTST    #3,7(A1)     LAST CHANCE TEST    yyyy JS 5/2/84
	 BEQ     CRD_DOWN     IF NOT PSTS, ERROR  yyyy JS 5/2/84
G_STS1B  ADDQ    #6,SP        STRIP TIMER REC     yyyy JS 8/1/83
	 RTS                  AND RETURN          yyyy JS 8/1/83

	 PAGE
******************************************
*
*  GPIO WAIT ROUTINE
*
******************************************
G_WAIT   BTST    #0,(A1)        IF CARD_READY THEN RETURN
	 BNE.S   G_WRTS
	 MOVE.L  TIMEOUT(A2),D1 D1 = (TIMEOUT)
	 BEQ.S   G_WAIT4
	 BTST    #TIMER_PRESENT,SYSFLAG2  GOT A TIMER?    yyyy JS 8/1/83
	 BEQ.S   G_WAIT2B             YES, SO USE IT      yyyy JS 8/1/83
G_WAIT2  EQU     *
* tm     MULU    #182,D1        CONVERT D1 TO MILLISECONDS
	 MOVE.L  D1,D5          \
	 LSL.L   #7,D1           \  * 196 IS CLOSE TO * 182
	 LSL.L   #6,D5           /
	 ADD.L   D5,D1          /
G_WAIT3  BTST    #0,(A1)        WHILE D1 MILLISECONDS HAS NOT EXPIRED DO
	 BNE.S   G_WRTS         IF CARD_READY THEN RETURN
	 SUBQ.L  #1,D1
	 BGT.S   G_WAIT3
G_WAITER MOVEQ   #TMO_ERR,D0    GENERATE ESCAPE
	 BRA.S   ESC_ERR
	 SPC     4
G_WAIT4  BTST    #0,(A1)        IF CARD_READY THEN RETURN
	 BEQ.S   G_WAIT4
G_WRTS   RTS

G_WAIT2B MOVE.B  #1,-(SP)       SETUP TIMER RECORD           yyyy JS 8/1/83
	 MOVE.L  D1,-(SP)       D1 HAS MS TO WAIT            yyyy JS 8/1/83
G_WAIT3B MOVE.L  #364,D1        INNER LOOP TO GET 1 MS AT    yyyy JS 8/1/83
G_WAIT4B BTST    #0,(A1)        16 MHZ -- CHECK FOR READY    yyyy JS 8/1/83
	 BNE.S   G_WAIT5B       READY -- EXIT THE LOOP       yyyy JS 8/1/83
	 SUBQ.L  #1,D1          ELSE LOOP FOR 1-2 MS HERE    yyyy JS 8/1/83
	 BGT     G_WAIT4B                                    yyyy JS 8/1/83
	 PEA     (SP)           AFTER INNER LOOP CHECK TIMER yyyy JS 8/1/83
	 JSR     CHECK_TIMER                                 yyyy JS 8/1/83
	 BPL     G_WAIT3B       BRANCH IF NO TIMEOUT         yyyy JS 8/1/83
	 BTST    #0,(A1)        TIMEOUT -- LAST CHANCE       yyyy JS 5/2/84
	 BEQ     G_WAITER       REAL TIMEOUT IF NOT READY    yyyy JS 5/2/84
G_WAIT5B ADDQ    #6,SP          CLEAN UP STACK               yyyy JS 8/1/83
	 RTS                    DONE                         yyyy JS 8/1/83

	 TTL IOLIB EXTG - ERROR ESCAPES
	 PAGE
********************************************************************************
*
*       Error escapes
*
********************************************************************************
G_SCBSY   MOVEQ  #SC_BUSY,D0            sc is busy
	  BRA.S  ESC_ERR
CRD_DOWN  MOVEQ  #CRD_DWN,D0            CARD IS DOWN
	  BRA.S  ESC_ERR
G_SC_ERR  MOVEQ  #BAD_SCT,D0            bad set/clear/test
	  BRA.S  ESC_ERR
GTERR_B   MOVEQ  #TFR_ERR,D0            bad transfer specification
	  BRA.S  ESC_ERR
GTERR_D   MOVEQ  #NO_DMA,D0             DMA not installed
*         BRA.S  ESC_ERR
	  SPC    4
ESC_ERR   EXT.L  D0                     assume errors<128
	  MOVE.L D0,IOE_RSLT(A5)        save ioe_result
	  MOVE.B IO_SC(A2),D0
	  MOVE.L D0,IOE_SC(A5)          save io s.c.
	  MOVE.W #IOE_ERROR,ESC_CODE(A5)
	  TRAP   #10                    escape
	  TTL IOLIB EXTG - GPIO DRIVERS
	  PAGE
********************************************
*
*       LINE DEFINITIONS
*
*           bit 0       STI0
*               1       STI1
*               2       EIR
*               3       PSTS
*               4       CTL0
*               5       CTL1
*               6       READY
*               7       PCTL
*
********************************************
	SPC 3
********************************************
*
*        SET LINE
*
********************************************
G_SET    AND.B  #7,D1           MASK TO RIGHT SIZE
	 CMP.B  #5,D1           \ HANDLE SET PCTL
	 BEQ.S  GSET_1          /
	 CMP.B  #6,D1           \ CAN ONLY SET
	 BLT.S  G_SC_ERR        /     CTL0/1
	 SUB.B  #5,D1           GET INTO 1/2 FORM
	 OR.B   D1,7(A1)        SET CTL0 or 1
	 OR.B   D1,EIRB_OFF(A2) SAVE IN EIRB
	 RTS
GSET_1   MOVE.B D1,0(A1)        SET PCTL
	 RTS
	 SPC    3
********************************************
*
*        CLEAR LINE
*
********************************************
G_CLR    AND.B  #7,D1           MASK TO RIGHT SIZE
	 CMP.B  #6,D1           \ CAN ONLY CLEAR
	 BLT.S  G_SC_ERR        /     CTL0/1
	 MOVE.B EIRB_OFF(A2),D0 GET OLD CTL0/1
	 SUB.B  #6,D1           GET INTO 0/1 FORM
	 BCLR   D1,D0           CLEAR COPY
	 MOVE.B D0,EIRB_OFF(A2) SAVE IN EIRB
	 MOVE.B D0,7(A1)        WRITE TO CARD
	 RTS
	 SPC    3
********************************************
*
*        TEST LINE
*
********************************************
G_TEST   CLR.W   D0             set FALSE indication
	 AND.B  #7,D1           mask to the right size
	 CMP.B  #7,D1           \ CHECK FOR PCTL
	 BEQ    G_SC_ERR        /       AND GIVE ERROR
	 CMP.B  #3,D1
	 BGT.S  GTST2
GTST1    BTST   D1,7(A1)        TEST ST0/1,EIR,or psts
GTST_CHK BEQ.S  GTST_RTS        if clear then RTS
GTST_SET MOVEQ  #1,D0              else return true indication
GTST_RTS RTS
	 SPC    2
GTST2    SUB.B  #4,D1
	 CMP.B  #1,D1
	 BGT.S  GTST4
GTST3    BTST   D1,EIRB_OFF(A2) TEST CTL0/1
	 BRA.S  GTST_CHK        GO TO COMMON CHECK CODE
	 SPC    2
GTST4    BTST   #0,0(A1)        CHECK READY LINE
	 BRA.S  GTST_CHK
	 PAGE
********************************************************************************
*
*       G_RDS
*
*         READ STATUS
*
*         PASCAL ROUTINE
*
********************************************************************************
G_ROUTINE EQU    2
G_TEMP    EQU    1
G_CRDREG  EQU    0
*
*
G_RDS     LEA    G_RDSTBL,A0            get pointer to lookup table
	  ADD.W  D1,D1                  multiply the rds register by 2
	  CMP.B  #G_RT_SIZ,D1           \ check for out of bounds
	  BGE.S  RDS_ERR                /
	  MOVE.W 0(A0,D1),D0            get the table entry
	  BMI.S  RDS_ERR                if the entry is 0 then error
	  CMP.B  #G_TEMP,D0
* tm      BEQ.S  GR_TEMP
	  BLT.S  GR_CARD
	  LSR    #8,D0                  get the routine offset
	  BEQ.S  G_RDS_DI               -  status rtn 3 - data in
	  SUBQ   #1,D0
	  BEQ.S  G_RDS_RDY              -  status 4 - ready
	  SUBQ   #1,D0
	  BEQ.S  G_RDS_PST              -  status  5 - peripheral status
*         BRA.S  RDS_ERR                there are no more status 'routines'
	  SPC    2
RDS_ERR   MOVEQ  #BAD_RDS,D0            bad read status
	  BRA    ESC_ERR
	  SPC    2
*
*         retrieve temps as words
*
* tm GR_TEMP   LSR    #8,D0                  get temp offset
* tm           MOVE.W 0(A2,D0),D0            get the value
* tm           RTS
	  SPC 3
*
*         retrieve card registers as bytes
*
GR_CARD   LSR    #8,D0                  get the card offset
GR_CARD1  MOVE.B 0(A1,D0),D0            get the value
GREGEXIT  ANDI.W #$00FF,D0              mask off garbage
	  RTS
	  SPC 3
*
*         data in
*
G_RDS_DI  MOVE.W 4(A1),D0               get data lines
	  RTS
	  SPC    3
G_RDS_RDY MOVE.B 0(A1),D0               get ready line
	  ANDI.B #$01,D0                mask to 1 bit
	  BRA    GREGEXIT               and get out
	  SPC    3
G_RDS_PST MOVE.B 7(A1),D0               get status
	  ANDI.B #$0F,D0                mask to 4 bits
	  BRA    GREGEXIT               and get out
	  SPC    4
G_RDSTBL  EQU    *
	  DC.B   1,G_CRDREG             status 0 - card reg  0   - card id
	  DC.B   3,G_CRDREG             status 1 - card reg 3   - intr/dma status
	  DC.B   9,G_ROUTINE            status 2 - not implemented
	  DC.B   0,G_ROUTINE            status 3 - data in
	  DC.B   1,G_ROUTINE            status 4 - ready line
	  DC.B   2,G_ROUTINE            status 5 - peripheral status
G_RT_END  EQU    *
G_RT_SIZ  EQU    G_RT_END-G_RDSTBL      size of table
	  PAGE
********************************************************************************
*
*       G_WTC
*
*         WRITE CONTROL
*
*         ENTRY:  D0.W = PARAMETER
*
********************************************************************************
G_WTC     CMP.W  #6,D1                  \
	  BGE.S  RDS_ERR                / check wtc limits
	  EXT.L  D1
	  ADD.L  D1,D1
	  JMP    GWTCTBL(D1)
	  SPC    2
GWTCTBL   BRA.S  G_WTC_RST              CONTROL 0 - DO A RESET
	  BRA.S  G_SET_PCT              CONTROL 1 - set pctl
	  BRA.S  G_SET_CTL              CONTROL 2 : set control lines
	  BRA.S  G_DATA_O               CONTROL 3 - write data out
	  BRA.S  RDS_ERR                CONTROL 4 : not used
	  BRA.S  G_EIR                  CONTROL 5 : enable intrpts
	  SPC    3
G_WTC_RST BRA    G_INIT                 reset card
	  SPC    2
G_SET_PCT MOVE.B D0,0(A1)               set pctl line           SPR836 TM 8/9/82
	  RTS
	  SPC    2
G_SET_CTL MOVE.B D0,7(A1)               set ctl 0 and 1
	  AND.B  #3,D0                  \ save CTL0/1           508 TM 9/17/82
	  ANDI.B #$FC,EIRB_OFF(A2)      CLEAR CTL0/1     #69 (3.0) JWS 4/26/84
	  OR.B   D0,EIRB_OFF(A2)        / in EIR byte           508 TM 9/17/82
	  RTS
G_DATA_O  MOVE.W D0,4(A1)               write 16 bit data
	  RTS
	  PAGE
*************************************************
*
*  EIR
*
*************************************************
G_EIR    MOVE.B  D0,EIRB_OFF(A2)
	 JSR     ITXFR                                          475 TM 9/17/82
	 BNE.S   G_RTS                  if tfr then don't
G_WTI5   MOVE.B  D0,7(A1)               Update CTL1:CTL0
	 BTST    #5,D0                  Check RESET bit
	 BNE     G_RESET
	 TST.B   D0
	 BGE.S   G_RTS1
	 MOVE.B  #$80,3(A1)
G_RTS    RTS
G_RTS1   MOVE.B  #0,3(A1)
	 RTS
	 TTL IOLIB EXTG - TRANSFER
	 PAGE
*************************************************
*
*  GPIO tfr
*
*************************************************
G_TFR     JSR    CHECK_TFR              wait for tfr to finish  475 TM 9/17/82
	  BSR    G_WAIT                 Wait for FLG            xxx TM 10/6/82
	  MOVE.W #0,4(A1)               CLEAR DATA REG    SPR12724  JS 5/3/84
	  TST.B  TEND_OFF(A3)           \ end NOT ALLOWED
	  BNE    GTERR_B                /
	  MOVE.L TCNT_OFF(A3),D0        GET COUNT
	  CLR.W  D1                     \
	  MOVE.B TUSR_OFF(A3),D1         \   COMPUTE OFFSET INTO JUMP TABLE
	  ADD.W  D1,D1                    \
	  JSR    TESTDMA                  /  BASED ON TFR       475 TM 9/17/82
	  BEQ.S  G_NODMA                 /      TYPE AND DMA PRESENCE
	  ADDI.W #20,D1                 /
G_NODMA   LEA    G_TBL,A0               \
	  ADDA.W 0(A0,D1),A0             INDEXED JUMP THRU TABLE
	  JMP    (A0)                   /
*
*         TRANSFER JUMP TABLE
*
*                               --------------------  DMA is not installed or available
G_TBL     DC.W   GTERR_B-G_TBL  serial  interrupt
	  DC.W   GTERR_D-G_TBL  serial  dma
	  DC.W   G_T_FHS-G_TBL  serial  fhs
	  DC.W   G_T_FHS-G_TBL  serial  fastest
	  DC.W   GTERR_B-G_TBL  serial  overlap
*                               --------------------
	  DC.W   G_T_INT-G_TBL  overlap interrupt
	  DC.W   GTERR_D-G_TBL  overlap dma
	  DC.W   G_T_BST-G_TBL  overlap fhs
	  DC.W   G_T_BST-G_TBL  overlap fastest
	  DC.W   G_T_INT-G_TBL  overlap overlap
*                               --------------------  DMA is installed
	  DC.W   GTERR_B-G_TBL  serial  interrupt
	  DC.W   G_T_DMA-G_TBL  serial  dma
	  DC.W   G_T_FHS-G_TBL  serial  fhs
	  DC.W   G_T_DMA-G_TBL  serial  fastest
	  DC.W   GTERR_B-G_TBL  serial  overlap
*                               --------------------
	  DC.W   G_T_INT-G_TBL  overlap interrupt
	  DC.W   G_T_DMA-G_TBL  overlap dma
	  DC.W   G_T_BST-G_TBL  overlap fhs
	  DC.W   G_T_DMA-G_TBL  overlap fastest
	  DC.W   G_T_DMA-G_TBL  overlap overlap
	  PAGE
*
*         Transfer DMA
*
G_T_DMA   CMP.L  #1,D0                  \ USE INTR IF COUNT=1 ON DMA
	  BEQ    G_T_INT                /
	  MOVE.B #TT_DMA,TACT_OFF(A3)   set tfr type to DMA
	  TST.B  TDIR_OFF(A3)           \ test for transfer direction
	  BGT.S  G_TOD                  /
*
*         Transfer Input Dma:
*
G_TID     EQU     *
	  SUBQ.L  #1,D0                 0 - Set up DMA for Input
	  JSR     GETDMA                Tfr N-1 bytes via DMA   475 TM 9/17/82
	  BTST    #3,3(A1)              Is BURST bit set on GPIO card ?
	  BEQ.S   G_DMA1                No
	  ORI.W   #8,D2                 Yes: Set BURST bit in DMA arm byte
G_DMA1    MOVE    D2,(A4)               Arm DMA
	  BSR     GD_STBSY              Set buffer busy (Card is still not triggered)
	  TST     4(A1)                 rdi 4
	  MOVE.B  D0,(A1)               wti 7,0  (trigger card)
	  MOVE.B  #1,2(A1)              RDYEN = 0 (so transfers won't interrupt)
	  TST.B   T_BW_OFF(A3)          Byte (0) or Word (1) transfers ?
	  BEQ.S   G_DMA3
	  ADD     #4,D3
G_DMA3    MOVE.B  D3,3(A1)              Tell the GPIO what channel he's got and
*                                          watch the shit hit the fan
	  BRA.S  G_DMA_W                DONE
*
*         Transfer Output Dma:
*
G_TOD     EQU     *
G_DMAOUT  JSR     GETDMA                Get a DMA channel       475 TM 9/17/82
	  BTST    #3,3(A1)              Is Burst mode enabled (1)
	  BEQ.S   G_DMA4
	  ORI.W   #8,D2                 Yes: Set the Burst bit in DMA arm byte
G_DMA4    MOVE    D2,(A4)               Arm the DMA channel
	  BSR     GD_STBSY              Set the buffer busy
	  MOVE.B  #1,2(A1)              Disable the transfer interrupt mechanism
	  TST.B   T_BW_OFF(A3)          Byte (1) or Word (0) transfers ?
	  BEQ.S   G_DMA6                Byte: Don't set the WORD bit on GPIO card
	  ORI.W   #4,D3                 WORD: Set the WORD bit
G_DMA6    MOVE.B  D3,3(A1)              Tell the GPIO what channel he's got, etc.
*
*       G_DMA_W                         IF SERIAL THEN WAIT FOR  COMPLETION
*
G_DMA_W   MOVE.B TUSR_OFF(A3),D4        \
	  CMP.B  #5,D4                   IS THE TRANSFER OVERLAP ?
	  BGE.S  G_DMA_W2               /
G_DMA_W1  CMPI.B #255,T_SC_OFF(A3)      IF NOT THEN WAIT TILL DONE
	  BNE.S  G_DMA_W1
G_DMA_W2  RTS
	  SPC    5
GD_STBSY  LEA    EXTG_EG_TDMA,A4        \  save g_dmaterm routine
	  JSR    DMA_STBSY              /  in dma temps         475 TM 9/17/82
	  RTS                                                   475 TM 9/17/82
	  PAGE
*
*         Transfer INTERRUPT
*
G_T_INT   MOVE.B #TT_INT,TACT_OFF(A3)   set tfr type to INTERRUPT
	  BRA.S  G_T_BIC                go to common code
	  SPC    3
*
*         Transfer BURST ( intr on 1st byte FHS on rest )
*
G_T_BST   MOVE.B #TT_BURST,TACT_OFF(A3) set tfr type to BURST
*         BRA.S  G_T_BIC                go to common code
	  SPC    3
*
*         common interrupt and burst code
*
G_T_BIC   JSR    STBSY                  SET BUFFER BUSY, ETC
	  TST.B  TDIR_OFF(A3)           \ test for transfer direction
	  BGT.S  G_TOI                  /
*
*         Transfer Input Interrupt or Transfer Input Burst
*
G_TII     EQU     *
G_INT_I   TST     4(A1)                 Dummy read to set I/O line to I
	  MOVE.B  D0,(A1)               wti 7,0 (trigger input)
*
*         Transfer Output Interrupt or Transfer Output Burst
*
G_TOI     EQU     *
G_INT_O   MOVE.B  #3,2(A1)              Allow I/O to cause an interrupt
	  MOVE.B  EIRB_OFF(A2),D0       GET CTL0/1
	  ORI.B   #$80,D0
	  BSR     G_WTI5                Enable interrupts
	  BRA     G_DMA_W               and wait if necessary
	  PAGE
*
*         Transfer FHS
*
G_T_FHS  MOVE.B #TT_FHS,TACT_OFF(A3)    set tfr type to FHS
	 JSR    STBSY                   set buffer busy         475 TM 9/17/82
	 JSR    ITXFR                   get all pointers        475 TM 9/17/82
	 TST.B  TDIR_OFF(A3)            \ test for transfer direction
	 BGT.S  G_TFO                   /
*
*         Transfer FHS in
*
G_TFI    TST     4(A1)                  to set I/O line to I    507 TM 9/17/82
	 MOVE.B  D0,(A1)                trigger input           507 TM 9/17/82
	 MOVEQ   #0,D0                  clear upper part  of data in
	 MOVEA.L TFIL_OFF(A3),A0        GET FILL POINTER
	 TST.B   T_BW_OFF(A3)           GET B/W INDICATIONS
	 BNE.S   G_TFIW
G_TFIB   BSR     G_WAIT
G_TFIB1  MOVE.B  5(A1),D0               D0.L = Byte received
	 MOVE.B  D0,(A0)+
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   GTFI_TRM               If buffer full; exit fast handshake
	 CMP.W   D0,D2                  If input character matches end character
	 BEQ.S   GTFI_TRM                 then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TFIB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TFIB1                Yes: Get next byte
	 BRA     G_TFIB2                No:  Keep checking
	 SPC     3
G_TFIW   BSR     G_WAIT
G_TFIW1  MOVE    4(A1),(A0)+            Copy word from GPIO to buffer
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   GTFI_TRM               If D3 = 0 we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TFIW2  BTST    #0,(A1)                PFLG = 1
	 BNE     G_TFIW1
	 BRA     G_TFIW2                No:  Keep checking
	 SPC     3
*
* FHS TRANSFER TERMINATION
*
GTFI_TRM MOVE.L  D3,TCNT_OFF(A3)        D3 has bytes not finished
	 MOVE.L  A0,TFIL_OFF(A3)        update fill pointer
GTFO_TRM JSR     STCLR                  MARK BUFFER FINISHED    475 TM 9/17/82
	 RTS
	 SPC     3
*
*         Transfer FHS out
*
G_TFO    MOVEA.L TEMP_OFF(A3),A0        GET EMPTY POINTER
	 TST.B   T_BW_OFF(A3)           GET B/W INDICATIONS
	 BNE.S   G_TFOW
G_TFOB   BSR     G_WAIT                 Wait for card ready
G_TFOB1  MOVE.B  (A0)+,5(A1)            Copy byte from buffer to GPIO
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TFO3                 If D3 = 0 then we're done
G_TFOB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TFOB1                Yes: Get next byte
	 BRA     G_TFOB2                No:  Keep checking
	 SPC     3
G_TFOW   BSR     G_WAIT                 wait for card ready
G_TFOW1  MOVE.W  (A0)+,4(A1)            Copy word from buffer to GPIO
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TFO3                 IF D3 = 0 then we're done
G_TFOW2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TFOW1                Yes: Get next byte
	 BRA     G_TFOW2                No:  Keep checking
	 SPC     3
G_TFO3   MOVE.L  A0,TEMP_OFF(A3)        SAVE EMPTY PTR
	 CLR.L   TCNT_OFF(A3)           CLEAR COUNT
	 BRA.S   GTFO_TRM
	 SPC     4
	 PAGE
****************************************************
*
*  UNDMA
*
*  Release the DMA channel associated with the GPIO
*  card when the transfer is done.
*
****************************************************
G_DMATERM        EQU *
G_UNDMA  ORI     #$2700,SR              Disable all other interrupts
	 JSR     DROPDMA                Release the DMA channel 475 TM 9/17/82
	 JSR     ITXFR                  See if buf was active   475 TM 9/17/82
	 BEQ.S   G_UNDEND               No: this should never happen
	 TST.B   TDIR_OFF(A3)           Was it an Input (0) or Output (1) ?
	 BEQ.S   UNINPUT
UNOUTPUT MOVE.B  EIRB_OFF(A2),D0
	 AND     #$F,D0
	 BSR     G_WTI5
	 MOVE.W  #$300,2(A1)            Restore REDYN and EIREN
	 TST.B   T_BW_OFF(A3)           Was it a Byte (1) or Word (0) tfr ?
	 BEQ.S   UNOUT2
	 ADD.L   D3,D3                  Word: Double the count
UNOUT2   ADD.L   D3,TEMP_OFF(A3)        UPDATE EMPTY POINTER
	 CLR.L   TCNT_OFF(A3)           CLEAR COUNT
	 JSR     STCLR                  Unbusy the buffer       475 TM 9/17/82
	 RTS
	 SPC     4
UNINPUT  MOVE.L  TCNT_OFF(A3),D0        D0 = Transfer count
* tm     MOVE.L  D4,TCNT_OFF(A3)        SET COUNT TO REMAINING BYTES
	 SUB.L   D4,D0                  GET ACTUAL BYTES TFR'D
	 TST.B   T_BW_OFF(A3)           Was it a Byte (1) or Word (0) tfr ?
	 BEQ.S   UNIN2
	 ADD.L   D0,D0                  Word: Double the count
UNIN2    ADD.L   D0,TFIL_OFF(A3)        UPDATE FILL POINTER
	 MOVE.L  #1,TCNT_OFF(A3)        Last byte is received via interrupt
	 MOVE.W  #$380,2(A1)            Allow it to cause an interrupt
	 MOVE.B  #TT_INT,TACT_OFF(A3)   change tfr type
G_UNDEND RTS
	 TTL IOLIB EXTG - INTERRUPT SERVICE ROUTINE
	 PAGE
*******************************************************
*
*  GPIO INTERRUPT SERVICE ROUTINE
*
*******************************************************
G_ISR    EQU     *
G_ISR1   JSR     ITXFR                  Transfer in progress?   475 TM 9/17/82
	 BNE.S   G_ATFR
G_ISR2   MOVE.B  EIRB_OFF(A2),D0        NO TFR IN PROGRESS
	 AND     #$F,D0
	 BSR     G_WTI5
	 JSR     LOGINT                 log the interrupt       475 TM 9/17/82
GISR_END RTS
	 SPC     4
G_ATFR   MOVE.B  3(A1),D0               Put DMA channel for GPIO in D0
	 AND     #3,D0
	 BNE.S   G_TABORT               If DMA in progress: Abort & update pointers
	 CMP.B   #TT_FHS,D1             \  If FHS then exit
	 BEQ.S   G_TABORT               /
G_ATFR1  SUB.B   #1,D1                  \ IF INTR THEN D1=0
	 LSL.B   #2,D1                  /    BURST THEN D1=8
	 TST.B   T_BW_OFF(A3)           \ IF WORD THEN ADD 4
	 BEQ.S   GTST_DIR               /
	 ADD.B   #4,D1
GTST_DIR TST.B   TDIR_OFF(A3)           \ IF OUTPUT THEN ADD 16
	 BEQ.S   G_ATFR2                /
	 ADD.B   #$10,D1
	 EXT.W   D1
	 EXT.L   D1
G_ATFR2  JMP     G_TTBL(D1)             computed goto
	 SPC     4
G_TTBL   BRA     G_TIIB                 INTR IN BYTE
	 BRA     G_TIIW                 INTR IN WORD
	 BRA     G_TIFB                 BRST IN BYTE
	 BRA     G_TIFW                 BRST IN WORD
	 BRA     G_TOIB                 INTR OUT BYTE
	 BRA     G_TOIW                 INTR OUT WORD
	 BRA     G_TOFB                 BRST OUT BYTE
	 BRA     G_TOFW                 BRST OUT WORD
	 SPC     4
G_TABORT JSR     DROPDMA                Release DMA channel     475 TM 9/17/82
	 BRA     G_TDIN
	 PAGE
**********************************************
*
*       OUTPUT TRANSFERS
*
**********************************************
G_TOFB   ORI     #$2700,SR              Disable interrupts
G_TOFB1  MOVE.B  (A0)+,5(A1)            Copy byte from buffer to GPIO
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TDOUT                If D3 = 0 then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
G_TOFB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TOFB1                Yes: Get next byte
	 BRA     G_TOFB2                No:  Keep checking
	 SPC     4
G_TOFW   ORI     #$2700,SR              Disable interrupts
G_TOFW1  MOVE.W  (A0)+,4(A1)            Copy word from buffer to GPIO
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TDOUT                IF D3 = 0 then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
G_TOFW2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TOFW1                Yes: Get next byte
	 BRA     G_TOFW2                No:  Keep checking
	 SPC     4
G_TOIB   MOVE.B  (A0)+,5(A1)            Copy a byte from buffer to GPIO
	 BRA.S   G_ENDOUT
G_TOIW   MOVE.W  (A0)+,4(A1)            Copy a word from buffer to GPIO
G_ENDOUT MOVE.L  A0,TEMP_OFF(A3)        Save A0 for use on next output byte/word
	 SUBQ.L  #1,D3
	 MOVE.L  D3,TCNT_OFF(A3)        Decrement transfer out counter
	 BLE.S   G_TDOUT                If zero, go thru Transfer Done Out
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger byte out)
	 RTS                            End of ISR
	 SPC     4
G_TDOUT  MOVE.L  A0,TEMP_OFF(A3)        save empty ptr
	 CLR.L   TCNT_OFF(A3)           clear tfr count
	 MOVE.B  #0,3(A1)               Stop card from interrupting
	 MOVE.B  EIRB_OFF(A2),7(A1)     Put EIR byte in CTL1/CTL0
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger last output)
	 JSR     STCLR                  Unbusy buffer           475 TM 9/17/82
	 RTS
	 PAGE
**********************************************
*
*       INPUT TRANSFERS
*
**********************************************
G_TIFB   ORI     #$2700,SR
	 MOVEQ   #0,D0
G_TIFB1  MOVE.B  5(A1),D0               D0.L = Byte received
	 MOVE.B  D0,(A0)+
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   G_TDIN                 If buffer full; exit fast handshake
	 CMP.W   D0,D2                  If input character matches end character
	 BEQ.S   G_TDIN                   then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TIFB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TIFB1                Yes: Get next byte
	 BRA     G_TIFB2                No:  Keep checking
	 SPC     4
G_TIFW   ORI     #$2700,SR              Disable interrupts
G_TIFW1  MOVE    4(A1),(A0)+            Copy word from GPIO to buffer
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   G_TDIN                 If D3 = 0 we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TIFW2  BTST    #0,(A1)                PFLG = 1
	 BNE     G_TIFW1
	 BRA     G_TIFW2                No:  Keep checking
	 SPC     4
G_TIIB   MOVEQ   #0,D0
	 MOVE.B  5(A1),D0               D0.L = Byte received
	 MOVE.B  D0,(A0)+               Store byte in input buffer
	 CMP.W   D0,D2                  Compare termination byte with input byte
	 BNE.S   G_ENDIN                No match: Everybody get out of here !
	 SUBQ.L  #1,D3                  Decrement byte counter
	 MOVE.L  D3,TCNT_OFF(A3)
	 BRA.S   G_TDIN
	 SPC     4
G_TIIW   MOVE    4(A1),(A0)+            Copy word from GPIO to buffer
G_ENDIN  MOVE.L  A0,TFIL_OFF(A3)        Save buffer pointer
	 SUBQ.L  #1,D3
	 MOVE.L  D3,TCNT_OFF(A3)
	 BLE.S   G_TDIN
	 MOVE.B  D0,(A1)                wti 7,0
	 RTS
	 SPC     4
G_TDIN   MOVE.L  A0,TFIL_OFF(A3)        save fill ptr
	 MOVE.L  D3,TCNT_OFF(A3)        save remaining count
	 MOVE.B  #0,3(A1)               Stop card from interrupting
	 MOVE.B  EIRB_OFF(A2),7(A1)     Put EIR byte in CTL1/CTL0
	 JSR     STCLR                  Unbusy buffer           475 TM 9/17/82
	 RTS
	 PAGE
	 END

@


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


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 1066
	TTL IOLIB EXTG - GPIO DRIVERS
	PAGE
********************************************************************************
*
*       COPYRIGHT (C) 1985 BY HEWLETT-PACKARD COMPANY
*
********************************************************************************
*
*
*       IOLIB     EXTG
*
*
********************************************************************************
*
*
*
*       Library - IOLIB
*       Author  - Tim Mikkelsen
*       Phone   - 303-226-3800  ext. 2910
*
*       Purpose - This set of assembly language code is intended to be used as
*                 a PASCAL module for I/O drivers for use by the external I/O
*                 procedures library.
*
*                 Much of this code was taken from Andy Goris' HPL GPIO
*                 drivers.
*
*       Date    - 09/20/81
*       Update  - 04/26/84 BY J Schmidt
*       Release - 07/12/85
*
*
*       Source  - IOLIB:GPIO.TEXT
*       Object  - IOLIB:GPIO.CODE
*
*
********************************************************************************
*
*
*       RELEASED
*       VERSION         3.1
*
*
********************************************************************************
	PAGE
****************************************************************************
*                                                                          *
*                                                                          *
*      BUG FIX HISTORY         - after release 1.0                         *
*                                                                          *
*                                                                          *
*      BUG #   BY  / ON        LOC             DESCRIPTION                 *
*      -----   -----------     --------------  ----------------------      *
*                                                                          *
*      SPR836  T Mikkelsen     G_SET_PCT       a IOCONTROL(x,1,1); does    *
*              08/09/1982                      not set the PCTL line, it   *
*                                              resets the interface.       *
*                                                                          *
*      475     T Mikkelsen     all over        Change BSRs into JSRs to    *
*              09/17/1982                      allow re-placement of the   *
*                                              modules.  Also in HPIB and  *
*                                              Data comm modules.          *
*                                                                          *
*      507     T Mikkelsen     G_TFI           Did not do a trigger to the *
*              09/17/1982                      gpio card before a FHS tfr. *
*                                                                          *
*      508     T Mikkelsen     G_WTC           Typographical error in      *
*              09/17/1982                      write control to CTL0/1.    *
*                                                                          *
*      xxx     T Mikkelsen     G_TFR           Transfer should wait for    *
*              10/06/1982                      card to be ready ( ala the  *
*                                              HPL system ).               *
*                                                                          *
*      yyy     J Schmidt       G_INIT          Changes for timing on       *
*              8/1/83          G_WAIT          680xx UMM CPU boards        *
*              5/2/84          G_STSCHK                                    *
*                                                                          *
*       69     J Schmidt       G_WTC           Missing inst. in set CTL0/1 *
*    (3.0 QA)  4/26/84                                                     *
*                                                                          *
*    SPR12724  J Schmidt       G_TFR           Clear upper byte on byte    *
*              5/3/84                          transfers                   *
****************************************************************************
	PAGE
********************************************************************************
*
*
*       The following lines are used to tell the LINKER/LOADER what this module
*       looks like in PASCAL terms.
*
*       Note that it is possible to create assembly modules that are functions.
*       These routines are called through an indirect pointer using the CALL
*       facility which does NOT permit functions.
*
*       This module is called 'EXTG' ( upper or lower case - doesn't matter )
*       independent of the file name ( by use of the MNAME pseudo-op ).
*
*       All the externally used procedures are called 'EXTG_@@@@@@@@@@@@@@@@' in
*       this module.  If you are using assembly to access them use the
*       'EXTG_@@@@@@@@@@@@@@' name.  If you are using Pascal use the '@@@@@@@@@@@@@@'
*       name.
*
********************************************************************************
	MNAME EXTG
	SRC MODULE EXTG;
	SRC IMPORT iodeclarations;
	SRC EXPORT
	SRC        PROCEDURE eg_init  ( temp : ANYPTR );
	SRC        PROCEDURE eg_isr   ( temp : ANYPTR );
	SRC        PROCEDURE eg_rdb   ( temp : ANYPTR ;  VAR x : CHAR);
	SRC        PROCEDURE eg_wtb   ( temp : ANYPTR ;  val   : CHAR);
	SRC        PROCEDURE eg_rdw   ( temp : ANYPTR ;  VAR x : io_word);
	SRC        PROCEDURE eg_wtw   ( temp : ANYPTR ;  val   : io_word);
	SRC        PROCEDURE eg_rds   ( temp : ANYPTR ;  reg   : io_word;
	SRC                                              VAR x : io_word);
	SRC        PROCEDURE eg_wtc   ( temp : ANYPTR ;  reg   : io_word;
	SRC                                              val   : io_word );
	SRC        PROCEDURE eg_tfr   ( temp : ANYPTR ;  bcb   : ANYPTR );
	SRC        PROCEDURE eg_clr   ( temp : ANYPTR ;  line  : io_bit );
	SRC        PROCEDURE eg_set   ( temp : ANYPTR ;  line  : io_bit );
	SRC        PROCEDURE eg_test  ( temp : ANYPTR ;  line  : io_bit ;
	SRC                                              VAR x : BOOLEAN );
	SRC END; { of EXTG }
	PAGE
********************************************************************************
*
*       SYMBOLS FOR EXPORT AS PROCEDURE NAMES
*
********************************************************************************
	DEF EXTG_EXTG
	SPC 1
	DEF EXTG_EG_INIT
	DEF EXTG_EG_ISR,EXTG_EG_TDMA
	DEF EXTG_EG_RDB,EXTG_EG_WTB
	DEF EXTG_EG_RDW,EXTG_EG_WTW
	DEF EXTG_EG_RDS,EXTG_EG_WTC
	DEF EXTG_EG_TFR
	SPC 1
	DEF EXTG_EG_SET,EXTG_EG_CLR,EXTG_EG_TEST
	SPC 1
********************************************************************************
*
*       SYMBOLS FOR IMPORT
*
********************************************************************************
	REFA STBSY
	REFA STCLR
	REFA ITXFR
	REFA ABORT_IO
	REFA LOGINT
	REFA GETDMA
	REFA DROPDMA
	REFA TESTDMA
	REFA DMA_STBSY
	REFA WAIT_TFR
	REFA CHECK_TFR
	REFA CHECK_TIMER                                       yyyy JS 8/ 1/83
	REFA DELAY_TIMER                                       yyyy JS 8/ 1/83
*
*       change references to allow long jumps when the I/O      475 TM 9/17/82
*       modules get moved around                                475 TM 9/17/82
	LMODE STBSY                                             475 TM 9/17/82
	LMODE STCLR                                             475 TM 9/17/82
	LMODE ITXFR                                             475 TM 9/17/82
	LMODE ABORT_IO                                          475 TM 9/17/82
	LMODE LOGINT                                            475 TM 9/17/82
	LMODE GETDMA                                            475 TM 9/17/82
	LMODE DROPDMA                                           475 TM 9/17/82
	LMODE TESTDMA                                           475 TM 9/17/82
	LMODE DMA_STBSY                                         475 TM 9/17/82
	LMODE WAIT_TFR                                          475 TM 9/17/82
	LMODE CHECK_TFR                                         475 TM 9/17/82
	LMODE CHECK_TIMER                                      yyyy JS 8/ 1/83
	LMODE DELAY_TIMER                                      yyyy JS 8/ 1/83

	TTL IOLIB EXTG - COMMON DECLARATIONS AND EQUATES
	PAGE
	INCLUDE COMDCL
	TTL IOLIB EXTG - PASCAL ENTRY POINTS
********************************************************************************
*
*         PASCAL DRIVER ENTRY POINTS FOR GPIO CARDS
*
********************************************************************************
	  SPC 1
*
*         MODULE initialization
*
EXTG_EXTG EQU *
	  RTS
*
*         Driver initialization
*
EXTG_EG_INIT      EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_INIT
*
*         Interrupt service routine
*
EXTG_EG_ISR       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_ISR
*
*         HPIB DMA transfer termination routine
*
EXTG_EG_TDMA      EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_DMATERM
*
*         Read a byte
*
EXTG_EG_RDB       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_RDB         call read byte ( or word )
	  MOVE.B  D0,(A3)       save character
	  RTS
*
*         Write a byte
*
EXTG_EG_WTB       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.B  (SP)+,D0      get value           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_WTB         call write byte ( or word )
*
*         Read a word
*
EXTG_EG_RDW       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_RDB         call read byte ( or word )
	  MOVE.W  D0,(A3)       save word
	  RTS
*
*         Write a word
*
EXTG_EG_WTW       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D0      get word value
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_WTB         write the byte ( or word )
*
*         Read status
*
EXTG_EG_RDS       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVE.W  (SP)+,D1      get register number
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_RDS         get status
	  MOVE.W  D0,(A3)       save status info
	  RTS
*
*         Write control
*
EXTG_EG_WTC       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D0      get value
	  MOVE.W  (SP)+,D1      get register number
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_WTC         write control
*
*         Transfer
*
EXTG_EG_TFR       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get buffer control block address
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_TFR         transfer
*
*         Set an GPIO line
*
EXTG_EG_SET       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D1      get line           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_SET         call set line
*
*         Clear an GPIO line
*
EXTG_EG_CLR       EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVE.W  (SP)+,D1      get line           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BRA     G_CLR         clear the line
*
*         Test an GPIO line
*
EXTG_EG_TEST      EQU *
	  MOVEA.L (SP)+,A0      get return address
	  MOVEA.L (SP)+,A3      get VAR address
	  MOVE.W  (SP)+,D1      get line           ( this actually bumps SP by 2 )
	  MOVEA.L (SP)+,A2      get temp address
	  MOVEA.L C_ADR(A2),A1  get card address
	  PEA     (A0)          push return address back on stack
	  BSR     G_TEST        read status
	  MOVE.B  D0,(A3)       save character
	  RTS
	  TTL IOLIB EXTG - GPIO DRIVERS
	  PAGE
******************************************
*
*  GPIO INITIALIZATION
*
******************************************
G_INIT   EQU *
G_RESET  JSR     ABORT_IO                                       475 TM 9/17/82
	 MOVE.W  #-1,MA_W(A2)   the card is not addressable - so my addr =-1
	 MOVE.B  D0,1(A1)       Reset the GPIO card
	 MOVE.L  #40,-(SP)         Wait AT LEAST 15 microseconds
	 JSR     DELAY_TIMER    USE DELAY ROUTINE 40 uS       yyyy  JS  8/1/83
	 MOVE.B  #3,2(A1)
	 RTS
	 SPC     6
******************************************
*
*  IOFS
*
******************************************
G_IOFS   MOVEQ   #0,D0
	 BTST    #3,7(A1)    PSTS -> D0<0>
	 BEQ.S   G_IOFS1
	 MOVEQ   #1,D0
G_IOFS1  BTST    #0,(A1)     PFLG -> D0<1>
	 BEQ.S   G_IOFS2
	 ADDQ    #2,D0
G_IOFS2  RTS
	 PAGE
******************************************
*
*  wtb
*
******************************************
G_WTB    BSR.S   G_STSCHK    Check for PSTS
	 BSR.S   G_WAIT      Wait for FLG
	 MOVE.W  D0,4(A1)    Write the word
	 MOVE.B  D0,(A1)     wti 7,0  trigger output
	 RTS
	 SPC     3
******************************************
*
*  rdb
*
******************************************
G_RDB    BSR.S   G_STSCHK    Check for PSTS
	 BSR.S   G_WAIT
	 MOVE.W  4(A1),D0    Set I/O line for input
	 MOVE.B  D0,(A1)     wti 7,0  trigger input
	 BSR.S   G_WAIT      Wait for data to come in
	 MOVE.W  4(A1),D0
	 RTS
	 SPC     6
G_STSCHK BTST    #3,7(A1)    CHECK FOR PSTS OK    yyyy JS 8/1/83
	 BNE.S   G_STSRTS    IF OK THEN RETURN    yyyy JS 8/1/83
	 BTST    #TIMER_PRESENT,SYSFLAG2   TIMER EXISTS?  yyyy JS 8/1/83
	 BEQ.S   G_STS0B     YES, USE IT          yyyy JS 8/1/83
	 MOVE    D0,-(SP)    SAVE D0              yyyy JS 8/1/83
	 MOVE    #22000,D0   SETUP 100MS LOOP     yyyy JS 8/1/83
G_STS0   BTST    #3,7(A1)    Is PSTS O.K. ?
	 BEQ.S   G_STS1      No:  Give him 100 ms
	 MOVE    (SP)+,D0    Yes: Restore D0
G_STSRTS RTS
G_STS1   DBRA    D0,G_STS0   Decrement loop counter
	 BRA     CRD_DOWN    If counter expires, card is down
G_STS0B  MOVE.B  #1,-(SP)    SETUP TIMER RECORD   yyyy JS 8/1/83
	 MOVE.L  #100,-(SP)  LOOP FOR 100 MS      yyyy JS 8/1/83
G_STS0C  BTST    #3,7(A1)    PSTS SET ?           yyyy JS 8/1/83
	 BNE.S   G_STS1B     YES, RETURN          yyyy JS 8/1/83
	 PEA     (SP)        CHECK TIMER          yyyy JS 8/1/83
	 JSR     CHECK_TIMER  SEE IF 100MS GONE   yyyy JS 8/1/83
	 BPL     G_STS0C      NO, CHECK PSTS      yyyy JS 8/1/83
	 BTST    #3,7(A1)     LAST CHANCE TEST    yyyy JS 5/2/84
	 BEQ     CRD_DOWN     IF NOT PSTS, ERROR  yyyy JS 5/2/84
G_STS1B  ADDQ    #6,SP        STRIP TIMER REC     yyyy JS 8/1/83
	 RTS                  AND RETURN          yyyy JS 8/1/83

	 PAGE
******************************************
*
*  GPIO WAIT ROUTINE
*
******************************************
G_WAIT   BTST    #0,(A1)        IF CARD_READY THEN RETURN
	 BNE.S   G_WRTS
	 MOVE.L  TIMEOUT(A2),D1 D1 = (TIMEOUT)
	 BEQ.S   G_WAIT4
	 BTST    #TIMER_PRESENT,SYSFLAG2  GOT A TIMER?    yyyy JS 8/1/83
	 BEQ.S   G_WAIT2B             YES, SO USE IT      yyyy JS 8/1/83
G_WAIT2  EQU     *
* tm     MULU    #182,D1        CONVERT D1 TO MILLISECONDS
	 MOVE.L  D1,D5          \
	 LSL.L   #7,D1           \  * 196 IS CLOSE TO * 182
	 LSL.L   #6,D5           /
	 ADD.L   D5,D1          /
G_WAIT3  BTST    #0,(A1)        WHILE D1 MILLISECONDS HAS NOT EXPIRED DO
	 BNE.S   G_WRTS         IF CARD_READY THEN RETURN
	 SUBQ.L  #1,D1
	 BGT.S   G_WAIT3
G_WAITER MOVEQ   #TMO_ERR,D0    GENERATE ESCAPE
	 BRA.S   ESC_ERR
	 SPC     4
G_WAIT4  BTST    #0,(A1)        IF CARD_READY THEN RETURN
	 BEQ.S   G_WAIT4
G_WRTS   RTS

G_WAIT2B MOVE.B  #1,-(SP)       SETUP TIMER RECORD           yyyy JS 8/1/83
	 MOVE.L  D1,-(SP)       D1 HAS MS TO WAIT            yyyy JS 8/1/83
G_WAIT3B MOVE.L  #364,D1        INNER LOOP TO GET 1 MS AT    yyyy JS 8/1/83
G_WAIT4B BTST    #0,(A1)        16 MHZ -- CHECK FOR READY    yyyy JS 8/1/83
	 BNE.S   G_WAIT5B       READY -- EXIT THE LOOP       yyyy JS 8/1/83
	 SUBQ.L  #1,D1          ELSE LOOP FOR 1-2 MS HERE    yyyy JS 8/1/83
	 BGT     G_WAIT4B                                    yyyy JS 8/1/83
	 PEA     (SP)           AFTER INNER LOOP CHECK TIMER yyyy JS 8/1/83
	 JSR     CHECK_TIMER                                 yyyy JS 8/1/83
	 BPL     G_WAIT3B       BRANCH IF NO TIMEOUT         yyyy JS 8/1/83
	 BTST    #0,(A1)        TIMEOUT -- LAST CHANCE       yyyy JS 5/2/84
	 BEQ     G_WAITER       REAL TIMEOUT IF NOT READY    yyyy JS 5/2/84
G_WAIT5B ADDQ    #6,SP          CLEAN UP STACK               yyyy JS 8/1/83
	 RTS                    DONE                         yyyy JS 8/1/83

	 TTL IOLIB EXTG - ERROR ESCAPES
	 PAGE
********************************************************************************
*
*       Error escapes
*
********************************************************************************
G_SCBSY   MOVEQ  #SC_BUSY,D0            sc is busy
	  BRA.S  ESC_ERR
CRD_DOWN  MOVEQ  #CRD_DWN,D0            CARD IS DOWN
	  BRA.S  ESC_ERR
G_SC_ERR  MOVEQ  #BAD_SCT,D0            bad set/clear/test
	  BRA.S  ESC_ERR
GTERR_B   MOVEQ  #TFR_ERR,D0            bad transfer specification
	  BRA.S  ESC_ERR
GTERR_D   MOVEQ  #NO_DMA,D0             DMA not installed
*         BRA.S  ESC_ERR
	  SPC    4
ESC_ERR   EXT.L  D0                     assume errors<128
	  MOVE.L D0,IOE_RSLT(A5)        save ioe_result
	  MOVE.B IO_SC(A2),D0
	  MOVE.L D0,IOE_SC(A5)          save io s.c.
	  MOVE.W #IOE_ERROR,ESC_CODE(A5)
	  TRAP   #10                    escape
	  TTL IOLIB EXTG - GPIO DRIVERS
	  PAGE
********************************************
*
*       LINE DEFINITIONS
*
*           bit 0       STI0
*               1       STI1
*               2       EIR
*               3       PSTS
*               4       CTL0
*               5       CTL1
*               6       READY
*               7       PCTL
*
********************************************
	SPC 3
********************************************
*
*        SET LINE
*
********************************************
G_SET    AND.B  #7,D1           MASK TO RIGHT SIZE
	 CMP.B  #5,D1           \ HANDLE SET PCTL
	 BEQ.S  GSET_1          /
	 CMP.B  #6,D1           \ CAN ONLY SET
	 BLT.S  G_SC_ERR        /     CTL0/1
	 SUB.B  #5,D1           GET INTO 1/2 FORM
	 OR.B   D1,7(A1)        SET CTL0 or 1
	 OR.B   D1,EIRB_OFF(A2) SAVE IN EIRB
	 RTS
GSET_1   MOVE.B D1,0(A1)        SET PCTL
	 RTS
	 SPC    3
********************************************
*
*        CLEAR LINE
*
********************************************
G_CLR    AND.B  #7,D1           MASK TO RIGHT SIZE
	 CMP.B  #6,D1           \ CAN ONLY CLEAR
	 BLT.S  G_SC_ERR        /     CTL0/1
	 MOVE.B EIRB_OFF(A2),D0 GET OLD CTL0/1
	 SUB.B  #6,D1           GET INTO 0/1 FORM
	 BCLR   D1,D0           CLEAR COPY
	 MOVE.B D0,EIRB_OFF(A2) SAVE IN EIRB
	 MOVE.B D0,7(A1)        WRITE TO CARD
	 RTS
	 SPC    3
********************************************
*
*        TEST LINE
*
********************************************
G_TEST   CLR.W   D0             set FALSE indication
	 AND.B  #7,D1           mask to the right size
	 CMP.B  #7,D1           \ CHECK FOR PCTL
	 BEQ    G_SC_ERR        /       AND GIVE ERROR
	 CMP.B  #3,D1
	 BGT.S  GTST2
GTST1    BTST   D1,7(A1)        TEST ST0/1,EIR,or psts
GTST_CHK BEQ.S  GTST_RTS        if clear then RTS
GTST_SET MOVEQ  #1,D0              else return true indication
GTST_RTS RTS
	 SPC    2
GTST2    SUB.B  #4,D1
	 CMP.B  #1,D1
	 BGT.S  GTST4
GTST3    BTST   D1,EIRB_OFF(A2) TEST CTL0/1
	 BRA.S  GTST_CHK        GO TO COMMON CHECK CODE
	 SPC    2
GTST4    BTST   #0,0(A1)        CHECK READY LINE
	 BRA.S  GTST_CHK
	 PAGE
********************************************************************************
*
*       G_RDS
*
*         READ STATUS
*
*         PASCAL ROUTINE
*
********************************************************************************
G_ROUTINE EQU    2
G_TEMP    EQU    1
G_CRDREG  EQU    0
*
*
G_RDS     LEA    G_RDSTBL,A0            get pointer to lookup table
	  ADD.W  D1,D1                  multiply the rds register by 2
	  CMP.B  #G_RT_SIZ,D1           \ check for out of bounds
	  BGE.S  RDS_ERR                /
	  MOVE.W 0(A0,D1),D0            get the table entry
	  BMI.S  RDS_ERR                if the entry is 0 then error
	  CMP.B  #G_TEMP,D0
* tm      BEQ.S  GR_TEMP
	  BLT.S  GR_CARD
	  LSR    #8,D0                  get the routine offset
	  BEQ.S  G_RDS_DI               -  status rtn 3 - data in
	  SUBQ   #1,D0
	  BEQ.S  G_RDS_RDY              -  status 4 - ready
	  SUBQ   #1,D0
	  BEQ.S  G_RDS_PST              -  status  5 - peripheral status
*         BRA.S  RDS_ERR                there are no more status 'routines'
	  SPC    2
RDS_ERR   MOVEQ  #BAD_RDS,D0            bad read status
	  BRA    ESC_ERR
	  SPC    2
*
*         retrieve temps as words
*
* tm GR_TEMP   LSR    #8,D0                  get temp offset
* tm           MOVE.W 0(A2,D0),D0            get the value
* tm           RTS
	  SPC 3
*
*         retrieve card registers as bytes
*
GR_CARD   LSR    #8,D0                  get the card offset
GR_CARD1  MOVE.B 0(A1,D0),D0            get the value
GREGEXIT  ANDI.W #$00FF,D0              mask off garbage
	  RTS
	  SPC 3
*
*         data in
*
G_RDS_DI  MOVE.W 4(A1),D0               get data lines
	  RTS
	  SPC    3
G_RDS_RDY MOVE.B 0(A1),D0               get ready line
	  ANDI.B #$01,D0                mask to 1 bit
	  BRA    GREGEXIT               and get out
	  SPC    3
G_RDS_PST MOVE.B 7(A1),D0               get status
	  ANDI.B #$0F,D0                mask to 4 bits
	  BRA    GREGEXIT               and get out
	  SPC    4
G_RDSTBL  EQU    *
	  DC.B   1,G_CRDREG             status 0 - card reg  0   - card id
	  DC.B   3,G_CRDREG             status 1 - card reg 3   - intr/dma status
	  DC.B   9,G_ROUTINE            status 2 - not implemented
	  DC.B   0,G_ROUTINE            status 3 - data in
	  DC.B   1,G_ROUTINE            status 4 - ready line
	  DC.B   2,G_ROUTINE            status 5 - peripheral status
G_RT_END  EQU    *
G_RT_SIZ  EQU    G_RT_END-G_RDSTBL      size of table
	  PAGE
********************************************************************************
*
*       G_WTC
*
*         WRITE CONTROL
*
*         ENTRY:  D0.W = PARAMETER
*
********************************************************************************
G_WTC     CMP.W  #6,D1                  \
	  BGE.S  RDS_ERR                / check wtc limits
	  EXT.L  D1
	  ADD.L  D1,D1
	  JMP    GWTCTBL(D1)
	  SPC    2
GWTCTBL   BRA.S  G_WTC_RST              CONTROL 0 - DO A RESET
	  BRA.S  G_SET_PCT              CONTROL 1 - set pctl
	  BRA.S  G_SET_CTL              CONTROL 2 : set control lines
	  BRA.S  G_DATA_O               CONTROL 3 - write data out
	  BRA.S  RDS_ERR                CONTROL 4 : not used
	  BRA.S  G_EIR                  CONTROL 5 : enable intrpts
	  SPC    3
G_WTC_RST BRA    G_INIT                 reset card
	  SPC    2
G_SET_PCT MOVE.B D0,0(A1)               set pctl line           SPR836 TM 8/9/82
	  RTS
	  SPC    2
G_SET_CTL MOVE.B D0,7(A1)               set ctl 0 and 1
	  AND.B  #3,D0                  \ save CTL0/1           508 TM 9/17/82
	  ANDI.B #$FC,EIRB_OFF(A2)      CLEAR CTL0/1     #69 (3.0) JWS 4/26/84
	  OR.B   D0,EIRB_OFF(A2)        / in EIR byte           508 TM 9/17/82
	  RTS
G_DATA_O  MOVE.W D0,4(A1)               write 16 bit data
	  RTS
	  PAGE
*************************************************
*
*  EIR
*
*************************************************
G_EIR    MOVE.B  D0,EIRB_OFF(A2)
	 JSR     ITXFR                                          475 TM 9/17/82
	 BNE.S   G_RTS                  if tfr then don't
G_WTI5   MOVE.B  D0,7(A1)               Update CTL1:CTL0
	 BTST    #5,D0                  Check RESET bit
	 BNE     G_RESET
	 TST.B   D0
	 BGE.S   G_RTS1
	 MOVE.B  #$80,3(A1)
G_RTS    RTS
G_RTS1   MOVE.B  #0,3(A1)
	 RTS
	 TTL IOLIB EXTG - TRANSFER
	 PAGE
*************************************************
*
*  GPIO tfr
*
*************************************************
G_TFR     JSR    CHECK_TFR              wait for tfr to finish  475 TM 9/17/82
	  BSR    G_WAIT                 Wait for FLG            xxx TM 10/6/82
	  MOVE.W #0,4(A1)               CLEAR DATA REG    SPR12724  JS 5/3/84
	  TST.B  TEND_OFF(A3)           \ end NOT ALLOWED
	  BNE    GTERR_B                /
	  MOVE.L TCNT_OFF(A3),D0        GET COUNT
	  CLR.W  D1                     \
	  MOVE.B TUSR_OFF(A3),D1         \   COMPUTE OFFSET INTO JUMP TABLE
	  ADD.W  D1,D1                    \
	  JSR    TESTDMA                  /  BASED ON TFR       475 TM 9/17/82
	  BEQ.S  G_NODMA                 /      TYPE AND DMA PRESENCE
	  ADDI.W #20,D1                 /
G_NODMA   LEA    G_TBL,A0               \
	  ADDA.W 0(A0,D1),A0             INDEXED JUMP THRU TABLE
	  JMP    (A0)                   /
*
*         TRANSFER JUMP TABLE
*
*                               --------------------  DMA is not installed or available
G_TBL     DC.W   GTERR_B-G_TBL  serial  interrupt
	  DC.W   GTERR_D-G_TBL  serial  dma
	  DC.W   G_T_FHS-G_TBL  serial  fhs
	  DC.W   G_T_FHS-G_TBL  serial  fastest
	  DC.W   GTERR_B-G_TBL  serial  overlap
*                               --------------------
	  DC.W   G_T_INT-G_TBL  overlap interrupt
	  DC.W   GTERR_D-G_TBL  overlap dma
	  DC.W   G_T_BST-G_TBL  overlap fhs
	  DC.W   G_T_BST-G_TBL  overlap fastest
	  DC.W   G_T_INT-G_TBL  overlap overlap
*                               --------------------  DMA is installed
	  DC.W   GTERR_B-G_TBL  serial  interrupt
	  DC.W   G_T_DMA-G_TBL  serial  dma
	  DC.W   G_T_FHS-G_TBL  serial  fhs
	  DC.W   G_T_DMA-G_TBL  serial  fastest
	  DC.W   GTERR_B-G_TBL  serial  overlap
*                               --------------------
	  DC.W   G_T_INT-G_TBL  overlap interrupt
	  DC.W   G_T_DMA-G_TBL  overlap dma
	  DC.W   G_T_BST-G_TBL  overlap fhs
	  DC.W   G_T_DMA-G_TBL  overlap fastest
	  DC.W   G_T_DMA-G_TBL  overlap overlap
	  PAGE
*
*         Transfer DMA
*
G_T_DMA   CMP.L  #1,D0                  \ USE INTR IF COUNT=1 ON DMA
	  BEQ    G_T_INT                /
	  MOVE.B #TT_DMA,TACT_OFF(A3)   set tfr type to DMA
	  TST.B  TDIR_OFF(A3)           \ test for transfer direction
	  BGT.S  G_TOD                  /
*
*         Transfer Input Dma:
*
G_TID     EQU     *
	  SUBQ.L  #1,D0                 0 - Set up DMA for Input
	  JSR     GETDMA                Tfr N-1 bytes via DMA   475 TM 9/17/82
	  BTST    #3,3(A1)              Is BURST bit set on GPIO card ?
	  BEQ.S   G_DMA1                No
	  ORI.W   #8,D2                 Yes: Set BURST bit in DMA arm byte
G_DMA1    MOVE    D2,(A4)               Arm DMA
	  BSR     GD_STBSY              Set buffer busy (Card is still not triggered)
	  TST     4(A1)                 rdi 4
	  MOVE.B  D0,(A1)               wti 7,0  (trigger card)
	  MOVE.B  #1,2(A1)              RDYEN = 0 (so transfers won't interrupt)
	  TST.B   T_BW_OFF(A3)          Byte (0) or Word (1) transfers ?
	  BEQ.S   G_DMA3
	  ADD     #4,D3
G_DMA3    MOVE.B  D3,3(A1)              Tell the GPIO what channel he's got and
*                                          watch the shit hit the fan
	  BRA.S  G_DMA_W                DONE
*
*         Transfer Output Dma:
*
G_TOD     EQU     *
G_DMAOUT  JSR     GETDMA                Get a DMA channel       475 TM 9/17/82
	  BTST    #3,3(A1)              Is Burst mode enabled (1)
	  BEQ.S   G_DMA4
	  ORI.W   #8,D2                 Yes: Set the Burst bit in DMA arm byte
G_DMA4    MOVE    D2,(A4)               Arm the DMA channel
	  BSR     GD_STBSY              Set the buffer busy
	  MOVE.B  #1,2(A1)              Disable the transfer interrupt mechanism
	  TST.B   T_BW_OFF(A3)          Byte (1) or Word (0) transfers ?
	  BEQ.S   G_DMA6                Byte: Don't set the WORD bit on GPIO card
	  ORI.W   #4,D3                 WORD: Set the WORD bit
G_DMA6    MOVE.B  D3,3(A1)              Tell the GPIO what channel he's got, etc.
*
*       G_DMA_W                         IF SERIAL THEN WAIT FOR  COMPLETION
*
G_DMA_W   MOVE.B TUSR_OFF(A3),D4        \
	  CMP.B  #5,D4                   IS THE TRANSFER OVERLAP ?
	  BGE.S  G_DMA_W2               /
G_DMA_W1  CMPI.B #255,T_SC_OFF(A3)      IF NOT THEN WAIT TILL DONE
	  BNE.S  G_DMA_W1
G_DMA_W2  RTS
	  SPC    5
GD_STBSY  LEA    EXTG_EG_TDMA,A4        \  save g_dmaterm routine
	  JSR    DMA_STBSY              /  in dma temps         475 TM 9/17/82
	  RTS                                                   475 TM 9/17/82
	  PAGE
*
*         Transfer INTERRUPT
*
G_T_INT   MOVE.B #TT_INT,TACT_OFF(A3)   set tfr type to INTERRUPT
	  BRA.S  G_T_BIC                go to common code
	  SPC    3
*
*         Transfer BURST ( intr on 1st byte FHS on rest )
*
G_T_BST   MOVE.B #TT_BURST,TACT_OFF(A3) set tfr type to BURST
*         BRA.S  G_T_BIC                go to common code
	  SPC    3
*
*         common interrupt and burst code
*
G_T_BIC   JSR    STBSY                  SET BUFFER BUSY, ETC
	  TST.B  TDIR_OFF(A3)           \ test for transfer direction
	  BGT.S  G_TOI                  /
*
*         Transfer Input Interrupt or Transfer Input Burst
*
G_TII     EQU     *
G_INT_I   TST     4(A1)                 Dummy read to set I/O line to I
	  MOVE.B  D0,(A1)               wti 7,0 (trigger input)
*
*         Transfer Output Interrupt or Transfer Output Burst
*
G_TOI     EQU     *
G_INT_O   MOVE.B  #3,2(A1)              Allow I/O to cause an interrupt
	  MOVE.B  EIRB_OFF(A2),D0       GET CTL0/1
	  ORI.B   #$80,D0
	  BSR     G_WTI5                Enable interrupts
	  BRA     G_DMA_W               and wait if necessary
	  PAGE
*
*         Transfer FHS
*
G_T_FHS  MOVE.B #TT_FHS,TACT_OFF(A3)    set tfr type to FHS
	 JSR    STBSY                   set buffer busy         475 TM 9/17/82
	 JSR    ITXFR                   get all pointers        475 TM 9/17/82
	 TST.B  TDIR_OFF(A3)            \ test for transfer direction
	 BGT.S  G_TFO                   /
*
*         Transfer FHS in
*
G_TFI    TST     4(A1)                  to set I/O line to I    507 TM 9/17/82
	 MOVE.B  D0,(A1)                trigger input           507 TM 9/17/82
	 MOVEQ   #0,D0                  clear upper part  of data in
	 MOVEA.L TFIL_OFF(A3),A0        GET FILL POINTER
	 TST.B   T_BW_OFF(A3)           GET B/W INDICATIONS
	 BNE.S   G_TFIW
G_TFIB   BSR     G_WAIT
G_TFIB1  MOVE.B  5(A1),D0               D0.L = Byte received
	 MOVE.B  D0,(A0)+
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   GTFI_TRM               If buffer full; exit fast handshake
	 CMP.W   D0,D2                  If input character matches end character
	 BEQ.S   GTFI_TRM                 then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TFIB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TFIB1                Yes: Get next byte
	 BRA     G_TFIB2                No:  Keep checking
	 SPC     3
G_TFIW   BSR     G_WAIT
G_TFIW1  MOVE    4(A1),(A0)+            Copy word from GPIO to buffer
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   GTFI_TRM               If D3 = 0 we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TFIW2  BTST    #0,(A1)                PFLG = 1
	 BNE     G_TFIW1
	 BRA     G_TFIW2                No:  Keep checking
	 SPC     3
*
* FHS TRANSFER TERMINATION
*
GTFI_TRM MOVE.L  D3,TCNT_OFF(A3)        D3 has bytes not finished
	 MOVE.L  A0,TFIL_OFF(A3)        update fill pointer
GTFO_TRM JSR     STCLR                  MARK BUFFER FINISHED    475 TM 9/17/82
	 RTS
	 SPC     3
*
*         Transfer FHS out
*
G_TFO    MOVEA.L TEMP_OFF(A3),A0        GET EMPTY POINTER
	 TST.B   T_BW_OFF(A3)           GET B/W INDICATIONS
	 BNE.S   G_TFOW
G_TFOB   BSR     G_WAIT                 Wait for card ready
G_TFOB1  MOVE.B  (A0)+,5(A1)            Copy byte from buffer to GPIO
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TFO3                 If D3 = 0 then we're done
G_TFOB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TFOB1                Yes: Get next byte
	 BRA     G_TFOB2                No:  Keep checking
	 SPC     3
G_TFOW   BSR     G_WAIT                 wait for card ready
G_TFOW1  MOVE.W  (A0)+,4(A1)            Copy word from buffer to GPIO
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TFO3                 IF D3 = 0 then we're done
G_TFOW2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TFOW1                Yes: Get next byte
	 BRA     G_TFOW2                No:  Keep checking
	 SPC     3
G_TFO3   MOVE.L  A0,TEMP_OFF(A3)        SAVE EMPTY PTR
	 CLR.L   TCNT_OFF(A3)           CLEAR COUNT
	 BRA.S   GTFO_TRM
	 SPC     4
	 PAGE
****************************************************
*
*  UNDMA
*
*  Release the DMA channel associated with the GPIO
*  card when the transfer is done.
*
****************************************************
G_DMATERM        EQU *
G_UNDMA  ORI     #$2700,SR              Disable all other interrupts
	 JSR     DROPDMA                Release the DMA channel 475 TM 9/17/82
	 JSR     ITXFR                  See if buf was active   475 TM 9/17/82
	 BEQ.S   G_UNDEND               No: this should never happen
	 TST.B   TDIR_OFF(A3)           Was it an Input (0) or Output (1) ?
	 BEQ.S   UNINPUT
UNOUTPUT MOVE.B  EIRB_OFF(A2),D0
	 AND     #$F,D0
	 BSR     G_WTI5
	 MOVE.W  #$300,2(A1)            Restore REDYN and EIREN
	 TST.B   T_BW_OFF(A3)           Was it a Byte (1) or Word (0) tfr ?
	 BEQ.S   UNOUT2
	 ADD.L   D3,D3                  Word: Double the count
UNOUT2   ADD.L   D3,TEMP_OFF(A3)        UPDATE EMPTY POINTER
	 CLR.L   TCNT_OFF(A3)           CLEAR COUNT
	 JSR     STCLR                  Unbusy the buffer       475 TM 9/17/82
	 RTS
	 SPC     4
UNINPUT  MOVE.L  TCNT_OFF(A3),D0        D0 = Transfer count
* tm     MOVE.L  D4,TCNT_OFF(A3)        SET COUNT TO REMAINING BYTES
	 SUB.L   D4,D0                  GET ACTUAL BYTES TFR'D
	 TST.B   T_BW_OFF(A3)           Was it a Byte (1) or Word (0) tfr ?
	 BEQ.S   UNIN2
	 ADD.L   D0,D0                  Word: Double the count
UNIN2    ADD.L   D0,TFIL_OFF(A3)        UPDATE FILL POINTER
	 MOVE.L  #1,TCNT_OFF(A3)        Last byte is received via interrupt
	 MOVE.W  #$380,2(A1)            Allow it to cause an interrupt
	 MOVE.B  #TT_INT,TACT_OFF(A3)   change tfr type
G_UNDEND RTS
	 TTL IOLIB EXTG - INTERRUPT SERVICE ROUTINE
	 PAGE
*******************************************************
*
*  GPIO INTERRUPT SERVICE ROUTINE
*
*******************************************************
G_ISR    EQU     *
G_ISR1   JSR     ITXFR                  Transfer in progress?   475 TM 9/17/82
	 BNE.S   G_ATFR
G_ISR2   MOVE.B  EIRB_OFF(A2),D0        NO TFR IN PROGRESS
	 AND     #$F,D0
	 BSR     G_WTI5
	 JSR     LOGINT                 log the interrupt       475 TM 9/17/82
GISR_END RTS
	 SPC     4
G_ATFR   MOVE.B  3(A1),D0               Put DMA channel for GPIO in D0
	 AND     #3,D0
	 BNE.S   G_TABORT               If DMA in progress: Abort & update pointers
	 CMP.B   #TT_FHS,D1             \  If FHS then exit
	 BEQ.S   G_TABORT               /
G_ATFR1  SUB.B   #1,D1                  \ IF INTR THEN D1=0
	 LSL.B   #2,D1                  /    BURST THEN D1=8
	 TST.B   T_BW_OFF(A3)           \ IF WORD THEN ADD 4
	 BEQ.S   GTST_DIR               /
	 ADD.B   #4,D1
GTST_DIR TST.B   TDIR_OFF(A3)           \ IF OUTPUT THEN ADD 16
	 BEQ.S   G_ATFR2                /
	 ADD.B   #$10,D1
	 EXT.W   D1
	 EXT.L   D1
G_ATFR2  JMP     G_TTBL(D1)             computed goto
	 SPC     4
G_TTBL   BRA     G_TIIB                 INTR IN BYTE
	 BRA     G_TIIW                 INTR IN WORD
	 BRA     G_TIFB                 BRST IN BYTE
	 BRA     G_TIFW                 BRST IN WORD
	 BRA     G_TOIB                 INTR OUT BYTE
	 BRA     G_TOIW                 INTR OUT WORD
	 BRA     G_TOFB                 BRST OUT BYTE
	 BRA     G_TOFW                 BRST OUT WORD
	 SPC     4
G_TABORT JSR     DROPDMA                Release DMA channel     475 TM 9/17/82
	 BRA     G_TDIN
	 PAGE
**********************************************
*
*       OUTPUT TRANSFERS
*
**********************************************
G_TOFB   ORI     #$2700,SR              Disable interrupts
G_TOFB1  MOVE.B  (A0)+,5(A1)            Copy byte from buffer to GPIO
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TDOUT                If D3 = 0 then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
G_TOFB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TOFB1                Yes: Get next byte
	 BRA     G_TOFB2                No:  Keep checking
	 SPC     4
G_TOFW   ORI     #$2700,SR              Disable interrupts
G_TOFW1  MOVE.W  (A0)+,4(A1)            Copy word from buffer to GPIO
	 SUBQ.L  #1,D3                  Decrement transfer count
	 BLE.S   G_TDOUT                IF D3 = 0 then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next output)
G_TOFW2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TOFW1                Yes: Get next byte
	 BRA     G_TOFW2                No:  Keep checking
	 SPC     4
G_TOIB   MOVE.B  (A0)+,5(A1)            Copy a byte from buffer to GPIO
	 BRA.S   G_ENDOUT
G_TOIW   MOVE.W  (A0)+,4(A1)            Copy a word from buffer to GPIO
G_ENDOUT MOVE.L  A0,TEMP_OFF(A3)        Save A0 for use on next output byte/word
	 SUBQ.L  #1,D3
	 MOVE.L  D3,TCNT_OFF(A3)        Decrement transfer out counter
	 BLE.S   G_TDOUT                If zero, go thru Transfer Done Out
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger byte out)
	 RTS                            End of ISR
	 SPC     4
G_TDOUT  MOVE.L  A0,TEMP_OFF(A3)        save empty ptr
	 CLR.L   TCNT_OFF(A3)           clear tfr count
	 MOVE.B  #0,3(A1)               Stop card from interrupting
	 MOVE.B  EIRB_OFF(A2),7(A1)     Put EIR byte in CTL1/CTL0
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger last output)
	 JSR     STCLR                  Unbusy buffer           475 TM 9/17/82
	 RTS
	 PAGE
**********************************************
*
*       INPUT TRANSFERS
*
**********************************************
G_TIFB   ORI     #$2700,SR
	 MOVEQ   #0,D0
G_TIFB1  MOVE.B  5(A1),D0               D0.L = Byte received
	 MOVE.B  D0,(A0)+
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   G_TDIN                 If buffer full; exit fast handshake
	 CMP.W   D0,D2                  If input character matches end character
	 BEQ.S   G_TDIN                   then we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TIFB2  BTST    #0,(A1)                PFLG = 1 ?
	 BNE     G_TIFB1                Yes: Get next byte
	 BRA     G_TIFB2                No:  Keep checking
	 SPC     4
G_TIFW   ORI     #$2700,SR              Disable interrupts
G_TIFW1  MOVE    4(A1),(A0)+            Copy word from GPIO to buffer
	 SUBQ.L  #1,D3                  Decrement transfer counter
	 BLE.S   G_TDIN                 If D3 = 0 we're done
	 MOVE.B  D0,(A1)                wti 7,0 (Trigger next input)
G_TIFW2  BTST    #0,(A1)                PFLG = 1
	 BNE     G_TIFW1
	 BRA     G_TIFW2                No:  Keep checking
	 SPC     4
G_TIIB   MOVEQ   #0,D0
	 MOVE.B  5(A1),D0               D0.L = Byte received
	 MOVE.B  D0,(A0)+               Store byte in input buffer
	 CMP.W   D0,D2                  Compare termination byte with input byte
	 BNE.S   G_ENDIN                No match: Everybody get out of here !
	 SUBQ.L  #1,D3                  Decrement byte counter
	 MOVE.L  D3,TCNT_OFF(A3)
	 BRA.S   G_TDIN
	 SPC     4
G_TIIW   MOVE    4(A1),(A0)+            Copy word from GPIO to buffer
G_ENDIN  MOVE.L  A0,TFIL_OFF(A3)        Save buffer pointer
	 SUBQ.L  #1,D3
	 MOVE.L  D3,TCNT_OFF(A3)
	 BLE.S   G_TDIN
	 MOVE.B  D0,(A1)                wti 7,0
	 RTS
	 SPC     4
G_TDIN   MOVE.L  A0,TFIL_OFF(A3)        save fill ptr
	 MOVE.L  D3,TCNT_OFF(A3)        save remaining count
	 MOVE.B  #0,3(A1)               Stop card from interrupting
	 MOVE.B  EIRB_OFF(A2),7(A1)     Put EIR byte in CTL1/CTL0
	 JSR     STCLR                  Unbusy buffer           475 TM 9/17/82
	 RTS
	 PAGE
	 END

@


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