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


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

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

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

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

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

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

52.1
date     91.02.19.09.11.07;  author jwh;  state Exp;
branches ;
next     51.14;

51.14
date     91.02.16.11.17.40;  author jwh;  state Exp;
branches ;
next     51.13;

51.13
date     91.02.16.10.55.03;  author jwh;  state Exp;
branches ;
next     51.12;

51.12
date     91.02.16.10.50.07;  author jwh;  state Exp;
branches ;
next     51.11;

51.11
date     91.02.15.20.19.08;  author jwh;  state Exp;
branches ;
next     51.10;

51.10
date     91.02.15.20.04.25;  author jwh;  state Exp;
branches ;
next     51.9;

51.9
date     91.02.15.16.33.01;  author jwh;  state Exp;
branches ;
next     51.8;

51.8
date     91.02.15.15.58.42;  author jwh;  state Exp;
branches ;
next     51.7;

51.7
date     91.02.15.15.55.53;  author jwh;  state Exp;
branches ;
next     51.6;

51.6
date     91.02.14.13.42.54;  author jwh;  state Exp;
branches ;
next     51.5;

51.5
date     91.02.14.13.06.18;  author jwh;  state Exp;
branches ;
next     51.4;

51.4
date     91.02.14.13.01.13;  author jwh;  state Exp;
branches ;
next     51.3;

51.3
date     91.02.14.12.39.01;  author jwh;  state Exp;
branches ;
next     51.2;

51.2
date     91.02.13.16.12.39;  author jwh;  state Exp;
branches ;
next     51.1;

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

50.1
date     90.10.29.16.25.32;  author jwh;  state Exp;
branches ;
next     49.3;

49.3
date     90.09.25.10.19.28;  author jwh;  state Exp;
branches ;
next     49.2;

49.2
date     90.09.24.15.09.32;  author jwh;  state Exp;
branches ;
next     49.1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2.1
date     86.07.30.14.41.40;  author hal;  state Exp;
branches ;
next     1.2;

1.2
date     86.06.06.16.50.33;  author danm;  state Exp;
branches ;
next     1.1;

1.1
date     86.04.11.17.51.13;  author paws;  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 IOCOMASM - common assembly routines
	PAGE
********************************************************************************
*
*       COPYRIGHT (C) 1985, 1985 BY HEWLETT-PACKARD COMPANY
*
********************************************************************************
*
*
*       IOLIB     IOCOMASM
*
*
********************************************************************************
*
*
*
*       Library - IOLIB
*       Module  - IOCOMASM
*       Author  - Tim Mikkelsen
*       Phone   - 303-226-3800  ext. 2910
*
*       Purpose - This set of assembly language
*                 code is intended to be used as
*                 a support module for I/O drivers
*
*       Date    - 08/18/81
*       Update  - 03/25/85
*       Release -  7/12/85
*
*
*       Source  - IOLIB:COMASM.TEXT
*       Object  - IOLIB:COMASM.CODE
*
*
********************************************************************************
*
*
*        RELEASED
*       VERSION         3.1
*
*
********************************************************************************
	  PAGE
********************************************************************************
*
*       PASCAL DEFINITION OF MODULE
*
********************************************************************************
	  MNAME IOCOMASM
	  SRC MODULE IOCOMASM;
	  SRC IMPORT iodeclarations;
	  SRC EXPORT
	  SRC     FUNCTION  dma_request ( temp   : ANYPTR ) : INTEGER;
	  SRC     PROCEDURE dma_release ( temp   : ANYPTR );
	  SRC     FUNCTION  bit_set     ( v : INTEGER ;
	  SRC                             b : INTEGER ) : BOOLEAN ;
	  SRC     FUNCTION  binand      ( x : INTEGER ;
	  SRC                             y : INTEGER ) : INTEGER ;
	  SRC     FUNCTION  binior      ( x : INTEGER ;
	  SRC                             y : INTEGER ) : INTEGER ;
	  SRC     FUNCTION  bineor      ( x : INTEGER ;
	  SRC                             y : INTEGER ) : INTEGER ;
	  SRC     FUNCTION  bincmp      ( x : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binasr ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binasl ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binlsr ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binlsl ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC END; { IOCOMASM }
	  SPC 5
	  DEF IOCOMASM_iocomasm
	  DEF IOCOMASM_dma_request
	  DEF IOCOMASM_dma_release
	  DEF IOCOMASM_bit_set
	  DEF IOCOMASM_binand
	  DEF IOCOMASM_binior
	  DEF IOCOMASM_bineor
	  DEF IOCOMASM_bincmp
	  DEF IOCOMASM_binasr
	  DEF IOCOMASM_binasl
	  DEF IOCOMASM_binlsr
	  DEF IOCOMASM_binlsl
	  PAGE
********************************************************************************
*
*       SYMBOLS FOR EXPORT - COMMON ASSEMBLY LANGUAGE ROUTINES
*
*       THE SYMBOLS DO NOT HAVE PASCAL ENTRY
*       POINTS SINCE THEY ARE ONLY USED BY
*       ASSEMBLY LANGUAGE MODULES OR WITH EXTERNAL DECLARATIONS
*
********************************************************************************
	  DEF  DROPDMA
	  DEF  GETDMA
	  DEF  TESTDMA
	  DEF  LOGINT
	  DEF  LOGEOT
	  DEF  STBSY
	  DEF  STCLR
	  DEF  DMA_STBSY
	  DEF  ITXFR
	  DEF  ABORT_IO
	  DEF  WAIT_TFR
	  DEF  CHECK_TFR
	  DEF  TIMEREXISTS    USED AS PASCAL EXTERNAL PROC
	  DEF  TIMED_OUT      USED AS PASCAL EXTERNAL PROC
	  SPC  3
*
*****************************************************************************
*
*          IMPORTED SYMBOLS
*
*****************************************************************************
*
	  REFA   CHECK_TIMER    USED TO GET AT TIMER ROUTINE IN POWERUP
	  REFA   ASM_FLUSH_ICACHE   USED TO FLUSH 68020 AFTER DMA XFR
*  JWH  9/24/90 :
	  LMODE  CHECK_TIMER
	  LMODE  ASM_FLUSH_ICACHE
	  LMODE  save_dtt1          jwh 9/24/90
	  TTL IOLIB IOCOMASM - pascal binary functions
	  PAGE
*
*       module initialization
*
IOCOMASM_IOCOMASM EQU *
	  RTS
*
*       bit test
*
IOCOMASM_BIT_SET  EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get bit #
	  MOVE.L  (SP)+,D1              get numeric value
	  CLR.B   D2                    clear indicator
	  BTST    D0,D1                 test bit in value
	  BEQ.S   BITT_EXIT
	  MOVEQ   #1,D2                 if bit set set indicator
BITT_EXIT MOVE.B  D2,(SP)               push result
	  JMP     (A0)                  return
*
*       binary and
*
IOCOMASM_BINAND   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get last param
	  MOVE.L  (SP)+,D1              get first param
	  AND.L   D0,D1                 perform AND
	  MOVE.L  D1,(SP)               push result
	  JMP     (A0)                  return
*
*       binary inclusive or
*
IOCOMASM_BINIOR   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get last param
	  MOVE.L  (SP)+,D1              get first param
	  OR.L    D0,D1                 perform OR
	  MOVE.L  D1,(SP)               push result
	  JMP     (A0)                  return
*
*       binary exclusive or
*
IOCOMASM_BINEOR   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get last param
	  MOVE.L  (SP)+,D1              get first param
	  EOR.L   D0,D1                 perform XOR
	  MOVE.L  D1,(SP)               push result
	  JMP     (A0)                  return
*
*       binary complement
*
IOCOMASM_BINCMP   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get param
	  NOT.L   D0                    perform complement
	  MOVE.L  D0,(SP)               push result
	  JMP     (A0)                  return
	  SPC     5
	  TTL IOLIB IOCOMASM - common equates and definitions
	  PAGE
	  INCLUDE IOLIB:COMDCL
	  TTL IOLIB IOCOMASM - error escape
	  PAGE
********************************************************************************
*
*       Error escapes
*
********************************************************************************
CTMO_ERR  MOVEQ  #TMO_ERR,D0            timeout
	  BRA.S  ESC_ERR
TERR_C    MOVEQ  #TCNTERR,D0            bad transfer specification
	  BRA.S  ESC_ERR
TERR_B    MOVEQ  #TFR_ERR,D0            bad transfer specification
	  BRA.S  ESC_ERR
TERR_D    MOVEQ  #NO_DMA,D0             DMA not installed
*         BRA.S  ESC_ERR
	  SPC    4
ESC_ERR   EXT.L  D0
	  MOVE.L D0,IOE_RSLT(A5)        save io error
	  MOVE.B IO_SC(A2),D0           \ get sc for error
	  MOVE.L D0,IOE_SC(A5)          /
	  MOVE.W #IOE_ERROR,ESC_CODE(A5)  give i/o error
	  TRAP   #10                    escape
	  TTL IOLIB IOCOMASM - transfer support
	  PAGE
********************************************************************************
*
*       ABORT_IO
*
*         USED DURING INITIALIZATION/RESET TO MAKE SURE THERE
*                IS NO ACTIVE BUFFER LEFT AROUND.
*
*         ENTRY:  A2.L = TEMP POINTER
*
*         USES:   D1,D2,D3  AND ROUTINE DROPDMA (WHICH USES A0)
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
ABORT_IO  TRAP  #11                     GET INTO SUPERVISOR MODE, SAVE SR  scs
* scs     MOVE    SR,-(SP)              \ PREVENT INTERRUPTS FOR A MOMENT.
	  ORI     #$2700,SR             /
ABORT_IO3 BSR     ITXFR                 IS THERE A TRANSFER IN PROGRESS?
	  BEQ.S   ABORT_IO2             IF NOT, DO NOTHING
	  CMP.B   #TT_DMA,D1            ELSE IS IT A DMA?
	  BEQ.S   ABORT_IO1             IF NOT, SKIP
	  BSR     DROPDMA               ELSE FREE UP THE DMA CH, GET COUNT
	  MOVE.L  D4,TCNT_OFF(A3)       fix up count
	  SUB.L   D4,D3                 fix up actual count
	  TST.B   TDIR_OFF(A3)
	  BNE.S   AB_OUT
	  ADD.L   D3,TFIL_OFF(A3)       if input then update fill
	  BRA.S   ABORT_IO1
AB_OUT    ADD.L   D3,TEMP_OFF(A3)       if output then update empty
ABORT_IO1 MOVE.B  #255,T_SC_OFF(A3)     UNBUSY THE BUFFER
	  CLR.B   TACT_OFF(A3)          SET TRANSFER TYPE TO NONE
	  CLR.L   (A4)                  clear buffer ptr
	  BRA     ABORT_IO3             see if there is another
ABORT_IO2 MOVE  (SP)+,SR                RESTORE USER MODE               scs
	  RTS                                                           scs
* scs     RTE                           RESTORE INTERRUPT LEVEL & RETURN
	  PAGE
********************************************************************************
*
*       CHECK_TFR
*
*         ROUTINE TO CHECK FOR ACTIVE TRANSFER IN THE OPPOSITE DIRECTION.
*               ( this is called by a tfr routine on cards
*                 that can't do bi-directional tfrs )
*               ( gpio and hpib modules use this routine )
*               ( with a timeout wait )
*
*         ENTRY:  A2.L = TEMP POINTER
*                 A3.L = BUF CTL BLK POINTER
*
*         EXIT :  IF NOT TRANSFER, RETURN
*                 IF     TRANSFER, THEN wait until finished
*                                       or   until timeout ( if any )
*
********************************************************************************
CHECK_TFR TST.B   TDIR_OFF(A3)          base test on direction
	  BNE.S   CHKT_IN               ( if this is in , check out )
CHKT_OUT  LEA     BUFO_OFF(A2),A4       IS THERE  AN output  BUFFER ACTIVE?
	  MOVE.L  (A4),D1
	  BRA.S   CHKWAIT               IF SO , THEN WAIT
	  SPC     2
CHKT_IN   LEA     BUFI_OFF(A2),A4       is there an input  tfr
	  MOVE.L  (A4),D1
*         BRA.S   CHKWAIT
	  SPC     3
CHKWAIT   BEQ.S   CHKEXIT               exit if no tfr
	  MOVE.L  TIMEOUT(A2),D2        get timeout value
	  BEQ.S   CHECK_TFR             if timeout = 0 then try forever
	  BTST    #TIMER_PRESENT,SYSFLAG2   CHECK IF TIMER PRESENT   JS 8/3/83
	  BEQ.S   CHKT_TIM              IF SO THEN USE IT            JS 8/3/83
	  LSL.L   #8,D2
CHKLOOP   MOVE.L  (A4),D1               check the buffer again
	  BEQ.S   CHKEXIT               if finished in time then return
	  SUBQ.L  #1,D2                 decrement
	  BNE.S   CHKLOOP
	  BRA     CTMO_ERR
CHKEXIT   RTS
	  SPC     3
CHKT_TIM  MOVE.B  #1,-(SP)              SET UP TIMER RECORD          JS 8/3/83
	  MOVE.L  D2,-(SP)                                           JS 8/3/83
CHKT_TIM1 MOVE.L  (A4),D1               TRANSFER ACTIVE ?            JS 8/3/83
	  BEQ.S   CHKT_TIM2             NO -- EXIT                   JS 8/3/83
	  PEA     (SP)                  ELSE CHECK TIMER             JS 8/3/83
	  JSR     CHECK_TIMER                                        JS 8/3/83
	  BPL     CHKT_TIM1             BRANCH IF NOT TIMED OUT      JS 8/3/83
	  BRA     CTMO_ERR              ELSE DO TIMEOUT ESCAPE       JS 8/3/83
CHKT_TIM2 ADDQ.L  #6,SP                 CLEAN TIMER RECORD FROM STACK JS 8/3/83
	  RTS                           AND RETURN                   JS 8/3/83
	  PAGE
********************************************************************************
*
*       WAIT_TFR
*
*         ROUTINE TO CHECK FOR ACTIVE TRANSFER.
*               ( with a timeout wait )
*
*         ENTRY:  A2.L = TEMP POINTER
*
*         EXIT :  IF NOT TRANSFER, RETURN
*                 IF     TRANSFER, THEN wait until finished
*                                       or   until timeout ( if any )
*
*         USES:   NO REGS OTHER THAN RETURN VALUES.
*
*
********************************************************************************
WAIT_TFR  BSR    ITXFR                  quick check for tfr
	  BEQ.S  WT_DONE                and exit
	  MOVE.L TIMEOUT(A2),D6         get timeout value
	  BEQ.S  WAIT_TFR               if timeout = 0 then try forever
	  BTST   #TIMER_PRESENT,SYSFLAG2 IF TIMER PRESENT USE IT   JS 8/3/83
	  BEQ.S  WT_TIM                  BRANCH IF WE HAVE IT      JS 8/3/83
	  LSL.L  #5,D6
WT_LOOP   BSR.S  ITXFR                  try
	  BEQ.S  WT_DONE                if finished in time then return
	  SUBQ.L #1,D6                  decrement
	  BNE.S  WT_LOOP
	  BRA    CTMO_ERR
WT_DONE   RTS
	  SPC    3
WT_TIM    MOVE.B #1,-(SP)              SET UP TIMER RECORD          JS 8/3/83
	  MOVE.L D6,-(SP)                                           JS 8/3/83
WT_TIM1   BSR.S  ITXFR                 CHECK FOR ACTIVE TRANSFER    JS 8/3/83
	  BEQ.S  WT_TIM2               NONE -- EXIT                 JS 8/3/83
	  PEA    (SP)                  CHECK TIMER                  JS 8/3/83
	  JSR    CHECK_TIMER                                        JS 8/3/83
	  BPL    WT_TIM1               LOOK AGAIN IF NOT TIMED OUT  JS 8/3/83
	  BRA    CTMO_ERR              ELSE DO TIMEOUT ESCAPE       JS 8/3/83
WT_TIM2   ADDQ.L #6,SP                 CLEAN UP TIMER RECORD        JS 8/3/83
	  RTS                          AND RETURN                   JS 8/3/83
	  PAGE
********************************************************************************
*
*       ITXFR
*
*         ROUTINE TO CHECK FOR ACTIVE TRANSFER.
*
*         ENTRY:  A2.L = TEMP POINTER
*
*         EXIT :  IF NOT TRANSFER, RET with zero flag  set
*                 IF     TRANSFER, RET with not zero
*                    D1.W = ACTUAL TFR TYPE
*                    D2.W = TERMINATING CHAR FROM TEMPS
*                    D3.L = TRANSFER COUNT FROM TEMPS
*                    A0.L = DATA POINTER FROM TEMPS ( either emtpy or fill )
*                    A3.L = BUF CTL BLK POINTER FROM TEMPS
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
ITXFR     LEA     BUFI_OFF(A2),A4       IS THERE  AN input  BUFFER ACTIVE?
	  MOVE.L  (A4),D1
	  BNE.S   ITXFR3                IF NOT, SKIP
	  LEA     BUFO_OFF(A2),A4       is there an output tfr
	  MOVE.L  (A4),D1
	  BEQ.S   ITXFR1                   -no
ITXFR3    MOVEA.L D1,A3                 \
	  CLR.L   D1                      ELSE GET BUFFER TYPE WORD
	  MOVE.B  TACT_OFF(A3),D1       /
	  CLR.L   D2
	  MOVE.W  TCHR_OFF(A3),D2       GET TERMINATING CHAR
	  MOVE.L  TCNT_OFF(A3),D3       GET COUNT
	  MOVEA.L TEMP_OFF(A3),A0       GET EMPTY POINTER
	  TST.B   TDIR_OFF(A3)          check direction
	  BNE.S   ITXFR2                \ IF INPUT
	  MOVEA.L TFIL_OFF(A3),A0       /    THEN GET FILL POINTER
ITXFR2    MOVEQ   #1,D5                 set not zero
STCLR1    EQU     *
ITXFR1    RTS
	  PAGE
********************************************************************************
*
*       STCLR
*
*         ROUTINE TO SET A BUFFER & SELECT CODE NOT BUSY
*
*         ENTRY:  gets buf ptr from ITXFR routine
*
*                 assumes only one tfr per select code
*
*         USES:   A3,D0
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
STCLR     BSR     ITXFR                 GET BUFFER POINTER FROM TEMPS
	  BEQ.S   STCLR1                IF ALREADY CLEAR, SKIP
	  MOVE.B  #255,T_SC_OFF(A3)     CLEAR S.C. INDICATOR IN THE BUF CTL BLK
	  CLR.B   TACT_OFF(A3)          clear tfr type
	  CLR.L   (A4)                  CLEAR BUF POINTER    IN SC TEMPS
*RTS
	  SPC     5
********************************************************************************
*
*       LOGEOT
*
*         CALL THE USER PROC AT END OF TRANSFER
*
*         PASCAL ROUTINE
*
*         modified to pass a user parameter:  JPC  02/22/82
*
********************************************************************************
LOGEOT    LEA     T_PR_OFF(A3),A0       point to procedure/static link/parameter

H_EOT1    MOVE.L  (A0),D0               is there a proc?
	  BEQ.S   H_EOT3                skip if not

	  MOVEM.L A1-A4,-(SP)           save dedicated regs      (8/10/82 JPC)
	  MOVE.L  8(A0),-(SP)           push the parameter
	  MOVE.L  4(A0),D1              is there a static link?
	  BEQ.S   H_EOT2                Roger Ison says it is okay to try
	  MOVE.L  D1,-(SP)                    and call proc with static link
H_EOT2    MOVEA.L D0,A0                 procedure address
	  JSR     (A0)                  call it
	  MOVEM.L (SP)+,A1-A4           restore dedicated regs   (8/10/82 JPC)

H_EOT3    RTS

	  PAGE
********************************************************************************
*
*       LOGINT
*
*         THIS ROUTINE WAS CALLED H_LOG
*
*         CALL THE USER PROC WHEN AN ISR SAYS TO
*
*         PASCAL ROUTINE
*
*         modified to pass a user parameter:  JPC  02/22/82
*
********************************************************************************
LOGINT    LEA     H_ISR_PR(A2),A0       point to procedure/static link/parameter
	  BRA     H_EOT1                call it (if it exists)
	  PAGE
********************************************************************************
*
*       DMA_STBSY
*
*         ROUTINE TO SET A BUFFER BUSY
*
*         ENTRY:
*                 D0.W = TRANSFER COUNT TO BE PUT IN TCNT_OFF(A2)
*                        AND TO BE ADDED TO E/F COUNT.
*                 A0.L = pointer to DMA temps
*                 A2.L = POINTER TO DRIVER TEMPS
*                 A3.L = POINTER TO BUFFER CTL BLOCK
*                 A4.L = POINTER TO TERMINATION ROUTINE
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
DMA_STBSY MOVE.L A4,DMAISR(A0)          SAVE THE TERMINATION ROUTINE
	  CLR.L  DMASL(A0)              CLEAR THE STATIC LINK
*         BRA.S  STBSY                  SET THE BUFFER BUSY
	  SPC    5
********************************************************************************
*
*       STBSY
*
*         ROUTINE TO SET A BUFFER BUSY
*
*         ENTRY:
*                 D0.W = TRANSFER COUNT TO BE PUT IN TCNT_OFF(A2)
*                        AND TO BE ADDED TO E/F COUNT.
*                 A2.L = POINTER TO DRIVER TEMPS
*                 A3.L = POINTER TO BUFFER CTL BLOCK
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
STBSY     MOVE.L D0,TCNT_OFF(A3)        COPY TFR COUNT INTO TEMPS.
	  TST.B  TDIR_OFF(A3)           \
	  BNE.S  STBSY1                  \
	  MOVE.L A3,BUFI_OFF(A2)           MAKE SELECT CODE BUSY
	  BRA.S  STBSY2                  /
STBSY1    MOVE.L A3,BUFO_OFF(A2)        /
STBSY2    MOVE.B IO_SC(A2),T_SC_OFF(A3) SET UP BUFFER ACTIVE SELECT CODE
	  RTS                           DONE!
	  TTL IOLIB IOCOMASM - dma support
	  PAGE
********************************************************************************
*
*       DMA RESOURCE MANAGEMENT ROUTINES
*
*
********************************************************************************
	  SPC 3
********************************************************************************
*
*       DMA RESOURCE temporaries
*
*         These resource temporaries need to be aligned with the offsets
*         generated by the main Pascal library.  This is not an automatic
*         operation - it must be done by hand if ANY new declarations are
*         added in the iodeclarations in front of the dma resource temps.
*
********************************************************************************
DMAFLAG   EQU    iodeclarations-61      boolean indicating presence of dma hardware
	  SPC    2
DMA0      EQU    iodeclarations-8
DMAISR_0  EQU    iodeclarations-8       \
DMASL_0   EQU    iodeclarations-4         channel 0 temps
DMA_SC_0  EQU    iodeclarations-9       /
	  SPC    2
DMA1      EQU    iodeclarations-18
DMAISR_1  EQU    iodeclarations-18      \
DMASL_1   EQU    iodeclarations-14        channel 1 temps
DMA_SC_1  EQU    iodeclarations-19      /
	  SPC    2
DMAISR    EQU    0                      isr pointer
DMASL     EQU    4                      static link
DMA_SC    EQU    -1                     allocated s.c.
	  SPC    2
DMACH0    EQU    $500000                address of dma channel 0
DMACH1    EQU    $500008                address of dma channel 1
********************************************************************************
*
*       ADDRESS CONSTANTS
*
********************************************************************************
H_INT_CA  EQU    $478000                ADDRESS OF INTERNAL HPIB INTERFACE
	  TTL IOLIB IOCOMASM - pascal dma procedures
	  PAGE
*
*       request a dma channel
*
IOCOMASM_DMA_REQUEST EQU *
	  MOVEA.L (SP)+,A4              save return address
	  MOVEA.L (SP)+,A2              get sc temp
	  MOVEA.L C_ADR(A2),A1          get card ptr
	  TRAP  #11                     GET INTO SUPERVISOR MODE        scs
* scs     MOVE    SR,-(SP)              JUST IN CASE CALLER DIDN'T DISABLE
	  ORI     #$2700,SR             INTERRUPTS, I WILL.
	  BSR     TESTDMA               SEE IF DMA IS INSTALLED
	  BEQ.S   DR_FAIL               IF NOT, return -1
	  SUBQ.W  #1,D3                 turn $82/$81 to $81/$80
	  ANDI.W  #1,D3                 determine channel
	  EXT.L   D3
	  MOVE.B  IO_SC(A2),DMA_SC(A0)     ELSE CLAIM THIS CHANNEL FOR CALLER
* following 3 lines for 68040 support JWH 2/15/91
	  btst  #3,SYSFLAG2
	  bne   no_40
	  jsr    WRITE_68040
	  jsr    ASM_FLUSH_ICACHE
no_40     BRA.S   DR_GOOD
DR_FAIL   MOVE.L  #-1,D3                return -1
DR_GOOD   MOVE    (SP)+,SR              restore int. state
	  MOVE.L  D3,(SP)               assign return value - channel ( or -1 )
	  JMP     (A4)                  return addr
	  SPC     4
*
*       release a dma channel
*
IOCOMASM_DMA_RELEASE EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVEA.L (SP)+,A2              get sc temp
	  MOVEA.L C_ADR(A2),A1          get card ptr
	  PEA     (A0)                  push return address
	  BRA     DROPDMA               release it
	  SPC     4
	  TTL IOLIB IOCOMASM - assembly dma procedures
	  PAGE
********************************************************************************
*
*       GETDMA
*
*         ROUTINE TO OBTAIN CONTROL OF A DMA CHANNEL
*         GET EITHER DMA CHANNEL, TRYING FOR CH 1 FIRST.
*
*         ENTR:   CONDITIONS ARE THE SAME AS FOR THE tfr DRIVER ENTRY POINT.
*
*         EXIT:   IF DMA IS NOT INSTALLED, 'no dma' escape is generated.
*                 IF DMA IS INSTALLED, THE ALGORITHM WAITS FOR A CHANNEL TO
*                 BECOME AVAILABLE AND THEN:
*                    LOGS USE OF DMA CHANNEL
*                    SETS UP ADDRESS AND COUNT REGISTERS.
*                    CONSTRUCTS CARD ARM AND DMA ARM MASKS AS FOLLOWS:
*                           D2.W = DMA ARM BYTE WITH BITS 1, 2 DEFINED BY
*                                  CONTENTS OF D1 AND BIT 0 = 1.
*                           D3.B = CARD ENABLE BYTE WITH BITS 0, 1 DEFINED BY
*                                  WHICH DMA CHANNEL WAS GRANTED AND BIT 7=1.
*                    A4.L = ADDRESS OF DMA CHANNEL ARM WORD.
*
*         NOTE:   IF THE REQUEST IS FOR INTERNAL HP-IB AS INDICATED BY A1,
*                 ONLY CHANNEL 0 WILL BE GRANTED.
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
GETDMA    TRAP  #11                     GET INTO SUPERVISOR MODE        scs
* scs     MOVE   SR,-(SP)               JUST IN CASE CALLER DIDN'T DISABLE
	  ORI    #$2700,SR              INTERRUPTS, I WILL.
	  CMPI.L #$010001,D0            \ make sure count <=65536
	   BPL   TERR_C                 /
	  BSR.S  TESTDMA                SEE IF DMA IS INSTALLED
	   BEQ   TERR_D                 IF NOT, GIVE ERROR
	  MOVE.B IO_SC(A2),DMA_SC(A0)      ELSE CLAIM THIS CHANNEL FOR CALLER
* added for 68040 support JWH 2/15/91
	  btst   #3,SYSFLAG2
	  bne    not_40
	  jsr  WRITE_68040
	  jsr  ASM_FLUSH_ICACHE
not_40    MOVEA.L D2,A4                 A4 = ADDRESS OF DMA CHANNEL HARDWARE.
	  SPC    1
	  MOVE.L TEMP_OFF(A3),D2        \
	  TST.B  TDIR_OFF(A3)            \
	  BNE.S  GETDMA1                   SET UP ADDRESS
	  MOVE.L TFIL_OFF(A3),D2         /
GETDMA1   MOVE.L D2,(A4)+               /
	  SPC    1
	  SUBQ.L #1,D0                     COUNT REGISTERS (COUNT REG
	  MOVE.W D0,(A4)+                  MUST BE COUNT-1)
	  ADDQ.L #1,D0
	  SPC    2
	  CLR.W  D2
	  MOVE.B TDIR_OFF(A3),D2        MOVE DIRECTION BIT INTO B2 OF D2
	  LSL    #2,D2                  IN ORDER TO CONSTRUCT DMA ARM
	  SPC    2
	  TST.B  T_BW_OFF(A3)           IF BYTE TRANSFER
	  BEQ.S  GETDMA2                THEN SKIP
	  ADDQ.W #2,D2                  ELSE SET BIT 1 OF DMA ARM.
GETDMA2   TST.B  T_DMAPRI(A3)           check for dma priority requested
	  BEQ.S  GETDMA3
	  ADDQ.W #8,D2                    if set  then set pri bit
GETDMA3   ADDQ.W #1,D2                  SET BIT0 OF DMA ARM
	  MOVE  (SP)+,SR                                                scs
	  RTS                                                           scs
* scs     RTE
	  SPC    6
********************************************************************************
*
*       TESTDMA
*
*         THIS ROUTINE TESTS FOR PRESENCE OF DMA HARDWARE AND WAITS FOR
*         A CHANNEL TO BECOME AVAILABLE.
*
*         ENTRY:  A1 = CARD ADDRESS
*
*         EXIT:   IF NO DMA IS INSTALLED, RET with zero flag set
*                 IF    DMA IS INSTALLED, RET with not zero set
*                      A0.L = ADDRESS OF DMA FLAG FOR AVAILABLE CHANNEL
*                      D2.L = ADDRESS OF AVAILABLE DMA CHANNEL
*                      D3.B = CARD ENABLE BYTE FOR AVAILABLE CHANNEL
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
TESTDMA   LEA    DMAFLAG(A5),A0         \
	  TST.B  (A0)                    DO RET 1 IF NO DMA
	  BEQ.S  TESTDMA_C              /
	  CMPA.L #H_INT_CA,A1           IF THIS IS A REQUEST FOR THE INTERNAL
	  BEQ.S  TESTDMA_A              HP-IB, THEN CAN'T TRY FOR CH 1 SO SKIP.
	  LEA    DMA1(A5),A0            ELSE ASSUME WE CAN GET CH 1
	  MOVE.L #DMACH1,D2
* tm      MOVEQ  #$82,D3
	  MOVE.B #$82,D3
	  CMPI.B #255,DMA_SC(A0)        CAN WE?
	  BEQ.S  TESTDMA_B              IF SO, THEN RET 3
TESTDMA_A LEA    DMA0(A5),A0            ELSE ASSUME WE CAN GET CH 0
	  MOVE.L #DMACH0,D2
* tm      MOVEQ  #$81,D3
	  MOVE.B #$81,D3
	  CMPI.B #255,DMA_SC(A0)        CAN WE?
	  BEQ.S  TESTDMA_B     IF HARDWARE PRESENT BUT BUSY,same as not there
	  CLR    D5
	  RTS
TESTDMA_B MOVEQ  #1,D5                  ELSE WE GOT A CH
TESTDMA_C RTS
	  SPC    6
********************************************************************************
*
*       DROPDMA
*
*         ROUTINE TO FREE UP A DMA CHANNEL
*
*         ENTRY:  A2.L = POINTER TO DRIVER TEMPS
*
*         EXIT:   D4.W = FINAL DMA CHANNEL COUNT
*                 CHANNEL IS DISARMED.
*
*         USES:   A0
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
DROPDMA   EQU *
	  TRAP #11                                                      scs
* scs     MOVE   SR,-(SP)               JUST IN CASE CALLER DIDN'T DISABLE
	  ORI    #$2700,SR              INTERRUPTS, I WILL.
	  BTST   #GOT_68020,SYSFLAG2    CHECK IF WE HAVE 68020
	  BEQ.S  DODROP                 IF NOT THEN SKIP
	  JSR    ASM_FLUSH_ICACHE       FLUSH ICACHE ON 68020
	  MOVE   CACHE_CTL,D4           GET EXT. CACHE CONTROL WORD
	  ANDI   #$63,D4                SET DISABLE
	  MOVE   D4,CACHE_CTL           TURN CACHE OFF
	  BSET   #2,D4                  SET ENABLE BIT
	  MOVE   D4,CACHE_CTL           TURN CACHE  BACK ON
DODROP    MOVEQ  #0,D4                  ASSUME DMA CHA ALREADY DROPPED...
	  MOVE.B DMA_SC_0(A5),D0        \
	  CMP.B  IO_SC(A2),D0           / IS IT CH 0?
	  BNE.S  DROPDMA0               IF NOT, SKIP
	  LEA    DMA0(A5),A4            GET A POINTER TO THE CHANNEL R/W
	  LEA    DMACH0,A0              POINT A0 TO CH 0
	  BRA.S  DROPDMA1               GO DO IT
	  SPC    2
DROPDMA0  MOVE.B DMA_SC_1(A5),D0        \
	  CMP.B  IO_SC(A2),D0           / IS IT CH 1?
	  BNE.S  DROPDMA2               IF NOT, DO NOTHING
	  LEA    DMA1(A5),A4            GET A POINTER TO THE CHANNEL R/W
	  LEA    DMACH1,A0              POINT A0 TO CH 1
DROPDMA1  equ   *
* next 3 lines for 68040 support JWH 2/15/91
	  btst   #3,SYSFLAG2
	  bne    same_old
	  jsr    copy_68040
same_old  MOVE.B #255,DMA_SC(A4)        clear s.c.
	  CLR.L  DMASL(A4)              clear static link
	  CLR.L  DMAISR(A4)             clear isr pointer
	  MOVE.L (A0)+,D4               DISARM CH BY READING ADDRESS
	  CLR.L  D4
	  MOVE.W (A0),D4                GET FINAL COUNT INTO D0
	  ADD.W  #1,D4                  FIX UP COUNT TO INDICATE LEFT OVER TFR'S
DROPDMA2  MOVE  (SP)+,SR                                                scs
	  RTS                                                           scs
* scs     RTE
	  PAGE
*
*******************************************************************************
*         WRITE_68040                             JEFF HENDERSHOT 2/15/91.
*
*         THIS ROUTINE IS CALLED IN CASE WE HAVE A 68040 AND WE HAVE ACTUALLY
*         CLAIMED A DMA CHANNEL. BASICALLY, ONCE A DMA CHANNEL HAS ACTUALLY
*         BEEN ASSIGNED, WE HAVE TO FORCE WRITETHROUGH CACHING MODE AND
*         FLUSH CACHES. WHEN ALL DMA CHANNELS ARE RELEASED WE CAN RESTORE
*         COPYBACK MODE IF THAT WAS THE MODE WE ENCOUNTERED HERE.
*
*         CALLED BY : DMA_REQUEST and GETDMA, right after a DMA channel has
*                     actually been claimed. Note - we do not call this from
*                     TESTDMA because TESTDMA does not assign channels
*
*         ALGORITHM:    ASSUMES 68040 (PUT TEST BEFORE CALLING)
*
*                       IF DTT1 CONTAINS SOMETHING NON-ZERO
*                          SAVE CONTENTS OF DTT1 (IN SAVE_DTT1)
*                          PUT 0 (WRITETHROUGH MODE) IN DTT1
*                       EXIT
********************************************************************************
SAVE_DTT1 DC.L   $00000000              save place for DTT1
*
WRITE_68040  trap #11                  supervisor mode
	     move.l d0,-(sp)           save d0
	     movec  DTT1,d0            grab DTT1
	     cmpi.l #$00000000,d0      if 0 don't ...
	     beq    bag_it             bother, already in writethrough
	     move.l d0,SAVE_DTT1       else saveit
	     move.l #0,d0              and force ...
	     movec  d0,DTT1            writethrough mode
bag_it       move.l (sp)+,d0           restore d0
	     move   (sp)+,SR           and SR also
	     RTS
*********************************************************************************
*         COPY_68040                             JEFF HENDERSHOT 2/15/91.
*
*         THIS ROUTINE IS CALLED IN CASE WE HAVE A 68040 AND WE ARE
*         DROPPING A DMA CHANNEL. BASICALLY, ONCE A DMA CHANNEL HAS ACTUALLY
*         BEEN ASSIGNED, WE HAVE TO FORCE WRITETHROUGH CACHING MODE AND
*         FLUSH CACHES. WHEN ALL DMA CHANNELS ARE RELEASED WE CAN RESTORE
*         COPYBACK MODE (IF THAT MODE WAS SAVED EARLIER)
*
*         CALLED BY : DROPDMA, right after the channel is released
*
*         ENTRY: A0 contains DMACH0 or DMACH1
*
*         ALGORITHM:    ASSUMES 68040 (PUT TEST BEFORE CALLING)
*
*                       IF SAVE_DTT1 HAS A NON-ZERO VALUE (COPYBACK MODE)
*                          IF CHANNEL 0 RELEASED
*                            IF CHANNEL 1 NOT IN USE
*                               RESTORE DTT1
*                               ZERO OUT SAVE_DTT1
*                               EXIT
*                          IF CHANNEL 1 RELEASED
*                            IF CHANNEL 0 NOT IN USE
*                               RESTORE DTT1
*                               ZERO OUT SAVE_DTT1
*                               EXIT
********************************************************************************
COPY_68040   equ   *
	  move.l  d0,-(sp)              save d0
	  move.l  SAVE_DTT1,d0
	  cmpi.l  #0,d0                 anything there ?
	  beq     OUTTA_HERE            bail out if not
	  move.l  a1,-(sp)              a1 needed in either case
	  cmpa.l  #DMACH0,a0            was it channel 0 released ?
	  bne     hadta_be_one          if not then one
	  lea    DMA1(A5),a1            see if ..
	  CMPI.B  #$FF,DMA_SC(a1)       channel 1 busy
	  BNE    DONT                   if so don't restore DTT1
	  BRA    PUT_IT                 otherwise do restore it
hadta_be_one  equ  *                    no other choice
	  lea    DMA0(A5),a1
	  CMPI.B  #$FF,DMA_SC(a1)       channel 0 busy ?
	  BNE    DONT                   if so don't restore DTT1
PUT_IT    trap #11                      otherwise do save it
	  movec  d0,DTT1                d0 has SAVE_DTT1
	  move.l  #0,SAVE_DTT1          clear save spot
	  move   (sp)+,SR               restore SR also
DONT      movea.l  (sp)+,a1             restore a1
OUTTA_HERE  move.l (sp)+,d0             restore d0
	   RTS
******************************************************************************
*
*         TIMEREXISTS:  PASCAL FUNCTION TO SEE IF TIMER EXISTS
*
*           FUNCTION TIMEREXISTS: BOOLEAN; EXTERNAL;
*
*           RETURNS TRUE IF TIMER PRESENT, ELSE FALSE
*
*           J SCHMIDT 8/2/83
*
*****************************************************************************
*
TIMEREXISTS EQU *
	  BTST   #TIMER_PRESENT,SYSFLAG2  CHECK BIT FOR TIMER PRESENT
	  SEQ    4(SP)                   SET FUNCTION RESULT 0=>TRUE
	  RTS                             AND RETURN
*
***************************************************************************
*
*         TIMED_OUT:   PASCAL FUNCTION TO SEE IF TIMEOUT HAS OCCURRED
*
*            FUNCTION TIMED_OUT(VAR REC: TIMEOUTREC): BOOLEAN; EXTERNAL;
*
*            TIMEOUTREC= PACKED RECORD
*                           COUNT: INTEGER { SET TO TIMEOUT IN MS }
*                           FIRSTTIME: BOOLEAN; {SET THIS TO TRUE FOR FIRST
*                                                 CALL }
*                         END;
*
*            RETURNS:  TRUE IF TIMEOUT PERIOD EXPIRED, ELSE FALSE
*
*            CAUTION: WILL SMASH BOTH PARTS OF TIMEOUTREC PARAMETER
*
*                J SCHMIDT 8/2/83
*
*                  REMOVED ADDQ.L #4,SP AFTER SMI   JWS 5/3/84
*****************************************************************************
*
TIMED_OUT      MOVEA.L   (SP)+,A0     SAVE RETURN ADDRESS
	       JSR       CHECK_TIMER  CALL CHECK_TIMER USING PARAMETER ON STK
	       SMI       (SP)        SET RESULT OF FUNCTION
	       JMP       (A0)         AND RETURN WITH SP POINTING TO RESULT




*
*****************************************************************************
*
*   Bit shifting routines
*
*****************************************************************************
*

IOCOMASM_binasr    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	asr.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

IOCOMASM_binlsr    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	lsr.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

IOCOMASM_binasl    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	asl.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

IOCOMASM_binlsl    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	lsl.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

	end
@


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


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 909
	TTL IOLIB IOCOMASM - common assembly routines
	PAGE
********************************************************************************
*
*       COPYRIGHT (C) 1985, 1985 BY HEWLETT-PACKARD COMPANY
*
********************************************************************************
*
*
*       IOLIB     IOCOMASM
*
*
********************************************************************************
*
*
*
*       Library - IOLIB
*       Module  - IOCOMASM
*       Author  - Tim Mikkelsen
*       Phone   - 303-226-3800  ext. 2910
*
*       Purpose - This set of assembly language
*                 code is intended to be used as
*                 a support module for I/O drivers
*
*       Date    - 08/18/81
*       Update  - 03/25/85
*       Release -  7/12/85
*
*
*       Source  - IOLIB:COMASM.TEXT
*       Object  - IOLIB:COMASM.CODE
*
*
********************************************************************************
*
*
*        RELEASED
*       VERSION         3.1
*
*
********************************************************************************
	  PAGE
********************************************************************************
*
*       PASCAL DEFINITION OF MODULE
*
********************************************************************************
	  MNAME IOCOMASM
	  SRC MODULE IOCOMASM;
	  SRC IMPORT iodeclarations;
	  SRC EXPORT
	  SRC     FUNCTION  dma_request ( temp   : ANYPTR ) : INTEGER;
	  SRC     PROCEDURE dma_release ( temp   : ANYPTR );
	  SRC     FUNCTION  bit_set     ( v : INTEGER ;
	  SRC                             b : INTEGER ) : BOOLEAN ;
	  SRC     FUNCTION  binand      ( x : INTEGER ;
	  SRC                             y : INTEGER ) : INTEGER ;
	  SRC     FUNCTION  binior      ( x : INTEGER ;
	  SRC                             y : INTEGER ) : INTEGER ;
	  SRC     FUNCTION  bineor      ( x : INTEGER ;
	  SRC                             y : INTEGER ) : INTEGER ;
	  SRC     FUNCTION  bincmp      ( x : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binasr ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binasl ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binlsr ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC     FUNCTION binlsl ( Object : INTEGER ;
	  SRC                        Amount_of_shift : INTEGER ) : INTEGER ;
	  SRC END; { IOCOMASM }
	  SPC 5
	  DEF IOCOMASM_iocomasm
	  DEF IOCOMASM_dma_request
	  DEF IOCOMASM_dma_release
	  DEF IOCOMASM_bit_set
	  DEF IOCOMASM_binand
	  DEF IOCOMASM_binior
	  DEF IOCOMASM_bineor
	  DEF IOCOMASM_bincmp
	  DEF IOCOMASM_binasr
	  DEF IOCOMASM_binasl
	  DEF IOCOMASM_binlsr
	  DEF IOCOMASM_binlsl
	  PAGE
********************************************************************************
*
*       SYMBOLS FOR EXPORT - COMMON ASSEMBLY LANGUAGE ROUTINES
*
*       THE SYMBOLS DO NOT HAVE PASCAL ENTRY
*       POINTS SINCE THEY ARE ONLY USED BY
*       ASSEMBLY LANGUAGE MODULES OR WITH EXTERNAL DECLARATIONS
*
********************************************************************************
	  DEF  DROPDMA
	  DEF  GETDMA
	  DEF  TESTDMA
	  DEF  LOGINT
	  DEF  LOGEOT
	  DEF  STBSY
	  DEF  STCLR
	  DEF  DMA_STBSY
	  DEF  ITXFR
	  DEF  ABORT_IO
	  DEF  WAIT_TFR
	  DEF  CHECK_TFR
	  DEF  TIMEREXISTS    USED AS PASCAL EXTERNAL PROC
	  DEF  TIMED_OUT      USED AS PASCAL EXTERNAL PROC
	  SPC  3
*
*****************************************************************************
*
*          IMPORTED SYMBOLS
*
*****************************************************************************
*
	  REFA   CHECK_TIMER    USED TO GET AT TIMER ROUTINE IN POWERUP
	  REFA   ASM_FLUSH_ICACHE   USED TO FLUSH 68020 AFTER DMA XFR
*  JWH  9/24/90 :
	  LMODE  CHECK_TIMER
	  LMODE  ASM_FLUSH_ICACHE
	  LMODE  save_dtt1          jwh 9/24/90
	  TTL IOLIB IOCOMASM - pascal binary functions
	  PAGE
*
*       module initialization
*
IOCOMASM_IOCOMASM EQU *
	  RTS
*
*       bit test
*
IOCOMASM_BIT_SET  EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get bit #
	  MOVE.L  (SP)+,D1              get numeric value
	  CLR.B   D2                    clear indicator
	  BTST    D0,D1                 test bit in value
	  BEQ.S   BITT_EXIT
	  MOVEQ   #1,D2                 if bit set set indicator
BITT_EXIT MOVE.B  D2,(SP)               push result
	  JMP     (A0)                  return
*
*       binary and
*
IOCOMASM_BINAND   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get last param
	  MOVE.L  (SP)+,D1              get first param
	  AND.L   D0,D1                 perform AND
	  MOVE.L  D1,(SP)               push result
	  JMP     (A0)                  return
*
*       binary inclusive or
*
IOCOMASM_BINIOR   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get last param
	  MOVE.L  (SP)+,D1              get first param
	  OR.L    D0,D1                 perform OR
	  MOVE.L  D1,(SP)               push result
	  JMP     (A0)                  return
*
*       binary exclusive or
*
IOCOMASM_BINEOR   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get last param
	  MOVE.L  (SP)+,D1              get first param
	  EOR.L   D0,D1                 perform XOR
	  MOVE.L  D1,(SP)               push result
	  JMP     (A0)                  return
*
*       binary complement
*
IOCOMASM_BINCMP   EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVE.L  (SP)+,D0              get param
	  NOT.L   D0                    perform complement
	  MOVE.L  D0,(SP)               push result
	  JMP     (A0)                  return
	  SPC     5
	  TTL IOLIB IOCOMASM - common equates and definitions
	  PAGE
	  INCLUDE IOLIB:COMDCL
	  TTL IOLIB IOCOMASM - error escape
	  PAGE
********************************************************************************
*
*       Error escapes
*
********************************************************************************
CTMO_ERR  MOVEQ  #TMO_ERR,D0            timeout
	  BRA.S  ESC_ERR
TERR_C    MOVEQ  #TCNTERR,D0            bad transfer specification
	  BRA.S  ESC_ERR
TERR_B    MOVEQ  #TFR_ERR,D0            bad transfer specification
	  BRA.S  ESC_ERR
TERR_D    MOVEQ  #NO_DMA,D0             DMA not installed
*         BRA.S  ESC_ERR
	  SPC    4
ESC_ERR   EXT.L  D0
	  MOVE.L D0,IOE_RSLT(A5)        save io error
	  MOVE.B IO_SC(A2),D0           \ get sc for error
	  MOVE.L D0,IOE_SC(A5)          /
	  MOVE.W #IOE_ERROR,ESC_CODE(A5)  give i/o error
	  TRAP   #10                    escape
	  TTL IOLIB IOCOMASM - transfer support
	  PAGE
********************************************************************************
*
*       ABORT_IO
*
*         USED DURING INITIALIZATION/RESET TO MAKE SURE THERE
*                IS NO ACTIVE BUFFER LEFT AROUND.
*
*         ENTRY:  A2.L = TEMP POINTER
*
*         USES:   D1,D2,D3  AND ROUTINE DROPDMA (WHICH USES A0)
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
ABORT_IO  TRAP  #11                     GET INTO SUPERVISOR MODE, SAVE SR  scs
* scs     MOVE    SR,-(SP)              \ PREVENT INTERRUPTS FOR A MOMENT.
	  ORI     #$2700,SR             /
ABORT_IO3 BSR     ITXFR                 IS THERE A TRANSFER IN PROGRESS?
	  BEQ.S   ABORT_IO2             IF NOT, DO NOTHING
	  CMP.B   #TT_DMA,D1            ELSE IS IT A DMA?
	  BEQ.S   ABORT_IO1             IF NOT, SKIP
	  BSR     DROPDMA               ELSE FREE UP THE DMA CH, GET COUNT
	  MOVE.L  D4,TCNT_OFF(A3)       fix up count
	  SUB.L   D4,D3                 fix up actual count
	  TST.B   TDIR_OFF(A3)
	  BNE.S   AB_OUT
	  ADD.L   D3,TFIL_OFF(A3)       if input then update fill
	  BRA.S   ABORT_IO1
AB_OUT    ADD.L   D3,TEMP_OFF(A3)       if output then update empty
ABORT_IO1 MOVE.B  #255,T_SC_OFF(A3)     UNBUSY THE BUFFER
	  CLR.B   TACT_OFF(A3)          SET TRANSFER TYPE TO NONE
	  CLR.L   (A4)                  clear buffer ptr
	  BRA     ABORT_IO3             see if there is another
ABORT_IO2 MOVE  (SP)+,SR                RESTORE USER MODE               scs
	  RTS                                                           scs
* scs     RTE                           RESTORE INTERRUPT LEVEL & RETURN
	  PAGE
********************************************************************************
*
*       CHECK_TFR
*
*         ROUTINE TO CHECK FOR ACTIVE TRANSFER IN THE OPPOSITE DIRECTION.
*               ( this is called by a tfr routine on cards
*                 that can't do bi-directional tfrs )
*               ( gpio and hpib modules use this routine )
*               ( with a timeout wait )
*
*         ENTRY:  A2.L = TEMP POINTER
*                 A3.L = BUF CTL BLK POINTER
*
*         EXIT :  IF NOT TRANSFER, RETURN
*                 IF     TRANSFER, THEN wait until finished
*                                       or   until timeout ( if any )
*
********************************************************************************
CHECK_TFR TST.B   TDIR_OFF(A3)          base test on direction
	  BNE.S   CHKT_IN               ( if this is in , check out )
CHKT_OUT  LEA     BUFO_OFF(A2),A4       IS THERE  AN output  BUFFER ACTIVE?
	  MOVE.L  (A4),D1
	  BRA.S   CHKWAIT               IF SO , THEN WAIT
	  SPC     2
CHKT_IN   LEA     BUFI_OFF(A2),A4       is there an input  tfr
	  MOVE.L  (A4),D1
*         BRA.S   CHKWAIT
	  SPC     3
CHKWAIT   BEQ.S   CHKEXIT               exit if no tfr
	  MOVE.L  TIMEOUT(A2),D2        get timeout value
	  BEQ.S   CHECK_TFR             if timeout = 0 then try forever
	  BTST    #TIMER_PRESENT,SYSFLAG2   CHECK IF TIMER PRESENT   JS 8/3/83
	  BEQ.S   CHKT_TIM              IF SO THEN USE IT            JS 8/3/83
	  LSL.L   #8,D2
CHKLOOP   MOVE.L  (A4),D1               check the buffer again
	  BEQ.S   CHKEXIT               if finished in time then return
	  SUBQ.L  #1,D2                 decrement
	  BNE.S   CHKLOOP
	  BRA     CTMO_ERR
CHKEXIT   RTS
	  SPC     3
CHKT_TIM  MOVE.B  #1,-(SP)              SET UP TIMER RECORD          JS 8/3/83
	  MOVE.L  D2,-(SP)                                           JS 8/3/83
CHKT_TIM1 MOVE.L  (A4),D1               TRANSFER ACTIVE ?            JS 8/3/83
	  BEQ.S   CHKT_TIM2             NO -- EXIT                   JS 8/3/83
	  PEA     (SP)                  ELSE CHECK TIMER             JS 8/3/83
	  JSR     CHECK_TIMER                                        JS 8/3/83
	  BPL     CHKT_TIM1             BRANCH IF NOT TIMED OUT      JS 8/3/83
	  BRA     CTMO_ERR              ELSE DO TIMEOUT ESCAPE       JS 8/3/83
CHKT_TIM2 ADDQ.L  #6,SP                 CLEAN TIMER RECORD FROM STACK JS 8/3/83
	  RTS                           AND RETURN                   JS 8/3/83
	  PAGE
********************************************************************************
*
*       WAIT_TFR
*
*         ROUTINE TO CHECK FOR ACTIVE TRANSFER.
*               ( with a timeout wait )
*
*         ENTRY:  A2.L = TEMP POINTER
*
*         EXIT :  IF NOT TRANSFER, RETURN
*                 IF     TRANSFER, THEN wait until finished
*                                       or   until timeout ( if any )
*
*         USES:   NO REGS OTHER THAN RETURN VALUES.
*
*
********************************************************************************
WAIT_TFR  BSR    ITXFR                  quick check for tfr
	  BEQ.S  WT_DONE                and exit
	  MOVE.L TIMEOUT(A2),D6         get timeout value
	  BEQ.S  WAIT_TFR               if timeout = 0 then try forever
	  BTST   #TIMER_PRESENT,SYSFLAG2 IF TIMER PRESENT USE IT   JS 8/3/83
	  BEQ.S  WT_TIM                  BRANCH IF WE HAVE IT      JS 8/3/83
	  LSL.L  #5,D6
WT_LOOP   BSR.S  ITXFR                  try
	  BEQ.S  WT_DONE                if finished in time then return
	  SUBQ.L #1,D6                  decrement
	  BNE.S  WT_LOOP
	  BRA    CTMO_ERR
WT_DONE   RTS
	  SPC    3
WT_TIM    MOVE.B #1,-(SP)              SET UP TIMER RECORD          JS 8/3/83
	  MOVE.L D6,-(SP)                                           JS 8/3/83
WT_TIM1   BSR.S  ITXFR                 CHECK FOR ACTIVE TRANSFER    JS 8/3/83
	  BEQ.S  WT_TIM2               NONE -- EXIT                 JS 8/3/83
	  PEA    (SP)                  CHECK TIMER                  JS 8/3/83
	  JSR    CHECK_TIMER                                        JS 8/3/83
	  BPL    WT_TIM1               LOOK AGAIN IF NOT TIMED OUT  JS 8/3/83
	  BRA    CTMO_ERR              ELSE DO TIMEOUT ESCAPE       JS 8/3/83
WT_TIM2   ADDQ.L #6,SP                 CLEAN UP TIMER RECORD        JS 8/3/83
	  RTS                          AND RETURN                   JS 8/3/83
	  PAGE
********************************************************************************
*
*       ITXFR
*
*         ROUTINE TO CHECK FOR ACTIVE TRANSFER.
*
*         ENTRY:  A2.L = TEMP POINTER
*
*         EXIT :  IF NOT TRANSFER, RET with zero flag  set
*                 IF     TRANSFER, RET with not zero
*                    D1.W = ACTUAL TFR TYPE
*                    D2.W = TERMINATING CHAR FROM TEMPS
*                    D3.L = TRANSFER COUNT FROM TEMPS
*                    A0.L = DATA POINTER FROM TEMPS ( either emtpy or fill )
*                    A3.L = BUF CTL BLK POINTER FROM TEMPS
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
ITXFR     LEA     BUFI_OFF(A2),A4       IS THERE  AN input  BUFFER ACTIVE?
	  MOVE.L  (A4),D1
	  BNE.S   ITXFR3                IF NOT, SKIP
	  LEA     BUFO_OFF(A2),A4       is there an output tfr
	  MOVE.L  (A4),D1
	  BEQ.S   ITXFR1                   -no
ITXFR3    MOVEA.L D1,A3                 \
	  CLR.L   D1                      ELSE GET BUFFER TYPE WORD
	  MOVE.B  TACT_OFF(A3),D1       /
	  CLR.L   D2
	  MOVE.W  TCHR_OFF(A3),D2       GET TERMINATING CHAR
	  MOVE.L  TCNT_OFF(A3),D3       GET COUNT
	  MOVEA.L TEMP_OFF(A3),A0       GET EMPTY POINTER
	  TST.B   TDIR_OFF(A3)          check direction
	  BNE.S   ITXFR2                \ IF INPUT
	  MOVEA.L TFIL_OFF(A3),A0       /    THEN GET FILL POINTER
ITXFR2    MOVEQ   #1,D5                 set not zero
STCLR1    EQU     *
ITXFR1    RTS
	  PAGE
********************************************************************************
*
*       STCLR
*
*         ROUTINE TO SET A BUFFER & SELECT CODE NOT BUSY
*
*         ENTRY:  gets buf ptr from ITXFR routine
*
*                 assumes only one tfr per select code
*
*         USES:   A3,D0
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
STCLR     BSR     ITXFR                 GET BUFFER POINTER FROM TEMPS
	  BEQ.S   STCLR1                IF ALREADY CLEAR, SKIP
	  MOVE.B  #255,T_SC_OFF(A3)     CLEAR S.C. INDICATOR IN THE BUF CTL BLK
	  CLR.B   TACT_OFF(A3)          clear tfr type
	  CLR.L   (A4)                  CLEAR BUF POINTER    IN SC TEMPS
*RTS
	  SPC     5
********************************************************************************
*
*       LOGEOT
*
*         CALL THE USER PROC AT END OF TRANSFER
*
*         PASCAL ROUTINE
*
*         modified to pass a user parameter:  JPC  02/22/82
*
********************************************************************************
LOGEOT    LEA     T_PR_OFF(A3),A0       point to procedure/static link/parameter

H_EOT1    MOVE.L  (A0),D0               is there a proc?
	  BEQ.S   H_EOT3                skip if not

	  MOVEM.L A1-A4,-(SP)           save dedicated regs      (8/10/82 JPC)
	  MOVE.L  8(A0),-(SP)           push the parameter
	  MOVE.L  4(A0),D1              is there a static link?
	  BEQ.S   H_EOT2                Roger Ison says it is okay to try
	  MOVE.L  D1,-(SP)                    and call proc with static link
H_EOT2    MOVEA.L D0,A0                 procedure address
	  JSR     (A0)                  call it
	  MOVEM.L (SP)+,A1-A4           restore dedicated regs   (8/10/82 JPC)

H_EOT3    RTS

	  PAGE
********************************************************************************
*
*       LOGINT
*
*         THIS ROUTINE WAS CALLED H_LOG
*
*         CALL THE USER PROC WHEN AN ISR SAYS TO
*
*         PASCAL ROUTINE
*
*         modified to pass a user parameter:  JPC  02/22/82
*
********************************************************************************
LOGINT    LEA     H_ISR_PR(A2),A0       point to procedure/static link/parameter
	  BRA     H_EOT1                call it (if it exists)
	  PAGE
********************************************************************************
*
*       DMA_STBSY
*
*         ROUTINE TO SET A BUFFER BUSY
*
*         ENTRY:
*                 D0.W = TRANSFER COUNT TO BE PUT IN TCNT_OFF(A2)
*                        AND TO BE ADDED TO E/F COUNT.
*                 A0.L = pointer to DMA temps
*                 A2.L = POINTER TO DRIVER TEMPS
*                 A3.L = POINTER TO BUFFER CTL BLOCK
*                 A4.L = POINTER TO TERMINATION ROUTINE
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
DMA_STBSY MOVE.L A4,DMAISR(A0)          SAVE THE TERMINATION ROUTINE
	  CLR.L  DMASL(A0)              CLEAR THE STATIC LINK
*         BRA.S  STBSY                  SET THE BUFFER BUSY
	  SPC    5
********************************************************************************
*
*       STBSY
*
*         ROUTINE TO SET A BUFFER BUSY
*
*         ENTRY:
*                 D0.W = TRANSFER COUNT TO BE PUT IN TCNT_OFF(A2)
*                        AND TO BE ADDED TO E/F COUNT.
*                 A2.L = POINTER TO DRIVER TEMPS
*                 A3.L = POINTER TO BUFFER CTL BLOCK
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
STBSY     MOVE.L D0,TCNT_OFF(A3)        COPY TFR COUNT INTO TEMPS.
	  TST.B  TDIR_OFF(A3)           \
	  BNE.S  STBSY1                  \
	  MOVE.L A3,BUFI_OFF(A2)           MAKE SELECT CODE BUSY
	  BRA.S  STBSY2                  /
STBSY1    MOVE.L A3,BUFO_OFF(A2)        /
STBSY2    MOVE.B IO_SC(A2),T_SC_OFF(A3) SET UP BUFFER ACTIVE SELECT CODE
	  RTS                           DONE!
	  TTL IOLIB IOCOMASM - dma support
	  PAGE
********************************************************************************
*
*       DMA RESOURCE MANAGEMENT ROUTINES
*
*
********************************************************************************
	  SPC 3
********************************************************************************
*
*       DMA RESOURCE temporaries
*
*         These resource temporaries need to be aligned with the offsets
*         generated by the main Pascal library.  This is not an automatic
*         operation - it must be done by hand if ANY new declarations are
*         added in the iodeclarations in front of the dma resource temps.
*
********************************************************************************
DMAFLAG   EQU    iodeclarations-61      boolean indicating presence of dma hardware
	  SPC    2
DMA0      EQU    iodeclarations-8
DMAISR_0  EQU    iodeclarations-8       \
DMASL_0   EQU    iodeclarations-4         channel 0 temps
DMA_SC_0  EQU    iodeclarations-9       /
	  SPC    2
DMA1      EQU    iodeclarations-18
DMAISR_1  EQU    iodeclarations-18      \
DMASL_1   EQU    iodeclarations-14        channel 1 temps
DMA_SC_1  EQU    iodeclarations-19      /
	  SPC    2
DMAISR    EQU    0                      isr pointer
DMASL     EQU    4                      static link
DMA_SC    EQU    -1                     allocated s.c.
	  SPC    2
DMACH0    EQU    $500000                address of dma channel 0
DMACH1    EQU    $500008                address of dma channel 1
********************************************************************************
*
*       ADDRESS CONSTANTS
*
********************************************************************************
H_INT_CA  EQU    $478000                ADDRESS OF INTERNAL HPIB INTERFACE
	  TTL IOLIB IOCOMASM - pascal dma procedures
	  PAGE
*
*       request a dma channel
*
IOCOMASM_DMA_REQUEST EQU *
	  MOVEA.L (SP)+,A4              save return address
	  MOVEA.L (SP)+,A2              get sc temp
	  MOVEA.L C_ADR(A2),A1          get card ptr
	  TRAP  #11                     GET INTO SUPERVISOR MODE        scs
* scs     MOVE    SR,-(SP)              JUST IN CASE CALLER DIDN'T DISABLE
	  ORI     #$2700,SR             INTERRUPTS, I WILL.
	  BSR     TESTDMA               SEE IF DMA IS INSTALLED
	  BEQ.S   DR_FAIL               IF NOT, return -1
	  SUBQ.W  #1,D3                 turn $82/$81 to $81/$80
	  ANDI.W  #1,D3                 determine channel
	  EXT.L   D3
	  MOVE.B  IO_SC(A2),DMA_SC(A0)     ELSE CLAIM THIS CHANNEL FOR CALLER
* following 3 lines for 68040 support JWH 2/15/91
	  btst  #3,SYSFLAG2
	  bne   no_40
	  jsr    WRITE_68040
	  jsr    ASM_FLUSH_ICACHE
no_40     BRA.S   DR_GOOD
DR_FAIL   MOVE.L  #-1,D3                return -1
DR_GOOD   MOVE    (SP)+,SR              restore int. state
	  MOVE.L  D3,(SP)               assign return value - channel ( or -1 )
	  JMP     (A4)                  return addr
	  SPC     4
*
*       release a dma channel
*
IOCOMASM_DMA_RELEASE EQU *
	  MOVEA.L (SP)+,A0              save return address
	  MOVEA.L (SP)+,A2              get sc temp
	  MOVEA.L C_ADR(A2),A1          get card ptr
	  PEA     (A0)                  push return address
	  BRA     DROPDMA               release it
	  SPC     4
	  TTL IOLIB IOCOMASM - assembly dma procedures
	  PAGE
********************************************************************************
*
*       GETDMA
*
*         ROUTINE TO OBTAIN CONTROL OF A DMA CHANNEL
*         GET EITHER DMA CHANNEL, TRYING FOR CH 1 FIRST.
*
*         ENTR:   CONDITIONS ARE THE SAME AS FOR THE tfr DRIVER ENTRY POINT.
*
*         EXIT:   IF DMA IS NOT INSTALLED, 'no dma' escape is generated.
*                 IF DMA IS INSTALLED, THE ALGORITHM WAITS FOR A CHANNEL TO
*                 BECOME AVAILABLE AND THEN:
*                    LOGS USE OF DMA CHANNEL
*                    SETS UP ADDRESS AND COUNT REGISTERS.
*                    CONSTRUCTS CARD ARM AND DMA ARM MASKS AS FOLLOWS:
*                           D2.W = DMA ARM BYTE WITH BITS 1, 2 DEFINED BY
*                                  CONTENTS OF D1 AND BIT 0 = 1.
*                           D3.B = CARD ENABLE BYTE WITH BITS 0, 1 DEFINED BY
*                                  WHICH DMA CHANNEL WAS GRANTED AND BIT 7=1.
*                    A4.L = ADDRESS OF DMA CHANNEL ARM WORD.
*
*         NOTE:   IF THE REQUEST IS FOR INTERNAL HP-IB AS INDICATED BY A1,
*                 ONLY CHANNEL 0 WILL BE GRANTED.
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
GETDMA    TRAP  #11                     GET INTO SUPERVISOR MODE        scs
* scs     MOVE   SR,-(SP)               JUST IN CASE CALLER DIDN'T DISABLE
	  ORI    #$2700,SR              INTERRUPTS, I WILL.
	  CMPI.L #$010001,D0            \ make sure count <=65536
	   BPL   TERR_C                 /
	  BSR.S  TESTDMA                SEE IF DMA IS INSTALLED
	   BEQ   TERR_D                 IF NOT, GIVE ERROR
	  MOVE.B IO_SC(A2),DMA_SC(A0)      ELSE CLAIM THIS CHANNEL FOR CALLER
* added for 68040 support JWH 2/15/91
	  btst   #3,SYSFLAG2
	  bne    not_40
	  jsr  WRITE_68040
	  jsr  ASM_FLUSH_ICACHE
not_40    MOVEA.L D2,A4                 A4 = ADDRESS OF DMA CHANNEL HARDWARE.
	  SPC    1
	  MOVE.L TEMP_OFF(A3),D2        \
	  TST.B  TDIR_OFF(A3)            \
	  BNE.S  GETDMA1                   SET UP ADDRESS
	  MOVE.L TFIL_OFF(A3),D2         /
GETDMA1   MOVE.L D2,(A4)+               /
	  SPC    1
	  SUBQ.L #1,D0                     COUNT REGISTERS (COUNT REG
	  MOVE.W D0,(A4)+                  MUST BE COUNT-1)
	  ADDQ.L #1,D0
	  SPC    2
	  CLR.W  D2
	  MOVE.B TDIR_OFF(A3),D2        MOVE DIRECTION BIT INTO B2 OF D2
	  LSL    #2,D2                  IN ORDER TO CONSTRUCT DMA ARM
	  SPC    2
	  TST.B  T_BW_OFF(A3)           IF BYTE TRANSFER
	  BEQ.S  GETDMA2                THEN SKIP
	  ADDQ.W #2,D2                  ELSE SET BIT 1 OF DMA ARM.
GETDMA2   TST.B  T_DMAPRI(A3)           check for dma priority requested
	  BEQ.S  GETDMA3
	  ADDQ.W #8,D2                    if set  then set pri bit
GETDMA3   ADDQ.W #1,D2                  SET BIT0 OF DMA ARM
	  MOVE  (SP)+,SR                                                scs
	  RTS                                                           scs
* scs     RTE
	  SPC    6
********************************************************************************
*
*       TESTDMA
*
*         THIS ROUTINE TESTS FOR PRESENCE OF DMA HARDWARE AND WAITS FOR
*         A CHANNEL TO BECOME AVAILABLE.
*
*         ENTRY:  A1 = CARD ADDRESS
*
*         EXIT:   IF NO DMA IS INSTALLED, RET with zero flag set
*                 IF    DMA IS INSTALLED, RET with not zero set
*                      A0.L = ADDRESS OF DMA FLAG FOR AVAILABLE CHANNEL
*                      D2.L = ADDRESS OF AVAILABLE DMA CHANNEL
*                      D3.B = CARD ENABLE BYTE FOR AVAILABLE CHANNEL
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
TESTDMA   LEA    DMAFLAG(A5),A0         \
	  TST.B  (A0)                    DO RET 1 IF NO DMA
	  BEQ.S  TESTDMA_C              /
	  CMPA.L #H_INT_CA,A1           IF THIS IS A REQUEST FOR THE INTERNAL
	  BEQ.S  TESTDMA_A              HP-IB, THEN CAN'T TRY FOR CH 1 SO SKIP.
	  LEA    DMA1(A5),A0            ELSE ASSUME WE CAN GET CH 1
	  MOVE.L #DMACH1,D2
* tm      MOVEQ  #$82,D3
	  MOVE.B #$82,D3
	  CMPI.B #255,DMA_SC(A0)        CAN WE?
	  BEQ.S  TESTDMA_B              IF SO, THEN RET 3
TESTDMA_A LEA    DMA0(A5),A0            ELSE ASSUME WE CAN GET CH 0
	  MOVE.L #DMACH0,D2
* tm      MOVEQ  #$81,D3
	  MOVE.B #$81,D3
	  CMPI.B #255,DMA_SC(A0)        CAN WE?
	  BEQ.S  TESTDMA_B     IF HARDWARE PRESENT BUT BUSY,same as not there
	  CLR    D5
	  RTS
TESTDMA_B MOVEQ  #1,D5                  ELSE WE GOT A CH
TESTDMA_C RTS
	  SPC    6
********************************************************************************
*
*       DROPDMA
*
*         ROUTINE TO FREE UP A DMA CHANNEL
*
*         ENTRY:  A2.L = POINTER TO DRIVER TEMPS
*
*         EXIT:   D4.W = FINAL DMA CHANNEL COUNT
*                 CHANNEL IS DISARMED.
*
*         USES:   A0
*
*         HPL ROUTINE ( MODIFIED )
*
********************************************************************************
DROPDMA   EQU *
	  TRAP #11                                                      scs
* scs     MOVE   SR,-(SP)               JUST IN CASE CALLER DIDN'T DISABLE
	  ORI    #$2700,SR              INTERRUPTS, I WILL.
	  BTST   #GOT_68020,SYSFLAG2    CHECK IF WE HAVE 68020
	  BEQ.S  DODROP                 IF NOT THEN SKIP
	  JSR    ASM_FLUSH_ICACHE       FLUSH ICACHE ON 68020
	  MOVE   CACHE_CTL,D4           GET EXT. CACHE CONTROL WORD
	  ANDI   #$63,D4                SET DISABLE
	  MOVE   D4,CACHE_CTL           TURN CACHE OFF
	  BSET   #2,D4                  SET ENABLE BIT
	  MOVE   D4,CACHE_CTL           TURN CACHE  BACK ON
DODROP    MOVEQ  #0,D4                  ASSUME DMA CHA ALREADY DROPPED...
	  MOVE.B DMA_SC_0(A5),D0        \
	  CMP.B  IO_SC(A2),D0           / IS IT CH 0?
	  BNE.S  DROPDMA0               IF NOT, SKIP
	  LEA    DMA0(A5),A4            GET A POINTER TO THE CHANNEL R/W
	  LEA    DMACH0,A0              POINT A0 TO CH 0
	  BRA.S  DROPDMA1               GO DO IT
	  SPC    2
DROPDMA0  MOVE.B DMA_SC_1(A5),D0        \
	  CMP.B  IO_SC(A2),D0           / IS IT CH 1?
	  BNE.S  DROPDMA2               IF NOT, DO NOTHING
	  LEA    DMA1(A5),A4            GET A POINTER TO THE CHANNEL R/W
	  LEA    DMACH1,A0              POINT A0 TO CH 1
DROPDMA1  equ   *
* next 3 lines for 68040 support JWH 2/15/91
	  btst   #3,SYSFLAG2
	  bne    same_old
	  jsr    copy_68040
same_old  MOVE.B #255,DMA_SC(A4)        clear s.c.
	  CLR.L  DMASL(A4)              clear static link
	  CLR.L  DMAISR(A4)             clear isr pointer
	  MOVE.L (A0)+,D4               DISARM CH BY READING ADDRESS
	  CLR.L  D4
	  MOVE.W (A0),D4                GET FINAL COUNT INTO D0
	  ADD.W  #1,D4                  FIX UP COUNT TO INDICATE LEFT OVER TFR'S
DROPDMA2  MOVE  (SP)+,SR                                                scs
	  RTS                                                           scs
* scs     RTE
	  PAGE
*
*******************************************************************************
*         WRITE_68040                             JEFF HENDERSHOT 2/15/91.
*
*         THIS ROUTINE IS CALLED IN CASE WE HAVE A 68040 AND WE HAVE ACTUALLY
*         CLAIMED A DMA CHANNEL. BASICALLY, ONCE A DMA CHANNEL HAS ACTUALLY
*         BEEN ASSIGNED, WE HAVE TO FORCE WRITETHROUGH CACHING MODE AND
*         FLUSH CACHES. WHEN ALL DMA CHANNELS ARE RELEASED WE CAN RESTORE
*         COPYBACK MODE IF THAT WAS THE MODE WE ENCOUNTERED HERE.
*
*         CALLED BY : DMA_REQUEST and GETDMA, right after a DMA channel has
*                     actually been claimed. Note - we do not call this from
*                     TESTDMA because TESTDMA does not assign channels
*
*         ALGORITHM:    ASSUMES 68040 (PUT TEST BEFORE CALLING)
*
*                       IF DTT1 CONTAINS SOMETHING NON-ZERO
*                          SAVE CONTENTS OF DTT1 (IN SAVE_DTT1)
*                          PUT 0 (WRITETHROUGH MODE) IN DTT1
*                       EXIT
********************************************************************************
SAVE_DTT1 DC.L   $00000000              save place for DTT1
*
WRITE_68040  trap #11                  supervisor mode
	     move.l d0,-(sp)           save d0
	     movec  DTT1,d0            grab DTT1
	     cmpi.l #$00000000,d0      if 0 don't ...
	     beq    bag_it             bother, already in writethrough
	     move.l d0,SAVE_DTT1       else saveit
	     move.l #0,d0              and force ...
	     movec  d0,DTT1            writethrough mode
bag_it       move.l (sp)+,d0           restore d0
	     move   (sp)+,SR           and SR also
	     RTS
*********************************************************************************
*         COPY_68040                             JEFF HENDERSHOT 2/15/91.
*
*         THIS ROUTINE IS CALLED IN CASE WE HAVE A 68040 AND WE ARE
*         DROPPING A DMA CHANNEL. BASICALLY, ONCE A DMA CHANNEL HAS ACTUALLY
*         BEEN ASSIGNED, WE HAVE TO FORCE WRITETHROUGH CACHING MODE AND
*         FLUSH CACHES. WHEN ALL DMA CHANNELS ARE RELEASED WE CAN RESTORE
*         COPYBACK MODE (IF THAT MODE WAS SAVED EARLIER)
*
*         CALLED BY : DROPDMA, right after the channel is released
*
*         ENTRY: A0 contains DMACH0 or DMACH1
*
*         ALGORITHM:    ASSUMES 68040 (PUT TEST BEFORE CALLING)
*
*                       IF SAVE_DTT1 HAS A NON-ZERO VALUE (COPYBACK MODE)
*                          IF CHANNEL 0 RELEASED
*                            IF CHANNEL 1 NOT IN USE
*                               RESTORE DTT1
*                               ZERO OUT SAVE_DTT1
*                               EXIT
*                          IF CHANNEL 1 RELEASED
*                            IF CHANNEL 0 NOT IN USE
*                               RESTORE DTT1
*                               ZERO OUT SAVE_DTT1
*                               EXIT
********************************************************************************
COPY_68040   equ   *
	  move.l  d0,-(sp)              save d0
	  move.l  SAVE_DTT1,d0
	  cmpi.l  #0,d0                 anything there ?
	  beq     OUTTA_HERE            bail out if not
	  move.l  a1,-(sp)              a1 needed in either case
	  cmpa.l  #DMACH0,a0            was it channel 0 released ?
	  bne     hadta_be_one          if not then one
	  lea    DMA1(A5),a1            see if ..
	  CMPI.B  #$FF,DMA_SC(a1)       channel 1 busy
	  BNE    DONT                   if so don't restore DTT1
	  BRA    PUT_IT                 otherwise do restore it
hadta_be_one  equ  *                    no other choice
	  lea    DMA0(A5),a1
	  CMPI.B  #$FF,DMA_SC(a1)       channel 0 busy ?
	  BNE    DONT                   if so don't restore DTT1
PUT_IT    trap #11                      otherwise do save it
	  movec  d0,DTT1                d0 has SAVE_DTT1
	  move.l  #0,SAVE_DTT1          clear save spot
	  move   (sp)+,SR               restore SR also
DONT      movea.l  (sp)+,a1             restore a1
OUTTA_HERE  move.l (sp)+,d0             restore d0
	   RTS
******************************************************************************
*
*         TIMEREXISTS:  PASCAL FUNCTION TO SEE IF TIMER EXISTS
*
*           FUNCTION TIMEREXISTS: BOOLEAN; EXTERNAL;
*
*           RETURNS TRUE IF TIMER PRESENT, ELSE FALSE
*
*           J SCHMIDT 8/2/83
*
*****************************************************************************
*
TIMEREXISTS EQU *
	  BTST   #TIMER_PRESENT,SYSFLAG2  CHECK BIT FOR TIMER PRESENT
	  SEQ    4(SP)                   SET FUNCTION RESULT 0=>TRUE
	  RTS                             AND RETURN
*
***************************************************************************
*
*         TIMED_OUT:   PASCAL FUNCTION TO SEE IF TIMEOUT HAS OCCURRED
*
*            FUNCTION TIMED_OUT(VAR REC: TIMEOUTREC): BOOLEAN; EXTERNAL;
*
*            TIMEOUTREC= PACKED RECORD
*                           COUNT: INTEGER { SET TO TIMEOUT IN MS }
*                           FIRSTTIME: BOOLEAN; {SET THIS TO TRUE FOR FIRST
*                                                 CALL }
*                         END;
*
*            RETURNS:  TRUE IF TIMEOUT PERIOD EXPIRED, ELSE FALSE
*
*            CAUTION: WILL SMASH BOTH PARTS OF TIMEOUTREC PARAMETER
*
*                J SCHMIDT 8/2/83
*
*                  REMOVED ADDQ.L #4,SP AFTER SMI   JWS 5/3/84
*****************************************************************************
*
TIMED_OUT      MOVEA.L   (SP)+,A0     SAVE RETURN ADDRESS
	       JSR       CHECK_TIMER  CALL CHECK_TIMER USING PARAMETER ON STK
	       SMI       (SP)        SET RESULT OF FUNCTION
	       JMP       (A0)         AND RETURN WITH SP POINTING TO RESULT




*
*****************************************************************************
*
*   Bit shifting routines
*
*****************************************************************************
*

IOCOMASM_binasr    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	asr.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

IOCOMASM_binlsr    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	lsr.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

IOCOMASM_binasl    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	asl.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

IOCOMASM_binlsl    equ     *
	movea.l (sp)+,a0        Save return address
	move.l  (sp)+,d0        Pop # of bits to shift
	move.l  (sp)+,d1        Pop the value to shift
	lsl.l   d0,d1           Shift the value
	move.l  d1,(sp)         Push the resulting return value
	jmp     (a0)            Return

	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.14
log
@*** empty log message ***
@
text
@@


51.13
log
@minor changes.
@
text
@d806 1
a806 2
	  move.l  a0,d0                 get a0
	  cmpi.l  #DMACH0,d0            was it channel 0 released ?
d817 1
a817 2
	  move.l SAVE_DTT1,d0           get it (d0 usable)
	  movec  d0,DTT1
@


51.12
log
@More work on the routines WRITE_68040 and COPY_68040.
@
text
@d555 1
a555 1
	  jsr    write_68040
d613 1
a613 1
	  jsr  write_68040
d762 1
a762 1
WRITE_68040  trap #11                  otherwise save it if <> 0
@


51.11
log
@*** empty log message ***
@
text
@a120 1
	  REFA   ASM_INV_CACHES  used to inv 68040 caches after DMA
a122 1
	  LMODE  ASM_INV_CACHES
d556 1
d614 1
a752 4
*         ENTRY:  D2.L has address of channel just assigned :
*                 channel 0 : $00500000
*                 channel 1 : $00500008
*
d755 3
a757 14
*                       IF CHANNEL 0 ASSIGNED
*                          IF CHANNEL 1 NOT IN USE
*                             IF DTT1 HAS A NON-ZERO VALUE (COPYBACK MODE)
*                                SAVE DTT1
*                                ZERO OUT DTT1 (WRITETHROUGH MODE)
*                                JSR  ASM_FLUSH_ICACHE
*                          EXIT (IF CHANNEL 0 ASSIGNED)
*
*                       IF CHANNEL 1 ASSIGNED
*                          IF CHANNEL 0 NOT IN USE
*                             IF DTT1 HAS A NON-ZERO VALUE (COPYBACK MODE)
*                                SAVE DTT1
*                                ZERO OUT DTT1 (WRITETHROUGH MODE)
*                                JSR  ASM_FLUSH_ICACHE
a758 1
*
d762 11
a772 24
WRITE_68040  EQU  *
	  move.l a1,-(sp)              save a1 - will need in either case
	  cmpi.l  #$00500000,d2        channel 0 assigned ?
	  bne     hasta_be_one         if not then one
	  lea    DMA1(A5),a1           get ch 1 active byte
	  CMPI.B  #$FF,DMA_SC(a1)      channel 1 busy ?
	  BNE    DONT_DOIT             if so don't save DTT1
	  BRA    SAVE_IT               save dtt1 if non-zero
hasta_be_one   equ *                   no other poss
	  lea    DMA0(A5),a1           get ch 0 active byte
	  CMPI.B  #$FF,DMA_SC(a1)      channel 0 busy ?
	  BNE    DONT_DOIT             if so don't save DTT1
SAVE_IT   trap #11                     otherwise save it if <> 0
	  move.l d0,-(sp)              save d0
	  movec  DTT1,d0               grab DTT1
	  cmpi.l #$00000000,d0         if 0 don't ...
	  beq   bag_it                 bother, already in writethrough
	  move.l d0,SAVE_DTT1          else saveit
	  move.l #0,d0                 and force ...
	  movec  d0,DTT1               writethrough mode
bag_it    move.l (sp)+,d0              restore d0
	  move   (sp)+,SR              and SR also
DONT_DOIT movea.l (sp)+,a1             restore a1
OUTTA_HERE    RTS
d780 1
a780 1
*         COPYBACK MODE IF THAT WAS THE MODE WE ENCOUNTERED HERE.
d788 11
a798 16
*                       IF CHANNEL 0 RELEASED
*                          IF CHANNEL 1 NOT IN USE
*                             IF SAVE_DTT1 HAS A NON-ZERO VALUE (COPYBACK MODE)
*                                RESTORE DTT1
*                                ZERO OUT SAVE_DTT1
*
*                          EXIT (IF CHANNEL 0 RELEASED)
*
*                       IF CHANNEL 1 RELEASED
*                          IF CHANNEL 0 NOT IN USE
*                             IF SAVE_DTT1 HAS A NON-ZERO VALUE (COPYBACK MODE)
*                                RESTORE DTT1
*                                ZERO OUT SAVE_DTT1
*
*                       EXIT
*
d802 3
d807 1
a807 1
	  cmpi.l  #$00500000,d0         channel 0 released ?
a818 2
	  cmpi.l #0,d0                  anything there ?
	  beq    not_really
d821 4
a824 6
not_really  move   (sp)+,SR             restore SR also
DONT      move.l  (sp)+,d0              restore d0
	  movea.l (sp)+,a1              restore a1
	  RTS
********************************************************************************
*
@


51.10
log
@Minor changes integrating COPY_68040 and WRITE_68040.
@
text
@d611 1
a611 1
* added for 68040 support JWH 2/15/9
d613 1
@


51.9
log
@Hooking in the routines copy_68040 and write_68040.
@
text
@d834 4
a837 2
	  move.l a1,-(sp)               a1 needed in either case
	  cmpi.l  #$00500000,a0         channel 0 released ?
d848 1
a848 2
	  move.l d0,-(sp)               save d0
	  move.l SAVE_DTT1,d0           get it
a850 1
	  move.l d0,SHOW_DTT1           debugging only
d853 3
a855 3
not_really  move.l (sp)+,d0               restore d0
	  move   (sp)+,SR               and SR also
DONT      movea.l (sp)+,a1              restore a1
@


51.8
log
@Added the routines WRITE_68040 and COPY_68040.
@
text
@d554 1
a554 2
* For 68040, do one more thing. Flush caches, and make sure DTT1
* register now indicates writethrough mode
d556 3
a558 12
	  bne   DR_GOOD
	  trap #11
	  move.l  d0,-(SP)  get a register
	  movec   DTT1,d0
	  move.l  d0,save_dtt1
	  andi.l  #0,d0         just shut it down
	  movec   d0,dtt1
	  CPUSHA  DC/IC       flush, invalidate both caches
	  move.l  (SP)+,d0    restore d0
	  move    (SP)+,SR    restore SR
* end of code for '040 JWH 9/24/90
	  BRA.S   DR_GOOD
d611 4
a614 1
	  MOVEA.L D2,A4                 A4 = ADDRESS OF DMA CHANNEL HARDWARE.
d638 1
a638 15
* For 68040, do one more thing. Flush caches, and make sure DTT1
* register now indicates writethrough mode
	  btst  #3,SYSFLAG2
	  bne   no_40
	  trap #11
	  move.l  d0,-(SP)  get a register
	  movec   DTT1,d0
	  move.l  d0,save_dtt1
	  andi.l  #0,d0         just shut it down
	  movec   d0,dtt1
	  CPUSHA  DC/IC       flush, invalidate both caches
	  move.l  (SP)+,d0    restore d0
	  move    (SP)+,SR    restore SR
no_40     RTS                                                           scs
save_dtt1 dc.l  $00000000   storage for DTT1
d675 1
a675 1
	  BEQ.S  TESTDMA_B              IF HARDWARE PRESENT BUT BUSY,same as not there
d701 1
a701 15
* added for 68040 support. if we have an '040, we want to
* mark all the cache entries invalid and
* restore the DTT1 in effect when the DMA was first initiated
	  BTST   #3,SYSFLAG2
	  bne    try_20
	  trap   #11      got an '040
	  jsr    ASM_INV_CACHES  mark all cache entries invalid
	  move.l  d0,-(SP)
	  move.l  save_dtt1,d0
	  movec   d0,DTT1        put back what was there before DMA
	  move.l  (SP)+,d0       restore d0
	  move    (SP)+,SR
	  BRA    DODROP          carry on
* end of '040 special stuff
try_20    BTST   #GOT_68020,SYSFLAG2    CHECK IF WE HAVE 68020
d722 6
a727 1
DROPDMA1  MOVE.B #255,DMA_SC(A4)        clear s.c.
@


51.7
log
@Put COMASM back to what it was right after the last turn.
@
text
@d769 120
@


51.6
log
@A few changes. This should conclude all the changes needed for support
of DMA when the processor might be in copyback mode.
@
text
@d120 2
d124 2
a125 1
	  LMODE  SAVE_DTT1      68040 JWH 2/14/91
d554 14
d645 15
a659 1
	  RTS                                                           scs
d690 1
a690 1
	  BEQ    HELP_0                 used to be BEQ.S TESTDMA_B
d696 1
a696 2
	  BEQ    HELP_1                 used to be BEQ.S TESTDMA_B
* IF HARDWARE PRESENT BUT BUSY,same as not there
a700 77
*=====================================================================
* The code for TESTDMA above is exactly the same but in the case of
* the 68040 we peek at the other channel to see if it's busy. If it
* is not we are responsible for putting the processor in writethrough
* mode.
*
* The following code is to make sure DMA does not take place with
* the 68040 in copyback mode. When a DMA request is granted, we
* check to see if we're already doing DMA (i.e. is the other channel
* busy). If we are we don't save DTT1 because that other request
* already did. Otherwise we do save DTT1.
*
* Now when DROPDMA is called we check to see if the other channel
* is busy. If it is, we don't restore DTT1, because DMA is still
* active. If it is not, we do restore DTT1.
*
* Jeff Hendershot 2/14/91.
*=====================================================================
SAVE_DTT1 DC.L   $00000000              save place for DTT1
* new for the 68040 - save DTT1 if other channel (0) not in use :
HELP_0    BTST   #3,SYSFLAG2            make sure 68040
	  BNE    TESTDMA_B              same as before if not
	  move.l a1,-(sp)               save a1
	  lea    DMA0(A5),a1
	  CMPI.B  #$FF,DMA_SC(a1)       channel 0 busy ?
	  BNE    DONT_DOIT              if so don't save DTT1
	  BRA    SAVE_IT                otherwise do save it
* new for the 68040 - save DTT1 if other channel (1) not in use :
HELP_1    BTST   #3,SYSFLAG2            make sure 68040
	  BNE    TESTDMA_B              same as before if not
	  move.l a1,-(sp)               save a1
	  lea    DMA1(A5),a1
	  CMPI.B  #$FF,DMA_SC(a1)       channel 1 busy ?
	  BNE    DONT_DOIT              if so don't save DTT1
SAVE_IT   trap #11                      otherwise do save it
	  move.l d0,-(sp)               save d0
	  movec  DTT1,d0
	  move.l d0,SAVE_DTT1           saveit
	  move.l #0,d0
	  movec  d0,DTT1                writethrough mode
	  move.l (sp)+,d0               restore d0
	  move   (sp)+,SR               and SR also
	  jsr    ASM_FLUSH_ICACHE       sync up ..
DONT_DOIT movea.l (sp)+,a1              restore a1
	  BRA    TESTDMA_B              same as before
*
* Following helps the DROPDMA put back DTT1, if it should need to
*
* new for the 68040 - restore DTT1 if other channel (1) not in use :
*
HELP_2    BTST   #3,SYSFLAG2            make sure 68040
	  BNE    DROPDMA1               same as before if not
	  move.l a1,-(sp)               save a1
	  lea    DMA1(A5),a1
	  CMPI.B  #$FF,DMA_SC(a1)       channel 0 busy ?
	  BNE    DONT                   if so don't save DTT1
	  BRA    PUT_IT                otherwise do save it
*
* new for the 68040 - restore DTT1 if other channel (0) not in use :
* DROPDMA calls ASM_FLUSH_ICACHE so we don't need to.
*
HELP_3    BTST   #3,SYSFLAG2            make sure 68040
	  BNE    DROPDMA1               same as before if not
	  move.l a1,-(sp)               save a1
	  lea    DMA0(A5),a1
	  CMPI.B  #$FF,DMA_SC(a1)       channel 1 busy ?
	  BNE    DONT                   if so don't restore DTT1
PUT_IT    trap #11                      otherwise do save it
	  move.l d0,-(sp)               save d0
	  move.l SAVE_DTT1,d0           saveit
	  movec  d0,DTT1
	  move.l  #0,SAVE_DTT1          clear save spot
	  move.l (sp)+,d0               restore d0
	  move   (sp)+,SR               and SR also
DONT      movea.l (sp)+,a1              restore a1
	  BRA    DROPDMA1               same as before
*=========================================================================
d722 15
a736 4
*===========================================================================
* Note - no special processing needed for 68040 support. ASM_FLUSH_ICACHE
*        works for the 68040 as well.
	  BTST   #GOT_68020,SYSFLAG2    CHECK IF WE HAVE 68020
a737 1
* Following works for 68030 and 68040 too JWH 2/13/91.
d750 1
a750 2
	  BRA    HELP_2                 see if 68040 etc.
*         BRA.S  DROPDMA1               GO DO IT
a756 1
	  BRA    HELP_3                 see if 68040 etc.
@


51.5
log
@small change.
@
text
@a550 5
* For 68040, do one more thing, Flush caches. JWH 2/13/91
	  btst  #3,SYSFLAG2
	  bne   DR_GOOD                 only a worry on the 68040
	  jsr   ASM_FLUSH_ICACHE
* end of code for '040 JWH 9/24/90
d628 1
a628 5
* For 68040, do one more thing, Flush caches. JWH 2/13/91
	  btst  #3,SYSFLAG2
	  bne   no_40                   only a worry on 68040
	  jsr   ASM_FLUSH_ICACHE
no_40     RTS                                                           scs
d713 1
d717 1
a717 1
* Following helps the DROPDMA put back DTT1, if it should
d724 1
a724 1
	  lea    DMA0(A5),a1
d730 1
d735 1
a735 1
	  lea    DMA1(A5),a1
@


51.4
log
@small change ...
@
text
@d718 2
a719 1
	  movec  #0,DTT1                writethrough mode
@


51.3
log
@Added a bunch of code to TESTDMA and DROPDMA to help with the 68040
and the problems caused by copyback mode with DMA. This code should
prevent the processor from being in copyback mode when there are
any active DMA channels.
@
text
@d122 1
@


51.2
log
@Modified this file so that ASM_FLUSH_ICACHE is called before DMA
in the case of the 68040. JWH 2/13/91. 
@
text
@d667 1
a667 1
	  BEQ.S  TESTDMA_B              IF SO, THEN RET 3
d673 2
a674 1
	  BEQ.S  TESTDMA_B              IF HARDWARE PRESENT BUT BUSY,same as not there
d679 74
d792 2
a793 1
	  BRA.S  DROPDMA1               GO DO IT
d800 1
@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@a119 2
*  JWH  9/24/90 :
	  REFA   ASM_INV_CACHES  used to inv 68040 caches after DMA
a121 2
	  LMODE  ASM_INV_CACHES
	  LMODE  save_dtt1          jwh 9/24/90
d550 1
a550 2
* For 68040, do one more thing. Flush caches, and make sure DTT1
* register now indicates writethrough mode
d552 2
a553 10
	  bne   DR_GOOD
	  trap #11
	  move.l  d0,-(SP)  get a register
	  movec   DTT1,d0
	  move.l  d0,save_dtt1
	  andi.l  #0,d0         just shut it down
	  movec   d0,dtt1
	  CPUSHA  DC/IC       flush, invalidate both caches
	  move.l  (SP)+,d0    restore d0
	  move    (SP)+,SR    restore SR
d632 1
a632 2
* For 68040, do one more thing. Flush caches, and make sure DTT1
* register now indicates writethrough mode
d634 2
a635 10
	  bne   no_40
	  trap #11
	  move.l  d0,-(SP)  get a register
	  movec   DTT1,d0
	  move.l  d0,save_dtt1
	  andi.l  #0,d0         just shut it down
	  movec   d0,dtt1
	  CPUSHA  DC/IC       flush, invalidate both caches
	  move.l  (SP)+,d0    restore d0
	  move    (SP)+,SR    restore SR
a636 1
save_dtt1 dc.l  $00000000   storage for DTT1
d699 4
a702 15
* added for 68040 support. if we have an '040, we want to
* mark all the cache entries invalid and
* restore the DTT1 in effect when the DMA was first initiated
	  BTST   #3,SYSFLAG2
	  bne    try_20
	  trap   #11      got an '040
	  jsr    ASM_INV_CACHES  mark all cache entries invalid
	  move.l  d0,-(SP)
	  move.l  save_dtt1,d0
	  movec   d0,DTT1        put back what was there before DMA
	  move.l  (SP)+,d0       restore d0
	  move    (SP)+,SR
	  BRA    DODROP          carry on
* end of '040 special stuff
try_20    BTST   #GOT_68020,SYSFLAG2    CHECK IF WE HAVE 68020
d704 1
@


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


49.3
log
@Fixed a minor bug I introduced with my last changes.
@
text
@@


49.2
log
@Enhanced dma_request, getdma, and dropdma for 68040 copyback mode.
@
text
@d566 1
a566 1
	  move.w  (SP)+,SR    restore SR
d657 1
a657 1
	  move.w  (SP)+,SR    restore SR
d733 1
a733 1
	  move.w  (SP)+,SR
@


49.1
log
@Automatic bump of revision number for PWS version 3.24b
@
text
@d120 2
d124 2
d554 14
d645 15
a659 1
	  RTS                                                           scs
d722 15
a736 1
	  BTST   #GOT_68020,SYSFLAG2    CHECK IF WE HAVE 68020
@


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.2
log
@added the routines from the cbit module and changed the names from
bit_* to bin*.
@
text
@@


1.1
log
@Initial revision
@
text
@d64 8
d74 12
a85 8
	  DEF IOCOMASM_IOCOMASM
	  DEF IOCOMASM_DMA_REQUEST
	  DEF IOCOMASM_DMA_RELEASE
	  DEF IOCOMASM_BIT_SET
	  DEF IOCOMASM_BINAND
	  DEF IOCOMASM_BINIOR
	  DEF IOCOMASM_BINEOR
	  DEF IOCOMASM_BINCMP
a767 1
	  END
d769 41
@
