?? zl5011xdpr.c
字號(hào):
/*******************************************************************************
*
* File name: zl5011xDpr.c
*
* Version: 20
*
* Author: PJE
*
* Date created: 09/09/2002
*
* Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
* All rights reserved.
*
* Module Description:
* This module is for the high level ISR functions which the user may wish to adapt
* for the specific application.
*
*
* Revision History:
*
* Rev: Date: Author: Comments:
* 1 25/09/2002 PJE initial version
* 2 26/09/2002 PJE new zl5011xIsrNoAppnInterruptSoFar() & zl5011xIsrNoApi..
* 3 03/10/2002 DJA ZL5011X_TRACE messages fixed up
* File header updated
* 4 03/10/2002 PJE code reviewed with DJA
* 5 24/10/2002 PJE API tidy up
* 6 31/10/2002 MRC Added variants + minor fixes
* 7 19/11/2002 PJE Added CET hook
* 8 22/11/2002 PJE API tidy up // COMMENTS
* 9 11/12/2002 PJE API tidy up COMMENTS
* 10 03/04/2003 MRC Moved CET to the api interrupt + other changes
* 11 10/04/2003 MRC Changed interrupt reporting and enabling
* 12 22/05/2003 MRC Tidied up interrupt fns
* 13 11/06/2003 DJA Performed pre-audit actions
* 14 26/07/2004 MRC Fixed some compiler warnings
* 15 26/08/2004 MRC Added PW status byte support
* 16 20/10/2004 APL Cast OS_ERROR to prevent a possible compiler warning
* 17 16/11/2004 MRC Shortened task label
* 18 07/03/2005 APL Removed unused code
* 19 19/04/2005 MRC Improved interrupt string routine
* 20 02/06/2005 MRC Added function to initialise PW polling
*
*******************************************************************************/
/***************** INCLUDE FILES ******************************************/
#include "zl5011xInterrupts.h"
#include "zl5011xDpr.h"
/***************** # DEFINES **********************************************/
/***************** STATIC FUNCTION DECLARATIONS ***************************/
/***************** STATIC GLOBAL VARIABLES ********************************/
typedef struct
{
zl5011xIsrSourcesE intSrc;
char *text;
} zl5011xDprInterruptStrS;
zl5011xDprInterruptStrS zl5011xDprInterruptStr[] =
{
{9999, "ZL5011X_UNKNOWN_INTERRUPT"},
{ZL5011X_NO_INTERRUPT, "ZL5011X_NO_INTERRUPT"},
{ZL5011X_WAN_TX_ERROR_OVERFLOW_INTERRUPT, "ZL5011X_WAN_TX_ERROR_OVERFLOW_INTERRUPT"},
{ZL5011X_WAN_TX_ERROR_INTERRUPT, "ZL5011X_WAN_TX_ERROR_INTERRUPT"},
{ZL5011X_WAN_TX_INFO_OVERFLOW_INTERRUPT, "ZL5011X_WAN_TX_INFO_OVERFLOW_INTERRUPT"},
{ZL5011X_WAN_TX_INFO_INTERRUPT, "ZL5011X_WAN_TX_INFO_INTERRUPT"},
{ZL5011X_WAN_TX_QUEUE_INTERRUPT, "ZL5011X_WAN_TX_QUEUE_INTERRUPT"},
{ZL5011X_WAN_TX_QUEUE_OVERFLOW_INTERRUPT, "ZL5011X_WAN_TX_QUEUE_OVERFLOW_INTERRUPT"},
{ZL5011X_WAN_TX_GRANULES_INTERRUPT, "ZL5011X_WAN_TX_GRANULES_INTERRUPT"},
{ZL5011X_WAN_RX_ERROR_INTERRUPT, "ZL5011X_WAN_RX_ERROR_INTERRUPT"},
{ZL5011X_WAN_RX_OVERFLOW_INTERRUPT, "ZL5011X_WAN_RX_OVERFLOW_INTERRUPT"},
{ZL5011X_WAN_RX_TASK_OVERFLOW_INTERRUPT, "ZL5011X_WAN_RX_TASK_OVERFLOW_INTERRUPT"},
{ZL5011X_RTP_STATS_INTERRUPT, "ZL5011X_RTP_STATS_INTERRUPT"},
{ZL5011X_WAN_CLK_INTERRUPT, "ZL5011X_WAN_CLK_INTERRUPT"},
{ZL5011X_MEMORY_PARITY_INTERRUPT, "ZL5011X_MEMORY_PARITY_INTERRUPT"},
{ZL5011X_MAC_IF_INTERRUPT, "ZL5011X_MAC_IF_INTERRUPT"},
{ZL5011X_PACKET_TX_INTERRUPT, "ZL5011X_PACKET_TX_INTERRUPT"},
{ZL5011X_PACKET_RX_INTERRUPT, "ZL5011X_PACKET_RX_INTERRUPT"},
{ZL5011X_TASK_MSG_INTERRUPT, "ZL5011X_TASK_MSG_INTERRUPT"},
{ZL5011X_GRANULE_INTERRUPT, "ZL5011X_GRANULE_INTERRUPT"},
{ZL5011X_HOST_OVERFLOW_INTERRUPT, "ZL5011X_HOST_OVERFLOW_INTERRUPT"},
{ZL5011X_HOST_GRANULES_INTERRUPT, "ZL5011X_HOST_GRANULES_INTERRUPT"},
{ZL5011X_HOST_DMA_RX_INTERRUPT, "ZL5011X_HOST_DMA_RX_INTERRUPT"}
};
/***************** EXPORTED GLOBAL VARIABLES ******************************/
/* Sempahore Ids */
OS_SEM_ID zl5011xIsrSemId = OS_SEM_INVALID;
/* Message Q Ids */
OS_MSG_Q_ID zl5011xIsrMsgQId = OS_MSG_Q_INVALID;
/* Task Ids */
OS_TASK_ID zl5011xIsrTaskId = (OS_TASK_ID)NULL;
OS_TASK_ID zl5011xDprTaskId = (OS_TASK_ID)NULL;
OS_TASK_ID zl5011xIsrPwTaskId = (OS_TASK_ID)NULL;
/***************** EXPORTED FUNCTION DEFINTIONS ***************************/
/*******************************************************************************
Function:
zl5011xIsrInitialiseStructInit
Description: stub function for forward compatibility.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to parameter structure
Structure Inputs:
None
Outputs:
Returns:
zlStatusE
Remarks:
*******************************************************************************/
zlStatusE zl5011xIsrInitialiseStructInit(zl5011xParamsS *zl5011xParams,
zl5011xIsrInitialiseS *par)
{
zlStatusE status = ZL5011X_OK;
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_ISR_FN_ID,
"zl5011xIsrInitialiseStructInit: ",
0, 0, 0, 0, 0, 0);
par->apiPhysIntr = (Uint32T)ZL5011X_INVALID;
par->appPhysIntr = (Uint32T)ZL5011X_INVALID;
}
return (status);
}
/*******************************************************************************
Function:
zl5011xIsrInitialise
Description:
This adds the device structure to the table of devices supported by this
interrupt. Table is a global, kept in another module.
If the interrupt is not currently active (determined by a static in the
interrupt routines), then sets up the vector and enables interrupt operation,
but, in the case of the application, it disables (masks) all individual
interrupts.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to parameter structure containing:
Structure Inputs:
apiPhysIntr interrupt number to use for the API interrupt - that is
used to maintain device statistics and clock recovery.
May be left as initialised to disable the interrupt.
appPhysIntr interrupt number to use for error reporting to the application.
May be left as initialised to disable the interrupt.
Outputs:
None
Returns:
zlStatusE
Remarks:
*******************************************************************************/
zlStatusE zl5011xIsrInitialise(zl5011xParamsS *zl5011xParams,
zl5011xIsrInitialiseS *par)
{
zlStatusE status = ZL5011X_OK;
/*OS_STATUS osStatus= 0;*/
Uint32T index;
zl5011xIsrDeleteS isrDelete;
/*VOIDFUNCPTR *vector;*/
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_ISR_FN_ID, "zl5011xIsrInitialise: apiInt %d, appInt %d",
par->apiPhysIntr, par->appPhysIntr, 0, 0, 0, 0);
if ((zl5011xIsrAppIntNum != (Uint32T)ZL5011X_INVALID) || (zl5011xIsrApiIntNum != (Uint32T)ZL5011X_INVALID))
{
/* if either interrupt has already been enabled then bomb out */
status = ZL5011X_INTERRUPTS_RUNNING;
}
}
if (status == ZL5011X_OK)
{
/* clear out the device table before setting up the interrupts */
for (index = 0; index < ZL5011X_ISR_MAX_NUMBER_DEVICES; index++)
{
zl5011xIsrDeviceTable[index]= NULL;
}
}
#if 0
/* set up the application ISR things if an interrupt number has been given */
if (par->appPhysIntr != (Uint32T)ZL5011X_INVALID)
{
if (status == ZL5011X_OK)
{
/* Create the 'zl5011xIsrSemId' semaphore if it does not already exist */
if (zl5011xIsrSemId == OS_SEM_INVALID)
{
zl5011xIsrSemId = OS_SEMA4_CREATE(OS_SEM_Q_PRIORITY,0);
}
else
{
ZL5011X_TRACE(ZL5011X_ISR_FN_ID, "zl5011xIsrInitialise: semaphore already exists", 0,0,0,0,0,0);
}
if (zl5011xIsrSemId == OS_SEM_INVALID)
{
status = ZL5011X_RTOS_SEMA4_CREATE_FAIL;
}
}
if (status == ZL5011X_OK)
{
/* Create the 'zl5011xIsrMsgQId' message queue if it does not already exist */
if (zl5011xIsrMsgQId == OS_MSG_Q_INVALID)
{
zl5011xIsrMsgQId = OS_MSG_Q_CREATE(ZL5011X_DPR_MESSAGES, sizeof(zl5011xInterruptQueueDataS), OS_MSG_Q_PRIORITY);
}
else
{
ZL5011X_TRACE(ZL5011X_ISR_FN_ID, "zl5011xIsrInitialise: message queue already exists", 0,0,0,0,0,0);
}
if (zl5011xIsrMsgQId == OS_MSG_Q_INVALID)
{
status = ZL5011X_RTOS_MSGQ_CREATE_FAIL;
}
}
if (status == ZL5011X_OK)
{
if (zl5011xIsrTaskId == (OS_TASK_ID)NULL)
{
/* Create the 'isr' task */
if ((zl5011xIsrTaskId = OS_TASK_SPAWN("zlIsrTask",
ZL5011X_ISR_TASK_PRIORITY,
OS_VX_NO_STACK_FILL,
ZL5011X_ISR_TASK_STACK_SIZE,
(FUNCPTR)zl5011xIsrTask,
0,0,0,0,0,0,0,0,0,0)) == (OS_TASK_ID)OS_ERROR)
{
status = ZL5011X_RTOS_TASK_CREATE_FAIL;
}
}
}
if (status == ZL5011X_OK)
{
if (zl5011xDprTaskId == (OS_TASK_ID)NULL)
{
/* Create the 'Dpr' task */
if ((zl5011xDprTaskId = OS_TASK_SPAWN("zlDprTask",
ZL5011X_DPR_TASK_PRIORITY,
OS_VX_NO_STACK_FILL,
ZL5011X_DPR_TASK_STACK_SIZE,
(FUNCPTR)zl5011xDprTask,
0,0,0,0,0,0,0,0,0,0)) == (OS_TASK_ID)OS_ERROR)
{
status = ZL5011X_RTOS_TASK_CREATE_FAIL;
}
}
}
if (status == ZL5011X_OK)
{
if (zl5011xIsrPwTaskId == (OS_TASK_ID)NULL)
{
/* Create the PW task */
if ((zl5011xIsrPwTaskId = OS_TASK_SPAWN("zlIsrPwTask",
ZL5011X_PW_TASK_PRIORITY,
OS_VX_NO_STACK_FILL,
ZL5011X_PW_TASK_STACK_SIZE,
(FUNCPTR)zl5011xIsrPwTask,
0,0,0,0,0,0,0,0,0,0)) == (OS_TASK_ID)OS_ERROR)
{
status = ZL5011X_RTOS_TASK_CREATE_FAIL;
}
}
}
if (status == ZL5011X_OK)
{
vector = (VOIDFUNCPTR *)par->appPhysIntr;
osStatus = OS_INTERRUPT_CONNECT(vector, (VOIDFUNCPTR)zl5011xIsrConnect, 0);
if (osStatus != OS_OK)
{
status = ZL5011X_RTOS_FAIL;
}
else
{
osStatus = OS_INTERRUPT_ENABLE(par->appPhysIntr);
if (osStatus != OS_OK)
{
status = ZL5011X_RTOS_FAIL;
}
}
}
}
/* set up the api ISR things if an interrupt number has been given */
if (par->apiPhysIntr != (Uint32T)ZL5011X_INVALID)
{
if (status == ZL5011X_OK)
{
vector = (VOIDFUNCPTR *)par->apiPhysIntr;
osStatus = OS_INTERRUPT_CONNECT(vector, (VOIDFUNCPTR)zl5011xIsrApiHandler, 0);
if (osStatus != OS_OK)
{
status = ZL5011X_RTOS_FAIL;
}
else
{
osStatus = OS_INTERRUPT_ENABLE(par->apiPhysIntr);
if (osStatus != OS_OK)
{
status = ZL5011X_RTOS_FAIL;
}
}
}
}
#endif
if (status != ZL5011X_OK)
{
/* if we failed because the interrupt had already been initialised then
DO NOT delete it */
if ((zl5011xIsrAppIntNum == (Uint32T)ZL5011X_INVALID) && (zl5011xIsrApiIntNum == (Uint32T)ZL5011X_INVALID))
{
ZL5011X_TRACE(ZL5011X_ISR_FN_ID, "zl5011xIsrInitialise: FAILED to initialise", 0, 0, 0, 0, 0, 0);
/* temporarily set the global interrupt values - so that they
can then be cleared up */
zl5011xIsrApiIntNum = par->apiPhysIntr;
zl5011xIsrAppIntNum = par->appPhysIntr;
/* Oops something wrong here, clear up before exit */
if (zl5011xIsrDeleteStructInit(zl5011xParams, &isrDelete) == ZL5011X_OK)
{
(void)zl5011xIsrDelete(zl5011xParams, &isrDelete);
}
}
}
else
{
zl5011xIsrApiIntNum = par->apiPhysIntr;
zl5011xIsrAppIntNum = par->appPhysIntr;
}
return (status);
}
/*******************************************************************************
Function:
zl5011xIsrDeleteStructInit
Description:
stub function for forward compatibility.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to parameter structure
Structure Inputs:
None
Outputs:
Returns:
zlStatusE
Remarks:
*******************************************************************************/
zlStatusE zl5011xIsrDeleteStructInit(zl5011xParamsS *zl5011xParams, zl5011xIsrDeleteS *par)
{
zlStatusE status = ZL5011X_OK;
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_ISR_FN_ID,
"zl5011xIsrDeleteStructInit:",
0, 0, 0, 0, 0, 0);
}
return (status);
}
/*******************************************************************************
Function:
zl5011xIsrDelete
Description:
cleans up any system resources created by the zl5011xIsrInitialise() routine.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to parameter structure
Outputs:
None
Returns:
zlStatusE
Remarks:
*******************************************************************************/
zlStatusE zl5011xIsrDelete(zl5011xParamsS *zl5011xParams, zl5011xIsrDeleteS *par)
{
zlStatusE status = ZL5011X_OK;
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_ISR_FN_ID,
"zl5011xIsrDelete: ",
0, 0, 0, 0, 0, 0);
}
if (status == ZL5011X_OK)
{
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -