summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/timecounter.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/include/rtems/score/timecounter.h')
-rw-r--r--cpukit/include/rtems/score/timecounter.h91
1 files changed, 80 insertions, 11 deletions
diff --git a/cpukit/include/rtems/score/timecounter.h b/cpukit/include/rtems/score/timecounter.h
index 8185140f9b..ced3d7c60c 100644
--- a/cpukit/include/rtems/score/timecounter.h
+++ b/cpukit/include/rtems/score/timecounter.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
*
@@ -8,17 +10,28 @@
*/
/*
- * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
- *
- * embedded brains GmbH
- * Dornierstr. 4
- * 82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Copyright (C) 2015, 2021 embedded brains GmbH & Co. KG
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RTEMS_SCORE_TIMECOUNTER_H
@@ -248,6 +261,62 @@ extern volatile int32_t _Timecounter_Time_uptime;
*/
extern struct timecounter *_Timecounter;
+/**
+ * @brief Handler doing the NTP update second processing shall have this type.
+ *
+ * @param[in, out] adjustment is the NTP time adjustment.
+ *
+ * @param[in, out] newsec is the number of seconds since Unix epoch.
+ */
+typedef void ( *Timecounter_NTP_update_second )(
+ int64_t *adjustment,
+ time_t *newsec
+);
+
+/**
+ * @brief Sets the NTP update second handler.
+ *
+ * @param handler is the new NTP update second handler used to carry out the
+ * NTP update second processing.
+ */
+void _Timecounter_Set_NTP_update_second(
+ Timecounter_NTP_update_second handler
+);
+
+/**
+ * @brief Updates the time adjustment and seconds according to the NTP state.
+ *
+ * @param[in, out] adjustment is the NTP time adjustment.
+ *
+ * @param[in, out] newsec is the number of seconds since Unix epoch.
+ */
+void _Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec);
+
+/**
+ * @brief Gets the frequency in Hz of the current timecounter at some time
+ * point during the call.
+ *
+ * @return Returns the frequency in Hz.
+ */
+uint64_t _Timecounter_Get_frequency(void);
+
+/**
+ * @brief 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.
+ *
+ * @param[in] tsp is the time at PPS event
+ *
+ * @param[i] nsec is the time in nanoseconds from the last PPS event
+ */
+void _Timecounter_Discipline(struct timespec *tsp, long nsec);
+
/** @} */
#ifdef __cplusplus