Queue.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:28k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*******************************************************************************
- * Filename:
- * ---------
- * Queue.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- *
- *
- * Author:
- * -------
- *
- *
- *==============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *==============================================================================
- *******************************************************************************/
- /**
- * Copyright Notice
- * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- */
- /**************************************************************
- FILENAME : Queue.c
- PURPOSE : Task queue implementation functions
- REMARKS : nil
- AUTHOR : Neeraj Sharma
- DATE : Dec' 28, 2002
- **************************************************************/
- // #define __NEWSIMULATOR
- #include "MMI_features.h"
- #include "stdc.h"
- // #include "L4Dr1.h"
- #include "OslMemory.h"
- #include "pixteldatatypes.h"
- #include "QueueGprot.h"
- #include "DebugInitDef.h"
- //#undef __NEWSIMULATOR
- //#include "l4dr.h"
- //#include "MMI_trc.h"
- #ifndef __MTK_TARGET__
- #define __align(x)
- #endif
- void *lastMemory;
- TSIZE *lastSize;
- MYQUEUE *qPtr;
- /*****************************************************************************
- * FUNCTION
- * OslIntCreateMsgQ
- * DESCRIPTION
- * Creates Message Queue
- * PARAMETERS
- * queue_name [IN]
- * max_msg_size [IN]
- * max_msgs [IN]
- * RETURNS
- * void
- *****************************************************************************/
- oslMsgqid OslIntCreateMsgQ(PS8 queue_name, U32 max_msg_size, U32 max_msgs)
- {
- #ifdef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- win32_msgqid *msgqid;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- msgqid = (win32_msgqid*) OslMalloc(sizeof(win32_msgqid));
- strcpy(msgqid->q_name, queue_name);
- msgqid->q_max_message_size = max_msg_size;
- msgqid->q_max_messages = max_msgs;
- msgqid->q_messages = 0;
- msgqid->q_queue_size = msgqid->q_max_message_size * msgqid->q_max_messages;
- msgqid->q_semaphore_read = CreateSemaphore(NULL, 0, 1000, NULL);
- msgqid->q_semaphore_write = CreateSemaphore(NULL, 0, 1000, NULL);
- msgqid->q_start = (PU32) OslMalloc(msgqid->q_queue_size);
- msgqid->q_message_size = (PU32) OslMalloc(msgqid->q_max_messages * 4);
- msgqid->q_read = 0;
- msgqid->q_write = 0;
- msgqid->q_tasks_waiting_read = 0;
- msgqid->q_tasks_waiting_write = 0;
- InitializeCriticalSection(&msgqid->q_cs);
- return msgqid;
- #else /* MMI_ON_WIN32 */
- return NULL;
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntDeleteMsgQ
- * DESCRIPTION
- * Deletes Message Queue
- * PARAMETERS
- * msgqid [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void OslIntDeleteMsgQ(oslMsgqid msgqid)
- {
- #ifdef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- DeleteCriticalSection(&msgqid->q_cs);
- CloseHandle(msgqid->q_semaphore_read);
- CloseHandle(msgqid->q_semaphore_write);
- OslMfree(msgqid->q_start);
- OslMfree(msgqid->q_message_size);
- OslMfree(msgqid);
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntWriteMsgQ
- * DESCRIPTION
- * Writes to Message Queue
- * PARAMETERS
- * msgqid [IN]
- * msgPtr [?]
- * msgSize [IN]
- * wait_mode [IN]
- * RETURNS
- * void
- *****************************************************************************/
- OSLSTATUS OslIntWriteMsgQ(oslMsgqid msgqid, void *msgPtr, U32 msgSize, OSLWAITMODE wait_mode)
- {
- #ifdef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 index;
- PU32 ptr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EnterCriticalSection(&msgqid->q_cs);
- if (msgSize > msgqid->q_max_message_size)
- {
- LeaveCriticalSection(&msgqid->q_cs);
- return OSL_MESSAGE_TOO_BIG;
- }
- /* Check whether the queue is full) */
- if (msgqid->q_messages == msgqid->q_max_messages)
- {
- if (wait_mode == OSL_INFINITE_WAIT)
- {
- ++msgqid->q_tasks_waiting_write;
- LeaveCriticalSection(&msgqid->q_cs);
- WaitForSingleObject(msgqid->q_semaphore_write, INFINITE);
- EnterCriticalSection(&msgqid->q_cs);
- }
- else
- {
- LeaveCriticalSection(&msgqid->q_cs);
- return OSL_Q_FULL;
- }
- }
- msgqid->q_message_size[msgqid->q_write] = msgSize;
- index = msgqid->q_write * (msgqid->q_max_message_size / 4);
- ptr = msgqid->q_start + index;
- memcpy(ptr, msgPtr, msgSize);
- if (++msgqid->q_write == msgqid->q_max_messages)
- {
- msgqid->q_write = 0;
- }
- ++msgqid->q_messages;
- if (msgqid->q_tasks_waiting_read != 0)
- {
- ReleaseSemaphore(msgqid->q_semaphore_read, 1, NULL);
- msgqid->q_tasks_waiting_read -= 1;
- }
- LeaveCriticalSection(&msgqid->q_cs);
- #endif /* MMI_ON_WIN32 */
- return OSL_SUCCESS;
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntReadMsgQ
- * DESCRIPTION
- * Reades from Message Queue
- * PARAMETERS
- * msgqid [IN]
- * msgPtr [?]
- * msgSize [?]
- * wait_mode [IN]
- * RETURNS
- * void
- *****************************************************************************/
- OSLSTATUS OslIntReadMsgQ(oslMsgqid msgqid, void *msgPtr, U32 *msgSize, OSLWAITMODE wait_mode)
- {
- #ifdef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EnterCriticalSection(&msgqid->q_cs);
- if ((msgqid->q_read == msgqid->q_write) && (msgqid->q_messages == 0))
- {
- if (wait_mode == OSL_INFINITE_WAIT)
- {
- ++msgqid->q_tasks_waiting_read;
- LeaveCriticalSection(&msgqid->q_cs);
- WaitForSingleObject(msgqid->q_semaphore_read, INFINITE);
- EnterCriticalSection(&msgqid->q_cs);
- }
- else
- {
- LeaveCriticalSection(&msgqid->q_cs);
- return OSL_Q_EMPTY;
- }
- }
- *msgSize = msgqid->q_message_size[msgqid->q_read];
- memcpy(msgPtr, msgqid->q_start + (msgqid->q_read * (msgqid->q_max_message_size / 4)), *msgSize);
- if (++msgqid->q_read == msgqid->q_max_messages)
- {
- msgqid->q_read = 0;
- }
- --msgqid->q_messages;
- if (msgqid->q_tasks_waiting_write != 0)
- {
- ReleaseSemaphore(msgqid->q_semaphore_write, 1, NULL);
- --msgqid->q_tasks_waiting_write;
- }
- LeaveCriticalSection(&msgqid->q_cs);
- #endif /* MMI_ON_WIN32 */
- return OSL_SUCCESS;
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntReceiveMsgExtQ
- * DESCRIPTION
- * Reades from Task External Queue
- * PARAMETERS
- * msgqid [IN]
- * Message [?]
- * RETURNS
- * void
- *****************************************************************************/
- U32 OslIntReceiveMsgExtQ(oslMsgqid msgqid, MYQUEUE *Message)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 msgSize = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- OslIntReadMsgQ(msgqid, Message, &msgSize, OSL_INFINITE_WAIT);
- return msgSize;
- }
- extern void CheckAndPrintMsgId(U16 Id);
- /*****************************************************************************
- * FUNCTION
- * OslIntMsgSendExtQueue
- * DESCRIPTION
- * Writes to Task External Queue
- * PARAMETERS
- * Message [?]
- * RETURNS
- * void
- *****************************************************************************/
- void OslIntMsgSendExtQueue(MYQUEUE *Message)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYQUEUE *oslMessage;
- U8 ref_count;
-
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
-
- /* check ref_count of local para */
- if (Message->local_para_ptr != NULL)
- {
- ref_count = Message->local_para_ptr->ref_count;
- EXT_ASSERT(ref_count != 0, (int)Message->src_mod_id,
- (int)Message->dest_mod_id, (int)Message->msg_id);
- }
-
- oslMessage = allocate_ilm(Message->oslSrcId);
- memcpy(oslMessage, Message, sizeof(MYQUEUE));
- if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_L4C)
- {
- oslMessage->sap_id = MMI_L4C_SAP;
- }
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_MMI)
- {
- oslMessage->sap_id = MMI_MMI_SAP;
- }
- #ifdef __MMI_FILE_MANAGER__
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_FMT)
- {
- oslMessage->sap_id = MMI_FMT_SAP;
- }
- #endif
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_ABM)
- {
- oslMessage->sap_id = MMI_ABM_SAP;
- }
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_J2ME)
- {
- oslMessage->sap_id = MMI_J2ME_SAP;
- }
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_JASYN)
- {
- oslMessage->sap_id = MMI_JASYN_SAP;
- }
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_SYNCML)
- {
- oslMessage->sap_id = MMI_SYNCML_SAP;
- }
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_POC)
- {
- oslMessage->sap_id = MMI_POC_SAP;
- }
- else if (oslMessage->oslSrcId == MOD_MMI &&
- oslMessage->oslDestId == MOD_WAP)
- {
- oslMessage->sap_id = MMI_WAP_SAP;
- }
- else if (oslMessage->oslSrcId == MOD_WAP &&
- oslMessage->oslDestId == MOD_MMI)
- {
- oslMessage->sap_id = WAP_MMI_SAP;
- }
- else
- {
- oslMessage->sap_id = INVALID_SAP;
- }
- msg_send_ext_queue(oslMessage);
- CheckAndPrintMsgId((U16) (Message->msg_id));
- #else /* MMI_ON_WIN32 */
- if (Message->oslDestId == MOD_MMI)
- {
- Message->oslDestId = MOD_PRT;
- }
- if (Message->oslSrcId == MOD_MMI)
- {
- Message->oslSrcId = MOD_PRT;
- }
- if (Message->oslDestId == MOD_WAP)
- {
- Message->oslDestId = MOD_PRT;
- }
-
- /* make sure destination module exists */
- MMI_ASSERT( Message->oslDestId < TOTAL_TASKS );
-
- OslIntWriteMsgQ(task_info_g1[Message->oslDestId].task_ext_qid, Message, sizeof(MYQUEUE), OSL_INFINITE_WAIT);
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntConstructDataPtr
- * DESCRIPTION
- * Constructs Data Ptr
- *
- * Not used now
- * PARAMETERS
- * size [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void *OslIntConstructDataPtr(U32 size)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (construct_local_para((kal_uint16) size, TD_CTRL));
- #else /* MMI_ON_WIN32 */
- void *ptr;
- TSIZE *temp, tempdata;
- temp = OslMalloc(size + sizeof(tempdata));
- assert(temp != NULL);
- tempdata.s = size;
- memcpy(temp, &tempdata, sizeof(tempdata));
- ptr = (void*)((char*)temp + sizeof(tempdata));
- return ptr;
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntFreeDataPtr
- * DESCRIPTION
- * Frees Data Ptr
- *
- * Not used now
- * PARAMETERS
- * ptr [?]
- * RETURNS
- * void
- *****************************************************************************/
- void OslIntFreeDataPtr(void *ptr)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- free_local_para(ptr);
- #else /* MMI_ON_WIN32 */
- TSIZE *temp;
- temp = (void*)((char*)ptr - sizeof(TSIZE));
- OslMfree(temp);
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntSizeofDataPtr
- * DESCRIPTION
- * Returns Size of Data Ptr
- *
- * Not used now
- * PARAMETERS
- * ptr [?]
- * RETURNS
- * void
- *****************************************************************************/
- U32 OslIntSizeofDataPtr(void *ptr)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- struct tsize
- {
- U8 ref_count;
- U16 size;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- };
- return 0;
- #else /* MMI_ON_WIN32 */
- typedef struct tsize
- {
- U32 size;
- } TSIZE;
- TSIZE *temp;
- if (ptr == NULL)
- {
- return 0;
- }
- temp = (void*)((char*)ptr - sizeof(TSIZE));
- return (U32) temp->size;
- #endif /* MMI_ON_WIN32 */
- }
- /*****************************************************************************
- * FUNCTION
- * OslIntFreeInterTaskMsg
- * DESCRIPTION
- * Frees InterTask Mesg
- *
- * Not used now
- * PARAMETERS
- * Message [?]
- * RETURNS
- * void
- *****************************************************************************/
- void OslIntFreeInterTaskMsg(void *Message)
- {
- #ifndef MMI_ON_WIN32
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- free_ilm(Message);
- #else /* MMI_ON_WIN32 */
- MYQUEUE *ptr;
- ptr = Message;
- if (ptr->oslSrcId == MOD_L4C)
- {
- ptr->oslSrcId = MOD_MMI;
- ptr->oslDestId = MOD_L4C;
- ptr->oslMsgId = 0;
- OslMsgSendExtQueue(ptr);
- }
- else
- {
- if (ptr->oslDataPtr != NULL)
- {
- OslIntFreeDataPtr(ptr->oslDataPtr);
- }
- }
- #endif /* MMI_ON_WIN32 */
- }
- #ifdef MMI_ON_WIN32
- /*****************************************************************************
- * FUNCTION
- * OslNumOfQMsgs
- * DESCRIPTION
- * Get the message number in MMI queue
- * PARAMETERS
- * void
- * RETURNS
- * message number
- *****************************************************************************/
- U8 OslNumOfQMsgs(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 num;
- oslMsgqid msgqid = task_info_g1[MOD_PRT].task_ext_qid;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- EnterCriticalSection(&msgqid->q_cs);
- num = (U8) (msgqid->q_messages);
- LeaveCriticalSection(&msgqid->q_cs);
- return num;
- }
- #endif /* MMI_ON_WIN32 */
- #define CIRCQ_NODE_SIZE sizeof(MYQUEUE)
- /*
- * Because MMI task will receive extQ message into circular queue,
- * we increase the circular queue size from 30 to 50
- */
- #define CIRCQ_NO_OF_NODES 65
- __align(4)
- U8 circq_array[CIRCQ_NODE_SIZE * CIRCQ_NO_OF_NODES];
- U8 circq_read = 0, circq_write = 0, circq_messages = 0, max_circq_messages = 0;
- /*****************************************************************************
- * FUNCTION
- * OslReadCircularQ
- * DESCRIPTION
- * Reads from Circ Queue
- *
- * Not used now
- * PARAMETERS
- * msgPtr [?]
- * RETURNS
- * void
- *****************************************************************************/
- U8 OslReadCircularQ(void *msgPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G1_FRM, "OslReadCircularQ: <#[%d], read:[%d], write:[%d]>", circq_messages,
- circq_read, circq_write));
- if (circq_messages == 0)
- {
- return 0;
- }
- memcpy(msgPtr, circq_array + (circq_read * CIRCQ_NODE_SIZE), CIRCQ_NODE_SIZE);
- if (++circq_read == CIRCQ_NO_OF_NODES)
- {
- circq_read = 0;
- }
- --circq_messages;
- return 1;
- }
- /*****************************************************************************
- * FUNCTION
- * OslLookUpLastCircularQMsg
- * DESCRIPTION
- * Look up the last message in Circ Queue
- *
- * Not used now
- * PARAMETERS
- * msgPtr [?]
- * RETURNS
- * void
- *****************************************************************************/
- U8 OslLookUpLastCircularQMsg(void *msgPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 last_read_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (circq_messages > 0)
- {
- if (circq_write == 0)
- {
- last_read_index = CIRCQ_NO_OF_NODES;
- }
- else
- {
- last_read_index = circq_write - 1;
- }
- memcpy(msgPtr, circq_array + (last_read_index * CIRCQ_NODE_SIZE), CIRCQ_NODE_SIZE);
- return 1;
- }
- else
- {
- memset(msgPtr, 0, CIRCQ_NODE_SIZE);
- return 0;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * OslWriteCircularQ
- * DESCRIPTION
- * Writes to Circ Queue
- *
- * Not used now
- * PARAMETERS
- * msgPtr [?]
- * RETURNS
- * void
- *****************************************************************************/
- U8 OslWriteCircularQ(void *msgPtr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G1_FRM, "OslWriteCircularQ: <#[%d], read:[%d], write:[%d]>", circq_messages,
- circq_read, circq_write));
- if (circq_messages == CIRCQ_NO_OF_NODES)
- {
- MMI_ASSERT(0);
- return 0;
- }
- memcpy(circq_array + (circq_write * CIRCQ_NODE_SIZE), msgPtr, CIRCQ_NODE_SIZE);
- if (++circq_write == CIRCQ_NO_OF_NODES)
- {
- circq_write = 0;
- }
- ++circq_messages;
- if (max_circq_messages < circq_messages)
- {
- max_circq_messages = circq_messages;
- }
- return 1;
- }
- /*****************************************************************************
- * FUNCTION
- * OslNumOfCircularQMsgs
- * DESCRIPTION
- * Get the message number
- *
- * Not used now
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- U8 OslNumOfCircularQMsgs(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return circq_messages;
- }
- /*****************************************************************************
- * FUNCTION
- * OslIsCircularQFull
- * DESCRIPTION
- * Check if Circ Queue is full
- *
- * Not used now
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- U8 OslIsCircularQFull(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (circq_messages == CIRCQ_NO_OF_NODES);
- }