diff options
Diffstat (limited to 'Acceleration/library/icp_telephony/tdm_infrastructure_message_handler')
17 files changed, 5218 insertions, 0 deletions
diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMh.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMh.c new file mode 100644 index 0000000..b0e9bff --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMh.c @@ -0,0 +1,692 @@ +/** + * @file IxPiuMh.c + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @description Contents are the implementation of the public API for the + * PIU Message Handler component. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/* + * Put the system defined include files required. + */ + +/* + * Put the user defined include files required. + */ + +#include "IxOsal.h" +#include "IxPiuMhMacros_p.h" + +#include "IxPiuMh.h" + +#include "IxPiuMhConfig_p.h" +#include "IxPiuMhReceive_p.h" +#include "IxPiuMhSend_p.h" +#include "IxPiuMhSolicitedCbMgr_p.h" +#include "IxPiuMhUnsolicitedCbMgr_p.h" + +/* + * #defines and macros used in this file. + */ + +/* + * Typedefs whose scope is limited to this file. + */ + +/* + * Variable declarations global to this file only. Externs are followed by + * static variables. + */ + +PRIVATE BOOL ixPiuMhInitialized = FALSE; + +/* + * Extern function prototypes. + */ + +/* + * Static function prototypes. + */ + +#if defined(__ep805xx) +/* + * Function definition: ixPiuMhPhysicalAddressSet + */ + +PUBLIC IX_STATUS ixPiuMhPhysicalAddressSet ( + IxPiuMhPiuId piuId, + UINT32 address) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhPhysicalAddressSet\n"); + + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* ensure that the compoonent is not initialized */ + if (ixPiuMhInitialized) + { + return IX_FAIL; + } + + /* set the address */ + ixPiuMhConfigPhysicalAddressSet(piuId, address); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhPhysicalAddressSet\n"); + + return IX_SUCCESS; +} +/* + * Function definition: ixPiuMhInterruptIdSet + */ + +PUBLIC IX_STATUS ixPiuMhInterruptIdSet ( + IxPiuMhPiuId piuId, + UINT32 interruptId) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhInterruptIdSet\n"); + + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* ensure that the compoonent is not initialized */ + if (ixPiuMhInitialized) + { + return IX_FAIL; + } + + /* set the address */ + ixPiuMhConfigInterruptIdSet(piuId, interruptId); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhInterruptIdSet\n"); + + return IX_SUCCESS; +} +#endif /* #if defined(__ep805xx) */ + +/* + * Function definition: ixPiuMhInitialize + */ + +PUBLIC IX_STATUS ixPiuMhInitialize ( + IxPiuMhPiuInterrupts piuInterrupts) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhInitialize\n"); + + /* check the piuInterrupts parameter */ + if ((piuInterrupts != IX_PIUMH_PIUINTERRUPTS_NO) && + (piuInterrupts != IX_PIUMH_PIUINTERRUPTS_YES)) + { + IX_PIUMH_ERROR_REPORT ("Illegal piuInterrupts parameter value\n"); + return IX_FAIL; + } + + /* parameters are ok ... */ + + /* initialize the Receive module */ + ixPiuMhReceiveInitialize (); + + + /* initialize the Solicited Callback Manager module */ + ixPiuMhSolicitedCbMgrInitialize (); + + /* initialize the Unsolicited Callback Manager module */ + ixPiuMhUnsolicitedCbMgrInitialize (); + + /* initialize the Configuration module + * + * NOTE: This module was originally configured before the + * others, but the sequence was changed so that interrupts + * would only be enabled after the handler functions were + * set up. The above modules need to be initialised to + * handle the PIU interrupts. See SCR #2231. + */ + ixPiuMhConfigInitialize (piuInterrupts); + + ixPiuMhInitialized = TRUE; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhInitialize\n"); + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhUnload + */ + +PUBLIC IX_STATUS ixPiuMhUnload (void) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhUnload\n"); + + if (!ixPiuMhInitialized) + { + return IX_FAIL; + } + + /* Uninitialize the Configuration module */ + ixPiuMhConfigUninit (); + /* Reset the PiuMhShow */ +#if defined(__ixp23xx) + ixPiuMhShowReset (IX_PIUMH_PIUID_PIU0); + ixPiuMhShowReset (IX_PIUMH_PIUID_PIU1); +#endif +#if defined(__ep805xx) + ixPiuMhShowReset (IX_PIUMH_PIUID_PIU0); +#endif +#if defined(__ixp42X) || defined(__ixp46X) || defined(__ixp5XX) + ixPiuMhShowReset (IX_PIUMH_PIUID_PIUA); + ixPiuMhShowReset (IX_PIUMH_PIUID_PIUB); +#endif +#if defined(__ixp42X) || defined(__ixp46X) && !defined(__ixp5XX) + ixPiuMhShowReset (IX_PIUMH_PIUID_PIUC); +#endif + + ixPiuMhUnsolicitedCbMgrUninitialize (); + ixPiuMhSolicitedCbMgrUninitialize (); + ixPiuMhReceiveUninitialize (); + ixPiuMhInitialized = FALSE; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhUnload\n"); + + return IX_SUCCESS; +} + + +/* + * Function definition: ixPiuMhUnsolicitedCallbackRegister + */ + +PUBLIC IX_STATUS ixPiuMhUnsolicitedCallbackRegister ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId messageId, + IxPiuMhCallback unsolicitedCallback) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhUnsolicitedCallbackRegister\n"); + + /* check that we are initialized */ + if (!ixPiuMhInitialized) + { + IX_PIUMH_ERROR_REPORT ("IxPiuMh component is not initialized\n"); + return IX_FAIL; + } + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* check the messageId parameter */ + if ((messageId < IX_PIUMH_MIN_MESSAGE_ID) + || (messageId > IX_PIUMH_MAX_MESSAGE_ID)) + { + IX_PIUMH_ERROR_REPORT ("Message ID is out of range\n"); + return IX_FAIL; + } + + /* the unsolicitedCallback parameter is allowed to be NULL */ + + /* parameters are ok ... */ + + /* get the lock to prevent other clients from entering */ + ixPiuMhConfigLockGet (piuId); + + /* save the unsolicited callback for the message ID */ + ixPiuMhUnsolicitedCbMgrCallbackSave ( + piuId, messageId, unsolicitedCallback); + + /* release the lock to allow other clients back in */ + ixPiuMhConfigLockRelease (piuId); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhUnsolicitedCallbackRegister\n"); + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhUnsolicitedCallbackForRangeRegister + */ + +PUBLIC IX_STATUS ixPiuMhUnsolicitedCallbackForRangeRegister ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId minMessageId, + IxPiuMhMessageId maxMessageId, + IxPiuMhCallback unsolicitedCallback) +{ + IxPiuMhMessageId messageId; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhUnsolicitedCallbackForRangeRegister\n"); + + /* check that we are initialized */ + if (!ixPiuMhInitialized) + { + IX_PIUMH_ERROR_REPORT ("IxPiuMh component is not initialized\n"); + return IX_FAIL; + } + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* check the minMessageId parameter */ + if ((minMessageId < IX_PIUMH_MIN_MESSAGE_ID) + || (minMessageId > IX_PIUMH_MAX_MESSAGE_ID)) + { + IX_PIUMH_ERROR_REPORT ("Min message ID is out of range\n"); + return IX_FAIL; + } + + /* check the maxMessageId parameter */ + if ((maxMessageId < IX_PIUMH_MIN_MESSAGE_ID) + || (maxMessageId > IX_PIUMH_MAX_MESSAGE_ID)) + { + IX_PIUMH_ERROR_REPORT ("Max message ID is out of range\n"); + return IX_FAIL; + } + + /* check the semantics of the message range parameters */ + if (minMessageId > maxMessageId) + { + IX_PIUMH_ERROR_REPORT ("Min message ID greater than max message " + "ID\n"); + return IX_FAIL; + } + + /* the unsolicitedCallback parameter is allowed to be NULL */ + + /* parameters are ok ... */ + + /* get the lock to prevent other clients from entering */ + ixPiuMhConfigLockGet (piuId); + + /* for each message ID in the range ... */ + for (messageId = minMessageId; messageId <= maxMessageId; messageId++) + { + /* save the unsolicited callback for the message ID */ + ixPiuMhUnsolicitedCbMgrCallbackSave ( + piuId, messageId, unsolicitedCallback); + } + + /* release the lock to allow other clients back in */ + ixPiuMhConfigLockRelease (piuId); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhUnsolicitedCallbackForRangeRegister\n"); + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhMessageSend + */ + +PUBLIC IX_STATUS ixPiuMhMessageSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + UINT32 maxSendRetries) +{ + IX_STATUS status = IX_SUCCESS; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhMessageSend\n"); + + /* check that we are initialized */ + if (!ixPiuMhInitialized) + { + IX_PIUMH_ERROR_REPORT ("IxPiuMh component is not initialized\n"); + return IX_FAIL; + } + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* parameters are ok ... */ + + /* get the lock to prevent other clients from entering */ + ixPiuMhConfigLockGet (piuId); + + /* send the message */ + status = ixPiuMhSendMessageSend (piuId, message, maxSendRetries); + if (status != IX_SUCCESS) + { + IX_PIUMH_ERROR_REPORT ("Failed to send message\n"); + } + + /* release the lock to allow other clients back in */ + ixPiuMhConfigLockRelease (piuId); + + IX_PIUMH_TRACE1 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhMessageSend" + " : status = %d\n", status); + + return status; +} + +/* + * Function definition: ixPiuMhMessageWithResponseSend + */ + +PUBLIC IX_STATUS ixPiuMhMessageWithResponseSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback solicitedCallback, + UINT32 maxSendRetries) +{ + IX_STATUS status = IX_SUCCESS; + IxPiuMhCallback unsolicitedCallback = NULL; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhMessageWithResponseSend\n"); + + /* check that we are initialized */ + if (!ixPiuMhInitialized) + { + IX_PIUMH_ERROR_REPORT ("IxPiuMh component is not initialized\n"); + return IX_FAIL; + } + + /* the solicitecCallback parameter is allowed to be NULL. this */ + /* signifies the client is not interested in the response message */ + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* check the solicitedMessageId parameter */ + if ((solicitedMessageId < IX_PIUMH_MIN_MESSAGE_ID) + || (solicitedMessageId > IX_PIUMH_MAX_MESSAGE_ID)) + { + IX_PIUMH_ERROR_REPORT ("Solicited message ID is out of range\n"); + return IX_FAIL; + } + + /* check the solicitedMessageId parameter. if an unsolicited */ + /* callback has been registered for the specified message ID then */ + /* report an error and return failure */ + ixPiuMhUnsolicitedCbMgrCallbackRetrieve ( + piuId, solicitedMessageId, &unsolicitedCallback); + if (unsolicitedCallback != NULL) + { + IX_PIUMH_ERROR_REPORT ("Solicited message ID conflicts with " + "unsolicited message ID\n"); + return IX_FAIL; + } + + /* parameters are ok ... */ + + /* get the lock to prevent other clients from entering */ + ixPiuMhConfigLockGet (piuId); + + /* send the message */ + status = ixPiuMhSendMessageWithResponseSend ( + piuId, message, solicitedMessageId, solicitedCallback, + maxSendRetries); + if (status != IX_SUCCESS) + { + IX_PIUMH_ERROR_REPORT ("Failed to send message\n"); + } + + /* release the lock to allow other clients back in */ + ixPiuMhConfigLockRelease (piuId); + + IX_PIUMH_TRACE1 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhMessageWithResponseSend" + " : status = %d\n", status); + + return status; +} + +/* + * Function definition: ixPiuMhMessagesReceive + */ + +PUBLIC IX_STATUS ixPiuMhMessagesReceive ( + IxPiuMhPiuId piuId) +{ + IX_STATUS status = IX_SUCCESS; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhMessagesReceive\n"); + + /* check that we are initialized */ + if (!ixPiuMhInitialized) + { + IX_PIUMH_ERROR_REPORT ("IxPiuMh component is not initialized\n"); + return IX_FAIL; + } + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* parameters are ok ... */ + + /* get the lock to prevent other clients from entering */ + ixPiuMhConfigLockGet (piuId); + + /* receive messages from the PIU */ + status = ixPiuMhReceiveMessagesReceive (piuId); + + if (status != IX_SUCCESS) + { + IX_PIUMH_ERROR_REPORT ("Failed to receive message\n"); + } + + /* release the lock to allow other clients back in */ + ixPiuMhConfigLockRelease (piuId); + + IX_PIUMH_TRACE1 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhMessagesReceive" + " : status = %d\n", status); + + return status; +} + +/* + * Function definition: ixPiuMhShow + */ + +PUBLIC IX_STATUS ixPiuMhShow ( + IxPiuMhPiuId piuId) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhShow\n"); + + /* check that we are initialized */ + if (!ixPiuMhInitialized) + { + IX_PIUMH_ERROR_REPORT ("IxPiuMh component is not initialized\n"); + return IX_FAIL; + } + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* parameters are ok ... */ + + /* note we don't get the lock here as printing the statistics */ + /* to a console may take some time and we don't want to impact */ + /* system performance. this means that the statistics displayed */ + /* may be in a state of flux and make not represent a consistent */ + /* snapshot. */ + + /* display a header */ + ixOsalLog (IX_OSAL_LOG_LVL_USER, IX_OSAL_LOG_DEV_STDOUT, + "Current state of PIU ID %d:\n\n", piuId, 0, 0, 0, 0, 0); + + /* show the current state of each module */ + + /* show the current state of the Configuration module */ + ixPiuMhConfigShow (piuId); + + /* show the current state of the Receive module */ + ixPiuMhReceiveShow (piuId); + + /* show the current state of the Send module */ + ixPiuMhSendShow (piuId); + + /* show the current state of the Solicited Callback Manager module */ + ixPiuMhSolicitedCbMgrShow (piuId); + + /* show the current state of the Unsolicited Callback Manager module */ + ixPiuMhUnsolicitedCbMgrShow (piuId); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhShow\n"); + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhShowReset + */ + +PUBLIC IX_STATUS ixPiuMhShowReset ( + IxPiuMhPiuId piuId) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhShowReset\n"); + + /* check that we are initialized */ + if (!ixPiuMhInitialized) + { + IX_PIUMH_ERROR_REPORT ("IxPiuMh component is not initialized\n"); + return IX_FAIL; + } + + /* check the piuId parameter */ + if (!ixPiuMhConfigPiuIdIsValid (piuId)) + { + IX_PIUMH_ERROR_REPORT ("PIU ID invalid\n"); + return IX_FAIL; + } + + /* parameters are ok ... */ + + /* note we don't get the lock here as resetting the statistics */ + /* shouldn't impact system performance. */ + + /* reset the current state of each module */ + + /* reset the current state of the Configuration module */ + ixPiuMhConfigShowReset (piuId); + + /* reset the current state of the Receive module */ + ixPiuMhReceiveShowReset (piuId); + + /* reset the current state of the Send module */ + ixPiuMhSendShowReset (piuId); + + /* reset the current state of the Solicited Callback Manager module */ + ixPiuMhSolicitedCbMgrShowReset (piuId); + + /* reset the current state of the Unsolicited Callback Manager module */ + ixPiuMhUnsolicitedCbMgrShowReset (piuId); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhShowReset\n"); + + return IX_SUCCESS; +} diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhConfig.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhConfig.c new file mode 100644 index 0000000..0c9061a --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhConfig.c @@ -0,0 +1,776 @@ +/** + * @file IxPiuMhConfig.c + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @description Contents are the implementation of the private API for the + * Configuration module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/* + * Put the system defined include files required. + */ + + +/* + * Put the user defined include files required. + */ + +#include "IxOsal.h" + +#include "IxPiuMhMacros_p.h" + +#include "IxPiuMhConfig_p.h" + + +#if defined(__ixp23xx) +#define IX_PIUMH_PIU0_INT (IX_PIU_IRQ_DBG0) +#define IX_PIUMH_PIU1_INT (IX_PIU_IRQ_DBG1) +#endif +#if defined(__ep805xx) +#define IX_PIUMH_PIU0_INT (IX_PIU_IRQ_DBG0) +#endif + + +PRIVATE IxPiuMhPiuInterrupts ixPiuMhConfigInterrupts; + +/* + * #defines and macros used in this file. + */ +#define IX_PIU_MH_MAX_NUM_OF_RETRIES 1000000 /**< Maximum number of + * retries before + * timeout + */ + +/* + * Typedefs whose scope is limited to this file. + */ + +/** + * @struct IxPiuMhConfigStats + * + * @brief This structure is used to maintain statistics for the + * Configuration module. + */ + +typedef struct +{ + UINT32 outFifoReads; /**< outFifo reads */ + UINT32 inFifoWrites; /**< inFifo writes */ + UINT32 maxInFifoFullRetries; /**< max retries if inFIFO full */ + UINT32 maxOutFifoEmptyRetries; /**< max retries if outFIFO empty */ +} IxPiuMhConfigStats; + +/* + * Variable declarations global to this file only. Externs are followed by + * static variables. + */ + +IxPiuMhConfigPiuInfo ixPiuMhConfigPiuInfo[IX_PIUMH_NUM_PIUS] = +{ +#if defined(__ixp23xx) + { + 0, /*mutex*/ + IX_PIUMH_PIU0_INT, /*interrupt ID*/ + 0, /*register virtual base address*/ + 0, /*status register virtual address*/ + 0, /*control register virtual address*/ + 0, /*inFIFO register virutal address*/ + 0, /*outFIFO register virtual address*/ + NULL, /*isr routine for handling interrupt*/ + FALSE /*old interrupt state (TRUE => enabled)*/ + }, + { + 0, /*mutex*/ + IX_PIUMH_PIU1_INT, /*interrupt ID*/ + 0, /*register virtual base address*/ + 0, /*status register virtual address*/ + 0, /*control register virtual address*/ + 0, /*inFIFO register virutal address*/ + 0, /*outFIFO register virtual address*/ + NULL, /*isr routine for handling interrupt*/ + FALSE /*old interrupt state (TRUE => enabled)*/ + } +#endif +#if defined(__ep805xx) + { + 0, /*mutex*/ + IX_PIUMH_PIU0_INT, /*interrupt ID*/ + IX_PIU_PIU0_PHYS, /*register physical base address*/ + 0, /*register virtual base address*/ + 0, /*status register virtual address*/ + 0, /*control register virtual address*/ + 0, /*inFIFO register virutal address*/ + 0, /*outFIFO register virtual address*/ + NULL, /*isr routine for handling interrupt*/ + FALSE /*old interrupt state (TRUE => enabled)*/ + } +#endif +#if defined(__ixp42X) || defined(__ixp46X) || defined(__ixp5XX) + { + 0, + IX_PIUMH_PIUA_INT, + 0, + 0, + 0, + 0, + 0, + NULL, + FALSE + }, + { + 0, + IX_PIUMH_PIUB_INT, + 0, + 0, + 0, + 0, + 0, + NULL, + FALSE + } +#endif +#if defined(__ixp42X) || defined(__ixp46X) && !defined(__ixp5XX) + , + { + 0, + IX_PIUMH_PIUC_INT, + 0, + 0, + 0, + 0, + 0, + NULL, + FALSE + } +#endif +}; + +PRIVATE IxPiuMhConfigStats ixPiuMhConfigStats[IX_PIUMH_NUM_PIUS]; + +/* + * Extern function prototypes. + */ + +/* + * Static function prototypes. + */ + +/* + * Function definition: ixPiuMhIsr + */ +void ixPiuMhIsr (void *parameter) +{ + IxPiuMhPiuId piuId = (IxPiuMhPiuId)parameter; + UINT32 ofint; + volatile UINT32 *statusReg = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].statusRegister; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhIsr\n"); + + /* get the OFINT (OutFifo interrupt) bit of the status register */ + IX_PIUMH_REGISTER_READ_BITS (statusReg, &ofint, IX_PIUMH_PIU_STAT_OFINT); + + /* if the OFINT status bit is set */ + if (ofint) + { + /* if there is an ISR registered for this PIU */ + if (ixPiuMhConfigPiuInfo[piuId].isr != NULL) + { + /* invoke the ISR routine */ + ixPiuMhConfigPiuInfo[piuId].isr (piuId); + } + else + { + /* if we don't service the interrupt the PIU will */ + /* continue to trigger the interrupt indefinitely */ + IX_PIUMH_ERROR_REPORT ("No ISR registered to service " + "interrupt\n"); + } + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhIsr\n"); +} + + +#if defined(__ep805xx) +/* + * Function definition: ixPiuMhConfigPhysicalAddressSet + */ + +void ixPiuMhConfigPhysicalAddressSet( + IxPiuMhPiuId piuId, + UINT32 address) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigPhysicalAddressSet\n"); + + /* set the address for the given PIU in the config structure */ + ixPiuMhConfigPiuInfo[piuId].physicalRegisterBase = address; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigPhysicalAddressSet\n"); +} + +/* + * Function definition: ixPiuMhConfigInterruptIdSet + */ + +void ixPiuMhConfigInterruptIdSet( + IxPiuMhPiuId piuId, + UINT32 interruptId) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigInterruptIdSet\n"); + + /* set the interruptID for the given PIU in the config structure */ + ixPiuMhConfigPiuInfo[piuId].interruptId = interruptId; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigInterruptIdSet\n"); +} +#endif /* #if defined(__ep805xx) */ + + +/* + * Function definition: ixPiuMhConfigInitialize + */ + +void ixPiuMhConfigInitialize ( + IxPiuMhPiuInterrupts piuInterrupts) +{ + IxPiuMhPiuId piuId; + UINT32 virtualAddr[IX_PIUMH_NUM_PIUS]; +#if defined(__ep805xx) + UINT32 physAddr = 0; +#endif + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigInitialize\n"); + + +#if defined(__ixp23xx) + /* PIU-0 register address space */ + virtualAddr[IX_PIUMH_PIUID_PIU0] = + (UINT32) IX_OSAL_MEM_MAP(IX_PIU_PIU0_PHYS,0); + + /* PIU-1 register address space */ + virtualAddr[IX_PIUMH_PIUID_PIU1] = + (UINT32) IX_OSAL_MEM_MAP(IX_PIU_PIU1_PHYS,0); +#endif + +#if defined(__ep805xx) + /* PIU-0 register address space */ + physAddr = ixPiuMhConfigPiuInfo[IX_PIUMH_PIUID_PIU0].physicalRegisterBase; + + /* no OS agnostic OSAL function available for memory mapping which works + * for linux - using linux ioremap call */ + virtualAddr[IX_PIUMH_PIUID_PIU0] = + (UINT32) ixOsalIoRemap (physAddr, IX_PIU_MAPPED_MEMORY_SIZE); + +#endif + +#if defined(__ixp42X) || defined(__ixp46X) || defined(__ixp5XX) + + /* Request a mapping for the PIU-A config register address space */ + virtualAddr[IX_PIUMH_PIUID_PIUA] = + (UINT32) IX_OSAL_MEM_MAP (IX_PIUMH_PIUA_BASE, + IX_OSAL_IXP400_PIUA_MAP_SIZE); + IX_OSAL_ASSERT (virtualAddr[IX_PIUMH_PIUID_PIUA]); + + /* Request a mapping for the PIU-B config register address space */ + virtualAddr[IX_PIUMH_PIUID_PIUB] = + (UINT32) IX_OSAL_MEM_MAP (IX_PIUMH_PIUB_BASE, + IX_OSAL_IXP400_PIUB_MAP_SIZE); + IX_OSAL_ASSERT (virtualAddr[IX_PIUMH_PIUID_PIUB]); +#endif +#if defined(__ixp42X) || defined(__ixp46X) && !defined(__ixp5XX) + /* Request a mapping for the PIU-C config register address space */ + virtualAddr[IX_PIUMH_PIUID_PIUC] = + (UINT32) IX_OSAL_MEM_MAP (IX_PIUMH_PIUC_BASE, + IX_OSAL_IXP400_PIUC_MAP_SIZE); + IX_OSAL_ASSERT (virtualAddr[IX_PIUMH_PIUID_PIUC]); +#endif + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* declare a convenience pointer */ + IxPiuMhConfigPiuInfo *piuInfo = &ixPiuMhConfigPiuInfo[piuId]; + + /* store the virtual addresses of the PIU registers for later use */ + piuInfo->virtualRegisterBase = virtualAddr[piuId]; + piuInfo->statusRegister = virtualAddr[piuId] + IX_PIUMH_PIUSTAT_OFFSET; + piuInfo->controlRegister = virtualAddr[piuId] + IX_PIUMH_PIUCTL_OFFSET; + piuInfo->inFifoRegister = virtualAddr[piuId] + IX_PIUMH_PIUFIFO_OFFSET; + piuInfo->outFifoRegister = virtualAddr[piuId] + IX_PIUMH_PIUFIFO_OFFSET; + + /* for test purposes - to verify the register addresses */ + IX_PIUMH_TRACE2 (IX_PIUMH_DEBUG, "PIU %d status register = " + "0x%08X\n", piuId, piuInfo->statusRegister); + IX_PIUMH_TRACE2 (IX_PIUMH_DEBUG, "PIU %d control register = " + "0x%08X\n", piuId, piuInfo->controlRegister); + IX_PIUMH_TRACE2 (IX_PIUMH_DEBUG, "PIU %d inFifo register = " + "0x%08X\n", piuId, piuInfo->inFifoRegister); + IX_PIUMH_TRACE2 (IX_PIUMH_DEBUG, "PIU %d outFifo register = " + "0x%08X\n", piuId, piuInfo->outFifoRegister); + + /* initialise a mutex for this PIU */ + (void) ixOsalMutexInit (&piuInfo->mutex); + + /* if we should service the PIU's "outFIFO not empty" interrupt */ + if (piuInterrupts == IX_PIUMH_PIUINTERRUPTS_YES) + { + /* enable the PIU's "outFIFO not empty" interrupt */ + ixPiuMhConfigPiuInterruptEnable (piuId); + } + else + { + /* disable the PIU's "outFIFO not empty" interrupt */ + ixPiuMhConfigPiuInterruptDisable (piuId); + } + } + + /* This will be used in ixPiuMhConfigUninit() */ + ixPiuMhConfigInterrupts = piuInterrupts; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigInitialize\n"); +} + +/* + * Function definition: ixPiuMhConfigUninit + */ + +void ixPiuMhConfigUninit (void) +{ + IxPiuMhPiuId piuId; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigUninit\n"); + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* declare a convenience pointer */ + IxPiuMhConfigPiuInfo *piuInfo = &ixPiuMhConfigPiuInfo[piuId]; + + /* Disconnect our ISR to the PIU interrupt */ + if (IX_PIUMH_PIUINTERRUPTS_YES == ixPiuMhConfigInterrupts) + { + ixPiuMhConfigPiuInterruptDisable (piuId); + } + + ixOsalMutexDestroy(&piuInfo->mutex); + +#if defined(__ep805xx) && !defined(UNIT_TEST) + /* no OS agnostic OSAL function available for memory mapping which works + * for linux - using linux iounmap call */ + ixOsalIoUnmap(piuInfo->virtualRegisterBase, IX_PIU_MAPPED_MEMORY_SIZE); +#endif + +#if !defined(__ep805xx) || defined(UNIT_TEST) + IX_OSAL_MEM_UNMAP (piuInfo->virtualRegisterBase); + IX_OSAL_MEM_UNMAP (piuInfo->statusRegister); + IX_OSAL_MEM_UNMAP (piuInfo->controlRegister); + IX_OSAL_MEM_UNMAP (piuInfo->inFifoRegister); + IX_OSAL_MEM_UNMAP (piuInfo->outFifoRegister); +#endif + } + + /* Reset this parameter here which was set during Init */ + if (IX_PIUMH_PIUINTERRUPTS_YES == ixPiuMhConfigInterrupts) + { + ixPiuMhConfigInterrupts = IX_PIUMH_PIUINTERRUPTS_NO; + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigUninit\n"); +} + +/* + * Function definition: ixPiuMhConfigIsrRegister + */ + +void ixPiuMhConfigIsrRegister ( + IxPiuMhPiuId piuId, + IxPiuMhConfigIsr isr) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigIsrRegister\n"); + + /* check if there is already an ISR registered for this PIU */ + if (ixPiuMhConfigPiuInfo[piuId].isr != NULL) + { + IX_PIUMH_TRACE0 (IX_PIUMH_DEBUG, "Over-writing registered PIU ISR\n"); + } + + /* save the ISR routine with the PIU info */ + ixPiuMhConfigPiuInfo[piuId].isr = isr; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigIsrRegister\n"); +} + +void ixPiuMhConfigIsrUnregister (IxPiuMhPiuId piuId) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigIsrUnregister\n"); + + ixPiuMhConfigPiuInfo[piuId].isr = NULL; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigIsrUnregister\n"); +} + +/* + * Function definition: ixPiuMhConfigPiuInterruptEnable + */ + +BOOL ixPiuMhConfigPiuInterruptEnable ( + IxPiuMhPiuId piuId) +{ + UINT32 ofe; + volatile UINT32 *controlReg = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].controlRegister; + + /* get the OFE (OutFifoEnable) bit of the control register */ + IX_PIUMH_REGISTER_READ_BITS (controlReg, &ofe, IX_PIUMH_PIU_CTL_OFE); + + /* if the interrupt is disabled then we must enable it */ + if (!ofe) + { + /* set the OFE (OutFifoEnable) bit of the control register */ + /* we must set the OFEWE (OutFifoEnableWriteEnable) at the same */ + /* time for the write to have effect */ + IX_PIUMH_REGISTER_WRITE_BITS (controlReg, + (IX_PIUMH_PIU_CTL_OFE | + IX_PIUMH_PIU_CTL_OFEWE), + (IX_PIUMH_PIU_CTL_OFE | + IX_PIUMH_PIU_CTL_OFEWE)); + } + + /* return the previous state of the interrupt */ + return (ofe != 0); +} + +/* + * Function definition: ixPiuMhConfigPiuInterruptDisable + */ + +BOOL ixPiuMhConfigPiuInterruptDisable ( + IxPiuMhPiuId piuId) +{ + UINT32 ofe; + volatile UINT32 *controlReg = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].controlRegister; + + /* get the OFE (OutFifoEnable) bit of the control register */ + IX_PIUMH_REGISTER_READ_BITS (controlReg, &ofe, IX_PIUMH_PIU_CTL_OFE); + + /* if the interrupt is enabled then we must disable it */ + if (ofe) + { + /* unset the OFE (OutFifoEnable) bit of the control register */ + /* we must set the OFEWE (OutFifoEnableWriteEnable) at the same */ + /* time for the write to have effect */ + IX_PIUMH_REGISTER_WRITE_BITS (controlReg, + (0 | + IX_PIUMH_PIU_CTL_OFEWE), + (IX_PIUMH_PIU_CTL_OFE | + IX_PIUMH_PIU_CTL_OFEWE)); + } + + /* return the previous state of the interrupt */ + return (ofe != 0); +} + +/* + * Function definition: ixPiuMhConfigMessageIdGet + */ + +IxPiuMhMessageId ixPiuMhConfigMessageIdGet ( + IxPiuMhMessage message) +{ + /* return the most-significant byte of the first word of the */ + /* message */ + return ((IxPiuMhMessageId) ((message.data[0] >> + IX_PIUMH_MESSAGE_ID_OFFSET) & 0xFF)); +} + +/* + * Function definition: ixPiuMhConfigPiuIdIsValid + */ + +BOOL ixPiuMhConfigPiuIdIsValid ( + IxPiuMhPiuId piuId) +{ + /* check that the piuId parameter is within the range of valid IDs */ + return (piuId >= 0 && piuId < IX_PIUMH_NUM_PIUS); +} + +/* + * Function definition: ixPiuMhConfigLockGet + */ + +void ixPiuMhConfigLockGet ( + IxPiuMhPiuId piuId) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigLockGet\n"); + + /* lock the mutex for this PIU */ + (void) ixOsalMutexLock (&ixPiuMhConfigPiuInfo[piuId].mutex, + IX_OSAL_WAIT_FOREVER); + + /* disable the PIU's "outFIFO not empty" interrupt */ + ixPiuMhConfigPiuInfo[piuId].oldInterruptState = + ixPiuMhConfigPiuInterruptDisable (piuId); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigLockGet\n"); +} + +/* + * Function definition: ixPiuMhConfigLockRelease + */ + +void ixPiuMhConfigLockRelease ( + IxPiuMhPiuId piuId) +{ + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhConfigLockRelease\n"); + + /* if the interrupt was previously enabled */ + if (ixPiuMhConfigPiuInfo[piuId].oldInterruptState) + { + /* enable the PIU's "outFIFO not empty" interrupt */ + ixPiuMhConfigPiuInfo[piuId].oldInterruptState = + ixPiuMhConfigPiuInterruptEnable (piuId); + } + + /* unlock the mutex for this PIU */ + (void) ixOsalMutexUnlock (&ixPiuMhConfigPiuInfo[piuId].mutex); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhConfigLockRelease\n"); +} + +/* + * Function definition: ixPiuMhConfigInFifoWrite + */ + +IX_STATUS ixPiuMhConfigInFifoWrite ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message) +{ + volatile UINT32 *piuInFifo = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].inFifoRegister; + UINT32 retriesCount = 0; + + /* write the first word of the message to the PIU's inFIFO */ + IX_PIUMH_REGISTER_WRITE (piuInFifo, message.data[0]); + + /* need to wait for room to write second word - see SCR #493, + poll for maximum number of retries, if exceed maximum + retries, exit from while loop */ + while ((IX_PIU_MH_MAX_NUM_OF_RETRIES > retriesCount) + && ixPiuMhConfigInFifoIsFull (piuId)) + { + retriesCount++; + } + + /* Return TIMEOUT status to caller, indicate that PIU Hang / Halt */ + if (IX_PIU_MH_MAX_NUM_OF_RETRIES == retriesCount) + { + return IX_PIUMH_CRITICAL_PIU_ERR; + } + + /* write the second word of the message to the PIU's inFIFO */ + IX_PIUMH_REGISTER_WRITE (piuInFifo, message.data[1]); + + /* record in the stats the maximum number of retries needed */ + if (ixPiuMhConfigStats[piuId].maxInFifoFullRetries < retriesCount) + { + ixPiuMhConfigStats[piuId].maxInFifoFullRetries = retriesCount; + } + + /* update statistical info */ + ixPiuMhConfigStats[piuId].inFifoWrites++; + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhConfigOutFifoRead + */ + +IX_STATUS ixPiuMhConfigOutFifoRead ( + IxPiuMhPiuId piuId, + IxPiuMhMessage *message) +{ + volatile UINT32 *piuOutFifo = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].outFifoRegister; + + /* read the first word of the message from the PIU's outFIFO */ + IX_PIUMH_REGISTER_READ (piuOutFifo, &message->data[0]); + +#if !defined(__ep805xx) + UINT32 retriesCount = 0; + /* need to wait for PIU to write second word - see SCR #493 + poll for maximum number of retries, if exceed maximum + retries, exit from while loop */ + while ((IX_PIU_MH_MAX_NUM_OF_RETRIES > retriesCount) + && ixPiuMhConfigOutFifoIsEmpty (piuId)) + { + retriesCount++; + } + + /* Return TIMEOUT status to caller, indicate that PIU Hang / Halt */ + if (IX_PIU_MH_MAX_NUM_OF_RETRIES == retriesCount) + { + return IX_PIUMH_CRITICAL_PIU_ERR; + } + + /* record in the stats the maximum number of retries needed */ + if (ixPiuMhConfigStats[piuId].maxOutFifoEmptyRetries < retriesCount) + { + ixPiuMhConfigStats[piuId].maxOutFifoEmptyRetries = retriesCount; + } +#endif /* #if !defined(__ep805xx) */ + + /* read the second word of the message from the PIU's outFIFO */ + IX_PIUMH_REGISTER_READ (piuOutFifo, &message->data[1]); + + /* update statistical info */ + ixPiuMhConfigStats[piuId].outFifoReads++; + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhConfigShow + */ + +void ixPiuMhConfigShow ( + IxPiuMhPiuId piuId) +{ + /* show the message fifo read counter */ + IX_PIUMH_SHOW ("Message FIFO reads", + ixPiuMhConfigStats[piuId].outFifoReads); + + /* show the message fifo write counter */ + IX_PIUMH_SHOW ("Message FIFO writes", + ixPiuMhConfigStats[piuId].inFifoWrites); + + /* show the max retries performed when inFIFO full */ + IX_PIUMH_SHOW ("Max inFIFO Full retries", + ixPiuMhConfigStats[piuId].maxInFifoFullRetries); + + /* show the max retries performed when outFIFO empty */ + IX_PIUMH_SHOW ("Max outFIFO Empty retries", + ixPiuMhConfigStats[piuId].maxOutFifoEmptyRetries); + + /* show the current status of the inFifo */ + ixOsalLog (IX_OSAL_LOG_LVL_USER, IX_OSAL_LOG_DEV_STDOUT, + "InFifo is %s and %s\n", + (ixPiuMhConfigInFifoIsEmpty (piuId) ? + (int) "EMPTY" : (int) "NOT EMPTY"), + (ixPiuMhConfigInFifoIsFull (piuId) ? + (int) "FULL" : (int) "NOT FULL"), + 0, 0, 0, 0); + + /* show the current status of the outFifo */ + ixOsalLog (IX_OSAL_LOG_LVL_USER, IX_OSAL_LOG_DEV_STDOUT, + "OutFifo is %s and %s\n", + (ixPiuMhConfigOutFifoIsEmpty (piuId) ? + (int) "EMPTY" : (int) "NOT EMPTY"), + (ixPiuMhConfigOutFifoIsFull (piuId) ? + (int) "FULL" : (int) "NOT FULL"), + 0, 0, 0, 0); +} + +/* + * Function definition: ixPiuMhConfigShowReset + */ + +void ixPiuMhConfigShowReset ( + IxPiuMhPiuId piuId) +{ + /* reset the message fifo read counter */ + ixPiuMhConfigStats[piuId].outFifoReads = 0; + + /* reset the message fifo write counter */ + ixPiuMhConfigStats[piuId].inFifoWrites = 0; + + /* reset the max inFIFO Full retries counter */ + ixPiuMhConfigStats[piuId].maxInFifoFullRetries = 0; + + /* reset the max outFIFO empty retries counter */ + ixPiuMhConfigStats[piuId].maxOutFifoEmptyRetries = 0; +} + + diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhDll.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhDll.c new file mode 100644 index 0000000..d01b0bb --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhDll.c @@ -0,0 +1,135 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * + * Use of this source code is subject to the terms of the Microsoft end-user + * license agreement (EULA) under which you licensed this SOFTWARE PRODUCT. + * If you did not accept the terms of the EULA, you are not authorized to use + * this source code. For a copy of the EULA, please see the LICENSE.RTF on your + * install media. +*/ +/** + * @file IxPiuMhDll.c + * + * @date June 23, 2003 + * + * @description Contents are the implementation for the piuMh layer + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * + */ + +#ifdef __wince + +/* + * System Defined Include Files + */ + +/* + * User Defined Header Files + */ +#include "IxOsalTypes.h" + +/* + * Macro Definitions + */ + +/* + * Type Definitions + */ + +/* + * Variable Declarations + */ + +/* + * Extern Function Prototypes + */ + +/* + * Static Function Prototypes + */ + +/* + * Function Definition + */ + +BOOL APIENTRY +IxPiuMhDllMain( + HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + break; + } + + return TRUE; +} + +#endif /* def __wince */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhReceive.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhReceive.c new file mode 100644 index 0000000..ee8737f --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhReceive.c @@ -0,0 +1,364 @@ +/** + * @file IxPiuMhReceive.c + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @description Contents are the implementation of the private API for + * the Receive module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/* + * Put the system defined include files required. + */ + + +/* + * Put the user defined include files required. + */ +#include "IxOsal.h" +#include "IxPiuMhMacros_p.h" +#include "IxPiuMhConfig_p.h" +#include "IxPiuMhReceive_p.h" +#include "IxPiuMhSolicitedCbMgr_p.h" +#include "IxPiuMhUnsolicitedCbMgr_p.h" + +/* + * #defines and macros used in this file. + */ + +/* + * Typedefs whose scope is limited to this file. + */ + +/** + * @struct IxPiuMhReceiveStats + * + * @brief This structure is used to maintain statistics for the Receive + * module. + */ + +typedef struct +{ + UINT32 isrs; /**< receive ISR invocations */ + UINT32 receives; /**< receive messages invocations */ + UINT32 messages; /**< messages received */ + UINT32 solicited; /**< solicited messages received */ + UINT32 unsolicited; /**< unsolicited messages received */ + UINT32 callbacks; /**< callbacks invoked */ +} IxPiuMhReceiveStats; + +/* + * Variable declarations global to this file only. Externs are followed by + * static variables. + */ + +PRIVATE IxPiuMhReceiveStats ixPiuMhReceiveStats[IX_PIUMH_NUM_PIUS]; + +/* + * Extern function prototypes. + */ + +/* + * Static function prototypes. + */ +PRIVATE +void ixPiuMhReceiveIsr (int piuId); + +PRIVATE +void ixPiuMhReceiveIsr (int piuId) +{ + int lockKey; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhReceiveIsr\n"); + + lockKey = ixOsalIrqLock (); + + /* invoke the message receive routine to get messages from the PIU */ + ixPiuMhReceiveMessagesReceive (piuId); + + /* update statistical info */ + ixPiuMhReceiveStats[piuId].isrs++; + + ixOsalIrqUnlock (lockKey); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhReceiveIsr\n"); +} + +/* + * Function definition: ixPiuMhReceiveInitialize + */ + +void ixPiuMhReceiveInitialize (void) +{ + IxPiuMhPiuId piuId = 0; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhReceiveInitialize\n"); + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* register our internal ISR for the PIU to handle "outFIFO not */ + /* empty" interrupts */ + ixPiuMhConfigIsrRegister (piuId, ixPiuMhReceiveIsr); + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhReceiveInitialize\n"); +} + +/* + * Function definition: ixPiuMhReceiveUninitialize + */ +void ixPiuMhReceiveUninitialize (void) +{ + IxPiuMhPiuId piuId; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhReceiveUninitialize\n"); + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* unregister and set ISR to NULL */ + ixPiuMhConfigIsrUnregister (piuId); + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhReceiveUninitialize\n"); + +} + +/* + * Function definition: ixPiuMhReceiveMessagesReceive + */ + +IX_STATUS ixPiuMhReceiveMessagesReceive ( + IxPiuMhPiuId piuId) +{ + IxPiuMhMessage message = { { 0, 0 } }; + IxPiuMhMessageId messageId = 0; + IxPiuMhCallback callback = NULL; + IX_STATUS status; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhReceiveMessagesReceive\n"); + + /* update statistical info */ + ixPiuMhReceiveStats[piuId].receives++; + + /* while the PIU has messages in its outFIFO */ + while (!ixPiuMhConfigOutFifoIsEmpty (piuId)) + { + /* read a message from the PIU's outFIFO */ + status = ixPiuMhConfigOutFifoRead (piuId, &message); + + if (IX_SUCCESS != status) + { + return status; + } + + /* get the ID of the message */ + messageId = ixPiuMhConfigMessageIdGet (message); + + IX_PIUMH_TRACE2 (IX_PIUMH_DEBUG, + "Received message from PIU %d with ID 0x%02X\n", + piuId, messageId); + + /* update statistical info */ + ixPiuMhReceiveStats[piuId].messages++; + + /* try to find a matching unsolicited callback for this message. */ + + /* we assume the message is unsolicited. only if there is no */ + /* unsolicited callback for this message type do we assume the */ + /* message is solicited. it is much faster to check for an */ + /* unsolicited callback, so doing this check first should result */ + /* in better performance. */ + + ixPiuMhUnsolicitedCbMgrCallbackRetrieve ( + piuId, messageId, &callback); + + if (callback != NULL) + { + IX_PIUMH_TRACE0 (IX_PIUMH_DEBUG, + "Found matching unsolicited callback\n"); + + /* update statistical info */ + ixPiuMhReceiveStats[piuId].unsolicited++; + } + + /* if no unsolicited callback was found try to find a matching */ + /* solicited callback for this message */ + if (callback == NULL) + { + ixPiuMhSolicitedCbMgrCallbackRetrieve ( + piuId, messageId, &callback); + + if (callback != NULL) + { + IX_PIUMH_TRACE0 (IX_PIUMH_DEBUG, + "Found matching solicited callback\n"); + + /* update statistical info */ + ixPiuMhReceiveStats[piuId].solicited++; + } + } + + /* if a callback (either unsolicited or solicited) was found */ + if (callback != NULL) + { + /* invoke the callback to pass the message back to the client */ + callback (piuId, message); + + /* update statistical info */ + ixPiuMhReceiveStats[piuId].callbacks++; + } + else /* no callback (neither unsolicited nor solicited) was found */ + { + IX_PIUMH_TRACE2 (IX_PIUMH_WARNING, + "No matching callback for PIU %d" + " and ID 0x%02X, discarding message\n", + piuId, messageId); + + /* the message will be discarded. this is normal behaviour */ + /* if the client passes a NULL solicited callback when */ + /* sending a message. this indicates that the client is not */ + /* interested in receiving the response. alternatively a */ + /* NULL callback here may signify an unsolicited message */ + /* with no appropriate registered callback. */ + } + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhReceiveMessagesReceive\n"); + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhReceiveShow + */ + +void ixPiuMhReceiveShow ( + IxPiuMhPiuId piuId) +{ + /* show the ISR invocation counter */ + IX_PIUMH_SHOW ("Receive ISR invocations", + ixPiuMhReceiveStats[piuId].isrs); + + /* show the receive message invocation counter */ + IX_PIUMH_SHOW ("Receive messages invocations", + ixPiuMhReceiveStats[piuId].receives); + + /* show the message received counter */ + IX_PIUMH_SHOW ("Messages received", + ixPiuMhReceiveStats[piuId].messages); + + /* show the solicited message counter */ + IX_PIUMH_SHOW ("Solicited messages received", + ixPiuMhReceiveStats[piuId].solicited); + + /* show the unsolicited message counter */ + IX_PIUMH_SHOW ("Unsolicited messages received", + ixPiuMhReceiveStats[piuId].unsolicited); + + /* show the callback invoked counter */ + IX_PIUMH_SHOW ("Callbacks invoked", + ixPiuMhReceiveStats[piuId].callbacks); + + /* show the message discarded counter */ + IX_PIUMH_SHOW ("Received messages discarded", + (ixPiuMhReceiveStats[piuId].messages - + ixPiuMhReceiveStats[piuId].callbacks)); +} + +/* + * Function definition: ixPiuMhReceiveShowReset + */ + +void ixPiuMhReceiveShowReset ( + IxPiuMhPiuId piuId) +{ + /* reset the ISR invocation counter */ + ixPiuMhReceiveStats[piuId].isrs = 0; + + /* reset the receive message invocation counter */ + ixPiuMhReceiveStats[piuId].receives = 0; + + /* reset the message received counter */ + ixPiuMhReceiveStats[piuId].messages = 0; + + /* reset the solicited message counter */ + ixPiuMhReceiveStats[piuId].solicited = 0; + + /* reset the unsolicited message counter */ + ixPiuMhReceiveStats[piuId].unsolicited = 0; + + /* reset the callback invoked counter */ + ixPiuMhReceiveStats[piuId].callbacks = 0; +} diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSend.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSend.c new file mode 100644 index 0000000..5950352 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSend.c @@ -0,0 +1,327 @@ +/** + * @file IxPiuMhSend.c + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @description Contents are the implementation of the private API for + * the Send module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/* + * Put the system defined include files required. + */ + + +/* + * Put the user defined include files required. + */ + +#include "IxPiuMhMacros_p.h" + +#include "IxPiuMhConfig_p.h" +#include "IxPiuMhSend_p.h" +#include "IxPiuMhSolicitedCbMgr_p.h" + +/* + * #defines and macros used in this file. + */ + +/** + * @def IX_PIUMH_INFIFO_RETRY_DELAY_US + * + * @brief Amount of time (uSecs) to delay between retries + * while inFIFO is Full when attempting to send a message + */ +#define IX_PIUMH_INFIFO_RETRY_DELAY_US (1) + + +/* + * Typedefs whose scope is limited to this file. + */ + +/** + * @struct IxPiuMhSendStats + * + * @brief This structure is used to maintain statistics for the Send + * module. + */ + +typedef struct +{ + UINT32 sends; /**< send invocations */ + UINT32 sendWithResponses; /**< send with response invocations */ + UINT32 queueFulls; /**< fifo queue full occurrences */ + UINT32 queueFullRetries; /**< fifo queue full retry occurrences */ + UINT32 maxQueueFullRetries; /**< max fifo queue full retries */ + UINT32 callbackFulls; /**< callback list full occurrences */ +} IxPiuMhSendStats; + +/* + * Variable declarations global to this file only. Externs are followed by + * static variables. + */ + +PRIVATE IxPiuMhSendStats ixPiuMhSendStats[IX_PIUMH_NUM_PIUS]; + +/* + * Extern function prototypes. + */ + +/* + * Static function prototypes. + */ +PRIVATE +BOOL ixPiuMhSendInFifoIsFull( + IxPiuMhPiuId piuId, + UINT32 maxSendRetries); + +/* + * Function definition: ixPiuMhSendInFifoIsFull + */ + +PRIVATE +BOOL ixPiuMhSendInFifoIsFull( + IxPiuMhPiuId piuId, + UINT32 maxSendRetries) +{ + BOOL isFull = FALSE; + UINT32 numRetries = 0; + + /* check the PIU's inFIFO */ + isFull = ixPiuMhConfigInFifoIsFull (piuId); + + /* we retry a few times, just to give the PIU a chance to read from */ + /* the FIFO if the FIFO is currently full */ + while (isFull && (numRetries < maxSendRetries)) + { + numRetries++; + if (numRetries >= IX_PIUMH_SEND_RETRIES_DEFAULT) + { + /* Delay here for as short a time as possible (1 us). */ + /* Adding a delay here should ensure we are not hogging */ + /* the AHB bus while we are retrying */ + ixOsalBusySleep (IX_PIUMH_INFIFO_RETRY_DELAY_US); + } + + /* re-check the PIU's inFIFO */ + isFull = ixPiuMhConfigInFifoIsFull (piuId); + + /* update statistical info */ + ixPiuMhSendStats[piuId].queueFullRetries++; + } + + /* record the highest number of retries that occurred */ + if (ixPiuMhSendStats[piuId].maxQueueFullRetries < numRetries) + { + ixPiuMhSendStats[piuId].maxQueueFullRetries = numRetries; + } + + if (isFull) + { + /* update statistical info */ + ixPiuMhSendStats[piuId].queueFulls++; + } + + return isFull; +} + +/* + * Function definition: ixPiuMhSendMessageSend + */ + +IX_STATUS ixPiuMhSendMessageSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + UINT32 maxSendRetries) +{ + IX_STATUS status; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhSendMessageSend\n"); + + /* update statistical info */ + ixPiuMhSendStats[piuId].sends++; + + /* check if the PIU's inFIFO is full - if so return an error */ + if (ixPiuMhSendInFifoIsFull (piuId, maxSendRetries)) + { + IX_PIUMH_TRACE0 (IX_PIUMH_WARNING, "PIU's inFIFO is full\n"); + return IX_FAIL; + } + + /* write the message to the PIU's inFIFO */ + status = ixPiuMhConfigInFifoWrite (piuId, message); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhSendMessageSend\n"); + + return status; +} + +/* + * Function definition: ixPiuMhSendMessageWithResponseSend + */ + +IX_STATUS ixPiuMhSendMessageWithResponseSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback solicitedCallback, + UINT32 maxSendRetries) +{ + IX_STATUS status = IX_SUCCESS; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhSendMessageWithResponseSend\n"); + + /* update statistical info */ + ixPiuMhSendStats[piuId].sendWithResponses++; + + /* check if the PIU's inFIFO is full - if so return an error */ + if (ixPiuMhSendInFifoIsFull (piuId, maxSendRetries)) + { + IX_PIUMH_TRACE0 (IX_PIUMH_WARNING, "PIU's inFIFO is full\n"); + return IX_FAIL; + } + + /* save the solicited callback */ + status = ixPiuMhSolicitedCbMgrCallbackSave ( + piuId, solicitedMessageId, solicitedCallback); + if (status != IX_SUCCESS) + { + IX_PIUMH_ERROR_REPORT ("Failed to save solicited callback\n"); + + /* update statistical info */ + ixPiuMhSendStats[piuId].callbackFulls++; + + return status; + } + + /* write the message to the PIU's inFIFO */ + status = ixPiuMhConfigInFifoWrite (piuId, message); + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhSendMessageWithResponseSend\n"); + + return status; +} + +/* + * Function definition: ixPiuMhSendShow + */ + +void ixPiuMhSendShow ( + IxPiuMhPiuId piuId) +{ + /* show the message send invocation counter */ + IX_PIUMH_SHOW ("Send invocations", + ixPiuMhSendStats[piuId].sends); + + /* show the message send with response invocation counter */ + IX_PIUMH_SHOW ("Send with response invocations", + ixPiuMhSendStats[piuId].sendWithResponses); + + /* show the fifo queue full occurrence counter */ + IX_PIUMH_SHOW ("Fifo queue full occurrences", + ixPiuMhSendStats[piuId].queueFulls); + + /* show the fifo queue full retry occurrence counter */ + IX_PIUMH_SHOW ("Fifo queue full retry occurrences", + ixPiuMhSendStats[piuId].queueFullRetries); + + /* show the fifo queue full maximum retries counter */ + IX_PIUMH_SHOW ("Maximum fifo queue full retries", + ixPiuMhSendStats[piuId].maxQueueFullRetries); + + /* show the callback list full occurrence counter */ + IX_PIUMH_SHOW ("Solicited callback list full occurrences", + ixPiuMhSendStats[piuId].callbackFulls); +} + +/* + * Function definition: ixPiuMhSendShowReset + */ + +void ixPiuMhSendShowReset ( + IxPiuMhPiuId piuId) +{ + /* reset the message send invocation counter */ + ixPiuMhSendStats[piuId].sends = 0; + + /* reset the message send with response invocation counter */ + ixPiuMhSendStats[piuId].sendWithResponses = 0; + + /* reset the fifo queue full occurrence counter */ + ixPiuMhSendStats[piuId].queueFulls = 0; + + /* reset the fifo queue full retry occurrence counter */ + ixPiuMhSendStats[piuId].queueFullRetries = 0; + + /* reset the max fifo queue full retries counter */ + ixPiuMhSendStats[piuId].maxQueueFullRetries = 0; + + /* reset the callback list full occurrence counter */ + ixPiuMhSendStats[piuId].callbackFulls = 0; +} diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSolicitedCbMgr.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSolicitedCbMgr.c new file mode 100644 index 0000000..c8e8fb1 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSolicitedCbMgr.c @@ -0,0 +1,436 @@ +/** + * @file IxPiuMhSolicitedCbMgr.c + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @description Contents are the implementation of the private API for + * the Solicited Callback Manager module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ +#ifndef IXPIUMHCONFIG_P_H +# define IXPIUMHSOLICITEDCBMGR_C +#else +# error "Error, IxPiuMhConfig_p.h should not be included before this defn." +#endif + +/* + * Put the system defined include files required. + */ + + +/* + * Put the user defined include files required. + */ + +#include "IxOsal.h" + +#include "IxPiuMhMacros_p.h" +#include "IxPiuMhSolicitedCbMgr_p.h" +#include "IxPiuMhConfig_p.h" +/* + * #defines and macros used in this file. + */ + +/* + * Typedefs whose scope is limited to this file. + */ + +/** + * @struct IxPiuMhSolicitedCallbackListEntry + * + * @brief This structure is used to store the information associated with + * an entry in the callback list. This consists of the ID of the send + * message (which indicates the ID of the corresponding response message) + * and the callback function pointer itself. + * + */ +typedef struct IxPiuMhSolicitedCallbackListEntry +{ + /** message ID */ + IxPiuMhMessageId messageId; + + /** callback function pointer */ + IxPiuMhCallback callback; + + /** pointer to next entry in the list */ + struct IxPiuMhSolicitedCallbackListEntry *next; +} IxPiuMhSolicitedCallbackListEntry; + +/** + * @struct IxPiuMhSolicitedCallbackList + * + * @brief This structure is used to maintain the list of response + * callbacks. The number of entries in this list will be variable, and + * they will be stored in a linked list fashion for ease of addition and + * removal. The entries themselves are statically allocated, and are + * organised into a "free" list and a "callback" list. Adding an entry + * means taking an entry from the "free" list and adding it to the + * "callback" list. Removing an entry means removing it from the + * "callback" list and returning it to the "free" list. + */ + +typedef struct +{ + /** pointer to the head of the free list */ + IxPiuMhSolicitedCallbackListEntry *freeHead; + + /** pointer to the head of the callback list */ + IxPiuMhSolicitedCallbackListEntry *callbackHead; + + /** pointer to the tail of the callback list */ + IxPiuMhSolicitedCallbackListEntry *callbackTail; + + /** array of entries - the first entry is used as a dummy entry to */ + /* avoid the scenario of having an empty list, hence '+ 1' */ + IxPiuMhSolicitedCallbackListEntry entries[IX_PIUMH_MAX_CALLBACKS + 1]; +} IxPiuMhSolicitedCallbackList; + +/** + * @struct IxPiuMhSolicitedCbMgrStats + * + * @brief This structure is used to maintain statistics for the Solicited + * Callback Manager module. + */ + +typedef struct +{ + UINT32 saves; /**< callback list saves */ + UINT32 retrieves; /**< callback list retrieves */ +} IxPiuMhSolicitedCbMgrStats; + +/* + * Variable declarations global to this file only. Externs are followed by + * static variables. + */ + +PRIVATE IxPiuMhSolicitedCallbackList +ixPiuMhSolicitedCbMgrCallbackLists[IX_PIUMH_NUM_PIUS]; + +PRIVATE IxPiuMhSolicitedCbMgrStats +ixPiuMhSolicitedCbMgrStats[IX_PIUMH_NUM_PIUS]; + +/* + * Extern function prototypes. + */ + +/* + * Static function prototypes. + */ + +/* + * Function definition: ixPiuMhSolicitedCbMgrInitialize + */ + +void ixPiuMhSolicitedCbMgrInitialize (void) +{ + IxPiuMhPiuId piuId; + UINT32 localIndex; + IxPiuMhSolicitedCallbackList *list = NULL; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhSolicitedCbMgrInitialize\n"); + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* initialise a pointer to the list for convenience */ + list = &ixPiuMhSolicitedCbMgrCallbackLists[piuId]; + + /* for each entry in the list, after the dummy entry ... */ + for (localIndex = 1; localIndex <= IX_PIUMH_MAX_CALLBACKS; localIndex++) + { + /* initialise the entry */ + list->entries[localIndex].messageId = 0x00; + list->entries[localIndex].callback = NULL; + + /* if this entry is before the last entry */ + if (localIndex < IX_PIUMH_MAX_CALLBACKS) + { + /* chain this entry to the following entry */ + list->entries[localIndex].next = + &(list->entries[localIndex + 1]); + } + else /* this entry is the last entry */ + { + /* the last entry isn't chained to anything */ + list->entries[localIndex].next = NULL; + } + } + + /* set the free list pointer to point to the first real entry */ + /* (all real entries begin chained together on the free list) */ + list->freeHead = &(list->entries[1]); + + /* set the callback list pointers to point to the dummy entry */ + /* (the callback list is initially empty) */ + list->callbackHead = &(list->entries[0]); + list->callbackTail = &(list->entries[0]); + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhSolicitedCbMgrInitialize\n"); +} + +/* + * Function definition: ixPiuMhSolicitedCbMgrUninitialize + */ +void ixPiuMhSolicitedCbMgrUninitialize (void) +{ + IxPiuMhPiuId piuId; + UINT32 localIndex; + IxPiuMhSolicitedCallbackList *list; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhSolicitedCbMgrUninitialize\n"); + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* initialise a pointer to the list for convenience */ + list = &ixPiuMhSolicitedCbMgrCallbackLists[piuId]; + + /* for each entry in the list, after the dummy entry ... */ + for (localIndex = 1; localIndex <= IX_PIUMH_MAX_CALLBACKS; localIndex++) + { + /* initialise the entry */ + list->entries[localIndex].messageId = 0x00; + list->entries[localIndex].callback = NULL; + + /* if this entry is before the last entry */ + if (IX_PIUMH_MAX_CALLBACKS > localIndex) + { + /* chain this entry to the following entry */ + list->entries[localIndex].next = + &(list->entries[localIndex + 1]); + } + else /* this entry is the last entry */ + { + /* the last entry isn't chained to anything */ + list->entries[localIndex].next = NULL; + } + } + /* set the free list pointer to point to the first real entry */ + /* (all real entries begin chained together on the free list) */ + list->freeHead = &(list->entries[1]); + + /* set the callback list pointers to point to the dummy entry */ + /* (the callback list is initially empty) */ + list->callbackHead = &(list->entries[0]); + list->callbackTail = &(list->entries[0]); + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhSolicitedCbMgrUninitialize\n"); + +} + +/* + * Function definition: ixPiuMhSolicitedCbMgrCallbackSave + */ + +IX_STATUS ixPiuMhSolicitedCbMgrCallbackSave ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback solicitedCallback) +{ + IxPiuMhSolicitedCallbackList *list = NULL; + IxPiuMhSolicitedCallbackListEntry *callbackEntry = NULL; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhSolicitedCbMgrCallbackSave\n"); + + /* initialise a pointer to the list for convenience */ + list = &ixPiuMhSolicitedCbMgrCallbackLists[piuId]; + + /* check to see if there are any entries in the free list */ + if (list->freeHead == NULL) + { + IX_PIUMH_ERROR_REPORT ("Solicited callback list is full\n"); + return IX_FAIL; + } + + /* there is an entry in the free list we can use */ + + /* update statistical info */ + ixPiuMhSolicitedCbMgrStats[piuId].saves++; + + /* remove a callback entry from the start of the free list */ + callbackEntry = list->freeHead; + list->freeHead = callbackEntry->next; + + /* fill in the callback entry with the new data */ + callbackEntry->messageId = solicitedMessageId; + callbackEntry->callback = solicitedCallback; + + /* the new callback entry will be added to the tail of the callback */ + /* list, so it isn't chained to anything */ + callbackEntry->next = NULL; + + /* chain new callback entry to the last entry of the callback list */ + list->callbackTail->next = callbackEntry; + list->callbackTail = callbackEntry; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhSolicitedCbMgrCallbackSave\n"); + + return IX_SUCCESS; +} + +/* + * Function definition: ixPiuMhSolicitedCbMgrCallbackRetrieve + */ + +void ixPiuMhSolicitedCbMgrCallbackRetrieve ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback *solicitedCallback) +{ + IxPiuMhSolicitedCallbackList *list = NULL; + IxPiuMhSolicitedCallbackListEntry *callbackEntry = NULL; + IxPiuMhSolicitedCallbackListEntry *previousEntry = NULL; + + /* initialise a pointer to the list for convenience */ + list = &ixPiuMhSolicitedCbMgrCallbackLists[piuId]; + + /* initialise the callback entry to the first entry of the callback */ + /* list - we must skip over the dummy entry, which is the previous */ + if (list != NULL) + { + callbackEntry = list->callbackHead->next; + previousEntry = list->callbackHead; + } + + /* traverse the callback list looking for an entry with a matching */ + /* message ID. note we also save the previous entry's pointer to */ + /* allow us to unchain the matching entry from the callback list */ + while ((callbackEntry != NULL) && + (callbackEntry->messageId != solicitedMessageId)) + { + previousEntry = callbackEntry; + callbackEntry = callbackEntry->next; + } + + /* if we didn't find a matching callback entry */ + if (callbackEntry == NULL) + { + /* return a NULL callback in the outgoing parameter */ + *solicitedCallback = NULL; + } + else /* we found a matching callback entry */ + { + /* update statistical info */ + ixPiuMhSolicitedCbMgrStats[piuId].retrieves++; + + /* return the callback in the outgoing parameter */ + *solicitedCallback = callbackEntry->callback; + + /* unchain callback entry by chaining previous entry to next */ + previousEntry->next = callbackEntry->next; + + /* if the callback entry is at the tail of the list */ + if (list->callbackTail == callbackEntry) + { + /* update the tail of the callback list */ + list->callbackTail = previousEntry; + } + + /* re-initialise the callback entry */ + callbackEntry->messageId = 0x00; + callbackEntry->callback = NULL; + + /* add the callback entry to the start of the free list */ + callbackEntry->next = list->freeHead; + list->freeHead = callbackEntry; + } +} + +/* + * Function definition: ixPiuMhSolicitedCbMgrShow + */ + +void ixPiuMhSolicitedCbMgrShow ( + IxPiuMhPiuId piuId) +{ + /* show the solicited callback list save counter */ + IX_PIUMH_SHOW ("Solicited callback list saves", + ixPiuMhSolicitedCbMgrStats[piuId].saves); + + /* show the solicited callback list retrieve counter */ + IX_PIUMH_SHOW ("Solicited callback list retrieves", + ixPiuMhSolicitedCbMgrStats[piuId].retrieves); +} + +/* + * Function definition: ixPiuMhSolicitedCbMgrShowReset + */ + +void ixPiuMhSolicitedCbMgrShowReset ( + IxPiuMhPiuId piuId) +{ + /* reset the solicited callback list save counter */ + ixPiuMhSolicitedCbMgrStats[piuId].saves = 0; + + /* reset the solicited callback list retrieve counter */ + ixPiuMhSolicitedCbMgrStats[piuId].retrieves = 0; +} diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSymbols.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSymbols.c new file mode 100644 index 0000000..e80f806 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhSymbols.c @@ -0,0 +1,110 @@ +/* + * @file IxPiuMhSymbols.c + * + * @author Intel Corporation + * @date 04-Oct-2002 + * + * @brief Contents are declarations for exported symbols for linux kernel + * module builds. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * + */ + +#ifdef __linux + +#include <linux/module.h> +#include <IxPiuMh.h> + +EXPORT_SYMBOL(ixPiuMhPhysicalAddressSet); + +EXPORT_SYMBOL(ixPiuMhInitialize); +EXPORT_SYMBOL(ixPiuMhUnload); +EXPORT_SYMBOL(ixPiuMhUnsolicitedCallbackRegister); +EXPORT_SYMBOL(ixPiuMhUnsolicitedCallbackForRangeRegister); +EXPORT_SYMBOL(ixPiuMhMessageSend); +EXPORT_SYMBOL(ixPiuMhMessageWithResponseSend); +EXPORT_SYMBOL(ixPiuMhMessagesReceive); +EXPORT_SYMBOL(ixPiuMhShow); +EXPORT_SYMBOL(ixPiuMhShowReset); +EXPORT_SYMBOL(ixPiuMhInterruptIdSet); + +extern void ixPiuMhIsr (void *parameter); +extern BOOL ixPiuMhConfigInFifoIsFull(IxPiuMhPiuId piuId); +extern BOOL ixPiuMhConfigOutFifoIsEmpty (IxPiuMhPiuId piuId); +extern void ixPiuMhConfigLockRelease (IxPiuMhPiuId piuId); +extern void ixPiuMhConfigLockGet (IxPiuMhPiuId piuId); +extern void ixPiuMhConfigOutFifoRead (IxPiuMhPiuId piuId, + IxPiuMhMessage *message); +extern void ixPiuMhConfigInFifoWrite (IxPiuMhPiuId piuId, + IxPiuMhMessage message); + + +EXPORT_SYMBOL(ixPiuMhIsr); +EXPORT_SYMBOL(ixPiuMhConfigInFifoIsFull); +EXPORT_SYMBOL(ixPiuMhConfigOutFifoIsEmpty); +EXPORT_SYMBOL(ixPiuMhConfigLockRelease); +EXPORT_SYMBOL(ixPiuMhConfigLockGet); +EXPORT_SYMBOL(ixPiuMhConfigOutFifoRead); +EXPORT_SYMBOL(ixPiuMhConfigInFifoWrite); + + +#endif /* __linux */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhUnsolicitedCbMgr.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhUnsolicitedCbMgr.c new file mode 100644 index 0000000..468b5e5 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/IxPiuMhUnsolicitedCbMgr.c @@ -0,0 +1,301 @@ +/** + * @file IxPiuMhUnsolicitedCbMgr.c + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @description Contents are the implementation of the private API for + * the Unsolicited Callback Manager module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/* + * Put the system defined include files required. + */ + + +/* + * Put the user defined include files required. + */ +#include "IxOsal.h" + +#include "IxPiuMhMacros_p.h" + +#include "IxPiuMhUnsolicitedCbMgr_p.h" + + +/* + * #defines and macros used in this file. + */ + +/* + * Typedefs whose scope is limited to this file. + */ + +/** + * @struct IxPiuMhUnsolicitedCallbackTable + * + * @brief This structure is used to maintain the list of registered + * callbacks. One entry exists for each message ID, and a NULL entry will + * signify that no callback has been registered for that ID. + */ + +typedef struct +{ + /** array of entries */ + IxPiuMhCallback entries[IX_PIUMH_MAX_MESSAGE_ID + 1]; +} IxPiuMhUnsolicitedCallbackTable; + +/** + * @struct IxPiuMhUnsolicitedCbMgrStats + * + * @brief This structure is used to maintain statistics for the Unsolicited + * Callback Manager module. + */ + +typedef struct +{ + UINT32 saves; /**< callback table saves */ + UINT32 overwrites; /**< callback table overwrites */ +} IxPiuMhUnsolicitedCbMgrStats; + +/* + * Variable declarations global to this file only. Externs are followed by + * static variables. + */ + +PRIVATE IxPiuMhUnsolicitedCallbackTable +ixPiuMhUnsolicitedCallbackTables[IX_PIUMH_NUM_PIUS]; + +PRIVATE IxPiuMhUnsolicitedCbMgrStats +ixPiuMhUnsolicitedCbMgrStats[IX_PIUMH_NUM_PIUS]; + +/* + * Extern function prototypes. + */ + +/* + * Static function prototypes. + */ + +/* + * Function definition: ixPiuMhUnsolicitedCbMgrInitialize + */ + +void ixPiuMhUnsolicitedCbMgrInitialize (void) +{ + IxPiuMhPiuId piuId = 0; + IxPiuMhUnsolicitedCallbackTable *table = NULL; + IxPiuMhMessageId messageId = 0; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhUnsolicitedCbMgrInitialize\n"); + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* initialise a pointer to the table for convenience */ + table = &ixPiuMhUnsolicitedCallbackTables[piuId]; + + /* for each message ID ... */ + for (messageId = IX_PIUMH_MIN_MESSAGE_ID; + messageId <= IX_PIUMH_MAX_MESSAGE_ID; messageId++) + { + /* initialise the callback for this message ID to NULL */ + table->entries[messageId] = NULL; + } + } + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhUnsolicitedCbMgrInitialize\n"); +} + +/* + * Function definition: ixPiuMhUnsolicitedCbMgrCallbackSave + */ +void ixPiuMhUnsolicitedCbMgrUninitialize (void) +{ + IxPiuMhPiuId piuId; + IxPiuMhUnsolicitedCallbackTable *table; + IxPiuMhMessageId messageId; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhUnsolicitedCbMgrUninitialize\n"); + + /* for each PIU ... */ + for (piuId = 0; piuId < IX_PIUMH_NUM_PIUS; piuId++) + { + /* initialise a pointer to the table for convenience */ + table = &ixPiuMhUnsolicitedCallbackTables[piuId]; + + /* for each message ID ... */ + for (messageId = IX_PIUMH_MIN_MESSAGE_ID; + messageId <= IX_PIUMH_MAX_MESSAGE_ID; messageId++) + { + /* initialise the callback for this message ID to NULL */ + table->entries[messageId] = NULL; + } + } + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhUnsolicitedCbMgrUninitialize\n"); +} + +/* + * Function definition: ixPiuMhUnsolicitedCbMgrCallbackSave + */ + +void ixPiuMhUnsolicitedCbMgrCallbackSave ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId unsolicitedMessageId, + IxPiuMhCallback unsolicitedCallback) +{ + IxPiuMhUnsolicitedCallbackTable *table = NULL; + + /* initialise a pointer to the table for convenience */ + table = &ixPiuMhUnsolicitedCallbackTables[piuId]; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Entering " + "ixPiuMhUnsolicitedCbMgrCallbackSave\n"); + + /* update statistical info */ + ixPiuMhUnsolicitedCbMgrStats[piuId].saves++; + + /* check if there is a callback already registered for this PIU and */ + /* message ID */ + if (table->entries[unsolicitedMessageId] != NULL) + { + /* if we are overwriting an existing callback */ + if (unsolicitedCallback != NULL) + { + IX_PIUMH_TRACE2 (IX_PIUMH_DEBUG, "Unsolicited callback " + "overwriting existing callback for PIU ID %d " + "message ID 0x%02X\n", piuId, unsolicitedMessageId); + } + else /* if we are clearing an existing callback */ + { + IX_PIUMH_TRACE2 (IX_PIUMH_DEBUG, "NULL unsolicited callback " + "clearing existing callback for PIU ID %d " + "message ID 0x%02X\n", piuId, unsolicitedMessageId); + } + + /* update statistical info */ + ixPiuMhUnsolicitedCbMgrStats[piuId].overwrites++; + } + + /* save the callback into the table */ + table->entries[unsolicitedMessageId] = unsolicitedCallback; + + IX_PIUMH_TRACE0 (IX_PIUMH_FN_ENTRY_EXIT, "Exiting " + "ixPiuMhUnsolicitedCbMgrCallbackSave\n"); +} + +/* + * Function definition: ixPiuMhUnsolicitedCbMgrCallbackRetrieve + */ + +void ixPiuMhUnsolicitedCbMgrCallbackRetrieve ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId unsolicitedMessageId, + IxPiuMhCallback *unsolicitedCallback) +{ + IxPiuMhUnsolicitedCallbackTable *table = NULL; + + /* initialise a pointer to the table for convenience */ + table = &ixPiuMhUnsolicitedCallbackTables[piuId]; + + /* retrieve the callback from the table */ + if (unsolicitedCallback != NULL) + { + *unsolicitedCallback = table->entries[unsolicitedMessageId]; + } +} + +/* + * Function definition: ixPiuMhUnsolicitedCbMgrShow + */ + +void ixPiuMhUnsolicitedCbMgrShow ( + IxPiuMhPiuId piuId) +{ + /* show the unsolicited callback table save counter */ + IX_PIUMH_SHOW ("Unsolicited callback table saves", + ixPiuMhUnsolicitedCbMgrStats[piuId].saves); + + /* show the unsolicited callback table overwrite counter */ + IX_PIUMH_SHOW ("Unsolicited callback table overwrites", + ixPiuMhUnsolicitedCbMgrStats[piuId].overwrites); +} + +/* + * Function definition: ixPiuMhUnsolicitedCbMgrShowReset + */ + +void ixPiuMhUnsolicitedCbMgrShowReset ( + IxPiuMhPiuId piuId) +{ + /* reset the unsolicited callback table save counter */ + ixPiuMhUnsolicitedCbMgrStats[piuId].saves = 0; + + /* reset the unsolicited callback table overwrite counter */ + ixPiuMhUnsolicitedCbMgrStats[piuId].overwrites = 0; +} diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/Makefile b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/Makefile new file mode 100644 index 0000000..3d4fcf1 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/Makefile @@ -0,0 +1,144 @@ +######################################################################### +# This Template Makefile will create the libraries, executables and module and place them in the output folder +# Remove the comments around the sections you wish to build for. +# +#Procedure +#1) Copy this template to the location of your source files +#2) "Common variables and defintions" must be filled out +#3) Edit as desired the "Libraries and executable section" and/or the "Linux kernel 2.6 Module section" depending on what you wish to build +#4) Remove the comments around the section and delete the other unnecessary section +#5) Save changes, return to command line and type "make". +# +# +# Targets supported +# all - builds everything and installs +# install - identical to all +# depend - build dependencies +# clean - clears all derived objects +# +# included makefiles +# common.mk - common defintions +# depend.mk - depend and cleandepend rules +# rules.mk - build rules. +# +# @par +# This file is provided under a dual BSD/GPLv2 license. When using or +# redistributing this file, you may do so under either license. +# +# GPL LICENSE SUMMARY +# +# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +# The full GNU General Public License is included in this distribution +# in the file called LICENSE.GPL. +# +# Contact Information: +# Intel Corporation +# +# BSD LICENSE +# +# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# +############################################################################ + +# Ensure The ICP_ENV_DIR environmental var is defined. +ifndef ICP_ENV_DIR +$(error ICP_ENV_DIR is undefined. Please set the path to your environment makefile \ + "-> setenv ICP_ENV_DIR <path>") +endif + +# Ensure The ICP_BUILDSYSTEM_PATH envorionmental var is defined. +ifndef ICP_BUILDSYSTEM_PATH +$(error ICP_BUILDSYSTEM_PATH is undefined. Please set the path to the top of the build structure \ + "-> setenv ICP_BUILDSYSTEM_PATH <path>") +endif + +#Add your project environment Makefile, extra comment +include $(ICP_ENV_DIR)/environment.mk + +#include the makefile with all the default and common Make variable definitions +include $(ICP_BUILDSYSTEM_PATH)/build_files/common.mk + +#Add the name for the executable, Library or Module output definitions +OUTPUT_NAME=$(ICP_TDM_MSG_HDLR_NAME) + +# List of Source Files to be compiled (to be in a single line or on different lines separated by a "\" and tab. +SOURCES= IxPiuMh.c \ + IxPiuMhConfig.c \ + IxPiuMhSend.c \ + IxPiuMhSolicitedCbMgr.c \ + IxPiuMhReceive.c \ + IxPiuMhDll.c \ + IxPiuMhUnsolicitedCbMgr.c + + +# Setup include directory +INCLUDES += -I $(src)/include \ + -I $(PWD)/include \ + -I $(ICP_API_DIR) \ + -I $(ICP_API_DIR)/accel_infra \ + -I $(ICP_COMP_PATH)/include \ + -I $(ICP_OSAL_DIR)/common/include \ + +ifeq ($(ICP_INTEL_DEV),YES) +INCLUDES += -I $(ICP_OSAL_DIR)/common/include/modules \ + -I $(ICP_OSAL_DIR)/common/include/modules/ddk \ + -I $(ICP_OSAL_DIR)/common/include/modules/bufferMgt \ + -I $(ICP_OSAL_DIR)/common/include/modules/ioMem +endif + +EXTRA_CFLAGS += -DENABLE_IOMEM -DENABLE_BUFFERMGT + + +#include your $(ICP_OS)_$(ICP_OS_LEVEL).mk file +include $(ICP_TDM_MSG_HDLR_DIR)/$(ICP_OS)_$(ICP_OS_LEVEL).mk + +# Install the module to the output dir +install: module + + +###################Include rules and dependency makefiles######################## +include $(ICP_BUILDSYSTEM_PATH)/build_files/rules.mk +###################End of Rules and dependency inclusion######################### + diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhConfig_p.h b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhConfig_p.h new file mode 100644 index 0000000..e4b2482 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhConfig_p.h @@ -0,0 +1,686 @@ +/** + * @file IxPiuMhConfig_p.h + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @brief This file contains the private API for the Configuration module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/** + * @defgroup IxPiuMhConfig_p IxPiuMhConfig_p + * + * @brief The private API for the Configuration module. + * + * @{ + */ + +#ifndef IXPIUMHCONFIG_P_H +#define IXPIUMHCONFIG_P_H + +#include "IxOsal.h" + +#include "IxPiuMh.h" +#include "IxPiuMhMacros_p.h" + +/* + * inline definition + */ +/* enable function inlining for performances */ +#ifdef IXPIUMHSOLICITEDCBMGR_C +/* Non-inline functions will be defined in this translation unit. + Reason is that in GNU Compiler, if the Optimization is turn off, all extern inline + functions will not be compiled. +*/ +# ifndef __wince +# ifndef IXPIUMHCONFIG_INLINE +# define IXPIUMHCONFIG_INLINE +# endif +# else +# ifndef IXPIUMHCONFIG_INLINE +# define IXPIUMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN +# endif +# endif /* __wince*/ + +#else + +# ifndef IXPIUMHCONFIG_INLINE +# ifdef _DIAB_TOOL + /* DIAB does not allow both the funtion prototype and + * defintion to use extern + */ +# define IXPIUMHCONFIG_INLINE IX_OSAL_INLINE +# else +# define IXPIUMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN +# endif +# endif /* IXPIUMHCONFIG_INLINE */ +#endif /* IXPIUMHSOLICITEDCBMGR_C */ +/* + * Typedefs and #defines, etc. + */ + +typedef void (*IxPiuMhConfigIsr) (int); /**< ISR function pointer */ + +/** + * @struct IxPiuMhConfigPiuInfo + * + * @brief This structure is used to maintain the configuration information + * associated with an PIU. + */ + +typedef struct +{ + IxOsalMutex mutex; /**< mutex */ + UINT32 interruptId; /**< interrupt ID */ +#if defined(__ep805xx) + UINT32 physicalRegisterBase;/**< register physical base address */ +#endif + UINT32 virtualRegisterBase; /**< register virtual base address */ + UINT32 statusRegister; /**< status register virtual address */ + UINT32 controlRegister; /**< control register virtual address */ + UINT32 inFifoRegister; /**< inFIFO register virutal address */ + UINT32 outFifoRegister; /**< outFIFO register virtual address */ + IxPiuMhConfigIsr isr; /**< isr routine for handling interrupt */ + BOOL oldInterruptState; /**< old interrupt state (TRUE => enabled) */ +} IxPiuMhConfigPiuInfo; + + +/* + * #defines for function return types, etc. + */ + +#define IX_PIUMH_PIUSTAT_OFFSET (0x002C) /**< PIU status register offset */ +#define IX_PIUMH_PIUCTL_OFFSET (0x0030) /**< PIU control register offset */ +#define IX_PIUMH_PIUFIFO_OFFSET (0x0038) /**< PIU FIFO register offset */ + +/* PIU control register bit definitions */ +#define IX_PIUMH_PIU_CTL_OFE (1 << 16) /**< OutFifoEnable */ +#define IX_PIUMH_PIU_CTL_IFE (1 << 17) /**< InFifoEnable */ +#define IX_PIUMH_PIU_CTL_OFEWE (1 << 24) /**< OutFifoEnableWriteEnable */ +#define IX_PIUMH_PIU_CTL_IFEWE (1 << 25) /**< InFifoEnableWriteEnable */ + +/* PIU status register bit definitions */ +#define IX_PIUMH_PIU_STAT_OFNE (1 << 16) /**< OutFifoNotEmpty */ +#define IX_PIUMH_PIU_STAT_IFNF (1 << 17) /**< InFifoNotFull */ +#define IX_PIUMH_PIU_STAT_OFNF (1 << 18) /**< OutFifoNotFull */ +#define IX_PIUMH_PIU_STAT_IFNE (1 << 19) /**< InFifoNotEmpty */ +#define IX_PIUMH_PIU_STAT_MBINT (1 << 20) /**< Mailbox interrupt */ +#define IX_PIUMH_PIU_STAT_IFINT (1 << 21) /**< InFifo interrupt */ +#define IX_PIUMH_PIU_STAT_OFINT (1 << 22) /**< OutFifo interrupt */ +#define IX_PIUMH_PIU_STAT_WFINT (1 << 23) /**< WatchFifo interrupt */ + +/* message offsets */ +#define IX_PIUMH_MESSAGE_ID_OFFSET (24) + +/* Hardware defs for IXP23XX */ +#if defined(__ixp23xx) +#include <asm/hardware.h> +#include <asm/arch/irqs.h> + +/* PIU-0 interrupt */ +#define IX_PIU_IRQ_DBG0 (IRQ_IXP23XX_DBG0) + +/* PIU-1 interrupt */ +#define IX_PIU_IRQ_DBG1 (IRQ_IXP23XX_DBG1) + +/* PIU-0 Base Physical Address */ +#define IX_PIU_PIU0_PHYS (IXP23XX_PIU0_PHYS) + +/* PIU-1 Base Physical Address */ +#define IX_PIU_PIU1_PHYS (IXP23XX_PIU1_PHYS) + + +#endif /* #if DEVICE == ixp23xx */ + +#if defined(__ixp42X) || defined(__ixp46X) || defined(__ixp5XX) + +/**< PIU register base address */ +#define IX_PIUMH_PIU_BASE (IX_OSAL_IXP400_PERIPHERAL_PHYS_BASE) + +#define IX_PIUMH_PIUA_OFFSET (0x6000) /**< PIU-A register base offset */ +#define IX_PIUMH_PIUB_OFFSET (0x7000) /**< PIU-B register base offset */ +#if defined(__ixp42X) || defined(__ixp46X) && !defined(__ixp5XX) +#define IX_PIUMH_PIUC_OFFSET (0x8000) /**< PIU-C register base offset */ +#endif + +/** PIU-A register base address */ +#define IX_PIUMH_PIUA_BASE (IX_PIUMH_PIU_BASE + IX_PIUMH_PIUA_OFFSET) +/** PIU-B register base address */ +#define IX_PIUMH_PIUB_BASE (IX_PIUMH_PIU_BASE + IX_PIUMH_PIUB_OFFSET) +#if defined(__ixp42X) || defined(__ixp46X) && !defined(__ixp5XX) +/** PIU-C register base address */ +#define IX_PIUMH_PIUC_BASE (IX_PIUMH_PIU_BASE + IX_PIUMH_PIUC_OFFSET) +#endif + +/* PIU-A configuration */ + +/** PIU-A interrupt */ +#define IX_PIUMH_PIUA_INT (IX_OSAL_IXP400_PIUA_IRQ_LVL) +/** PIU-A FIFO register */ +#define IX_PIUMH_PIUA_FIFO (IX_PIUMH_PIUA_BASE + IX_PIUMH_PIUFIFO_OFFSET) +/** PIU-A control register */ +#define IX_PIUMH_PIUA_CTL (IX_PIUMH_PIUA_BASE + IX_PIUMH_PIUCTL_OFFSET) +/** PIU-A status register */ +#define IX_PIUMH_PIUA_STAT (IX_PIUMH_PIUA_BASE + IX_PIUMH_PIUSTAT_OFFSET) + +/* PIU-B configuration */ + +/** PIU-B interrupt */ +#define IX_PIUMH_PIUB_INT (IX_OSAL_IXP400_PIUB_IRQ_LVL) +/** PIU-B FIFO register */ +#define IX_PIUMH_PIUB_FIFO (IX_PIUMH_PIUB_BASE + IX_PIUMH_PIUFIFO_OFFSET) +/** PIU-B control register */ +#define IX_PIUMH_PIUB_CTL (IX_PIUMH_PIUB_BASE + IX_PIUMH_PIUCTL_OFFSET) +/** PIU-B status register */ +#define IX_PIUMH_PIUB_STAT (IX_PIUMH_PIUB_BASE + IX_PIUMH_PIUSTAT_OFFSET) + +#if defined(__ixp42X) || defined(__ixp46X) && !defined(__ixp5XX) +/* PIU-C configuration */ + +/** PIU-C interrupt */ +#define IX_PIUMH_PIUC_INT (IX_OSAL_IXP400_PIUC_IRQ_LVL) +/** PIU-C FIFO register */ +#define IX_PIUMH_PIUC_FIFO (IX_PIUMH_PIUC_BASE + IX_PIUMH_PIUFIFO_OFFSET) +/** PIU-C control register */ +#define IX_PIUMH_PIUC_CTL (IX_PIUMH_PIUC_BASE + IX_PIUMH_PIUCTL_OFFSET) +/** PIU-C status register */ +#define IX_PIUMH_PIUC_STAT (IX_PIUMH_PIUC_BASE + IX_PIUMH_PIUSTAT_OFFSET) +#endif + +#endif + +/* Hardware defs for tolapai */ +#if defined(__ep805xx) + +/* PIU-0 interrupt */ +#define IX_PIU_IRQ_DBG0 193 + +// TODO - below is physical address for PIU on FPGA +// now being set by the setup driver +#define IX_PIU_PIU0_PHYS 0 + +/* size of mapped memory block used by PIU */ +#define IX_PIU_MAPPED_MEMORY_SIZE 0x1000 + + + +#endif /* #if defined(__ep805xx) */ + + +/** + * Variable declarations. Externs are followed by static variables. + */ +extern IxPiuMhConfigPiuInfo ixPiuMhConfigPiuInfo[IX_PIUMH_NUM_PIUS]; + + +/* + * Prototypes for interface functions. + */ + +#if defined(__ep805xx) +/** + * @fn void ixPiuMhConfigPhysicalAddressSet( + * IxPiuMhPiuId piuId, + * UINT32 address) + * + * @brief This function sets the physical base address for the given piu + * + * @param IxPiuMhPiuId piuId (in) - the ID of the PIU whose physical base + * address will be set + * @param UINT32 address (in) - the address to set the physical address to + * + * @return No return value. + */ +void ixPiuMhConfigPhysicalAddressSet( + IxPiuMhPiuId piuId, + UINT32 address); + +/** + * @fn void ixPiuMhConfigInterruptIdSet( + * IxPiuMhPiuId piuId, + * UINT32 interruptId) + * + * @brief This function sets the interruptId for the given piu + * + * @param IxPiuMhPiuId piuId (in) - the ID of the PIU whose physical base + * address will be set + * @param UINT32 interruptId (in) - the interruptId + * + * @return No return value. + */ +void ixPiuMhConfigInterruptIdSet( + IxPiuMhPiuId piuId, + UINT32 interruptId); + +#endif // #if defined(__ep805xx) + +/** + * @fn void ixPiuMhConfigInitialize ( + IxPiuMhPiuInterrupts piuInterrupts) + * + * @brief This function initialises the Configuration module. + * + * @param IxPiuMhPiuInterrupts piuInterrupts (in) - whether or not to + * service the PIU "outFIFO not empty" interrupts. + * + * @return No return value. + */ + +void ixPiuMhConfigInitialize ( + IxPiuMhPiuInterrupts piuInterrupts); + +/** + * @fn void ixPiuMhConfigUninit (void) + * + * @brief This function uninitialises the Configuration module. + * + * @return No return value. + */ + +void ixPiuMhConfigUninit (void); + +/** + * @fn void ixPiuMhConfigIsrRegister ( + IxPiuMhPiuId piuId, + IxPiuMhConfigIsr isr) + * + * @brief This function registers an ISR to handle PIU "outFIFO not + * empty" interrupts. + * + * @param IxPiuMhPiuId piuId (in) - the ID of the PIU whose interrupt will + * be handled. + * @param IxPiuMhConfigIsr isr (in) - the ISR function pointer that the + * interrupt will trigger. + * + * @return No return value. + */ + +void ixPiuMhConfigIsrRegister ( + IxPiuMhPiuId piuId, + IxPiuMhConfigIsr isr); + +/** + * @fn void ixPiuMhConfigIsrUnregister (IxPiuMhPiuId piuId) + * + * @brief This function unregisters the ISR. + * + * @param IxPiuMhPiuId piuId (in) - the ID of the PIU whose interrupt will + * be unregistered. + * + * @return No return value. + */ +void ixPiuMhConfigIsrUnregister (IxPiuMhPiuId piuId); + +/** + * @fn BOOL ixPiuMhConfigPiuInterruptEnable ( + IxPiuMhPiuId piuId) + * + * @brief This function enables a PIU's "outFIFO not empty" interrupt. + * + * @param IxPiuMhPiuId piuId (in) - the ID of the PIU whose interrupt will + * be enabled. + * + * @return Returns the previous state of the interrupt (TRUE => enabled). + */ + +BOOL ixPiuMhConfigPiuInterruptEnable ( + IxPiuMhPiuId piuId); + +/** + * @fn BOOL ixPiuMhConfigPiuInterruptDisable ( + IxPiuMhPiuId piuId) + * + * @brief This function disables a PIU's "outFIFO not empty" interrupt + * + * @param IxPiuMhPiuId piuId (in) - the ID of the PIU whose interrupt will + * be disabled. + * + * @return Returns the previous state of the interrupt (TRUE => enabled). + */ + +BOOL ixPiuMhConfigPiuInterruptDisable ( + IxPiuMhPiuId piuId); + +/** + * @fn IxPiuMhMessageId ixPiuMhConfigMessageIdGet ( + IxPiuMhMessage message) + * + * @brief This function gets the ID of a message. + * + * @param IxPiuMhMessage message (in) - the message to get the ID of. + * + * @return the ID of the message + */ + +IxPiuMhMessageId ixPiuMhConfigMessageIdGet ( + IxPiuMhMessage message); + +/** + * @fn BOOL ixPiuMhConfigPiuIdIsValid ( + IxPiuMhPiuId piuId) + * + * @brief This function checks to see if a PIU ID is valid. + * + * @param IxPiuMhPiuId piuId (in) - the PIU ID to validate. + * + * @return True if the PIU ID is valid, otherwise False. + */ + +BOOL ixPiuMhConfigPiuIdIsValid ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhConfigLockGet ( + IxPiuMhPiuId piuId) + * + * @brief This function gets a lock for exclusive PIU interaction, and + * disables the PIU's "outFIFO not empty" interrupt. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which to get the + * lock and disable its interrupt. + * + * @return No return value. + */ + +void ixPiuMhConfigLockGet ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhConfigLockRelease ( + IxPiuMhPiuId piuId) + * + * @brief This function releases a lock for exclusive PIU interaction, and + * enables the PIU's "outFIFO not empty" interrupt. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which to release + * the lock and enable its interrupt. + * + * @return No return value. + */ + +void ixPiuMhConfigLockRelease ( + IxPiuMhPiuId piuId); + +/** + * @fn BOOL ixPiuMhConfigInFifoIsEmpty ( + IxPiuMhPiuId piuId) + * + * @brief This inline function checks if a PIU's inFIFO is empty. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which the inFIFO + * will be checked. + * + * @return True if the inFIFO is empty, otherwise False. + */ + +IXPIUMHCONFIG_INLINE BOOL ixPiuMhConfigInFifoIsEmpty ( + IxPiuMhPiuId piuId); + +/** + * @fn BOOL ixPiuMhConfigInFifoIsFull ( + IxPiuMhPiuId piuId) + * + * @brief This inline function checks if a PIU's inFIFO is full. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which the inFIFO + * will be checked. + * + * @return True if the inFIFO is full, otherwise False. + */ + +IXPIUMHCONFIG_INLINE BOOL ixPiuMhConfigInFifoIsFull ( + IxPiuMhPiuId piuId); + +/** + * @fn BOOL ixPiuMhConfigOutFifoIsEmpty ( + IxPiuMhPiuId piuId) + * + * @brief This inline function checks if a PIU's outFIFO is empty. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which the outFIFO + * will be checked. + * + * @return True if the outFIFO is empty, otherwise False. + */ + +IXPIUMHCONFIG_INLINE BOOL ixPiuMhConfigOutFifoIsEmpty ( + IxPiuMhPiuId piuId); + +/** + * @fn BOOL ixPiuMhConfigOutFifoIsFull ( + IxPiuMhPiuId piuId) + * + * @brief This inline function checks if a PIU's outFIFO is full. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which the outFIFO + * will be checked. + * + * @return True if the outFIFO is full, otherwise False. + */ + +IXPIUMHCONFIG_INLINE BOOL ixPiuMhConfigOutFifoIsFull ( + IxPiuMhPiuId piuId); + +/** + * @fn IX_STATUS ixPiuMhConfigInFifoWrite ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message) + * + * @brief This function writes a message to a PIU's inFIFO. The caller + * must first check that the PIU's inFifo is not full. After writing the first + * word of the message, this function will keep polling PIU's inFIFO is not + * full to write the second word. If inFIFO is not available after maximum + * retries (IX_PIU_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT + * status to indicate PIU hang / halt. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which the inFIFO + * will be written to. + * @param IxPiuMhMessage message (in) - The message to write. + * + * @return The function returns a status indicating success, failure or timeout. + */ + +IX_STATUS ixPiuMhConfigInFifoWrite ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message); + +/** + * @fn IX_STATUS ixPiuMhConfigOutFifoRead ( + IxPiuMhPiuId piuId, + IxPiuMhMessage *message) + * + * @brief This function reads a message from a PIU's outFIFO. The caller + * must first check that the PIU's outFifo is not empty. After reading the first + * word of the message, this function will keep polling PIU's outFIFO is not + * empty to read the second word. If outFIFO is empty after maximum + * retries (IX_PIU_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT + * status to indicate PIU hang / halt. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU for which the outFIFO + * will be read from. + * @param IxPiuMhMessage message (out) - The message read. + * + * @return The function returns a status indicating success, failure or timeout. + */ + +IX_STATUS ixPiuMhConfigOutFifoRead ( + IxPiuMhPiuId piuId, + IxPiuMhMessage *message); + +/** + * @fn void ixPiuMhConfigShow ( + IxPiuMhPiuId piuId) + * + * @brief This function will display the current state of the Configuration + * module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to display state + * information for. + * + * @return No return value. + */ + +void ixPiuMhConfigShow ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhConfigShowReset ( + IxPiuMhPiuId piuId) + * + * @brief This function will reset the current state of the Configuration + * module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to reset state + * information for. + * + * @return No return value. + */ + +void ixPiuMhConfigShowReset ( + IxPiuMhPiuId piuId); + +/* + * Inline functions + */ + +/* + * This inline function checks if a PIU's inFIFO is empty. + */ + +IXPIUMHCONFIG_INLINE +BOOL ixPiuMhConfigInFifoIsEmpty ( + IxPiuMhPiuId piuId) +{ + UINT32 ifne; + volatile UINT32 *statusReg = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].statusRegister; + + /* get the IFNE (InFifoNotEmpty) bit of the status register */ + IX_PIUMH_REGISTER_READ_BITS (statusReg, &ifne, IX_PIUMH_PIU_STAT_IFNE); + + /* if the IFNE status bit is unset then the inFIFO is empty */ + return (ifne == 0); +} + + +/* + * This inline function checks if a PIU's inFIFO is full. + */ +IXPIUMHCONFIG_INLINE +BOOL ixPiuMhConfigInFifoIsFull ( + IxPiuMhPiuId piuId) +{ + UINT32 ifnf; + volatile UINT32 *statusReg = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].statusRegister; + + /* get the IFNF (InFifoNotFull) bit of the status register */ + IX_PIUMH_REGISTER_READ_BITS (statusReg, &ifnf, IX_PIUMH_PIU_STAT_IFNF); + + /* if the IFNF status bit is unset then the inFIFO is full */ + return (ifnf == 0); +} + + +/* + * This inline function checks if a PIU's outFIFO is empty. + */ +IXPIUMHCONFIG_INLINE +BOOL ixPiuMhConfigOutFifoIsEmpty ( + IxPiuMhPiuId piuId) +{ + UINT32 ofne; + volatile UINT32 *statusReg = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].statusRegister; + + /* get the OFNE (OutFifoNotEmpty) bit of the status register */ + IX_PIUMH_REGISTER_READ_BITS (statusReg, &ofne, IX_PIUMH_PIU_STAT_OFNE); + + /* if the OFNE status bit is unset then the outFIFO is empty */ + return (ofne == 0); +} + +/* + * This inline function checks if a PIU's outFIFO is full. + */ +IXPIUMHCONFIG_INLINE +BOOL ixPiuMhConfigOutFifoIsFull ( + IxPiuMhPiuId piuId) +{ + UINT32 ofnf; + volatile UINT32 *statusReg = + (UINT32 *)ixPiuMhConfigPiuInfo[piuId].statusRegister; + + /* get the OFNF (OutFifoNotFull) bit of the status register */ + IX_PIUMH_REGISTER_READ_BITS (statusReg, &ofnf, IX_PIUMH_PIU_STAT_OFNF); + + /* if the OFNF status bit is unset then the outFIFO is full */ + return (ofnf == 0); +} + +#endif /* IXPIUMHCONFIG_P_H */ + +/** + * @} defgroup IxPiuMhConfig_p + */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhMacros_p.h b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhMacros_p.h new file mode 100644 index 0000000..e2aea6a --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhMacros_p.h @@ -0,0 +1,319 @@ +/** + * @file IxPiuMhMacros_p.h + * + * @author Intel Corporation + * @date 21 Jan 2002 + * + * @brief This file contains the macros for the IxPiuMh component. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/** + * @defgroup IxPiuMhMacros_p IxPiuMhMacros_p + * + * @brief Macros for the IxPiuMh component. + * + * @{ + */ + +#ifndef IXPIUMHMACROS_P_H +#define IXPIUMHMACROS_P_H + +/* if we are running as a unit test */ +#ifdef IX_UNIT_TEST +#undef NDEBUG +#endif /* #ifdef IX_UNIT_TEST */ + +#include "IxOsal.h" + +/* + * #defines for function return types, etc. + */ + +#define IX_PIUMH_SHOW_TEXT_WIDTH (40) /**< text width for stats display */ +#define IX_PIUMH_SHOW_STAT_WIDTH (10) /**< stat width for stats display */ + +/** + * @def IX_PIUMH_SHOW + * + * @brief Macro for displaying a stat preceded by a textual description. + */ + +#define IX_PIUMH_SHOW(TEXT, STAT) \ + ixOsalLog (IX_OSAL_LOG_LVL_USER, IX_OSAL_LOG_DEV_STDOUT, \ + "%-40s: %10d\n", (int) TEXT, (int) STAT, 0, 0, 0, 0) + +/* + * Prototypes for interface functions. + */ + +/** + * @typedef IxPiuMhTraceTypes + * + * @brief Enumeration defining IxPiuMh trace levels + */ + +typedef enum +{ + IX_PIUMH_TRACE_OFF = IX_OSAL_LOG_LVL_NONE, /**< no trace */ + IX_PIUMH_WARNING = IX_OSAL_LOG_LVL_WARNING, /**< warning */ + IX_PIUMH_DEBUG = IX_OSAL_LOG_LVL_MESSAGE, /**< debug */ + IX_PIUMH_FN_ENTRY_EXIT = IX_OSAL_LOG_LVL_DEBUG3 /**< function entry/exit */ +} IxPiuMhTraceTypes; + +#ifdef IX_UNIT_TEST +#define IX_PIUMH_TRACE_LEVEL (IX_PIUMH_FN_ENTRY_EXIT) /**< trace level */ +#endif +#ifndef IX_UNIT_TEST +#define IX_PIUMH_TRACE_LEVEL (IX_PIUMH_TRACE_OFF) /**< trace level */ +#endif + +/** + * @def IX_PIUMH_TRACE0 + * + * @brief Trace macro taking 0 arguments. + */ + +#define IX_PIUMH_TRACE0(LEVEL, STR) \ + IX_PIUMH_TRACE6(LEVEL, STR, 0, 0, 0, 0, 0, 0) + +/** + * @def IX_PIUMH_TRACE1 + * + * @brief Trace macro taking 1 argument. + */ + +#define IX_PIUMH_TRACE1(LEVEL, STR, ARG1) \ + IX_PIUMH_TRACE6(LEVEL, STR, ARG1, 0, 0, 0, 0, 0) + +/** + * @def IX_PIUMH_TRACE2 + * + * @brief Trace macro taking 2 arguments. + */ + +#define IX_PIUMH_TRACE2(LEVEL, STR, ARG1, ARG2) \ + IX_PIUMH_TRACE6(LEVEL, STR, ARG1, ARG2, 0, 0, 0, 0) + +/** + * @def IX_PIUMH_TRACE3 + * + * @brief Trace macro taking 3 arguments. + */ + +#define IX_PIUMH_TRACE3(LEVEL, STR, ARG1, ARG2, ARG3) \ + IX_PIUMH_TRACE6(LEVEL, STR, ARG1, ARG2, ARG3, 0, 0, 0) + +/** + * @def IX_PIUMH_TRACE4 + * + * @brief Trace macro taking 4 arguments. + */ + +#define IX_PIUMH_TRACE4(LEVEL, STR, ARG1, ARG2, ARG3, ARG4) \ + IX_PIUMH_TRACE6(LEVEL, STR, ARG1, ARG2, ARG3, ARG4, 0, 0) + +/** + * @def IX_PIUMH_TRACE5 + * + * @brief Trace macro taking 5 arguments. + */ + +#define IX_PIUMH_TRACE5(LEVEL, STR, ARG1, ARG2, ARG3, ARG4, ARG5) \ + IX_PIUMH_TRACE6(LEVEL, STR, ARG1, ARG2, ARG3, ARG4, ARG5, 0) + +/** + * @def IX_PIUMH_TRACE6 + * + * @brief Trace macro taking 6 arguments. + */ + +#define IX_PIUMH_TRACE6(LEVEL, STR, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ +{ \ + if (LEVEL <= IX_PIUMH_TRACE_LEVEL) \ + { \ + (void) ixOsalLog (LEVEL, IX_OSAL_LOG_DEV_STDOUT, (STR), \ + (int)(ARG1), (int)(ARG2), (int)(ARG3), \ + (int)(ARG4), (int)(ARG5), (int)(ARG6)); \ + } \ +} + +/** + * @def IX_PIUMH_ERROR_REPORT + * + * @brief Error reporting facility. + */ + +#define IX_PIUMH_ERROR_REPORT(STR) \ +{ \ + (void) ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, \ + (STR), 0, 0, 0, 0, 0, 0); \ +} + +/* if we are running on XScale, i.e. real environment */ +#if (defined(__ep805xx) || CPU==XSCALE) && !defined(IX_UNIT_TEST) + +/** + * @def IX_PIUMH_REGISTER_READ + * + * @brief This macro reads a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_READ(registerAddress, value) \ +{ \ + *value = IX_OSAL_READ_LONG(registerAddress); \ +} + +/** + * @def IX_PIUMH_REGISTER_READ_BITS + * + * @brief This macro partially reads a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_READ_BITS(registerAddress, value, mask) \ +{ \ + *value = (IX_OSAL_READ_LONG(registerAddress) & mask); \ +} + +/** + * @def IX_PIUMH_REGISTER_WRITE + * + * @brief This macro writes a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_WRITE(registerAddress, value) \ +{ \ + IX_OSAL_WRITE_LONG(registerAddress, value); \ +} + +/** + * @def IX_PIUMH_REGISTER_WRITE_BITS + * + * @brief This macro partially writes a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_WRITE_BITS(registerAddress, value, mask) \ +{ \ + UINT32 orig = IX_OSAL_READ_LONG(registerAddress); \ + orig &= (~mask); \ + orig |= (value & mask); \ + IX_OSAL_WRITE_LONG(registerAddress, orig); \ +} + + +/* if we are running as a unit test */ +#else /* #if CPU==XSCALE */ + +#include "IxPiuMhTestRegister.h" + +/** + * @def IX_PIUMH_REGISTER_READ + * + * @brief This macro reads a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_READ(registerAddress, value) \ +{ \ + ixPiuMhTestRegisterRead (registerAddress, value); \ +} + +/** + * @def IX_PIUMH_REGISTER_READ_BITS + * + * @brief This macro partially reads a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_READ_BITS(registerAddress, value, mask) \ +{ \ + ixPiuMhTestRegisterReadBits (registerAddress, value, mask); \ +} + +/** + * @def IX_PIUMH_REGISTER_WRITE + * + * @brief This macro writes a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_WRITE(registerAddress, value) \ +{ \ + ixPiuMhTestRegisterWrite (registerAddress, value); \ +} + +/** + * @def IX_PIUMH_REGISTER_WRITE_BITS + * + * @brief This macro partially writes a memory-mapped register. + */ + +#define IX_PIUMH_REGISTER_WRITE_BITS(registerAddress, value, mask) \ +{ \ + ixPiuMhTestRegisterWriteBits (registerAddress, value, mask); \ +} + +#endif /* #if CPU==XSCALE */ + +#endif /* IXPIUMHMACROS_P_H */ + +/** + * @} defgroup IxPiuMhMacros_p + */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhReceive_p.h b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhReceive_p.h new file mode 100644 index 0000000..9ee3709 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhReceive_p.h @@ -0,0 +1,173 @@ +/** + * @file IxPiuMhReceive_p.h + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @brief This file contains the private API for the Receive module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/** + * @defgroup IxPiuMhReceive_p IxPiuMhReceive_p + * + * @brief The private API for the Receive module. + * + * @{ + */ + +#ifndef IXPIUMHRECEIVE_P_H +#define IXPIUMHRECEIVE_P_H + +#include "IxPiuMh.h" +#include "IxOsalTypes.h" + +/* + * #defines for function return types, etc. + */ + +/* + * Prototypes for interface functions. + */ + +/** + * @fn void ixPiuMhReceiveInitialize (void) + * + * @brief This function registers an internal ISR to handle the PIUs' + * "outFIFO not empty" interrupts and receive messages from the PIUs when + * they become available. + * + * @return No return value. + */ + +void ixPiuMhReceiveInitialize (void); + +/** + * @fn void ixPiuMhReceiveUninitialize (void) + * + * @brief This function unregisters the internal ISR to handle the PIUs' + * "outFIFO not empty" interrupt. + * + * @return No return value. + */ + +void ixPiuMhReceiveUninitialize (void); + + +/** + * @fn void ixPiuMhReceiveMessagesReceive ( + IxPiuMhPiuId piuId) + * + * @brief This function reads messages from a particular PIU's outFIFO + * until the outFIFO is empty, and for each message looks first for an + * unsolicited callback, then a solicited callback, to pass the message + * back to the client. If no callback can be found the message is + * discarded and an error reported. This function will return TIMEOUT + * status if PIU hang / halt. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to receive + * messages from. + * + * @return The function returns a status indicating success, failure or timeout. + */ + +IX_STATUS ixPiuMhReceiveMessagesReceive ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhReceiveShow ( + IxPiuMhPiuId piuId) + * + * @brief This function will display the current state of the Receive + * module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to display state + * information for. + * + * @return No return status. + */ + +void ixPiuMhReceiveShow ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhReceiveShowReset ( + IxPiuMhPiuId piuId) + * + * @brief This function will reset the current state of the Receive + * module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to reset state + * information for. + * + * @return No return status. + */ + +void ixPiuMhReceiveShowReset ( + IxPiuMhPiuId piuId); + +#endif /* IXPIUMHRECEIVE_P_H */ + +/** + * @} defgroup IxPiuMhReceive_p + */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhSend_p.h b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhSend_p.h new file mode 100644 index 0000000..d6a0352 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhSend_p.h @@ -0,0 +1,185 @@ +/** + * @file IxPiuMhSend_p.h + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @brief This file contains the private API for the Send module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/** + * @defgroup IxPiuMhSend_p IxPiuMhSend_p + * + * @brief The private API for the Send module. + * + * @{ + */ + +#ifndef IXPIUMHSEND_P_H +#define IXPIUMHSEND_P_H + +#include "IxPiuMh.h" +#include "IxOsalTypes.h" + +/* + * #defines for function return types, etc. + */ + +/* + * Prototypes for interface functions. + */ + +/** + * @fn IX_STATUS ixPiuMhSendMessageSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + UINT32 maxSendRetries) + * + * @brief This function writes a message to the specified PIU's inFIFO, + * and must be used when the message being sent does not solicit a response + * from the PIU. This function will return TIMEOUT status if PIU hang / halt. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to send the message + * to. + * @param IxPiuMhMessage message (in) - The message to send. + * @param UINT32 maxSendRetries (in) - Max num. of retries to perform + * if the PIU's inFIFO is full. + * + * @return The function returns a status indicating success, failure or timeout. + */ + +IX_STATUS ixPiuMhSendMessageSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + UINT32 maxSendRetries); + +/** + * @fn IX_STATUS ixPiuMhSendMessageWithResponseSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback solicitedCallback, + UINT32 maxSendRetries) + * + * @brief This function writes a message to the specified PIU's inFIFO, + * and must be used when the message being sent solicits a response from + * the PIU. The ID of the solicited response must be specified so that it + * can be recognised, and a callback provided to pass the response back to + * the client. This function will return TIMEOUT status if PIU hang / halt. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to send the message + * to. + * @param IxPiuMhMessage message (in) - The message to send. + * @param IxPiuMhMessageId solicitedMessageId (in) - The ID of the + * solicited response. + * @param IxPiuMhCallback solicitedCallback (in) - The callback to pass the + * solicited response back to the client. + * @param UINT32 maxSendRetries (in) - Max num. of retries to perform + * if the PIU's inFIFO is full. + * + * @return The function returns a status indicating success, failure or timeout. + */ + +IX_STATUS ixPiuMhSendMessageWithResponseSend ( + IxPiuMhPiuId piuId, + IxPiuMhMessage message, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback solicitedCallback, + UINT32 maxSendRetries); + +/** + * @fn void ixPiuMhSendShow ( + IxPiuMhPiuId piuId) + * + * @brief This function will display the current state of the Send module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to display state + * information for. + * + * @return No return value. + */ + +void ixPiuMhSendShow ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhSendShowReset ( + IxPiuMhPiuId piuId) + * + * @brief This function will reset the current state of the Send module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to reset state + * information for. + * + * @return No return value. + */ + +void ixPiuMhSendShowReset ( + IxPiuMhPiuId piuId); + +#endif /* IXPIUMHSEND_P_H */ + +/** + * @} defgroup IxPiuMhSend_p + */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhSolicitedCbMgr_p.h b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhSolicitedCbMgr_p.h new file mode 100644 index 0000000..8f7ec58 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhSolicitedCbMgr_p.h @@ -0,0 +1,203 @@ +/** + * @file IxPiuMhSolicitedCbMgr_p.h + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @brief This file contains the private API for the Solicited Callback + * Manager module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ + +/** + * @defgroup IxPiuMhSolicitedCbMgr_p IxPiuMhSolicitedCbMgr_p + * + * @brief The private API for the Solicited Callback Manager module. + * + * @{ + */ + +#ifndef IXPIUMHSOLICITEDCBMGR_P_H +#define IXPIUMHSOLICITEDCBMGR_P_H + +#include "IxPiuMh.h" +#include "IxOsalTypes.h" + +/* + * #defines for function return types, etc. + */ + +/** Maximum number of solicited callbacks that can be stored in the list */ +#define IX_PIUMH_MAX_CALLBACKS (16) + +/* + * Prototypes for interface functions. + */ + +/** + * @fn void ixPiuMhSolicitedCbMgrInitialize (void) + * + * @brief This function initializes the Solicited Callback Manager module, + * setting up a callback data structure for each PIU. + * + * @return No return value. + */ + +void ixPiuMhSolicitedCbMgrInitialize (void); + +/** + * @fn void ixPiuMhSolicitedCbMgrUninitialize (void) + * + * @brief This function uninitializes the Solicited Callback Manager module. + * + * @return No return value. + */ + +void ixPiuMhSolicitedCbMgrUninitialize (void); + +/** + * @fn IX_STATUS ixPiuMhSolicitedCbMgrCallbackSave ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback solicitedCallback) + * + * @brief This function saves a callback in the specified PIU's callback + * list. If the callback list is full the function will fail. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU in whose callback + * list the callback will be saved. + * @param IxPiuMhMessageId solicitedMessageId (in) - The ID of the message + * that this callback is for. + * @param IxPiuMhCallback solicitedCallback (in) - The callback function + * pointer to save. + * + * @return The function returns a status indicating success or failure. + */ + +IX_STATUS ixPiuMhSolicitedCbMgrCallbackSave ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback solicitedCallback); + +/** + * @fn void ixPiuMhSolicitedCbMgrCallbackRetrieve ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback *solicitedCallback) + * + * @brief This function retrieves the first ID-matching callback from the + * specified PIU's callback list. If no matching callback can be found the + * function will fail. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU from whose callback + * list the callback will be retrieved. + * @param IxPiuMhMessageId solicitedMessageId (in) - The ID of the message + * that the callback is for. + * @param IxPiuMhCallback solicitedCallback (out) - The callback function + * pointer retrieved. + * + * @return No return value. + */ + +void ixPiuMhSolicitedCbMgrCallbackRetrieve ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId solicitedMessageId, + IxPiuMhCallback *solicitedCallback); + +/** + * @fn void ixPiuMhSolicitedCbMgrShow ( + IxPiuMhPiuId piuId) + * + * @brief This function will display the current state of the Solicited + * Callback Manager module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to display state + * information for. + * + * @return No return value. + */ + +void ixPiuMhSolicitedCbMgrShow ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhSolicitedCbMgrShowReset ( + IxPiuMhPiuId piuId) + * + * @brief This function will reset the current state of the Solicited + * Callback Manager module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to reset state + * information for. + * + * @return No return value. + */ + +void ixPiuMhSolicitedCbMgrShowReset ( + IxPiuMhPiuId piuId); + +#endif /* IXPIUMHSOLICITEDCBMGR_P_H */ + +/** + * @} defgroup IxPiuMhSolicitedCbMgr_p + */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhUnsolicitedCbMgr_p.h b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhUnsolicitedCbMgr_p.h new file mode 100644 index 0000000..5e4e187 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/include/IxPiuMhUnsolicitedCbMgr_p.h @@ -0,0 +1,202 @@ +/** + * @file IxPiuMhUnsolicitedCbMgr_p.h + * + * @author Intel Corporation + * @date 18 Jan 2002 + * + * @brief This file contains the private API for the Unsolicited Callback + * Manager module. + * + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * + */ + +/** + * @defgroup IxPiuMhUnsolicitedCbMgr_p IxPiuMhUnsolicitedCbMgr_p + * + * @brief The private API for the Unsolicited Callback Manager module. + * + * @{ + */ + +#ifndef IXPIUMHUNSOLICITEDCBMGR_P_H +#define IXPIUMHUNSOLICITEDCBMGR_P_H + +#include "IxPiuMh.h" +#include "IxOsalTypes.h" + +/* + * #defines for function return types, etc. + */ + +/* + * Prototypes for interface functions. + */ + +/** + * @fn void ixPiuMhUnsolicitedCbMgrInitialize (void) + * + * @brief This function initializes the Unsolicited Callback Manager + * module, setting up a callback data structure for each PIU. + * + * @return No return value. + */ + +void ixPiuMhUnsolicitedCbMgrInitialize (void); + +/** + * @fn void ixPiuMhUnsolicitedCbMgrUninitialize (void) + * + * @brief This function uninitializes the Unsolicited Callback Manager + * module. + * + * @return No return value. + */ + +void ixPiuMhUnsolicitedCbMgrUninitialize (void); + +/** + * @fn void ixPiuMhUnsolicitedCbMgrCallbackSave ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId unsolicitedMessageId, + IxPiuMhCallback unsolicitedCallback) + * + * @brief This function saves a callback in the specified PIU's callback + * table. If a callback already exists for the specified ID then it will + * be overwritten. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU in whose callback + * table the callback will be saved. + * @param IxPiuMhMessageId unsolicitedMessageId (in) - The ID of the + * messages that this callback is for. + * @param IxPiuMhCallback unsolicitedCallback (in) - The callback function + * pointer to save. + * + * @return No return value. + */ + +void ixPiuMhUnsolicitedCbMgrCallbackSave ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId unsolicitedMessageId, + IxPiuMhCallback unsolicitedCallback); + +/** + * @fn void ixPiuMhUnsolicitedCbMgrCallbackRetrieve ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId unsolicitedMessageId, + IxPiuMhCallback *unsolicitedCallback) + * + * @brief This function retrieves the callback for the specified ID from + * the specified PIU's callback table. If no callback is registered for + * the specified ID and PIU then a callback value of NULL will be returned. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU from whose callback + * table the callback will be retrieved. + * @param IxPiuMhMessageId unsolicitedMessageId (in) - The ID of the + * messages that the callback is for. + * @param IxPiuMhCallback unsolicitedCallback (out) - The callback function + * pointer retrieved. + * + * @return No return value. + */ + +void ixPiuMhUnsolicitedCbMgrCallbackRetrieve ( + IxPiuMhPiuId piuId, + IxPiuMhMessageId unsolicitedMessageId, + IxPiuMhCallback *unsolicitedCallback); + +/** + * @fn void ixPiuMhUnsolicitedCbMgrShow ( + IxPiuMhPiuId piuId) + * + * @brief This function will display the current state of the Unsolicited + * Callback Manager module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to display state + * information for. + * + * @return No return value. + */ + +void ixPiuMhUnsolicitedCbMgrShow ( + IxPiuMhPiuId piuId); + +/** + * @fn void ixPiuMhUnsolicitedCbMgrShowReset ( + IxPiuMhPiuId piuId) + * + * @brief This function will reset the current state of the Unsolicited + * Callback Manager module. + * + * @param IxPiuMhPiuId piuId (in) - The ID of the PIU to reset state + * information for. + * + * @return No return value. + */ + +void ixPiuMhUnsolicitedCbMgrShowReset ( + IxPiuMhPiuId piuId); + +#endif /* IXPIUMHUNSOLICITEDCBMGR_P_H */ + +/** + * @} defgroup IxPiuMhUnsolicitedCbMgr_p + */ diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/linux_2.6_kernel_space.mk b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/linux_2.6_kernel_space.mk new file mode 100644 index 0000000..c59e1bd --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/linux_2.6_kernel_space.mk @@ -0,0 +1,80 @@ +################### +# @par +# This file is provided under a dual BSD/GPLv2 license. When using or +# redistributing this file, you may do so under either license. +# +# GPL LICENSE SUMMARY +# +# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. +# The full GNU General Public License is included in this distribution +# in the file called LICENSE.GPL. +# +# Contact Information: +# Intel Corporation +# +# BSD LICENSE +# +# Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +# +################### + +#specific include directories in kernel space +INCLUDES+= -I $(ICP_OSAL_DIR)/platforms/EP805XX/include \ + -I $(ICP_OSAL_DIR)/platforms/EP805XX/os/linux/include \ + -I $(ICP_OSAL_DIR)/common/os/linux/include/core \ + -I $(ICP_OSAL_DIR)/common/os/linux/include/modules \ + -I $(ICP_OSAL_DIR)/common/os/linux/include/modules/ddk \ + -I $(ICP_OSAL_DIR)/common/os/linux/include/modules/ioMem \ + -I $(ICP_OSAL_DIR)/common/os/linux/include/modules/bufferMgt + + +SOURCES+= $(ICP_DEVICE)$(ICP_SLASH)linux_kernel_module.c + + +#Extra Flags Specific in kernel space e.g. include path or debug flags etc. e.g to add an include path EXTRA_CFLAGS += -I$(src)/../include +EXTRA_CFLAGS += $(INCLUDES) -DTOLAPAI -D__tolapai -DEP805XX -D__ep805xx -DIX_HW_COHERENT_MEMORY=1 +EXTRA_LDFLAGS+=-whole-archive + + diff --git a/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/linux_kernel_module.c b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/linux_kernel_module.c new file mode 100644 index 0000000..3f05ff0 --- /dev/null +++ b/Acceleration/library/icp_telephony/tdm_infrastructure_message_handler/linux_kernel_module.c @@ -0,0 +1,85 @@ +/** + * @file linux_kernel_module.c + * + * @author Intel Corporation + * + * @description Contents are the kernel module file. + * + * @par + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Corporation + * + * BSD LICENSE + * + * Copyright(c) 2007,2008,2009 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * +*/ +#include <linux/module.h> + + +MODULE_DESCRIPTION("TDM Infrastructure Driver"); +MODULE_VERSION("1.0"); +MODULE_AUTHOR("Intel Corporation"); +MODULE_LICENSE("Dual BSD/GPL"); + +int init_module(void) +{ + return 0; +} + +void cleanup_module(void) +{ + +} + |