feature:支持queue地址外部部署共功能及queue名字设置
Signed-off-by: xuxinyu <xuxinyu6@huawei.com> Change-Id: I1984014956a92d61d65b68f79279b2aa593a72e1
This commit is contained in:
parent
df30bc4e0a
commit
c09b3a8774
|
@ -1226,14 +1226,40 @@ osMessageQueueId_t osMessageQueueNew(uint32_t msg_count, uint32_t msg_size, cons
|
||||||
{
|
{
|
||||||
UINT32 queueId;
|
UINT32 queueId;
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
UNUSED(attr);
|
|
||||||
osMessageQueueId_t handle;
|
osMessageQueueId_t handle;
|
||||||
|
const char *queueName = NULL;
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
UINT32 queueSize = 0;
|
||||||
|
UINT8 *staticMem = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((msg_count == 0) || (msg_size == 0) || OS_INT_ACTIVE) {
|
if ((msg_count == 0) || (msg_size == 0) || OS_INT_ACTIVE) {
|
||||||
return (osMessageQueueId_t)NULL;
|
return (osMessageQueueId_t)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = LOS_QueueCreate((char *)NULL, (UINT16)msg_count, &queueId, 0, (UINT16)msg_size);
|
if (attr != NULL) {
|
||||||
|
queueName = attr->name;
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
queueSize = attr->mq_size;
|
||||||
|
staticMem = attr->mq_mem;
|
||||||
|
if ((queueSize == 0 || staticMem == NULL)) {
|
||||||
|
return (osMessageQueueId_t)NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
if (staticMem != NULL) {
|
||||||
|
ret = LOS_QueueCreateStatic((const CHAR *)queueName, (UINT16)msg_count, &queueId, \
|
||||||
|
(UINT8 *)staticMem, 0, (UINT16)queueSize / msg_count);
|
||||||
|
} else {
|
||||||
|
ret = LOS_QueueCreate((const CHAR *)queueName, (UINT16)msg_count, &queueId, 0, (UINT16)msg_size);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
ret = LOS_QueueCreate((const CHAR *)queueName, (UINT16)msg_count, &queueId, 0, (UINT16)msg_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ret == LOS_OK) {
|
if (ret == LOS_OK) {
|
||||||
handle = (osMessageQueueId_t)(GET_QUEUE_HANDLE(queueId));
|
handle = (osMessageQueueId_t)(GET_QUEUE_HANDLE(queueId));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1361,8 +1387,13 @@ osStatus_t osMessageQueueDelete(osMessageQueueId_t mq_id)
|
||||||
|
|
||||||
const char *osMessageQueueGetName(osMessageQueueId_t mq_id)
|
const char *osMessageQueueGetName(osMessageQueueId_t mq_id)
|
||||||
{
|
{
|
||||||
UNUSED(mq_id);
|
if (mq_id == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
LosQueueCB *pstQueue = (LosQueueCB *)mq_id;
|
||||||
|
|
||||||
|
return (const char *)pstQueue->queueName;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -350,6 +350,14 @@ extern "C" {
|
||||||
#define LOSCFG_BASE_IPC_QUEUE_LIMIT 6
|
#define LOSCFG_BASE_IPC_QUEUE_LIMIT 6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_config
|
||||||
|
* Maximum supported number of static queues rather than the number of usable queues
|
||||||
|
*/
|
||||||
|
#ifndef LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT
|
||||||
|
#define LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT 3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
Software timer module configuration
|
Software timer module configuration
|
||||||
|
|
|
@ -380,7 +380,7 @@ typedef struct tagQueueInfo {
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>There are LOSCFG_BASE_IPC_QUEUE_LIMIT queues available, change it's value when necessary.</li>
|
* <li>There are LOSCFG_BASE_IPC_QUEUE_LIMIT queues available, change it's value when necessary.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @param queueName [IN] Message queue name. Reserved parameter, not used for now.
|
* @param queueName [IN] Message queue name.
|
||||||
* @param len [IN] Queue length. The value range is [1,0xffff].
|
* @param len [IN] Queue length. The value range is [1,0xffff].
|
||||||
* @param queueID [OUT] ID of the queue control structure that is successfully created.
|
* @param queueID [OUT] ID of the queue control structure that is successfully created.
|
||||||
* @param flags [IN] Queue mode. Reserved parameter, not used for now.
|
* @param flags [IN] Queue mode. Reserved parameter, not used for now.
|
||||||
|
@ -403,6 +403,41 @@ extern UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||||
UINT32 flags,
|
UINT32 flags,
|
||||||
UINT16 maxMsgSize);
|
UINT16 maxMsgSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_queue
|
||||||
|
* @brief Create a message queue.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* This API is used to create a message queue.
|
||||||
|
* @attention
|
||||||
|
* <ul>
|
||||||
|
* <li>There are LOSCFG_BASE_IPC_QUEUE_LIMIT queues available, change it's value when necessary.</li>
|
||||||
|
* </ul>
|
||||||
|
* @param queueName [IN] Message queue name.
|
||||||
|
* @param len [IN] Queue length. The value range is [1,0xffff].
|
||||||
|
* @param queueID [OUT] ID of the queue control structure that is successfully created.
|
||||||
|
* @param staticMem [IN] Pointer to a static memory for the message queue data.
|
||||||
|
* @param flags [IN] Queue mode. Reserved parameter, not used for now.
|
||||||
|
* @param maxMsgSize [IN] Node size. The value range is [1,0xffff-4].
|
||||||
|
*
|
||||||
|
* @retval #LOS_OK The message queue is successfully created.
|
||||||
|
* @retval #LOS_ERRNO_QUEUE_CB_UNAVAILABLE The upper limit of the number of created queues is exceeded.
|
||||||
|
* @retval #LOS_ERRNO_QUEUE_CREATE_NO_MEMORY Insufficient memory for queue creation.
|
||||||
|
* @retval #LOS_ERRNO_QUEUE_CREAT_PTR_NULL Null pointer, queueID is NULL.
|
||||||
|
* @retval #LOS_ERRNO_QUEUE_PARA_ISZERO The queue length or message node size passed in during queue
|
||||||
|
* creation is 0.
|
||||||
|
* @retval #LOS_ERRNO_QUEUE_SIZE_TOO_BIG The parameter maxMsgSize is larger than 0xffff - 4.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
|
||||||
|
* @see LOS_QueueDelete
|
||||||
|
*/
|
||||||
|
extern UINT32 LOS_QueueCreateStatic(const CHAR *queueName,
|
||||||
|
UINT16 len,
|
||||||
|
UINT32 *queueID,
|
||||||
|
UINT8 *staticMem,
|
||||||
|
UINT32 flags,
|
||||||
|
UINT16 maxMsgSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
* @brief Read a queue.
|
* @brief Read a queue.
|
||||||
|
@ -775,6 +810,7 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT8 *queue; /**< Pointer to a queue handle */
|
UINT8 *queue; /**< Pointer to a queue handle */
|
||||||
|
UINT8 *queueName; /**< Queue name */
|
||||||
UINT16 queueState; /**< Queue state */
|
UINT16 queueState; /**< Queue state */
|
||||||
UINT16 queueLen; /**< Queue length */
|
UINT16 queueLen; /**< Queue length */
|
||||||
UINT16 queueSize; /**< Node size */
|
UINT16 queueSize; /**< Node size */
|
||||||
|
@ -787,6 +823,9 @@ typedef struct {
|
||||||
LOS_DL_LIST memList; /**< Pointer to the memory linked list */
|
LOS_DL_LIST memList; /**< Pointer to the memory linked list */
|
||||||
} LosQueueCB;
|
} LosQueueCB;
|
||||||
|
|
||||||
|
|
||||||
|
extern LosQueueCB *OsGetQueueHandle(UINT32 queueID);
|
||||||
|
|
||||||
/* queue state */
|
/* queue state */
|
||||||
/**
|
/**
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
|
@ -822,14 +861,24 @@ extern LosQueueCB *g_allQueue;
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
* Obtain a handle of the queue that has a specified ID.
|
* Obtain a handle of the queue that has a specified ID.
|
||||||
*/
|
*/
|
||||||
#define GET_QUEUE_HANDLE(QueueID) (((LosQueueCB *)g_allQueue) + (QueueID))
|
#define GET_QUEUE_HANDLE(QueueID) OsGetQueueHandle(QueueID)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
* Obtain the head node in a queue doubly linked list.
|
* Obtain the head node in a queue doubly linked list.
|
||||||
*/
|
*/
|
||||||
#define GET_QUEUE_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosQueueCB, readWriteList[OS_QUEUE_WRITE])
|
#define GET_QUEUE_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosQueueCB, readWriteList[OS_QUEUE_WRITE])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_queue
|
||||||
|
* Maximum number of queues
|
||||||
|
*/
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
#define OS_ALL_IPC_QUEUE_LIMIT LOSCFG_BASE_IPC_QUEUE_LIMIT + LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT
|
||||||
|
#else
|
||||||
|
#define OS_ALL_IPC_QUEUE_LIMIT LOSCFG_BASE_IPC_QUEUE_LIMIT
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_queue
|
* @ingroup los_queue
|
||||||
* @brief Alloc a stationary memory for a mail.
|
* @brief Alloc a stationary memory for a mail.
|
||||||
|
|
|
@ -47,6 +47,11 @@
|
||||||
LITE_OS_SEC_BSS LosQueueCB *g_allQueue = NULL ;
|
LITE_OS_SEC_BSS LosQueueCB *g_allQueue = NULL ;
|
||||||
LITE_OS_SEC_BSS LOS_DL_LIST g_freeQueueList;
|
LITE_OS_SEC_BSS LOS_DL_LIST g_freeQueueList;
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
LITE_OS_SEC_BSS LosQueueCB *g_staticQueue = NULL ;
|
||||||
|
LITE_OS_SEC_BSS LOS_DL_LIST g_freeStaticQueueList;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
Function : OsQueueInit
|
Function : OsQueueInit
|
||||||
Description : queue initial
|
Description : queue initial
|
||||||
|
@ -59,7 +64,11 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsQueueInit(VOID)
|
||||||
LosQueueCB *queueNode = NULL;
|
LosQueueCB *queueNode = NULL;
|
||||||
UINT16 index;
|
UINT16 index;
|
||||||
|
|
||||||
if (LOSCFG_BASE_IPC_QUEUE_LIMIT == 0) {
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
LosQueueCB *queueNodeStatic = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (OS_ALL_IPC_QUEUE_LIMIT == 0) {
|
||||||
return LOS_ERRNO_QUEUE_MAXNUM_ZERO;
|
return LOS_ERRNO_QUEUE_MAXNUM_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,24 +87,33 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsQueueInit(VOID)
|
||||||
LOS_ListTailInsert(&g_freeQueueList, &queueNode->readWriteList[OS_QUEUE_WRITE]);
|
LOS_ListTailInsert(&g_freeQueueList, &queueNode->readWriteList[OS_QUEUE_WRITE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
g_staticQueue = (LosQueueCB *)LOS_MemAlloc(m_aucSysMem0, LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT * sizeof(LosQueueCB));
|
||||||
|
if (g_staticQueue == NULL) {
|
||||||
|
return LOS_ERRNO_QUEUE_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
(VOID)memset_s(g_staticQueue, LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT * sizeof(LosQueueCB),
|
||||||
|
0, LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT * sizeof(LosQueueCB));
|
||||||
|
|
||||||
|
LOS_ListInit(&g_freeStaticQueueList);
|
||||||
|
for (index = 0; index < LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT; index++) {
|
||||||
|
queueNodeStatic = ((LosQueueCB *)g_staticQueue) + index;
|
||||||
|
queueNodeStatic->queueID = index + LOSCFG_BASE_IPC_QUEUE_LIMIT;
|
||||||
|
LOS_ListTailInsert(&g_freeStaticQueueList, &queueNodeStatic->readWriteList[OS_QUEUE_WRITE]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
Function : LOS_QueueCreate
|
static UINT32 OsQueueCreate(const CHAR *queueName,
|
||||||
Description : Create a queue
|
UINT16 len,
|
||||||
Input : queueName --- Queue name, less than 4 characters
|
UINT32 *queueID,
|
||||||
: len --- Queue length
|
UINT8 *staticMem,
|
||||||
: flags --- Queue type, FIFO or PRIO
|
UINT32 flags,
|
||||||
: maxMsgSize --- Maximum message size in byte
|
UINT16 maxMsgSize)
|
||||||
Output : queueID --- Queue ID
|
|
||||||
Return : LOS_OK on success or error code on failure
|
|
||||||
*****************************************************************************/
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
|
|
||||||
UINT16 len,
|
|
||||||
UINT32 *queueID,
|
|
||||||
UINT32 flags,
|
|
||||||
UINT16 maxMsgSize)
|
|
||||||
{
|
{
|
||||||
LosQueueCB *queueCB = NULL;
|
LosQueueCB *queueCB = NULL;
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
@ -103,7 +121,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||||
UINT8 *queue = NULL;
|
UINT8 *queue = NULL;
|
||||||
UINT16 msgSize;
|
UINT16 msgSize;
|
||||||
|
|
||||||
(VOID)queueName;
|
|
||||||
(VOID)flags;
|
(VOID)flags;
|
||||||
|
|
||||||
if (queueID == NULL) {
|
if (queueID == NULL) {
|
||||||
|
@ -124,6 +141,32 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||||
if ((UINT32_MAX / msgSize) < len) {
|
if ((UINT32_MAX / msgSize) < len) {
|
||||||
return LOS_ERRNO_QUEUE_SIZE_TOO_BIG;
|
return LOS_ERRNO_QUEUE_SIZE_TOO_BIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
if (staticMem != NULL) {
|
||||||
|
queue = staticMem;
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
|
if (LOS_ListEmpty(&g_freeStaticQueueList)) {
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
return LOS_ERRNO_QUEUE_CB_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
unusedQueue = LOS_DL_LIST_FIRST(&(g_freeStaticQueueList));
|
||||||
|
} else {
|
||||||
|
queue = (UINT8 *)LOS_MemAlloc(m_aucSysMem0, (UINT32)len * msgSize);
|
||||||
|
if (queue == NULL) {
|
||||||
|
return LOS_ERRNO_QUEUE_CREATE_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
intSave = LOS_IntLock();
|
||||||
|
if (LOS_ListEmpty(&g_freeQueueList)) {
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
(VOID)LOS_MemFree(m_aucSysMem0, queue);
|
||||||
|
return LOS_ERRNO_QUEUE_CB_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
unusedQueue = LOS_DL_LIST_FIRST(&(g_freeQueueList));
|
||||||
|
}
|
||||||
|
#else
|
||||||
queue = (UINT8 *)LOS_MemAlloc(m_aucSysMem0, (UINT32)len * msgSize);
|
queue = (UINT8 *)LOS_MemAlloc(m_aucSysMem0, (UINT32)len * msgSize);
|
||||||
if (queue == NULL) {
|
if (queue == NULL) {
|
||||||
return LOS_ERRNO_QUEUE_CREATE_NO_MEMORY;
|
return LOS_ERRNO_QUEUE_CREATE_NO_MEMORY;
|
||||||
|
@ -135,10 +178,12 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||||
(VOID)LOS_MemFree(m_aucSysMem0, queue);
|
(VOID)LOS_MemFree(m_aucSysMem0, queue);
|
||||||
return LOS_ERRNO_QUEUE_CB_UNAVAILABLE;
|
return LOS_ERRNO_QUEUE_CB_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unusedQueue = LOS_DL_LIST_FIRST(&(g_freeQueueList));
|
unusedQueue = LOS_DL_LIST_FIRST(&(g_freeQueueList));
|
||||||
|
#endif
|
||||||
|
|
||||||
LOS_ListDelete(unusedQueue);
|
LOS_ListDelete(unusedQueue);
|
||||||
queueCB = (GET_QUEUE_LIST(unusedQueue));
|
queueCB = (GET_QUEUE_LIST(unusedQueue));
|
||||||
|
queueCB->queueName = (UINT8 *)queueName; // The name can be null
|
||||||
queueCB->queueLen = len;
|
queueCB->queueLen = len;
|
||||||
queueCB->queueSize = msgSize;
|
queueCB->queueSize = msgSize;
|
||||||
queueCB->queue = queue;
|
queueCB->queue = queue;
|
||||||
|
@ -159,10 +204,62 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
Function : LOS_QueueCreateStatic
|
||||||
|
Description : Create a queue use static menory
|
||||||
|
Input : queueName --- Queue name, less than 4 characters
|
||||||
|
: len --- Queue length
|
||||||
|
: queueMem --- Queue static memory for data storage
|
||||||
|
: flags --- Queue type, FIFO or PRIO
|
||||||
|
: maxMsgSize --- Maximum message size in byte
|
||||||
|
Output : queueID --- Queue ID
|
||||||
|
Return : LOS_OK on success or error code on failure
|
||||||
|
*****************************************************************************/
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreateStatic(const CHAR *queueName,
|
||||||
|
UINT16 len,
|
||||||
|
UINT32 *queueID,
|
||||||
|
UINT8 *staticMem,
|
||||||
|
UINT32 flags,
|
||||||
|
UINT16 maxMsgSize)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
|
||||||
|
(VOID)flags;
|
||||||
|
|
||||||
|
ret = OsQueueCreate(queueName, len, queueID, staticMem, 0, maxMsgSize);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
Function : LOS_QueueCreate
|
||||||
|
Description : Create a queue
|
||||||
|
Input : queueName --- Queue name, less than 4 characters
|
||||||
|
: len --- Queue length
|
||||||
|
: flags --- Queue type, FIFO or PRIO
|
||||||
|
: maxMsgSize --- Maximum message size in byte
|
||||||
|
Output : queueID --- Queue ID
|
||||||
|
Return : LOS_OK on success or error code on failure
|
||||||
|
*****************************************************************************/
|
||||||
|
LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(const CHAR *queueName,
|
||||||
|
UINT16 len,
|
||||||
|
UINT32 *queueID,
|
||||||
|
UINT32 flags,
|
||||||
|
UINT16 maxMsgSize)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
|
||||||
|
(VOID)flags;
|
||||||
|
|
||||||
|
ret = OsQueueCreate(queueName, len, queueID, NULL, 0, maxMsgSize);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static INLINE LITE_OS_SEC_TEXT UINT32 OsQueueReadParameterCheck(UINT32 queueID, VOID *bufferAddr,
|
static INLINE LITE_OS_SEC_TEXT UINT32 OsQueueReadParameterCheck(UINT32 queueID, VOID *bufferAddr,
|
||||||
UINT32 *bufferSize, UINT32 timeOut)
|
UINT32 *bufferSize, UINT32 timeOut)
|
||||||
{
|
{
|
||||||
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT) {
|
if (queueID >= OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
return LOS_ERRNO_QUEUE_INVALID;
|
return LOS_ERRNO_QUEUE_INVALID;
|
||||||
}
|
}
|
||||||
if ((bufferAddr == NULL) || (bufferSize == NULL)) {
|
if ((bufferAddr == NULL) || (bufferSize == NULL)) {
|
||||||
|
@ -184,7 +281,7 @@ static INLINE LITE_OS_SEC_TEXT UINT32 OsQueueReadParameterCheck(UINT32 queueID,
|
||||||
static INLINE LITE_OS_SEC_TEXT UINT32 OsQueueWriteParameterCheck(UINT32 queueID, VOID *bufferAddr,
|
static INLINE LITE_OS_SEC_TEXT UINT32 OsQueueWriteParameterCheck(UINT32 queueID, VOID *bufferAddr,
|
||||||
UINT32 *bufferSize, UINT32 timeOut)
|
UINT32 *bufferSize, UINT32 timeOut)
|
||||||
{
|
{
|
||||||
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT) {
|
if (queueID >= OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
return LOS_ERRNO_QUEUE_INVALID;
|
return LOS_ERRNO_QUEUE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +556,7 @@ LITE_OS_SEC_TEXT VOID *OsQueueMailAlloc(UINT32 queueID, VOID *mailPool, UINT32 t
|
||||||
LosQueueCB *queueCB = (LosQueueCB *)NULL;
|
LosQueueCB *queueCB = (LosQueueCB *)NULL;
|
||||||
LosTaskCB *runTsk = (LosTaskCB *)NULL;
|
LosTaskCB *runTsk = (LosTaskCB *)NULL;
|
||||||
|
|
||||||
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT) {
|
if (queueID >= OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +620,7 @@ LITE_OS_SEC_TEXT UINT32 OsQueueMailFree(UINT32 queueID, VOID *mailPool, VOID *ma
|
||||||
LosQueueCB *queueCB = (LosQueueCB *)NULL;
|
LosQueueCB *queueCB = (LosQueueCB *)NULL;
|
||||||
LosTaskCB *resumedTask = (LosTaskCB *)NULL;
|
LosTaskCB *resumedTask = (LosTaskCB *)NULL;
|
||||||
|
|
||||||
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT) {
|
if (queueID >= OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
return LOS_ERRNO_QUEUE_MAIL_HANDLE_INVALID;
|
return LOS_ERRNO_QUEUE_MAIL_HANDLE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +670,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueDelete(UINT32 queueID)
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
|
|
||||||
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT) {
|
if (queueID >= OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
return LOS_ERRNO_QUEUE_NOT_FOUND;
|
return LOS_ERRNO_QUEUE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,6 +705,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueDelete(UINT32 queueID)
|
||||||
queue = queueCB->queue;
|
queue = queueCB->queue;
|
||||||
queueCB->queue = (UINT8 *)NULL;
|
queueCB->queue = (UINT8 *)NULL;
|
||||||
queueCB->queueState = OS_QUEUE_UNUSED;
|
queueCB->queueState = OS_QUEUE_UNUSED;
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT && queueID < OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
|
LOS_ListAdd(&g_freeStaticQueueList, &queueCB->readWriteList[OS_QUEUE_WRITE]);
|
||||||
|
LOS_IntRestore(intSave);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
LOS_ListAdd(&g_freeQueueList, &queueCB->readWriteList[OS_QUEUE_WRITE]);
|
LOS_ListAdd(&g_freeQueueList, &queueCB->readWriteList[OS_QUEUE_WRITE]);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
@ -632,7 +737,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_QueueInfoGet(UINT32 queueID, QUEUE_INFO_S *que
|
||||||
return LOS_ERRNO_QUEUE_PTR_NULL;
|
return LOS_ERRNO_QUEUE_PTR_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT) {
|
if (queueID >= OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
return LOS_ERRNO_QUEUE_INVALID;
|
return LOS_ERRNO_QUEUE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,5 +778,16 @@ QUEUE_END:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LosQueueCB *OsGetQueueHandle(UINT32 queueID)
|
||||||
|
{
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
if (queueID >= LOSCFG_BASE_IPC_QUEUE_LIMIT && queueID < OS_ALL_IPC_QUEUE_LIMIT) {
|
||||||
|
return (((LosQueueCB *)g_staticQueue) + (queueID - LOSCFG_BASE_IPC_QUEUE_LIMIT));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (((LosQueueCB *)g_allQueue) + (queueID));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* (LOSCFG_BASE_IPC_QUEUE == 1) */
|
#endif /* (LOSCFG_BASE_IPC_QUEUE == 1) */
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,10 @@ static UINT32 Testcase(VOID)
|
||||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[LOSCFG_BASE_IPC_QUEUE_LIMIT], 0, QUEUE_BASE_MSGSIZE);
|
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[LOSCFG_BASE_IPC_QUEUE_LIMIT], 0, QUEUE_BASE_MSGSIZE);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CB_UNAVAILABLE, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CB_UNAVAILABLE, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_LIMIT + 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueWrite(OS_ALL_IPC_QUEUE_LIMIT + 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT + 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueRead(OS_ALL_IPC_QUEUE_LIMIT + 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
|
|
|
@ -41,7 +41,7 @@ static UINT32 Testcase(VOID)
|
||||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_LIMIT, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueWrite(OS_ALL_IPC_QUEUE_LIMIT, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||||
|
|
|
@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
|
||||||
ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueDelete(LOSCFG_BASE_IPC_QUEUE_LIMIT + 1);
|
ret = LOS_QueueDelete(OS_ALL_IPC_QUEUE_LIMIT + 1);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_FOUND, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_FOUND, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||||
|
|
|
@ -38,15 +38,15 @@ static UINT32 Testcase(VOID)
|
||||||
UINT32 swTmrID;
|
UINT32 swTmrID;
|
||||||
QUEUE_INFO_S queueInfo;
|
QUEUE_INFO_S queueInfo;
|
||||||
|
|
||||||
swTmrID = LOSCFG_BASE_IPC_QUEUE_LIMIT + 1;
|
swTmrID = OS_ALL_IPC_QUEUE_LIMIT + 1;
|
||||||
ret = LOS_QueueInfoGet(swTmrID, &queueInfo);
|
ret = LOS_QueueInfoGet(swTmrID, &queueInfo);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
swTmrID = LOSCFG_BASE_IPC_QUEUE_LIMIT;
|
swTmrID = OS_ALL_IPC_QUEUE_LIMIT;
|
||||||
ret = LOS_QueueInfoGet(swTmrID, &queueInfo);
|
ret = LOS_QueueInfoGet(swTmrID, &queueInfo);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
swTmrID = LOSCFG_BASE_IPC_QUEUE_LIMIT - 1;
|
swTmrID = OS_ALL_IPC_QUEUE_LIMIT - 1;
|
||||||
ret = LOS_QueueInfoGet(swTmrID, &queueInfo);
|
ret = LOS_QueueInfoGet(swTmrID, &queueInfo);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,10 @@ static UINT32 Testcase(VOID)
|
||||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[LOSCFG_BASE_IPC_QUEUE_LIMIT], 0, QUEUE_BASE_MSGSIZE);
|
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &queueID[LOSCFG_BASE_IPC_QUEUE_LIMIT], 0, QUEUE_BASE_MSGSIZE);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CB_UNAVAILABLE, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CB_UNAVAILABLE, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_LIMIT + 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueWriteHead(OS_ALL_IPC_QUEUE_LIMIT + 1, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_LIMIT + 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueRead(OS_ALL_IPC_QUEUE_LIMIT + 1, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
|
|
|
@ -41,7 +41,7 @@ static UINT32 Testcase(VOID)
|
||||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_LIMIT, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueWriteHead(OS_ALL_IPC_QUEUE_LIMIT, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||||
|
|
|
@ -70,7 +70,7 @@ static UINT32 Testcase(VOID)
|
||||||
ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_QueueDelete(LOSCFG_BASE_IPC_QUEUE_LIMIT + 1);
|
ret = LOS_QueueDelete(OS_ALL_IPC_QUEUE_LIMIT + 1);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_FOUND, ret, EXIT);
|
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_FOUND, ret, EXIT);
|
||||||
|
|
||||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||||
|
|
|
@ -102,18 +102,34 @@ UINT32 SwtmrCountGetTest(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern LosQueueCB *g_allQueue;
|
extern LosQueueCB *g_allQueue;
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
extern LosQueueCB *g_staticQueue;
|
||||||
|
#endif
|
||||||
|
|
||||||
UINT32 QueueUsedCountGet(VOID)
|
UINT32 QueueUsedCountGet(VOID)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
UINT32 count = 0;
|
UINT32 count = 0;
|
||||||
|
UINT32 index;
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
for (UINT32 index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
|
for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
|
||||||
LosQueueCB *queueNode = ((LosQueueCB *)g_allQueue) + index;
|
LosQueueCB *queueNode = ((LosQueueCB *)g_allQueue) + index;
|
||||||
if (queueNode->queueState == OS_QUEUE_INUSED) {
|
if (queueNode->queueState == OS_QUEUE_INUSED) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||||
|
for (index = 0; index < LOSCFG_BASE_IPC_STATIC_QUEUE_LIMIT; index++) {
|
||||||
|
LosQueueCB *queueNode = ((LosQueueCB *)g_staticQueue) + index;
|
||||||
|
if (queueNode->queueState == OS_QUEUE_INUSED) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
Loading…
Reference in New Issue