summaryrefslogtreecommitdiffstats
path: root/data/mnet/Common/Os/src
diff options
context:
space:
mode:
Diffstat (limited to 'data/mnet/Common/Os/src')
-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
6 files changed, 1056 insertions, 0 deletions
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)
+
+