IPC API  3.30.01.12
 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 {
426 
433 typedef struct {
443  MessageQ_QueueIndex queueIndex;
459 
463 typedef struct {
464  Bits32 reserved0;
465  Bits32 reserved1;
466  Bits32 msgSize;
467  Bits16 flags;
468  Bits16 msgId;
469  Bits16 dstId;
470  Bits16 dstProc;
471  Bits16 replyId;
472  Bits16 replyProc;
473  Bits16 srcProc;
474  Bits16 heapId;
475  Bits16 seqNum;
476  Bits16 reserved;
478 
483 
487 typedef enum {
493 
500 #define MessageQ_ANY (Bits16)~(0)
501 
508 typedef Void (*MessageQ_FreeHookFxn)(Bits16 heapId, Bits16 msgId);
509 
510 /* =============================================================================
511  * MessageQ Module-wide Functions
512  * =============================================================================
513  */
514 
521 
528 
545 MessageQ_Handle MessageQ_create(String name, const MessageQ_Params *params);
546 
563 MessageQ_Handle MessageQ_create2(String name, const MessageQ_Params2 *params);
564 
578 Int MessageQ_delete(MessageQ_Handle *handlePtr);
579 
597 Int MessageQ_open(String name, MessageQ_QueueId *queueId);
598 
632 MessageQ_QueueId MessageQ_openQueueId(UInt16 queueIndex, UInt16 remoteProcId);
633 
645 Int MessageQ_close(MessageQ_QueueId *queueId);
646 
669 MessageQ_Msg MessageQ_alloc(UInt16 heapId, UInt32 size);
670 
682 Int MessageQ_free(MessageQ_Msg msg);
683 
711 Int MessageQ_registerHeap(Ptr heap, UInt16 heapId);
712 
726 Int MessageQ_unregisterHeap(UInt16 heapId);
727 
738 Void MessageQ_setMsgTrace(MessageQ_Msg msg, Bool traceFlag);
739 
764 Void MessageQ_staticMsgInit(MessageQ_Msg msg, UInt32 size);
765 
785 
786 /* =============================================================================
787  * MessageQ Per-instance Functions
788  * =============================================================================
789  */
790 
820 Int MessageQ_get(MessageQ_Handle handle, MessageQ_Msg *msg, UInt timeout);
821 
850 Int MessageQ_put(MessageQ_QueueId queueId, MessageQ_Msg msg);
851 
861 Int MessageQ_count(MessageQ_Handle handle);
862 
875 UInt32 MessageQ_getQueueId(MessageQ_Handle handle);
876 
894 Void MessageQ_setReplyQueue(MessageQ_Handle handle, MessageQ_Msg msg);
895 
922 Void MessageQ_unblock(MessageQ_Handle handle);
923 
924 #if defined (__cplusplus)
925 }
926 #endif /* defined (__cplusplus) */
927 #endif /* ti_ipc_MessageQ__include */
Int MessageQ_free(MessageQ_Msg msg)
Frees a message back to the heap.
Bits16 replyProc
Definition: MessageQ.h:472
Bits16 reserved
Definition: MessageQ.h:476
Int MessageQ_get(MessageQ_Handle handle, MessageQ_Msg *msg, UInt timeout)
Gets a message from the message queue.
Void MessageQ_setFreeHookFxn(MessageQ_FreeHookFxn freeHookFxn)
Sets MessageQ&#39;s free hook function.
MessageQ_Priority
Message priority.
Definition: MessageQ.h:487
Structure defining parameters for MessageQ_create().
Definition: MessageQ.h:415
Bits16 dstId
Definition: MessageQ.h:469
Int MessageQ_delete(MessageQ_Handle *handlePtr)
Delete a created MessageQ instance.
MessageQ_Handle MessageQ_create2(String name, const MessageQ_Params2 *params)
Create a MessageQ instance with the MessageQ_Params2 structure.
Int MessageQ_open(String name, MessageQ_QueueId *queueId)
Open a message queue.
Definition: MessageQ.h:491
Int MessageQ_registerHeap(Ptr heap, UInt16 heapId)
Register a heap with MessageQ.
Bits32 msgSize
Definition: MessageQ.h:466
Definition: MessageQ.h:489
Void * synchronizer
Definition: MessageQ.h:416
UInt32 MessageQ_getQueueId(MessageQ_Handle handle)
Returns the QueueId associated with the handle.
UInt16 MessageQ_QueueIndex
Local queue index.
Definition: MessageQ.h:405
MessageQ_MsgHeader * MessageQ_Msg
Typedef for ease of use.
Definition: MessageQ.h:482
Definition: MessageQ.h:488
Bits16 seqNum
Definition: MessageQ.h:475
Void(* MessageQ_FreeHookFxn)(Bits16 heapId, Bits16 msgId)
Free hook prototype.
Definition: MessageQ.h:508
struct MessageQ_Object * MessageQ_Handle
MessageQ_Handle type.
Definition: MessageQ.h:410
Bits16 flags
Definition: MessageQ.h:467
MessageQ_Msg MessageQ_alloc(UInt16 heapId, UInt32 size)
Allocates a message from the heap.
Int MessageQ_count(MessageQ_Handle handle)
Returns the number of messages in a message queue.
Void * synchronizer
Definition: MessageQ.h:434
Processor ID Manager.
Void MessageQ_Params2_init(MessageQ_Params2 *params)
Initialize MessageQ_Params2.
Void MessageQ_unblock(MessageQ_Handle handle)
Unblocks a MessageQ.
UInt32 MessageQ_QueueId
A 32-bit value that uniquely identifies a message queue.
Definition: MessageQ.h:400
Int MessageQ_put(MessageQ_QueueId queueId, MessageQ_Msg msg)
Place a message onto a message queue.
Required first field in every message.
Definition: MessageQ.h:463
Bits16 heapId
Definition: MessageQ.h:474
Void MessageQ_Params_init(MessageQ_Params *params)
Initialize MessageQ_Params.
MessageQ_QueueIndex queueIndex
Definition: MessageQ.h:443
Structure defining parameters for MessageQ_create2().
Definition: MessageQ.h:433
Int MessageQ_unregisterHeap(UInt16 heapId)
Unregister a heap with MessageQ.
Definition: MessageQ.h:490
Int MessageQ_close(MessageQ_QueueId *queueId)
Close the opened handle.
Bits32 reserved1
Definition: MessageQ.h:465
Bits16 msgId
Definition: MessageQ.h:468
Void MessageQ_setReplyQueue(MessageQ_Handle handle, MessageQ_Msg msg)
Embeds a source message queue into a message.
MessageQ_QueueId MessageQ_openQueueId(UInt16 queueIndex, UInt16 remoteProcId)
Opens a MessageQ given the queue index and remote processor id.
Bits16 replyId
Definition: MessageQ.h:471
MessageQ_Handle MessageQ_create(String name, const MessageQ_Params *params)
Create a MessageQ instance.
Bits16 dstProc
Definition: MessageQ.h:470
Bits32 reserved0
Definition: MessageQ.h:464
Bits16 srcProc
Definition: MessageQ.h:473
Void MessageQ_staticMsgInit(MessageQ_Msg msg, UInt32 size)
Initializes a message not obtained from MessageQ_alloc()
Void MessageQ_setMsgTrace(MessageQ_Msg msg, Bool traceFlag)
Sets the message tracing flag on a given message.
Copyright 2014, Texas Instruments Incorporated