More timing cleanups for RTEMS.
This commit is contained in:
@@ -45,8 +45,7 @@
|
||||
RTEMS_INTERRUPT_LEVEL(0))
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_FLOATING_POINT | RTEMS_LOCAL)
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE (16*1024)
|
||||
#define CONFIGURE_INIT_TASK_ENTRY_POINT rtemsInit
|
||||
rtems_task rtemsInit (rtems_task_argument argument);
|
||||
rtems_task Init (rtems_task_argument argument);
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
|
||||
#include "epicsRtemsInitHooks.h"
|
||||
|
||||
rtems_interval rtemsTicksPerSecond;
|
||||
double rtemsTicksPerSecond_double;
|
||||
|
||||
static void
|
||||
logReset (void)
|
||||
{
|
||||
@@ -68,10 +71,7 @@ logReset (void)
|
||||
static void
|
||||
delayedPanic (const char *msg)
|
||||
{
|
||||
rtems_interval ticksPerSecond;
|
||||
|
||||
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
|
||||
rtems_task_wake_after (ticksPerSecond);
|
||||
rtems_task_wake_after (rtemsTicksPerSecond);
|
||||
rtems_panic (msg);
|
||||
}
|
||||
|
||||
@@ -414,7 +414,6 @@ Init (rtems_task_argument ignored)
|
||||
{
|
||||
int i;
|
||||
const char *argv[3] = { NULL, NULL, NULL };
|
||||
rtems_interval ticksPerSecond;
|
||||
rtems_task_priority newpri;
|
||||
rtems_status_code sc;
|
||||
rtems_time_of_day now;
|
||||
@@ -422,7 +421,8 @@ Init (rtems_task_argument ignored)
|
||||
/*
|
||||
* Get configuration
|
||||
*/
|
||||
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
|
||||
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &rtemsTicksPerSecond);
|
||||
rtemsTicksPerSecond_double = rtemsTicksPerSecond;
|
||||
|
||||
/*
|
||||
* Explain why we're here
|
||||
@@ -492,7 +492,7 @@ Init (rtems_task_argument ignored)
|
||||
printf ("***** Initializing NTP *****\n");
|
||||
if (rtems_bsdnet_synchronize_ntp (0, 0) >= 0)
|
||||
break;
|
||||
rtems_task_wake_after (5*ticksPerSecond);
|
||||
rtems_task_wake_after (5*rtemsTicksPerSecond);
|
||||
if (i >= 12) {
|
||||
printf (" *************** WARNING ***************\n");
|
||||
printf (" ***** NO RESPONSE FROM NTP SERVER *****\n");
|
||||
|
||||
@@ -245,8 +245,9 @@ SRCS += tsDefs.c
|
||||
# These files are in osi/os/vxWorks
|
||||
# IOC Time of Day clock
|
||||
INC_vxWorks += iocClock.h
|
||||
INC_RTEMS += iocClock.h
|
||||
SRCS_vxWorks += iocClock.c
|
||||
INC_RTEMS += iocClock.h
|
||||
SRCS_RTEMS += iocClock.c
|
||||
# Special reboot hook
|
||||
SRCS_vxWorks += atReboot.cpp
|
||||
# For old vxWorks applications
|
||||
|
||||
@@ -230,9 +230,7 @@ epicsThreadInit (void)
|
||||
if (!initialized) {
|
||||
rtems_id tid;
|
||||
rtems_task_priority old;
|
||||
extern void clockInit (void);
|
||||
|
||||
clockInit ();
|
||||
rtems_task_set_priority (RTEMS_SELF, epicsThreadGetOssPriorityValue(99), &old);
|
||||
onceMutex = epicsMutexMustCreate();
|
||||
taskVarMutex = epicsMutexMustCreate ();
|
||||
|
||||
@@ -15,36 +15,20 @@
|
||||
* ANSI C
|
||||
*/
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
/*#include <limits.h>*/
|
||||
|
||||
/*
|
||||
* RTEMS
|
||||
*/
|
||||
#include <rtems.h>
|
||||
*/
|
||||
|
||||
/*
|
||||
* EPICS
|
||||
*/
|
||||
#define epicsExportSharedSymbols
|
||||
#include <epicsStdio.h>
|
||||
#include <epicsThread.h>
|
||||
#include <cantProceed.h>
|
||||
#include "iocClock.h"
|
||||
#include "errlog.h"
|
||||
#include <epicsTime.h>
|
||||
|
||||
extern "C" {
|
||||
/*
|
||||
* RTEMS clock rate
|
||||
*/
|
||||
rtems_interval rtemsTicksPerSecond;
|
||||
double rtemsTicksPerSecond_double;
|
||||
|
||||
/*
|
||||
* RTEMS time begins January 1, 1988 (local time).
|
||||
* EPICS time begins January 1, 1990 (GMT).
|
||||
*/
|
||||
#define EPICS_EPOCH_SEC_PAST_RTEMS_EPOCH ((366+365)*86400)
|
||||
static unsigned long timeoffset;
|
||||
|
||||
int epicsTime_gmtime ( const time_t *pAnsiTime, struct tm *pTM )
|
||||
{
|
||||
@@ -68,91 +52,4 @@ int epicsTime_localtime ( const time_t *clock, struct tm *result )
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clockInit(void)
|
||||
{
|
||||
timeoffset = EPICS_EPOCH_SEC_PAST_RTEMS_EPOCH;
|
||||
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &rtemsTicksPerSecond);
|
||||
rtemsTicksPerSecond_double = rtemsTicksPerSecond;
|
||||
}
|
||||
|
||||
static int iocClockGetCurrent(epicsTimeStamp *pDest);
|
||||
static int iocClockGetEvent(epicsTimeStamp *pDest, int eventNumber);
|
||||
|
||||
typedef struct iocClockPvt {
|
||||
pepicsTimeGetCurrent getCurrent;
|
||||
pepicsTimeGetEvent getEvent;
|
||||
}iocClockPvt;
|
||||
static iocClockPvt *piocClockPvt = 0;
|
||||
|
||||
void
|
||||
iocClockInit(void)
|
||||
{
|
||||
if(piocClockPvt) return;
|
||||
piocClockPvt = (iocClockPvt *)callocMustSucceed(1,sizeof(iocClockPvt),"iocClockInit");
|
||||
piocClockPvt->getCurrent = iocClockGetCurrent;
|
||||
piocClockPvt->getEvent = iocClockGetEvent;
|
||||
}
|
||||
|
||||
void
|
||||
iocClockRegister(pepicsTimeGetCurrent getCurrent, pepicsTimeGetEvent getEvent) {
|
||||
if(piocClockPvt) {
|
||||
printf("iocClockRegister: iocClock already initialized\n");
|
||||
return;
|
||||
}
|
||||
piocClockPvt = (iocClockPvt *)callocMustSucceed(1,sizeof(iocClockPvt),"iocClockRegister");
|
||||
piocClockPvt->getCurrent = getCurrent;
|
||||
piocClockPvt->getEvent = getEvent;
|
||||
}
|
||||
|
||||
static int
|
||||
iocClockGetCurrent(epicsTimeStamp *pDest)
|
||||
{
|
||||
struct timeval curtime;
|
||||
rtems_interval t;
|
||||
rtems_status_code sc;
|
||||
|
||||
for (;;) {
|
||||
sc = rtems_clock_get (RTEMS_CLOCK_GET_TIME_VALUE, &curtime);
|
||||
if (sc == RTEMS_SUCCESSFUL)
|
||||
break;
|
||||
else if (sc != RTEMS_NOT_DEFINED)
|
||||
return epicsTimeERROR;
|
||||
sc = rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &t);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
return epicsTimeERROR;
|
||||
rtems_task_wake_after (t);
|
||||
}
|
||||
pDest->nsec = curtime.tv_usec * 1000;
|
||||
pDest->secPastEpoch = curtime.tv_sec - timeoffset;
|
||||
return epicsTimeOK;
|
||||
}
|
||||
|
||||
static int
|
||||
iocClockGetEvent(epicsTimeStamp *pDest, int eventNumber)
|
||||
{
|
||||
if (eventNumber==epicsTimeEventCurrentTime)
|
||||
return iocClockGetCurrent(pDest);
|
||||
return(epicsTimeERROR);
|
||||
}
|
||||
|
||||
int
|
||||
epicsTimeGetCurrent (epicsTimeStamp *pDest)
|
||||
{
|
||||
if(!piocClockPvt)
|
||||
iocClockInit();
|
||||
if(piocClockPvt->getCurrent) return((*piocClockPvt->getCurrent)(pDest));
|
||||
return(epicsTimeERROR);
|
||||
}
|
||||
|
||||
int
|
||||
epicsTimeGetEvent (epicsTimeStamp *pDest, int eventNumber)
|
||||
{
|
||||
if(!piocClockPvt)
|
||||
iocClockInit();
|
||||
if(piocClockPvt->getEvent)
|
||||
return((*piocClockPvt->getEvent)(pDest,eventNumber));
|
||||
return(epicsTimeERROR);
|
||||
}
|
||||
|
||||
} /* extern "C" */
|
||||
|
||||
@@ -72,6 +72,9 @@ struct rtems_bsdnet_config rtems_bsdnet_config = {
|
||||
#include <rtems/error.h>
|
||||
#include <epicsExit.h>
|
||||
|
||||
rtems_interval rtemsTicksPerSecond;
|
||||
double rtemsTicksPerSecond_double;
|
||||
|
||||
rtems_task
|
||||
Init (rtems_task_argument ignored)
|
||||
{
|
||||
@@ -94,6 +97,8 @@ Init (rtems_task_argument ignored)
|
||||
if ((sc = rtems_clock_set (&now)) != RTEMS_SUCCESSFUL)
|
||||
printf ("***** Can't set time: %s\n", rtems_status_text (sc));
|
||||
}
|
||||
rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &rtemsTicksPerSecond);
|
||||
rtemsTicksPerSecond_double = rtemsTicksPerSecond;
|
||||
|
||||
/*
|
||||
* Some tests need a 'network'
|
||||
|
||||
Reference in New Issue
Block a user