IPC API  3.00.04.29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MessageQ.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-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 
133 #ifndef ti_ipc_MessageQ__include
134 #define ti_ipc_MessageQ__include
135 
136 #include <ti/ipc/MultiProc.h>
137 
138 #if defined (__cplusplus)
139 extern "C" {
140 #endif
141 
142 /* =============================================================================
143  * All success and failure codes for the module
144  * =============================================================================
145  */
146 
150 #define MessageQ_S_BUSY 2
151 
155 #define MessageQ_S_ALREADYSETUP 1
156 
160 #define MessageQ_S_SUCCESS 0
161 
165 #define MessageQ_E_FAIL -1
166 
170 #define MessageQ_E_INVALIDARG -2
171 
175 #define MessageQ_E_MEMORY -3
176 
180 #define MessageQ_E_ALREADYEXISTS -4
181 
185 #define MessageQ_E_NOTFOUND -5
186 
190 #define MessageQ_E_TIMEOUT -6
191 
195 #define MessageQ_E_INVALIDSTATE -7
196 
200 #define MessageQ_E_OSFAILURE -8
201 
205 #define MessageQ_E_RESOURCE -9
206 
210 #define MessageQ_E_RESTART -10
211 
215 #define MessageQ_E_INVALIDMSG -11
216 
220 #define MessageQ_E_NOTOWNER -12
221 
225 #define MessageQ_E_REMOTEACTIVE -13
226 
230 #define MessageQ_E_INVALIDHEAPID -14
231 
235 #define MessageQ_E_INVALIDPROCID -15
236 
240 #define MessageQ_E_MAXREACHED -16
241 
245 #define MessageQ_E_UNREGISTEREDHEAPID -17
246 
250 #define MessageQ_E_CANNOTFREESTATICMSG -18
251 
255 #define MessageQ_E_UNBLOCKED -19
256 
257 /* =============================================================================
258  * Macros
259  * =============================================================================
260  */
261 
265 #define MessageQ_FOREVER ~(0)
266 
270 #define MessageQ_INVALIDMSGID 0xffff
271 
275 #define MessageQ_INVALIDMESSAGEQ 0xffff
276 
280 #define MessageQ_PRIORITYMASK 0x3
281 
292 #define MessageQ_getDstQueue(msg) \
293  ((msg)->dstId == (MessageQ_QueueIndex)MessageQ_INVALIDMESSAGEQ) ? \
294  (MessageQ_QueueId)MessageQ_INVALIDMESSAGEQ : \
295  (MessageQ_QueueId)(((MessageQ_QueueId)MultiProc_self() << 16u) \
296  | (((MessageQ_Msg)(msg))->dstId))
297 
298 
313 #define MessageQ_getMsgId(msg) (((MessageQ_Msg) (msg))->msgId)
314 
323 #define MessageQ_getMsgSize(msg) (((MessageQ_Msg) (msg))->msgSize)
324 
332 #define MessageQ_getMsgPri(msg) \
333  ((((MessageQ_Msg) (msg))->flags & MessageQ_PRIORITYMASK))
334 
345 #define MessageQ_getProcId(queueId) \
346  ((UInt16)((queueId) >> 16))
347 
365 #define MessageQ_getReplyQueue(msg) \
366  (MessageQ_QueueId)((((MessageQ_Msg) (msg))->replyProc << 16u) \
367  | ((MessageQ_Msg)(msg))->replyId)
368 
381 #define MessageQ_setMsgId(msg, id) ((MessageQ_Msg) (msg))->msgId = (id)
382 
389 #define MessageQ_setMsgPri(msg, priority) \
390  (((MessageQ_Msg) (msg))->flags = ((priority) & MessageQ_PRIORITYMASK))
391 
392 /* =============================================================================
393  * Structures & Enums
394  * =============================================================================
395  */
396 
400 typedef UInt32 MessageQ_QueueId;
401 
405 typedef UInt16 MessageQ_QueueIndex;
406 
410 typedef struct MessageQ_Object *MessageQ_Handle;
411 
415 typedef struct {
416  Void *synchronizer;
426 
430 typedef struct {
431  Bits32 reserved0;
432  Bits32 reserved1;
433  Bits32 msgSize;
434  Bits16 flags;
435  Bits16 msgId;
436  Bits16 dstId;
437  Bits16 dstProc;
438  Bits16 replyId;
439  Bits16 replyProc;
440  Bits16 srcProc;
441  Bits16 heapId;
442  Bits16 seqNum;
443  Bits16 reserved;
445 
450 
454 typedef enum {
460 
461 
462 /* =============================================================================
463  * MessageQ Module-wide Functions
464  * =============================================================================
465  */
466 
473 
490 MessageQ_Handle MessageQ_create(String name, const MessageQ_Params *params);
491 
505 Int MessageQ_delete(MessageQ_Handle *handlePtr);
506 
524 Int MessageQ_open(String name, MessageQ_QueueId *queueId);
525 
537 Int MessageQ_close(MessageQ_QueueId *queueId);
538 
561 MessageQ_Msg MessageQ_alloc(UInt16 heapId, UInt32 size);
562 
574 Int MessageQ_free(MessageQ_Msg msg);
575 
603 Int MessageQ_registerHeap(Ptr heap, UInt16 heapId);
604 
618 Int MessageQ_unregisterHeap(UInt16 heapId);
619 
630 Void MessageQ_setMsgTrace(MessageQ_Msg msg, Bool traceFlag);
631 
656 Void MessageQ_staticMsgInit(MessageQ_Msg msg, UInt32 size);
657 
658 /* =============================================================================
659  * MessageQ Per-instance Functions
660  * =============================================================================
661  */
662 
692 Int MessageQ_get(MessageQ_Handle handle, MessageQ_Msg *msg, UInt timeout);
693 
722 Int MessageQ_put(MessageQ_QueueId queueId, MessageQ_Msg msg);
723 
733 Int MessageQ_count(MessageQ_Handle handle);
734 
747 UInt32 MessageQ_getQueueId(MessageQ_Handle handle);
748 
766 Void MessageQ_setReplyQueue(MessageQ_Handle handle, MessageQ_Msg msg);
767 
794 Void MessageQ_unblock(MessageQ_Handle handle);
795 
796 #if defined (__cplusplus)
797 }
798 #endif /* defined (__cplusplus) */
799 #endif /* ti_ipc_MessageQ__include */
Copyright 2013, Texas Instruments Incorporated