summaryrefslogtreecommitdiffstats
path: root/data/mnet/Common/Os
diff options
context:
space:
mode:
Diffstat (limited to 'data/mnet/Common/Os')
-rw-r--r--data/mnet/Common/Os/Makefile28
-rw-r--r--data/mnet/Common/Os/include/JCMsgQDefs.h40
-rw-r--r--data/mnet/Common/Os/loadmodule/LoadModule.cpp195
-rw-r--r--data/mnet/Common/Os/loadmodule/Makefile62
-rw-r--r--data/mnet/Common/Os/src/JCCTimer.cpp91
-rw-r--r--data/mnet/Common/Os/src/JCModule.cpp470
-rw-r--r--data/mnet/Common/Os/src/JCMsgQueue.cpp197
-rw-r--r--data/mnet/Common/Os/src/JCMutex.cpp43
-rw-r--r--data/mnet/Common/Os/src/JCTask.cpp193
-rw-r--r--data/mnet/Common/Os/src/Makefile62
-rw-r--r--data/mnet/Common/Os/test/Makefile65
-rw-r--r--data/mnet/Common/Os/test/MsgQTest.cpp91
12 files changed, 1537 insertions, 0 deletions
diff --git a/data/mnet/Common/Os/Makefile b/data/mnet/Common/Os/Makefile
new file mode 100644
index 0000000..9347a18
--- /dev/null
+++ b/data/mnet/Common/Os/Makefile
@@ -0,0 +1,28 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1: make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2: make all VOB=GP10 APPDIR=Host\vxTemplate\bin -
+# Places .o file(s) in VOB/$(APPDIR) directory.
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+SUBDIRS = src loadmodule
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+VOBDIR = $(TOP_OF_VOB)\$(VOB)
+
+include $(VOBDIR)\l3defs.mk
+
+
diff --git a/data/mnet/Common/Os/include/JCMsgQDefs.h b/data/mnet/Common/Os/include/JCMsgQDefs.h
new file mode 100644
index 0000000..45e2730
--- /dev/null
+++ b/data/mnet/Common/Os/include/JCMsgQDefs.h
@@ -0,0 +1,40 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMsgQDefs.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCMSGQDEFS_H_
+#define _JCMSGQDEFS_H_ /* include once only */
+
+#include "Os/JCMsgQueue.h"
+#include "MnetModuleId.h"
+
+
+/* THIS IS FOR MESSAGE QUEUE INTERNAL ONLY!!!! */
+
+typedef struct jc_msg_hdr {
+ JCMsgQueue *rplyQ; /* identifier of queue to which to reply,
+ if any */
+ unsigned int msgType; /* module dependent message type */
+ MNET_MODULE_ID modId; /* module ID of sender */
+ int bytes; /* size of associated data */
+ } JC_MSG_HDR;
+/* data follows header */
+
+
+#define JC_MSG_HDR_SIZE sizeof(JC_MSG_HDR)
+
+
+#endif
diff --git a/data/mnet/Common/Os/loadmodule/LoadModule.cpp b/data/mnet/Common/Os/loadmodule/LoadModule.cpp
new file mode 100644
index 0000000..a339b48
--- /dev/null
+++ b/data/mnet/Common/Os/loadmodule/LoadModule.cpp
@@ -0,0 +1,195 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : LoadModule.cpp
+// Author(s) : Kevin Lim
+// Create Date : 04-14-99
+// Description : Functions to load modules
+//
+// *******************************************************************
+
+// *******************************************************************
+// Include Files.
+// *******************************************************************
+#include "vxWorks.h"
+#include "dosFsLib.h"
+#include "loadLib.h"
+#include "ioLib.h"
+#include "stdio.h"
+#include "string.h"
+
+#ifdef GMC_VOB_SPECIFIC
+#include <oam_api.h>
+#include <vipermib.h>
+#endif /* GMC_VOB_SPECIFIC */
+
+#define UNIX_FILE_EOFS
+
+#ifdef UNIX_FILE_EOFS
+#define EOL_TRUNC_LEN 1
+#else
+#define EOL_TRUNC_LEN 2
+#endif
+
+// *******************************************************************
+int viperLoad(char * filename)
+{
+ int fd;
+ MODULE_ID mId;
+
+#ifdef NEVER // changed from GMC_VOB_SPECIFIC by oleg
+ Ss7Type* networkType;
+ char* fn;
+
+ if ((fn = strstr(filename, "gmccpapp.out"))
+ != NULL)
+ {
+ if( NULL != ( networkType = (Ss7Type*)oam_getMibAddress( MIB_ss7NetworkType ) ))
+ {
+
+ if (*networkType == ansi)
+ {
+ printf ("Mib returned ansi for loading.\n");
+ strcpy(fn, "gmccpapp-ansi.out");
+ }
+ else
+ {
+ printf ("Mib returned itu for loading.\n");
+ strcpy(fn, "gmccpapp-itu.out");
+ }
+ }
+ else
+ {
+ printf ("Major Error reading network type from the Mib. Cannot load GMC CP.\n");
+ return (-1);
+ }
+ }
+
+#endif /* GMC_VOB_SPECIFIC */
+
+ printf("Loading %s\n", filename);
+ fd = open (filename, 0, 0);
+ if(fd == ERROR)
+ {
+ // error on open object file
+ printf("[loadMod] Fatal Error on fopen(%s) return ERROR\n", filename);
+ return ERROR;
+ }
+ mId = loadModule (fd, LOAD_ALL_SYMBOLS);
+ if(mId == NULL)
+ {
+ // error on loading module
+ printf("[loadMod] Fatal Error on loadModule() return NULL\n");
+ return (-1);
+ }
+ close (fd);
+ return (int)mId;
+}
+
+// *******************************************************************
+#define VIPER_MAX_BASE_PREFIX 100
+#define VIPER_MAX_MODULE_LINE 180
+// *******************************************************************
+extern "C"
+{
+void viperLoadList(char * filename, char * base, int append)
+{
+ char base_line[VIPER_MAX_MODULE_LINE];
+ char line[VIPER_MAX_MODULE_LINE];
+ FILE * fd;
+ char * lp;
+ int base_len = strlen(base);
+ int i, line_len;
+ bool done = false;
+
+ if(base_len > VIPER_MAX_BASE_PREFIX){
+ printf("[viperLoadList] base string too long %d\n", base_len);
+ return;
+ }
+ else{
+ for(i=0; i<base_len; i++) base_line[i] = base[i];
+ base_line[i]='/';
+ base_len++;
+ }
+
+ if(append){
+ int filename_len = strlen(filename);
+ if((base_len+filename_len)>VIPER_MAX_MODULE_LINE){
+ printf("[viperLoadList] base + module list name too long: %d\n", base_line+filename_len);
+ printf("%s%s\n", base_line, filename);
+ return;
+ }
+ for(i=0; i<filename_len; i++) base_line[base_len+i] = filename[i];
+ // mark null
+ base_line[base_len+i] = '\0';
+ fd = fopen(base_line, "r");
+ if(fd == NULL){
+ printf("[viperLoadList] Error on openning module list file: %s\n", base_line);
+ return;
+ }
+ else{
+ printf("[viperLoadList] Loading modules from: %s\n", base_line);
+ }
+ }
+ else{
+ fd = fopen(filename, "r");
+ if(fd == NULL){
+ printf("[viperLoadList] Error on openning module list file: %s\n", filename);
+ return;
+ }
+ else{
+ printf("[viperLoadList] Loading modules from: %s\n", filename);
+ }
+ }
+
+ while(!done){
+ lp = fgets(line, 80, fd);
+ if(lp == NULL){
+ done = true;
+ }
+ else{ // parse the line
+ line_len = strlen(lp);
+ if(lp[0] == '#'){ // do not append base
+ if(line_len>VIPER_MAX_MODULE_LINE){
+ printf("[viperLoadList] module line too long: %d\n", line_len);
+ printf("%s\n", line);
+ fclose(fd);
+ return;
+ }
+ // mark null at eol
+ lp[line_len-EOL_TRUNC_LEN] = '\0';
+ viperLoad(&line[1]); // exclude #
+ }
+ else if(lp[0] == '!'){ // comment fields
+ printf("%s", lp);
+ }
+ else if(line_len<3){ // probably blank line
+
+ }
+ else{ //append to the line
+ if((base_len+line_len)>VIPER_MAX_MODULE_LINE){
+ printf("[viperLoadList] base + module line too long: %d\n", base_line+line_len);
+ printf("%s%s\n", base_line, line);
+ fclose(fd);
+ return;
+ }
+ for(i=0; i<line_len; i++) base_line[base_len+i] = lp[i];
+ // mark null
+ base_line[base_len+i-EOL_TRUNC_LEN] = '\0';
+ viperLoad(base_line);
+ }
+ } // end parse
+ }
+ fclose(fd);
+}
+}
+
+
diff --git a/data/mnet/Common/Os/loadmodule/Makefile b/data/mnet/Common/Os/loadmodule/Makefile
new file mode 100644
index 0000000..5eeffdb
--- /dev/null
+++ b/data/mnet/Common/Os/loadmodule/Makefile
@@ -0,0 +1,62 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+COMMON_APP_DIR = loadmodule
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(COMMON_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(COMMON_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/Os/src/JCCTimer.cpp b/data/mnet/Common/Os/src/JCCTimer.cpp
new file mode 100644
index 0000000..d2de948
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCCTimer.cpp
@@ -0,0 +1,91 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCCTimer.cpp
+// Author(s) : Bhava Nelakanti
+// Create Date : 10-19-98
+// Description : interface specification for - JCCTimer
+//
+// *******************************************************************
+
+// *******************************************************************
+// Include Files.
+// *******************************************************************
+
+#include <stdio.h>
+#include "Os/JCCTimer.h"
+
+extern "C" int sysClkRateGet (void);
+
+#define JCCLog printf
+
+int JCCTimer::tickPerSec = sysClkRateGet();
+
+
+void JCCTimer::cancelTimer()
+{
+ if (timerSet_ == true)
+ {
+ wdCancel(timerId_);
+ timerSet_ = false;
+ }
+}
+
+JCCTimer::~JCCTimer()
+{
+ wdDelete(timerId_);
+}
+
+JCCTimer::JCCTimer (FUNCPTR fPtr ,
+ int timerData)
+ :timerData_(timerData),
+ funcPtr_ (fPtr) ,
+ timerSet_ (false)
+{
+ init ();
+}
+
+
+JCCTimer::JCCTimer (FUNCPTR fPtr)
+ :timerData_(-1) ,
+ funcPtr_ (fPtr) ,
+ timerSet_ (false)
+{
+ init ();
+}
+
+
+void JCCTimer::setTimer(int howLong)
+{
+ if (timerSet_ == true)
+ {
+ cancelTimer();
+ }
+
+ wdStart(timerId_, howLong, funcPtr_, timerData_);
+
+ timerSet_ = true;
+}
+
+
+void JCCTimer::init()
+{
+ if (!tickPerSec)
+ tickPerSec = sysClkRateGet ();
+
+ if ((timerId_ = wdCreate()) == NULL)
+ {
+ // Handle Operating System Resource Allocation Error
+ JCCLog("JCC Error - Operating System Resource Allocation Error:\n");
+ JCCLog(" - WatchDog Timer could not be created.\n");
+ }
+}
+
diff --git a/data/mnet/Common/Os/src/JCModule.cpp b/data/mnet/Common/Os/src/JCModule.cpp
new file mode 100644
index 0000000..a94a73b
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCModule.cpp
@@ -0,0 +1,470 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCModule.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+
+#include <stdio.h>
+#include <errNoLib.h>
+#include <string.h>
+#include <ioLib.h>
+#include <dbgLib.h>
+#include <usrLib.h>
+#include "Os/JCModule.h"
+#include "AlarmCode.h"
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule constructor
+**
+** PURPOSE: Initialize data members for JCModule object.
+**
+** INPUT PARAMETERS: id - module id
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCModule::JCModule
+(
+ MNET_MODULE_ID id,
+ JC_SYSCMD_FUNC cmdFunc,
+ char *cmdFuncStr
+) : modId(id), numRun(0), numSub(0)
+{
+ char *name = GetMnetModuleName(id);
+ if (name)
+ {
+ modName = new char[strlen(name) + 1];
+ if (modName)
+ {
+ strcpy(modName, name);
+ }
+ else
+ {
+ printf("JCModule::JCModule ERROR: Unable to allocate memory\n");
+ }
+ }
+ else
+ {
+ modName = 0;
+ }
+
+
+ if (!TestSym(cmdFuncStr))
+ {
+ syscmd = cmdFunc;
+ isModuleLoaded = TRUE;
+ }
+ else
+ {
+ isModuleLoaded = FALSE;
+ }
+
+ for (int i=0; i < MAX_NUM_SUB_TASKS; i++)
+ {
+ tasks[i] = 0;
+ }
+}
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule destructor
+**
+** PURPOSE: Delete data members for JCModule object.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCModule::~JCModule ()
+{
+ delete [] modName;
+}
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule InsertTaskInfo
+**
+** PURPOSE: InsertTaskInfo adds the task object to the list of tasks
+** currently running under this module.
+**
+** INPUT PARAMETERS: id - module id
+** pTask - pointer to the new task object
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCModule::InsertTaskInfo(MNET_MODULE_ID id, JCTask *pTask)
+{
+ for (int j=0; j < MNET_MAX_MODULE_IDS; j++)
+ {
+ if (systemModules[j])
+ {
+ if (systemModules[j]->modId == id)
+ {
+ for (int i=0; i < MAX_NUM_SUB_TASKS; i++)
+ {
+ if (!systemModules[j]->tasks[i])
+ {
+ systemModules[j]->tasks[i] = pTask;
+ systemModules[j]->numSub++;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule StartModule
+**
+** PURPOSE: StartModule sends a SYS_START system command to the module.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): TRUE - if module is loaded
+** FALSE - if module is not loaded
+**
+**----------------------------------------------------------------------------*/
+bool JCModule::StartModule()
+{
+ bool ret = FALSE;
+
+ if (isModuleLoaded)
+ {
+ if (!numRun)
+ {
+ printf("SysCommand(SYS_START): %s\n", modName);
+
+ syscmd(SYS_START);
+ numRun++;
+ }
+ else
+ {
+ printf("Module %d already started\n", modId);
+ }
+ ret = TRUE;
+ }
+
+ return(ret);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule ShutdownModule
+**
+** PURPOSE: StartModule sends a SYS_SHUTDOWN system command to the module.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCModule::ShutdownModule()
+{
+ if (isModuleLoaded)
+ {
+ printf("SysCommand(SYS_SHUTDOWN): %s\n", modName);
+ syscmd(SYS_SHUTDOWN);
+ }
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule RebootModule
+**
+** PURPOSE: StartModule sends a SYS_REBOOT system command to the module.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCModule::RebootModule()
+{
+ if (isModuleLoaded)
+ {
+ printf("SysCommand(SYS_REBOOT): %s\n", modName);
+ syscmd(SYS_REBOOT);
+ }
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule CheckModule
+**
+** PURPOSE: CheckModule verifies that all tasks associated with this module
+** are currently running.
+**
+** INPUT PARAMETERS: pTask - if problems a pointer to the troubled task
+** with the highest criticality
+**
+** RETURN VALUE(S): SYSTEM_MODULE_STATUS
+**
+**----------------------------------------------------------------------------*/
+SYSTEM_MODULE_STATUS JCModule::CheckModule(JCTask **pTask)
+{
+ SYSTEM_MODULE_STATUS retCode = MODULE_OK;
+ *pTask = 0;
+ if (isModuleLoaded)
+ {
+ char *tName;
+ for(int i=0; i < numSub; i++){
+ // check for exit abnormal
+ tName = taskName(tasks[i]->GetTaskId());
+ if(tName == NULL)
+ {
+ printf("Alert! found missing task(%s)\n", tasks[i]->GetTaskName());
+
+ if (!*pTask)
+ {
+ retCode = TASK_MISSING;
+ *pTask = tasks[i];
+ }
+ else if ((tasks[i]->GetTaskImportance() == JC_CRITICAL_TASK) &&
+ ((*pTask)->GetTaskImportance() == JC_NON_CRITICAL_TASK))
+ {
+ retCode = TASK_MISSING;
+ *pTask = tasks[i];
+ }
+ }
+ // check for suspended
+ else if(taskIsSuspended(tasks[i]->GetTaskId()))
+ {
+ char coreFileName[128];
+ char *pMnetBase;
+ int coreFd = ERROR;
+ int stdoutFd, stderrFd;
+
+ // Create a core file for this task.
+ pMnetBase = getenv("MNET_BASE");
+
+ if (pMnetBase && !tasks[i]->GetTaskAlarmStatus())
+ {
+ strcpy(coreFileName, pMnetBase);
+ strcat(coreFileName, "\\");
+ strcat(coreFileName, tasks[i]->GetTaskName());
+ strcat(coreFileName, ".dmp");
+
+ // If the file was created replace stdout and stderr with the
+ // file descriptor for the task core file.
+ if ((coreFd = creat(coreFileName, O_RDWR)) != ERROR)
+ {
+ stdoutFd = ioGlobalStdGet(1);
+ stderrFd = ioGlobalStdGet(2);
+ ioGlobalStdSet(1, coreFd);
+ ioGlobalStdSet(2, coreFd);
+ }
+ }
+
+ printf("Alert! found suspended task(%s)\n", tasks[i]->GetTaskName());
+ tt(tasks[i]->GetTaskId());
+ ti(tasks[i]->GetTaskId());
+ tasks[i]->ExecuteCoreDumpFunc();
+
+ // If a core file was created then return stdout and stderr.
+ if (coreFd != ERROR)
+ {
+ ioGlobalStdSet(1, stdoutFd);
+ ioGlobalStdSet(2, stderrFd);
+ close(coreFd);
+ printf("Alert! found suspended task(%s)\n", tasks[i]->GetTaskName());
+ tt(tasks[i]->GetTaskId());
+ ti(tasks[i]->GetTaskId());
+ tasks[i]->ExecuteCoreDumpFunc();
+ }
+
+ if (!*pTask)
+ {
+ retCode = TASK_SUSPENDED;
+ *pTask = tasks[i];
+ }
+ else if ((tasks[i]->GetTaskImportance() == JC_CRITICAL_TASK) &&
+ ((*pTask)->GetTaskImportance() == JC_NON_CRITICAL_TASK))
+ {
+ retCode = TASK_SUSPENDED;
+ *pTask = tasks[i];
+ }
+ }
+ }
+ }
+
+ return(retCode);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule AllTasksInMainLoop
+**
+** PURPOSE: Check to see if all tasks are in the main loop.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): TRUE - all in main
+** FALSE - not all tasks in main loop
+**
+**----------------------------------------------------------------------------*/
+bool JCModule::AllTasksInMainLoop()
+{
+ for (int i=0; i < MNET_MAX_MODULE_IDS; i++)
+ {
+ if (systemModules[i])
+ {
+ for (int j=0; j < MAX_NUM_SUB_TASKS; j++)
+ {
+ if (systemModules[i]->tasks[j])
+ {
+ if (systemModules[i]->tasks[j]->GetTaskStatus() != JC_TASK_LOOP)
+ {
+ return (FALSE);
+ }
+ }
+ }
+ }
+ }
+
+ return (TRUE);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule ShowModuleStat
+**
+** PURPOSE: Display module status.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+extern "C"
+{
+void ShellShowModuleStat()
+{
+ JCModule::ShowModuleStat();
+}
+}
+
+void JCModule::ShowModuleStat()
+{
+ int totalTasks, totalInit, totalIdle, totalLoop, totalExit, totalUnknown;
+
+ printf ("System Module Status\n");
+
+ for (int i=0; i < MNET_MAX_MODULE_IDS; i++)
+ {
+ if (systemModules[i])
+ {
+ totalTasks = 0;
+ totalInit = 0;
+ totalIdle = 0;
+ totalLoop = 0;
+ totalExit = 0;
+ totalUnknown = 0;
+
+ for (int j=0; j < MAX_NUM_SUB_TASKS; j++)
+ {
+ if (systemModules[i]->tasks[j])
+ {
+ totalTasks++;
+ switch (systemModules[i]->tasks[j]->GetTaskStatus())
+ {
+ case JC_TASK_IDLE :
+ totalIdle++;
+ break;
+ case JC_TASK_INIT :
+ totalInit++;
+ break;
+ case JC_TASK_LOOP :
+ totalLoop++;
+ break;
+ case JC_TASK_EXIT :
+ totalExit++;
+ break;
+ default :
+ totalUnknown++;
+ }
+ }
+ }
+ printf("\tModule - %s\n", systemModules[i]->modName);
+ printf("\t\tTotalTasks(%d) Idle(%d) Init(%d) Loop(%d) Exit(%d) Unknown(%d)\n",
+ totalTasks, totalIdle, totalInit, totalLoop, totalExit, totalUnknown);
+ }
+ }
+
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule CheckSym
+**
+** PURPOSE: CheckSym does a string compare to see if against the symbol.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): 0 - string match
+** 1 - no string match
+**
+**----------------------------------------------------------------------------*/
+int JCModule::CheckSym(char *name, int val, SYM_TYPE type, int arg, UINT16 group)
+{
+ if(strstr(name, (char *)arg))
+ {
+ return 0; // exit symEach
+ }
+ return 1; // continue
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCModule TestSym
+**
+** PURPOSE: Loop through each symbol in the symbol table testing if the
+** string given matches a valid symbol.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): 0 - symbol found
+** 1 - symbol not found
+**
+**----------------------------------------------------------------------------*/
+int JCModule::TestSym(char *str)
+{
+ SYMBOL *symbol = symEach(sysSymTbl, (FUNCPTR)JCModule::CheckSym, (int)str);
+
+ if(symbol) return 0;
+ else
+ {
+ printf("[WARNING] function not found from symbol table: %s\n", str);
+ return 1;
+ }
+}
diff --git a/data/mnet/Common/Os/src/JCMsgQueue.cpp b/data/mnet/Common/Os/src/JCMsgQueue.cpp
new file mode 100644
index 0000000..f58a9b2
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCMsgQueue.cpp
@@ -0,0 +1,197 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMsgQueue.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+//
+// Revision history:
+// ===================================================================
+// Igal | 11/30/00 | Fixed incorrect max message size acceptable by the queue
+// -------------------------------------------------------------------
+//
+//
+
+#include <stdio.h>
+#include <errNoLib.h>
+#include <string.h>
+#include "Os/JCMsgQueue.h"
+#include "JCMsgQDefs.h"
+
+#define PADDING 4
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue constructor
+**
+** PURPOSE: Initialize data members for JCMsgQueue object. A message
+** queue for the native operating system will be created.
+**
+** INPUT PARAMETERS: maxMsgs - max msgs that can be queued
+** maxMsgLength - max bytes in a msg
+** options - message queue options (MSG_Q_FIFO or
+** MSG_Q_PRIORITY)
+**
+** RETURN VALUE(S): none
+** Note: If the message queue cannot be created msgQId will be set to NULL
+**
+**----------------------------------------------------------------------------*/
+JCMsgQueue::JCMsgQueue
+(
+ int maxMsgs, /* max msgs that can be queued */
+ int maxMsgLength, /* max bytes in a msg */
+ int options /* message queue options */
+) : msgQMaxLen(maxMsgLength+PADDING)
+{
+ if (!(msgQId = msgQCreate(maxMsgs, msgQMaxLen + JC_MSG_HDR_SIZE, options)))
+ {
+ printf("Error creating message queue %s\n", errnoGet());
+ }
+
+ if (!(msgQSndBuf = new char[msgQMaxLen + JC_MSG_HDR_SIZE]))
+ {
+ printf("Error: unable to allocate msg buffer memory\n");
+ }
+
+ if (!(msgQRcvBuf = new char[msgQMaxLen + JC_MSG_HDR_SIZE]))
+ {
+ printf("Error: unable to allocate msg buffer memory\n");
+ }
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue destructor
+**
+** PURPOSE: Delete data members for JCMsgQueue object.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCMsgQueue::~JCMsgQueue ()
+{
+ if (msgQDelete(msgQId) != OK)
+ {
+ printf("Error deleting message queue %s\n", errnoGet());
+ }
+
+ delete [] msgQSndBuf;
+ delete [] msgQRcvBuf;
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue::JCMsgQSend
+**
+** PURPOSE: JCMsgQSend sends the specified message to the specified message
+** queue. The buffer given will be copied into a local send buffer prior
+** to sending the message.
+**
+** INPUT PARAMETERS: replyMsgQ - message queue to use for sending a reply
+** msgType - type of message being sent
+** modId - module ID of sender
+** buffer - message to send
+** nBytes - number of bytes in the message
+** timeout - ticks to wait
+** priority - priority of the message (normal or urgent)
+**
+** RETURN VALUE(S): JC_STATUS
+**
+**----------------------------------------------------------------------------*/
+JC_STATUS JCMsgQueue::JCMsgQSend
+(
+ JCMsgQueue *replyMsgQ,
+ unsigned int msgType,
+ MNET_MODULE_ID modId,
+ char * buffer,
+ unsigned int nBytes,
+ int timeout,
+ int priority
+)
+{
+ // Verify a few parameters first.
+ if (nBytes && !buffer)
+ return JC_PARAM_INVALID;
+
+ if (nBytes > msgQMaxLen-PADDING)
+ return JC_MSG_LENGTH_ERROR;
+
+ // Build message in the receive message buffer for this queue.
+ JC_MSG_HDR *pMsg = (JC_MSG_HDR *)msgQSndBuf;
+
+ pMsg->rplyQ = replyMsgQ;
+ pMsg->msgType = msgType ;
+ pMsg->modId = modId ;
+ pMsg->bytes = nBytes ;
+ if (buffer)
+ memcpy (msgQSndBuf + JC_MSG_HDR_SIZE, buffer, nBytes);
+
+ return (msgQSend(msgQId, msgQSndBuf, nBytes + JC_MSG_HDR_SIZE, timeout, priority));
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCMsgQueue::JCMsgQReceive
+**
+** PURPOSE: JCMsgQReceive.
+**
+** INPUT PARAMETERS: replyMsgQ - message queue to use for sending a reply
+** msgType - type of message being sent
+** modId - module ID of sender
+** buffer - message to send
+** nBytes - number of bytes in the message
+** timeout - ticks to wait
+**
+** RETURN VALUE(S): number of bytes received
+**
+**----------------------------------------------------------------------------*/
+int JCMsgQueue::JCMsgQReceive
+(
+ JCMsgQueue **replyMsgQ,
+ unsigned int *msgType,
+ MNET_MODULE_ID *modId,
+ char * buffer,
+ unsigned int *nBytes,
+ int timeout
+)
+{
+ int bytesRcvd;
+
+ // Verify a few parameters first.
+ if ((!buffer) || (!replyMsgQ) || (!msgType) || (!nBytes))
+ return JC_PARAM_INVALID;
+
+
+ // Wait here for a message to arrive or timeout number of ticks to expire.
+ if ((bytesRcvd = msgQReceive(msgQId, msgQRcvBuf, msgQMaxLen + JC_MSG_HDR_SIZE,
+ timeout)) != ERROR)
+ {
+ // Access the message header at the start of the buffer.
+ JC_MSG_HDR *pMsg = (JC_MSG_HDR *)msgQRcvBuf;
+
+ *replyMsgQ = pMsg->rplyQ;
+ *msgType = pMsg->msgType;
+ *modId = pMsg->modId;
+ *nBytes = pMsg->bytes;
+
+ // Message contents should follow the message header.
+ memcpy(buffer, msgQRcvBuf + JC_MSG_HDR_SIZE, bytesRcvd - JC_MSG_HDR_SIZE);
+ }
+
+ return (bytesRcvd);
+}
diff --git a/data/mnet/Common/Os/src/JCMutex.cpp b/data/mnet/Common/Os/src/JCMutex.cpp
new file mode 100644
index 0000000..5077cf5
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCMutex.cpp
@@ -0,0 +1,43 @@
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMutex.cpp
+// Author(s) : Igal Gutkin
+// Create Date : 11/06/00
+// Description : JCMutex class (Mutual-Exclusion Semapore) implementation
+//
+// *******************************************************************
+
+#include "Os\JCMutex.h"
+
+
+JCMutex::JCMutex ()
+{
+ semId_ = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
+}
+
+
+bool JCMutex::take ()
+{
+ return (semId_ && semTake (semId_, WAIT_FOREVER) == OK);
+}
+
+
+bool JCMutex::give ()
+{
+ return (semId_ && semGive (semId_) == OK);
+}
+
+
+JCMutex::~JCMutex ()
+{
+ semDelete (semId_);
+}
diff --git a/data/mnet/Common/Os/src/JCTask.cpp b/data/mnet/Common/Os/src/JCTask.cpp
new file mode 100644
index 0000000..8488da3
--- /dev/null
+++ b/data/mnet/Common/Os/src/JCTask.cpp
@@ -0,0 +1,193 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCTask.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+
+#include <stdio.h>
+#include <errNoLib.h>
+#include <string.h>
+#include "Os/JCTask.h"
+#include "Os/JCModule.h"
+
+SEM_ID *pMnetSyncSem;
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask constructor
+**
+** PURPOSE: Initialize data members for JCTask object.
+**
+** INPUT PARAMETERS: name - name of the task
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCTask::JCTask
+(
+ char *name /* name of the task */
+) : taskStatus(JC_TASK_IDLE), taskAlarmed(FALSE)
+{
+ if (name)
+ {
+ taskName = new char[strlen(name) + 1];
+ if (taskName)
+ {
+ strcpy(taskName, name);
+ }
+ else
+ {
+ printf("JCTask::JCTask ERROR: Unable to allocate memory\n");
+ }
+ }
+ else
+ {
+ taskName = 0;
+ }
+}
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask destructor
+**
+** PURPOSE: Delete data members for JCTask object.
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+JCTask::~JCTask ()
+{
+ delete [] taskName;
+}
+
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask::JCTaskSpawn
+**
+** PURPOSE: Spawn a task.
+**
+** INPUT PARAMETERS: priority - (0-255)
+** options - option word
+** stackSize - size in bytes of stack
+** entryPt - entry point of task
+** arg1 - argument 1 passed to entryPt
+** arg2 - argument 1 passed to entryPt
+** arg3 - argument 1 passed to entryPt
+** arg4 - argument 1 passed to entryPt
+** arg5 - argument 1 passed to entryPt
+** arg6 - argument 1 passed to entryPt
+** arg7 - argument 1 passed to entryPt
+** arg8 - argument 1 passed to entryPt
+** arg9 - argument 1 passed to entryPt
+** arg10 - NOT AN ARGUMENT!!!! This parameter can be used
+** to pass a function pointer to a function that
+** will be called if the task is suspended.
+** modId - module id number
+** importance - critical or non-critical
+**
+** RETURN VALUE(S): taskId or ERROR
+**
+**----------------------------------------------------------------------------*/
+int JCTask::JCTaskSpawn
+(
+ int priority, /* priority of new task */
+ int options, /* task option word */
+ int stackSize, /* size (bytes) of stack needed plus name */
+ FUNCPTR entryPt, /* entry point of new task */
+ int arg1, /* 1st of 10 req'd task args to pass to func */
+ int arg2,
+ int arg3,
+ int arg4,
+ int arg5,
+ int arg6,
+ int arg7,
+ int arg8,
+ int arg9,
+ int arg10,
+ MNET_MODULE_ID modId,
+ JC_TASK_IMPORTANCE importance
+)
+{
+
+ JCModule::InsertTaskInfo(modId, this);
+ taskPri = priority;
+ taskOpt = options;
+ taskStackSize = stackSize;
+ taskEntryPt = entryPt;
+ taskArg1 = arg1;
+ taskArg2 = arg2;
+ taskArg3 = arg3;
+ taskArg4 = arg4;
+ taskArg5 = arg5;
+ taskArg6 = arg6;
+ taskArg7 = arg7;
+ taskArg8 = arg8;
+ taskArg9 = arg9;
+ taskArg10 = arg10;
+ taskImportance = importance;
+ moduleId = modId;
+ taskStatus = JC_TASK_INIT;
+ coreDumpFunc = (FUNCPTR)arg10;
+
+ taskId = taskSpawn(taskName, priority, options, stackSize, entryPt,
+ arg1, arg2, arg3, arg4, arg5,
+ arg6, arg7, arg8, arg9, 0);
+
+ return(taskId);
+}
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask::JCTaskEnterLoop()
+**
+** PURPOSE:
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCTask::JCTaskEnterLoop()
+{
+ taskStatus = JC_TASK_LOOP;
+
+ // Spin here waiting for all other tasks to call enter loop.
+ if (pMnetSyncSem)
+ semBTake(*pMnetSyncSem, WAIT_FOREVER);
+}
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: JCTask::JCTaskNormExit()
+**
+** PURPOSE:
+**
+** INPUT PARAMETERS: none
+**
+** RETURN VALUE(S): none
+**
+**----------------------------------------------------------------------------*/
+void JCTask::JCTaskNormExit()
+{
+ taskStatus = JC_TASK_EXIT;
+}
diff --git a/data/mnet/Common/Os/src/Makefile b/data/mnet/Common/Os/src/Makefile
new file mode 100644
index 0000000..e5c0242
--- /dev/null
+++ b/data/mnet/Common/Os/src/Makefile
@@ -0,0 +1,62 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+# Name of this App's Directory
+COMMON_APP_DIR = os
+
+VOB2DIR = $(TOP_OF_VOB)\..\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\$(COMMON_APP_DIR).out
+else
+ MY_OUTPUT = $(OBJDIR)\$(COMMON_APP_DIR).out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/Os/test/Makefile b/data/mnet/Common/Os/test/Makefile
new file mode 100644
index 0000000..2ca8e4a
--- /dev/null
+++ b/data/mnet/Common/Os/test/Makefile
@@ -0,0 +1,65 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+# Use Examples:
+#
+# Case 1:
+# make all VOB=GP10 -
+# Places .out in VOB/bin directory
+#
+# Case 2:
+# make all VOB=GP10 APPDIR=Host\<Application Name>\<Source Directory> -
+# Places .o file(s) in VOB\$(APPDIR)\bin directory.
+#
+# <Application Name> = Name of Application directory
+# <Source Directory> = application sub directory where the calling
+# Makefile resides.
+#
+# Example: make all VOB=GP10 APPDIR=Host\vxTemplate\src
+#
+#
+# Note: This make file must reference a VOB that
+# has a defs.mk in the top level directory.
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# Name of this App's Directory
+COMMON_APP_DIR = Os
+
+VOB2DIR = $(TOP_OF_VOB)\$(VOB)
+BINDIR = ..\bin
+
+ifeq ($(APPDIR),)
+ MY_OUTPUT = $(VOB2DIR)\bin\OsTest.out
+else
+ MY_OUTPUT = $(OBJDIR)\OsTest.out
+endif
+
+include $(VOB2DIR)\l3defs.mk
+
+
+all: $(MY_OUTPUT)
+
+$(MY_OUTPUT): $(MODULE_OBJS)
+ $(LD) -r -o $@.tmp $(MODULE_OBJS)
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+ifneq ($(APPDIR),)
+ $(CP) $(BINDIR)\*.o $(VOB2DIR)\$(APPDIR)\bin\*.o
+endif
+
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+
diff --git a/data/mnet/Common/Os/test/MsgQTest.cpp b/data/mnet/Common/Os/test/MsgQTest.cpp
new file mode 100644
index 0000000..e762b40
--- /dev/null
+++ b/data/mnet/Common/Os/test/MsgQTest.cpp
@@ -0,0 +1,91 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : MsgQTest.cpp
+// Author(s) : Tim Olson
+// Create Date : 10/18/2000
+// Description :
+//
+// *******************************************************************
+
+
+#include <stdio.h>
+#include "Os/JCMsgQueue.h"
+
+JCMsgQueue *pMsgQ;
+bool isTestComplete = FALSE;
+
+extern "C"
+{
+void InitializeQueue()
+{
+ pMsgQ = new JCMsgQueue(10, 256, JC_MSG_Q_FIFO);
+
+ if (pMsgQ->JCGetMsgQId() == 0)
+ {
+ printf("Error creating test message queue\n");
+ return;
+ }
+
+ JC_MSG_Q_ID replyMsgQ;
+ unsigned int msgType;
+ char buffer[256];
+ unsigned int nBytes;
+ MNET_MODULE_ID modId;
+
+ while (!isTestComplete)
+ {
+ JC_STATUS status;
+ if ((status = pMsgQ->JCMsgQReceive(&replyMsgQ, &msgType, &modId, buffer, &nBytes,
+ JC_WAIT_FOREVER)) == JC_OK)
+ {
+ printf("Received a test message!\n");
+ printf("\treplyMsgQ = %x\n", replyMsgQ);
+ printf("\tmsgType = %x\n", msgType);
+ printf("\tmodId = %x\n", modId);
+ printf("\tnBytes = %x\n", nBytes);
+ printf("\tbuffer = ");
+ for (int i=0; i < nBytes; i++)
+ printf("%02x ", buffer[i]);
+ printf("\n");
+ }
+ else
+ {
+ printf("Error receiving message - errcode %x\n", status);
+ }
+ }
+}
+
+
+
+void SendToQueue()
+{
+ char msg[256];
+ JC_STATUS status;
+
+ // build a test message
+ for (int i=0; i < 16; i++)
+ {
+ msg[i] = (char)i;
+ }
+
+ isTestComplete = TRUE;
+ unsigned int msgType = 13;
+ unsigned int msgLen = 16;
+
+ if ((status = pMsgQ->JCMsgQSend((JC_MSG_Q_ID)0xabcd0123, msgType, LOGGER, msg, msgLen, JC_WAIT_FOREVER,
+ JC_MSG_PRI_NORMAL)) != JC_OK)
+ {
+ printf("Error sending test message - errcode %x\n", status);
+ }
+}
+
+} \ No newline at end of file