diff --git a/qnx/src/api/MessageQ.c b/qnx/src/api/MessageQ.c
index bea345111e264ba1cd629759d09da150e8612b07..9bf536059d6310c20c4d53d7007eb364819161f9 100644 (file)
--- a/qnx/src/api/MessageQ.c
+++ b/qnx/src/api/MessageQ.c
#define MESSAGEQ_RPMSG_MAXSIZE 512
#define RPMSG_RESERVED_ADDRESSES (1024)
-/* MessageQ needs local address bound to be a 16-bit value */
-#define MAX_LOCAL_ADDR 0x10000
-
/* Trace flag settings: */
#define TRACESHIFT 12
#define TRACEMASK 0x1000
*/
/* This is a helper function to initialize a message. */
-static Int transportCreateEndpoint(int * fd, UInt16 * queueIndex);
+static Int transportCreateEndpoint(int * fd, UInt16 queueIndex);
static Int transportCloseEndpoint(int fd);
static Int transportGet(int fd, MessageQ_Msg * retMsg);
static Int transportPut(MessageQ_Msg msg, UInt16 dstId, UInt16 dstProcId);
{
Int status = MessageQ_S_SUCCESS;
MessageQ_Object * obj = NULL;
- UInt16 queueIndex = 0u;
+ UInt16 queuePort = 0u;
MessageQDrv_CmdArgs cmdArgs;
int fildes[2];
MessageQ_Params ps;
return NULL;
}
- PRINTVERBOSE2("MessageQ_create: creating endpoint for: %s, \
- queueIndex: %d\n", name, queueIndex)
- status = transportCreateEndpoint(&obj->ipcFd, &queueIndex);
- if (status < 0) {
- goto cleanup;
- }
-
- /*
- * We expect the endpoint creation to return a port number from
- * the MessageQCopy layer. This port number will be greater than
- * 1024 and less than 0x10000. Use this number as the queueIndex.
- */
- cmdArgs.args.create.queueId = queueIndex;
-
status = MessageQDrv_ioctl (CMD_MESSAGEQ_CREATE, &cmdArgs);
if (status < 0) {
PRINTVERBOSE1("MessageQ_create: API (through IOCTL) failed, \
goto cleanup;
}
- /* Populate the params member */
+ /* Populate the params member */
memcpy(&obj->params, &ps, sizeof(ps));
obj->queue = cmdArgs.args.create.queueId;
obj->serverHandle = cmdArgs.args.create.handle;
+ /* Get the queue port # (queueIndex + PORT_OFFSET) */
+ queuePort = obj->queue & 0x0000FFFF;
+
+ PRINTVERBOSE2("MessageQ_create: creating endpoint for: %s"
+ "queuePort %d\n", (name == NULL) ? "NULL" : name , queuePort)
+ status = transportCreateEndpoint(&obj->ipcFd, queuePort);
+ if (status < 0) {
+ goto cleanup;
+ }
+
/*
* Now, to support MessageQ_unblock() functionality, create an event object.
* Writing to this event will unblock the select() call in MessageQ_get().
return (status);
}
+/*
+ * ======== MessageQ_openQueueId ========
+ */
+MessageQ_QueueId MessageQ_openQueueId(UInt16 queueIndex, UInt16 procId)
+{
+ MessageQ_QueueIndex queuePort;
+ MessageQ_QueueId queueId;
+
+ /* queue port is embedded in the queueId */
+ queuePort = queueIndex + MessageQ_PORTOFFSET;
+ queueId = ((MessageQ_QueueId)(procId) << 16) | queuePort;
+
+ return (queueId);
+}
+
/* Closes previously opened instance of MessageQ module. */
Int MessageQ_close (MessageQ_QueueId * queueId)
{
{
Int status;
UInt16 dstProcId = (UInt16)(queueId >> 16);
- UInt16 queueIndex = (MessageQ_QueueIndex)(queueId & 0x0000ffff);
+ UInt16 queuePort = queueId & 0x0000ffff;
- msg->dstId = queueIndex;
+ /* use the queue port # for destination address */
+ msg->dstId = queuePort;
msg->dstProc = dstProcId;
/* invoke put hook function after addressing the message */
MessageQ_module->putHookFxn(queueId, msg);
}
- status = transportPut(msg, queueIndex, dstProcId);
+ status = transportPut(msg, queuePort, dstProcId);
return (status);
}
Int MessageQ_attach (UInt16 remoteProcId, Ptr sharedAddr)
{
Int status = MessageQ_S_SUCCESS;
- UInt32 localAddr;
int ipcFd;
int err;
* local endpoint
*/
Connect(ipcFd, remoteProcId, MESSAGEQ_RPMSG_PORT);
- err = BindAddr(ipcFd, &localAddr);
+ /* Bind to any port # above 1024 (MessageQCopy_MAXRESERVEDEPT) */
+ err = BindAddr(ipcFd, TIIPC_ADDRANY);
if (err < 0) {
status = MessageQ_E_FAIL;
printf ("MessageQ_attach: bind failed: %d, %s\n",
*
* Create a communication endpoint to receive messages.
*/
-static Int transportCreateEndpoint(int * fd, UInt16 * queueIndex)
+static Int transportCreateEndpoint(int * fd, UInt16 queuePort)
{
Int status = MessageQ_S_SUCCESS;
int err;
- UInt32 localAddr;
/* Create a fd to the ti-ipc to receive messages for this messageQ */
*fd= open("/dev/tiipc", O_RDWR);
PRINTVERBOSE1("transportCreateEndpoint: opened fd: %d\n", *fd)
- err = BindAddr(*fd, &localAddr);
+ /* Bind to this port # in the transport */
+ err = BindAddr(*fd, (UInt32)queuePort);
if (err < 0) {
status = MessageQ_E_FAIL;
printf("transportCreateEndpoint: bind failed: %d, %s\n",
goto exit;
}
- if (localAddr >= MAX_LOCAL_ADDR) {
- status = MessageQ_E_FAIL;
- printf("transportCreateEndpoint: local address returned is"
- "by BindAddr is greater than max supported\n");
-
- close(*fd);
- goto exit;
- }
-
- *queueIndex = localAddr;
-
exit:
return (status);
}