Move the microseconds per tick configuration constant out of the configuration table.
Add WATCHDOG_MICROSECONDS_PER_TICK_DEFAULT and use it to provide a default definition of the watchdog ticks constants. Update #3875. --- cpukit/Makefile.am | 1 + cpukit/include/rtems/confdefs.h | 25 ++++++++++-------- cpukit/include/rtems/config.h | 10 ++------ cpukit/include/rtems/score/watchdogticks.h | 13 ++++++++++ cpukit/score/src/watchdogticksdefault.c | 41 ++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 cpukit/score/src/watchdogticksdefault.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index 1d3935776b..c3bdd284cd 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -1001,6 +1001,7 @@ librtemscpu_a_SOURCES += score/src/coretodhookrun.c librtemscpu_a_SOURCES += score/src/coretodhookunregister.c librtemscpu_a_SOURCES += score/src/watchdogremove.c librtemscpu_a_SOURCES += score/src/watchdogtick.c +librtemscpu_a_SOURCES += score/src/watchdogticksdefault.c librtemscpu_a_SOURCES += score/src/watchdogtickssinceboot.c librtemscpu_a_SOURCES += score/src/userextaddset.c librtemscpu_a_SOURCES += score/src/userext.c diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h index 0181af356a..4c2c80b2a9 100644 --- a/cpukit/include/rtems/confdefs.h +++ b/cpukit/include/rtems/confdefs.h @@ -1964,10 +1964,8 @@ extern "C" { /**@{*/ /** The configures the number of microseconds per clock tick. */ -#ifndef CONFIGURE_MICROSECONDS_PER_TICK - #define CONFIGURE_MICROSECONDS_PER_TICK \ - RTEMS_MILLISECONDS_TO_MICROSECONDS(10) -#endif +#if defined(CONFIGURE_MICROSECONDS_PER_TICK) && \ + CONFIGURE_MICROSECONDS_PER_TICK != WATCHDOG_MICROSECONDS_PER_TICK_DEFAULT #if 1000000 % CONFIGURE_MICROSECONDS_PER_TICK != 0 #warning "The clock ticks per second is not an integer" @@ -1977,7 +1975,18 @@ extern "C" { #error "The CONFIGURE_MICROSECONDS_PER_TICK must be positive" #endif -#define _CONFIGURE_TICKS_PER_SECOND (1000000 / CONFIGURE_MICROSECONDS_PER_TICK) +#ifdef CONFIGURE_INIT + const uint32_t _Watchdog_Microseconds_per_tick = + CONFIGURE_MICROSECONDS_PER_TICK; + + const uint32_t _Watchdog_Nanoseconds_per_tick = + (uint32_t) 1000 * CONFIGURE_MICROSECONDS_PER_TICK; + + const uint32_t _Watchdog_Ticks_per_second = + 1000000 / CONFIGURE_MICROSECONDS_PER_TICK; +#endif + +#endif /* CONFIGURE_MICROSECONDS_PER_TICK */ /** The configures the number of clock ticks per timeslice. */ #ifndef CONFIGURE_TICKS_PER_TIMESLICE @@ -2474,11 +2483,6 @@ struct _reent *__getreent(void) sizeof( Thread_queue_Configured_heads ); #endif - const uint32_t _Watchdog_Nanoseconds_per_tick = - (uint32_t) 1000 * CONFIGURE_MICROSECONDS_PER_TICK; - - const uint32_t _Watchdog_Ticks_per_second = _CONFIGURE_TICKS_PER_SECOND; - const size_t _Thread_Initial_thread_count = rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) + rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS ); @@ -2644,7 +2648,6 @@ struct _reent *__getreent(void) */ const rtems_configuration_table Configuration = { CONFIGURE_EXECUTIVE_RAM_SIZE, /* required RTEMS workspace */ - CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */ CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */ CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */ CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */ diff --git a/cpukit/include/rtems/config.h b/cpukit/include/rtems/config.h index d9f91db741..84917366f3 100644 --- a/cpukit/include/rtems/config.h +++ b/cpukit/include/rtems/config.h @@ -86,12 +86,6 @@ typedef struct { */ uintptr_t work_space_size; - /** - * This field specifies the number of microseconds which elapse - * between clock ticks. This is the basis for RTEMS timing. - */ - uint32_t microseconds_per_tick; - /** * This field specifies the number of ticks in each task's timeslice. */ @@ -162,9 +156,9 @@ uintptr_t rtems_configuration_get_stack_space_size( void ); uint32_t rtems_configuration_get_maximum_extensions( void ); #define rtems_configuration_get_microseconds_per_tick() \ - (Configuration.microseconds_per_tick) + (_Watchdog_Microseconds_per_tick) #define rtems_configuration_get_milliseconds_per_tick() \ - (Configuration.microseconds_per_tick / 1000) + (_Watchdog_Microseconds_per_tick / 1000) #define rtems_configuration_get_nanoseconds_per_tick() \ (_Watchdog_Nanoseconds_per_tick) diff --git a/cpukit/include/rtems/score/watchdogticks.h b/cpukit/include/rtems/score/watchdogticks.h index e7cf3f3ea3..eaeddb5e6b 100644 --- a/cpukit/include/rtems/score/watchdogticks.h +++ b/cpukit/include/rtems/score/watchdogticks.h @@ -42,6 +42,11 @@ typedef uint32_t Watchdog_Interval; */ #define WATCHDOG_NO_TIMEOUT 0 +/** + * @brief Default value for the watchdog tick interval in microseconds. + */ +#define WATCHDOG_MICROSECONDS_PER_TICK_DEFAULT 10000 + /** * @brief The watchdog ticks counter. * @@ -49,6 +54,14 @@ typedef uint32_t Watchdog_Interval; */ extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot; +/** + * @brief The watchdog microseconds per tick. + * + * This constant is defined by the application configuration via + * <rtems/confdefs.h>. + */ +extern const uint32_t _Watchdog_Microseconds_per_tick; + /** * @brief The watchdog nanoseconds per tick. * diff --git a/cpukit/score/src/watchdogticksdefault.c b/cpukit/score/src/watchdogticksdefault.c new file mode 100644 index 0000000000..412de71c77 --- /dev/null +++ b/cpukit/score/src/watchdogticksdefault.c @@ -0,0 +1,41 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (C) 2020 embedded brains GmbH + * + * 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. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/score/watchdogticks.h> + +const uint32_t _Watchdog_Microseconds_per_tick = + WATCHDOG_MICROSECONDS_PER_TICK_DEFAULT; + +const uint32_t _Watchdog_Nanoseconds_per_tick = + WATCHDOG_MICROSECONDS_PER_TICK_DEFAULT * 1000; + +const uint32_t _Watchdog_Ticks_per_second = + 1000000 / WATCHDOG_MICROSECONDS_PER_TICK_DEFAULT; -- 2.16.4 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel