index 8aa9ab167d20a2e31a5e916303b98b8a3a66eb99..acef72ec4c04431c82eb6376ec2276b600a18a81 100644 (file)
/*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015 Texas Instruments Incorporated - http://www.ti.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/* For MultiProc id to remoteproc index map */
#include <_MultiProc.h>
-static Bool verbose = FALSE;
+/* Traces in this file are controlled via _SocketFxns_verbose
+ *
+ * Caution! This file is used by both LAD and TransportRpmsg. The
+ * PRINTVERBOSE macros use printf(), which sends its output to
+ * STDOUT (fd = 0). However, LAD closes STDOUT and by unfortunate
+ * chance, the file descriptor zero (fd = 0) is reused for the outbound
+ * pipe to the first client. This means all trace messages go into
+ * the pipe and corrupt the data on the client side.
+
+ * If you want to enable this trace for LAD, in addition to setting
+ * _SocketFxns_versbose to TRUE below, you must also comment out the
+ * three calls to close() in linux/src/daemon/lad.c:
+ *
+ * close(STDIN_FILENO);
+ * close(STDOUT_FILENO);
+ * close(STDERR_FILENO);
+ *
+ * If you only want to enable trace in the client (i.e. calls from
+ * TransportRpmsg), then simply set the environment variable IPC_DEBUG
+ * (to either 2 or 3) before you run your program.
+ *
+ * IPC_DEBUG=3 ./app_host
+ */
+Bool _SocketFxns_verbose = FALSE;
+#define verbose _SocketFxns_verbose
int ConnectSocket(int sock, UInt16 procId, int dst)
{
int err;
struct sockaddr_rpmsg srcAddr, dstAddr;
socklen_t len;
+ UInt16 clusterId;
+
+ /* map procId to clusterId (rprocList[] indexed by clusterId) */
+ clusterId = procId - _MultiProc_cfg.baseIdOfCluster;
/* connect to remote service */
memset(&dstAddr, 0, sizeof(dstAddr));
dstAddr.family = AF_RPMSG;
- /* convert MultiProc 'procId' to remoteproc index */
- dstAddr.vproc_id = _MultiProc_cfg.rprocList[procId];
+ /* convert MultiProc 'clusterId' to remoteproc index */
+ dstAddr.vproc_id = _MultiProc_cfg.rprocList[clusterId];
dstAddr.addr = dst;
len = sizeof(struct sockaddr_rpmsg);
return(0);
}
-int SocketBindAddr(int fd, UInt16 rprocId, UInt32 localAddr)
+int SocketBindAddr(int fd, UInt16 procId, UInt32 localAddr)
{
int err;
socklen_t len;
struct sockaddr_rpmsg srcAddr;
+ UInt16 clusterId;
+
+ /* map procId to clusterId (rprocList[] indexed by clusterId) */
+ clusterId = procId - _MultiProc_cfg.baseIdOfCluster;
/* Now bind to the source address. */
memset(&srcAddr, 0, sizeof(srcAddr));
srcAddr.family = AF_RPMSG;
- /* We bind the remote proc ID, but local address! */
- srcAddr.vproc_id = _MultiProc_cfg.rprocList[rprocId];
+ /* We bind the remote clusterId, but local address! */
+ srcAddr.vproc_id = _MultiProc_cfg.rprocList[clusterId];
srcAddr.addr = localAddr;
len = sizeof(struct sockaddr_rpmsg);