From: Robert Tivy Date: Thu, 7 May 2015 23:53:51 +0000 (-0700) Subject: Add new command-line options to LAD to override static defaults X-Git-Tag: 3.36.00.07~5 X-Git-Url: https://git.ti.com/gitweb?p=ipc%2Fipcdev.git;a=commitdiff_plain;h=591015e8fb4bd1407d7a27fd4984b5587fb0addb Add new command-line options to LAD to override static defaults Add -n support for overriding the total number of processors in the system (not to be confused with number of processors in cluster). Add -r support for overriding the number of reserved MessageQ queues. Add -s support for overriding the Ipc_ProcSync_* type (can be -s ALL|PAIR|NONE). --- diff --git a/hlos_common/include/_MessageQ.h b/hlos_common/include/_MessageQ.h index d972107..836d74f 100644 --- a/hlos_common/include/_MessageQ.h +++ b/hlos_common/include/_MessageQ.h @@ -170,6 +170,8 @@ Void MessageQ_cleanupOwner(Int pid); Void MessageQ_msgInit(MessageQ_Msg msg); +Void _MessageQ_setNumReservedEntries(UInt n); + #if defined (__cplusplus) } #endif /* defined (__cplusplus) */ diff --git a/linux/include/_Ipc.h b/linux/include/_Ipc.h index 0a9ef42..f9df0e3 100644 --- a/linux/include/_Ipc.h +++ b/linux/include/_Ipc.h @@ -56,6 +56,8 @@ typedef struct { Void Ipc_getConfig(Ipc_Config *cfg); +Void Ipc_setConfig(Ipc_Config *cfg); + #if defined (__cplusplus) } #endif diff --git a/linux/src/daemon/Ipc_daemon.c b/linux/src/daemon/Ipc_daemon.c index c3539da..2a12666 100644 --- a/linux/src/daemon/Ipc_daemon.c +++ b/linux/src/daemon/Ipc_daemon.c @@ -54,3 +54,12 @@ Void Ipc_getConfig(Ipc_Config *cfg) assert(cfg != NULL); memcpy(cfg, &ti_ipc_Ipc_config, sizeof(Ipc_Config)); } + +/* + * ======== Ipc_setConfig ======== + */ +Void Ipc_setConfig(Ipc_Config *cfg) +{ + assert(cfg != NULL); + memcpy(&ti_ipc_Ipc_config, cfg, sizeof(Ipc_Config)); +} diff --git a/linux/src/daemon/MessageQ_daemon.c b/linux/src/daemon/MessageQ_daemon.c index dc301c2..15d6e76 100644 --- a/linux/src/daemon/MessageQ_daemon.c +++ b/linux/src/daemon/MessageQ_daemon.c @@ -103,8 +103,6 @@ typedef struct MessageQ_ModuleObject { /*!< Handle of gate to be used for local thread safety */ MessageQ_Config *cfg; /*!< Current config values */ - MessageQ_Config defaultCfg; - /*!< Default config values */ MessageQ_Params defaultInstParams; /*!< Default instance creation parameters */ MessageQ_Handle * queues; @@ -151,10 +149,6 @@ static MessageQ_ModuleObject MessageQ_state = .gate = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, #endif .cfg = &ti_ipc_MessageQ_cfg, - .defaultCfg.traceFlag = FALSE, - .defaultCfg.maxRuntimeEntries = 32u, - .defaultCfg.maxNameLen = 32u, - .defaultCfg.numReservedEntries = 0 }; /*! @@ -183,13 +177,7 @@ Void MessageQ_getConfig(MessageQ_Config * cfg) { assert(cfg != NULL); - /* If setup has not yet been called... */ - if (MessageQ_module->refCount < 1) { - memcpy(cfg, &MessageQ_module->defaultCfg, sizeof(MessageQ_Config)); - } - else { - memcpy(cfg, MessageQ_module->cfg, sizeof(MessageQ_Config)); - } + memcpy(cfg, MessageQ_module->cfg, sizeof(MessageQ_Config)); } /* Function to setup the MessageQ module. */ @@ -529,3 +517,8 @@ Void MessageQ_cleanupOwner(Int pid) } } } + +Void _MessageQ_setNumReservedEntries(UInt n) +{ + MessageQ_module->cfg->numReservedEntries = n; +} diff --git a/linux/src/daemon/lad.c b/linux/src/daemon/lad.c index 87b3260..170c3ec 100644 --- a/linux/src/daemon/lad.c +++ b/linux/src/daemon/lad.c @@ -96,7 +96,10 @@ Options:\n\ h : print this help message\n\ g : enable GateMP support \n\ l : name of logfile for LAD\n\ + n : total number of processors in the system\n\ p : set LAD's directory permissions\n\ + r : number of reserved queues\n\ + s : type of Ipc_ProcSync (ALL|PAIR|NONE)\n\ b : Processor's base cluster id \n\ \n\ Examples:\n\ @@ -113,6 +116,7 @@ Examples:\n\ int main(int argc, char * argv[]) { MessageQ_Handle handle; + Ipc_Config ipcCfg; UInt16 *procIdPtr; Int statusIO; Int clientId; @@ -156,7 +160,7 @@ int main(int argc, char * argv[]) /* process command line args */ while (1) { - c = getopt(argc, argv, "b:ghl:p:"); + c = getopt(argc, argv, "b:ghl:n:p:r:s:"); if (c == -1) { break; } @@ -171,17 +175,9 @@ int main(int argc, char * argv[]) #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); - } + printf("\nSet LAD's base cluster id to %s\n", optarg); + _MultiProc_cfg.id = atoi(optarg); + _MultiProc_cfg.baseIdOfCluster = atoi(optarg); break; case 'h': printf("%s", LAD_USAGE); @@ -204,11 +200,42 @@ int main(int argc, char * argv[]) } } break; + case 'n': + printf("\nSet LAD's number of processors to %s\n", optarg); + _MultiProc_cfg.numProcessors = atoi(optarg); + 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; + case 'r': + printf("\nSet LAD's number of reserved queues to %s\n", optarg); + _MessageQ_setNumReservedEntries(atoi(optarg)); + break; + case 's': + printf("\nSet LAD's synchronization scheme to ProcSync_%s\n", + optarg); + + Ipc_getConfig(&ipcCfg); + + if (!strcmp(optarg, "ALL")) { + ipcCfg.procSync = Ipc_ProcSync_ALL; + } + else if (!strcmp(optarg, "PAIR")) { + ipcCfg.procSync = Ipc_ProcSync_PAIR; + } + else if (!strcmp(optarg, "NONE")) { + ipcCfg.procSync = Ipc_ProcSync_NONE; + } + else { + printf("Error: bad synchronization specified, must be " + "ALL|PAIR|NONE\n"); + exit(EXIT_FAILURE); + } + + Ipc_setConfig(&ipcCfg); + break; default: fprintf (stderr, "\nUnrecognized argument\n"); exit(EXIT_FAILURE); @@ -216,12 +243,24 @@ int main(int argc, char * argv[]) } /* 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 ("\nnumProcessors = %d id = %d baseId = %d\n", + _MultiProc_cfg.numProcessors, _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 ((_MultiProc_cfg.baseIdOfCluster + _MultiProc_cfg.numProcsInCluster) > + _MultiProc_cfg.numProcessors) { + printf("\nNumber of processors (%d) must be >= base cluster id + " + "number of processors in cluster (%d + %d)\n", + _MultiProc_cfg.numProcessors, _MultiProc_cfg.baseIdOfCluster, + _MultiProc_cfg.numProcsInCluster); + exit(EXIT_FAILURE); + } #if DAEMON