summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from parent 1: fbe2efb)
raw | patch | inline | side by side (from parent 1: fbe2efb)
author | vwan@ti.com <vwan@ti.com> | |
Fri, 20 Feb 2015 23:54:37 +0000 (15:54 -0800) | ||
committer | Robert Tivy <rtivy@ti.com> | |
Mon, 23 Feb 2015 22:09:06 +0000 (14:09 -0800) |
This commit adds support for reserved queues on QNX (SDOCM00114908).
Signed-off-by: VW <vwan@ti.com>
Signed-off-by: VW <vwan@ti.com>
index 9128059af5642a63a93f18b99e6de5d30d1fd7c6..c725878f8d17614a61e5562eb4763c51cf0c0dd1 100644 (file)
--- a/qnx/include/TiIpcFxns.h
+++ b/qnx/include/TiIpcFxns.h
/*
- * Copyright (c) 2013-2014, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
extern int Connect(int fd, UInt16 procId, int dst);
-extern int BindAddr(int fd, UInt32 * localAddr);
+extern int BindAddr(int fd, UInt32 localAddr);
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);
}
similarity index 73%
rename from qnx/src/ipc3x_dev/ti/syslink/inc/_MessageQ_daemon.h
rename to qnx/src/cfg/MessageQCfg.c
index 7e6fc7b59ad9becf32cffa4d057569195fc5ec0e..133cb1f56f8915275fcf0cc5f86316a87f04f679 100644 (file)
rename from qnx/src/ipc3x_dev/ti/syslink/inc/_MessageQ_daemon.h
rename to qnx/src/cfg/MessageQCfg.c
index 7e6fc7b59ad9becf32cffa4d057569195fc5ec0e..133cb1f56f8915275fcf0cc5f86316a87f04f679 100644 (file)
/*
- * Copyright (c) 2014, Texas Instruments Incorporated
+ * Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * ======== _MessageQ_daemon.h ========
- *
- * Internal header
+/*============================================================================
+ * @file MessageQCfg.c
*
+ * @brief Module configuration
*/
-#ifndef _MESSAGEQ_DAEMON_H
-#define _MESSAGEQ_DAEMON_H
-
-#include <ti/ipc/MessageQ.h>
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
+#include <ti/ipc/Std.h>
+#include <_MessageQ.h>
-/*!
- * Internal MessageQ_create function that accepts a local queueId assignment
- * (i.e. bottom 16-bit of its queueId)
+/*
+ * ======== ti_ipc_MessageQ_cfg ========
+ * The MessageQ module configuration object
+ * See documentation for details on the various fields.
*/
-MessageQ_Handle MessageQ_createWithQueueId(String name, const
- MessageQ_Params * params, UInt32 localQueueId);
-
-#if defined (__cplusplus)
-}
-#endif /* defined (__cplusplus) */
-
-#endif /* _MESSAGEQ_DAEMON_H */
+MessageQ_Config ti_ipc_MessageQ_cfg = {
+ .traceFlag = FALSE,
+ .maxRuntimeEntries = 32,
+ .maxNameLen = 32,
+ .numReservedEntries = 0
+};
diff --git a/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/common.mk b/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/common.mk
index 3ed7f474b4e7a9fdeaece4f1c8f279ea2f844fea..72689dd163178442b8f27787ee870f839484ce9c 100644 (file)
$(IPC_ROOT)/ti/syslink/ti-ipc \
$(IPC_ROOT)/ti/syslink/rpmsg-rpc \
$(IPC_ROOT)/ti/syslink/rpmsg-resmgr/hlos/knl/$(IPC_BUILDOS)/family/$(IPC_PLATFORM) \
- $(IPC_ROOT)/ti/syslink/rpmsg-resmgr/hlos/knl/$(IPC_BUILDOS)
+ $(IPC_ROOT)/ti/syslink/rpmsg-resmgr/hlos/knl/$(IPC_BUILDOS) \
+ $(IPC_REPO)/qnx/src/cfg
ifeq ("$(IPC_PLATFORM)", "omap5430")
EXTRA_SRCVPATH+=$(IPC_ROOT)/ti/syslink/family/$(IPC_PLATFORM) \
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/MessageQ_daemon.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/MessageQ_daemon.c
index 0d84713df66b8fd0b52956a79af849cd9fb5b3a1..e73f6bbe8ce4497ff1afdff234d290f7a8ca3e5c 100644 (file)
/*
- * Copyright (c) 2013-2014, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*/
#define MessageQ_NAMESERVER "MessageQ"
-/* Slot 0 reserved for NameServer messages: */
-#define RESERVED_MSGQ_INDEX 1
-
/* Define BENCHMARK to quiet key MessageQ APIs: */
//#define BENCHMARK
/*!< Handle to the local NameServer used for storing GP objects */
pthread_mutex_t gate;
/*!< Handle of gate to be used for local thread safety */
- MessageQ_Config cfg;
+ MessageQ_Config *cfg;
/*!< Current config values */
MessageQ_Config defaultCfg;
/*!< Default config values */
/*! Instance specific creation parameters */
MessageQ_QueueId queue;
/* Unique id */
- MessageQ_QueueIndex queueIndex;
- /* 16-bit index into the queues array */
Ptr nsKey;
/* NameServer key */
Int ownerPid;
* Globals
* =============================================================================
*/
+extern MessageQ_Config ti_ipc_MessageQ_cfg;
+
static MessageQ_ModuleObject MessageQ_state =
{
.refCount = 0,
.numQueues = 2u,
.canFreeQueues = FALSE,
.gate = PTHREAD_MUTEX_INITIALIZER,
+ .cfg = &ti_ipc_MessageQ_cfg,
.defaultCfg.traceFlag = FALSE,
- .defaultCfg.maxRuntimeEntries = 32u,
- .defaultCfg.maxNameLen = 32u,
+ .defaultCfg.maxRuntimeEntries = 32u,
+ .defaultCfg.maxNameLen = 32u,
+ .defaultCfg.numReservedEntries = 0
};
/*!
memcpy(cfg, &MessageQ_module->defaultCfg, sizeof(MessageQ_Config));
}
else {
- memcpy(cfg, &MessageQ_module->cfg, sizeof(MessageQ_Config));
+ memcpy(cfg, MessageQ_module->cfg, sizeof(MessageQ_Config));
}
}
MessageQ_module->refCount++;
if (MessageQ_module->refCount > 1) {
status = MessageQ_S_ALREADYSETUP;
- LOG1("MessageQ module has been already setup, refCount=%d\n", MessageQ_module->refCount)
+ LOG1("MessageQ module has been already setup, refCount=%d\n",
+ MessageQ_module->refCount)
goto exitSetup;
}
/* Initialize the parameters */
NameServer_Params_init(¶ms);
params.maxValueLen = sizeof(UInt32);
- params.maxNameLen = cfg->maxNameLen;
+ params.maxNameLen = MessageQ_module->cfg->maxNameLen;
/* Create the nameserver for modules */
MessageQ_module->nameServer = NameServer_create(MessageQ_NAMESERVER,
¶ms);
- memcpy(&MessageQ_module->cfg, (void *)cfg, sizeof(MessageQ_Config));
-
MessageQ_module->seqNum = 0;
- MessageQ_module->numQueues = cfg->maxRuntimeEntries;
+ MessageQ_module->numQueues = MessageQ_module->cfg->maxRuntimeEntries;
MessageQ_module->queues = (MessageQ_Handle *)
calloc(1, sizeof(MessageQ_Handle) * MessageQ_module->numQueues);
MessageQ_module->queues = NULL;
}
- memset(&MessageQ_module->cfg, 0, sizeof(MessageQ_Config));
MessageQ_module->numQueues = 0u;
MessageQ_module->canFreeQueues = TRUE;
/*
* Function to create a MessageQ object for receiving.
*/
-MessageQ_Handle MessageQ_createWithQueueId(String name, const MessageQ_Params * params,
- UInt32 queueId)
+MessageQ_Handle MessageQ_create(String name, const MessageQ_Params * params)
{
Int status = MessageQ_S_SUCCESS;
MessageQ_Object * obj = NULL;
Bool found = FALSE;
UInt16 count = 0;
UInt16 queueIndex = 0u;
+ UInt16 queuePort;
UInt16 procId;
int i;
+ UInt numReserved;
LOG1("MessageQ_create: creating '%s'\n", name)
/* Create the generic obj */
obj = (MessageQ_Object *)calloc(1, sizeof(MessageQ_Object));
+ if (obj == NULL) {
+ LOG0("MessageQ_create: Error: no memory\n")
+ return (NULL);
+ }
+
+ numReserved = MessageQ_module->cfg->numReservedEntries;
+
pthread_mutex_lock(&(MessageQ_module->gate));
- count = MessageQ_module->numQueues;
+ /* check if creating a reserved queue */
+ if (params->queueIndex != MessageQ_ANY) {
+ queueIndex = params->queueIndex;
- /* Search the dynamic array for any holes */
- /* We start from 1, as 0 is reserved for binding NameServer: */
- for (i = RESERVED_MSGQ_INDEX; i < count ; i++) {
- if (MessageQ_module->queues [i] == NULL) {
- MessageQ_module->queues [i] = (MessageQ_Handle)obj;
- queueIndex = i;
- found = TRUE;
- break;
+ if (queueIndex > numReserved) {
+ LOG2("MessageQ_create: Error: requested queue index %d is greater "
+ "than reserved maximum %d\n", queueIndex, numReserved - 1)
+ free(obj);
+ obj = NULL;
+ }
+ else if (MessageQ_module->queues[queueIndex] != NULL) {
+ LOG1("MessageQ_create: Error: requested queue index %d is already "
+ "in use.\n", queueIndex);
+ free(obj);
+ obj = NULL;
+ }
+
+ if (obj == NULL) {
+ pthread_mutex_unlock(&(MessageQ_module->gate));
+ return (NULL);
+ }
+
+ MessageQ_module->queues[queueIndex] = (MessageQ_Handle)obj;
+ found = TRUE;
+ }
+ else {
+ count = MessageQ_module->numQueues;
+
+ /* Search the dynamic array for any holes */
+ for (i = numReserved; i < count ; i++) {
+ if (MessageQ_module->queues [i] == NULL) {
+ MessageQ_module->queues [i] = (MessageQ_Handle)obj;
+ queueIndex = i;
+ found = TRUE;
+ break;
+ }
}
}
}
procId = MultiProc_self();
- obj->queueIndex = queueIndex;
/* create globally unique messageQ ID */
- obj->queue = (MessageQ_QueueId)(((UInt32)procId << 16) | queueId);
+ queuePort = queueIndex + MessageQ_PORTOFFSET;
+ obj->queue = (MessageQ_QueueId)(((UInt32)procId << 16) | queuePort);
obj->ownerPid = 0;
if (name != NULL) {
MessageQ_delete((MessageQ_Handle *)&obj);
}
- LOG1("MessageQ_create: returning %p\n", obj)
+ LOG2("MessageQ_create: returning obj=%p, qid=0x%x\n", obj, obj->queue)
return ((MessageQ_Handle)obj);
}
Int status = MessageQ_S_SUCCESS;
MessageQ_Object *obj;
MessageQ_Handle queue;
+ UInt16 queueIndex;
obj = (MessageQ_Object *)(*handlePtr);
LOG1("MessageQ_delete: deleting %p\n", obj)
- queue = MessageQ_module->queues[obj->queueIndex];
+ queueIndex = MessageQ_getQueueIndex(obj->queue);
+ queue = MessageQ_module->queues[queueIndex];
if (queue != obj) {
- LOG1(" ERROR: obj != MessageQ_module->queues[%d]\n", (MessageQ_QueueIndex)(obj->queueIndex))
+ LOG1(" ERROR: obj != MessageQ_module->queues[%d]\n", queueIndex)
}
if (obj->nsKey != NULL) {
pthread_mutex_lock(&(MessageQ_module->gate));
/* Clear the MessageQ obj from array. */
- MessageQ_module->queues[(MessageQ_QueueIndex)obj->queueIndex] = NULL;
+ MessageQ_module->queues[queueIndex] = NULL;
/* Release the local lock */
pthread_mutex_unlock(&(MessageQ_module->gate));
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/messageq_devctl.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/messageq_devctl.c
index 72149cfe6dcccec6a55a55660c68846e75ed6950..14e6c324edd21dbadcc0b5b4fe384200b01b4b4e 100644 (file)
/* Module specific header files */
#include <ti/ipc/MessageQ.h>
#include <ti/syslink/inc/MessageQDrvDefs.h>
-#include <ti/syslink/inc/_MessageQ_daemon.h>
/* Function prototypes */
int ipc_messageq_getconfig(resmgr_context_t *ctp, io_devctl_t *msg,
(_DEVCTL_DATA (msg->o));
MessageQ_Params *local_createparams = NULL;
String local_createname = NULL;
- UInt32 local_queueId;
out->apiStatus = MessageQ_S_SUCCESS;
local_createname = (String)(cargs+1);
}
- local_queueId = cargs->args.create.queueId;
-
- /* Force MessageQ to use the id passed in as the bottom 16-bit of its queue id */
- out->args.create.handle = MessageQ_createWithQueueId(local_createname,
- local_createparams, local_queueId);
+ out->args.create.handle = MessageQ_create(local_createname,
+ local_createparams);
GT_assert (curTrace, (out->args.create.handle != NULL));
/* Set failure status if create has failed. */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/_MessageQCopyDefs.h b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/_MessageQCopyDefs.h
index 971c87ce5c89dc217c295c92505e320abbf07e5e..6ea5f29c75bf7ccb70cc0875f1014b9ebae2c586 100644 (file)
/*
- * Copyright (c) 2011-2013 Texas Instruments Incorporated
+ * Copyright (c) 2011-2015 Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* @def MessageQCopy_MAXMQS
* @brief Maximum number of MQ handles (endpoints) per transport supported.
*/
-#define MessageQCopy_MAXMQS 1280u
+#define MessageQCopy_MAXMQS 2280u
/*!
* @def MessageQCopy_NUMVIRTQS
index ea0f4e65910d9ffd7c1da354334f67b9da733ffa..54985f0a4cf5654b4de31be8f15cb07a63c35bed 100644 (file)
/*
- * Copyright (c) 2013-2014, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
return(0);
}
-int BindAddr(int fd, UInt32 * localAddr)
+int BindAddr(int fd, UInt32 localAddr)
{
tiipc_local_params src_addr;
int err;
- src_addr.local_addr = TIIPC_ADDRANY;
+ src_addr.local_addr = localAddr;
/* This calls MessageQCopy_create(): */
err = ioctl(fd, TIIPC_IOCSETLOCAL, &src_addr);
if (err >= 0) {
PRINTVERBOSE2("IOCSETLOCAL: bound fd: %d, src addr: %d\n",
- fd, src_addr.local_addr)
+ fd, localAddr)
}
- *localAddr = src_addr.local_addr;
-
return (err);
}