RTEMS 6.1-rc7
Loading...
Searching...
No Matches
timecounter.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2015, 2021 embedded brains GmbH & Co. KG
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_SCORE_TIMECOUNTER_H
38#define _RTEMS_SCORE_TIMECOUNTER_H
39
40#include <sys/time.h>
41#include <sys/timetc.h>
43
44#include <rtems/score/isrlock.h>
45
46#ifdef __cplusplus
47extern "C" {
48#endif /* __cplusplus */
49
65void _Timecounter_Bintime( struct bintime *bt );
66
72void _Timecounter_Nanotime( struct timespec *ts );
73
79void _Timecounter_Microtime( struct timeval *tv );
80
86void _Timecounter_Binuptime( struct bintime *bt );
87
94
100void _Timecounter_Nanouptime( struct timespec *ts );
101
107void _Timecounter_Microuptime( struct timeval *tv );
108
117void _Timecounter_Getbintime( struct bintime *bt );
118
129void _Timecounter_Getnanotime( struct timespec *ts );
130
141void _Timecounter_Getmicrotime( struct timeval *tv );
142
151void _Timecounter_Getbinuptime( struct bintime *bt );
152
161void _Timecounter_Getnanouptime( struct timespec *ts );
162
171void _Timecounter_Getmicrouptime( struct timeval *tv );
172
178void _Timecounter_Getboottime( struct timeval *tv );
179
185void _Timecounter_Getboottimebin( struct bintime *bt );
186
197
201void _Timecounter_Tick( void );
202
203#if ISR_LOCK_NEEDS_OBJECT
207extern ISR_lock_Control _Timecounter_Lock;
208#endif
209
217#define _Timecounter_Acquire( lock_context ) \
218 _ISR_lock_ISR_disable_and_acquire( &_Timecounter_Lock, lock_context )
219
227#define _Timecounter_Release(lock_context) \
228 _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, lock_context)
229
243 uint32_t delta,
244 uint32_t offset,
245 ISR_lock_Context *lock_context
246);
247
251extern volatile time_t _Timecounter_Time_second;
252
259extern volatile int32_t _Timecounter_Time_uptime;
260
264extern struct timecounter *_Timecounter;
265
274 int64_t *adjustment,
275 time_t *newsec
276);
277
286);
287
295void _Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec);
296
304
320void _Timecounter_Discipline(struct timespec *tsp, long nsec);
321
324#ifdef __cplusplus
325}
326#endif /* __cplusplus */
327
328#endif /* _RTEMS_SCORE_TIMECOUNTER_H */
This header file provides timecounter definitions for the kernel space (_KERNEL is defined before inc...
void _Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec)
Updates the time adjustment and seconds according to the NTP state.
void _Timecounter_Microtime(struct timeval *tv)
Returns the wall clock time in the timeval format.
volatile int32_t _Timecounter_Time_uptime
The uptime in seconds.
void _Timecounter_Tick(void)
Performs a timecounter tick.
void _Timecounter_Nanotime(struct timespec *ts)
Returns the wall clock time in the timespec format.
void _Timecounter_Getmicrouptime(struct timeval *tv)
Returns the uptime in the timeval format.
int64_t _Timecounter_Sbinuptime(void)
Returns the uptime in the sbintime_t format.
void _Timecounter_Microuptime(struct timeval *tv)
Returns the uptime in the timeval format.
volatile time_t _Timecounter_Time_second
The wall clock time in seconds.
void _Timecounter_Getboottimebin(struct bintime *bt)
Returns the boot time in the bintime format.
void _Timecounter_Getboottime(struct timeval *tv)
Returns the boot time in the timeval format.
void _Timecounter_Tick_simple(uint32_t delta, uint32_t offset, ISR_lock_Context *lock_context)
Performs a simple timecounter tick.
void _Timecounter_Nanouptime(struct timespec *ts)
Returns the uptime in the timespec format.
uint64_t _Timecounter_Get_frequency(void)
Gets the frequency in Hz of the current timecounter at some time point during the call.
void(* Timecounter_NTP_update_second)(int64_t *adjustment, time_t *newsec)
Handler doing the NTP update second processing shall have this type.
Definition: timecounter.h:273
void _Timecounter_Getmicrotime(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.
void _Timecounter_Discipline(struct timespec *tsp, long nsec)
Updates the timecounter frequency adjustment used by _Timecounter_Set_NTP_update_second().
void _Timecounter_Bintime(struct bintime *bt)
Returns the wall clock time in the bintime format.
void _Timecounter_Getbinuptime(struct bintime *bt)
Returns the uptime in the bintime format.
void _Timecounter_Install(struct timecounter *tc)
Installs the timecounter.
void _Timecounter_Getnanouptime(struct timespec *ts)
Returns the uptime in the timespec format.
void _Timecounter_Getbintime(struct bintime *bt)
Returns the wall clock time in the bintime format.
void _Timecounter_Set_NTP_update_second(Timecounter_NTP_update_second handler)
Sets the NTP update second handler.
void _Timecounter_Getnanotime(struct timespec *ts)
Returns the wall clock time in the timespec format.
struct timecounter * _Timecounter
The current timecounter.
This header file provides the interfaces of the ISR Locks.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:94
Definition: timetc.h:58
This header file provides interfaces of the timecounter implementation.