diff --git a/linux/src/api/Ipc.c b/linux/src/api/Ipc.c
index 214c6264612627943c5e500607488ba11093372d..ffad32bb5ce97ffb67c19e64c4ac41b1b3a049a8 100644 (file)
--- a/linux/src/api/Ipc.c
+++ b/linux/src/api/Ipc.c
/*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* @brief Starts and stops user side Ipc
* All setup/destroy APIs on user side will be call from this
* module.
- *
- * @ver 0002
- *
*/
/* Standard headers */
#include <ti/ipc/Std.h>
#include <ti/ipc/Ipc.h>
#include <ti/ipc/NameServer.h>
+#include <IMessageQTransport.h>
+#include <TransportRpmsg.h>
/* User side headers */
#include <ladclient.h>
/* IPC startup/shutdown stuff: */
#include <ti/ipc/MultiProc.h>
+#include <GateHWSpinlock.h>
+#include <_GateMP.h>
#include <_MultiProc.h>
#include <_MessageQ.h>
#include <_NameServer.h>
+GateHWSpinlock_Config _GateHWSpinlock_cfgParams;
+
static LAD_ClientHandle ladHandle;
static void cleanup(int arg);
/* Function to start Ipc */
Int Ipc_start (Void)
{
- MessageQ_Config msgqCfg;
- MultiProc_Config mpCfg;
- Int32 status;
- LAD_Status ladStatus;
- UInt16 rprocId;
- Int32 attachedAny = 0;
+ TransportRpmsg_Handle transport;
+ TransportRpmsg_Params params;
+ IMessageQTransport_Handle iMsgQTrans;
+ MessageQ_Config msgqCfg;
+ MultiProc_Config mpCfg;
+#if defined(GATEMP_SUPPORT)
+ GateHWSpinlock_Config gateHWCfg;
+#endif
+ Int attachStatus;
+ Int32 status;
+ LAD_Status ladStatus;
+ UInt16 rprocId;
+ Int32 attachedAny;
/* Catch ctrl-C, and cleanup: */
(void) signal(SIGINT, cleanup);
+ if (getenv("IPC_DEBUG") != NULL) {
+ /* turn on tracing */
+ if (getenv("IPC_DEBUG")[0] == '1') {
+ /* level 1 enables typical user API tracing */
+ _MessageQ_verbose = TRUE;
+ _MultiProc_verbose = TRUE;
+ _NameServer_verbose = TRUE;
+#if defined(GATEMP_SUPPORT)
+ _GateMP_verbose = TRUE;
+
+ _GateHWSpinlock_verbose = TRUE;
+#endif
+ }
+ else if ((getenv("IPC_DEBUG")[0] == '2') ||
+ (getenv("IPC_DEBUG")[0] == '3')) {
+ /* levels 2 and 3 add socket and LAD client tracing */
+ _MessageQ_verbose = TRUE;
+ _MultiProc_verbose = TRUE;
+ _NameServer_verbose = TRUE;
+
+#if defined(GATEMP_SUPPORT)
+ _GateMP_verbose = TRUE;
+
+ _GateHWSpinlock_verbose = TRUE;
+#endif
+
+ /* internals - should be declared in respective _*.h files */
+ extern Bool _SocketFxns_verbose;
+ extern Bool _LAD_Client_verbose;
+
+ _SocketFxns_verbose = TRUE;
+ _LAD_Client_verbose = TRUE;
+ }
+ }
+
ladStatus = LAD_connect(&ladHandle);
if (ladStatus != LAD_SUCCESS) {
printf("Ipc_start: LAD_connect() failed: %d\n", ladStatus);
goto exit;
}
- /*
+ /*
* Get MultiProc configuration from LAD and initialize local MultiProc
* config structure.
*/
MessageQ_getConfig(&msgqCfg);
MessageQ_setup(&msgqCfg);
- /* Now attach to all remote processors, assuming they are up. */
+ /*
+ * Attach to all remote processors. We need to attach to
+ * at least one, so tolerate MessageQ_E_RESOURCE failures for
+ * now.
+ */
+ status = Ipc_S_SUCCESS;
+ attachedAny = FALSE;
+
for (rprocId = 0; rprocId < MultiProc_getNumProcessors(); rprocId++) {
if (0 == rprocId) {
/* Skip host, which should always be 0th entry. */
continue;
}
- status = MessageQ_attach(rprocId, NULL);
- if (status == MessageQ_E_RESOURCE) {
- continue;
+
+ params.rprocId = rprocId;
+ transport = TransportRpmsg_create(¶ms, &attachStatus);
+
+ if (transport) {
+ iMsgQTrans = TransportRpmsg_upCast(transport);
+ MessageQ_registerTransport(iMsgQTrans, rprocId, 0);
+
+ attachedAny = TRUE;
}
- if (status < 0) {
- printf("Ipc_start: MessageQ_attach(%d) failed: %d\n",
- rprocId, status);
+ else {
+ if (attachStatus == MessageQ_E_RESOURCE) {
+ continue;
+ }
+
+ printf("Ipc_start: failed to attach to %d: %d\n",
+ rprocId, attachStatus);
+
status = Ipc_E_FAIL;
break;
}
- else {
- attachedAny = 1;
- }
}
- if (attachedAny) {
- status = Ipc_S_SUCCESS;
+ if (!attachedAny) {
+ status = Ipc_E_FAIL;
}
}
else {
status = Ipc_E_FAIL;
}
+ /* Start GateMP only if device has support */
+#if defined(GATEMP_SUPPORT)
+ if (GateMP_isSetup()) {
+ /*
+ * Get HWSpinlock base address and size from LAD and
+ * initialize the local config structure.
+ */
+ GateHWSpinlock_getConfig(&gateHWCfg);
+ _GateHWSpinlock_cfgParams = gateHWCfg;
+
+ 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;
+ }
+ }
+ }
+#endif
+ /* Success */
+ goto exit;
+#if defined(GATEMP_SUPPORT)
+gatempstart_fail:
+ GateHWSpinlock_stop();
+gatehwspinlockstart_fail:
+#if 0
+ for (rprocId = rprocId - 1; (rprocId > 0) && (status >= 0); rprocId--) {
+ MessageQ_detach(rprocId);
+ }
+#endif
+#endif
+
exit:
return (status);
}
/* Skip host, which should always be 0th entry. */
continue;
}
+#if 0
status = MessageQ_detach(rprocId);
if (status < 0) {
printf("Ipc_stop: MessageQ_detach(%d) failed: %d\n",
status = Ipc_E_FAIL;
goto exit;
}
+#endif
}
status = MessageQ_destroy();