Project  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MessageQ.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, 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 
403 typedef UInt32 MessageQ_QueueId;
404 
408 typedef UInt16 MessageQ_QueueIndex;
409 
413 typedef struct MessageQ_Object *MessageQ_Handle;
414 
418 typedef struct {
419  Void *synchronizer;
429 
436 typedef struct {
437  Void *synchronizer;
446  MessageQ_QueueIndex queueIndex;
462 
466 typedef struct {
467  Bits32 reserved0;
468  Bits32 reserved1;
469  Bits32 msgSize;
470  Bits16 flags;
471  Bits16 msgId;
472  Bits16 dstId;
473  Bits16 dstProc;
474  Bits16 replyId;
475  Bits16 replyProc;
476  Bits16 srcProc;
477  Bits16 heapId;
478  Bits16 seqNum;
479  Bits16 reserved;
481 
486 
490 typedef enum {
496 
503 #define MessageQ_ANY (Bits16)~(0)
504 
511 typedef Void (*MessageQ_FreeHookFxn)(Bits16 heapId, Bits16 msgId);
512 
513 /* =============================================================================
514  * MessageQ Module-wide Functions
515  * =============================================================================
516  */
517 
524 
531 
548 MessageQ_Handle MessageQ_create(String name, const MessageQ_Params *params);
549 
566 MessageQ_Handle MessageQ_create2(String name, const MessageQ_Params2 *params);
567 
581 Int MessageQ_delete(MessageQ_Handle *handlePtr);
582 
600 Int MessageQ_open(String name, MessageQ_QueueId *queueId);
601 
635 MessageQ_QueueId MessageQ_openQueueId(UInt16 queueIndex, UInt16 remoteProcId);
636 
648 Int MessageQ_close(MessageQ_QueueId *queueId);
649 
672 MessageQ_Msg MessageQ_alloc(UInt16 heapId, UInt32 size);
673 
685 Int MessageQ_free(MessageQ_Msg msg);
686 
714 Int MessageQ_registerHeap(Ptr heap, UInt16 heapId);
715 
729 Int MessageQ_unregisterHeap(UInt16 heapId);
730 
741 Void MessageQ_setMsgTrace(MessageQ_Msg msg, Bool traceFlag);
742 
767 Void MessageQ_staticMsgInit(MessageQ_Msg msg, UInt32 size);
768 
788 
789 /* =============================================================================
790  * MessageQ Per-instance Functions
791  * =============================================================================
792  */
793 
823 Int MessageQ_get(MessageQ_Handle handle, MessageQ_Msg *msg, UInt timeout);
824 
853 Int MessageQ_put(MessageQ_QueueId queueId, MessageQ_Msg msg);
854 
864 Int MessageQ_count(MessageQ_Handle handle);
865 
878 UInt32 MessageQ_getQueueId(MessageQ_Handle handle);
879 
897 Void MessageQ_setReplyQueue(MessageQ_Handle handle, MessageQ_Msg msg);
898 
925 Void MessageQ_unblock(MessageQ_Handle handle);
926 
927 #if defined (__cplusplus)
928 }
929 #endif /* defined (__cplusplus) */
930 #endif /* ti_ipc_MessageQ__include */
931 
932 /*
933  */
934 
935 /*
936  * @(#) ti.ipc; 1, 0, 0, 0,; 5-10-2013 12:29:02; /db/vtree/library/trees/ipc/ipc-i15/src/ xlibrary
937 
938  */
939 
Copyright 2013, Texas Instruments Incorporated