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

VxWorks

开发平台:

C/C++

  1. /* dga001Vme.c - VMEbus controller (DGA-001) library */
  2. /* Copyright 1994-1997 Wind River Systems, Inc. */
  3. #include "copyright_wrs.h"
  4. /*
  5. modification history
  6. --------------------
  7. 01o,07dec97,hk   added INTC control for DVE7043 in sysMailboxEnable().
  8. 01n,12jul97,hk   changed inclusion of multi/dga001.h to vme/dga001Vme.h.
  9. 01m,27apr97,hk   doc: cleanup.
  10. 01l,22jan96,hk   made sysMailboxEnable() generic for dve7604/dve7043.
  11. 01k,24nov95,hk   supplemented documentation.
  12. 01j,10nov95,hk   followed dga001.h 01j.
  13. 01i,09nov95,hk   followed dga001.h 01i.
  14. 01h,08nov95,hk   renamed as dga001Vme.c, it was originally dga001.c.
  15. 01g,08nov95,hk   changed dga001.h directory to drv/multi/.
  16. 01f,08nov95,hk   changed to use INT_VEC_MBOX, made CSR24 init code safer.
  17. 01e,14jun95,hk   code review.
  18. 01d,08jun95,hk   changed sysMailboxEnable() for CSR20 header mod.
  19. 01c,28feb95,hk   changed sysMailboxConnect() to conform the ivSh.h 01e rule.
  20. 01b,08feb95,sa   just modified comment.
  21. 01a,15dec94,sa   created for sysIntDisable(), sysIntEnable(), sysBusIntAck(),
  22.  sysBusIntGen(), sysMailboxInt(), sysMailboxConnect(), 
  23.          sysMailboxEnable().
  24. */
  25. /*
  26. DESCRIPTION
  27. This library contains routines which relate to the 'Densan' VMEbus 
  28. controller (DGA-001).
  29. The functions addressed here include:
  30.     Bus interrupt functions:
  31. - enable/disable VMEbus interrupt levels
  32. - generate bus interrupts
  33.     Mailbox/locations monitor functions:
  34. - enable mailbox/location monitor interrupts
  35. */
  36. #include "drv/vme/dga001Vme.h"
  37. LOCAL FUNCPTR sysMailboxRoutine = NULL;
  38. LOCAL int sysMailboxArg     = NULL;
  39. /*******************************************************************************
  40. *
  41. * sysIntDisable - disable a bus interrupt level
  42. *
  43. * This routine disables a specified VMEbus interrupt level.
  44. *
  45. * NOTE: This routine is currently not called from VxWorks drivers.
  46. *
  47. * RETURNS: OK, or ERROR if <intLevel> is not in the range 1 - 7.
  48. *
  49. * SEE ALSO: sysIntEnable()
  50. */
  51. STATUS sysIntDisable
  52.     (
  53.     int intLevel /* interrupt level to disable (1-7) */
  54.     )
  55.     {
  56.     if (intLevel < 1 || intLevel > 7)
  57. return (ERROR);
  58.     *DGA_CSR21 &= (UINT32) ~(1 << intLevel);
  59.     return (OK);
  60.     }
  61. /*******************************************************************************
  62. *
  63. * sysIntEnable - enable a bus interrupt level
  64. *
  65. * This routine enables a specified VMEbus interrupt level.
  66. *
  67. * NOTE: This routine is currently called from if_bp, if_egl, if_enp, if_ex,
  68. * and smUtilLib.
  69. *
  70. * RETURNS: OK, or ERROR if <intLevel> is not in the range 1 - 7.
  71. *
  72. * SEE ALSO: sysIntDisable()
  73. */
  74. STATUS sysIntEnable
  75.     (
  76.     int intLevel /* interrupt level to enable (1-7) */
  77.     )
  78.     {
  79.     if (intLevel < 1 || intLevel > 7)
  80. return (ERROR);
  81.     *DGA_CSR21 |= (UINT32)(1 << intLevel);
  82.     return (OK);
  83.     }
  84. /*******************************************************************************
  85. *
  86. * sysBusIntAck - acknowledge a bus interrupt
  87. *
  88. * This routine acknowledges a specified VMEbus interrupt level.
  89. *
  90. * NOTE: This routine has no effect, since VMEbus interrupts are acknowledged
  91. * automatically by hardware if the interrupt level is enabled.  This routine
  92. * is currently called from if_bp, if_egl, if_enp, if_ex, and smNetLib.
  93. *
  94. * RETURNS: NULL.
  95. *
  96. * SEE ALSO: sysBusIntGen()
  97. */
  98. int sysBusIntAck
  99.     (
  100.     int intLevel /* interrupt level to acknowledge */
  101.     )
  102.     {
  103.     return (NULL);
  104.     }
  105. /*******************************************************************************
  106. *
  107. * sysBusIntGen - generate a bus interrupt
  108. *
  109. * This routine generates a VMEbus interrupt for a specified interrupt level.
  110. *
  111. * RETURNS: OK, or ERROR if <level> or <vector> are out of range or
  112. * a previous interrupt is not acknowledged.
  113. *
  114. * SEE ALSO: sysBusIntAck()
  115. */
  116.  
  117. STATUS sysBusIntGen
  118.     (
  119.     int level, /* interrupt level to generate    */
  120.     int vector /* interrupt vector for interrupt */
  121.     )
  122.     {
  123.     if (level < 1 || level > 7 || vector > 255 || vector < 2)
  124. return (ERROR);
  125.     if (*DGA_CSR18_2 != 0) /* previous interrupt is not acknowledged */
  126. return (ERROR);
  127.     *DGA_CSR18_3 = (UINT8)vector;
  128.     *DGA_CSR18_2 = (UINT8)level;
  129.     return (OK);
  130.     }
  131. /*******************************************************************************
  132. *
  133. * sysMailboxInt - handle a mailbox interrupt request from DGA-001
  134. *
  135. * NOMANUAL
  136. */
  137. LOCAL void sysMailboxInt (void)
  138.     {
  139.     *DGA_IFR0   = (UINT32)IFR0_SRQF; /* clear SRQ       */
  140.     *DGA_CSR23 |= (UINT32)CSR23_SRQICL; /* clear interrupt */
  141.     if (sysMailboxRoutine != NULL)
  142. sysMailboxRoutine (sysMailboxArg);
  143.     }
  144. /*******************************************************************************
  145. *
  146. * sysMailboxConnect - connect a routine to the mailbox interrupt
  147. *
  148. * This routine specifies the interrupt serivce routine to be called at each
  149. * mailbox interrupt.  The DGA-001 SRQ (service request) interrupt is used to
  150. * implement the mailbox interrupt.
  151. *
  152. * RETURNS: OK, or ERROR if the routine cannot be connected to the interrupt.
  153. *
  154. * SEE ALSO: intConnect(), sysMailboxEnable()
  155. */
  156. STATUS sysMailboxConnect
  157.     (
  158.     FUNCPTR routine, /* routine called at each mailbox interrupt */
  159.     int arg /* argument with which to call routine      */
  160.     )
  161.     {
  162.     static BOOL sysMailboxConnected = FALSE;
  163.     if (!sysMailboxConnected &&
  164. intConnect (INT_VEC_MBOX, sysMailboxInt, NULL) == ERROR)
  165. {
  166. return (ERROR);
  167. }
  168.     sysMailboxConnected = TRUE;
  169.     sysMailboxRoutine = routine;
  170.     sysMailboxArg = arg;
  171.     return (OK);
  172.     }
  173. /*******************************************************************************
  174. *
  175. * sysMailboxEnable - enable the mailbox interrupt
  176. *
  177. * This routine enables the mailbox interrupt.  The DGA-001 SRQ (service request)
  178. * interrupt is used to implement the mailbox interrupt.  The SRQ interrupt is
  179. * driven by accessing to a DGA-001 IFR (interface register) across VMEbus.
  180. *
  181. * NOTE: This routine has an argument <mailboxAdrs> to specify an address of
  182. * mailbox, but the address of DGA-001 IFR (interface register) is pre-configured
  183. * in sysProcNumSet() as a function of processor number; thus <mailboxAdrs> is
  184. * ignored at here.
  185. *
  186. * RETURNS: OK, always.
  187. *
  188. * SEE ALSO: sysMailboxConnect()
  189. */
  190. STATUS sysMailboxEnable
  191.     (
  192.     char *mailboxAdrs /* address of mailbox (ignored) */
  193.     )
  194.     {
  195. #ifdef TARGET_DVE7043
  196.     *INTC_IPRA = (UINT16)((*INTC_IPRA & 0x0fff) | ((INT_LVL_MBOX & 0xf) << 12));
  197. #endif
  198.     *DGA_CSR21 |= (UINT32)CSR21_SRQIEN; /* enable interrupt */
  199.     return (OK);
  200.     }