summaryrefslogtreecommitdiffstats
path: root/bsps/shared/dev/clock/clockimpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'bsps/shared/dev/clock/clockimpl.h')
-rw-r--r--bsps/shared/dev/clock/clockimpl.h102
1 files changed, 70 insertions, 32 deletions
diff --git a/bsps/shared/dev/clock/clockimpl.h b/bsps/shared/dev/clock/clockimpl.h
index dad71307f4..b27f7c15bc 100644
--- a/bsps/shared/dev/clock/clockimpl.h
+++ b/bsps/shared/dev/clock/clockimpl.h
@@ -1,18 +1,40 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
*
- * @ingroup bsp_clock
+ * @ingroup RTEMSDriverClockImpl
+ *
+ * @brief This header file contains the shared Clock Driver implementation.
*
- * @brief Clock Tick Device Driver Shell
+ * This header file shall only be included by a particular Clock Driver
+ * implementation source file.
*/
/*
* COPYRIGHT (c) 1989-2014.
* On-Line Applications Research Corporation (OAR).
*
- * 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.
+ * 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.
*/
#include <stdlib.h>
@@ -20,27 +42,35 @@
#include <bsp.h>
#include <rtems/clockdrv.h>
#include <rtems/score/percpu.h>
+#include <rtems/score/processormaskimpl.h>
#include <rtems/score/smpimpl.h>
#include <rtems/score/timecounter.h>
#include <rtems/score/thread.h>
#include <rtems/score/watchdogimpl.h>
-#ifdef Clock_driver_nanoseconds_since_last_tick
-#error "Update driver to use the timecounter instead of nanoseconds extension"
-#endif
-
/**
- * @defgroup bsp_clock Clock Support
- *
- * @ingroup RTEMSBSPsShared
+ * @defgroup RTEMSDriverClockImpl Clock Driver Implementation
*
- * @brief Clock support
+ * @ingroup RTEMSDriverClock
*
+ * @brief This group contains the Clock Driver implementation.
*/
+
+#ifdef Clock_driver_nanoseconds_since_last_tick
+#error "Update driver to use the timecounter instead of nanoseconds extension"
+#endif
+
#if CLOCK_DRIVER_USE_FAST_IDLE && CLOCK_DRIVER_ISRS_PER_TICK
#error "Fast Idle PLUS n ISRs per tick is not supported"
#endif
+#if defined(BSP_FEATURE_IRQ_EXTENSION) || \
+ (CPU_SIMPLE_VECTORED_INTERRUPTS != TRUE)
+typedef void * Clock_isr_argument;
+#else
+typedef rtems_vector_number Clock_isr_argument;
+#endif
+
/**
* @brief Do nothing by default.
*/
@@ -59,7 +89,7 @@
* @brief Do nothing by default.
*/
#ifndef Clock_driver_support_at_tick
- #define Clock_driver_support_at_tick()
+ #define Clock_driver_support_at_tick( arg ) do { (void) arg; } while (0)
#endif
/**
@@ -74,8 +104,9 @@
* instead of the default.
*/
#ifndef Clock_driver_timecounter_tick
-static void Clock_driver_timecounter_tick( void )
+static void Clock_driver_timecounter_tick( Clock_isr_argument arg )
{
+ (void) arg;
#if defined(CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER)
rtems_clock_tick();
#elif defined(RTEMS_SMP) && defined(CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR)
@@ -117,25 +148,31 @@ volatile uint32_t Clock_driver_ticks;
#error "Clock_driver_support_shutdown_hardware() is no longer supported"
#endif
+#if CLOCK_DRIVER_USE_FAST_IDLE
+static bool _Clock_Has_watchdogs(const Per_CPU_Control *cpu)
+{
+ size_t i;
+
+ for (i = 0; i < RTEMS_ARRAY_SIZE(cpu->Watchdog.Header); ++i) {
+ if (_Watchdog_Header_first(&cpu->Watchdog.Header[i]) != NULL) {
+ return true;
+ }
+ }
+
+ return false;
+}
+#endif
+
/**
* @brief Clock_isr
*
* This is the clock tick interrupt handler.
*
- * @param vector Vector number.
+ * @param arg is the clock interrupt handler argument.
*/
-#if defined(BSP_FEATURE_IRQ_EXTENSION) || \
- (CPU_SIMPLE_VECTORED_INTERRUPTS != TRUE)
-void Clock_isr(void *arg);
-void Clock_isr(void *arg)
+void Clock_isr( Clock_isr_argument arg );
+void Clock_isr( Clock_isr_argument arg )
{
-#else
-rtems_isr Clock_isr(rtems_vector_number vector);
-rtems_isr Clock_isr(
- rtems_vector_number vector
-)
-{
-#endif
/*
* Accurate count of ISRs
*/
@@ -143,7 +180,7 @@ rtems_isr Clock_isr(
#if CLOCK_DRIVER_USE_FAST_IDLE
{
- Clock_driver_timecounter_tick();
+ Clock_driver_timecounter_tick( arg );
if (_SMP_Get_processor_maximum() == 1) {
struct timecounter *tc;
@@ -160,6 +197,7 @@ rtems_isr Clock_isr(
cpu_self->thread_dispatch_disable_level == cpu_self->isr_nest_level
&& cpu_self->heir == cpu_self->executing
&& cpu_self->executing->is_idle
+ && _Clock_Has_watchdogs(cpu_self)
) {
ISR_lock_Context lock_context;
@@ -172,7 +210,7 @@ rtems_isr Clock_isr(
}
}
- Clock_driver_support_at_tick();
+ Clock_driver_support_at_tick( arg );
}
#else
/*
@@ -180,14 +218,14 @@ rtems_isr Clock_isr(
*
* The counter/timer may or may not be set to automatically reload.
*/
- Clock_driver_support_at_tick();
+ Clock_driver_support_at_tick( arg );
#if CLOCK_DRIVER_ISRS_PER_TICK
/*
* The driver is multiple ISRs per clock tick.
*/
if ( !Clock_driver_isrs ) {
- Clock_driver_timecounter_tick();
+ Clock_driver_timecounter_tick( arg );
Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK_VALUE;
}
@@ -196,7 +234,7 @@ rtems_isr Clock_isr(
/*
* The driver is one ISR per clock tick.
*/
- Clock_driver_timecounter_tick();
+ Clock_driver_timecounter_tick( arg );
#endif
#endif
}