fga002Dma.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:4k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* fga002Dma.c - FGA-002 DMA library */
  2. /* Copyright 1984-1996 Wind River Systems, Inc. */
  3. #include "copyright_wrs.h"
  4. /*
  5. modification history
  6. --------------------
  7. 01c,21jun96,wlf  doc: cleanup.
  8. 01b,28may96,dat  Updated with TechSupport patch for SPR #2211
  9. 01a,03aug92,ccc  written for the frc30.
  10. */
  11. /*
  12. DESCRIPTION
  13. These routines provide DMA transfer for the mb87031 SCSI chip using the
  14. FGA-002 DMA function.
  15. */
  16. #ifdef INCLUDE_SCSI
  17. #ifdef INCLUDE_SCSI_DMA
  18. #include "cacheLib.h"
  19. #include "logLib.h"
  20. #define DMA_FUNCTION_CODE (0x05)
  21. /*******************************************************************************
  22. *
  23. * fgaDmaTransfer - start the DMA data transfer
  24. *
  25. * This routines initializes the DMA, and starts the transfer
  26. *
  27. * NOMANUAL
  28. */
  29. void fgaDmaTransfer
  30.     (
  31.     UINT8 *pBuffer, /* ptr to the data buffer  */
  32.     int    bufLength, /* number of bytes to xfer */
  33.     int    direction /* direction of transfer   */
  34.     )
  35.     {
  36.     *FGA_DMATRFCNT = (long) bufLength;
  37.     if (direction == O_RDONLY)
  38. {
  39. /* FLUSH any shared CACHE lines */
  40. cacheFlush (DATA_CACHE, pBuffer, 1);
  41. cacheFlush (DATA_CACHE, pBuffer + bufLength, 1);
  42. *FGA_DMADSTADR = (long) pBuffer;
  43. *FGA_DMASRCATT = FGA_DMA_AUX_BUS;
  44. *FGA_DMADSTATT = FGA_DMA_MAIN_MEMORY |
  45.  DMA_FUNCTION_CODE;
  46. *FGA_DMAGENERAL = FGA_DMA_SRC_NO_COUNT |
  47.   FGA_DMA_DST_COUNTS   |
  48.   FGA_DMA_ENABLE;
  49. }
  50.     else
  51. {
  52. /* flush entire CACHE if more than 1/2 */
  53. if (bufLength < 0x800)
  54.     cacheFlush (DATA_CACHE, pBuffer, bufLength);
  55. else
  56.     cacheFlush (DATA_CACHE, 0, ENTIRE_CACHE);
  57. *FGA_DMASRCADR = (long) pBuffer;
  58. *FGA_DMASRCATT = FGA_DMA_MAIN_MEMORY |
  59.  DMA_FUNCTION_CODE;
  60. *FGA_DMADSTATT = FGA_DMA_AUX_BUS;
  61. *FGA_DMAGENERAL = FGA_DMA_SRC_COUNTS |
  62.   FGA_DMA_DST_NO_COUNT |
  63.   FGA_DMA_ENABLE;
  64. }
  65.     *FGA_DMARUNCTL = 0x01; /* start the DMA transfer */
  66.     /*XXX*/
  67.     while ((*FGA_DMARUNCTL & 0x80) == 0x80)
  68. ;
  69.     if (direction == O_RDONLY)
  70. cacheInvalidate (DATA_CACHE, pBuffer, bufLength);
  71.     }
  72. /********************************************************************************
  73. * fgaDmaBytesIn - input SCSI data bytes using on-board DMA
  74. *
  75. * This routine gets passed to the mb87030CtrlCreate() call when DMA should
  76. * be used for SCSI DATA IN transfers.
  77. *
  78. * RETURNS: OK or ERROR.
  79. *
  80. * SEE ALSO: mb87030Lib
  81. *
  82. * NOMANUAL
  83. */
  84. STATUS fgaDmaBytesIn
  85.     (
  86.     SCSI_PHYS_DEV *pScsiPhysDev,       /* ptr to phys dev info    */
  87.     UINT8 *pBuffer,                    /* ptr to the data buffer  */
  88.     int bufLength                      /* number of bytes to xfer */
  89.     )
  90.     {
  91.     fgaDmaTransfer (pBuffer, bufLength, O_RDONLY);
  92.     return (OK);
  93.     }
  94.  
  95. /********************************************************************************
  96. * fgaDmaBytesOut - output SCSI data bytes using on-board DMA
  97. *
  98. * This routine passes control to mb87030CtrlCreate() when DMA should
  99. * be used for SCSI DATA OUT transfers.
  100. *
  101. * RETURNS: OK or ERROR.
  102. *
  103. * SEE ALSO: mb87030Lib
  104. *
  105. * NOMANUAL
  106. */
  107.  
  108. STATUS fgaDmaBytesOut
  109.     (
  110.     SCSI_PHYS_DEV *pScsiPhysDev,       /* ptr to phys dev info    */
  111.     UINT8 *pBuffer,                    /* ptr to the data buffer  */
  112.     int bufLength                      /* number of bytes to xfer */
  113.     )
  114.     {
  115.     fgaDmaTransfer (pBuffer, bufLength, O_WRONLY);
  116.     return (OK);
  117.     }
  118.  
  119. /********************************************************************************
  120. * fgaDmaIntr - Force FGA-002 SCSI DMA interrupt routine
  121. *
  122. * This routine connects to the interrupt vector when handling SCSI DMA
  123. * operations.
  124. *
  125. * RETURNS: N/A.
  126. *
  127. * NOMANUAL
  128. */
  129.  
  130. void fgaDmaIntr
  131.     (
  132.     MB_87030_SCSI_CTRL *pSbic     /* ptr to SBIC info */
  133.     )
  134.     {
  135.     if (scsiIntsDebug)
  136.         logMsg ("fgaDmaIntr called.n", 0, 0, 0, 0, 0, 0);
  137.     *FGA_ISDMANORM = 0x00; /* write anything to clear interrupt */
  138.     *pSbic->pSctlReg |= SPC_SCTL_INT_ENBL;  /* spcIntsEnable (pSpc); */
  139.     }
  140.        
  141. #endif  /* INCLUDE_SCSI_DMA */
  142. #endif /* INCLUDE_SCSI */