|
@@ -68,7 +68,7 @@ extern void (*rt_object_put_hook)(struct rt_object *object);
|
|
|
*
|
|
|
* @warning This function can be called from all IPC initialization and creation.
|
|
|
*/
|
|
|
-rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
|
|
|
+rt_inline rt_err_t _ipc_object_init(struct rt_ipc_object *ipc)
|
|
|
{
|
|
|
/* initialize ipc object */
|
|
|
rt_list_init(&(ipc->suspend_thread));
|
|
@@ -106,9 +106,9 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
|
|
|
* rt_sem_take(), rt_mutex_take(), rt_event_recv(), rt_mb_send_wait(),
|
|
|
* rt_mb_recv(), rt_mq_recv(), rt_mq_send_wait()
|
|
|
*/
|
|
|
-rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list,
|
|
|
- struct rt_thread *thread,
|
|
|
- rt_uint8_t flag)
|
|
|
+rt_inline rt_err_t _ipc_list_suspend(rt_list_t *list,
|
|
|
+ struct rt_thread *thread,
|
|
|
+ rt_uint8_t flag)
|
|
|
{
|
|
|
/* suspend thread */
|
|
|
rt_thread_suspend(thread);
|
|
@@ -175,7 +175,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list,
|
|
|
* rt_sem_release(), rt_mutex_release(), rt_mb_send_wait(), rt_mq_send_wait(),
|
|
|
* rt_mb_urgent(), rt_mb_recv(), rt_mq_urgent(), rt_mq_recv(),
|
|
|
*/
|
|
|
-rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list)
|
|
|
+rt_inline rt_err_t _ipc_list_resume(rt_list_t *list)
|
|
|
{
|
|
|
struct rt_thread *thread;
|
|
|
|
|
@@ -204,7 +204,7 @@ rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list)
|
|
|
* When the return value is any other values, it means this operation failed.
|
|
|
*
|
|
|
*/
|
|
|
-rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
|
|
|
+rt_inline rt_err_t _ipc_list_resume_all(rt_list_t *list)
|
|
|
{
|
|
|
struct rt_thread *thread;
|
|
|
register rt_ubase_t temp;
|
|
@@ -292,7 +292,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
|
|
|
rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(sem->parent));
|
|
|
+ _ipc_object_init(&(sem->parent));
|
|
|
|
|
|
/* set initial value */
|
|
|
sem->value = (rt_uint16_t)value;
|
|
@@ -331,7 +331,7 @@ rt_err_t rt_sem_detach(rt_sem_t sem)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent));
|
|
|
|
|
|
/* wakeup all suspended threads */
|
|
|
- rt_ipc_list_resume_all(&(sem->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(sem->parent.suspend_thread));
|
|
|
|
|
|
/* detach semaphore object */
|
|
|
rt_object_detach(&(sem->parent.parent));
|
|
@@ -386,7 +386,7 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag)
|
|
|
return sem;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(sem->parent));
|
|
|
+ _ipc_object_init(&(sem->parent));
|
|
|
|
|
|
/* set initial value */
|
|
|
sem->value = value;
|
|
@@ -427,7 +427,7 @@ rt_err_t rt_sem_delete(rt_sem_t sem)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE);
|
|
|
|
|
|
/* wakeup all suspended threads */
|
|
|
- rt_ipc_list_resume_all(&(sem->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(sem->parent.suspend_thread));
|
|
|
|
|
|
/* delete semaphore object */
|
|
|
rt_object_delete(&(sem->parent.parent));
|
|
@@ -513,7 +513,7 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
|
|
|
thread->name));
|
|
|
|
|
|
/* suspend thread */
|
|
|
- rt_ipc_list_suspend(&(sem->parent.suspend_thread),
|
|
|
+ _ipc_list_suspend(&(sem->parent.suspend_thread),
|
|
|
thread,
|
|
|
sem->parent.parent.flag);
|
|
|
|
|
@@ -607,7 +607,7 @@ rt_err_t rt_sem_release(rt_sem_t sem)
|
|
|
if (!rt_list_isempty(&sem->parent.suspend_thread))
|
|
|
{
|
|
|
/* resume the suspended thread */
|
|
|
- rt_ipc_list_resume(&(sem->parent.suspend_thread));
|
|
|
+ _ipc_list_resume(&(sem->parent.suspend_thread));
|
|
|
need_schedule = RT_TRUE;
|
|
|
}
|
|
|
else
|
|
@@ -667,7 +667,7 @@ rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg)
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
|
|
/* resume all waiting thread */
|
|
|
- rt_ipc_list_resume_all(&sem->parent.suspend_thread);
|
|
|
+ _ipc_list_resume_all(&sem->parent.suspend_thread);
|
|
|
|
|
|
/* set new value */
|
|
|
sem->value = (rt_uint16_t)value;
|
|
@@ -730,7 +730,7 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag)
|
|
|
rt_object_init(&(mutex->parent.parent), RT_Object_Class_Mutex, name);
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(mutex->parent));
|
|
|
+ _ipc_object_init(&(mutex->parent));
|
|
|
|
|
|
mutex->value = 1;
|
|
|
mutex->owner = RT_NULL;
|
|
@@ -771,7 +771,7 @@ rt_err_t rt_mutex_detach(rt_mutex_t mutex)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent));
|
|
|
|
|
|
/* wakeup all suspended threads */
|
|
|
- rt_ipc_list_resume_all(&(mutex->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(mutex->parent.suspend_thread));
|
|
|
|
|
|
/* detach mutex object */
|
|
|
rt_object_detach(&(mutex->parent.parent));
|
|
@@ -813,7 +813,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag)
|
|
|
return mutex;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(mutex->parent));
|
|
|
+ _ipc_object_init(&(mutex->parent));
|
|
|
|
|
|
mutex->value = 1;
|
|
|
mutex->owner = RT_NULL;
|
|
@@ -856,7 +856,7 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE);
|
|
|
|
|
|
/* wakeup all suspended threads */
|
|
|
- rt_ipc_list_resume_all(&(mutex->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(mutex->parent.suspend_thread));
|
|
|
|
|
|
/* delete mutex object */
|
|
|
rt_object_delete(&(mutex->parent.parent));
|
|
@@ -985,7 +985,7 @@ __again:
|
|
|
}
|
|
|
|
|
|
/* suspend current thread */
|
|
|
- rt_ipc_list_suspend(&(mutex->parent.suspend_thread),
|
|
|
+ _ipc_list_suspend(&(mutex->parent.suspend_thread),
|
|
|
thread,
|
|
|
mutex->parent.parent.flag);
|
|
|
|
|
@@ -1150,7 +1150,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
|
|
|
}
|
|
|
|
|
|
/* resume thread */
|
|
|
- rt_ipc_list_resume(&(mutex->parent.suspend_thread));
|
|
|
+ _ipc_list_resume(&(mutex->parent.suspend_thread));
|
|
|
|
|
|
need_schedule = RT_TRUE;
|
|
|
}
|
|
@@ -1269,7 +1269,7 @@ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag)
|
|
|
event->parent.parent.flag = flag;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(event->parent));
|
|
|
+ _ipc_object_init(&(event->parent));
|
|
|
|
|
|
/* initialize event */
|
|
|
event->set = 0;
|
|
@@ -1305,7 +1305,7 @@ rt_err_t rt_event_detach(rt_event_t event)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&event->parent.parent));
|
|
|
|
|
|
/* resume all suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(event->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(event->parent.suspend_thread));
|
|
|
|
|
|
/* detach event object */
|
|
|
rt_object_detach(&(event->parent.parent));
|
|
@@ -1358,7 +1358,7 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag)
|
|
|
event->parent.parent.flag = flag;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(event->parent));
|
|
|
+ _ipc_object_init(&(event->parent));
|
|
|
|
|
|
/* initialize event */
|
|
|
event->set = 0;
|
|
@@ -1396,7 +1396,7 @@ rt_err_t rt_event_delete(rt_event_t event)
|
|
|
RT_DEBUG_NOT_IN_INTERRUPT;
|
|
|
|
|
|
/* resume all suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(event->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(event->parent.suspend_thread));
|
|
|
|
|
|
/* delete event object */
|
|
|
rt_object_delete(&(event->parent.parent));
|
|
@@ -1628,7 +1628,7 @@ rt_err_t rt_event_recv(rt_event_t event,
|
|
|
thread->event_info = option;
|
|
|
|
|
|
/* put thread to suspended thread list */
|
|
|
- rt_ipc_list_suspend(&(event->parent.suspend_thread),
|
|
|
+ _ipc_list_suspend(&(event->parent.suspend_thread),
|
|
|
thread,
|
|
|
event->parent.parent.flag);
|
|
|
|
|
@@ -1700,7 +1700,7 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg)
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
|
|
/* resume all waiting thread */
|
|
|
- rt_ipc_list_resume_all(&event->parent.suspend_thread);
|
|
|
+ _ipc_list_resume_all(&event->parent.suspend_thread);
|
|
|
|
|
|
/* initialize event set */
|
|
|
event->set = 0;
|
|
@@ -1781,7 +1781,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb,
|
|
|
mb->parent.parent.flag = flag;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(mb->parent));
|
|
|
+ _ipc_object_init(&(mb->parent));
|
|
|
|
|
|
/* initialize mailbox */
|
|
|
mb->msg_pool = (rt_ubase_t *)msgpool;
|
|
@@ -1824,9 +1824,9 @@ rt_err_t rt_mb_detach(rt_mailbox_t mb)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent));
|
|
|
|
|
|
/* resume all suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(mb->parent.suspend_thread));
|
|
|
/* also resume all mailbox private suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
|
|
|
+ _ipc_list_resume_all(&(mb->suspend_sender_thread));
|
|
|
|
|
|
/* detach mailbox object */
|
|
|
rt_object_detach(&(mb->parent.parent));
|
|
@@ -1882,7 +1882,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
|
|
|
mb->parent.parent.flag = flag;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(mb->parent));
|
|
|
+ _ipc_object_init(&(mb->parent));
|
|
|
|
|
|
/* initialize mailbox */
|
|
|
mb->size = size;
|
|
@@ -1934,10 +1934,10 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent) == RT_FALSE);
|
|
|
|
|
|
/* resume all suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(mb->parent.suspend_thread));
|
|
|
|
|
|
/* also resume all mailbox private suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
|
|
|
+ _ipc_list_resume_all(&(mb->suspend_sender_thread));
|
|
|
|
|
|
/* free mailbox pool */
|
|
|
RT_KERNEL_FREE(mb->msg_pool);
|
|
@@ -2020,7 +2020,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
|
|
|
|
|
|
RT_DEBUG_IN_THREAD_CONTEXT;
|
|
|
/* suspend current thread */
|
|
|
- rt_ipc_list_suspend(&(mb->suspend_sender_thread),
|
|
|
+ _ipc_list_suspend(&(mb->suspend_sender_thread),
|
|
|
thread,
|
|
|
mb->parent.parent.flag);
|
|
|
|
|
@@ -2087,7 +2087,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
|
|
|
/* resume suspended thread */
|
|
|
if (!rt_list_isempty(&mb->parent.suspend_thread))
|
|
|
{
|
|
|
- rt_ipc_list_resume(&(mb->parent.suspend_thread));
|
|
|
+ _ipc_list_resume(&(mb->parent.suspend_thread));
|
|
|
|
|
|
/* enable interrupt */
|
|
|
rt_hw_interrupt_enable(temp);
|
|
@@ -2183,7 +2183,7 @@ rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value)
|
|
|
/* resume suspended thread */
|
|
|
if (!rt_list_isempty(&mb->parent.suspend_thread))
|
|
|
{
|
|
|
- rt_ipc_list_resume(&(mb->parent.suspend_thread));
|
|
|
+ _ipc_list_resume(&(mb->parent.suspend_thread));
|
|
|
|
|
|
/* enable interrupt */
|
|
|
rt_hw_interrupt_enable(temp);
|
|
@@ -2266,7 +2266,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
|
|
|
|
|
|
RT_DEBUG_IN_THREAD_CONTEXT;
|
|
|
/* suspend current thread */
|
|
|
- rt_ipc_list_suspend(&(mb->parent.suspend_thread),
|
|
|
+ _ipc_list_suspend(&(mb->parent.suspend_thread),
|
|
|
thread,
|
|
|
mb->parent.parent.flag);
|
|
|
|
|
@@ -2329,7 +2329,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
|
|
|
/* resume suspended thread */
|
|
|
if (!rt_list_isempty(&(mb->suspend_sender_thread)))
|
|
|
{
|
|
|
- rt_ipc_list_resume(&(mb->suspend_sender_thread));
|
|
|
+ _ipc_list_resume(&(mb->suspend_sender_thread));
|
|
|
|
|
|
/* enable interrupt */
|
|
|
rt_hw_interrupt_enable(temp);
|
|
@@ -2379,9 +2379,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg)
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
|
|
/* resume all waiting thread */
|
|
|
- rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(mb->parent.suspend_thread));
|
|
|
/* also resume all mailbox private suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
|
|
|
+ _ipc_list_resume_all(&(mb->suspend_sender_thread));
|
|
|
|
|
|
/* re-init mailbox */
|
|
|
mb->entry = 0;
|
|
@@ -2478,7 +2478,7 @@ rt_err_t rt_mq_init(rt_mq_t mq,
|
|
|
mq->parent.parent.flag = flag;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(mq->parent));
|
|
|
+ _ipc_object_init(&(mq->parent));
|
|
|
|
|
|
/* set message pool */
|
|
|
mq->msg_pool = msgpool;
|
|
@@ -2538,9 +2538,9 @@ rt_err_t rt_mq_detach(rt_mq_t mq)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent));
|
|
|
|
|
|
/* resume all suspended thread */
|
|
|
- rt_ipc_list_resume_all(&mq->parent.suspend_thread);
|
|
|
+ _ipc_list_resume_all(&mq->parent.suspend_thread);
|
|
|
/* also resume all message queue private suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mq->suspend_sender_thread));
|
|
|
+ _ipc_list_resume_all(&(mq->suspend_sender_thread));
|
|
|
|
|
|
/* detach message queue object */
|
|
|
rt_object_detach(&(mq->parent.parent));
|
|
@@ -2602,7 +2602,7 @@ rt_mq_t rt_mq_create(const char *name,
|
|
|
mq->parent.parent.flag = flag;
|
|
|
|
|
|
/* initialize ipc object */
|
|
|
- rt_ipc_object_init(&(mq->parent));
|
|
|
+ _ipc_object_init(&(mq->parent));
|
|
|
|
|
|
/* initialize message queue */
|
|
|
|
|
@@ -2673,9 +2673,9 @@ rt_err_t rt_mq_delete(rt_mq_t mq)
|
|
|
RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent) == RT_FALSE);
|
|
|
|
|
|
/* resume all suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mq->parent.suspend_thread));
|
|
|
+ _ipc_list_resume_all(&(mq->parent.suspend_thread));
|
|
|
/* also resume all message queue private suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mq->suspend_sender_thread));
|
|
|
+ _ipc_list_resume_all(&(mq->suspend_sender_thread));
|
|
|
|
|
|
/* free message queue pool */
|
|
|
RT_KERNEL_FREE(mq->msg_pool);
|
|
@@ -2776,7 +2776,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq,
|
|
|
|
|
|
RT_DEBUG_IN_THREAD_CONTEXT;
|
|
|
/* suspend current thread */
|
|
|
- rt_ipc_list_suspend(&(mq->suspend_sender_thread),
|
|
|
+ _ipc_list_suspend(&(mq->suspend_sender_thread),
|
|
|
thread,
|
|
|
mq->parent.parent.flag);
|
|
|
|
|
@@ -2862,7 +2862,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq,
|
|
|
/* resume suspended thread */
|
|
|
if (!rt_list_isempty(&mq->parent.suspend_thread))
|
|
|
{
|
|
|
- rt_ipc_list_resume(&(mq->parent.suspend_thread));
|
|
|
+ _ipc_list_resume(&(mq->parent.suspend_thread));
|
|
|
|
|
|
/* enable interrupt */
|
|
|
rt_hw_interrupt_enable(temp);
|
|
@@ -2991,7 +2991,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size)
|
|
|
/* resume suspended thread */
|
|
|
if (!rt_list_isempty(&mq->parent.suspend_thread))
|
|
|
{
|
|
|
- rt_ipc_list_resume(&(mq->parent.suspend_thread));
|
|
|
+ _ipc_list_resume(&(mq->parent.suspend_thread));
|
|
|
|
|
|
/* enable interrupt */
|
|
|
rt_hw_interrupt_enable(temp);
|
|
@@ -3081,7 +3081,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
|
|
|
}
|
|
|
|
|
|
/* suspend current thread */
|
|
|
- rt_ipc_list_suspend(&(mq->parent.suspend_thread),
|
|
|
+ _ipc_list_suspend(&(mq->parent.suspend_thread),
|
|
|
thread,
|
|
|
mq->parent.parent.flag);
|
|
|
|
|
@@ -3157,7 +3157,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
|
|
|
/* resume suspended thread */
|
|
|
if (!rt_list_isempty(&(mq->suspend_sender_thread)))
|
|
|
{
|
|
|
- rt_ipc_list_resume(&(mq->suspend_sender_thread));
|
|
|
+ _ipc_list_resume(&(mq->suspend_sender_thread));
|
|
|
|
|
|
/* enable interrupt */
|
|
|
rt_hw_interrupt_enable(temp);
|
|
@@ -3208,9 +3208,9 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg)
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
|
|
/* resume all waiting thread */
|
|
|
- rt_ipc_list_resume_all(&mq->parent.suspend_thread);
|
|
|
+ _ipc_list_resume_all(&mq->parent.suspend_thread);
|
|
|
/* also resume all message queue private suspended thread */
|
|
|
- rt_ipc_list_resume_all(&(mq->suspend_sender_thread));
|
|
|
+ _ipc_list_resume_all(&(mq->suspend_sender_thread));
|
|
|
|
|
|
/* release all message in the queue */
|
|
|
while (mq->msg_queue_head != RT_NULL)
|