SysLink API Reference  2.21.03.11
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MessageQ.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * */
32 
136 #ifndef ti_ipc_MessageQ__include
137 #define ti_ipc_MessageQ__include
138 
139 #include <ti/ipc/MultiProc.h>
140 
141 #if defined (__cplusplus)
142 extern "C" {
143 #endif
144 
145 /* =============================================================================
146  * All success and failure codes for the module
147  * =============================================================================
148  */
149 
153 #define MessageQ_S_BUSY 2
154 
158 #define MessageQ_S_ALREADYSETUP 1
159 
163 #define MessageQ_S_SUCCESS 0
164 
168 #define MessageQ_E_FAIL -1
169 
173 #define MessageQ_E_INVALIDARG -2
174 
178 #define MessageQ_E_MEMORY -3
179 
183 #define MessageQ_E_ALREADYEXISTS -4
184 
188 #define MessageQ_E_NOTFOUND -5
189 
193 #define MessageQ_E_TIMEOUT -6
194 
198 #define MessageQ_E_INVALIDSTATE -7
199 
203 #define MessageQ_E_OSFAILURE -8
204 
208 #define MessageQ_E_RESOURCE -9
209 
213 #define MessageQ_E_RESTART -10
214 
218 #define MessageQ_E_INVALIDMSG -11
219 
223 #define MessageQ_E_NOTOWNER -12
224 
228 #define MessageQ_E_REMOTEACTIVE -13
229 
233 #define MessageQ_E_INVALIDHEAPID -14
234 
238 #define MessageQ_E_INVALIDPROCID -15
239 
243 #define MessageQ_E_MAXREACHED -16
244 
248 #define MessageQ_E_UNREGISTEREDHEAPID -17
249 
253 #define MessageQ_E_CANNOTFREESTATICMSG -18
254 
258 #define MessageQ_E_UNBLOCKED -19
259 
260 /* =============================================================================
261  * Macros
262  * =============================================================================
263  */
264 
268 #define MessageQ_FOREVER ~(0)
269 
273 #define MessageQ_INVALIDMSGID 0xffff
274 
278 #define MessageQ_INVALIDMESSAGEQ 0xffff
279 
283 #define MessageQ_PRIORITYMASK 0x3
284 
295 #define MessageQ_getDstQueue(msg) \
296  ((msg)->dstId == (MessageQ_QueueIndex)MessageQ_INVALIDMESSAGEQ) ? \
297  (MessageQ_QueueId)MessageQ_INVALIDMESSAGEQ : \
298  (MessageQ_QueueId)(((MessageQ_QueueId)MultiProc_self() << 16u) \
299  | (((MessageQ_Msg)(msg))->dstId))
300 
301 
316 #define MessageQ_getMsgId(msg) (((MessageQ_Msg) (msg))->msgId)
317 
326 #define MessageQ_getMsgSize(msg) (((MessageQ_Msg) (msg))->msgSize)
327 
335 #define MessageQ_getMsgPri(msg) \
336  ((((MessageQ_Msg) (msg))->flags & MessageQ_PRIORITYMASK))
337 
348 #define MessageQ_getProcId(queueId) \
349  ((UInt16)((queueId) >> 16))
350 
368 #define MessageQ_getReplyQueue(msg) \
369  (MessageQ_QueueId)((((MessageQ_Msg) (msg))->replyProc << 16u) \
370  | ((MessageQ_Msg)(msg))->replyId)
371 
384 #define MessageQ_setMsgId(msg, id) ((MessageQ_Msg) (msg))->msgId = (id)
385 
392 #define MessageQ_setMsgPri(msg, priority) \
393  (((MessageQ_Msg) (msg))->flags = ((priority) & MessageQ_PRIORITYMASK))
394 
395 /* =============================================================================
396  * Structures & Enums
397  * =============================================================================
398  */
399 
404 
409 
413 typedef struct MessageQ_Object *MessageQ_Handle;
414 
418 typedef struct {
419  Void *synchronizer;
429 
433 typedef struct {
448 
453 
457 typedef enum {
463 
464 
465 /* =============================================================================
466  * MessageQ Module-wide Functions
467  * =============================================================================
468  */
469 
476 
493 MessageQ_Handle MessageQ_create(String name, const MessageQ_Params *params);
494 
508 Int MessageQ_delete(MessageQ_Handle *handlePtr);
509 
527 Int MessageQ_open(String name, MessageQ_QueueId *queueId);
528 
540 Int MessageQ_close(MessageQ_QueueId *queueId);
541 
564 MessageQ_Msg MessageQ_alloc(UInt16 heapId, UInt32 size);
565 
577 Int MessageQ_free(MessageQ_Msg msg);
578 
606 Int MessageQ_registerHeap(Ptr heap, UInt16 heapId);
607 
622 
633 Void MessageQ_setMsgTrace(MessageQ_Msg msg, Bool traceFlag);
634 
659 Void MessageQ_staticMsgInit(MessageQ_Msg msg, UInt32 size);
660 
661 /* =============================================================================
662  * MessageQ Per-instance Functions
663  * =============================================================================
664  */
665 
695 Int MessageQ_get(MessageQ_Handle handle, MessageQ_Msg *msg, UInt timeout);
696 
725 Int MessageQ_put(MessageQ_QueueId queueId, MessageQ_Msg msg);
726 
736 Int MessageQ_count(MessageQ_Handle handle);
737 
750 UInt32 MessageQ_getQueueId(MessageQ_Handle handle);
751 
769 Void MessageQ_setReplyQueue(MessageQ_Handle handle, MessageQ_Msg msg);
770 
797 Void MessageQ_unblock(MessageQ_Handle handle);
798 
799 #if defined (__cplusplus)
800 }
801 #endif /* defined (__cplusplus) */
802 #endif /* ti_ipc_MessageQ__include */
803 
804 /*
805  */
806 
807 /*
808  * @(#) ti.ipc; 1, 0, 0, 0,; 11-7-2012 13:07:52; /db/vtree/library/trees/ipc/ipc-i09/src/ xlibrary
809 
810  */
811 
Copyright 2014, Texas Instruments Incorporated