* Allocate an IPC message from the statically-allocated array. */
| 63 | * Allocate an IPC message from the statically-allocated array. |
| 64 | */ |
| 65 | static rt_ipc_msg_t _ipc_msg_alloc(void) |
| 66 | { |
| 67 | rt_ipc_msg_t p = (rt_ipc_msg_t)RT_NULL; |
| 68 | rt_base_t level; |
| 69 | |
| 70 | level = rt_spin_lock_irqsave(&_msg_list_lock); |
| 71 | if (_ipc_msg_free_list) /* use the released chain first */ |
| 72 | { |
| 73 | p = _ipc_msg_free_list; |
| 74 | _ipc_msg_free_list = (rt_ipc_msg_t)p->msg.sender; /* emtry payload as a pointer */ |
| 75 | } |
| 76 | else if (rt_ipc_msg_used < RT_CH_MSG_MAX_NR) |
| 77 | { |
| 78 | p = &ipc_msg_pool[rt_ipc_msg_used]; |
| 79 | rt_ipc_msg_used++; |
| 80 | } |
| 81 | rt_spin_unlock_irqrestore(&_msg_list_lock, level); |
| 82 | return p; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Put a released IPC message back to the released chain. |
no test coverage detected