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

VxWorks

开发平台:

C/C++

  1. /* frcEagle01.c - Force EAGLE-01C module library */
  2. /* Copyright 1984-1992 Wind River Systems, Inc. */
  3. #include "copyright_wrs.h"
  4. /*
  5. modification history
  6. --------------------
  7. 01e,24jun96,wlf  doc: cleanup.
  8. 01d,20oct92,caf  changed sysEagle01Init() to sysEagleInit(), made it NOMANUAL.
  9.  included fga002Dma.c.
  10. 01c,26sep92,ccc  moved SCSI interrupt enable after mb87030CtrlInit().
  11. 01b,22aug92,ccc  fixed sysScsiInit() for new Eagle-01.
  12. 01a,16jul92,caf  created.
  13. */
  14. /*
  15. DESCRIPTION
  16. This library contains routines to manipulate the Force EAGLE-01C
  17. module.  This library addresses initialization, plus the SCSI and
  18. LANCE Ethernet functions of the EAGLE-01C.
  19. */
  20. #include "dma/fga002Dma.c"
  21. /*******************************************************************************
  22. *
  23. * sysEagleInit - initialize the Force EAGLE-01C module hardware
  24. *
  25. * RETURNS: N/A
  26. *
  27. * NOMANUAL
  28. */
  29. void sysEagleInit (void)
  30.     {
  31.     *FGA_ICRLOCAL1 = INT_LVL_FDC | FGA_ICR_AUTOCLEAR;
  32.     *FGA_ICRLOCAL6 = INT_LVL_LANCE;
  33.     *FGA_ICRLOCAL7 = INT_LVL_SCSI | FGA_ICR_AUTOCLEAR | FGA_ICR_ACTIVITY;
  34.     }
  35. /*******************************************************************************
  36. *
  37. * sysLanIntEnable - enable a LAN interrupt level
  38. *
  39. * This routine enables interrupts for the on-board LAN chip at a specified
  40. * level.  LAN interrupts are controlled by the FGA-002 chip.
  41. *
  42. * RETURNS: OK, always.
  43. *
  44. * SEE ALSO: sysLanIntDisable()
  45. */
  46. STATUS sysLanIntEnable
  47.     (
  48.     int intLevel        /* interrupt level to enable */
  49.     )
  50.     {
  51.     /* unmask local LANCE interrupt */
  52.     *FGA_ICRLOCAL6 |= FGA_ICR_ENABLE;
  53.     return (OK);
  54.     }
  55. /*******************************************************************************
  56. *
  57. * sysLanIntDisable - disable a LAN interrupt level
  58. *
  59. * This routine disables a specified interrupt level for the on-board LAN chip.
  60. * LAN interrupts are controlled by the FGA-002 chip.
  61. *
  62. * RETURNS: OK, always.
  63. *
  64. * SEE ALSO: sysLanIntEnable()
  65. */
  66. STATUS sysLanIntDisable (void)
  67.     {
  68.     /* mask LANCE interrupt */
  69.     *FGA_ICRLOCAL6 &= ~FGA_ICR_ENABLE;
  70.     return (OK);
  71.     }
  72. #ifdef INCLUDE_SCSI
  73. #ifdef INCLUDE_SCSI_DMA
  74. /******************************************************************************
  75. *
  76. * sysDmaBytesIn - initialize the DMA data direction
  77. *
  78. * This routine initializes the DMA data direction then calls fgaDmaBytesIn().
  79. *
  80. * RETURNS: The return value from fgaDmaBytesIn().
  81. *
  82. * NOMANUAL
  83. */
  84. STATUS sysDmaBytesIn
  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.     *FRC_SCSI_DMA_CR = FRC_SCSI_DMA_READ;
  92.     return (fgaDmaBytesIn (pScsiPhysDev, pBuffer, bufLength));
  93.     }
  94. /******************************************************************************
  95. *
  96. * sysDmaBytesOut - initialize the DMA data direction
  97. *
  98. * This routine initialized the DMA data direction then calls fgaDmaBytesOut().
  99. *
  100. * RETURNS: The return value from fgaDmaBytesOut().
  101. *
  102. * NOMANUAL
  103. */
  104. STATUS sysDmaBytesOut
  105.     (
  106.     SCSI_PHYS_DEV *pScsiPhysDev, /* ptr to phys dev info    */
  107.     UINT8 *pBuffer, /* ptr to the data buffer  */
  108.     int bufLength /* number of bytes to xfer */
  109.     )
  110.     {
  111.     *FRC_SCSI_DMA_CR &= ~FRC_SCSI_DMA_READ; /* set for write */
  112.     return (fgaDmaBytesOut (pScsiPhysDev, pBuffer, bufLength));
  113.     }
  114. #endif /* INCLUDE_SCSI_DMA */
  115. /******************************************************************************
  116. *
  117. * sysScsiInit - initialize an on-board SCSI port 
  118. *
  119. * This routine creates and initializes a Fujitsu SPC structure, enabling use
  120. * of the on-board SCSI port.  It connects the proper interrupt service
  121. * routine to the desired vector, and enables the interrupt at the desired
  122. * level.
  123. *
  124. * RETURNS: OK, or ERROR if the SPC structure cannot be connected, the
  125. * controller cannot be initialized, or the interrupt service routine cannot be
  126. * connected to the interrupt.
  127. */
  128. STATUS sysScsiInit (void)
  129.     {
  130.     pSysScsiCtrl = (SCSI_CTRL *) mb87030CtrlCreate (FRC40_SPC_BASE_ADRS,
  131.     FRC40_SPC_REG_OFFSET,
  132.     FRC40_SPC_CLK_PERIOD,
  133.     FRC40_SPC_PARITY,
  134. #ifdef INCLUDE_SCSI_DMA
  135.     (FUNCPTR) sysDmaBytesIn,
  136.     (FUNCPTR) sysDmaBytesOut);
  137. #else /* INCLUDE_SCSI_DMA */
  138.     (FUNCPTR) NULL,
  139.     (FUNCPTR) NULL);
  140. #endif /* INCLUDE_SCSI_DMA */
  141.     if (pSysScsiCtrl == NULL)
  142. return (ERROR);
  143.     /* connect the SCSI controller's interrupt service routine */
  144.     if (intConnect (INUM_TO_IVEC (INT_VEC_SCSI), spcIntr, (int) pSysScsiCtrl)
  145. == ERROR)
  146. return (ERROR);
  147.     /* initialize SCSI controller with default parameters (user tunable) */
  148.     if (mb87030CtrlInit ((MB_87030_SCSI_CTRL *)pSysScsiCtrl,
  149.          SCSI_DEF_CTRL_BUS_ID,
  150.          SCSI_DEF_SELECT_TIMEOUT,
  151.            NONE) == ERROR)
  152.         {
  153. return (ERROR);
  154.         }
  155.     /* enable the SPC interrupt */
  156.     *FGA_ICRLOCAL7 |= FGA_ICR_ENABLE;
  157. #ifdef INCLUDE_SCSI_DMA
  158.     /* connect the DMA controller's interrupt service routine */
  159.     if (intConnect (INUM_TO_IVEC (INT_VEC_SCSI_DMA), fgaDmaIntr,
  160.     (int) pSysScsiCtrl) == ERROR)
  161. {
  162. return (ERROR);
  163. }
  164.     *FGA_AUXPINCTL = FGA_AUXPIN_NOAUTOREQ |
  165.      FGA_AUXPIN_RDY_HIGH  |
  166.      FGA_AUXPIN_ACK_LOW   |
  167.      FGA_AUXPIN_REQ_HIGH;
  168.     *FGA_AUXDSTSTART = FGA_ASSACK_4CLK |  
  169.        FGA_RDY_1CLK;
  170.     *FGA_AUXDSTTERM = FGA_RELACK_5CLK |
  171.       FGA_NEWCYC_6CLK;
  172.     *FGA_AUXFIFWEX = FGA_AUXFIFO_TIMING15;
  173.     *FGA_AUXSRCSTART = FGA_ASSACK_4CLK |
  174.        FGA_RDY_4CLK;
  175.     *FGA_AUXSRCTERM = FGA_RELACK_1CLK |
  176.       FGA_NEWCYC_2CLK;
  177.       
  178.     *FGA_ICRDMANORM = FGA_ICR_ENABLE | INT_LVL_SCSI;
  179. #endif  /* INCLUDE_SCSI_DMA */
  180.     return (OK);
  181.     }
  182. #endif /* INCLUDE_SCSI */