diff --git a/qnx/src/api/Ipc.c b/qnx/src/api/Ipc.c
index 7d400d324e1915384aedddf7c4ee0a37b98e65f9..763a17b3919b42cfb429bd487aede5419ca9dd4a 100644 (file)
--- a/qnx/src/api/Ipc.c
+++ b/qnx/src/api/Ipc.c
/*
- * Copyright (c) 2013, Texas Instruments Incorporated
+ * Copyright (c) 2013-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
-#include <Std.h>
+#include <ti/ipc/Std.h>
/* Common IPC headers: */
#include <ti/ipc/Ipc.h>
/* User side headers */
#include <ti/syslink/inc/usr/Qnx/IpcDrv.h>
-//#include <SysLink.h>
/* IPC startup/shutdown stuff: */
#include <ti/ipc/MultiProc.h>
#include <ti/ipc/NameServer.h>
#include <_MessageQ.h>
#include <_NameServer.h>
+#include <_GateMP.h>
+#include <_GateMP_usr.h>
+#include <_TiIpcFxns.h>
+#include <_IpcLog.h>
+#include <ti/syslink/inc/_GateHWSpinlock.h>
+#include <ti/syslink/inc/_MultiProc.h>
+
+MultiProc_Config _MultiProc_cfg;
+
+/* traces in this file are controlled via _Ipc_verbose */
+Bool _Ipc_verbose = FALSE;
+#define verbose _Ipc_verbose
static void cleanup(int arg);
Int Ipc_start (Void)
{
MessageQ_Config msgqCfg;
+ MultiProc_Config mpCfg;
Int32 status = Ipc_S_SUCCESS;
UInt16 rprocId;
/* 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 */
+ _Ipc_verbose = TRUE;
+ _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 TiIpcFxns tracing */
+ _Ipc_verbose = TRUE;
+ _MessageQ_verbose = TRUE;
+ _MultiProc_verbose = TRUE;
+ _NameServer_verbose = TRUE;
+
+#if defined(GATEMP_SUPPORT)
+ _GateMP_verbose = TRUE;
+
+ _GateHWSpinlock_verbose = TRUE;
+#endif
+
+ _TiIpcFxns_verbose = TRUE;
+ }
+ }
+
status = IpcDrv_open();
if (status < 0) {
printf("Ipc_start: IpcDrv_open() failed: %d\n", status);
MessageQ_getConfig(&msgqCfg);
MessageQ_setup(&msgqCfg);
+ /* Setup and get MultiProc configuration from resource manager */
+ MultiProc_getConfig(&mpCfg);
+ _MultiProc_cfg = mpCfg;
+
/* Now attach to all remote processors, assuming they are up. */
for (rprocId = 0;
(rprocId < MultiProc_getNumProcessors()) && (status >= 0);
printf("Ipc_start: MessageQ_attach(%d) failed: %d\n",
rprocId, status);
status = Ipc_E_FAIL;
+ goto messageqattach_fail;
}
}
+
+ /*
+ * Check if MultiProc config is valid and that
+ * MultiProc_getNumProcessors() is non-zero to make sure we are not
+ * in the middle of a recovery.
+ */
+ if (rprocId == 0) {
+ PRINTVERBOSE0("Ipc_start: MultiProc not yet configured\n")
+ 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 defined(GATEMP_SUPPORT)
+ if (GateMP_isSetup()) {
+ /* Get GateHWSpinlock configuration from resource manager */
+ 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:
+ for (rprocId = rprocId - 1; (rprocId > 0) && (status >= 0); rprocId--) {
+ MessageQ_detach(rprocId);
+ }
+#endif
+messageqattach_fail:
+ MessageQ_destroy();
+ NameServer_destroy();
+nameserversetup_fail:
+ IpcDrv_close();
+
exit:
return (status);
}
{
Int32 status = Ipc_S_SUCCESS;
UInt16 rprocId;
+#if defined(GATEMP_SUPPORT)
+ 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;
+ }
+ }
+#endif
/* Now detach from all remote processors, assuming they are up. */
for (rprocId = 0;
(rprocId < MultiProc_getNumProcessors()) && (status >= 0);