MCPcopy Create free account
hub / github.com/ARMmbed/DAPLink / osRtxMessageQueuePostProcess

Function osRtxMessageQueuePostProcess

source/rtos2/RTX/Source/rtx_msgqueue.c:163–231  ·  view source on GitHub ↗

Message Queue post ISR processing. \param[in] msg message object.

Source from the content-addressed store, hash-verified

161/// Message Queue post ISR processing.
162/// \param[in] msg message object.
163static void osRtxMessageQueuePostProcess (os_message_t *msg) {
164 os_message_queue_t *mq;
165 os_message_t *msg0;
166 os_thread_t *thread;
167 const uint32_t *reg;
168 const void *ptr_src;
169 void *ptr_dst;
170
171 if (msg->flags != 0U) {
172 // Remove Message
173 //lint -e{9079} -e{9087} "cast between pointers to different object types"
174 mq = *((os_message_queue_t **)(void *)&msg[1]);
175 MessageQueueRemove(mq, msg);
176 // Free memory
177 msg->id = osRtxIdInvalid;
178 (void)osRtxMemoryPoolFree(&mq->mp_info, msg);
179 // Check if Thread is waiting to send a Message
180 if (mq->thread_list != NULL) {
181 // Try to allocate memory
182 //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5]
183 msg0 = osRtxMemoryPoolAlloc(&mq->mp_info);
184 if (msg0 != NULL) {
185 // Wakeup waiting Thread with highest Priority
186 thread = osRtxThreadListGet(osRtxObject(mq));
187 osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE);
188 // Copy Message (R2: const void *msg_ptr, R3: uint8_t msg_prio)
189 reg = osRtxThreadRegPtr(thread);
190 //lint -e{923} "cast from unsigned int to pointer"
191 ptr_src = (const void *)reg[2];
192 memcpy(&msg0[1], ptr_src, mq->msg_size);
193 // Store Message into Queue
194 msg0->id = osRtxIdMessage;
195 msg0->flags = 0U;
196 msg0->priority = (uint8_t)reg[3];
197 MessageQueuePut(mq, msg0);
198 EvrRtxMessageQueueInserted(mq, ptr_src);
199 }
200 }
201 } else {
202 // New Message
203 //lint -e{9079} -e{9087} "cast between pointers to different object types"
204 mq = (void *)msg->next;
205 //lint -e{9087} "cast between pointers to different object types"
206 ptr_src = (const void *)msg->prev;
207 // Check if Thread is waiting to receive a Message
208 if ((mq->thread_list != NULL) && (mq->thread_list->state == osRtxThreadWaitingMessageGet)) {
209 EvrRtxMessageQueueInserted(mq, ptr_src);
210 // Wakeup waiting Thread with highest Priority
211 thread = osRtxThreadListGet(osRtxObject(mq));
212 osRtxThreadWaitExit(thread, (uint32_t)osOK, FALSE);
213 // Copy Message (R2: void *msg_ptr, R3: uint8_t *msg_prio)
214 reg = osRtxThreadRegPtr(thread);
215 //lint -e{923} "cast from unsigned int to pointer"
216 ptr_dst = (void *)reg[2];
217 memcpy(ptr_dst, &msg[1], mq->msg_size);
218 if (reg[3] != 0U) {
219 //lint -e{923} -e{9078} "cast from unsigned int to pointer"
220 *((uint8_t *)reg[3]) = msg->priority;

Callers

nothing calls this directly

Calls 9

MessageQueueRemoveFunction · 0.85
osRtxMemoryPoolFreeFunction · 0.85
osRtxMemoryPoolAllocFunction · 0.85
osRtxThreadListGetFunction · 0.85
osRtxThreadWaitExitFunction · 0.85
osRtxThreadRegPtrFunction · 0.85
MessageQueuePutFunction · 0.85

Tested by

no test coverage detected