📄 txc_os_queue.c
字号:
/*--------------------------------------------------------------------------
******* ****
* ***** ** * * * * * * ***** **** * *
* * * * * ** * * * * * * * * * *
* * * * * * * * **** * * * * * ******
* ***** ****** * * * * * ** * * * * * *
* * * * * * ** * * ** ** * * * * * *
* * * * * * * **** * * * * **** * *
Proprietary and Confidential
This program is made available only to customers and prospective customers
of TranSwitch Corporation under license and may be used only with TranSwitch
semi-conductor products.
Copyright(c) 2004 TranSwitch Inc.
|-----------------------------------------------------------------------|
| |
| ******** ****** |
| ** ** ** ** |
| ** ** ** * |
| ** ** ** |
| ** ** ** |
| ** ** ** |
| ** ** * *** |
| ** ** ** ** |
| ******** ****** |
| |
|-----------------------------------------------------------------------|
| Queue Source File |
|-----------------------------------------------------------------------|
| |
| Workfile: txc_os_queue.c |
| |
| Description: this file contains all code for queue management |
| |
-------------------------------------------------------------------------
Revision History
-------------------------------------------------------------------------
Rev # Date Author Description
----- ------ ------- -----------
1.0 13-Mar-01 R. Ruchandani Initial Revision.
1.1 16-May-01 D. Zhang Added VxWorks block
1.2 19-Apr-02 R. Ruchandani Removed VxWorks block
1.3 25-Apr-02 B. Hawthorne Added VxWorks block back in, needed
by MCS Full in Expresso.
1.4 10-May-02 B. Hawthorne Changed TXC_Dequeue(...) if VxWorks.
1.5 28-Jun-02 R. Kuhnen Made a change in TXC_Enqueue and TXC_Dequeue
1.6 24-Oct-02 D. Shea Redefined, PSOS, VXWORKS.
Added TXC_NO_RTOS
1.7 24-Oct-02 D. Shea Removed nested #elif statements
1.8 02-Dec-02 J. Esposito Removed sysclock variable and used CLOCK_PER_SEC macro
1.9 27-Dec-02 R. Kuhnen 1) Added include file, sysLib.h
2) Fix C++ compiler warning
-----------------------------------------------------------------------*/
/***********************************************************************
** Include Files **
***********************************************************************/
#ifdef TXC_PSOS
#include <sys_conf.h>
#include <psos.h>
#endif
#ifdef TXC_VXWORKS
#include <vxWorks.h>
#include <msgQLib.h>
#include <objLib.h>
#include <sysLib.h>
#include <time.h>
/* #include <CIOTimer.h> */
extern int sysClkRateGet (void);
#endif
#include "txc_generic.h"
#include "txc_platform.h"
#include "txc_error.h"
#include "txc_os_queue.h"
/***********************************************************************
** Imported Variables / Externs **
***********************************************************************/
/***********************************************************************
** Global Variables **
***********************************************************************/
/***********************************************************************
** Static Variables **
***********************************************************************/
/***********************************************************************
** Static Prototypes **
***********************************************************************/
/************************************************************************
* *
* FUNCTION: TXC_CreateQueue *
* *
* DESCRIPTION: Create a first in first out queue system. *
* *
* INPUTS:TXC_QUEUE_ID* queueIdPtr, TXC_U16BIT queueDepth, lowWaterMark*
* highWaterMark, const char* name *
* RETURNS: *
* TXC_U16BIT error code *
* TXC_NO_ERR, TXC_OS_RESOURCE_ERR, *
* *
* CAVEATS: *
* Non Blocking function. *
* *
* *
* REVISION HISTORY: *
* Date Author Description *
* ------------------------------------------------------------------- *
* 1.0 13-Mar-01 R. Ruchandani Initial Revision *
* *
************************************************************************/
TXC_U16BIT TXC_CreateQueue(TXC_QUEUE_ID * queueIdPtr, TXC_U16BIT queueDepth,
TXC_U16BIT lowWaterMark, TXC_U16BIT highWaterMark, const char * name)
{
#ifdef TXC_PSOS
unsigned long flags, psosError;
/* Call the psos function */
flags = Q_LOCAL|Q_FIFO;
psosError = q_create (name, (unsigned long)queueDepth, flags,
(unsigned long *)queueIdPtr);
/* Process the error */
if(psosError)
{
*queueIdPtr = TXC_NULL;
return TXC_OS_RESOURCE_ERR;
}
return TXC_NO_ERR;
#elif defined (TXC_VXWORKS) /* end of TXC_PSOS */
int options;
MSG_Q_ID msgQError;
/* Call the vxworks function */
options = MSG_Q_FIFO;
msgQError = msgQCreate ((int)queueDepth,
TXC_VXWORKS_MSG_LEN, /*only send pointers*/
options /*FIFO queue*/
);
/* Process the error */
if(msgQError == NULL)
{
*queueIdPtr = TXC_NULL;
return TXC_OS_RESOURCE_ERR;
}
else
{
*queueIdPtr = (TXC_QUEUE_ID)msgQError;
return TXC_NO_ERR;
}
#elif defined (TXC_NO_RTOS) /* end of TXC_VXWORKS */
return TXC_NO_ERR;
#else /* end of TXC_NO_RTOS */
return TXC_OS_RESOURCE_ERR;
#endif /* end of default */
}
/************************************************************************
* *
* FUNCTION: TXC_Enqueue *
* *
* DESCRIPTION: This functions enqueues a message from the specified *
* queue. *
* *
* INPUTS: TXC_QUEUE_ID queueId, TXC_VOID_PTR bufferPtr *
* *
* RETURNS: *
* TXC_NO_ERR, TXC_OS_RESOURCE_ERR *
* *
* *
* CAVEATS: *
* None at this time *
* *
* *
* REVISION HISTORY: *
* Date Author Description *
* ------------------------------------------------------------------- *
* 1.0 13-Mar-01 R. Ruchandani Initial Revision *
* 1.1 28-Jun-02 R. Kuhnen When in VXWORKS mode, changed *
* message data pointer reference *
* *
************************************************************************/
TXC_U16BIT TXC_Enqueue(TXC_QUEUE_ID queueId, TXC_VOID_PTR bufferPtr)
{
#ifdef TXC_PSOS
unsigned long messageBuffer[4], psosError;
/* Call the psos function, TXC only uses 1 long for transporting a pointer */
messageBuffer[0] = (unsigned long) bufferPtr;
messageBuffer[1] = messageBuffer[2] = messageBuffer[3] = 0;
psosError = q_send(queueId, messageBuffer);
/* Process the error */
if (psosError)
return TXC_OS_RESOURCE_ERR;
else
return TXC_NO_ERR;
#elif defined (TXC_VXWORKS) /* end of TXC_PSOS */
int msgQError;
/* Call the vxworks function, TXC only uses 1 long for transporting a pointer */
msgQError = msgQSend((MSG_Q_ID)queueId,
(char *)&bufferPtr,
(unsigned int)(TXC_VXWORKS_MSG_LEN), /*length of msg, CONSTANT = 4*/
(int) (0), /*timeout*/
(int) (0) /*priority, FIFO Queue*/
);
/* Process the error */
if (msgQError == ERROR)
return TXC_OS_RESOURCE_ERR;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -