diff --git a/linux/src/api/Ipc.c b/linux/src/api/Ipc.c
index 42ac0cbe415ad0a8d75f71e7fd5dc3a81d60cbbd..44b4816a6e981c839977d5253aaae27eb6c0a6d9 100644 (file)
--- a/linux/src/api/Ipc.c
+++ b/linux/src/api/Ipc.c
#include <ti/ipc/Std.h>
#include <ti/ipc/Ipc.h>
#include <ti/ipc/NameServer.h>
+#include <ti/ipc/heaps/HeapStd.h>
+#include <ti/ipc/interfaces/IHeap.h>
/* User side headers */
#include <ladclient.h>
.gate = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
#endif
.transportFactory = NULL,
- .config.procSync = Ipc_ProcSync_NONE
+ .config.procSync = Ipc_ProcSync_NONE,
+ .config.idHeapStd = 0
};
GateHWSpinlock_Config _GateHWSpinlock_cfgParams;
UInt16 baseId;
UInt16 clusterId;
Int i;
+ HeapStd_Handle heap;
+ IHeap_Handle iheap;
/* function must be serialized */
pthread_mutex_lock(&Ipc_module.gate);
ladStatus = LAD_connect(&ladHandle);
if (ladStatus != LAD_SUCCESS) {
- printf("Ipc_start: LAD_connect() failed: %d\n", ladStatus);
+ fprintf(stderr, "Ipc_start: LAD_connect() failed: %d\n", ladStatus);
status = Ipc_E_FAIL;
goto exit;
}
status = NameServer_setup();
if (status < 0) {
- printf("Ipc_start: NameServer_setup() failed: %d\n", status);
+ fprintf(stderr, "Ipc_start: NameServer_setup() failed: %d\n", status);
status = Ipc_E_FAIL;
goto exit;
}
MessageQ_getConfig(&msgqCfg);
MessageQ_setup(&msgqCfg);
+ /* register the standard heap */
+ heap = HeapStd_handle();
+ iheap = HeapStd_upCast(heap);
+ MessageQ_registerHeap((Ptr)iheap, Ipc_module.config.idHeapStd);
+
/* invoke the transport factory create method */
status = Ipc_module.transportFactory->createFxn();
status = GateHWSpinlock_start();
if (status < 0) {
- printf("Ipc_start: GateHWSpinlock_start failed: %d\n", status);
+ fprintf(stderr, "Ipc_start: GateHWSpinlock_start failed: %d\n",
+ status);
status = Ipc_E_FAIL;
goto exit;
}
status = GateMP_start();
if (status < 0) {
- printf("Ipc_start: GateMP_start failed: %d\n", status);
+ fprintf(stderr, "Ipc_start: GateMP_start failed: %d\n", status);
status = Ipc_E_FAIL;
GateHWSpinlock_stop();
goto exit;
Ipc_module.transportFactory->deleteFxn();
+ /* unregister the standard heap */
+ MessageQ_unregisterHeap(Ipc_module.config.idHeapStd);
+
status = MessageQ_destroy();
if (status < 0) {
- printf("Ipc_stop: MessageQ_destroy() failed: %d\n", status);
+ fprintf(stderr, "Ipc_stop: MessageQ_destroy() failed: %d\n", status);
status = Ipc_E_FAIL;
goto exit;
}
status = NameServer_destroy();
if (status < 0) {
- printf("Ipc_stop: NameServer_destroy() failed: %d\n", status);
+ fprintf(stderr, "Ipc_stop: NameServer_destroy() failed: %d\n", status);
status = Ipc_E_FAIL;
goto exit;
}
ladStatus = LAD_disconnect(ladHandle);
if (ladStatus != LAD_SUCCESS) {
- printf("LAD_disconnect() failed: %d\n", ladStatus);
+ fprintf(stderr, "LAD_disconnect() failed: %d\n", ladStatus);
status = Ipc_E_FAIL;
goto exit;
}
{
Int status = Ipc_S_SUCCESS;
UInt16 clusterId;
+#if defined(GATEMP_SUPPORT)
+ Int ret;
+#endif
/* cannot attach to yourself */
if (MultiProc_self() == procId) {
/* hack: bind all existing message queues to remote processor */
MessageQ_bind(procId);
+#if defined(GATEMP_SUPPORT)
+ if (GateMP_isSetup()) {
+ /* establish GateMP connection to remote processor */
+ ret = GateMP_attach(procId);
+
+ if (ret < 0) {
+ PRINTVERBOSE1("Ipc_attach: failed to GateMP_attach to procId %d\n",
+ procId);
+ }
+ }
+#endif
+
/* getting here means we have successfully attached */
Ipc_module.attached[clusterId]++;
{
Int status = Ipc_S_SUCCESS;
UInt16 clusterId;
+#if defined(GATEMP_SUPPORT)
+ Int ret;
+#endif
/* cannot detach from yourself */
if (MultiProc_self() == procId) {
goto done;
}
+#if defined(GATEMP_SUPPORT)
+ if (GateMP_isSetup()) {
+ /* establish GateMP connection to remote processor */
+ ret = GateMP_detach(procId);
+
+ if (ret < 0) {
+ PRINTVERBOSE1("Ipc_detach: failed to GateMP_detach from procId %d\n",
+ procId);
+ }
+ }
+#endif
+
/* hack: unbind all existing message queues from remote processor */
MessageQ_unbind(procId);
done:
if (status < 0) {
/* report error */
- printf("Ipc_detach: Error %d, procId %d\n", status, procId);
+ fprintf(stderr, "Ipc_detach: Error %d, procId %d\n", status, procId);
}
pthread_mutex_unlock(&Ipc_module.gate);