diff --git a/linux/src/daemon/lad.c b/linux/src/daemon/lad.c
index daf3870217cc279e8020298f7ba4ec618098c82d..1162c2d3701bf48ec4f60b81c5b79b9e257c4427 100644 (file)
--- a/linux/src/daemon/lad.c
+++ b/linux/src/daemon/lad.c
/*
- * Copyright (c) 2012-2014, Texas Instruments Incorporated
+ * Copyright (c) 2012-2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <_NameServer.h>
#include <ti/ipc/GateMP.h>
#include <_GateMP_daemon.h>
+#include <_MultiProc.h>
#include <GateHWSpinlock.h>
Bool logFile = FALSE;
FILE *logPtr = NULL;
+struct timeval start_tv;
static String commandFIFOFile = LAD_COMMANDFIFO;
static FILE *commandFIFOFilePtr = NULL;
+#if defined(GATEMP_SUPPORT)
static Bool gatempEnabled = FALSE;
+#endif
/* LAD client info arrays */
static Bool clientConnected[LAD_MAXNUMCLIENTS];
h : print this help message\n\
g : enable GateMP support \n\
l <logfile> : name of logfile for LAD\n\
+ p <oct value>: set LAD's directory permissions\n\
+ b <value> : Processor's base cluster id \n\
\n\
Examples:\n\
lad_<platform> -h\n\
lad_<platform> -l log.txt\n\
+ lad_<platform> -l log.txt -p 777\n\
lad_<platform> -g -l log.txt\n\
+ lad_<platform> -l log.txt -b 10\n\
\n"
/*
Int i;
Int n;
Int c;
+#if defined(GATEMP_SUPPORT)
Int status;
+#endif
String tmpString;
#if DAEMON
pid_t pid;
pid_t sid;
#endif
+ /* change to LAD's root directory */
+ if ((chdir(LAD_ROOTDIR)) < 0) {
+ /* if can't change directory assume it needs to be created, do it */
+ if ((mkdir(LAD_ROOTDIR, 0666)) < 0) {
+ printf("\nERROR: Failed to create LAD's root directory!\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+
/* change to LAD's working directory */
if ((chdir(LAD_WORKINGDIR)) < 0) {
/* process command line args */
while (1) {
- c = getopt(argc, argv, "ghl:");
+ c = getopt(argc, argv, "b:ghl:p:");
if (c == -1) {
break;
}
printf("\nGateMP is not supported for this device\n");
#endif
break;
+ case 'b':
+ if (_MultiProc_cfg.id == 0xFFFF &&
+ _MultiProc_cfg.baseIdOfCluster == 0xFFFF) {
+ printf("\nSetting base cluster id to %s\n", optarg);
+ _MultiProc_cfg.id = atoi(optarg);
+ _MultiProc_cfg.baseIdOfCluster = atoi(optarg);
+ }
+ else {
+ printf("\nBase cluster id in the MultiProcCfg file must be\n"
+ "set to MultiProc_INVALIDID(0xFFFF) when using -b option\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
case 'h':
printf("%s", LAD_USAGE);
exit(0);
}
else {
logFile = TRUE;
- printf("\nOpened log file: %s", optarg);
+ gettimeofday(&start_tv, NULL);
+ printf("\nOpened log file: %s\n", optarg);
/* close log file upon LAD termination */
flags = fcntl(fileno(logPtr), F_GETFD);
if (flags != -1) {
}
}
break;
+ case 'p':
+ printf("\nSet LAD's directory permissions to '%s'\n", optarg);
+ chmod(LAD_ROOTDIR, strtol(optarg, NULL, 8));
+ chmod(LAD_WORKINGDIR, strtol(optarg, NULL, 8));
+ break;
default:
fprintf (stderr, "\nUnrecognized argument\n");
exit(EXIT_FAILURE);
}
}
+ /* Check to ensure id and baseId are not invalid */
+ printf ("id = %d baseId= %d\n", _MultiProc_cfg.id, _MultiProc_cfg.baseIdOfCluster);
+ if (_MultiProc_cfg.id == 0xFFFF || _MultiProc_cfg.baseIdOfCluster == 0xFFFF){
+ printf("\nBase cluster id is set to an INVALID value\n");
+ printf("Use -b option to set value or modify the MultiProcCfg file\n");
+ exit(EXIT_FAILURE);
+ }
+
+
#if DAEMON
/* fork off a child process */
pid = fork();
@@ -829,6 +877,9 @@ static Int connectToLAD(String clientName, Int pid, String clientProto, Int *cli
openResponseFIFO:
+ /* if response FIFO exists from previous LAD session delete it now */
+ unlink(clientName);
+
/* create the dedicated response FIFO to the client */
statusIO = mkfifo(clientName, 0777);
if (statusIO != 0) {