 PAGE   1 [3.3a] 6/28/89 17:43:54  ASSEMBLY OF GPIO.TEXT

PASS 1 COMPLETE. ERRORS: 0
    1                       *  sccs info:  @(#)  gpio  8.1  84/05/04  00:17:44  *
    2                       
    3                               nosyms
    4                       
    5                       *
    6                       * global or common symbol declarations
    7                       *
    8                                       nolist
  194                       
  195                       *
  196                       * define constants for timer routines
  197                       *
  198             FFFF FEDA sysflag2        equ     $FFFFFEDA       location of sysflag2
  199             0000 0001 timer_absent    equ     1               1 for no timer, 0 for timer
  200             0000 0000 M68000          equ     0               1 for 68000, 0 for 68010/12
  201                       
  202                       *******************************************************************************
  203                       *                            Pascal Interface Text                           *
  204                       ******************************************************************************
  205                       
  206                               mname   gp
  207                       
  208                        src      module gp;
  209                        src
  210                        src      import
  211                        src        brdecs;
  212                        src
  213                        src      export
  214                        src        type
  215                        src          gpiotype = { gpio interface card definition }
  216                        src            packed record case integer of
  217                        src              0: {direct byte access}
  218                        src                ( r0,r1,r2,r3,r4,r5,r6,r7: unsgn8 );
  219                        src              1: {read access}
  220                        src                ( {r0}  R0pad:0..127; ready:boolean;
  221                        src                  {r1}  R1pad:0..7; cardid:0..31;
  222                        src                  {r2}  R2pad: unsgn8;
  223                        src                  {r3}  Renab,req:boolean; intlevel:0..3; burst,Rword,Rdmac1,Rdmac0: boolean;
  224                        src                  {r4}  Rdata:
  225                        src                  {r5}    signed16;
  226                        src                  {r6}  R6pad:unsgn8;
  227                        src                  {r7}  R7pad:0..15; psts,eir,sti1,sti0:boolean );
  228                        src              2: {write access}
  229                        src                ( {r0}  setpctl:unsgn8;
  230                        src                  {r1}  reset:unsgn8;
  231                        src                  {r2}  W2pad:0..63; rdyen,eiren:boolean;
  232                        src                  {r3}  Wenab:boolean; W3pad:0..15; Wword,Wdmac1,Wdmac0: boolean;
  233                        src                  {r4}  Wdata:
  234                        src                  {r5}    signed16;
  235                        src                  {r6}  W6pad:unsgn8;
  236                        src                  {r7}  W7pad:0..63; ctl1,ctl0:boolean )
  237                        src            end; { gpio interface card definition }
  238                        src
  239                        src        var
  240                        src          dma0_disarm[5242880]: signed16;
  241                        src
  242                        src        procedure gpioclear  (var gpio: gpiotype);
  243                        src        procedure gpiowordout(var gpio: gpiotype; datum: signed16);

 PAGE   2 [3.3a] 6/28/89 17:43:54  ASSEMBLY OF GPIO.TEXT

  244                        src        function  gpiowordin (var gpio: gpiotype): signed16;
  245                        src        procedure gpiodmain  (var gpio: gpiotype; command: signed16; buffer: charptr; length: intege
  246                        src
  247                        src    end; {gpio}

 PAGE   3 [3.3a] 6/28/89 17:43:54  ASSEMBLY OF GPIO.TEXT

  249                       *
  250                       * Def's & Ref's
  251                       *
  252                               def     gp_gpio
  253                               def     gp_gpioclear
  254                               def     gp_gpiowordout
  255                               def     gp_gpiowordin
  256                               def     gp_gpiodmain
  257                               refa    start_timer,check_timer,delay,milli_to_micro
  258                       
  259                       *
  260                       * module initialization routine
  261                       *
  262    00000000 4E75      gp_gpio  rts
  263                       
  264                       
  265                       *
  266                       * escape(ec_bad_error_state) exit for all procedures
  267                       *
  268    00000002 7006      escape_bes      moveq   #ec_bad_error_state,d0
  269                       
  270    00000004 3B40 FFFE escape          move    d0,-2(a5)               set the escapecode
  271    00000008 4E4A                      trap    #10                     escape
  272                       
  273                       
  274                       ******************************************************************************
  275                       *                                  gpioclear                                 *
  276                       *                                                                            *
  277                       *     Modified by:      Anny Randel                                          *
  278                       *     Date:             Dec. 14, 1983                                        *
  279                       *     Purpose:          Use timer when present                               *
  280                       ******************************************************************************
  281                       
  282    0000000A 205F      gp_gpioclear    movea.l (sp)+,a0                pop the return address
  283    0000000C 225F                      movea.l (sp)+,a1                pop the gpiocard base address
  284    0000000E 1340 0001                 move.b  d0,1(a1)                reset the card
  285    00000012 137C 0000                 move.b  #0,7(a1)                clear ctl1 & clt0
                  0007 
  286    00000018 4ED0                      jmp     (a0)                    return
  287                       
  288                       *
  289                       *  gpiowaitrdy with 2 second timeout
  290                       *
  291                       
  292                       ******** START OF ANNY'S CHANGES *******
  293    0000001A 0838 0001 waitready       btst    #timer_absent,sysflag2  timer absent?
                  FEDA 
  294    00000020 662C                      bne.s   waitready1              branch if so
  295    00000022 2F3C 001E                 move.l  #2000000,-(sp)          push microsec value (2 secs)
                  8480 
  296    00000028 4857                      pea     (sp)                    push loc
  297    0000002A 4EB8 0000                 jsr     start_timer             get timeout value
  298    0000002E 201F      waitreadylp1    move.l  (sp)+,d0                pop timeout value into d0
  299    00000030 0829 0003                 btst    #3,7(a1)                peripheral status?
                  0007 
  300    00000036 66CA                      bne     escape_bes              escape(ec_bad_error_state) if so
  301    00000038 0811 0000                 btst    #0,(a1)                 ready?

 PAGE   4 [3.3a] 6/28/89 17:43:54  ASSEMBLY OF GPIO.TEXT

  302    0000003C 662C                      bne.s   waitready_rts           return if so
  303    0000003E 2F00                      move.l  d0,-(sp)                push timeout value
  304    00000040 4857                      pea     (sp)                    push it's location
  305    00000042 4EB8 0000                 jsr     check_timer             timed out yet???
  306    00000046 6AE6                      bpl     waitreadylp1            branch if not timed out
  307    00000048 588F                      addq.l  #4,sp                   pop stack
  308    0000004A 7001                      moveq   #1,d0                   prepare to...
  309    0000004C 6006                      bra.s   waitready_loop          test one more time
  310                       ******** END OF ANNY'S CHANGES *******
  311                       
  312    0000004E 203C 0003 waitready1      move.l  #206185,d0              timeout counter
                  2569 
  313                       
  314    00000054 0829 0003 waitready_loop  btst    #3,7(a1)                peripheral status?
                  0007 
  315    0000005A 66A6                      bne     escape_bes              escape(ec_bad_error_state) if so
  316    0000005C 0811 0000                 btst    #0,(a1)                 ready?
  317    00000060 6608                      bne.s   waitready_rts           branch if so
  318    00000062 5380                      subq.l  #1,d0                   decrement the timeout counter
  319    00000064 6EEE                      bgt     waitready_loop          loop until timeout count exhausted
  320                       
  321    00000066 7001                      moveq   #ec_no_device,d0        escape code
  322    00000068 609A                      bra     escape                  escape
  323                       
  324    0000006A 4E75      waitready_rts   rts                             return

 PAGE   5 [3.3a] 6/28/89 17:43:54  ASSEMBLY OF GPIO.TEXT

  326                       *******************************************************************************
  327                       *                                 gpiowordout                                 *
  328                       *******************************************************************************
  329                       
  330    0000006C 205F      gp_gpiowordout  movea.l (sp)+,a0                pop the return address
  331    0000006E 226F 0002                 movea.l 2(sp),a1                gpio card base address
  332    00000072 61A6                      bsr     waitready               wait until ready
  333    00000074 3357 0004                 move    (sp),4(a1)              output the datum
  334    00000078 1280                      move.b  d0,(a1)                 set pctl
  335    0000007A 5C8F                      addq.l  #6,sp                   pop off the parameters
  336    0000007C 4ED0                      jmp     (a0)                    return
  337                       
  338                       
  339                       *******************************************************************************
  340                       *                                 gpiowordin                                  *
  341                       *******************************************************************************
  342                       
  343    0000007E 205F      gp_gpiowordin   movea.l (sp)+,a0                pop the return address
  344    00000080 225F                      movea.l (sp)+,a1                gpio card base address
  345    00000082 6196                      bsr     waitready               wait until ready
  346    00000084 3EA9 0004                 move    4(a1),(sp)              input the datum
  347    00000088 1280                      move.b  d0,(a1)                 set pctl (same manner as 98032 autohandshake)
  348    0000008A 4ED0                      jmp     (a0)                    return
  349                       

 PAGE   6 [3.3a] 6/28/89 17:43:54  ASSEMBLY OF GPIO.TEXT

  351                       
  352                       *
  353                       * dmain stack frame definition
  354                       *
  355             0000 0000 olda6   equ     +0      (long)          old stack frame pointer
  356             0000 0004 radd    equ     +4      (long)          return address
  357             0000 0008 len     equ     +8      (long)          length of transfer in words
  358             0000 000C buf     equ     +12     (long)          address of buffer
  359             0000 0010 cmnd    equ     +16     (word)          disc command (read/write/verify)
  360             0000 0012 gpio    equ     +18     (long)          gpio card base address
  361                       
  362                       *******************************************************************************
  363                       *                                  gpiodmain                                  *
  364                       *******************************************************************************
  365                       
  366    0000008C 4E56 0000 gp_gpiodmain    link    a6,#0                   create our own stack frame
  367                       
  368    00000090 226E 0012                 movea.l gpio(a6),a1
  369    00000094 6184                      bsr     waitready               wait for previous handshake to complete
  370                       
  371    00000096 40E7                      move    sr,-(sp)                prepare to disable interrupts
  372    00000098 007C 2700                 ori     #$2700,sr               disable interrupts *******************
  373                       
  374    0000009C 336E 0010                 move    cmnd(a6),4(a1)          disc command
                  0004 
  375    000000A2 1280                      move.b  d0,(a1)                 trigger it
  376                       
  377    000000A4 7000                      moveq   #0,d0                   ready bit (register 0)
  378    000000A6 45E9 0007                 lea     7(a1),a2                register 7 address
  379    000000AA 7203                      moveq   #3,d1                   psts bit (register 7)
  380                       
  381    000000AC 0312      di_loop1        btst    d1,(a2)                 peripheral status?
  382    000000AE 660A                      bne.s   di_enab                 fall out of critical section if so
  383    000000B0 0111                      btst    d0,(a1)                 ready?
  384    000000B2 67F8                      beq     di_loop1                loop if not
  385                       
  386    000000B4 4269 0004                 clr     4(a1)                   clear the output buffer
  387    000000B8 1280                      move.b  d0,(a1)                 set pctl, requesting the first word in
  388                       
  389    000000BA 137C 0005 di_enab         move.b  #$05,3(a1)              enable the gpio card for dma
                  0003 
  390    000000C0 45F9 0050                 lea     $500000,a2              dma channel base address
                  0000 
  391    000000C6 24AE 000C                 move.l  buf(a6),(a2)            set the dma address
  392    000000CA 202E 0008                 move.l  len(a6),d0              transfer length
  393    000000CE 5580                      subq.l  #2,d0                   length-2
  394    000000D0 6D0A                      blt.s   di_reni                 branch if one transfer only
  395    000000D2 3540 0004                 move    d0,4(a2)                set the dma count
  396    000000D6 357C 0002                 move    #$0002,6(a2)            arm the dma channel
                  0006 
  397                       
  398    000000DC 46DF      di_reni         move    (sp)+,sr                renable interrupts ********************
  399                       

 PAGE   7 [3.3a] 6/28/89 17:43:54  ASSEMBLY OF GPIO.TEXT

  401                       
  402    000000DE 0829 0003 di_loop2        btst    #3,7(a1)                psts?
                  0007 
  403    000000E4 6600 FF1C                 bne     escape_bes              escape(ec_bad_error_state) if so
  404    000000E8 082A 0000                 btst    #0,7(a2)                dma channel still armed?
                  0007 
  405    000000EE 66EE                      bne     di_loop2                keep looping if so
  406                       
  407    000000F0 7007                      moveq   #ec_bus_error,d0        escapecode if bus error
  408    000000F2 0C6A FFFF                 cmpi    #-1,4(a2)               dma transfer complete normally?
                  0004 
  409    000000F8 6600 FF0A                 bne     escape                  branch if not (bus error)
  410                       
  411    000000FC 6100 FF1C                 bsr     waitready               wait for last handshake to complete
  412    00000100 206E 000C                 movea.l buf(a6),a0              buffer address
  413    00000104 202E 0008                 move.l  len(a6),d0              transfer length in words
  414    00000108 D080                      add.l   d0,d0                   transfer length in bytes
  415    0000010A 31A9 0004                 move    4(a1),-2(a0,d0.l)       transfer last word
                  08FE 
  416                       
  417    00000110 4E5E                      unlk    a6                      remove our stack frame
  418    00000112 205F                      movea.l (sp)+,a0                pop the return address
  419    00000114 DEFC 000E                 adda    #14,sp                  pop off the parameters
  420    00000118 4ED0                      jmp     (a0)                    return
  421                       
  422                                       end
PASS 1 ERRORS: 0
PASS 2 ERRORS: 0
