summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 810049d)
raw | patch | inline | side by side (parent: 810049d)
author | vwan@ti.com <vwan@ti.com> | |
Tue, 27 Aug 2013 16:48:45 +0000 (09:48 -0700) | ||
committer | Chris Ring <cring@ti.com> | |
Wed, 28 Aug 2013 23:46:49 +0000 (16:46 -0700) |
To enable GateMP,throw the -g option when launching the IPC resource
manager.
On the BIOS side, DSP1 must be configured as the owner of SR0 and
the new GateMP.hostSupport config param must be set to true like
this:
var GateMP = xdc.useModule('ti.sdo.ipc.GateMP');
GateMP.hostSupport = true;
Note that it's initially only been validated on DRA7XX DSP1.
Signed-off-by: VW <vwan@ti.com>
manager.
On the BIOS side, DSP1 must be configured as the owner of SR0 and
the new GateMP.hostSupport config param must be set to true like
this:
var GateMP = xdc.useModule('ti.sdo.ipc.GateMP');
GateMP.hostSupport = true;
Note that it's initially only been validated on DRA7XX DSP1.
Signed-off-by: VW <vwan@ti.com>
35 files changed:
diff --git a/hlos_common/include/_NameServerRemoteRpmsg.h b/hlos_common/include/_NameServerRemoteRpmsg.h
index b168bd021c6294322ed39cd00d5fb0ed45243fa8..cb1d2ec6a7cd0cae7ae404a63fc2d812b376b914 100644 (file)
#define MAXNAMEINCHAR 80
#define NAMEARRAYSZIE (((MAXNAMEINCHAR - 1) / sizeof(Bits32)) + 1)
+#define MAXVALUELEN 75
#define NAMESERVER_GET_TIMEOUT 10 /* Seconds */
Bits32 instanceName[NAMEARRAYSZIE];
/* name of NameServer entry */
Bits32 name[NAMEARRAYSZIE];
+ Bits32 valueLen; /* len of value */
+ Bits32 valueBuf[MAXVALUELEN]; /* value buffer */
} NameServerMsg;
diff --git a/packages/ti/ipc/namesrv/NameServerRemoteRpmsg.c b/packages/ti/ipc/namesrv/NameServerRemoteRpmsg.c
index 5f895f2f885738dad4bd7e2775f573b84fc8bc0d..a005e51631e0dc85bf0f4c22e1ff9d1f4ec0b1bd 100644 (file)
/* Create request message and send to remote processor: */
msg.request = NameServerRemoteRpmsg_REQUEST;
msg.requestStatus = 0;
+ msg.valueLen = *valueLen;
len = strlen(instanceName);
Assert_isTrue(len < MAXNAMEINCHAR, NameServerRemoteRpmsg_A_nameIsTooLong);
/* name is found */
/* set length to amount of data that was copied */
- *valueLen = sizeof(Bits32);
+ *valueLen = replyMsg->valueLen;
/* set the contents of value */
- memcpy(value, &(replyMsg->value), sizeof(Bits32));
+ if (*valueLen <= sizeof (Bits32)) {
+ memcpy(value, &(replyMsg->value), sizeof(Bits32));
+ }
+ else {
+ memcpy(value, replyMsg->valueBuf, *valueLen);
+ }
/* set the status to success */
status = NameServer_S_SUCCESS;
UInt16 dstProc = MultiProc_getId("HOST");
Assert_isTrue(msg != NULL, NULL);
+ Assert_isTrue(msg->valueLen <= MAXVALUELEN, NULL);
if (msg->request == NameServerRemoteRpmsg_REQUEST) {
Log_print1(Diags_INFO, FXNN": Request from procId %d.\n", dstProc);
if (handle != NULL) {
/* Search for the NameServer entry */
- status = NameServer_getLocalUInt32(handle,
+ if (msg->valueLen <= sizeof (Bits32)) {
+ status = NameServer_getLocalUInt32(handle,
(String)msg->name, &msg->value);
+ }
+ else {
+ status = NameServer_getLocal(handle, (String)msg->name,
+ (Ptr)msg->valueBuf, &msg->valueLen);
+ }
}
/* set the request status */
diff --git a/packages/ti/ipc/namesrv/_NameServerRemoteRpmsg.h b/packages/ti/ipc/namesrv/_NameServerRemoteRpmsg.h
index 074f2699ce9f1c49095dacee200a9948f900c512..84412283c1f3b6ed18f1cfcdc8fba041940dbfe1 100644 (file)
#define MAXNAMEINCHAR 80
#define NAMEARRAYSZIE (((MAXNAMEINCHAR - 1) / sizeof(Bits32)) + 1)
+#define MAXVALUELEN 75
/* message sent to remote procId */
typedef struct NameServerRemote_Msg {
Bits32 reserved; /* reserved field: must be first! */
- Bits32 value; /* holds value */
+ Bits32 value; /* holds value if len <= 4 */
Bits32 request; /* whether its a request/response */
Bits32 requestStatus; /* status of request */
/* name of NameServer instance */
Bits32 instanceName[NAMEARRAYSZIE];
/* name of NameServer entry */
Bits32 name[NAMEARRAYSZIE];
+ Bits32 valueLen; /* len of value */
+ Bits32 valueBuf[MAXVALUELEN]; /* value buffer */
} NameServerRemote_Msg;
#define NAME_SERVER_RPMSG_ADDR 0
index f53e84554239450acac0cede8d6988a8b79eb43b..e4bb004ba0612e2a2dec6e9aca453e3ddaaf298b 100644 (file)
{
SharedRegion_SRPtr sharedShmBase;
Int status;
+ ti_sdo_ipc_GateMP_Object *obj;
+ ti_sdo_ipc_GateMP_Params params;
+ Error_Block eb;
+ UInt key;
UInt32 len;
+ UInt32 mask;
+ UInt32 resourceId;
Ptr sharedAddr;
- UInt32 nsValue[2];
+ UInt32 nsValue[4];
+
+ Error_init(&eb);
/* Assert that a pointer has been supplied */
Assert_isTrue(handlePtr != NULL, ti_sdo_ipc_Ipc_A_nullArgument);
* from a local heap so don't do SharedRegion Ptr conversion.
*/
sharedAddr = (Ptr)nsValue[0];
+ status = GateMP_openByAddr(sharedAddr, handlePtr);
}
- else {
+ else if (GateMP_module->hostSupport == FALSE) {
/* Opening a remote GateMP. Need to do SharedRegion Ptr conversion. */
sharedShmBase = (SharedRegion_SRPtr)nsValue[0];
sharedAddr = SharedRegion_getPtr(sharedShmBase);
+ status = GateMP_openByAddr(sharedAddr, handlePtr);
}
+ else {
+ /* need to track number of opens atomically */
+ key = Hwi_disable();
+ resourceId = nsValue[2];
+ mask = nsValue[3];
+
+ /* Remote case */
+ switch (GETREMOTE(mask)) {
+ case GateMP_RemoteProtect_SYSTEM:
+ obj = GateMP_module->remoteSystemGates[resourceId];
+ break;
+
+ case GateMP_RemoteProtect_CUSTOM1:
+ obj = GateMP_module->remoteCustom1Gates[resourceId];
+ break;
+
+ case GateMP_RemoteProtect_CUSTOM2:
+ obj = GateMP_module->remoteCustom2Gates[resourceId];
+ break;
- status = GateMP_openByAddr(sharedAddr, handlePtr);
+ default:
+ obj = NULL;
+ status = GateMP_E_FAIL;
+ break;
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ /*
+ * If the object is NULL, then it must have been created on a
+ * remote processor. Need to create a local object. This is
+ * accomplished by setting the openFlag to TRUE.
+ */
+ if (obj == NULL) {
+ /* Create a GateMP object with the openFlag set to true */
+ ti_sdo_ipc_GateMP_Params_init(¶ms);
+ params.openFlag = TRUE;
+ params.sharedAddr = NULL;
+ params.resourceId = resourceId;
+ params.localProtect = GETLOCAL(mask);
+ params.remoteProtect = GETREMOTE(mask);
+
+ obj = ti_sdo_ipc_GateMP_create(¶ms, &eb);
+ if (obj == NULL) {
+ status = GateMP_E_FAIL;
+ }
+ }
+ else {
+ obj->numOpens++;
+ }
+ }
+
+ /* Return the GateMP instance */
+ *handlePtr = (GateMP_Handle)obj;
+
+ /* restore hwi mask */
+ Hwi_restore(key);
+ }
return (status);
}
SizeT minAlign, offset;
UInt i;
Bits32 *delegateReservedMask;
+ UInt32 nsValue[6];
minAlign = Memory_getMaxDefaultTypeAlign();
if (SharedRegion_getCacheLineSize(0) > minAlign) {
GateMP_module->remoteCustom2InUse = GateMP_module->remoteSystemInUse;
GateMP_module->remoteCustom2Gates = GateMP_module->remoteSystemGates;
}
+
+ if (GateMP_module->hostSupport == TRUE) {
+ /* Add special entry to store inuse arrays' location and size */
+ nsValue[0] = (UInt32)GateMP_module->remoteSystemInUse;
+ nsValue[1] = (UInt32)GateMP_module->remoteCustom1InUse;
+ nsValue[2] = (UInt32)GateMP_module->remoteCustom2InUse;
+ nsValue[3] = GateMP_module->numRemoteSystem;
+ nsValue[4] = GateMP_module->numRemoteCustom1;
+ nsValue[5] = GateMP_module->numRemoteCustom2;
+ GateMP_module->nsKey = NameServer_add((NameServer_Handle)
+ GateMP_module->nameServer, "_GateMP_TI_info", &nsValue,
+ sizeof(nsValue));
+ }
}
/*
gateMPParams.sharedAddr = (Ptr)((UInt32)sharedAddr +
ti_sdo_ipc_GateMP_getRegion0ReservedSize());
gateMPParams.localProtect = ti_sdo_ipc_GateMP_LocalProtect_TASKLET;
+ gateMPParams.name = "_GateMP_TI_dGate";
if (ti_sdo_utils_MultiProc_numProcessors > 1) {
gateMPParams.remoteProtect = ti_sdo_ipc_GateMP_RemoteProtect_SYSTEM;
/* delete the default GateMP */
status = GateMP_delete(&gate);
}
+
+ /* Remove global info entry from NameServer */
+ if ((GateMP_module->hostSupport == TRUE) &&
+ (GateMP_module->nsKey != 0)) {
+ NameServer_removeEntry((NameServer_Handle)GateMP_module->nameServer,
+ GateMP_module->nsKey);
+ }
}
return (status);
SizeT minAlign, offset;
SharedRegion_SRPtr sharedShmBase;
GateMP_Params sparams;
- UInt32 nsValue[2];
+ UInt32 nsValue[4];
+ UInt32 sizeNsValue;
IHeap_Handle regionHeap;
/* Initialize resourceId to an invalid value */
obj->nsKey = 0;
obj->numOpens = 0; /* Will be set to 1 after init() complete */
obj->attrs = (ti_sdo_ipc_GateMP_Attrs *)params->sharedAddr;
- obj->regionId = SharedRegion_getId((Ptr)obj->attrs);
- obj->cacheEnabled = SharedRegion_isCacheEnabled(obj->regionId);
-
- /* Assert that the buffer is in a valid shared region */
- Assert_isTrue(obj->regionId != SharedRegion_INVALIDREGIONID,
+ if (obj->attrs != NULL) {
+ obj->regionId = SharedRegion_getId((Ptr)obj->attrs);
+ obj->cacheEnabled = SharedRegion_isCacheEnabled(obj->regionId);
+ /* Assert that the buffer is in a valid shared region */
+ Assert_isTrue(obj->regionId != SharedRegion_INVALIDREGIONID,
ti_sdo_ipc_Ipc_A_addrNotInSharedRegion);
+ }
obj->allocSize = 0;
obj->objType = ti_sdo_ipc_Ipc_ObjType_OPENDYNAMIC;
minAlign = Memory_getMaxDefaultTypeAlign();
- if (SharedRegion_getCacheLineSize(obj->regionId) > minAlign) {
+ if ((obj->attrs != NULL) &&
+ (SharedRegion_getCacheLineSize(obj->regionId) > minAlign)) {
minAlign = SharedRegion_getCacheLineSize(obj->regionId);
}
offset = _Ipc_roundup(sizeof(ti_sdo_ipc_GateMP_Attrs), minAlign);
- obj->proxyAttrs = (Ptr)((UInt32)obj->attrs + offset);
+ /* TODO: host side created gates cannot have proxy memory */
+ if (obj->attrs != NULL) {
+ obj->proxyAttrs = (Ptr)((UInt32)obj->attrs + offset);
+ }
+ else {
+ obj->proxyAttrs = NULL;
+ }
}
/* Create GateMP instance */
else {
* Bottom 16 bits = '0' if local, '1' otherwise
*/
nsValue[1] = ((UInt32)MultiProc_self()) << 16;
+
+ if (GateMP_module->hostSupport == TRUE) {
+ nsValue[2] = obj->attrs->arg;
+ nsValue[3] = obj->attrs->mask;
+ sizeNsValue = sizeof(nsValue);
+ }
+ else {
+ sizeNsValue = 2 * sizeof(UInt32);
+ }
+
obj->nsKey = NameServer_add((NameServer_Handle)
GateMP_module->nameServer, params->name, &nsValue,
- 2 * sizeof(UInt32));
+ sizeNsValue);
if (obj->nsKey == NULL) {
Error_raise(eb, ti_sdo_ipc_Ipc_E_nameFailed, params->name,
return (5);
}
- /* Finish filling in the object */
- obj->gateHandle = IGateMPSupport_Handle_upCast(remoteHandle);
-
/* Fill in the local array because it is cooked */
key = Hwi_disable();
GateMP_module->remoteSystemGates[obj->resourceId] = obj;
* Bottom 16 bits = '0' if local, '1' otherwise
*/
nsValue[1] = ((UInt32)MultiProc_self() << 16) | 1;
- obj->nsKey = NameServer_add(
- (NameServer_Handle)GateMP_module->nameServer, params->name,
- &nsValue, 2 * sizeof(UInt32));
+
+ if (GateMP_module->hostSupport == TRUE) {
+ /* Making a copy of these for host processor */
+ nsValue[2] = obj->attrs->arg;
+ nsValue[3] = obj->attrs->mask;
+ sizeNsValue = sizeof(nsValue);
+ }
+ else {
+ sizeNsValue = 2 * sizeof(UInt32);
+ }
+
+ obj->nsKey = NameServer_add((NameServer_Handle)
+ GateMP_module->nameServer, params->name, &nsValue,
+ sizeNsValue);
if (obj->nsKey == NULL) {
Error_raise(eb, ti_sdo_ipc_Ipc_E_nameFailed, params->name, 0);
{
SharedRegion_SRPtr srPtr;
- srPtr = SharedRegion_getSRPtr(obj->attrs, obj->regionId);
+ if (obj->attrs != NULL) {
+ srPtr = SharedRegion_getSRPtr(obj->attrs, obj->regionId);
+ }
+ else {
+ srPtr = NULL;
+ }
return (srPtr);
}
index dd7a5d2d0cfdb1f6784770cc1cd162652e6bf8c3..e41982905cfb3596b2f44b30dbffc8005cdee227 100644 (file)
*/
config UInt maxNameLen = 32;
+ /*!
+ * ======== hostSupport ========
+ * Support for host processor
+ */
+ metaonly config Bool hostSupport = false;
+
/*!
* ======== tableSection ========
* Section name is used to place the names table
IGateProvider.Handle gateMutexPri;
IGateProvider.Handle gateNull;
Handle defaultGate;
+ Ptr nsKey;
+ Bool hostSupport;
Int proxyMap[ProxyOrder_NUM];
};
}
index 2bbb4da4f31cb8816ec5dd9a86cbeeefec86844e..add8db1547e0495d129dba8e8a3a03664fbf4794 100644 (file)
var Program = xdc.module('xdc.cfg.Program');
var target = Program.build.target;
- /*
- * Need 2 words:
- * 1 word for the SharedRegion Ptr.
- * 1 word for the proc id of creator and if remote is allowed.
- */
- GateMP.nameSrvPrms.maxValueLen = 2 * target.stdTypes["t_Int32"].size;
+ if (params.hostSupport) {
+ /*
+ * Need 6 words for info entry, which is larger than other entries
+ */
+ GateMP.nameSrvPrms.maxValueLen = 6 * target.stdTypes["t_Int32"].size;
+ if (params.maxNameLen < 16) {
+ GateMP.nameSrvPrms.maxNameLen = 16; /* min 16 chars for def gate */
+ }
+ mod.hostSupport = true;
+ }
+ else {
+ /*
+ * Need 2 words:
+ * 1 word for the SharedRegion Ptr.
+ * 1 word for the proc id of creator and if remote is allowed.
+ */
+ GateMP.nameSrvPrms.maxValueLen = 2 * target.stdTypes["t_Int32"].size;
+ mod.hostSupport = false;
+ }
/*
* Get the current number of created static instances of this module.
}
mod.defaultGate = null;
-
+ mod.nsKey = 0;
mod.remoteSystemGates[0] = mod.defaultGate;
/* Initialize the rest of the proxy gate arrays */
diff --git a/qnx/include/GateMP_config.h b/qnx/include/GateMP_config.h
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== GateMP_config.h ========
+ *
+ * Define the configuration of parameters used in GateMP. This file also
+ * configures the various proxies.
+ *
+ */
+
+#ifndef GATEMP_CONFIG
+#define GATEMP_CONFIG
+
+#include <ti/syslink/inc/GateHWSpinlock.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#define MAX_RUNTIME_ENTRIES 128 /* Max number of GateMP instances + 1 */
+#define MAX_NAME_LEN 16 /* Max name length of GateMP instances */
+
+/* Proxy functions and data structures */
+#define GateMP_RemoteSystemProxy_Params_init(x) GateHWSpinlock_Params_init(x)
+#define GateMP_RemoteSystemProxy_create GateHWSpinlock_create
+#define GateMP_RemoteSystemProxy_delete GateHWSpinlock_delete
+#define GateMP_RemoteSystemProxy_Params GateHWSpinlock_Params
+#define GateMP_RemoteSystemProxy_Handle GateHWSpinlock_Handle
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+#endif /* GATEMP_CONFIG */
diff --git a/qnx/include/_GateMP.h b/qnx/include/_GateMP.h
--- /dev/null
+++ b/qnx/include/_GateMP.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== _GateMP.h ========
+ *
+ * Internal header
+ *
+ */
+#ifndef _GATEMP_H
+#define _GATEMP_H
+
+#include <ti/ipc/GateMP.h>
+
+#include <ti/syslink/inc/IObject.h>
+#include <ti/syslink/utils/IGateProvider.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/* Helper macros */
+#define GETREMOTE(mask) ((GateMP_RemoteProtect)(mask >> 8))
+#define GETLOCAL(mask) ((GateMP_LocalProtect)(mask & 0xFF))
+#define SETMASK(remoteProtect, localProtect) \
+ ((Bits32)(remoteProtect << 8 | localProtect))
+
+/*!
+ * @brief Structure for the Handle for the GateMP.
+ */
+typedef struct {
+ GateMP_Params params;
+ /*!< Instance specific creation parameters */
+ GateMP_RemoteProtect remoteProtect;
+ GateMP_LocalProtect localProtect;
+ Ptr nsKey;
+ Int numOpens;
+
+ Bits16 mask;
+ Bits16 creatorProcId;
+ Bits32 arg;
+
+ IGateProvider_Handle gateHandle; /* remote gate handle */
+ Ipc_ObjType objType;
+ IGateProvider_Handle localGate; /* local gate handle */
+
+ UInt resourceId;
+ /*!< Resource id of GateMP proxy */
+} GateMP_Object;
+
+/* Has GateMP been setup */
+Bool GateMP_isSetup(Void);
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+#endif /* _GATEMP_H */
diff --git a/qnx/include/_GateMP_usr.h b/qnx/include/_GateMP_usr.h
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== _GateMP_usr.h ========
+ *
+ * Internal header
+ *
+ */
+#ifndef _GATEMP_USR_H
+#define _GATEMP_USR_H
+
+#include <ti/ipc/GateMP.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*!
+ * Start the GateMP module.
+ */
+Int GateMP_start(Void);
+
+/*!
+ * Function to stop the GateMP module.
+ */
+Int GateMP_stop(Void);
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+#endif /* _GATEMP_USR_H */
diff --git a/qnx/src/api/Ipc.c b/qnx/src/api/Ipc.c
index d24423b9b6ac2172ea6963ace168759c3fdff65a..b6cd3dfc914cb6367f10fb01333412db4233b32f 100644 (file)
--- a/qnx/src/api/Ipc.c
+++ b/qnx/src/api/Ipc.c
#include <ti/ipc/NameServer.h>
#include <_MessageQ.h>
#include <_NameServer.h>
+#include <_GateMP.h>
+#include <_GateMP_usr.h>
+#include <ti/syslink/inc/GateHWSpinlock.h>
#include <ti/syslink/inc/_MultiProc.h>
MultiProc_Config _MultiProc_cfg;
printf("Ipc_start: MessageQ_attach(%d) failed: %d\n",
rprocId, status);
status = Ipc_E_FAIL;
+ goto messageqattach_fail;
}
}
}
else {
printf("Ipc_start: NameServer_setup() failed: %d\n", status);
status = Ipc_E_FAIL;
+ goto nameserversetup_fail;
}
+ /* Start GateMP only if it is setup in the resource manager */
+ if (GateMP_isSetup()) {
+ status = GateHWSpinlock_start();
+ if (status < 0) {
+ printf("Ipc_start: GateHWSpinlock_start failed: %d\n",
+ status);
+ status = Ipc_E_FAIL;
+ goto gatehwspinlockstart_fail;
+ }
+ else {
+ status = GateMP_start();
+ if (status < 0) {
+ printf("Ipc_start: GateMP_start failed: %d\n",
+ status);
+ status = Ipc_E_FAIL;
+ goto gatempstart_fail;
+ }
+ }
+ }
+
+ /* Success */
+ goto exit;
+
+gatempstart_fail:
+ GateHWSpinlock_stop();
+gatehwspinlockstart_fail:
+ for (rprocId = rprocId - 1; (rprocId > 0) && (status >= 0); rprocId--) {
+ MessageQ_detach(rprocId);
+ }
+messageqattach_fail:
+ MessageQ_destroy();
+ NameServer_destroy();
+nameserversetup_fail:
+ IpcDrv_close();
+
exit:
return (status);
}
Int32 status = Ipc_S_SUCCESS;
UInt16 rprocId;
+ if (GateMP_isSetup()) {
+ /* Stop GateMP */
+ status = GateMP_stop();
+ if (status < 0) {
+ printf("Ipc_stop: GateMP_stop() failed: %d\n", status);
+ status = Ipc_E_FAIL;
+ goto exit;
+ }
+
+ /* Finalize GateHWSpinlock */
+ status = GateHWSpinlock_stop();
+ if (status < 0) {
+ printf("Ipc_stop: GateHWSpinlock_stop() failed: %d\n", status);
+ status = Ipc_E_FAIL;
+ goto exit;
+ }
+ }
+
/* Now detach from all remote processors, assuming they are up. */
for (rprocId = 0;
(rprocId < MultiProc_getNumProcessors()) && (status >= 0);
index 3dac43a424a53105aab4e2aca1fe8a954130e085..b6429608a0701ac258afc4c69bbc72d381b38157 100644 (file)
--- a/qnx/src/api/NameServer.c
+++ b/qnx/src/api/NameServer.c
#include <time.h>
#include <ti/ipc/NameServer.h>
+#include <ti/ipc/MultiProc.h>
+
#include <_IpcLog.h>
#include <ti/syslink/inc/_MultiProc.h>
#include <ti/syslink/inc/IoctlDefs.h>
return cmdArgs.args.create.handle;
}
+Ptr NameServer_add(NameServer_Handle nsHandle, String name, Ptr buf,
+ UInt32 len)
+{
+ Int status;
+ NameServerDrv_CmdArgs cmdArgs;
+
+ cmdArgs.args.add.handle = nsHandle;
+ cmdArgs.args.add.name = name;
+ cmdArgs.args.add.nameLen = strlen(name) + 1;
+ cmdArgs.args.add.buf = buf;
+ cmdArgs.args.add.len = len;
+
+ status = NameServerDrv_ioctl(CMD_NAMESERVER_ADD, &cmdArgs);
+
+ if (status < 0) {
+ PRINTVERBOSE1("NameServer_add: API (through IOCTL) failed, \
+ status=%d\n", status)
+ return NULL;
+ }
+
+ return cmdArgs.args.add.entry;
+}
+
+Int NameServer_get(NameServer_Handle handle, String name, Ptr buf,
+ UInt32 * len, UInt16 procId[])
+{
+ Int status;
+ UInt32 procLen = 0;
+ NameServerDrv_CmdArgs cmdArgs;
+
+ cmdArgs.args.get.name = name;
+ cmdArgs.args.get.handle = handle;
+ cmdArgs.args.get.procId = procId;
+ if (procId != NULL) {
+ while (procId[procLen] != MultiProc_INVALIDID) {
+ procLen++;
+ }
+ }
+ cmdArgs.args.get.procLen = procLen;
+ cmdArgs.args.get.buf = buf;
+ cmdArgs.args.get.len = *len;
+ cmdArgs.args.get.nameLen = strlen(name) + 1;
+
+ status = NameServerDrv_ioctl (CMD_NAMESERVER_GET, &cmdArgs);
+
+ if (status < 0) {
+ PRINTVERBOSE1("NameServer_get: API (through IOCTL) failed, \
+ status=%d\n", status)
+ return status;
+ }
+
+ *len = cmdArgs.args.get.len;
+
+ return status;
+}
+
+
Ptr NameServer_addUInt32(NameServer_Handle nsHandle, String name, UInt32 value)
{
Int status;
diff --git a/qnx/src/api/common.mk b/qnx/src/api/common.mk
index a89e2032af205e49ae1cd979f0d2376b8d4cb21c..b5db8586d66d4e89ba09942f4efe8f2c0be3de3d 100644 (file)
--- a/qnx/src/api/common.mk
+++ b/qnx/src/api/common.mk
# source path
EXTRA_SRCVPATH += \
$(IPC_REPO)/qnx/src/api \
+ $(IPC_REPO)/qnx/src/api/gates
EXCLUDE_OBJS =
diff --git a/qnx/src/api/gates/GateHWSpinlock.c b/qnx/src/api/gates/GateHWSpinlock.c
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== GateHWSpinlock.c ========
+ */
+
+/* Standard headers */
+#include <ti/ipc/Std.h>
+
+/* Utilities & OSAL headers */
+#include <ti/ipc/MultiProc.h>
+#include <ti/ipc/GateMP.h>
+
+#include <ti/syslink/inc/GateHWSpinlock.h>
+
+#include <ti/syslink/utils/IGateProvider.h>
+
+/*
+ * TODO: does this belong in ti/ipc/Std.h? We should consider getting rid of
+ * error blocks from the GateMutex.h interface.
+ */
+typedef UInt32 Error_Block;
+#include <ti/syslink/utils/GateMutex.h>
+
+/* Module level headers */
+#include <ti/syslink/utils/String.h>
+
+#include <_IpcLog.h>
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+
+/*
+ * TODO: Hardcoding these for now. In daemon, we should ideally pass these in
+ * through config in GateHWSpinlock_setup and user lib can query the daemon.
+ */
+#define HWSPINLOCK_BASE 0x4A0F6000
+#define HWSPINLOCK_SIZE 0x1000
+#define HWSPINLOCK_OFFSET 0x800
+
+
+/* =============================================================================
+ * Structures & Enums
+ * =============================================================================
+ */
+/* GateHWSpinlock Module Local State */
+typedef struct {
+ UInt32 * baseAddr; /* base addr lock registers */
+ GateMutex_Handle gmHandle; /* handle to gate mutex */
+} GateHWSpinlock_Module_State;
+
+/* GateHWSpinlock instance object */
+struct GateHWSpinlock_Object {
+ IGateProvider_SuperObject; /* For inheritance from IGateProvider */
+ UInt lockNum;
+ UInt nested;
+ IGateProvider_Handle localGate;
+ int token; /* HWSpinlock token */
+};
+
+
+/* =============================================================================
+ * Globals
+ * =============================================================================
+ */
+static GateHWSpinlock_Module_State GateHWSpinlock_state =
+{
+ .baseAddr = NULL,
+ .gmHandle = NULL
+};
+
+static GateHWSpinlock_Module_State *Mod = &GateHWSpinlock_state;
+
+static GateHWSpinlock_Params GateHWSpinlock_defInstParams =
+{
+ .resourceId = 0,
+ .openFlag = FALSE,
+ .regionId = 0,
+ .sharedAddr = NULL
+};
+
+static Bool verbose = FALSE;
+
+/* =============================================================================
+ * APIS
+ * =============================================================================
+ */
+/*
+ * Function to start the GateHWSpinlock module.
+ */
+Int32 GateHWSpinlock_start(Void)
+{
+ Int32 status = GateHWSpinlock_S_SUCCESS;
+ UInt32 dst;
+
+ /* map the hardware lock registers into the local address space */
+ if (status == GateHWSpinlock_S_SUCCESS) {
+ dst = (UInt32)mmap(NULL, HWSPINLOCK_SIZE,
+ (PROT_READ | PROT_WRITE | PROT_NOCACHE),
+ (MAP_PHYS|MAP_SHARED), NOFD,
+ (off_t)HWSPINLOCK_BASE);
+
+ if (dst == (UInt32)MAP_FAILED) {
+ PRINTVERBOSE0("GateHWSpinlock_start: Memory map failed")
+ status = GateHWSpinlock_E_OSFAILURE;
+ }
+ else {
+ Mod->baseAddr = (UInt32 *)(dst + HWSPINLOCK_OFFSET);
+ status = GateHWSpinlock_S_SUCCESS;
+ }
+ }
+
+ /* create GateMutex for local protection*/
+ if (status == GateHWSpinlock_S_SUCCESS) {
+ Mod->gmHandle = GateMutex_create(NULL, NULL);
+
+ if (Mod->gmHandle == NULL) {
+ PRINTVERBOSE0("GateHWSpinlock_start: GateMutex create failed")
+ status = GateHWSpinlock_E_FAIL;
+ GateHWSpinlock_stop();
+ }
+ }
+
+ return (status);
+}
+
+/*
+ * Function to stop the GateHWSpinlock module.
+ */
+Int GateHWSpinlock_stop(Void)
+{
+ Int32 status = GateHWSpinlock_S_SUCCESS;
+
+ /* delete GateMutex */
+ if (Mod->gmHandle != NULL) {
+ status = GateMutex_delete(&Mod->gmHandle);
+ }
+
+ /* release lock register mapping */
+ if (Mod->baseAddr != NULL) {
+ munmap((void *)HWSPINLOCK_BASE, HWSPINLOCK_SIZE);
+ }
+
+ return(status);
+}
+
+/*
+ * Initialize parameter structure
+ */
+Void GateHWSpinlock_Params_init(GateHWSpinlock_Params *params)
+{
+ assert(params != NULL);
+
+ memcpy(params, &GateHWSpinlock_defInstParams,
+ sizeof(GateHWSpinlock_Params));
+}
+
+/*
+ * Create a GateHWSpinlock instance
+ */
+/* TODO: change the function to accept a local gate. Do this on all platforms */
+GateHWSpinlock_Handle GateHWSpinlock_create(GateHWSpinlock_LocalProtect
+ localProtect, const GateHWSpinlock_Params * params)
+{
+ GateHWSpinlock_Object * obj = (GateHWSpinlock_Object *)calloc(1,
+ sizeof (GateHWSpinlock_Object));
+
+ if (!obj) {
+ PRINTVERBOSE0("GateHWSpinlock_create: memory allocation failure")
+ return NULL;
+ }
+
+ IGateProvider_ObjectInitializer(obj, GateHWSpinlock);
+ /* TODO: handle more local protection types */
+ obj->localGate = (IGateProvider_Handle)Mod->gmHandle;
+ obj->lockNum = params->resourceId;
+ obj->nested = 0;
+
+ return (GateHWSpinlock_Handle)obj;
+}
+
+/*
+ * Delete a GateHWSpinlock instance
+ */
+Int GateHWSpinlock_delete (GateHWSpinlock_Handle * handle)
+{
+ GateHWSpinlock_Object * obj;
+ Int status = GateHWSpinlock_S_SUCCESS;
+
+ if (handle == NULL) {
+ return GateHWSpinlock_E_INVALIDARG;
+ }
+ if (*handle == NULL) {
+ return GateHWSpinlock_E_INVALIDARG;
+ }
+
+ obj = (GateHWSpinlock_Object *)(*handle);
+
+ free(obj);
+ *handle = NULL;
+
+ return (status);
+}
+
+/*
+ * Enter a GateHWSpinlock instance
+ */
+IArg GateHWSpinlock_enter(GateHWSpinlock_Object *obj)
+{
+ volatile UInt32 *baseAddr = Mod->baseAddr;
+ IArg key;
+
+ key = IGateProvider_enter(obj->localGate);
+
+ /* if gate already entered, just return with current key */
+ obj->nested++;
+ if (obj->nested > 1) {
+ return(key);
+ }
+
+ /* enter the spinlock */
+ while (1) {
+ /* read the spinlock, returns non-zero when we get it */
+ if (baseAddr[obj->lockNum] == 0) {
+ break;
+ }
+ obj->nested--;
+ IGateProvider_leave(obj->localGate, key);
+ key = IGateProvider_enter(obj->localGate);
+ obj->nested++; /* re-nest the gate */
+ }
+
+ return (key);
+}
+
+/*
+ * Leave a GateHWSpinlock instance
+ */
+Int GateHWSpinlock_leave(GateHWSpinlock_Object *obj, IArg key)
+{
+ volatile UInt32 *baseAddr = Mod->baseAddr;
+
+ obj->nested--;
+
+ /* release the spinlock if not nested */
+ if (obj->nested == 0) {
+ baseAddr[obj->lockNum] = 0;
+ }
+
+ IGateProvider_leave(obj->localGate, key);
+
+ return GateHWSpinlock_S_SUCCESS;
+}
diff --git a/qnx/src/api/gates/GateMP.c b/qnx/src/api/gates/GateMP.c
--- /dev/null
@@ -0,0 +1,727 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== GateMP.c ========
+ */
+#include <ti/ipc/Std.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <pthread.h>
+#include <assert.h>
+
+#include <ti/ipc/GateMP.h>
+#include <ti/ipc/NameServer.h>
+#include <ti/ipc/MultiProc.h>
+
+#include <GateMP_config.h>
+
+#include <_GateMP.h>
+#include <_IpcLog.h>
+
+#include <_GateMP_usr.h>
+
+#include <ti/syslink/inc/IoctlDefs.h>
+#include <ti/syslink/inc/usr/Qnx/GateMPDrv.h>
+#include <ti/syslink/inc/GateMPDrvDefs.h>
+
+/* structure for GateMP module state */
+typedef struct {
+ GateMP_Params defaultInstParams;
+ /* Default instance creation parameters */
+ GateMP_Handle defaultGate;
+ /* Handle to default gate */
+ NameServer_Handle nameServer;
+ /* NameServer for GateMP instances */
+ Bool isStarted;
+ /* Has GateMP been started */
+ pthread_mutex_t mutex;
+ /* Mutex for use on local process to serialize access to gate obj */
+ GateMP_Object ** remoteSystemGates;
+ /* Remote system gates */
+ Int numRemoteSystem;
+ /* Number of remote system gates */
+} GateMP_ModuleObject;
+
+
+static Bool verbose = FALSE;
+
+/* Internal structure defining parameters for GateMP_Instance_init */
+typedef struct {
+ String name; /* Name of instance */
+ UInt16 regionId; /* not used on host*/
+ Ptr sharedAddr; /* not used on host*/
+ GateMP_LocalProtect localProtect; /* Local protection level */
+ GateMP_RemoteProtect remoteProtect; /* Remote protection level */
+ UInt32 resourceId; /* resource id */
+ Bool openFlag; /* Is this open or create? */
+} _GateMP_Params;
+
+static Int GateMP_getNumResources(GateMP_RemoteProtect type);
+static Int GateMP_getFreeResource(GateMP_RemoteProtect type);
+static Int GateMP_releaseResource(UInt id, GateMP_RemoteProtect type);
+static GateMP_Handle _GateMP_create (const _GateMP_Params * params);
+static Int GateMP_Instance_init(GateMP_Object *obj,
+ const _GateMP_Params *params);
+static Void GateMP_Instance_finalize(GateMP_Object *obj, Int status);
+
+/* -----------------------------------------------------------------------------
+ * Globals
+ * -----------------------------------------------------------------------------
+ */
+static GateMP_ModuleObject GateMP_state =
+{
+ .remoteSystemGates = NULL,
+ .defaultGate = NULL,
+ .nameServer = NULL,
+ .mutex = PTHREAD_MUTEX_INITIALIZER,
+// .gateMutex = NULL,
+// .gateProcess = NULL
+};
+
+static GateMP_ModuleObject *GateMP_module = &GateMP_state;
+
+static GateMP_Params GateMP_defInstParams =
+{
+ .name = NULL,
+ .regionId = 0,
+ .sharedAddr = NULL,
+ .localProtect = GateMP_LocalProtect_PROCESS,
+ .remoteProtect = GateMP_RemoteProtect_SYSTEM
+};
+
+Int GateMP_start(Void)
+{
+ Int status;
+ GateMPDrv_CmdArgs cmdArgs;
+
+ status = GateMPDrv_ioctl(CMD_GATEMP_START, &cmdArgs);
+ if (status < 0) {
+ PRINTVERBOSE1("GateMP_start: API (through IOCTL) failed, \
+ status=%d\n", status)
+ }
+ else {
+ /*
+ * Initialize module state. Note that Nameserver handles are compatible
+ * across processes.
+ */
+ GateMP_module->nameServer = cmdArgs.args.start.nameServerHandle;
+ }
+
+ /* allocate memory for remote system gate handles */
+ if (status == GateMP_S_SUCCESS) {
+ GateMP_module->numRemoteSystem =
+ GateMP_getNumResources(GateMP_RemoteProtect_SYSTEM);
+ if (GateMP_module->numRemoteSystem > 0) {
+ GateMP_module->remoteSystemGates = calloc(1,
+ GateMP_module->numRemoteSystem *
+ sizeof(IGateProvider_Handle));
+
+ if (GateMP_module->remoteSystemGates == NULL) {
+ status = GateMP_E_MEMORY;
+ PRINTVERBOSE0("GateMP_start: memory allocation failed")
+ }
+ }
+ else {
+ GateMP_module->remoteSystemGates = NULL;
+ }
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ /* Open default gate */
+ status = GateMP_open("_GateMP_TI_dGate", &GateMP_module->defaultGate);
+ if (status < 0) {
+ PRINTVERBOSE1("GateMP_start: could not open default gate, \
+ status=%d\n", status)
+ }
+ }
+
+ /* in failure case, release acquired resources in reverse order */
+ if (status < 0) {
+ GateMP_stop();
+ }
+
+ GateMP_module->isStarted = TRUE;
+
+ return status;
+}
+
+Int GateMP_stop(Void)
+{
+ Int status = GateMP_S_SUCCESS;
+
+ PRINTVERBOSE0("GateMP_stop: entered\n")
+
+ /* close the default gate */
+ if (GateMP_module->defaultGate) {
+ GateMP_close(&GateMP_module->defaultGate);
+ GateMP_module->defaultGate = NULL;
+ }
+
+ /* free system gate array */
+ if (GateMP_module->remoteSystemGates != NULL) {
+ free(GateMP_module->remoteSystemGates);
+ GateMP_module->remoteSystemGates = NULL;
+ }
+
+ GateMP_module->isStarted = FALSE;
+
+ return status;
+}
+
+Void GateMP_Params_init(GateMP_Params *params)
+{
+ if (params != NULL) {
+ memcpy(params, &GateMP_defInstParams, sizeof(GateMP_Params));
+ }
+ else {
+ PRINTVERBOSE0("GateMP_Params_init: Params argument cannot be NULL")
+ }
+
+ return;
+}
+
+GateMP_Handle GateMP_create(const GateMP_Params *params)
+{
+ _GateMP_Params _params;
+ GateMP_Handle handle = NULL;
+
+ if (GateMP_module->isStarted == FALSE) {
+ PRINTVERBOSE0("GateMP_create: GateMP module has not been started!")
+ }
+ else {
+ memset(&_params, 0, sizeof(_GateMP_Params));
+ memcpy(&_params, params, sizeof(GateMP_Params));
+
+ handle = _GateMP_create(&_params);
+ }
+
+ return(handle);
+}
+
+static GateMP_Handle _GateMP_create(const _GateMP_Params *params)
+{
+ GateMP_Handle handle = NULL;
+ GateMP_Object * obj = NULL;
+ Int status;
+
+ /* allocate the instance object */
+ obj = (GateMP_Object *)calloc(1, sizeof(GateMP_Object));
+
+ if (obj != NULL) {
+ status = GateMP_Instance_init(obj, params);
+ if (status < 0) {
+ free(obj);
+ }
+ else {
+ handle = (GateMP_Handle)obj;
+ }
+ }
+ else {
+ PRINTVERBOSE0("GateMP_create: Memory allocation failed")
+ }
+
+ return(handle);
+}
+
+Int GateMP_open(String name, GateMP_Handle *handle)
+{
+ Int status = GateMP_S_SUCCESS;
+ UInt32 len;
+ UInt32 nsValue[4];
+ GateMP_Object * obj = NULL;
+ UInt32 arg;
+ UInt32 mask;
+ UInt32 creatorProcId;
+ _GateMP_Params params;
+
+ /* assert that a valid pointer has been supplied */
+ if (handle == NULL) {
+ PRINTVERBOSE0("GateMP_open: handle cannot be null")
+ status = GateMP_E_INVALIDARG;
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ len = sizeof(nsValue);
+
+ status = NameServer_get(GateMP_module->nameServer, name, &nsValue,
+ &len, NULL);
+
+ if (status < 0) {
+ *handle = NULL;
+ status = GateMP_E_NOTFOUND;
+ }
+ else {
+ arg = nsValue[2];
+ mask = nsValue[3];
+ creatorProcId = nsValue[1] >> 16;
+ }
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ /*
+ * The least significant bit of nsValue[1] == 0 means its a
+ * local (private) GateMP, otherwise its a remote (shared) GateMP.
+ */
+ if ((nsValue[1] & 0x1) == 0) {
+ if ((nsValue[1] >> 16) != MultiProc_self()) {
+ /* error: trying to open another processor's private gate */
+ *handle = NULL;
+ PRINTVERBOSE0("GateMP_open: cannot open private gate from \
+ another processor")
+ status = GateMP_E_FAIL;
+ }
+ else if (nsValue[0] != getpid()) {
+ /* error: trying to open another process's private gate */
+ *handle = NULL;
+ PRINTVERBOSE0("GateMP_open: cannot open private gate from \
+ another process")
+ status = GateMP_E_FAIL;
+ }
+ }
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ /* local gate */
+ if (GETREMOTE(mask) == GateMP_RemoteProtect_NONE) {
+ if (creatorProcId != MultiProc_self()) {
+ status = GateMP_E_FAIL;
+ }
+ else {
+ *handle = (GateMP_Handle)arg;
+ obj = (GateMP_Object *)(*handle);
+ pthread_mutex_lock(&GateMP_module->mutex);
+ obj->numOpens++;
+ pthread_mutex_unlock(&GateMP_module->mutex);
+ }
+ }
+ else {
+ /* remote case */
+ switch (GETREMOTE(mask)) {
+ case GateMP_RemoteProtect_SYSTEM:
+ case GateMP_RemoteProtect_CUSTOM1:
+ case GateMP_RemoteProtect_CUSTOM2:
+ obj = GateMP_module->remoteSystemGates[arg];
+ break;
+
+ default:
+ status = GateMP_E_FAIL;
+ PRINTVERBOSE0("GateMP_open: unsupported remote protection \
+ type")
+ break;
+ }
+
+ /* If the object is NULL, then it must have been created
+ * on a remote processor or in another process on the
+ * local processor. Need to create a local object. This is
+ * accomplished by setting the openFlag to TRUE.
+ */
+ if (status == GateMP_S_SUCCESS) {
+ if (obj == NULL) {
+ /* create a GateMP object with the openFlag set to true */
+ params.name = NULL;
+ params.openFlag = TRUE;
+ params.sharedAddr = NULL;
+ params.resourceId = arg;
+ params.localProtect = GETLOCAL(mask);
+ params.remoteProtect = GETREMOTE(mask);
+
+ obj = (GateMP_Object *)_GateMP_create(¶ms);
+
+ if (obj == NULL) {
+ status = GateMP_E_FAIL;
+ }
+ }
+ else {
+ pthread_mutex_lock(&GateMP_module->mutex);
+ obj->numOpens++;
+ pthread_mutex_unlock(&GateMP_module->mutex);
+ }
+ }
+
+ /* Return the "opened" GateMP instance */
+ *handle = (GateMP_Handle)obj;
+ }
+ }
+
+ return status;
+}
+
+GateMP_Handle GateMP_getDefaultRemote()
+{
+ return(GateMP_module->defaultGate);
+}
+
+GateMP_LocalProtect GateMP_getLocalProtect(GateMP_Handle handle)
+{
+ GateMP_Object *obj;
+
+ obj = (GateMP_Object *)handle;
+ return(obj->localProtect);
+}
+
+GateMP_RemoteProtect GateMP_getRemoteProtect(GateMP_Handle handle)
+{
+ GateMP_Object *obj;
+
+ obj = (GateMP_Object *)handle;
+ return (obj->remoteProtect);
+}
+
+static Int GateMP_getNumResources(GateMP_RemoteProtect type)
+{
+ Int status;
+ GateMPDrv_CmdArgs cmdArgs;
+
+ cmdArgs.args.getNumResources.type = type;
+ status = GateMPDrv_ioctl(CMD_GATEMP_GETNUMRES, &cmdArgs);
+
+ if (status < 0) {
+ PRINTVERBOSE1("GateMP_getNumResources: API (through IOCTL) failed, \
+ status=%d\n", status)
+ return -1;
+ }
+
+ return (cmdArgs.args.getNumResources.value);
+}
+
+static Int GateMP_getFreeResource(GateMP_RemoteProtect type)
+{
+ Int status;
+ GateMPDrv_CmdArgs cmdArgs;
+
+ cmdArgs.args.getFreeResource.type = type;
+ status = GateMPDrv_ioctl(CMD_GATEMP_GETFREERES, &cmdArgs);
+
+ if (status < 0) {
+ PRINTVERBOSE1("GateMP_getFreeResource: API (through IOCTL) failed, \
+ status=%d\n", status)
+ return -1;
+ }
+
+ return (cmdArgs.args.getFreeResource.id);
+}
+
+static Int GateMP_releaseResource(UInt id, GateMP_RemoteProtect type)
+{
+ Int status;
+ GateMPDrv_CmdArgs cmdArgs;
+
+ cmdArgs.args.releaseResource.type = type;
+ cmdArgs.args.releaseResource.id = id;
+ status = GateMPDrv_ioctl(CMD_GATEMP_RELRES, &cmdArgs);
+
+ if (status < 0) {
+ PRINTVERBOSE1("GateMP_releaseResource: API (through IOCTL) failed, \
+ status=%d\n", status)
+ }
+
+ return (status);
+}
+
+Bool GateMP_isSetup(Void)
+{
+ Int status;
+ GateMPDrv_CmdArgs cmdArgs;
+
+ cmdArgs.args.isSetup.result = FALSE;
+ status = GateMPDrv_ioctl(CMD_GATEMP_ISSETUP, &cmdArgs);
+
+ if (status < 0) {
+ PRINTVERBOSE1("GateMP_isSetup: API (through IOCTL) failed, \
+ status=%d\n", status)
+ }
+
+ assert(status == GateMP_S_SUCCESS);
+
+ return (cmdArgs.args.isSetup.result);
+}
+
+Int GateMP_close(GateMP_Handle *handle)
+{
+ GateMP_Object * obj;
+ Int status = GateMP_S_SUCCESS;
+
+ obj = (GateMP_Object *)(*handle);
+
+ pthread_mutex_lock(&GateMP_module->mutex);
+
+ /* Cannot call with the numOpens equal to zero. This is either
+ * a created handle or been closed already.
+ */
+ if (obj->numOpens == 0) {
+ status = GateMP_E_INVALIDSTATE;
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ obj->numOpens--;
+
+ /* If the count is zero and the gate is opened, then this
+ * object was created in the open (i.e. the create happened
+ * on a remote processor or another process).
+ */
+ if ((obj->numOpens == 0) && (obj->objType == Ipc_ObjType_OPENDYNAMIC)) {
+ GateMP_delete(handle);
+ }
+ else {
+ *handle = NULL;
+ }
+ }
+
+ pthread_mutex_unlock(&GateMP_module->mutex);
+
+ return(status);
+}
+
+Int GateMP_delete(GateMP_Handle *handlePtr)
+{
+ Int status = GateMP_S_SUCCESS;
+
+ if ((handlePtr == NULL) || (*handlePtr == NULL)) {
+ status = GateMP_E_INVALIDARG;
+ }
+ else {
+ GateMP_Instance_finalize((GateMP_Object *)(*handlePtr), 0);
+ free(*handlePtr);
+ *handlePtr = NULL;
+ }
+
+ return status;
+}
+
+static Int GateMP_Instance_init(GateMP_Object *obj,
+ const _GateMP_Params *params)
+{
+ GateMP_RemoteSystemProxy_Params systemParams;
+ UInt32 nsValue[4];
+ Int status;
+
+ status = 0;
+
+ obj->resourceId = (UInt)-1;
+
+ /* TODO: create/open the local gate instance */
+ obj->localGate = NULL;
+
+ /* open GateMP instance */
+ if (params->openFlag == TRUE) {
+ /* all open work done here except for remote gateHandle */
+ obj->localProtect = params->localProtect;
+ obj->remoteProtect = params->remoteProtect;
+ obj->nsKey = 0;
+ obj->numOpens = 1;
+
+ obj->objType = Ipc_ObjType_OPENDYNAMIC;
+ }
+
+ /* create GateMP instance */
+ else {
+ obj->localProtect = params->localProtect;
+ obj->remoteProtect = params->remoteProtect;
+ obj->nsKey = 0;
+ obj->numOpens = 0;
+
+ if (obj->remoteProtect == GateMP_RemoteProtect_NONE) {
+ /* TODO: create a local gate */
+ obj->gateHandle = obj->localGate;
+
+ /* create a local gate allocating from the local heap */
+ obj->objType = Ipc_ObjType_LOCAL;
+ obj->arg = (Bits32)obj;
+ obj->mask = SETMASK(obj->remoteProtect, obj->localProtect);
+ obj->creatorProcId = MultiProc_self();
+
+ if (params->name != NULL) {
+ /* nsv[0] : creator process id
+ * nsv[1](31:16): creator procId
+ * nsv[1](15:0) : 0 = local gate, 1 = remote gate
+ * nsv[2] : local gate object
+ * nsv[3] : protection mask
+ */
+ nsValue[0] = getpid();
+ nsValue[1] = MultiProc_self() << 16;
+ nsValue[2] = obj->arg;
+ nsValue[3] = obj->mask;
+ obj->nsKey = NameServer_add(GateMP_module->nameServer,
+ params->name, &nsValue, sizeof(nsValue));
+ if (obj->nsKey == NULL) {
+ PRINTVERBOSE0("GateMP_Instance_init: NameServer_add failed")
+ return (GateMP_E_FAIL);
+ }
+ }
+
+ /* nothing else to do for local gates */
+ return(0);
+ }
+
+ obj->objType = Ipc_ObjType_CREATEDYNAMIC;
+ }
+
+ /* proxy work for open and create done here */
+ switch (obj->remoteProtect) {
+ /* TODO: implement other types of remote protection */
+ case GateMP_RemoteProtect_SYSTEM:
+ case GateMP_RemoteProtect_CUSTOM1:
+ case GateMP_RemoteProtect_CUSTOM2:
+ if (obj->objType == Ipc_ObjType_OPENDYNAMIC) {
+ /* resourceId set by open call */
+ obj->resourceId = params->resourceId;
+ }
+ else {
+ /* created instance */
+ obj->resourceId = GateMP_getFreeResource(obj->remoteProtect);
+ if (obj->resourceId == -1) {
+ return (GateMP_E_RESOURCE);
+ }
+ }
+
+ /* create the proxy object */
+ GateMP_RemoteSystemProxy_Params_init(&systemParams);
+ systemParams.resourceId = obj->resourceId;
+ systemParams.openFlag = (obj->objType == Ipc_ObjType_OPENDYNAMIC);
+ //systemParams.sharedAddr = obj->proxyAttrs;
+
+ /*
+ * TODO: Currently passing in localProtect instead of localGate,
+ * since existing GateHWSpinlock.h defines it this way
+ */
+ obj->gateHandle = (IGateProvider_Handle)
+ GateMP_RemoteSystemProxy_create(obj->localProtect,
+ &systemParams);
+
+ if (obj->gateHandle == NULL) {
+ PRINTVERBOSE0("GateMP_Instance_init: failed to create proxy\n");
+ return(GateMP_E_FAIL);
+ }
+
+ /* store the object handle in the gate array */
+ GateMP_module->remoteSystemGates[obj->resourceId] = obj;
+ break;
+
+ default:
+ break;
+ }
+
+ /* add name/attrs to NameServer table */
+ if (obj->objType != Ipc_ObjType_OPENDYNAMIC) {
+ obj->arg = obj->resourceId;
+ obj->mask = SETMASK(obj->remoteProtect, obj->localProtect);
+
+ if (params->name != NULL) {
+ /* nsv[0] : creator pid
+ * nsv[1](31:16): creator procId
+ * nsv[1](15:0) : 0 = local gate, 1 = remote gate
+ * nsv[2] : resource id
+ * nsv[3] : protection mask
+ */
+ nsValue[0] = getpid();
+ nsValue[1] = MultiProc_self() << 16 | 1;
+ nsValue[2] = obj->resourceId;
+ nsValue[3] = obj->mask;
+ obj->nsKey = NameServer_add(GateMP_module->nameServer,
+ params->name, &nsValue, sizeof(nsValue));
+
+ if (obj->nsKey == NULL) {
+ PRINTVERBOSE0("GateMP_Instance_init: NameServer_add failed")
+ return (GateMP_E_FAIL);
+ }
+ }
+ }
+
+ return (GateMP_S_SUCCESS);
+}
+
+static Void GateMP_Instance_finalize(GateMP_Object *obj, Int status)
+{
+ GateMP_Object ** remoteGates = NULL;
+
+ /* remove from NameServer */
+ if (obj->nsKey != 0) {
+ NameServer_removeEntry(GateMP_module->nameServer, obj->nsKey);
+ obj->nsKey = 0;
+ }
+
+ /* delete the remote gate */
+ switch (obj->remoteProtect) {
+
+ case GateMP_RemoteProtect_SYSTEM:
+ case GateMP_RemoteProtect_CUSTOM1:
+ case GateMP_RemoteProtect_CUSTOM2:
+ if (obj->gateHandle != NULL) {
+ GateMP_RemoteSystemProxy_delete(
+ (GateMP_RemoteSystemProxy_Handle *)&obj->gateHandle);
+ }
+ remoteGates = GateMP_module->remoteSystemGates;
+ break;
+
+ case GateMP_RemoteProtect_NONE:
+ /* nothing else to finalize */
+ return;
+
+ default:
+ /* Nothing to do */
+ break;
+ }
+
+ /* TODO: close/delete local gate */
+
+ /* clear the handle array entry in local memory */
+ if (obj->resourceId != (UInt)-1) {
+ remoteGates[obj->resourceId] = NULL;
+ }
+
+ if ((obj->objType != Ipc_ObjType_OPENDYNAMIC)
+ && (obj->resourceId != (UInt)-1)) {
+ GateMP_releaseResource(obj->resourceId, obj->remoteProtect);
+ }
+
+}
+
+IArg GateMP_enter(GateMP_Handle handle)
+{
+ GateMP_Object * obj;
+ IArg key;
+
+ obj = (GateMP_Object *)handle;
+ key = IGateProvider_enter(obj->gateHandle);
+
+ return(key);
+}
+
+Void GateMP_leave(GateMP_Handle handle, IArg key)
+{
+ GateMP_Object *obj;
+
+ obj = (GateMP_Object *)handle;
+ IGateProvider_leave(obj->gateHandle, key);
+}
diff --git a/qnx/src/api/gates/GateMutex.c b/qnx/src/api/gates/GateMutex.c
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== GateMutex.c ========
+ */
+
+
+/* Standard headers */
+#include <ti/ipc/Std.h>
+
+/* QNX headers */
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <assert.h>
+
+#include <ti/syslink/utils/IGateProvider.h>
+
+/*
+ * TODO: does this belong in ti/ipc/Std.h? We should consider getting rid of
+ * error blocks from the GateMutex.h interface.
+ */
+typedef UInt32 Error_Block;
+#include <ti/syslink/utils/GateMutex.h>
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * Structs & Enums
+ * -----------------------------------------------------------------------------
+ */
+struct GateMutex_Object {
+ IGateProvider_SuperObject; /* For inheritance from IGateProvider */
+ pthread_mutex_t mutex; /* Mutex lock */
+};
+
+
+/* -----------------------------------------------------------------------------
+ * Forward declarations
+ * -----------------------------------------------------------------------------
+ */
+IArg GateMutex_enter(GateMutex_Handle gmhandle);
+Void GateMutex_leave(GateMutex_Handle gmhandle, IArg key);
+
+
+/* -----------------------------------------------------------------------------
+ * APIs
+ * -----------------------------------------------------------------------------
+ */
+GateMutex_Handle GateMutex_create(const GateMutex_Params * params,
+ Error_Block *eb)
+{
+ pthread_mutexattr_t attr;
+
+ GateMutex_Object * obj = (GateMutex_Object *)calloc(1,
+ sizeof(GateMutex_Object));
+ if (obj == NULL) {
+ return NULL;
+ }
+
+ memset(obj, 0, sizeof(GateMutex_Object));
+ IGateProvider_ObjectInitializer(obj, GateMutex);
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_setrecursive(&attr, PTHREAD_RECURSIVE_ENABLE);
+ pthread_mutex_init(&(obj->mutex), &attr);
+
+ return (GateMutex_Handle)obj;
+}
+
+Int GateMutex_delete(GateMutex_Handle * handle)
+{
+ if (handle == NULL) {
+ return GateMutex_E_INVALIDARG;
+ }
+ if (*handle == NULL) {
+ return GateMutex_E_INVALIDARG;
+ }
+ free(*handle);
+ *handle = NULL;
+
+ return GateMutex_S_SUCCESS;
+}
+
+IArg GateMutex_enter (GateMutex_Handle gmHandle)
+{
+ GateMutex_Object * obj = (GateMutex_Object *)gmHandle;
+ int ret;
+
+ ret = pthread_mutex_lock(&(obj->mutex));
+ assert(ret == 0);
+
+ return (IArg)ret;
+}
+
+Void GateMutex_leave (GateMutex_Handle gmHandle, IArg key)
+{
+ GateMutex_Object * obj = (GateMutex_Object *)gmHandle;
+ int ret;
+
+ ret = pthread_mutex_unlock(&(obj->mutex));
+ assert(ret == 0);
+}
+
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
diff --git a/qnx/src/ipc3x_dev/sharedmemallocator/usr/arm/a.le.v7/Makefile b/qnx/src/ipc3x_dev/sharedmemallocator/usr/arm/a.le.v7/Makefile
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2013, Texas Instruments Incorporated
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# * Neither the name of Texas Instruments Incorporated nor the names of
+# its contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+include ../../common.mk
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 3b64f2e114fb437f2477ed054c2979baf225ea46..3adc25bcbc7ec0e4feb76de7a65a99f3d20339d2 100644 (file)
ifeq ("$(SYSLINK_PLATFORM)", "omap5430")
EXTRA_SRCVPATH+=$(SYSLINK_ROOT)/ti/syslink/family/$(SYSLINK_PLATFORM) \
$(SYSLINK_ROOT)/ti/syslink/family/$(SYSLINK_PLATFORM)/ipu
+
+EXCLUDE_OBJS = GateMP_daemon.o gatemp_devctl.o
endif
ifeq ("$(SYSLINK_PLATFORM)", "ti81xx")
$(SYSLINK_ROOT)/ti/syslink/family/$(SYSLINK_PLATFORM) \
$(SYSLINK_ROOT)/ti/syslink/family/$(SYSLINK_PLATFORM)/$(SYSLINK_PLATFORM)dsp \
$(SYSLINK_ROOT)/ti/syslink/family/$(SYSLINK_PLATFORM)/$(SYSLINK_PLATFORM)ipu \
- $(SYSLINK_ROOT)/ti/syslink/family/$(SYSLINK_PLATFORM)/$(SYSLINK_PLATFORM)ipu/$(SYSLINK_PLATFORM)core1
+ $(SYSLINK_ROOT)/ti/syslink/family/$(SYSLINK_PLATFORM)/$(SYSLINK_PLATFORM)ipu/$(SYSLINK_PLATFORM)core1 \
+ $(IPC_REPO)/qnx/src/api/gates
+
+EXCLUDE_OBJS = GateMP.o
endif
include $(MKFILES_ROOT)/qtargets.mk
diff --git a/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/dcmd_syslink.h b/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/dcmd_syslink.h
index f13e7cb20095f3b0d2d712ba9a6b13fe266e5b7d..5cfbff3d6ac1f9c97c4206b3e96b130875cb7ba9 100644 (file)
typedef enum {
_DCMD_SYSLINK_NAMESERVER = 0x2A,
_DCMD_SYSLINK_MESSAGEQ,
- _DCMD_SYSLINK_MULTIPROC
+ _DCMD_SYSLINK_MULTIPROC,
+ _DCMD_SYSLINK_GATEMP
} dcmd_class_t_val;
/* ----------------------------------------------------------------------------
#define DCMD_NAMESERVER_GETUINT32 __DIOTF(_DCMD_SYSLINK_NAMESERVER,\
10, \
NameServerDrv_CmdArgs)
+/*!
+ * @brief Command for NameServer_add
+ */
+#define DCMD_NAMESERVER_ADD __DIOTF(_DCMD_SYSLINK_NAMESERVER,\
+ 11,\
+ NameServerDrv_CmdArgs)
+/*!
+ * @brief Command for NameServer_get
+ */
+#define DCMD_NAMESERVER_GET __DIOTF(_DCMD_SYSLINK_NAMESERVER,\
+ 12, \
+ NameServerDrv_CmdArgs)
/* ----------------------------------------------------------------------------
1,\
MultiProcDrv_CmdArgs)
+/* ----------------------------------------------------------------------------
+* IOCTL command IDs for GateMP
+* ----------------------------------------------------------------------------
+*/
+
+/*!
+ * @brief Command for GateMP_getFreeResource
+ */
+#define DCMD_GATEMP_GETFREERES __DIOTF(_DCMD_SYSLINK_GATEMP,\
+ 1,\
+ GateMPDrv_CmdArgs)
+
+/*!
+ * @brief Command for GateMP_releaseResource
+ */
+#define DCMD_GATEMP_RELRES __DIOTF(_DCMD_SYSLINK_GATEMP,\
+ 2,\
+ GateMPDrv_CmdArgs)
+
+/*!
+ * @brief Command for GateMP_getNumResources
+ */
+#define DCMD_GATEMP_GETNUMRES __DIOTF(_DCMD_SYSLINK_GATEMP,\
+ 3,\
+ GateMPDrv_CmdArgs)
+
+/*!
+ * @brief Command for GateMP_start
+ */
+#define DCMD_GATEMP_START __DIOTF(_DCMD_SYSLINK_GATEMP,\
+ 4,\
+ GateMPDrv_CmdArgs)
+
+/*!
+ * @brief Command for GateMP_isSetup
+ */
+#define DCMD_GATEMP_ISSETUP __DIOTF(_DCMD_SYSLINK_GATEMP,\
+ 5,\
+ GateMPDrv_CmdArgs)
+
#if defined (__cplusplus)
}
#endif
diff --git a/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_devctl.c b/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_devctl.c
index 359604d64cb09d9286b1aa4a6c89d85effa6f3e1..b66cdb749870461134b281e76ad73dab3473e594 100644 (file)
syslink_ocb_t * ocb);
extern int syslink_multiproc_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
syslink_ocb_t * ocb);
+extern int syslink_gatemp_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t * ocb);
/**
* Handler for devctl() messages.
@@ -118,9 +120,11 @@ int syslink_devctl(resmgr_context_t *ctp, io_devctl_t *msg, syslink_ocb_t *ocb)
case MESSAGEQCOPY_BASE_CMD:
status = MessageQCopyDrv_devctl( ctp, msg, ocb);
break;
+#ifndef SYSLINK_PLATFORM_VAYU
case HWSPINLOCKDRV_BASE_CMD:
status = GateHWSpinlockDrv_devctl(ctp, msg, ocb);
break;
+#endif
case _DCMD_SYSLINK_NAMESERVER:
status = syslink_nameserver_devctl(ctp, msg, ocb);
break;
@@ -130,6 +134,11 @@ int syslink_devctl(resmgr_context_t *ctp, io_devctl_t *msg, syslink_ocb_t *ocb)
case _DCMD_SYSLINK_MULTIPROC:
status = syslink_multiproc_devctl(ctp, msg, ocb);
break;
+#ifdef SYSLINK_PLATFORM_VAYU
+ case _DCMD_SYSLINK_GATEMP:
+ status = syslink_gatemp_devctl(ctp, msg, ocb);
+ break;
+#endif
default:
status = _RESMGR_ERRNO(ENOSYS);
GT_1trace( curTrace, GT_3CLASS,
diff --git a/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_main.c b/qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_main.c
index 6314f59e3d6e5f986049d112f89f07cd612f44d0..c87c3aae29de154fb0a75c6b01e82b1c69a73b5f 100644 (file)
#include <ti/syslink/utils/List.h>
#include <ti/syslink/utils/MemoryOS.h>
#include <ti/ipc/MultiProc.h>
+#include <ti/ipc/NameServer.h>
#include <_MultiProc.h>
+#include <_NameServer.h>
+#include <_GateMP_daemon.h>
#include <OsalSemaphore.h>
#include <ti/syslink/utils/OsalPrint.h>
#if defined(SYSLINK_PLATFORM_OMAP4430) || defined(SYSLINK_PLATFORM_OMAP5430)
#else
static int verbosity = 2;
#endif
+
+#if defined(SYSLINK_PLATFORM_VAYU)
+static bool gatempEnabled = false;
+#endif
static char trace_buffer[TRACE_BUFFER_SIZE];
static pthread_mutex_t trace_mutex = PTHREAD_MUTEX_INITIALIZER;
static Bool trace_active;
syslink_ocb_t * ocb = (syslink_ocb_t *)i_ocb;
if (ocb) {
+#ifndef SYSLINK_PLATFORM_VAYU
GateHWSpinlock_LeaveLockForPID(ocb->pid);
+#endif
free (ocb);
}
}
if (status < 0)
goto rpcsetup_fail;
+#if defined(SYSLINK_PLATFORM_VAYU)
+ if (gatempEnabled) {
+ /* Set up NameServer for resource manager process */
+ status = NameServer_setup();
+ if (status < 0) {
+ goto nameserversetup_fail;
+ }
+
+ /* Set up GateMP */
+ status = GateMP_setup();
+ if (status < 0) {
+ goto gatempsetup_fail;
+ }
+ }
+#endif
+
goto exit;
}
+#if defined(SYSLINK_PLATFORM_VAYU)
+gatempsetup_fail:
+ NameServer_destroy();
+nameserversetup_fail:
+ rpmsg_rpc_destroy();
+#endif
rpcsetup_fail:
ti_ipc_destroy(recover);
tiipcsetup_fail:
}
}
+#if defined(SYSLINK_PLATFORM_VAYU)
+ if (gatempEnabled) {
+ GateMP_destroy();
+
+ NameServer_destroy();
+ }
+#endif
+
rpmsg_rpc_destroy();
ti_ipc_destroy(recover);
#endif
printf (" -H enable/disable hibernation, 1: ON, 0: OFF, Default: 1)\n");
printf (" -T specify the hibernation timeout in ms, Default: 5000 ms)\n");
-
+#if defined(SYSLINK_PLATFORM_VAYU)
+ printf (" -g enable GateMP support on host\n");
+#endif
exit (EXIT_SUCCESS);
}
/* Parse the input args */
while (1)
{
- c = getopt (argc, argv, "f:d:H:T:U:v:");
+ c = getopt (argc, argv, "f:d:H:T:U:gv:");
if (c == -1)
break;
case 'v':
verbosity++;
break;
+#if defined(SYSLINK_PLATFORM_VAYU)
+ case 'g':
+ printf("GateMP support enabled on host\n");
+ gatempEnabled = true;
+ break;
+#endif
default:
fprintf (stderr, "Unrecognized argument\n");
}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/family/vayu/Platform.c b/qnx/src/ipc3x_dev/ti/syslink/family/vayu/Platform.c
index e2b337e3578abb093c2ee403e3e77f206a9106d2..187b4606e81d5282bc74b921bfb379ebfaf9dc09 100644 (file)
#include <_MultiProc.h>
#include <IpcKnl.h>
#include <sys/mman.h>
+#include <GateHWSpinlock.h>
#if defined (__cplusplus)
extern "C" {
* Macros.
* ============================================================================
*/
+/* Hardware spinlocks info */
+#define HWSPINLOCK_BASE 0x4A0F6000
+#define HWSPINLOCK_SIZE 0x1000
+#define HWSPINLOCK_OFFSET 0x800
/** ============================================================================
* Application specific configuration, please change these value according to
ElfLoader_Config elfLoaderConfig;
/*!< Elf loader config parameter */
+
+ GateHWSpinlock_Config gateHWSpinlockConfig;
+ /*!< GateHWSpinlock config parameter */
} Platform_Config;
/*! @brief structure for platform instance */
/*!< IpcInt Initialize flag */
Bool platformInitFlag;
/*!< Flag to indicate platform initialization status */
+ Bool gateHWSpinlockInitFlag;
+ /*!< GateHWSpinlock Initialize flag */
+ Ptr gateHWSpinlockVAddr;
+ /*!< GateHWSpinlock Virtual Address */
} Platform_Module_State;
/* Get the ElfLoader default config */
ElfLoader_getConfig (&config->elfLoaderConfig);
+
+ /* Get the HWSpinlock default config */
+ GateHWSpinlock_getConfig (&config->gateHWSpinlockConfig);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
}
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
Platform_Config _config;
Platform_Config * config;
VAYUIpcInt_Config VAYUcfg;
+ Memory_MapInfo minfo;
Platform_getConfig (&_config);
config = &_config;
}
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
}
+ if (status >= 0) {
+ minfo.src = HWSPINLOCK_BASE;
+ minfo.size = HWSPINLOCK_SIZE;
+ minfo.isCached = FALSE;
+ status = Memory_map (&minfo);
+ if (status < 0) {
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "Platform_setup",
+ status,
+ "Memory_map failed!");
+ }
+ else {
+ Platform_module->gateHWSpinlockVAddr = (Ptr)minfo.dst;
+ config->gateHWSpinlockConfig.numLocks = 32;
+ config->gateHWSpinlockConfig.baseAddr = minfo.dst + HWSPINLOCK_OFFSET;
+ status = GateHWSpinlock_setup (&config->gateHWSpinlockConfig);
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+ if (status < 0) {
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "Platform_setup",
+ status,
+ "GateHWSpinlock_setup failed!");
+ }
+ else {
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+ status = GateHWSpinlock_start();
+ if (status < 0) {
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "Platform_setup",
+ status,
+ "GateHWSpinlock_start failed!");
+ }
+ else {
+ Platform_module->gateHWSpinlockInitFlag = TRUE;
+ }
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+ }
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+ }
+ }
if (status < 0) {
Platform_destroy();
Platform_destroy (void)
{
Int32 status = Platform_S_SUCCESS;
+ Memory_UnmapInfo minfo;
GT_0trace (curTrace, GT_ENTER, "Platform_destroy");
(sizeof (Platform_Object) * MultiProc_getNumProcessors()));
}
+ if (Platform_module->gateHWSpinlockInitFlag == TRUE) {
+ status = GateHWSpinlock_stop();
+ if (status < 0) {
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "Platform_destroy",
+ status,
+ "GateHWSpinlock_stop failed!");
+ }
+ else {
+ status = GateHWSpinlock_destroy();
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+ if (status < 0) {
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "Platform_destroy",
+ status,
+ "GateHWSpinlock_destroy failed!");
+ }
+ else {
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+ Platform_module->gateHWSpinlockInitFlag = FALSE;
+ }
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+ }
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+ }
+
+ if (Platform_module->gateHWSpinlockVAddr) {
+ minfo.addr = (UInt32)Platform_module->gateHWSpinlockVAddr;
+ minfo.size = HWSPINLOCK_SIZE;
+ minfo.isCached = FALSE;
+ status = Memory_unmap(&minfo);
+#if !defined(SYSLINK_BUILD_OPTIMIZE)
+ if (status < 0) {
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "Platform_destroy",
+ status,
+ "Memory_unmap failed!");
+ }
+#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
+ Platform_module->gateHWSpinlockVAddr = NULL;
+ }
+
GT_1trace (curTrace, GT_LEAVE, "Platform_destroy", status);
/*! @retval Platform_S_SUCCESS Operation successful */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/GateHWSpinlock.h b/qnx/src/ipc3x_dev/ti/syslink/inc/GateHWSpinlock.h
index 80fa35b6f31030b9bdf0e771e1879b419843197f..0aa76a9a008970b0c3992f5af2ad50b63c957762 100644 (file)
-/**
- * @file GateHWSpinlock.h
+/*
+ * Copyright (c) 2008-2013, Texas Instruments Incorporated
+ * All rights reserved.
*
- * @brief Defines for Gate based on Hardware SpinLock.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
*
- * @ver 02.00.00.46_alpha1
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * ============================================================================
- *
- * Copyright (c) 2008-20012, Texas Instruments Incorporated
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * Contact information for paper mail:
- * Texas Instruments
- * Post Office Box 655303
- * Dallas, Texas 75265
- * Contact information:
- * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
- * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
- * ============================================================================
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== GateHWSpinlock.h ========
*/
-
#ifndef GATEHWSPINLOCK_H_0xF416
#define GATEHWSPINLOCK_H_0xF416
/* Utilities & Osal headers */
#include <ti/syslink/Std.h>
+#include <ti/ipc/GateMP.h>
+
#if defined (__cplusplus)
extern "C" {
#endif
*/
#define GateHWSpinlock_MODULEID (0xc43d)
-typedef enum GateMP_LocalProtect {
- GateMP_LocalProtect_NONE = 0,
- /*!< Use no local protection */
-
- GateMP_LocalProtect_INTERRUPT = 1,
- /*!< Use the INTERRUPT local protection level */
-
- GateMP_LocalProtect_TASKLET = 2,
- /*!< Use the TASKLET local protection level */
-
- GateMP_LocalProtect_THREAD = 3,
- /*!< Use the THREAD local protection level */
-
- GateMP_LocalProtect_PROCESS = 4
- /*!< Use the PROCESS local protection level */
-
-} GateMP_LocalProtect;
-
/* =============================================================================
* Module Success and Failure codes
* =============================================================================
Int
GateHWSpinlock_destroy (Void);
+/* Initialize parameter structure */
+Void GateHWSpinlock_Params_init(GateHWSpinlock_Params *params);
+
+/* Function to start GateHWSpinlock module */
+Int32 GateHWSpinlock_start(Void);
+
+/* Funciton to stop GateHWSpinlock module */
+Int GateHWSpinlock_stop(Void);
+
/* Function to create an instance of GateHWSpinlock */
GateHWSpinlock_Handle
GateHWSpinlock_create ( GateHWSpinlock_LocalProtect localProtect,
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/GateMPDrvDefs.h b/qnx/src/ipc3x_dev/ti/syslink/inc/GateMPDrvDefs.h
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*!
+ * @file GateMPDrvDefs.h
+ *
+ * @brief Definitions of GateMPDrv types and structures.
+ *
+ */
+
+
+#ifndef GATEMP_DRVDEFS_H
+#define GATEMP_DRVDEFS_H
+
+
+#include <ti/ipc/GateMP.h>
+#include <ti/ipc/NameServer.h>
+
+#include "UtilsCmdBase.h"
+#include "_GateMP.h"
+#include "_MultiProc.h"
+#include <ti/syslink/inc/IoctlDefs.h>
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* ----------------------------------------------------------------------------
+ * IOCTL command IDs for GateMP
+ * ----------------------------------------------------------------------------
+ */
+/*!
+ * @brief Base command ID for GateMP
+ */
+#define GATEMP_BASE_CMD (0x160)
+
+/*!
+ * @brief Command for GateMP_getFreeResource
+ */
+#define CMD_GATEMP_GETFREERES _IOWR(UTILSCMDBASE,\
+ GATEMP_BASE_CMD + 1u,\
+ GateMPDrv_CmdArgs)
+/*!
+ * @brief Command for GateMP_releaseResource
+ */
+#define CMD_GATEMP_RELRES _IOWR(UTILSCMDBASE,\
+ GATEMP_BASE_CMD + 2u,\
+ GateMPDrv_CmdArgs)
+/*!
+ * @brief Command for GateMP_getNumResource
+ */
+#define CMD_GATEMP_GETNUMRES _IOWR(UTILSCMDBASE,\
+ GATEMP_BASE_CMD + 3u,\
+ GateMPDrv_CmdArgs)
+/*!
+ * @brief Command for GateMP_start
+ */
+#define CMD_GATEMP_START _IOWR(UTILSCMDBASE,\
+ GATEMP_BASE_CMD + 4u,\
+ GateMPDrv_CmdArgs)
+/*!
+ * @brief Command for GateMP_isSetup
+ */
+#define CMD_GATEMP_ISSETUP _IOWR(UTILSCMDBASE,\
+ GATEMP_BASE_CMD + 5u,\
+ GateMPDrv_CmdArgs)
+
+
+
+/* ----------------------------------------------------------------------------
+ * Command arguments for GateMP
+ * ----------------------------------------------------------------------------
+ */
+/*!
+ * @brief Command arguments for GateMP
+ */
+typedef struct GateMPDrv_CmdArgs {
+ union {
+ struct {
+ GateMP_RemoteProtect type;
+ Int32 id;
+ } getFreeResource;
+
+ struct {
+ GateMP_RemoteProtect type;
+ Int32 id;
+ } releaseResource;
+
+ struct {
+ GateMP_RemoteProtect type;
+ Int32 value;
+ } getNumResources;
+
+ struct {
+ NameServer_Handle nameServerHandle;
+ } start;
+
+ struct {
+ Bool result;
+ } isSetup;
+ } args;
+
+ Int32 apiStatus;
+} GateMPDrv_CmdArgs;
+
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+
+#endif /* GateMP_DrvDefs_H */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/NameServerDrvDefs.h b/qnx/src/ipc3x_dev/ti/syslink/inc/NameServerDrvDefs.h
index 675484dc39d042bcaf95cd069e9a74da9627b8d2..f3358aa84bbc7fc6c66fb2c4162356352e5a28a1 100644 (file)
NAMESERVER_BASE_CMD + 9u,\
NameServerDrv_CmdArgs)
/*!
- * @brief Command for NameServer_close
+ * @brief Command for NameServer_getUInt32
*/
#define CMD_NAMESERVER_GETUINT32 _IOWR(UTILSCMDBASE,\
NAMESERVER_BASE_CMD + 10u,\
NameServerDrv_CmdArgs)
+/*!
+ * @brief Command for NameServer_add
+ */
+#define CMD_NAMESERVER_ADD _IOWR(UTILSCMDBASE,\
+ NAMESERVER_BASE_CMD + 11u,\
+ NameServerDrv_CmdArgs)
+
+/*!
+ * @brief Command for NameServer_get
+ */
+#define CMD_NAMESERVER_GET _IOWR(UTILSCMDBASE,\
+ NAMESERVER_BASE_CMD + 12u,\
+ NameServerDrv_CmdArgs)
/* ----------------------------------------------------------------------------
* Command arguments for NameServer
NameServer_Handle handle;
} delete;
+ struct {
+ NameServer_Handle handle;
+ String name;
+ UInt32 nameLen;
+ Ptr buf;
+ UInt32 len;
+ Ptr entry;
+ } add;
+
+ struct {
+ NameServer_Handle handle;
+ String name;
+ UInt32 nameLen;
+ Ptr buf;
+ UInt32 len;
+ UInt16 * procId;
+ UInt32 procLen;
+ } get;
+
struct {
NameServer_Handle handle;
String name;
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/_GateMP_daemon.h b/qnx/src/ipc3x_dev/ti/syslink/inc/_GateMP_daemon.h
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== _GateMP_daemon.h ========
+ *
+ * Internal header
+ *
+ */
+
+#ifndef _GATEMP_DAEMON_H
+#define _GATEMP_DAEMON_H
+
+#include <ti/ipc/GateMP.h>
+#include <ti/ipc/NameServer.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*!
+ * Setup the GateMP module.
+ */
+Int GateMP_setup(Void);
+
+/*!
+ * Function to destroy the GateMP module.
+ */
+Void GateMP_destroy(Void);
+
+/*!
+ * Find a free resource id for a particular protection type.
+ */
+Int GateMP_getFreeResource(GateMP_RemoteProtect type);
+
+/*!
+ * Release a resource id for a particular protection type.
+ */
+Int GateMP_releaseResource(UInt id, GateMP_RemoteProtect type);
+
+/*!
+ * Get the total number of resources for a particular protection type.
+ */
+Int GateMP_getNumResources(GateMP_RemoteProtect type);
+
+/*!
+ * Get the NameServer handle for GateMP.
+ */
+NameServer_Handle GateMP_getNameServer(Void);
+
+/*!
+ * Find out whether GateMP is setup
+ */
+Bool GateMP_isSetup(Void);
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+#endif /* _GATEMP_DAEMONH */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/_NameServer_daemon.h b/qnx/src/ipc3x_dev/ti/syslink/inc/_NameServer_daemon.h
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== _NameServer_daemon.h ========
+ *
+ * Internal header
+ *
+ */
+
+#ifndef _NAMESERVER_DAEMON_H
+#define _NAMESERVER_DAEMON_H
+
+#include <ti/ipc/NameServer.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*!
+ * Setup the NameServer module.
+ */
+Int NameServer_setup(Void);
+
+/*!
+ * Function to destroy the NameServer module.
+ */
+Void NameServer_destroy(Void);
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+#endif /* _NAMESERVER_DAEMON_H */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/usr/Qnx/GateMPDrv.h b/qnx/src/ipc3x_dev/ti/syslink/inc/usr/Qnx/GateMPDrv.h
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== GateMPDrv.h ========
+ *
+ */
+
+#ifndef GateMPDrv_H
+#define GateMPDrv_H
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* =============================================================================
+ * APIs
+ * =============================================================================
+ */
+
+/* Function to invoke the APIs through ioctl. */
+Int GateMPDrv_ioctl (UInt32 cmd, Ptr args);
+
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+
+#endif /* GateMPDrv_H */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateHWSpinlock.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateHWSpinlock_daemon.c
similarity index 90%
rename from qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateHWSpinlock.c
rename to qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateHWSpinlock_daemon.c
index fbac920574981aa7e0e16a195096051dfe401ce2..cdfed4dcce7917a69abf98165727cdd79a6f5f17 100644 (file)
rename from qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateHWSpinlock.c
rename to qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateHWSpinlock_daemon.c
index fbac920574981aa7e0e16a195096051dfe401ce2..cdfed4dcce7917a69abf98165727cdd79a6f5f17 100644 (file)
/*
- * @file GateHWSpinlock.c
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
*
- * @brief Gate based on Hardware SpinLock.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
*
- * @ver 02.00.00.46_alpha1
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * ============================================================================
- *
- * Copyright (c) 2008-2009, Texas Instruments Incorporated
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * Contact information for paper mail:
- * Texas Instruments
- * Post Office Box 655303
- * Dallas, Texas 75265
- * Contact information:
- * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
- * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
- * ============================================================================
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== GateHWSpinlock_daemon.c ========
*/
/* Standard headers */
extern "C" {
#endif
+#ifdef SYSLINK_PLATFORM_VAYU
+/* TODO: implement these to handle config passed in through Platform.c */
+Void GateHWSpinlock_getConfig (GateHWSpinlock_Config * cfgParams)
+{
+ return;
+}
+
+Int32 GateHWSpinlock_setup(const GateHWSpinlock_Config * cfg)
+{
+ return GateHWSpinlock_S_SUCCESS;
+}
+
+Int GateHWSpinlock_destroy(Void)
+{
+ return GateHWSpinlock_S_SUCCESS;
+}
+#else
/* =============================================================================
* Macros
* =============================================================================
return GateHWSpinlock_S_SUCCESS;
}
+#endif /* SYSLINK_PLATFORM_VAYU */
#if defined (__cplusplus)
}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateMP_daemon.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateMP_daemon.c
--- /dev/null
@@ -0,0 +1,501 @@
+/*
+ * Copyright (c) 2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== GateMP_daemon.c ========
+ */
+
+
+/* Standard headers */
+#include <ti/ipc/Std.h>
+
+/* Qnx specific header files */
+#include <pthread.h>
+
+/* System headers */
+#include <sys/mman.h>
+#include <stdlib.h>
+#include <assert.h>
+
+/* Module level headers */
+#include <ti/ipc/GateMP.h>
+#include <ti/ipc/NameServer.h>
+#include <ti/ipc/MultiProc.h>
+#include <_MultiProc.h>
+#include <GateMP_config.h>
+#include <_GateMP.h>
+
+#include <ti/syslink/utils/IGateProvider.h>
+#include <ti/syslink/inc/_GateMP_daemon.h>
+#include <_IpcLog.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#define NUM_INFO_FIELDS 6 /* Number of fields in info entry */
+
+/* Values used to populate the resource 'inUse' arrays */
+#define UNUSED ((UInt8)0)
+#define USED ((UInt8)1)
+#define RESERVED ((UInt8)-1)
+
+/* Name of GateMP's nameserver */
+#define GateMP_NAMESERVER "GateMP"
+
+/* =============================================================================
+ * Structures & Enums
+ * =============================================================================
+ */
+
+/* structure for GateMP module state */
+typedef struct {
+ Int numRemoteSystem;
+ Int numRemoteCustom1;
+ Int numRemoteCustom2;
+ UInt8 * remoteSystemInUse;
+ UInt8 * remoteCustom1InUse;
+ UInt8 * remoteCustom2InUse;
+ GateMP_Handle defaultGate;
+ NameServer_Handle nameServer;
+ Bool isSetup;
+} GateMP_ModuleObject;
+
+/* Internal functions */
+static Int GateMP_openDefaultGate(GateMP_Handle *handlePtr);
+static Int GateMP_closeDefaultGate(GateMP_Handle *handlePtr);
+
+/* =============================================================================
+ * Globals
+ * =============================================================================
+ */
+/*
+ * GateMP_state
+ */
+static GateMP_ModuleObject GateMP_state = {
+ .numRemoteSystem = 0,
+ .numRemoteCustom1 = 0,
+ .numRemoteCustom2 = 0,
+ .remoteSystemInUse = NULL,
+ .remoteCustom1InUse = NULL,
+ .remoteCustom2InUse = NULL,
+ .defaultGate = NULL,
+ .nameServer = NULL,
+ .isSetup = FALSE
+};
+
+static GateMP_ModuleObject * GateMP_module = &GateMP_state;
+
+/* =============================================================================
+ * APIS
+ * =============================================================================
+ */
+
+/* Function to setup the gatemp module. */
+Int GateMP_setup(Void)
+{
+ Int status = GateMP_S_SUCCESS;
+ NameServer_Params params;
+ UInt32 nsValue[NUM_INFO_FIELDS];
+ UInt32 len;
+
+ NameServer_Params_init(¶ms);
+ params.maxRuntimeEntries = MAX_RUNTIME_ENTRIES;
+ params.maxNameLen = MAX_NAME_LEN;
+
+ /* Assume info entry has more fields than other entries */
+ params.maxValueLen = NUM_INFO_FIELDS * sizeof(UInt32);
+
+ GateMP_module->nameServer =
+ NameServer_create(GateMP_NAMESERVER, ¶ms);
+
+ if (GateMP_module->nameServer == NULL) {
+ status = GateMP_E_FAIL;
+ LOG0("GateMP_setup: NameServer_create failed\n");
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ do {
+ sleep(1); /* Give the slaves some time to get NameServer ready */
+ status = GateMP_openDefaultGate(&GateMP_module->defaultGate);
+ } while (status == GateMP_E_NOTFOUND);
+
+
+ if (status < 0) {
+ LOG0("GateMP_setup: failed to open default gate\n");
+ status = GateMP_E_FAIL;
+ }
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ /* Process global info NameServer entry */
+ len = sizeof(nsValue);
+
+ status = NameServer_get(GateMP_module->nameServer, "_GateMP_TI_info",
+ &nsValue, &len, NULL);
+
+ if (status < 0) {
+ LOG0("GateMP_setup: failed to find info entry\n");
+ status = GateMP_E_NOTFOUND;
+ }
+ else {
+ GateMP_module->numRemoteSystem = nsValue[3];
+ GateMP_module->numRemoteCustom1 = nsValue[4];
+ GateMP_module->numRemoteCustom2 = nsValue[5];
+
+ /* Map InUse arrays to daemon's address space */
+ GateMP_module->remoteSystemInUse = mmap(NULL,
+ GateMP_module->numRemoteSystem * sizeof (UInt8),
+ (PROT_READ|PROT_WRITE|PROT_NOCACHE),
+ (MAP_PHYS|MAP_SHARED), NOFD, (off_t)nsValue[0]);
+ if (GateMP_module->remoteSystemInUse == MAP_FAILED) {
+ GateMP_module->remoteSystemInUse = NULL;
+ status = GateMP_E_MEMORY;
+ LOG0("Failed to map remoteSystemInUse to host address space!");
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ GateMP_module->remoteCustom1InUse = mmap(NULL,
+ GateMP_module->numRemoteCustom1 * sizeof (UInt8),
+ (PROT_READ|PROT_WRITE|PROT_NOCACHE),
+ (MAP_PHYS|MAP_SHARED), NOFD, (off_t)nsValue[1]);
+ if (GateMP_module->remoteCustom1InUse == MAP_FAILED) {
+ GateMP_module->remoteCustom1InUse = NULL;
+ status = GateMP_E_MEMORY;
+ LOG0("Failed to map remoteSystemInUse to host address" \
+ " space!");
+ }
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ GateMP_module->remoteCustom2InUse = mmap(NULL,
+ GateMP_module->numRemoteCustom2 * sizeof (UInt8),
+ (PROT_READ|PROT_WRITE|PROT_NOCACHE),
+ (MAP_PHYS|MAP_SHARED), NOFD, (off_t)nsValue[2]);
+ if (GateMP_module->remoteCustom2InUse == MAP_FAILED) {
+ GateMP_module->remoteCustom2InUse = NULL;
+ status = GateMP_E_MEMORY;
+ LOG0("Failed to map remoteSystemInUse to host address" \
+ " space!");
+ }
+ }
+ }
+ }
+
+ /* TODO: setup the proxy map */
+
+ /* clean up if error */
+ if (status < 0) {
+ GateMP_destroy();
+ }
+
+ GateMP_module->isSetup = TRUE;
+
+ return (status);
+}
+
+Void GateMP_destroy(Void)
+{
+ if (GateMP_module->remoteSystemInUse) {
+ munmap((unsigned int *)GateMP_module->remoteSystemInUse,
+ GateMP_module->numRemoteSystem * sizeof (UInt8));
+ GateMP_module->remoteSystemInUse = NULL;
+ }
+
+ if (GateMP_module->remoteCustom1InUse) {
+ munmap((unsigned int *)GateMP_module->remoteCustom1InUse,
+ GateMP_module->numRemoteCustom1 * sizeof (UInt8));
+ GateMP_module->remoteCustom1InUse = NULL;
+ }
+
+ if (GateMP_module->remoteCustom2InUse) {
+ munmap((unsigned int *)GateMP_module->remoteCustom2InUse,
+ GateMP_module->numRemoteCustom2 * sizeof (UInt8));
+ GateMP_module->remoteCustom2InUse = NULL;
+ }
+
+ if (GateMP_module->defaultGate) {
+ GateMP_closeDefaultGate(&GateMP_module->defaultGate);
+ }
+
+ if (GateMP_module->nameServer) {
+ NameServer_delete(&GateMP_module->nameServer);
+ GateMP_module->nameServer = NULL;
+ }
+
+ GateMP_module->isSetup = FALSE;
+
+ return;
+}
+
+/* Open default gate during GateMP_setup. Should only be called once */
+static Int GateMP_openDefaultGate(GateMP_Handle *handlePtr)
+{
+ Int status = GateMP_S_SUCCESS;
+ UInt32 len;
+ UInt32 nsValue[4];
+ GateMP_Object * obj = NULL;
+ UInt32 arg;
+ UInt32 mask;
+ UInt32 creatorProcId;
+
+ GateMP_RemoteSystemProxy_Params systemParams;
+
+ /* assert that a valid pointer has been supplied */
+ if (handlePtr == NULL) {
+ LOG0("GateMP_open: argument cannot be null\n");
+ status = GateMP_E_INVALIDARG;
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ len = sizeof(nsValue);
+
+ status = NameServer_get(GateMP_module->nameServer, "_GateMP_TI_dGate",
+ &nsValue, &len, NULL);
+
+ if (status < 0) {
+ *handlePtr = NULL;
+ status = GateMP_E_NOTFOUND;
+ }
+ else {
+ arg = nsValue[2];
+ mask = nsValue[3];
+ creatorProcId = nsValue[1] >> 16;
+ }
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ /* allocate the instance object */
+ obj = (GateMP_Object *)calloc(1, sizeof (GateMP_Object));
+ if (obj != NULL) {
+ obj->localGate = NULL; /* TODO: create the local gate instance */
+ obj->localProtect = GETLOCAL(mask);
+ obj->remoteProtect = GETREMOTE(mask);
+ obj->nsKey = 0;
+ obj->numOpens = 1;
+ obj->objType = Ipc_ObjType_OPENDYNAMIC;
+ obj->resourceId = arg;
+
+ assert(obj->remoteProtect == GateMP_RemoteProtect_SYSTEM);
+
+ /* create the proxy object */
+ GateMP_RemoteSystemProxy_Params_init(&systemParams);
+ systemParams.resourceId = obj->resourceId;
+ systemParams.openFlag = TRUE;
+
+ /*
+ * TODO: Currently passing in localProtect instead of localGate,
+ * since GateHWSpinlock owns the local gate
+ */
+ obj->gateHandle = (IGateProvider_Handle)
+ GateMP_RemoteSystemProxy_create(obj->localProtect,
+ &systemParams);
+
+ if (obj->gateHandle == NULL) {
+ LOG0("GateMP_openDefaultGate: failed to create proxy\n");
+ free(obj);
+ obj = NULL;
+ }
+ }
+ else {
+ LOG0("GateMP_openDefaultGate: Memory allocation failed")
+ }
+
+ if (obj == NULL) {
+ status = GateMP_E_FAIL;
+ }
+ }
+
+ /* Return the "opened" GateMP instance */
+ *handlePtr = (GateMP_Handle)obj;
+
+ return status;
+}
+
+static Int GateMP_closeDefaultGate(GateMP_Handle *handlePtr)
+{
+ Int status = GateMP_S_SUCCESS;
+ GateMP_Object * obj = *(GateMP_Object **)handlePtr;
+
+ if (obj->gateHandle != NULL) {
+ /* Default gate is always of type System when more than 1 processor */
+ GateMP_RemoteSystemProxy_delete(
+ (GateMP_RemoteSystemProxy_Handle *)&obj->gateHandle);
+ }
+
+ free(*handlePtr);
+ *handlePtr = NULL;
+
+ return(status);
+}
+
+Int GateMP_getFreeResource(GateMP_RemoteProtect type)
+{
+ IArg key;
+ Bool flag = FALSE;
+ Int resourceId = -1;
+ UInt8* inUse = NULL;
+ Int num = 0;
+
+ /* Remote case */
+ switch (type) {
+ /* TODO: currently only support System proxy */
+ case GateMP_RemoteProtect_SYSTEM:
+ case GateMP_RemoteProtect_CUSTOM1:
+ case GateMP_RemoteProtect_CUSTOM2:
+ inUse = GateMP_module->remoteSystemInUse;
+ num = GateMP_module->numRemoteSystem;
+ break;
+
+ default:
+ LOG0("GateMP_getFreeResource: Invalid remote protection type\n");
+ break;
+ }
+
+ if (inUse != NULL) {
+ assert(GateMP_module->defaultGate != NULL);
+ key = GateMP_enter(GateMP_module->defaultGate);
+
+ /*
+ * Find a free resource id. Note: zero is reserved on the
+ * system proxy for the default gate.
+ */
+ for (resourceId = 0; resourceId < num; resourceId++) {
+ /*
+ * If not in-use, set the inUse to TRUE to prevent other
+ * creates from getting this one.
+ */
+ if (inUse[resourceId] == UNUSED) {
+ flag = TRUE;
+
+ /* Denote in shared memory that the resource is used */
+ inUse[resourceId] = USED;
+ break;
+ }
+ }
+
+ GateMP_leave(GateMP_module->defaultGate, key);
+ }
+
+ if (flag == FALSE) {
+ resourceId = -1;
+ }
+
+ return (resourceId);
+}
+
+Int GateMP_releaseResource(UInt id, GateMP_RemoteProtect type)
+{
+ Int status = GateMP_S_SUCCESS;
+ IArg key;
+ UInt8* inUse = NULL;
+ Int num = 0;
+
+ /* Remote case */
+ switch (type) {
+ /* TODO: currently only support System proxy */
+ case GateMP_RemoteProtect_SYSTEM:
+ case GateMP_RemoteProtect_CUSTOM1:
+ case GateMP_RemoteProtect_CUSTOM2:
+ inUse = GateMP_module->remoteSystemInUse;
+ num = GateMP_module->numRemoteSystem;
+ break;
+
+ default:
+ LOG0("GateMP_releaseResource: Invalid remote protection type\n");
+ status = GateMP_E_FAIL;
+ break;
+ }
+
+ if ((inUse != NULL) && (id < num)) {
+ assert(GateMP_module->defaultGate != NULL);
+ key = GateMP_enter(GateMP_module->defaultGate);
+ inUse[id] = UNUSED;
+ GateMP_leave(GateMP_module->defaultGate, key);
+ }
+ else {
+ /* Should not happen if module is properly setup */
+ status = GateMP_E_FAIL;
+ }
+
+ return (status);
+}
+
+Int GateMP_getNumResources(GateMP_RemoteProtect type)
+{
+ Int num = -1;
+
+ /* Remote case */
+ switch (type) {
+ /* TODO: currently only support System proxy */
+ case GateMP_RemoteProtect_SYSTEM:
+ case GateMP_RemoteProtect_CUSTOM1:
+ case GateMP_RemoteProtect_CUSTOM2:
+ num = GateMP_module->numRemoteSystem;
+ break;
+
+ default:
+ LOG0("GateMP_getNumResources: Invalid remote protection type\n");
+ break;
+ }
+
+ return (num);
+}
+
+NameServer_Handle GateMP_getNameServer(Void)
+{
+ return (GateMP_module->nameServer);
+}
+
+Bool GateMP_isSetup(Void)
+{
+ return (GateMP_module->isSetup);
+}
+
+IArg GateMP_enter(GateMP_Handle handle)
+{
+ GateMP_Object * obj;
+ IArg key;
+
+ obj = (GateMP_Object *)handle;
+ key = IGateProvider_enter(obj->gateHandle);
+
+ return(key);
+}
+
+Void GateMP_leave(GateMP_Handle handle, IArg key)
+{
+ GateMP_Object *obj;
+
+ obj = (GateMP_Object *)handle;
+ IGateProvider_leave(obj->gateHandle, key);
+}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/gatemp_devctl.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/gatemp_devctl.c
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2013 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== gatemp_devctl.c ========
+ *
+ */
+
+/* Standard headers */
+#include <ti/syslink/Std.h>
+
+/* QNX specific header include */
+#include <ti/syslink/build/Qnx/resmgr/proto.h>
+#include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
+
+/* Module specific header files */
+#include <ti/ipc/GateMP.h>
+#include <ti/syslink/inc/_GateMP_daemon.h>
+#include <ti/syslink/inc/GateMPDrvDefs.h>
+
+/* Function prototypes */
+int syslink_gatemp_getFreeResource(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb);
+int syslink_gatemp_releaseResource(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb);
+int syslink_gatemp_getNumResources(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb);
+int syslink_gatemp_start(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb);
+int syslink_gatemp_isSetup(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb);
+
+/**
+ * Handler for devctl() messages for GateMP module.
+ *
+ * Handles special devctl() messages that we export for control.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_gatemp_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+
+ switch (msg->i.dcmd)
+ {
+ case DCMD_GATEMP_GETFREERES:
+ {
+ return syslink_gatemp_getFreeResource(ctp, msg, ocb);
+ }
+ break;
+
+ case DCMD_GATEMP_RELRES:
+ {
+ return syslink_gatemp_releaseResource(ctp, msg, ocb);
+ }
+ break;
+
+ case DCMD_GATEMP_GETNUMRES:
+ {
+ return syslink_gatemp_getNumResources(ctp, msg, ocb);
+ }
+ break;
+
+ case DCMD_GATEMP_START:
+ {
+ return syslink_gatemp_start(ctp, msg, ocb);
+ }
+ break;
+
+ case DCMD_GATEMP_ISSETUP:
+ {
+ return syslink_gatemp_isSetup(ctp, msg, ocb);
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Invalid DEVCTL for gatemp 0x%x\n", msg->i.dcmd);
+ break;
+
+ }
+
+ return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
+ sizeof(GateMPDrv_CmdArgs)));
+}
+
+
+/**
+ * Handler for gatemp getFreeResource API.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_gatemp_getFreeResource(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+ GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->i));
+ GateMPDrv_CmdArgs * out = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->o));
+
+ out->apiStatus = GateMP_getFreeResource(cargs->args.getFreeResource.type);
+ out->args.getFreeResource.id = out->apiStatus;
+
+ return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
+ sizeof(GateMPDrv_CmdArgs)));
+}
+
+/**
+ * Handler for gatemp releaseResource API.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_gatemp_releaseResource(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+ GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->i));
+ GateMPDrv_CmdArgs * out = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->o));
+
+ out->apiStatus = GateMP_releaseResource(cargs->args.releaseResource.id,
+ cargs->args.releaseResource.type);
+
+ return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
+ sizeof(GateMPDrv_CmdArgs)));
+}
+
+/**
+ * Handler for gatemp getNumResources API.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_gatemp_getNumResources(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+ GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->i));
+ GateMPDrv_CmdArgs * out = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->o));
+
+ out->apiStatus = GateMP_getNumResources(cargs->args.getNumResources.type);
+ cargs->args.getNumResources.value = out->apiStatus;
+
+ return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
+ sizeof(GateMPDrv_CmdArgs)));
+}
+
+/**
+ * Handler for gatemp start API.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_gatemp_start(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+ GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->i));
+ GateMPDrv_CmdArgs * out = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->o));
+
+ cargs->args.start.nameServerHandle = GateMP_getNameServer();
+ out->apiStatus = GateMP_S_SUCCESS;
+
+ return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
+ sizeof(GateMPDrv_CmdArgs)));
+}
+
+/**
+ * Handler for gatemp isSetup API.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_gatemp_isSetup(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+ GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->i));
+ GateMPDrv_CmdArgs * out = (GateMPDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->o));
+
+ cargs->args.isSetup.result = GateMP_isSetup();
+ out->apiStatus = GateMP_S_SUCCESS;
+
+ return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
+ sizeof(GateMPDrv_CmdArgs)));
+}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/usr/Qnx/GateMPDrv.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/usr/Qnx/GateMPDrv.c
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2013 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== GateMPDrv.c ========
+ *
+ */
+
+/* Standard headers */
+#include <ti/syslink/Std.h>
+
+/* OSAL & Utils headers */
+#include <ti/syslink/utils/Trace.h>
+#include <ti/ipc/GateMP.h>
+#include <_MultiProc.h>
+#include <ti/syslink/inc/GateMPDrvDefs.h>
+
+#include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
+
+/** ============================================================================
+ * Globals
+ * ============================================================================
+ */
+
+extern Int32 IpcDrv_handle;
+
+
+/** ============================================================================
+ * Functions
+ * ============================================================================
+ */
+/*!
+ * @brief Function to open the GateMP driver.
+ *
+ * @sa GateMPDrv_close
+ */
+Int GateMPDrv_open (Void)
+{
+ Int status = GateMP_S_SUCCESS;
+
+ return status;
+}
+
+
+/*!
+ * @brief Function to close the GateMP driver.
+ *
+ * @sa GateMPDrv_open
+ */
+Int GateMPDrv_close (Void)
+{
+ Int status = GateMP_S_SUCCESS;
+
+ return status;
+}
+
+
+/*!
+ * @brief Function to invoke the APIs through ioctl.
+ *
+ * @param cmd Command for driver ioctl
+ * @param args Arguments for the ioctl command
+ *
+ * @sa
+ */
+Int GateMPDrv_ioctl(UInt32 cmd, Ptr args)
+{
+ Int status = GateMP_S_SUCCESS;
+ Int osStatus = 0;
+ GateMPDrv_CmdArgs * cargs = (GateMPDrv_CmdArgs *)args;
+
+ GT_2trace (curTrace, GT_ENTER, "GateMPDrv_ioctl", cmd, args);
+
+ switch (cmd) {
+
+ case CMD_GATEMP_GETFREERES:
+ {
+ osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_GETFREERES, cargs,
+ sizeof(GateMPDrv_CmdArgs), NULL);
+
+ if (osStatus != 0) {
+ status = GateMP_E_OSFAILURE;
+ }
+ }
+ break;
+
+ case CMD_GATEMP_RELRES:
+ {
+ osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_RELRES, cargs,
+ sizeof(GateMPDrv_CmdArgs), NULL);
+
+ if (osStatus != 0) {
+ status = GateMP_E_OSFAILURE;
+ }
+ }
+ break;
+
+ case CMD_GATEMP_GETNUMRES:
+ {
+ osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_GETNUMRES, cargs,
+ sizeof(GateMPDrv_CmdArgs), NULL);
+
+ if (osStatus != 0) {
+ status = GateMP_E_OSFAILURE;
+ }
+ }
+ break;
+
+ case CMD_GATEMP_START:
+ {
+ osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_START, cargs,
+ sizeof(GateMPDrv_CmdArgs), NULL);
+
+ if (osStatus != 0) {
+ status = GateMP_E_OSFAILURE;
+ }
+ }
+ break;
+
+ case CMD_GATEMP_ISSETUP:
+ {
+ osStatus = devctl(IpcDrv_handle, DCMD_GATEMP_ISSETUP, cargs,
+ sizeof(GateMPDrv_CmdArgs), NULL);
+
+ if (osStatus != 0) {
+ status = GateMP_E_OSFAILURE;
+ }
+ }
+ break;
+
+ default:
+ {
+ status = GateMP_E_INVALIDARG;
+ GT_setFailureReason (curTrace,
+ GT_4CLASS,
+ "GateMPDrv_ioctl",
+ status,
+ "Unsupported ioctl command specified");
+ }
+ break;
+ }
+
+ if (status == GateMP_S_SUCCESS) {
+ status = cargs->apiStatus;
+ }
+
+ GT_1trace(curTrace, GT_LEAVE, "GateMPDrv_ioctl", status);
+
+ return (status);
+}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/samples/hlos/hwspinlock/usr/common.mk b/qnx/src/ipc3x_dev/ti/syslink/samples/hlos/hwspinlock/usr/common.mk
index 391c340acdcf6b080a27847e5583865daa21dc98..bebe4a2f660b1ea79db65a381a2422e6344d13cb 100644 (file)
#Add extra include path
EXTRA_INCVPATH+=$(SYSLINK_ROOT)/inc \
$(SYSLINK_ROOT)/inc/ti/ipc \
+ $(IPC_REPO)/packages \
$(SYSLINK_ROOT)/../..
diff --git a/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/knl/NameServer_daemon.c b/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/knl/NameServer_daemon.c
index b84cbd5c81edcb6b5c55c347d25afe0122d6b91b..f166516332329f074c8b00d6b4f5355779ab9111 100644 (file)
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*!
- * @file NameServer.c
+ * @file NameServer_daemon.c
*
* @brief NameServer Manager
*
LOG2("NameServer Request: instanceName: %s, name: %s\n",
(String)msg->instanceName, (String)msg->name)
+ assert(msg->valueLen <= MAXVALUELEN);
+
/*
* Message is a request. Lookup name in NameServer table.
* Send a response message back to source processor.
@@ -253,9 +255,16 @@ static void NameServerRemote_processMessage(NameServerMsg * msg, UInt16 procId)
if (handle != NULL) {
/* Search for the NameServer entry */
- LOG0("Calling NameServer_getLocalUInt32...\n")
- status = NameServer_getLocalUInt32(handle,
+ if (msg->valueLen <= sizeof (Bits32)) {
+ LOG0("Calling NameServer_getLocalUInt32...\n")
+ status = NameServer_getLocalUInt32(handle,
(String)msg->name, &msg->value);
+ }
+ else {
+ LOG0("Calling NameServer_getLocal...\n")
+ status = NameServer_getLocal(handle,
+ (String)msg->name, (Ptr)msg->valueBuf, &msg->valueLen);
+ }
}
LOG2("NameServer Response: instanceName: %s, name: %s,",
LOG0("listener_cb: Entered Listener thread.\n")
LOG1("NameServer: Listener got NameServer message "
- "from MessageQCopy: 0x%x!\n", handle);
+ "from MessageQCopy: 0x%p!\n", handle);
/* Get NameServer message and process: */
memcpy(&msg, data, len);
len)
}
else {
- LOG1("listener_cb: read from MessageQCopy 0x%x\n", handle)
+ LOG1("listener_cb: read from MessageQCopy 0x%p\n", handle)
LOG2("\tReceived ns msg: byte count: %d, from addr: %d, ",
len, src)
LOG1("from vproc: %d\n", srcProc)
pthread_mutex_lock(&NameServer_module->modGate);
- if (params->maxValueLen > sizeof(UInt32)) {
- LOG1("NameServer_create: params->maxValueLen (%d) too big for now\n", params->maxValueLen)
- /* Can't handle more than UInt32 at this time: */
- goto leave;
- }
-
/* check if the name is already created or not */
if (NameServer_getHandle(name)) {
LOG0("NameServer_create NameServer_E_INVALIDARG Name is in use!\n")
strncpy(handle->name, name, strlen (name) + 1u);
memcpy((Ptr) &handle->params, (Ptr) params, sizeof(NameServer_Params));
+ assert(params.maxValueLen <= MAXVALUELEN);
+
if (params->maxValueLen < sizeof(UInt32)) {
handle->params.maxValueLen = sizeof(UInt32);
}
/* Calculate the hash */
hash = stringHash(name);
+ if (len > handle->params.maxValueLen) {
+ status = NameServer_E_INVALIDARG;
+ LOG0("NameServer_add: value length exceeded maximum!\n")
+ new_node = NULL;
+ goto exit;
+ }
+
pthread_mutex_lock(&handle->gate);
/* Traverse the list to find duplicate check */
nsMsg.reserved = NAMESERVER_MSG_TOKEN;
nsMsg.request = NAMESERVER_REQUEST;
nsMsg.requestStatus = 0;
+ nsMsg.valueLen = *len;
strncpy((char *)nsMsg.instanceName, obj->name, strlen(obj->name) + 1);
strncpy((char *)nsMsg.name, name, strlen(name) + 1);
if (replyMsg->requestStatus) {
/* name is found */
+
+ /* set length to amount of data that was copied */
+ *len = replyMsg->valueLen;
+
/* set the contents of value */
- *(UInt32 *)value = (UInt32)replyMsg->value;
+ if (*len <= sizeof (Bits32)) {
+ *(UInt32 *)value = (UInt32)replyMsg->value;
+ LOG2("NameServer_getRemote: Reply from: %d, %s:",
+ procId, (String)replyMsg->instanceName)
+ LOG2("%s, value: 0x%x...\n",
+ (String)replyMsg->name, *(UInt32 *)value)
+ }
+ else {
+ memcpy(value, replyMsg->valueBuf, *len);
+ LOG2("NameServer_getRemote: Reply from: %d, %s:",
+ procId, (String)replyMsg->instanceName)
+ LOG2("%s, value buffer at address: 0x%p...\n",
+ (String)replyMsg->name, value)
+ }
- LOG2("NameServer_getRemote: Reply from: %d, %s:",
- procId, (String)replyMsg->instanceName)
- LOG2("%s, value: 0x%x...\n",
- (String)replyMsg->name, *(UInt32 *)value)
goto exit;
}
else {
diff --git a/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/knl/Qnx/Nameserver_devctl.c b/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/knl/Qnx/Nameserver_devctl.c
index 98f4e92595b99eba287bc31383b1e32d0d8f17eb..a59c035c1b8142ee6601362e03fa283843ceedbb 100644 (file)
#include <ti/syslink/inc/NameServerDrvDefs.h>
/* Function prototypes */
+int syslink_nameserver_add(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb);
+int syslink_nameserver_get(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb);
int syslink_nameserver_adduint32(resmgr_context_t *ctp, io_devctl_t *msg,
syslink_ocb_t *ocb);
int syslink_nameserver_getuint32(resmgr_context_t *ctp, io_devctl_t *msg,
switch (msg->i.dcmd)
{
+ case DCMD_NAMESERVER_ADD:
+ {
+ return syslink_nameserver_add( ctp, msg, ocb);
+ }
+ break;
+
+ case DCMD_NAMESERVER_GET:
+ {
+ return syslink_nameserver_get( ctp, msg, ocb);
+ }
+ break;
case DCMD_NAMESERVER_ADDUINT32:
{
return syslink_nameserver_adduint32( ctp, msg, ocb);
sizeof(NameServerDrv_CmdArgs)));
}
+/**
+ * Handler for nameserver add API.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_nameserver_add(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+ NameServerDrv_CmdArgs * cargs = (NameServerDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->i));
+ NameServerDrv_CmdArgs * out = (NameServerDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->o));
+ String name = (String)(cargs+1);
+ Ptr buf = (Ptr)((sizeof(char) * cargs->args.add.nameLen) + (char *)(name));
+ Ptr entry;
+
+ GT_assert (curTrace, (name != NULL));
+
+ entry = NameServer_add(cargs->args.add.handle,
+ name,
+ buf,
+ cargs->args.add.len);
+ GT_assert (curTrace, (entry != NULL));
+
+ out->args.add.entry = entry;
+
+ return (_RESMGR_PTR (ctp, &msg->o, sizeof(msg->o) +
+ sizeof(NameServerDrv_CmdArgs)));
+}
+
+/**
+ * Handler for nameserver get API.
+ *
+ * \param ctp Thread's associated context information.
+ * \param msg The actual devctl() message.
+ * \param ocb OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK Success.
+ * \retval ENOTSUP Unsupported devctl().
+ */
+int syslink_nameserver_get(resmgr_context_t *ctp, io_devctl_t *msg,
+ syslink_ocb_t *ocb)
+{
+ NameServerDrv_CmdArgs * cargs = (NameServerDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->i));
+ NameServerDrv_CmdArgs * out = (NameServerDrv_CmdArgs *)
+ (_DEVCTL_DATA (msg->o));
+
+ char * buf = (char *)(cargs + 1);
+ char * name = (char *)(buf + (sizeof(char) * cargs->args.get.len));
+ UInt16 * procId = NULL;
+
+ if (cargs->args.get.procLen > 0) {
+ procId = (UInt16 *)(name + (sizeof(char) * cargs->args.get.nameLen));
+ }
+
+ out->apiStatus = NameServer_get(cargs->args.get.handle,
+ (String)name,
+ (Ptr)buf,
+ &cargs->args.get.len,
+ procId);
+
+ SETIOV(&ctp->iov[0], &msg->o, sizeof(msg->o) +
+ sizeof(NameServerDrv_CmdArgs));
+ SETIOV(&ctp->iov[1], (Ptr)buf, cargs->args.get.len);
+
+ return _RESMGR_NPARTS(2);
+}
+
/**
* Handler for nameserver addunit32 API.
*
diff --git a/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/usr/Qnx/NameServerDrv.c b/qnx/src/ipc3x_dev/ti/syslink/utils/hlos/usr/Qnx/NameServerDrv.c
index d138b4b2d44115c91ebb29fd39c3569d6422d95d..91b8dfcc091d11078bfd926dc4717f9ed4294618 100644 (file)
switch (cmd) {
+ case CMD_NAMESERVER_ADD:
+ {
+ iov_t nameserver_add_iov[3];
+
+ SETIOV(&nameserver_add_iov[0], cargs, sizeof(NameServerDrv_CmdArgs));
+ SETIOV(&nameserver_add_iov[1], cargs->args.add.name,
+ cargs->args.add.nameLen);
+ SETIOV( &nameserver_add_iov[2], cargs->args.add.buf,
+ cargs->args.add.len);
+
+ osStatus = devctlv(IpcDrv_handle, DCMD_NAMESERVER_ADD, 3, 3,
+ nameserver_add_iov, nameserver_add_iov, NULL);
+
+ if ( osStatus != 0 ){
+ status = NameServer_E_OSFAILURE;
+ }
+ }
+ break;
+
+ case CMD_NAMESERVER_GET:
+ {
+ iov_t nameserver_get_iov[4];
+ unsigned char count = 0;
+
+ SETIOV(&nameserver_get_iov[count], cargs,
+ sizeof(NameServerDrv_CmdArgs));
+ count++;
+ SETIOV( &nameserver_get_iov[count], cargs->args.get.buf,
+ cargs->args.get.len);
+ count++;
+ SETIOV( &nameserver_get_iov[count], cargs->args.get.name,
+ cargs->args.get.nameLen);
+ count++;
+
+ if (cargs->args.get.procId != NULL) {
+ SETIOV(&nameserver_get_iov[count], cargs->args.get.procId,
+ cargs->args.get.procLen);
+ count++;
+ }
+
+ osStatus = devctlv(IpcDrv_handle, DCMD_NAMESERVER_GET, count,
+ 2, nameserver_get_iov, nameserver_get_iov, NULL);
+ if (osStatus != 0) {
+ status = NameServer_E_OSFAILURE;
+ }
+ }
+ break;
+
case CMD_NAMESERVER_ADDUINT32:
{
iov_t nameserver_add_iov[2];