RTEMS 6.3
Loading...
Searching...
No Matches
Timecounter Handler

This group contains the Timecounter Handler implementation. More...

Files

file  cpukit/include/machine/_timecounter.h
 This header file provides timecounter definitions for the kernel space (_KERNEL is defined before including <sys/time.h>) and RTEMS.
file  cpukit/include/rtems/score/timecounter.h
 This header file provides interfaces of the Timecounter Handler which are used by the implementation and the API.
file  cpukit/include/rtems/score/timecounterimpl.h
 This header file provides interfaces of the Timecounter Handler which are only used by the implementation.
file  cpukit/include/sys/_ffcounter.h
 This header file provides interfaces of the feed-forward clock counter.
file  cpukit/include/sys/timeffc.h
 This header file provides interfaces of the feed-back and feed-forward clock implementations.
file  cpukit/include/sys/timepps.h
 This header file provides interfaces of the Pulse Per Second (PPS) support.
file  cpukit/include/sys/timetc.h
 This header file provides interfaces of the timecounter implementation.
file  cpukit/include/sys/timex.h
 This header file provides interfaces of the Network Time Protocol (NTP) support.
file  cpukit/score/src/kern_ntptime.c
 This source file contains the implementation of ntp_gettime(), ntp_adjtime(), adjtime(), and _Timecounter_NTP_update_second().
file  cpukit/score/src/kern_tc.c
 This source file contains the definition of _Timecounter, _Timecounter_Time_second, and _Timecounter_Time_uptime and the implementation of _Timecounter_Set_NTP_update_second(), _Timecounter_Binuptime(), _Timecounter_Nanouptime(), _Timecounter_Microuptime(), _Timecounter_Bintime(), _Timecounter_Nanotime(), _Timecounter_Microtime(), _Timecounter_Getbinuptime(), _Timecounter_Getnanouptime(), _Timecounter_Getmicrouptime(), _Timecounter_Getbintime(), _Timecounter_Getnanotime(), _Timecounter_Getmicrotime(), _Timecounter_Getboottime(), _Timecounter_Getboottimebin(), and _Timecounter_Install().
file  cpukit/score/src/opt_compat.h
 This header file is provided for FreeBSD compatibility.
file  cpukit/score/src/opt_ffclock.h
 This header file is provided for FreeBSD compatibility.
file  cpukit/score/src/opt_ntp.h
 This header file is provided for FreeBSD compatibility.

Macros

#define _Timecounter_Acquire(lock_context)
 Acquires the timecounter lock.
#define _Timecounter_Release(lock_context)
 Releases the timecounter lock.

Typedefs

typedef void(*) Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec)
 Handler doing the NTP update second processing shall have this type.

Functions

void _Timecounter_Bintime (struct bintime *bt)
 Returns the wall clock time in the bintime format.
void _Timecounter_Nanotime (struct timespec *ts)
 Returns the wall clock time in the timespec format.
void _Timecounter_Microtime (struct timeval *tv)
 Returns the wall clock time in the timeval format.
void _Timecounter_Binuptime (struct bintime *bt)
 Returns the uptime in the bintime format.
int64_t _Timecounter_Sbinuptime (void)
 Returns the uptime in the sbintime_t format.
void _Timecounter_Nanouptime (struct timespec *ts)
 Returns the uptime in the timespec format.
void _Timecounter_Microuptime (struct timeval *tv)
 Returns the uptime in the timeval format.
void _Timecounter_Getbintime (struct bintime *bt)
 Returns the wall clock time in the bintime format.
void _Timecounter_Getnanotime (struct timespec *ts)
 Returns the wall clock time in the timespec format.
void _Timecounter_Getmicrotime (struct timeval *tv)
 Returns the wall clock time in the timeval format.
void _Timecounter_Getbinuptime (struct bintime *bt)
 Returns the uptime in the bintime format.
void _Timecounter_Getnanouptime (struct timespec *ts)
 Returns the uptime in the timespec format.
void _Timecounter_Getmicrouptime (struct timeval *tv)
 Returns the uptime in the timeval format.
void _Timecounter_Getboottime (struct timeval *tv)
 Returns the boot time in the timeval format.
void _Timecounter_Getboottimebin (struct bintime *bt)
 Returns the boot time in the bintime format.
void _Timecounter_Install (struct timecounter *tc)
 Installs the timecounter.
void _Timecounter_Tick (void)
 Performs a timecounter tick.
void _Timecounter_Tick_simple (uint32_t delta, uint32_t offset, ISR_lock_Context *lock_context)
 Performs a simple timecounter tick.
void _Timecounter_Set_NTP_update_second (Timecounter_NTP_update_second handler)
 Sets the NTP update second handler.
void _Timecounter_NTP_update_second (int64_t *adjustment, time_t *newsec)
 Updates the time adjustment and seconds according to the NTP state.
uint64_t _Timecounter_Get_frequency (void)
 Gets the frequency in Hz of the current timecounter at some time point during the call.
void _Timecounter_Discipline (struct timespec *tsp, long nsec)
 Updates the timecounter frequency adjustment used by _Timecounter_Set_NTP_update_second().
void _Timecounter_Set_clock (const struct bintime *bt, ISR_lock_Context *lock_context)
 Sets the timecounter clock to the given value.

Variables

volatile time_t _Timecounter_Time_second
 The wall clock time in seconds.
volatile int32_t _Timecounter_Time_uptime
 The uptime in seconds.
struct timecounter * _Timecounter
 The current timecounter.

Detailed Description

This group contains the Timecounter Handler implementation.

Macro Definition Documentation

◆ _Timecounter_Acquire

#define _Timecounter_Acquire ( lock_context)
Value:
_ISR_lock_ISR_disable_and_acquire( &_Timecounter_Lock, lock_context )
#define _ISR_lock_ISR_disable_and_acquire(_lock, _context)
Acquires an ISR lock.
Definition isrlock.h:204

Acquires the timecounter lock.

Parameters
lock_contextThe lock context.

See _Timecounter_Tick_simple().

◆ _Timecounter_Release

#define _Timecounter_Release ( lock_context)
Value:
_ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, lock_context)
#define _ISR_lock_Release_and_ISR_enable(_lock, _context)
Releases an ISR lock.
Definition isrlock.h:229

Releases the timecounter lock.

Parameters
lock_contextThe lock context.

See _Timecounter_Tick_simple().

Typedef Documentation

◆ Timecounter_NTP_update_second

typedef void(*) Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec)

Handler doing the NTP update second processing shall have this type.

Parameters
[in,out]adjustmentis the NTP time adjustment.
[in,out]newsecis the number of seconds since Unix epoch.

Function Documentation

◆ _Timecounter_Bintime()

void _Timecounter_Bintime ( struct bintime * bt)

Returns the wall clock time in the bintime format.

Parameters
[out]btReturns the wall clock time.

◆ _Timecounter_Binuptime()

void _Timecounter_Binuptime ( struct bintime * bt)

Returns the uptime in the bintime format.

Parameters
[out]btReturns the uptime.

◆ _Timecounter_Discipline()

void _Timecounter_Discipline ( struct timespec * tsp,
long nsec )

Updates the timecounter frequency adjustment used by _Timecounter_Set_NTP_update_second().

This function is part of the time synchronization using a PPS (Pulse Per Second) signal.

When an event (a rising or falling edge of the PPS signal) occurs, the functions pps_capture() and pps_event() are executed. Only if the kernel consumer is configured to be PPS_KC_HARDPPS, the timecounter is disciplined.

Parameters
[in]tspis the time at PPS event
[i]nsec is the time in nanoseconds from the last PPS event

◆ _Timecounter_Get_frequency()

uint64_t _Timecounter_Get_frequency ( void )

Gets the frequency in Hz of the current timecounter at some time point during the call.

Returns
Returns the frequency in Hz.

◆ _Timecounter_Getbintime()

void _Timecounter_Getbintime ( struct bintime * bt)

Returns the wall clock time in the bintime format.

This function obtains the time with a lower overhead and lower accuracy compared to the _Timecounter_Bintime() variant.

Parameters
[out]tsReturns the wall clock time.

◆ _Timecounter_Getbinuptime()

void _Timecounter_Getbinuptime ( struct bintime * bt)

Returns the uptime in the bintime format.

This function obtains the time with a lower overhead and lower accuracy compared to the _Timecounter_Binuptime() variant.

Parameters
[out]tsReturns the uptime.

◆ _Timecounter_Getboottime()

void _Timecounter_Getboottime ( struct timeval * tv)

Returns the boot time in the timeval format.

Parameters
[out]tvReturns the boot time.

◆ _Timecounter_Getboottimebin()

void _Timecounter_Getboottimebin ( struct bintime * bt)

Returns the boot time in the bintime format.

Parameters
[out]tvReturns the boot time.

◆ _Timecounter_Getmicrotime()

void _Timecounter_Getmicrotime ( struct timeval * tv)

Returns the wall clock time in the timeval format.

This function obtains the time with a lower overhead and lower accuracy compared to the _Timecounter_Microtime() variant.

Parameters
[out]tvReturns the wall clock time.
See also
_Timecounter_Getbintime().

◆ _Timecounter_Getmicrouptime()

void _Timecounter_Getmicrouptime ( struct timeval * tv)

Returns the uptime in the timeval format.

This function obtains the time with a lower overhead and lower accuracy compared to the _Timecounter_Microuptime() variant.

Parameters
[out]tvReturns the uptime.

◆ _Timecounter_Getnanotime()

void _Timecounter_Getnanotime ( struct timespec * ts)

Returns the wall clock time in the timespec format.

This function obtains the time with a lower overhead and lower accuracy compared to the _Timecounter_Nanotime() variant.

Parameters
[out]tsReturns the wall clock time.
See also
_Timecounter_Getbintime().

◆ _Timecounter_Getnanouptime()

void _Timecounter_Getnanouptime ( struct timespec * ts)

Returns the uptime in the timespec format.

This function obtains the time with a lower overhead and lower accuracy compared to the _Timecounter_Nanouptime() variant.

Parameters
[out]tsReturns the uptime.

◆ _Timecounter_Install()

void _Timecounter_Install ( struct timecounter * tc)

Installs the timecounter.

The timecounter structure must contain valid values in the fields tc_get_timecount, tc_counter_mask, tc_frequency and tc_quality. All other fields must be zero initialized.

Parameters
tcThe timecounter.

◆ _Timecounter_Microtime()

void _Timecounter_Microtime ( struct timeval * tv)

Returns the wall clock time in the timeval format.

Parameters
[out]tvReturns the wall clock time.

◆ _Timecounter_Microuptime()

void _Timecounter_Microuptime ( struct timeval * tv)

Returns the uptime in the timeval format.

Parameters
[out]tvReturns the uptime.

◆ _Timecounter_Nanotime()

void _Timecounter_Nanotime ( struct timespec * ts)

Returns the wall clock time in the timespec format.

Parameters
[out]tsReturns the wall clock time.

◆ _Timecounter_Nanouptime()

void _Timecounter_Nanouptime ( struct timespec * ts)

Returns the uptime in the timespec format.

Parameters
[out]tsReturns the uptime.

◆ _Timecounter_NTP_update_second()

void _Timecounter_NTP_update_second ( int64_t * adjustment,
time_t * newsec )

Updates the time adjustment and seconds according to the NTP state.

Parameters
[in,out]adjustmentis the NTP time adjustment.
[in,out]newsecis the number of seconds since Unix epoch.

◆ _Timecounter_Sbinuptime()

int64_t _Timecounter_Sbinuptime ( void )

Returns the uptime in the sbintime_t format.

Returns
Returns the uptime.

◆ _Timecounter_Set_clock()

void _Timecounter_Set_clock ( const struct bintime * bt,
ISR_lock_Context * lock_context )

Sets the timecounter clock to the given value.

Parameters
btThe value to set the clock to.
lock_contextThe interrupt lock context.

◆ _Timecounter_Set_NTP_update_second()

void _Timecounter_Set_NTP_update_second ( Timecounter_NTP_update_second handler)

Sets the NTP update second handler.

Parameters
handleris the new NTP update second handler used to carry out the NTP update second processing.

◆ _Timecounter_Tick_simple()

void _Timecounter_Tick_simple ( uint32_t delta,
uint32_t offset,
ISR_lock_Context * lock_context )

Performs a simple timecounter tick.

This is a special purpose tick function for simple timecounter to support legacy clock drivers.

Parameters
deltaThe time in timecounter ticks elapsed since the last call to _Timecounter_Tick_simple().
offsetThe current value of the timecounter.
]lock_context The lock context of the corresponding _Timecounter_Acquire().

Variable Documentation

◆ _Timecounter_Time_uptime

volatile int32_t _Timecounter_Time_uptime
extern

The uptime in seconds.

For compatibility with the FreeBSD network stack the initial value is one second.