diff options
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/coretodhookdata.c | 45 | ||||
-rw-r--r-- | cpukit/score/src/coretodhookregister.c | 61 | ||||
-rw-r--r-- | cpukit/score/src/coretodhookrun.c | 72 | ||||
-rw-r--r-- | cpukit/score/src/coretodhookunregister.c | 60 | ||||
-rw-r--r-- | cpukit/score/src/coretodset.c | 11 |
5 files changed, 248 insertions, 1 deletions
diff --git a/cpukit/score/src/coretodhookdata.c b/cpukit/score/src/coretodhookdata.c new file mode 100644 index 0000000000..6e7bcff494 --- /dev/null +++ b/cpukit/score/src/coretodhookdata.c @@ -0,0 +1,45 @@ +/** + * @file + * + * @brief TOD Hook Set + * + * @ingroup RTEMSScoreTODHooks + */ + +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * COPYRIGHT (c) 2019. + * On-Line Applications Research Corporation (OAR). + * + * 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/todimpl.h> +#include <rtems/score/chainimpl.h> + +Chain_Control _TOD_Hooks = CHAIN_INITIALIZER_EMPTY(_TOD_Hooks); + diff --git a/cpukit/score/src/coretodhookregister.c b/cpukit/score/src/coretodhookregister.c new file mode 100644 index 0000000000..69996a2b06 --- /dev/null +++ b/cpukit/score/src/coretodhookregister.c @@ -0,0 +1,61 @@ +/** + * @file + * + * @brief Register Hook to be in TOD Hook Set + * + * @ingroup RTEMSScoreTODHooks + */ + +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * COPYRIGHT (c) 2019. + * On-Line Applications Research Corporation (OAR). + * + * 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/todimpl.h> +#include <rtems/score/chainimpl.h> + +void _TOD_Hook_Register( + TOD_Hook *hook +) +{ + /* + * At this time, this method does NOT have a Classic or POSIX API + * that exports it. Any use of this method will be a direct call. + * It should only be called while NOT holding the TOD lock. + */ + _Assert( !_TOD_Is_owner() ); + + _Assert( hook != NULL ); + + _TOD_Lock(); + _Chain_Append_unprotected( &_TOD_Hooks, &hook->Node ); + _TOD_Unlock(); +} + diff --git a/cpukit/score/src/coretodhookrun.c b/cpukit/score/src/coretodhookrun.c new file mode 100644 index 0000000000..ae9cf66dfc --- /dev/null +++ b/cpukit/score/src/coretodhookrun.c @@ -0,0 +1,72 @@ +/** + * @file + * + * @brief Run TOD Hook Set + * + * @ingroup RTEMSScoreTODHooks + */ + +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * COPYRIGHT (c) 2019. + * On-Line Applications Research Corporation (OAR). + * + * 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/todimpl.h> +#include <rtems/score/assert.h> +#include <rtems/score/chainimpl.h> + +bool _TOD_Hook_Run( + TOD_Action action, + const struct timespec *tod +) +{ + Chain_Node *the_node; + bool retval = true; + + /* + * This is assumed to be called only from _TOD_Set() which is supposed + * to be called only while holding the TOD lock. + */ + _Assert( _TOD_Is_owner() ); + + for ( the_node = _Chain_First( &_TOD_Hooks ); + !_Chain_Is_tail( &_TOD_Hooks, the_node ) ; + the_node = the_node->next ) { + TOD_Hook *the_hook = (TOD_Hook *) the_node; + + retval = (the_hook->handler)( action, tod ); + if ( retval == false ) { + break; + } + } + + return retval; +} + diff --git a/cpukit/score/src/coretodhookunregister.c b/cpukit/score/src/coretodhookunregister.c new file mode 100644 index 0000000000..ce978e8e81 --- /dev/null +++ b/cpukit/score/src/coretodhookunregister.c @@ -0,0 +1,60 @@ +/** + * @file + * + * @brief Remove Hook from TOD Hook Set + * + * @ingroup RTEMSScoreTODHooks + */ + +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * COPYRIGHT (c) 2019. + * On-Line Applications Research Corporation (OAR). + * + * 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/todimpl.h> +#include <rtems/score/chainimpl.h> + +void _TOD_Hook_Unregister( + TOD_Hook *hook +) +{ + /* + * At this time, this method does NOT have a Classic or POSIX API + * that exports it. Any use of this method will be a direct call. + * It should only be called while NOT holding the TOD lock. + */ + _Assert( !_TOD_Is_owner() ); + + _Assert( hook != NULL ); + + _TOD_Lock(); + _Chain_Extract_unprotected( &hook->Node ); + _TOD_Unlock(); +} diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c index b021a58dc6..94ecd0b322 100644 --- a/cpukit/score/src/coretodset.c +++ b/cpukit/score/src/coretodset.c @@ -22,7 +22,7 @@ #include <rtems/score/assert.h> #include <rtems/score/watchdogimpl.h> -void _TOD_Set( +bool _TOD_Set( const struct timespec *tod, ISR_lock_Context *lock_context ) @@ -31,9 +31,16 @@ void _TOD_Set( uint64_t tod_as_ticks; uint32_t cpu_max; uint32_t cpu_index; + bool retval; _Assert( _TOD_Is_owner() ); + retval = _TOD_Hook_Run( TOD_ACTION_SET_CLOCK, tod ); + if ( retval == false ) { + _TOD_Release( lock_context ); + return false; + } + timespec2bintime( tod, &tod_as_bintime ); _Timecounter_Set_clock( &tod_as_bintime, lock_context ); @@ -67,4 +74,6 @@ void _TOD_Set( } _TOD.is_set = true; + + return true; } |