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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


desc
@Base file for PWS 3.2 release.

@


56.3
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@		nosyms
		mname   gp

 src      module gp;
 src
 src      import
 src        sysglobals, mini;
 src
 src      export
 src        type
 src          gpiotype = { gpio interface card definition }
 src            packed record case integer of
 src              0: {direct byte access}
 src                ( r0,r1,r2,r3,r4,r5,r6,r7: byte );
 src              1: {read access}
 src                ( {r0}  R0pad:0..127; ready:boolean;
 src                  {r1}  R1pad:0..7; cardid:0..31;
 src                  {r2}  R2pad: byte;
 src                  {r3}  Renab,req:boolean; intlevel:0..3; burst,Rword,Rdmac1,Rdmac0: boolean;
 src                  {r4}  Rdata:
 src                  {r5}    shortint;
 src                  {r6}  R6pad:byte;
 src                  {r7}  R7pad:0..15; psts,eir,sti1,sti0:boolean );
 src              2: {write access}
 src                ( {r0}  setpctl:byte;
 src                  {r1}  reset:byte;
 src                  {r2}  W2pad:0..63; rdyen,eiren:boolean;
 src                  {r3}  Wenab:boolean; W3pad:0..15; Wword,Wdmac1,Wdmac0: boolean;
 src                  {r4}  Wdata:
 src                  {r5}    shortint;
 src                  {r6}  W6pad:byte;
 src                  {r7}  W7pad:0..63; ctl1,ctl0:boolean )
 src            end; { gpio interface card definition }
 src
 src          gpio_r3_type = {separate declaration for use with structured constants}
 src            packed record
 src              {r3}  Wenab:boolean; W3pad:0..15; Wword,Wdmac1,Wdmac0: boolean;
 src            end;
 src
 src          dmachanneltype = packed array[0..7] of byte;
 src
 src        var
 src          dma_port[5242880]: array[0..1] of dmachanneltype;
 src
 src        procedure gpioclear    (var gpio: gpiotype);
 src        procedure gpiowordout  (var gpio: gpiotype; datum: shortint);
 src        function  gpiowordin   (var gpio: gpiotype): shortint;
 src        procedure gpiodmaout   (var gpio: gpiotype;
 src                                command: shortint;
 src                                enable_byte: gpio_r3_type;
 src                                var dma_channel: dmachanneltype;
 src                                buffer: charptr; length: integer);
 src        procedure gpiodmain    (var gpio: gpiotype;
 src                                command: shortint;
 src                                enable_byte: gpio_r3_type;
 src                                var dma_channel: dmachanneltype;
 src                                buffer: charptr; length: integer);
 src    end; {gpio}
	page
*
* dmaout/dmain stack frame definitions
*
olda6     equ     +0      (long)          old stack frame pointer
radd      equ     +4      (long)          return address
len       equ     +8      (long)          length of transfer in words
buf       equ     +12     (long)          address of buffer
chan      equ     +16     (long)          dma channel base address
enab      equ     +20     (byte)          gpio dma enable byte
stackpad  equ     +21     (byte)          unused - caused by pushing byte on stack
cmnd      equ     +22     (word)          disc command (read/write/verify)
gpio      equ     +24     (long)          gpio card base address


*
* Def's & Ref's
*
		def     gp_gp
		def     gp_gpioclear
		def     gp_gpiowordout
		def     gp_gpiowordin
		def     gp_gpiodmaout
		def     gp_gpiodmain

		refa    sysglobals
		refa    mini_ioresc
		refa    check_timer                jws 8/10/83

		lmode   mini_ioresc
		lmode   check_timer                jws 8/10/83

timer_present   equ 1                              jws 8/10/83
sysflag2        equ $fffffeda                      jws 8/10/83



*
* module initialization routine
*
gp_gp           rts


*
* ioresult assignments
*
ztimeout        equ     4
zcatchall       equ     21


*
* error exits
*
ioresc_catchall moveq   #zcatchall,d0           zcatchall ioresult

ioresc          move    d0,-(sp)                push the ioresult
		jsr     mini_ioresc             set ioresult then escape(-10)


bus_error       move    #-12,sysglobals-2(a5)   set the escapecode
		trap    #10                     escape
		page
*
* gpiowaitready with 2 second timeout
*
waitready       move.l  #206,d0              timeout counter
*
* Counter changed to be about 1 ms at 16 MHz -- was 206185
*   by jws 8/10/83
*

waitready_loop  btst    #3,7(a1)                peripheral status?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    #0,(a1)                 ready?
		bne.s   waitready_rts           branch if so
		subq.l  #1,d0                   decrement the timeout counter
		bgt     waitready_loop          loop until timeout count expired
*
*   Low data rate if we get here, so use timer if have it    jws 8/10/83
*   8 MHz loop code is duplicated from above                 jws 8/10/83
*                                                            jws 8/10/83
		btst    #timer_present,sysflag2              jws 8/10/83
		beq.s   waitready_timer         use timer    jws 8/10/83
		move.l  #206185,d0       else set 2 sec loop jws 8/10/83
waitready_loop2  btst    #3,7(a1)                peripheral status?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    #0,(a1)                 ready?
		bne.s   waitready_rts           branch if so
		subq.l  #1,d0                   decrement the timeout counter
		bgt     waitready_loop2         loop until timeout count expired
		bra.s   wait_timeout            timeout on 2sec loop  jws
*
waitready_timer equ    *                                     jws 8/10/83
		move.b  #1,-(sp)         setup timer record  jws 8/10/83
		move.l  #2000,-(sp)      time to wait        jws 8/10/83
waitready_tloop btst    #3,7(a1)         check psts          jws 8/10/83
		bne     ioresc_catchall  if not there,escape jws 8/10/83
		btst    #0,(a1)          check card ready    jws 8/10/83
		bne.s   waitready_texit  if so then done     jws 8/10/83
		pea     (sp)             point to timer rec  jws 8/10/83
		jsr     check_timer      timed out?          jws 8/10/83
		bpl     waitready_tloop  no--try again       jws 8/10/83
		addq    #6,sp            yes, clean stack    jws 5/2/84
		moveq   #10,d0           give one more try   jws 5/2/84
		bra     waitready_loop2  with a short count  jws 5/2/84
waitready_texit addq    #6,sp            cleanup stack       jws 8/10/83
waitready_rts   rts                      and continue        jws 8/10/83


wait_timeout    moveq   #ztimeout,d0            ztimeout ioresult
		bra     ioresc                  escape



******************************************************************************
*                                  gpioclear                                 *
******************************************************************************

gp_gpioclear    movea.l (sp)+,a0                pop the return address
		movea.l (sp)+,a1                pop the gpio card base address
		move.b  d0,1(a1)                reset the card
		move.l  #200,d0                 prepare to...
*
* Count changed from 100 to 200 for 16 MHz processors jws 8/10/83
*
		dbra    d0,*                    wait a while...
		clr.b   7(a1)                   clear ctl1 & clt0
		bsr     waitready               before testing psts & ready
		jmp     (a0)                    return


*******************************************************************************
*                                 gpiowordout                                 *
*******************************************************************************

gp_gpiowordout  movea.l (sp)+,a0                pop the return address
		movea.l 2(sp),a1                gpio card base address
		bsr     waitready               wait until ready
		move    (sp),4(a1)              output the datum
		move.b  d0,(a1)                 set pctl
		addq.l  #6,sp                   pop off the parameters
		jmp     (a0)                    return


*******************************************************************************
*                                 gpiowordin                                  *
*******************************************************************************

gp_gpiowordin   movea.l (sp)+,a0                pop the return address
		movea.l (sp)+,a1                gpio card base address
		bsr     waitready               wait until ready
		move    4(a1),(sp)              input the datum
		move.b  d0,(a1)                 set pctl (same manner as 98032 autohandshake)
		jmp     (a0)                    return
		page
*******************************************************************************
*                                 gpiodmaout                                  *
*******************************************************************************

gp_gpiodmaout   link    a6,#0                   create our own stack frame

		movea.l gpio(a6),a1             gpio card base address
		bsr     waitready               wait for previous handshake to complete

		trap    #11                     move into supervisor mode       (scs)
* scs           move    sr,-(sp)                prepare to disable interrupts
		ori     #$2700,sr               disable interrupts *******************

		move    cmnd(a6),4(a1)          disc command
		move.b  d0,(a1)                 set pctl
		move.b  enab(a6),3(a1)          enable the gpio card for dma

		movea.l chan(a6),a2             dma channel base address
		move.l  buf(a6),(a2)            set the dma address
		move.l  len(a6),d0              transfer length
		subq.l  #1,d0                   length-1
		move    d0,4(a2)                set the dma count
		move    #$0006,6(a2)            arm the dma channel

		move    (sp)+,sr                re-enable interrupts ******************

		lea     7(a1),a3                gpio register 7 address
		moveq   #3,d0                   psts bit (gpio register 7)
		lea     7(a2),a4                dma status lower byte address
		moveq   #0,d1                   armed bit (dma status register)

do_loop         btst    d0,(a3)                 psts?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    d1,(a4)                 dma channel still armed?
		bne     do_loop                 keep looping if so

		cmpi    #-1,4(a2)               dma transfer complete normally?
		bne     bus_error               branch if not (bus error)

		bsr     waitready               wait for the final handshake to complete

		unlk    a6                      remove our stack frame
		movea.l (sp)+,a0                pop the return address
		adda    #20,sp                  pop off the parameters
		jmp     (a0)                    return

		page
*******************************************************************************
*                                  gpiodmain                                  *
*******************************************************************************

gp_gpiodmain    link    a6,#0                   create our own stack frame

		movea.l gpio(a6),a1             gpio card base address
		bsr     waitready               wait for previous handshake to complete

		trap    #11                     move into supervisor mode       (scs)
* scs           move    sr,-(sp)                prepare to disable interrupts
		ori     #$2700,sr               disable interrupts *******************

		move    cmnd(a6),4(a1)          disc command
		move.b  d0,(a1)                 set pctl

		moveq   #0,d0                   ready bit (register 0)
		lea     7(a1),a2                register 7 address
		moveq   #3,d1                   psts bit (register 7)

d_loop          btst    d1,(a2)                 peripheral status?
		bne.s   d_enab                  fall out of the critical section if so
		btst    d0,(a1)                 ready?
		beq     d_loop                  branch if not

		clr     4(a1)                   clear the output buffer
		move.b  d0,(a1)                 set pctl, requesting the first word in

d_enab          move.b  enab(a6),3(a1)          enable the gpio card for dma

		movea.l chan(a6),a2             dma channel base address
		move.l  buf(a6),(a2)            set the dma address
		move    #-1,4(a2)               set count to -1 for the case of one transfer
		move.l  len(a6),d0              transfer length
		subq.l  #2,d0                   length-2
		blt.s   di_reni                 branch if one transfer only
		move    d0,4(a2)                set the dma count
		move    #$0002,6(a2)            arm the dma channel

di_reni         move    (sp)+,sr                re-enable interrupts ******************

		lea     7(a1),a3                gpio register 7 address
		moveq   #3,d0                   psts bit (gpio register 7)
		lea     7(a2),a4                dma status lower byte address
		moveq   #0,d1                   armed bit (dma status register)

di_loop         btst    d0,(a3)                 psts?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    d1,(a4)                 dma channel still armed?
		bne     di_loop                 keep looping if so

		page

		cmpi    #-1,4(a2)               dma transfer complete normally?
		bne     bus_error               branch if not (bus error)

		bsr     waitready               wait for last handshake to complete

		movea.l buf(a6),a0              buffer address
		move.l  len(a6),d0              transfer length in words
		add.l   d0,d0                   transfer length in bytes
		move    4(a1),-2(a0,d0.l)       transfer last word

		unlk    a6                      remove our stack frame
		movea.l (sp)+,a0                pop the return address
		adda    #20,sp                  pop off the parameters
		jmp     (a0)                    return


		end







@


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


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 337
		nosyms
		mname   gp

 src      module gp;
 src
 src      import
 src        sysglobals, mini;
 src
 src      export
 src        type
 src          gpiotype = { gpio interface card definition }
 src            packed record case integer of
 src              0: {direct byte access}
 src                ( r0,r1,r2,r3,r4,r5,r6,r7: byte );
 src              1: {read access}
 src                ( {r0}  R0pad:0..127; ready:boolean;
 src                  {r1}  R1pad:0..7; cardid:0..31;
 src                  {r2}  R2pad: byte;
 src                  {r3}  Renab,req:boolean; intlevel:0..3; burst,Rword,Rdmac1,Rdmac0: boolean;
 src                  {r4}  Rdata:
 src                  {r5}    shortint;
 src                  {r6}  R6pad:byte;
 src                  {r7}  R7pad:0..15; psts,eir,sti1,sti0:boolean );
 src              2: {write access}
 src                ( {r0}  setpctl:byte;
 src                  {r1}  reset:byte;
 src                  {r2}  W2pad:0..63; rdyen,eiren:boolean;
 src                  {r3}  Wenab:boolean; W3pad:0..15; Wword,Wdmac1,Wdmac0: boolean;
 src                  {r4}  Wdata:
 src                  {r5}    shortint;
 src                  {r6}  W6pad:byte;
 src                  {r7}  W7pad:0..63; ctl1,ctl0:boolean )
 src            end; { gpio interface card definition }
 src
 src          gpio_r3_type = {separate declaration for use with structured constants}
 src            packed record
 src              {r3}  Wenab:boolean; W3pad:0..15; Wword,Wdmac1,Wdmac0: boolean;
 src            end;
 src
 src          dmachanneltype = packed array[0..7] of byte;
 src
 src        var
 src          dma_port[5242880]: array[0..1] of dmachanneltype;
 src
 src        procedure gpioclear    (var gpio: gpiotype);
 src        procedure gpiowordout  (var gpio: gpiotype; datum: shortint);
 src        function  gpiowordin   (var gpio: gpiotype): shortint;
 src        procedure gpiodmaout   (var gpio: gpiotype;
 src                                command: shortint;
 src                                enable_byte: gpio_r3_type;
 src                                var dma_channel: dmachanneltype;
 src                                buffer: charptr; length: integer);
 src        procedure gpiodmain    (var gpio: gpiotype;
 src                                command: shortint;
 src                                enable_byte: gpio_r3_type;
 src                                var dma_channel: dmachanneltype;
 src                                buffer: charptr; length: integer);
 src    end; {gpio}
	page
*
* dmaout/dmain stack frame definitions
*
olda6     equ     +0      (long)          old stack frame pointer
radd      equ     +4      (long)          return address
len       equ     +8      (long)          length of transfer in words
buf       equ     +12     (long)          address of buffer
chan      equ     +16     (long)          dma channel base address
enab      equ     +20     (byte)          gpio dma enable byte
stackpad  equ     +21     (byte)          unused - caused by pushing byte on stack
cmnd      equ     +22     (word)          disc command (read/write/verify)
gpio      equ     +24     (long)          gpio card base address


*
* Def's & Ref's
*
		def     gp_gp
		def     gp_gpioclear
		def     gp_gpiowordout
		def     gp_gpiowordin
		def     gp_gpiodmaout
		def     gp_gpiodmain

		refa    sysglobals
		refa    mini_ioresc
		refa    check_timer                jws 8/10/83

		lmode   mini_ioresc
		lmode   check_timer                jws 8/10/83

timer_present   equ 1                              jws 8/10/83
sysflag2        equ $fffffeda                      jws 8/10/83



*
* module initialization routine
*
gp_gp           rts


*
* ioresult assignments
*
ztimeout        equ     4
zcatchall       equ     21


*
* error exits
*
ioresc_catchall moveq   #zcatchall,d0           zcatchall ioresult

ioresc          move    d0,-(sp)                push the ioresult
		jsr     mini_ioresc             set ioresult then escape(-10)


bus_error       move    #-12,sysglobals-2(a5)   set the escapecode
		trap    #10                     escape
		page
*
* gpiowaitready with 2 second timeout
*
waitready       move.l  #206,d0              timeout counter
*
* Counter changed to be about 1 ms at 16 MHz -- was 206185
*   by jws 8/10/83
*

waitready_loop  btst    #3,7(a1)                peripheral status?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    #0,(a1)                 ready?
		bne.s   waitready_rts           branch if so
		subq.l  #1,d0                   decrement the timeout counter
		bgt     waitready_loop          loop until timeout count expired
*
*   Low data rate if we get here, so use timer if have it    jws 8/10/83
*   8 MHz loop code is duplicated from above                 jws 8/10/83
*                                                            jws 8/10/83
		btst    #timer_present,sysflag2              jws 8/10/83
		beq.s   waitready_timer         use timer    jws 8/10/83
		move.l  #206185,d0       else set 2 sec loop jws 8/10/83
waitready_loop2  btst    #3,7(a1)                peripheral status?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    #0,(a1)                 ready?
		bne.s   waitready_rts           branch if so
		subq.l  #1,d0                   decrement the timeout counter
		bgt     waitready_loop2         loop until timeout count expired
		bra.s   wait_timeout            timeout on 2sec loop  jws
*
waitready_timer equ    *                                     jws 8/10/83
		move.b  #1,-(sp)         setup timer record  jws 8/10/83
		move.l  #2000,-(sp)      time to wait        jws 8/10/83
waitready_tloop btst    #3,7(a1)         check psts          jws 8/10/83
		bne     ioresc_catchall  if not there,escape jws 8/10/83
		btst    #0,(a1)          check card ready    jws 8/10/83
		bne.s   waitready_texit  if so then done     jws 8/10/83
		pea     (sp)             point to timer rec  jws 8/10/83
		jsr     check_timer      timed out?          jws 8/10/83
		bpl     waitready_tloop  no--try again       jws 8/10/83
		addq    #6,sp            yes, clean stack    jws 5/2/84
		moveq   #10,d0           give one more try   jws 5/2/84
		bra     waitready_loop2  with a short count  jws 5/2/84
waitready_texit addq    #6,sp            cleanup stack       jws 8/10/83
waitready_rts   rts                      and continue        jws 8/10/83


wait_timeout    moveq   #ztimeout,d0            ztimeout ioresult
		bra     ioresc                  escape



******************************************************************************
*                                  gpioclear                                 *
******************************************************************************

gp_gpioclear    movea.l (sp)+,a0                pop the return address
		movea.l (sp)+,a1                pop the gpio card base address
		move.b  d0,1(a1)                reset the card
		move.l  #200,d0                 prepare to...
*
* Count changed from 100 to 200 for 16 MHz processors jws 8/10/83
*
		dbra    d0,*                    wait a while...
		clr.b   7(a1)                   clear ctl1 & clt0
		bsr     waitready               before testing psts & ready
		jmp     (a0)                    return


*******************************************************************************
*                                 gpiowordout                                 *
*******************************************************************************

gp_gpiowordout  movea.l (sp)+,a0                pop the return address
		movea.l 2(sp),a1                gpio card base address
		bsr     waitready               wait until ready
		move    (sp),4(a1)              output the datum
		move.b  d0,(a1)                 set pctl
		addq.l  #6,sp                   pop off the parameters
		jmp     (a0)                    return


*******************************************************************************
*                                 gpiowordin                                  *
*******************************************************************************

gp_gpiowordin   movea.l (sp)+,a0                pop the return address
		movea.l (sp)+,a1                gpio card base address
		bsr     waitready               wait until ready
		move    4(a1),(sp)              input the datum
		move.b  d0,(a1)                 set pctl (same manner as 98032 autohandshake)
		jmp     (a0)                    return
		page
*******************************************************************************
*                                 gpiodmaout                                  *
*******************************************************************************

gp_gpiodmaout   link    a6,#0                   create our own stack frame

		movea.l gpio(a6),a1             gpio card base address
		bsr     waitready               wait for previous handshake to complete

		trap    #11                     move into supervisor mode       (scs)
* scs           move    sr,-(sp)                prepare to disable interrupts
		ori     #$2700,sr               disable interrupts *******************

		move    cmnd(a6),4(a1)          disc command
		move.b  d0,(a1)                 set pctl
		move.b  enab(a6),3(a1)          enable the gpio card for dma

		movea.l chan(a6),a2             dma channel base address
		move.l  buf(a6),(a2)            set the dma address
		move.l  len(a6),d0              transfer length
		subq.l  #1,d0                   length-1
		move    d0,4(a2)                set the dma count
		move    #$0006,6(a2)            arm the dma channel

		move    (sp)+,sr                re-enable interrupts ******************

		lea     7(a1),a3                gpio register 7 address
		moveq   #3,d0                   psts bit (gpio register 7)
		lea     7(a2),a4                dma status lower byte address
		moveq   #0,d1                   armed bit (dma status register)

do_loop         btst    d0,(a3)                 psts?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    d1,(a4)                 dma channel still armed?
		bne     do_loop                 keep looping if so

		cmpi    #-1,4(a2)               dma transfer complete normally?
		bne     bus_error               branch if not (bus error)

		bsr     waitready               wait for the final handshake to complete

		unlk    a6                      remove our stack frame
		movea.l (sp)+,a0                pop the return address
		adda    #20,sp                  pop off the parameters
		jmp     (a0)                    return

		page
*******************************************************************************
*                                  gpiodmain                                  *
*******************************************************************************

gp_gpiodmain    link    a6,#0                   create our own stack frame

		movea.l gpio(a6),a1             gpio card base address
		bsr     waitready               wait for previous handshake to complete

		trap    #11                     move into supervisor mode       (scs)
* scs           move    sr,-(sp)                prepare to disable interrupts
		ori     #$2700,sr               disable interrupts *******************

		move    cmnd(a6),4(a1)          disc command
		move.b  d0,(a1)                 set pctl

		moveq   #0,d0                   ready bit (register 0)
		lea     7(a1),a2                register 7 address
		moveq   #3,d1                   psts bit (register 7)

d_loop          btst    d1,(a2)                 peripheral status?
		bne.s   d_enab                  fall out of the critical section if so
		btst    d0,(a1)                 ready?
		beq     d_loop                  branch if not

		clr     4(a1)                   clear the output buffer
		move.b  d0,(a1)                 set pctl, requesting the first word in

d_enab          move.b  enab(a6),3(a1)          enable the gpio card for dma

		movea.l chan(a6),a2             dma channel base address
		move.l  buf(a6),(a2)            set the dma address
		move    #-1,4(a2)               set count to -1 for the case of one transfer
		move.l  len(a6),d0              transfer length
		subq.l  #2,d0                   length-2
		blt.s   di_reni                 branch if one transfer only
		move    d0,4(a2)                set the dma count
		move    #$0002,6(a2)            arm the dma channel

di_reni         move    (sp)+,sr                re-enable interrupts ******************

		lea     7(a1),a3                gpio register 7 address
		moveq   #3,d0                   psts bit (gpio register 7)
		lea     7(a2),a4                dma status lower byte address
		moveq   #0,d1                   armed bit (dma status register)

di_loop         btst    d0,(a3)                 psts?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    d1,(a4)                 dma channel still armed?
		bne     di_loop                 keep looping if so

		page

		cmpi    #-1,4(a2)               dma transfer complete normally?
		bne     bus_error               branch if not (bus error)

		bsr     waitready               wait for last handshake to complete

		movea.l buf(a6),a0              buffer address
		move.l  len(a6),d0              transfer length in words
		add.l   d0,d0                   transfer length in bytes
		move    4(a1),-2(a0,d0.l)       transfer last word

		unlk    a6                      remove our stack frame
		movea.l (sp)+,a0                pop the return address
		adda    #20,sp                  pop off the parameters
		jmp     (a0)                    return


		end







@


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


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


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


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@a0 337
		nosyms
		mname   gp

 src      module gp;
 src
 src      import
 src        sysglobals, mini;
 src
 src      export
 src        type
 src          gpiotype = { gpio interface card definition }
 src            packed record case integer of
 src              0: {direct byte access}
 src                ( r0,r1,r2,r3,r4,r5,r6,r7: byte );
 src              1: {read access}
 src                ( {r0}  R0pad:0..127; ready:boolean;
 src                  {r1}  R1pad:0..7; cardid:0..31;
 src                  {r2}  R2pad: byte;
 src                  {r3}  Renab,req:boolean; intlevel:0..3; burst,Rword,Rdmac1,Rdmac0: boolean;
 src                  {r4}  Rdata:
 src                  {r5}    shortint;
 src                  {r6}  R6pad:byte;
 src                  {r7}  R7pad:0..15; psts,eir,sti1,sti0:boolean );
 src              2: {write access}
 src                ( {r0}  setpctl:byte;
 src                  {r1}  reset:byte;
 src                  {r2}  W2pad:0..63; rdyen,eiren:boolean;
 src                  {r3}  Wenab:boolean; W3pad:0..15; Wword,Wdmac1,Wdmac0: boolean;
 src                  {r4}  Wdata:
 src                  {r5}    shortint;
 src                  {r6}  W6pad:byte;
 src                  {r7}  W7pad:0..63; ctl1,ctl0:boolean )
 src            end; { gpio interface card definition }
 src
 src          gpio_r3_type = {separate declaration for use with structured constants}
 src            packed record
 src              {r3}  Wenab:boolean; W3pad:0..15; Wword,Wdmac1,Wdmac0: boolean;
 src            end;
 src
 src          dmachanneltype = packed array[0..7] of byte;
 src
 src        var
 src          dma_port[5242880]: array[0..1] of dmachanneltype;
 src
 src        procedure gpioclear    (var gpio: gpiotype);
 src        procedure gpiowordout  (var gpio: gpiotype; datum: shortint);
 src        function  gpiowordin   (var gpio: gpiotype): shortint;
 src        procedure gpiodmaout   (var gpio: gpiotype;
 src                                command: shortint;
 src                                enable_byte: gpio_r3_type;
 src                                var dma_channel: dmachanneltype;
 src                                buffer: charptr; length: integer);
 src        procedure gpiodmain    (var gpio: gpiotype;
 src                                command: shortint;
 src                                enable_byte: gpio_r3_type;
 src                                var dma_channel: dmachanneltype;
 src                                buffer: charptr; length: integer);
 src    end; {gpio}
	page
*
* dmaout/dmain stack frame definitions
*
olda6     equ     +0      (long)          old stack frame pointer
radd      equ     +4      (long)          return address
len       equ     +8      (long)          length of transfer in words
buf       equ     +12     (long)          address of buffer
chan      equ     +16     (long)          dma channel base address
enab      equ     +20     (byte)          gpio dma enable byte
stackpad  equ     +21     (byte)          unused - caused by pushing byte on stack
cmnd      equ     +22     (word)          disc command (read/write/verify)
gpio      equ     +24     (long)          gpio card base address


*
* Def's & Ref's
*
		def     gp_gp
		def     gp_gpioclear
		def     gp_gpiowordout
		def     gp_gpiowordin
		def     gp_gpiodmaout
		def     gp_gpiodmain

		refa    sysglobals
		refa    mini_ioresc
		refa    check_timer                jws 8/10/83

		lmode   mini_ioresc
		lmode   check_timer                jws 8/10/83

timer_present   equ 1                              jws 8/10/83
sysflag2        equ $fffffeda                      jws 8/10/83



*
* module initialization routine
*
gp_gp           rts


*
* ioresult assignments
*
ztimeout        equ     4
zcatchall       equ     21


*
* error exits
*
ioresc_catchall moveq   #zcatchall,d0           zcatchall ioresult

ioresc          move    d0,-(sp)                push the ioresult
		jsr     mini_ioresc             set ioresult then escape(-10)


bus_error       move    #-12,sysglobals-2(a5)   set the escapecode
		trap    #10                     escape
		page
*
* gpiowaitready with 2 second timeout
*
waitready       move.l  #206,d0              timeout counter
*
* Counter changed to be about 1 ms at 16 MHz -- was 206185
*   by jws 8/10/83
*

waitready_loop  btst    #3,7(a1)                peripheral status?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    #0,(a1)                 ready?
		bne.s   waitready_rts           branch if so
		subq.l  #1,d0                   decrement the timeout counter
		bgt     waitready_loop          loop until timeout count expired
*
*   Low data rate if we get here, so use timer if have it    jws 8/10/83
*   8 MHz loop code is duplicated from above                 jws 8/10/83
*                                                            jws 8/10/83
		btst    #timer_present,sysflag2              jws 8/10/83
		beq.s   waitready_timer         use timer    jws 8/10/83
		move.l  #206185,d0       else set 2 sec loop jws 8/10/83
waitready_loop2  btst    #3,7(a1)                peripheral status?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    #0,(a1)                 ready?
		bne.s   waitready_rts           branch if so
		subq.l  #1,d0                   decrement the timeout counter
		bgt     waitready_loop2         loop until timeout count expired
		bra.s   wait_timeout            timeout on 2sec loop  jws
*
waitready_timer equ    *                                     jws 8/10/83
		move.b  #1,-(sp)         setup timer record  jws 8/10/83
		move.l  #2000,-(sp)      time to wait        jws 8/10/83
waitready_tloop btst    #3,7(a1)         check psts          jws 8/10/83
		bne     ioresc_catchall  if not there,escape jws 8/10/83
		btst    #0,(a1)          check card ready    jws 8/10/83
		bne.s   waitready_texit  if so then done     jws 8/10/83
		pea     (sp)             point to timer rec  jws 8/10/83
		jsr     check_timer      timed out?          jws 8/10/83
		bpl     waitready_tloop  no--try again       jws 8/10/83
		addq    #6,sp            yes, clean stack    jws 5/2/84
		moveq   #10,d0           give one more try   jws 5/2/84
		bra     waitready_loop2  with a short count  jws 5/2/84
waitready_texit addq    #6,sp            cleanup stack       jws 8/10/83
waitready_rts   rts                      and continue        jws 8/10/83


wait_timeout    moveq   #ztimeout,d0            ztimeout ioresult
		bra     ioresc                  escape



******************************************************************************
*                                  gpioclear                                 *
******************************************************************************

gp_gpioclear    movea.l (sp)+,a0                pop the return address
		movea.l (sp)+,a1                pop the gpio card base address
		move.b  d0,1(a1)                reset the card
		move.l  #200,d0                 prepare to...
*
* Count changed from 100 to 200 for 16 MHz processors jws 8/10/83
*
		dbra    d0,*                    wait a while...
		clr.b   7(a1)                   clear ctl1 & clt0
		bsr     waitready               before testing psts & ready
		jmp     (a0)                    return


*******************************************************************************
*                                 gpiowordout                                 *
*******************************************************************************

gp_gpiowordout  movea.l (sp)+,a0                pop the return address
		movea.l 2(sp),a1                gpio card base address
		bsr     waitready               wait until ready
		move    (sp),4(a1)              output the datum
		move.b  d0,(a1)                 set pctl
		addq.l  #6,sp                   pop off the parameters
		jmp     (a0)                    return


*******************************************************************************
*                                 gpiowordin                                  *
*******************************************************************************

gp_gpiowordin   movea.l (sp)+,a0                pop the return address
		movea.l (sp)+,a1                gpio card base address
		bsr     waitready               wait until ready
		move    4(a1),(sp)              input the datum
		move.b  d0,(a1)                 set pctl (same manner as 98032 autohandshake)
		jmp     (a0)                    return
		page
*******************************************************************************
*                                 gpiodmaout                                  *
*******************************************************************************

gp_gpiodmaout   link    a6,#0                   create our own stack frame

		movea.l gpio(a6),a1             gpio card base address
		bsr     waitready               wait for previous handshake to complete

		trap    #11                     move into supervisor mode       (scs)
* scs           move    sr,-(sp)                prepare to disable interrupts
		ori     #$2700,sr               disable interrupts *******************

		move    cmnd(a6),4(a1)          disc command
		move.b  d0,(a1)                 set pctl
		move.b  enab(a6),3(a1)          enable the gpio card for dma

		movea.l chan(a6),a2             dma channel base address
		move.l  buf(a6),(a2)            set the dma address
		move.l  len(a6),d0              transfer length
		subq.l  #1,d0                   length-1
		move    d0,4(a2)                set the dma count
		move    #$0006,6(a2)            arm the dma channel

		move    (sp)+,sr                re-enable interrupts ******************

		lea     7(a1),a3                gpio register 7 address
		moveq   #3,d0                   psts bit (gpio register 7)
		lea     7(a2),a4                dma status lower byte address
		moveq   #0,d1                   armed bit (dma status register)

do_loop         btst    d0,(a3)                 psts?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    d1,(a4)                 dma channel still armed?
		bne     do_loop                 keep looping if so

		cmpi    #-1,4(a2)               dma transfer complete normally?
		bne     bus_error               branch if not (bus error)

		bsr     waitready               wait for the final handshake to complete

		unlk    a6                      remove our stack frame
		movea.l (sp)+,a0                pop the return address
		adda    #20,sp                  pop off the parameters
		jmp     (a0)                    return

		page
*******************************************************************************
*                                  gpiodmain                                  *
*******************************************************************************

gp_gpiodmain    link    a6,#0                   create our own stack frame

		movea.l gpio(a6),a1             gpio card base address
		bsr     waitready               wait for previous handshake to complete

		trap    #11                     move into supervisor mode       (scs)
* scs           move    sr,-(sp)                prepare to disable interrupts
		ori     #$2700,sr               disable interrupts *******************

		move    cmnd(a6),4(a1)          disc command
		move.b  d0,(a1)                 set pctl

		moveq   #0,d0                   ready bit (register 0)
		lea     7(a1),a2                register 7 address
		moveq   #3,d1                   psts bit (register 7)

d_loop          btst    d1,(a2)                 peripheral status?
		bne.s   d_enab                  fall out of the critical section if so
		btst    d0,(a1)                 ready?
		beq     d_loop                  branch if not

		clr     4(a1)                   clear the output buffer
		move.b  d0,(a1)                 set pctl, requesting the first word in

d_enab          move.b  enab(a6),3(a1)          enable the gpio card for dma

		movea.l chan(a6),a2             dma channel base address
		move.l  buf(a6),(a2)            set the dma address
		move    #-1,4(a2)               set count to -1 for the case of one transfer
		move.l  len(a6),d0              transfer length
		subq.l  #2,d0                   length-2
		blt.s   di_reni                 branch if one transfer only
		move    d0,4(a2)                set the dma count
		move    #$0002,6(a2)            arm the dma channel

di_reni         move    (sp)+,sr                re-enable interrupts ******************

		lea     7(a1),a3                gpio register 7 address
		moveq   #3,d0                   psts bit (gpio register 7)
		lea     7(a2),a4                dma status lower byte address
		moveq   #0,d1                   armed bit (dma status register)

di_loop         btst    d0,(a3)                 psts?
		bne     ioresc_catchall         ioresc(zcatchall) if so
		btst    d1,(a4)                 dma channel still armed?
		bne     di_loop                 keep looping if so

		page

		cmpi    #-1,4(a2)               dma transfer complete normally?
		bne     bus_error               branch if not (bus error)

		bsr     waitready               wait for last handshake to complete

		movea.l buf(a6),a0              buffer address
		move.l  len(a6),d0              transfer length in words
		add.l   d0,d0                   transfer length in bytes
		move    4(a1),-2(a0,d0.l)       transfer last word

		unlk    a6                      remove our stack frame
		movea.l (sp)+,a0                pop the return address
		adda    #20,sp                  pop off the parameters
		jmp     (a0)                    return


		end







@


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


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


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


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


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


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


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


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


45.1
log
@Automatic bump of revision number for PWS version 3.23C
@
text
@@


44.1
log
@Automatic bump of revision number for PWS version 3.23B
@
text
@@


43.1
log
@Automatic bump of revision number for PWS version 3.23aA
@
text
@@


42.1
log
@Automatic bump of revision number for PWS version 3.23e
@
text
@@


41.1
log
@Automatic bump of revision number for PWS version 3.23d
@
text
@@


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


1.1
log
@Initial revision
@
text
@@
