⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zl5011xinterrupts.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*******************************************************************************
*
*  File name:              zl5011xInterrupts.c
*
*  Version:                48
*
*  Author:                 PJE
*
*  Date created:           08/07/2002
*
*  Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
*  All rights reserved.
*
*  Module Description:
*     This module is for the high level ISR functions.
*
*
*  Revision History:
*
*  Rev:  Date:       Author:  Comments:
*  1     17/07/2002  PJE      first fns.- enable/disable - ZL5011X_TESTED OK
*  2     30/07/2002  PJE      added freeze fns. and ZL5011X_TESTED(status) macro
*  3     01/08/2002  PJE      debug after progr model drwing
*  4     09/08/2002  PJE      compiles Ok but no AddDevice yet
*  5     14/08/2002  PJE      compiles Ok but no zl5011xIsrConnectApi yet
*  6     14/08/2002  PJE      debugged defines to bit positions
*  7     27/08/2002  MRC      Changed include file
*  8     28/08/2002  PJE      First clear the interrupts before enabling.
*  9     29/08/2002  PJE      more clearing the interrupts before enabling.
*  10    30/08/2002  PJE      for testing zl5011xIsrDeferredHandler
*  11    03/09/2002  PJE      zl5011xIsrTask to handle devices in any order
*  12    05/09/2002  PJE      debugging IsrTask
*  13    06/09/2002  PJE      debugging IsrInitialise and reorganising after review
*  14    26/09/2002  PJE      new zl5011xIsrNoAppnInterruptSoFar() & zl5011xIsrNoApi..
*  15    27/09/2002  PJE       debugging IsrHandler & IsrCompose
*  16    02/10/2002  PJE      new IsrApiHandler
*  17    07/10/2002  PJE      code reviewed with DJA
*  18    10/10/2002  PJE      new fns zl5011xIsrEnableApiInterrupts & Disable...
*  19    11/10/2002  PJE      Review actions
*  20    18/10/2002  PJE      Updated Cpq interrupt enable
*  21    23/10/2002  PJE      improvements to ApiHandler
*  22    24/10/2002  PJE      API tidy up & peer rev actions
*  23    31/10/2002  MRC      Added variants + minor fixes
*  24    18/11/2002  PJE      Debug & added CET ISR fns.
*  25    20/11/2002  PJE      Debug CET ISR fns.
*  26    22/11/2002  PJE      debug // comments
*  27    11/12/2002  PJE      clean-up comments
*  28    09/01/2003  MRC      Renamed fns IsrIsRunning & IsrSetCetQueueid
*  29    10/01/2003  MRC      Update
*  30    17/02/2003  MRC      Fixed typo on enable/disable fn StructInits
*  31    20/03/2003  JG       Added missing fn to api handler
*  32    03/04/2003  MRC      Moved CET to the api interrupt + other changes
*  33    10/04/2003  MRC      Changed interrupt reporting and enabling
*  34    22/05/2003  MRC      Tidied up interrupt fns
*  35    10/06/2003  DJA      Performed pre-audit actions
*  36    29/07/2003  APL      Renamed global wanLimits structure to devLimits
*  37    26/07/2004  MRC      Fixed some compiler warnings
*  38    25/08/2004  MRC      Added PW functionality
*  39    26/08/2004  MRC      Updated PW status byte support
*  40    06/09/2004  APL      Map ports correctly for different device variants
*  41    13/09/2004  APL      Renamed port mapping functions.
*  42    27/09/2004  MRC      Send message whenever the status byte changes,
*                             rather than just for L and R bit changes
*  43    24/02/2005  MRC      Moved trace statement to show interrupt bits for
*                             API handler
*  44    03/03/2005  MRC      Added notification mechanism for clock recovery flags
*  45    31/03/2005  MRC      Added support for DMA packet Rx interrupt
*  46    19/04/2005  MRC      Stopped packet Rx interrupt from being passed to
*                             the application when used for DMA processing
*  47    02/06/2005  MRC      Added support for PW polling
*  48    21/07/2005  MRC      Added PLL status to interrupt message
*
*******************************************************************************/

/*****************   INCLUDE FILES   ******************************************/

#include "zl5011xInterrupts.h"
#include "zl5011xDpr.h"
#include "zl5011xPkcMap.h"

/*****************   # DEFINES   **********************************************/

/*****************   STATIC FUNCTION DECLARATIONS   ***************************/

static zlStatusE zl5011xIsrCompose(zl5011xParamsS *zl5011xParams, Uint32T admIntrBit);
static zlStatusE zl5011xIsrQueueUpInterrupts(zl5011xParamsS *zl5011xParams, zl5011xInterruptQueueDataS *par);
static zlStatusE zl5011xHandleCetIntr(zl5011xParamsS *zl5011xParams);

/*********************   GLOBAL VARIABLES   ***********************************/

Uint32T zl5011xIsrAppIntNum = (Uint32T)ZL5011X_INVALID;
Uint32T zl5011xIsrApiIntNum = (Uint32T)ZL5011X_INVALID;

/* Message Q Ids */
OS_MSG_Q_ID zl5011xCetMsgQid = NULL;

/* Table of devices supported by the ISR */
zl5011xParamsS *zl5011xIsrDeviceTable[ZL5011X_ISR_MAX_NUMBER_DEVICES];

/* Statistics are maintained for the PW status byte and this flag is used to
   enable reporting of changes via the message queue. The application should
   access this variable using function zl5011xIsrPwReportEnable */
zl5011xBooleanE zl5011xIsrPwReportEnableFlag = ZL5011X_FALSE;

/* Or, the status changes can be fed to the clock recovery messaging system.
   The following boolean indicates whether this redirection is needed and if
   so the function to use as a callout */
zl5011xBooleanE zl5011xCetPwReportEnableFlag = ZL5011X_FALSE;
zlStatusE (*zl5011xIrqCetStatusFunc)(zl5011xParamsS *, Uint32T, Uint32T) = NULL;

/* The following variables indicate whether the DMA Rx packet interrupt is enabled
   and the function to use as a callout */
zl5011xBooleanE zl5011xIrqDmaRxFuncEnableFlag = ZL5011X_FALSE;
zlStatusE (*zl5011xIrqDmaRxFunc)(void) = NULL;

/*****************   EXPORTED FUNCTION DEFINTIONS   ***************************/

/*******************************************************************************
 Function:
    zl5011xIsrAddDeviceStructInit

 Description: stub function for forward compatibility.
 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   par               Pointer to structure for configuration items
 Outputs:

 Returns:
    zlStatusE

 Remarks:
*******************************************************************************/

zlStatusE zl5011xIsrAddDeviceStructInit(zl5011xParamsS *zl5011xParams,
      zl5011xIsrAddDeviceS *par)
{
   zlStatusE status = ZL5011X_OK;

   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_ISR_FN_ID,
            "zl5011xIsrAddDeviceStructInit:",
            0, 0, 0, 0, 0, 0);

      par->rtpStatsEnable = ZL5011X_TRUE;
   }

   return status;
}

/*******************************************************************************
 Function:
    zl5011xIsrAddDevice

 Description:
   Adds the device to the list of devices that are attached to the interrupt. If
   no interruptSoFar assumes this is the first device and clears the dev table.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   par               Pointer to function structure containing

   (accesses static variables zl5011xIsrAppIntNum & zl5011xIsrApiIntNum)

 Structure Inputs:
   rtpStatsEnable    ZL5011X_TRUE to enable interrupt processing to support RTP
                     statistics.

 Structure outputs:
   None

 Returns:
    zlStatusE

 Remarks:

*******************************************************************************/

zlStatusE zl5011xIsrAddDevice(zl5011xParamsS *zl5011xParams, zl5011xIsrAddDeviceS *par)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T mask, index, freePlace = (Uint32T)ZL5011X_INVALID;

   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_ISR_FN_ID, "zl5011xIsrAddDevice:  %08X, rtpStats %d",
            (Uint32T)zl5011xParams, par->rtpStatsEnable, 0, 0, 0, 0);
   }

   if (status == ZL5011X_OK)
   {
      if ((zl5011xIsrAppIntNum == (Uint32T)ZL5011X_INVALID) && (zl5011xIsrApiIntNum == (Uint32T)ZL5011X_INVALID))
      {
         status = ZL5011X_NOT_RUNNING;
      }
   }

   /* add pointer to table */
   if (status == ZL5011X_OK)
   {
      /* find next free place  */
      for (index = 0; index < ZL5011X_ISR_MAX_NUMBER_DEVICES; index++)
      {
         if(zl5011xIsrDeviceTable[index] == zl5011xParams)
         {
            ZL5011X_TRACE(ZL5011X_ISR_FN_ID,
                  "zl5011xIsrAddDevice: device already exists",
                  0, 0, 0, 0, 0, 0);

            status = ZL5011X_MULTIPLE_INIT_ATTEMPT;
            break;
         }

         if (zl5011xIsrDeviceTable[index] == NULL)
         {
            if (freePlace == (Uint32T)ZL5011X_INVALID)
            {
               freePlace = index;
            }
         }
      }
   }

   if (status == ZL5011X_OK)
   {
      /* if got to the end of the device table without finding the device,
         then add it to the list if there is space */
      if (index == ZL5011X_ISR_MAX_NUMBER_DEVICES)
      {
         if (freePlace != (Uint32T)ZL5011X_INVALID)
         {
            /* put it here */
            zl5011xIsrDeviceTable[freePlace] = zl5011xParams;

            /* initialise the PW interrupt flag */
            zl5011xParams->interruptMasks.pkcPwInterruptEnabled = ZL5011X_FALSE;
         }
         else
         {
            /* no free place found */
            ZL5011X_TRACE(ZL5011X_ISR_FN_ID,
                  "zl5011xIsrAddDevice:  No free place found",
                  0, 0, 0, 0, 0, 0);

            status = ZL5011X_ERROR;
         }

         if (status == ZL5011X_OK)
         {
            /* if the api interrupt is active then enable the interrupt from the device */
            if (zl5011xIsrApiIntNum != (Uint32T)ZL5011X_INVALID)
            {
               mask = (ZL5011X_1BIT_MASK << ZL5011X_MAC_IF_INTERRUPT) |
                     (ZL5011X_1BIT_MASK << ZL5011X_WAN_CLK_INTERRUPT);

               if (par->rtpStatsEnable == ZL5011X_TRUE)
               {
                  status = zl5011xRtpEnableReporting(zl5011xParams);

                  mask |= ZL5011X_1BIT_MASK << ZL5011X_RTP_STATS_INTERRUPT;
               }

               /* enable RTP interrupts at the higher level as well */
               if (status == ZL5011X_OK)
               {
                  status = zl5011xAdmEnableInterruptSource(zl5011xParams, ZL5011X_INTERRUPT_ONE, mask);
               }

               if (status == ZL5011X_OK)
               {
                  status = zl5011xAdmEnableInterrupt(zl5011xParams, ZL5011X_ENABLE_INT_1);
               }
            }
         }

         if (status == ZL5011X_OK)
         {
            /* if the api interrupt is active then enable the interrupt from the device */
            if (zl5011xIsrAppIntNum != (Uint32T)ZL5011X_INVALID)
            {
               status = zl5011xAdmEnableInterrupt(zl5011xParams, ZL5011X_ENABLE_INT_0);
            }
         }
      }
   }

   return status;
}

/*******************************************************************************

 Function:
    zl5011xIsrRemoveDeviceStructInit

 Description: stub function for forward compatibility.
 Inputs:
    zl5011xParams      Pointer to the structure for this device instance
   par               Pointer to structure for configuration items
Outputs:

 Returns:
    zlStatusE

 Remarks:

*******************************************************************************/

zlStatusE zl5011xIsrRemoveDeviceStructInit(zl5011xParamsS *zl5011xParams, zl5011xIsrRemoveDeviceS *par)
{
   zlStatusE status = ZL5011X_OK;

   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_ISR_FN_ID, "zl5011xIsrRemoveDeviceStructInit:",
            0, 0, 0, 0, 0, 0);
   }

   return status;
}

/*******************************************************************************

 Function:
    zl5011xIsrRemoveDevice

 Description:
   Removes the device from the list of devices that are attached to the interrupt.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   par               Pointer to function structure containing

 Structure Inputs:
   None

 Structure outputs:
   None

 Returns:
    zlStatusE

 Remarks:

*******************************************************************************/

zlStatusE zl5011xIsrRemoveDevice(zl5011xParamsS *zl5011xParams, zl5011xIsrRemoveDeviceS *par)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T index;

   status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);

   if (status == ZL5011X_OK)
   {
      ZL5011X_TRACE(ZL5011X_ISR_FN_ID,
            "zl5011xIsrRemoveDevice: device %08X",
            (Uint32T)zl5011xParams, 0, 0, 0, 0, 0);
   }

   /* find pointer in table */
   if (status == ZL5011X_OK)
   {
      for( index= 0; index < ZL5011X_ISR_MAX_NUMBER_DEVICES; index++)
      {
         if (zl5011xIsrDeviceTable[index] == zl5011xParams)
         {
            /* turn off interrupts while removing the device from the table */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -