home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / mpel / mpelFifoOut.s < prev    next >
Text File  |  1992-01-04  |  9KB  |  272 lines

  1. #include    "OSas.h"
  2.  /* waits for fifo to be "NOT_FULL" -- expects PSR in R4 and clobbers */
  3.  /* R0.  needs a label which is passed in.                  */
  4. #define    WAITFIFO1(n)    n : LS R0,0(R4) ; NILZ R0,R0,0x2000 ; JZ n
  5.  
  6. OSHEADER
  7.  
  8.  /*------------------------------------------------------------------------*/
  9.  /* mfCmd0Args(cmd) -- writes byte count (always 4) and then 'cmd' to fifo as */
  10.  /*          soon as room is available.*/
  11.  /*------------------------------------------------------------------------*/
  12.     .text
  13.     .globl TEXT_ENTRY(mfCmd0Args)
  14.     .align 1
  15. TEXT_ENTRY(mfCmd0Args) :
  16.     GET(R4,0xf000094a)    /* get address of PSR into R4*/
  17.                 /* get address of FIFO into 4(R4)*/
  18.  
  19.     CAL    R3,4(R0)    /* load byte count*/
  20.     WAITFIFO1( cmdbcnt )    /* wait for fifo to come ready*/
  21.     STHS    R3,4(R4)    /* write byte count to FIFO*/
  22.  
  23.     WAITFIFO1( cmdcmd )    /* wait for fifo to come ready*/
  24.  
  25.     BRX    R15        /* go home while...*/
  26.     STHS    R2,4(R4)    /* writing 'cmd' to FIFO*/
  27.     .align 2; .byte 0xdf, 2, 0xdf, 0;    /* trace table*/
  28.     .data
  29.     .globl DATA_ENTRY(mfCmd0Args)
  30. DATA_ENTRY(mfCmd0Args) :
  31.     .long    TEXT_ENTRY(mfCmd0Args)
  32.  /*------------------------------------------------------------------------*/
  33.  /* mfCmd1Arg(cmd,arg) --writes [byte count (always 6),cmd,a] to fifo as */
  34.  /*            room is available. */
  35.  /*------------------------------------------------------------------------*/
  36.     .text
  37.     .globl TEXT_ENTRY(mfCmd1Arg)
  38.     .align 1
  39. TEXT_ENTRY(mfCmd1Arg) :
  40.     GET(R4,0xf000094a)    /* get address of PSR into R4*/
  41.                 /* get address of FIFO into 4(R4)*/
  42.  
  43.     WAITFIFO1( cmd1bcnt )    /* wait for fifo to come ready*/
  44.     CAL    R0,6(R0)    /* load byte count*/
  45.     STHS    R0,4(R4)    /* write byte count to FIFO*/
  46.  
  47.     WAITFIFO1( cmd1cmd )    /* wait for fifo to come ready*/
  48.     STHS    R2,4(R4)    /* write command to FIFO*/
  49.  
  50.     WAITFIFO1( cmd1arg )    /* wait for fifo to come ready*/
  51.  
  52.     BRX    R15        /* go home while...*/
  53.     STHS    R3,4(R4)    /* ...writing arg to FIFO*/
  54.     .align 2; .byte 0xdf, 2, 0xdf, 0;    /* trace table*/
  55.     .data
  56.     .globl DATA_ENTRY(mfCmd1Arg)
  57. DATA_ENTRY(mfCmd1Arg) :
  58.     .long    TEXT_ENTRY(mfCmd1Arg)
  59.  /*------------------------------------------------------------------------*/
  60.  /* mfCmd2Args(cmd,a,b) -- writes [byte count (always 8),cmd,arg1,arg2] to*/
  61.  /*            fifo as room is available. */
  62.  /*------------------------------------------------------------------------*/
  63.     .text
  64.     .globl TEXT_ENTRY(mfCmd2Args)
  65.     .align 1
  66. TEXT_ENTRY(mfCmd2Args) :
  67.     GET(R5,0xf000094a)    /* get address of PSR into R5*/
  68.                 /* get address of FIFO into 4(R5)*/
  69.  
  70.     WAITFIFO1( cmd2bcnt )    /* wait for fifo to come ready*/
  71.     CAL    R0,8(R0)    /* load byte count*/
  72.     STHS    R0,4(R5)    /* write byte count to FIFO*/
  73.  
  74.     WAITFIFO1( cmd2cmd )    /* wait for fifo to come ready*/
  75.     STHS    R2,4(R5)    /* write command to FIFO*/
  76.  
  77.     WAITFIFO1( cmd2arg1 )    /* wait for fifo to come ready*/
  78.     STHS    R3,4(R5)    /* write first arg to FIFO*/
  79.  
  80.     WAITFIFO1( cmd2arg2 )    /* wait for fifo to come ready*/
  81.  
  82.     BRX    R15        /* go home while...*/
  83.     STHS    R4,4(R5)    /* ...writing second arg to FIFO*/
  84.     .align 2; .byte 0xdf, 2, 0xdf, 0;    /* trace table*/
  85.     .data
  86.     .globl DATA_ENTRY(mfCmd2Args)
  87. DATA_ENTRY(mfCmd2Args) :
  88.     .long    TEXT_ENTRY(mfCmd2Args)
  89.  
  90.  /*------------------------------------------------------------------------*/
  91.  /* mfNOut(pData,n,&PSR,&FIFO) -- Writes n half-words starting at pData */
  92.  /*        to fifo as soon as room is available.  &PSR should be */
  93.  /*        address of PSR, &FIFO address of FIFO. */
  94.  /*------------------------------------------------------------------------*/
  95.     .text
  96.     .align 1
  97. mfNOut:
  98.     LHS    R0,0(R4)    /* get PSR into R0*/
  99.     NILZ    R0,R0,0x6000    /* AND with FIFO_NOT_HALF_FULL|FIFO_NOT_FULL*/
  100.     JZ    mfNOut        /* fifo is full -- spin.*/
  101.     NILZ    R0,R0,0x4000    /* AND with FIFO_NOT_HALF_FULL*/
  102.     JNZ    writemany    /* less than half full, write lots of words*/
  103. writeone:            /* more than half full, write one word*/
  104.     SIS    R3,2        /* decrement counter*/
  105.     BLR    R15        /* go home if less than 0*/
  106.     LHS    R0,0(R2)    /* load data to be written*/
  107.     INC    R2,2        /* increment pointer*/
  108.     BX    mfNOut        /* branch to check PSR while...*/
  109.     STHS    R0,4(R4)    /* ...writing data to fifo*/
  110. writemany:
  111.     SIS    R3,2        /* decrement counter*/
  112.     BLR    R15        /* go home if less than 0*/
  113.     LHS    R0,0(R2)    /* load data to be written*/
  114.     INC    R2,2        /* increment pointer*/
  115.     STHS    R0,4(R4)    /* write data to fifo*/
  116.     J    writemany    /* loop back to write some more*/
  117.  
  118.  /*------------------------------------------------------------------------*/
  119.  /* mfCmdNArgs(cmd,nBytes,pData) --*/
  120.  /*    writes data to fifo when fifo is ready*/
  121.  /*    if nBytes is odd it is increased by one*/
  122.  /*    nBytes *must* be less than 1024*/
  123.  /*    writes [nBytes,cmd,nBytes-4 of data from pData] */
  124.  /*------------------------------------------------------------------------*/
  125.     .text
  126.     .globl TEXT_ENTRY(mfCmdNArgs)
  127.     .align 1
  128. TEXT_ENTRY(mfCmdNArgs) :
  129.     DEC    R1,4        /* bump stack pointer (need 4 bytes of temp)*/
  130.     CAS    R5,R15,R0    /* save return address in R5*/
  131.     STS    R4,0(R1)    /* save 'pData' on the stack*/
  132.  
  133.     INC    R3,1        /* round nBytes by adding one and...*/
  134.     NILZ    R3,R3,0xfffe    /* ...lopping off low bit */
  135.     GET(R4,0xf000094a)    /* get address of PSR into R4*/
  136.                 /* get address of FIFO into 4(R4)*/
  137.  
  138.     WAITFIFO1( cmdNbcnt )    /* wait for fifo to come ready*/
  139.     STHS    R3,4(R4)    /* write nBytes to FIFO*/
  140.  
  141.     WAITFIFO1( cmdNcmd )    /* wait for fifo to come ready*/
  142.     STHS    R2,4(R4)    /* write 'cmd' to FIFO*/
  143.  
  144.     DEC    R3,4        /* deduct bytes already written from nBytes*/
  145.  
  146.     BALIX    R15,mfNOut    /* call write many function while...*/
  147.     LS    R2,0(R1)    /* ...getting pData off of the stack*/
  148.  
  149.     BRX    R5        /* go home while... Note return address is in R5*/
  150.     INC    R1,4        /* ...restoring stack pointer*/
  151.  
  152.     .align 2; .byte 0xdf, 2, 0xdf, 0;    /* trace table*/
  153.     .data
  154.     .globl DATA_ENTRY(mfCmdNArgs)
  155. DATA_ENTRY(mfCmdNArgs) :
  156.     .long    TEXT_ENTRY(mfCmdNArgs)
  157.  /*------------------------------------------------------------------------*/
  158.  /* mfCmdVArgs(cmd,nBytes,pData,nExtra) --*/
  159.  /*    writes data to fifo when fifo is ready*/
  160.  /*    nBytes *must* be even*/
  161.  /*    if nExtra is odd it is increased by one*/
  162.  /*    writes [nBytes,cmd,nBytes-4 of data from pData] */
  163.  /*------------------------------------------------------------------------*/
  164.     .text
  165.     .globl TEXT_ENTRY(mfCmdVArgs)
  166.     .align 1
  167. TEXT_ENTRY(mfCmdVArgs) :
  168.     DEC    R1,8        /* bump stack pointer (need 12 bytes of temp)*/
  169.     STHS    R3,0(R1)    /* save 'nBytes' on the stack*/
  170.     STS    R4,4(R1)    /* save 'pData' on the stack*/
  171.  
  172.     A    R5,R3        /* add 'nBytes' and 'extra' */
  173.     INC    R5,1        /* round R5 by adding one and...*/
  174.     NILZ    R3,R5,0xfffe    /* ...lopping off low bit (results into R3)*/
  175.     CAS    R5,R15,R0    /* save return address in R5*/
  176.     GET(R4,0xf000094a)    /* get address of PSR into R4*/
  177.                 /* get address of FIFO into 4(R4)*/
  178.  
  179.     WAITFIFO1( cmdVbcnt )    /* wait for FIFO to come ready*/
  180.     STHS    R3,4(R4)    /* write nBytes+extra to FIFO*/
  181.  
  182.     WAITFIFO1( cmdVcmd )    /* wait for FIFO to come ready*/
  183.     STHS    R2,4(R4)    /* write command to FIFO*/
  184.  
  185.     LH    R3,0(R1)    /* get 'nBytes' back from the stack*/
  186.     DEC    R3,4        /* deduct bytes already written*/
  187.     CI    R3,1024        /* is request bigger than half of queue*/
  188.     BH    bigcall        /* too big, branch to bigcall*/
  189.     
  190. smallcall:
  191.     BALIX    R15,mfNOut    /* call write many function while...*/
  192.     LS    R2,4(R1)    /* ...getting pData off of the stack*/
  193.  
  194.     BRX    R5        /* go home while... Note return address is in R5*/
  195.     INC    R1,8        /* ...restoring stack pointer*/
  196.  
  197. bigcall:            /* *** Note *** return address is in R5*/
  198.     CAL    R3,-1024(R3)    /* decrement 'nBytes'*/
  199.     STHS    R3,0(R1)    /* save new 'nBytes' on the stack*/
  200.     CAL    R3,1024(R0)    /* set counter to 1024*/
  201.  
  202.     BALIX    R15,mfNOut    /* call write many function while...*/
  203.     LS    R2,4(R1)    /* ...getting pData off of the stack*/
  204.  
  205.     LH    R3,0(R1)    /* get (new) 'nBytes' from the stack*/
  206.     CI    R3,1024        /* still too big?*/
  207.     BHX    bigcall        /* yup, jump to big call again while...*/
  208.     STS    R2,4(R1)    /* ...saving new value of 'pData'*/
  209.     J    smallcall    /* nope, make last call and get out of here*/
  210.  
  211.     .align 2; .byte 0xdf, 2, 0xdf, 0;    /* trace table*/
  212.     .data
  213.     .globl DATA_ENTRY(mfCmdVArgs)
  214. DATA_ENTRY(mfCmdVArgs) :
  215.     .long    TEXT_ENTRY(mfCmdVArgs)
  216.  /*------------------------------------------------------------------------*/
  217.  /* mfData(pData,nBytes)*/
  218.  /*    writes data to fifo when fifo is ready*/
  219.  /*    writes [nBytes of data from pData] */
  220.  /**/
  221.     .text
  222.     .globl TEXT_ENTRY(mfData)
  223.     .align 1
  224. TEXT_ENTRY(mfData) :
  225.     DEC    R1,8        /* increase stack pointer (need 8 bytes)*/
  226.     CAS    R5,R15,R0    /* save return address in R5*/
  227.  
  228.     GET(R4,0xf000094a)    /* get address of PSR into R4*/
  229.                 /* get address of FIFO into 4(R4)*/
  230.  
  231.     INC    R3,1        /* round R3 by adding one and...*/
  232.     NILZ    R3,R3,0xfffe    /* ...lopping off low bit*/
  233.     CI    R3,1024        /* how big is nBytes?*/
  234.     BHX    bigcall        /* too big -- branch to bigcall...*/
  235.     STS    R2,4(R1)    /* ...while storing pData on stack*/
  236.  
  237.     BALI    R15,mfNOut    /* call write many function */
  238.  
  239.     BRX    R5        /* go home while... Note return address is in R5*/
  240.     INC    R1,8        /* ...restoring stack pointer*/
  241.  
  242.     .align 2; .byte 0xdf, 2, 0xdf, 0;    /* trace table*/
  243.     .data
  244.     .globl DATA_ENTRY(mfData)
  245. DATA_ENTRY(mfData) :
  246.     .long    TEXT_ENTRY(mfData)
  247.  
  248. #ifdef BSDrt
  249. /* mpelCopy(short *from, short *to, int nwords) */
  250.     .data
  251.     .align    2
  252.     .globl    DATA_ENTRY(mpelCopy)
  253.     .globl    TEXT_ENTRY(mpelCopy)
  254. DATA_ENTRY(mpelCopy):
  255.     .long    TEXT_ENTRY(mpelCopy)
  256.  
  257.     .text
  258.     .align    2
  259. TEXT_ENTRY(mpelCopy):
  260.     ail    r3,r3,-4
  261. 0:                /* this is word aligned */
  262.     ls    r0,0(r2)
  263.     inc    r2,4
  264.     inc    r3,4
  265.     sths    r0,2(r3)
  266.     sri16    r0,0
  267.     sths    r0,0(r3)
  268.     sis    r4,2
  269.     jh    0b
  270.     br    r15
  271. #endif
  272.