summaryrefslogtreecommitdiffstats
path: root/data/mnet/Common/include/Os
diff options
context:
space:
mode:
Diffstat (limited to 'data/mnet/Common/include/Os')
-rw-r--r--data/mnet/Common/include/Os/JCCTimer.h117
-rw-r--r--data/mnet/Common/include/Os/JCModule.h88
-rw-r--r--data/mnet/Common/include/Os/JCMsgQueue.h91
-rw-r--r--data/mnet/Common/include/Os/JCMutex.h44
-rw-r--r--data/mnet/Common/include/Os/JCTask.h131
5 files changed, 471 insertions, 0 deletions
diff --git a/data/mnet/Common/include/Os/JCCTimer.h b/data/mnet/Common/include/Os/JCCTimer.h
new file mode 100644
index 0000000..2d5154a
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCCTimer.h
@@ -0,0 +1,117 @@
+#ifndef JCCTimer_H
+#define JCCTimer_H
+
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCCTimer.h
+// Author(s) : Bhava Nelakanti
+// Create Date : 10-19-98
+// Description : interface specification for - JCCTimer
+//
+// REVISION HISTORY:
+// __________________________________________________________________
+//| Name | Date | Reason
+//+__________+________+_______________________________________________
+//| Igal |11/29/00| Added support to set timer in 100 mSec resolution
+//| Shiv |01/14/00| Added support to enable windows applications to
+//| | | use the same APIs provided by JCCTimer
+//+__________+________+______________________________________________
+//
+// *******************************************************************
+// Include Files.
+// *******************************************************************
+
+#if defined(__VXWORKS__)
+ #include "vxWorks.h"
+ #include "wdLib.h"
+#elif (defined(WIN32) || defined(_WINDOWS_))
+ //#include "stdAfx.h"
+ #include <mmsystem.h>
+ #define FUNCPTR LPTIMECALLBACK
+ #define WDOG_ID MMRESULT
+ #define TARGET_RESOLUTION 1 // 1-millisecond target resolution
+#endif
+
+// *******************************************************************
+// forward declarations.
+// *******************************************************************
+
+class JCCTimer
+{
+
+public:
+
+ // Destructor
+ ~JCCTimer() ;
+
+ // Constructors
+ JCCTimer (FUNCPTR fPtr,
+ int timerData);
+
+ JCCTimer (FUNCPTR fPtr);
+
+ // Operators
+
+ // primary behaviour methods
+ void cancelTimer ();
+ void setTimer (int howLong);
+ void setTimer (int howLong, int timerData)
+ { timerData_ = timerData;
+ setTimer (howLong); }
+
+ // set timer in resolution of 100 mSec
+ void setTimerMSec(unsigned mSec)
+ { setTimer (tickPerSec*mSec/10);}
+
+ // set timer in resolution of 100 mSec
+ void setTimerMSec(unsigned mSec, int timerData)
+ { setTimer ((tickPerSec*mSec/10), timerData);}
+
+ static int getTickRate () { return (tickPerSec); }
+
+ // maintenance methods
+
+ // get and set for private data members
+
+ // boolean to indicate if timer is active
+ bool timerSet_;
+
+protected:
+
+private:
+
+ // hide the assignment, and copy ctor and other defaults as needed.
+ JCCTimer();
+
+ JCCTimer (const JCCTimer& rhs) ;
+
+ JCCTimer& operator= (const JCCTimer& rhs) ;
+
+ int operator==(const JCCTimer& rhs) const ;
+
+ void init ();
+
+private:
+
+ static int tickPerSec;
+
+ // data members
+ FUNCPTR funcPtr_ ;
+ int timerData_; // data for timer call-back
+ WDOG_ID timerId_ ; // VxWorks Watchdog Timer Id
+#if (defined(WIN32) || defined(_WINDOWS_))
+ unsigned int wTimerRes;
+#endif
+};
+
+
+#endif // JCCTimer_H
diff --git a/data/mnet/Common/include/Os/JCModule.h b/data/mnet/Common/include/Os/JCModule.h
new file mode 100644
index 0000000..57f5b84
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCModule.h
@@ -0,0 +1,88 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCModule.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCMODULE_H_
+#define _JCMODULE_H_ /* include once only */
+
+#include <sysSymTbl.h>
+#include "MnetModuleId.h"
+#include "Os/JCTask.h"
+
+#define MAX_NUM_SUB_TASKS 50
+
+
+typedef enum {
+ SYS_SHUTDOWN = 0,
+ SYS_START = 1,
+ SYS_REBOOT = 2,
+} T_SYS_CMD;
+
+
+typedef int (*JC_SYSCMD_FUNC)(T_SYS_CMD);
+
+typedef enum
+{
+ TASK_SUSPENDED,
+ TASK_MISSING,
+ MODULE_OK
+} SYSTEM_MODULE_STATUS;
+
+class JCModule {
+public:
+ JCModule
+ (
+ MNET_MODULE_ID id,
+ JC_SYSCMD_FUNC cmdFunc,
+ char *cmdFuncStr
+ );
+
+ ~JCModule();
+
+ bool StartModule();
+ void ShutdownModule();
+ void RebootModule();
+ SYSTEM_MODULE_STATUS CheckModule(JCTask **pTask);
+ MNET_MODULE_ID GetModuleId() { return (modId); }
+
+ static JCModule *systemModules[];
+ static void InsertTaskInfo(MNET_MODULE_ID id, JCTask *pTask);
+ static bool AllTasksInMainLoop();
+ static void ShowModuleStat();
+
+private:
+ JC_SYSCMD_FUNC syscmd;
+ char *modName;
+ MNET_MODULE_ID modId;
+ int numRun;
+ int numSub;
+ JCTask *tasks[MAX_NUM_SUB_TASKS];
+ bool isModuleLoaded;
+
+ // Private functions
+ static int CheckSym(char *name, int val, SYM_TYPE type, int arg, UINT16 group);
+ int TestSym(char *str);
+
+
+ // Disallow the following functions
+ JCModule();
+ JCModule(const JCModule&);
+ JCModule& operator=(const JCModule&);
+ int operator== (const JCModule&) const;
+};
+
+
+#endif
diff --git a/data/mnet/Common/include/Os/JCMsgQueue.h b/data/mnet/Common/include/Os/JCMsgQueue.h
new file mode 100644
index 0000000..3c6630d
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCMsgQueue.h
@@ -0,0 +1,91 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMsgQueue.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCMSGQUEUE_H_
+#define _JCMSGQUEUE_H_ /* include once only */
+
+#include "JCErr.h"
+#include "msgQLib.h"
+#include "MnetModuleId.h"
+
+/* OS independent message queue id */
+#define JC_MSG_Q_ID MSG_Q_ID
+
+/* Message queue sending options */
+#define JC_MSG_PRI_NORMAL MSG_PRI_NORMAL
+#define JC_MSG_PRI_URGENT MSG_PRI_URGENT
+
+/* Message queue creation options */
+#define JC_MSG_Q_FIFO MSG_Q_FIFO
+#define JC_MSG_Q_PRIORITY MSG_Q_PRIORITY
+
+/* Message queue reception timeout options */
+#define JC_NO_WAIT NO_WAIT
+#define JC_WAIT_FOREVER WAIT_FOREVER
+
+class JCMsgQueue {
+public:
+ JCMsgQueue
+ (
+ int maxMsgs, /* max msgs that can be queued */
+ int maxMsgLength, /* max bytes in a msg */
+ int options /* message queue options */
+ );
+
+ ~JCMsgQueue();
+
+ JC_STATUS JCMsgQSend
+ (
+ JCMsgQueue *replyMsgQ,
+ unsigned int msgType,
+ MNET_MODULE_ID modId,
+ char * buffer,
+ unsigned int nBytes,
+ int timeout,
+ int priority
+ );
+
+ int JCMsgQReceive
+ (
+ JCMsgQueue **replyMsgQ,
+ unsigned int *msgType,
+ MNET_MODULE_ID *modId,
+ char * buffer,
+ unsigned int *nBytes,
+ int timeout
+ );
+
+ JC_MSG_Q_ID JCGetMsgQId()
+ {
+ return(msgQId);
+ }
+
+private:
+ JC_MSG_Q_ID msgQId;
+ int msgQMaxLen;
+ char *msgQSndBuf;
+ char *msgQRcvBuf;
+
+ // Disallow the following functions
+ JCMsgQueue();
+ JCMsgQueue(const JCMsgQueue&);
+ JCMsgQueue& operator=(const JCMsgQueue&);
+ int operator== (const JCMsgQueue&) const;
+};
+
+
+#endif
diff --git a/data/mnet/Common/include/Os/JCMutex.h b/data/mnet/Common/include/Os/JCMutex.h
new file mode 100644
index 0000000..8adc962
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCMutex.h
@@ -0,0 +1,44 @@
+#ifndef __JCMUTEX_H__
+#define __JCMUTEX_H__
+// *******************************************************************
+//
+// (c) Copyright CISCO Systems, 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCMutex.h
+// Author(s) : Igal Gutkin
+// Create Date : 11/06/00
+// Description : JCMutex class (Mutual-Exclusion Semapore) definition
+//
+// *******************************************************************
+
+
+#include <vxworks.h>
+#include <semlib.h>
+
+class JCMutex
+{
+public:
+ // Constructors & destructor
+ JCMutex ();
+ virtual ~JCMutex ();
+
+ // pramary methods
+ bool take ();
+ bool give ();
+
+private:
+
+// data members
+private:
+
+ SEM_ID semId_;
+};
+
+#endif //__JCMUTEX_H__ \ No newline at end of file
diff --git a/data/mnet/Common/include/Os/JCTask.h b/data/mnet/Common/include/Os/JCTask.h
new file mode 100644
index 0000000..30e5888
--- /dev/null
+++ b/data/mnet/Common/include/Os/JCTask.h
@@ -0,0 +1,131 @@
+// *******************************************************************
+//
+// (c) Copyright Cisco 2000
+// All Rights Reserved
+//
+// *******************************************************************
+
+// *******************************************************************
+//
+// Version : 1.0
+// Status : Under development
+// File : JCTask.h
+// Author(s) : Tim Olson
+// Create Date : 9/18/2000
+// Description :
+//
+// *******************************************************************
+#ifndef _JCTASK_H_
+#define _JCTASK_H_ /* include once only */
+
+#include <taskLib.h>
+#include <semLib.h>
+#include "JCErr.h"
+#include "MnetModuleId.h"
+
+/* OS independent task id */
+#define JC_TASK_ID int
+
+/* Task creation options */
+#define JC_VX_FP_TASK VX_FP_TASK /* execute with floating-point coprocessor support */
+#define JC_VX_PRIVATE_ENV VX_PRIVATE_ENV /* include private environment support */
+#define JC_VX_NO_STACK_FILL VX_NO_STACK_FILL /* do not fill the stack for use by checkStack */
+#define JC_VX_UNBREAKABLE VX_UNBREAKABLE /* do not allow breakpoint debugging */
+
+extern SEM_ID *pMnetSyncSem;
+
+/* System importance for task */
+typedef enum {
+ JC_CRITICAL_TASK,
+ JC_NON_CRITICAL_TASK
+} JC_TASK_IMPORTANCE;
+
+/* Task status */
+typedef enum {
+ JC_TASK_IDLE,
+ JC_TASK_INIT,
+ JC_TASK_LOOP,
+ JC_TASK_EXIT,
+} JC_TASK_STATUS;
+
+
+class JCTask {
+public:
+ JCTask
+ (
+ char *name
+ );
+
+ ~JCTask();
+
+ int 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
+ );
+
+ void JCTaskEnterLoop();
+ void JCTaskNormExit();
+
+ const char *GetTaskName() { return (taskName); }
+ int GetTaskId() { return (taskId); }
+ JC_TASK_IMPORTANCE GetTaskImportance() { return (taskImportance); }
+ JC_TASK_STATUS GetTaskStatus() { return (taskStatus); }
+
+ JC_TASK_ID JCTaskId()
+ {
+ return(taskId);
+ }
+
+ void SetTaskAlarmStatus(bool stat) { taskAlarmed = stat; }
+ bool GetTaskAlarmStatus() { return(taskAlarmed); }
+
+ void ExecuteCoreDumpFunc() { if (coreDumpFunc) coreDumpFunc(); }
+
+private:
+ int taskId;
+ char *taskName;
+ int taskPri; /* priority of new task */
+ int taskOpt; /* task option word */
+ int taskStackSize; /* size (bytes) of stack needed plus name */
+ FUNCPTR taskEntryPt; /* entry point of new task */
+ int taskArg1; /* 1st of 10 req'd task args to pass to func */
+ int taskArg2;
+ int taskArg3;
+ int taskArg4;
+ int taskArg5;
+ int taskArg6;
+ int taskArg7;
+ int taskArg8;
+ int taskArg9;
+ int taskArg10;
+ MNET_MODULE_ID moduleId;
+ JC_TASK_IMPORTANCE taskImportance;
+ FUNCPTR coreDumpFunc;
+ JC_TASK_STATUS taskStatus;
+ bool taskAlarmed;
+
+
+ // Disallow the following functions
+ JCTask();
+ JCTask(const JCTask&);
+ JCTask& operator=(const JCTask&);
+ int operator== (const JCTask&) const;
+};
+
+
+#endif