19 #ifndef _RTEMS_SCORE_WATCHDOGIMPL_H 20 #define _RTEMS_SCORE_WATCHDOGIMPL_H 24 #include <rtems/score/assert.h> 29 #include <sys/types.h> 30 #include <sys/timespec.h> 75 #if defined(RTEMS_SMP) 76 #define WATCHDOG_INITIALIZER( routine ) \ 78 { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ 79 &_Per_CPU_Information[ 0 ].per_cpu, \ 84 #define WATCHDOG_INITIALIZER( routine ) \ 86 { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ 126 return RB_COLOR( &the_watchdog->
Node.
RBTree, Node );
134 RB_COLOR( &the_watchdog->
Node.
RBTree, Node ) = state;
141 #if defined(RTEMS_SMP) 142 return the_watchdog->cpu;
144 return _Per_CPU_Get_by_index( 0 );
153 #if defined(RTEMS_SMP) 154 the_watchdog->cpu = cpu;
173 _Watchdog_Set_CPU( the_watchdog, cpu );
176 #if defined(RTEMS_DEBUG) 193 the_watchdog->
routine = routine;
196 void _Watchdog_Do_tickle(
200 #
if defined(RTEMS_SMP)
206 #if defined(RTEMS_SMP) 207 #define _Watchdog_Tickle( header, first, now, lock, lock_context ) \ 208 _Watchdog_Do_tickle( header, first, now, lock, lock_context ) 210 #define _Watchdog_Tickle( header, first, now, lock, lock_context ) \ 211 _Watchdog_Do_tickle( header, first, now, lock_context ) 256 expire = the_watchdog->
expire;
258 if ( now < expire ) {
259 remaining = expire - now;
283 if ( node !=
NULL ) {
290 header->
first = node;
299 #define WATCHDOG_MAXIMUM_TICKS UINT64_MAX 301 #define WATCHDOG_NANOSECONDS_PER_SECOND 1000000000 311 #define WATCHDOG_BITS_FOR_1E9_NANOSECONDS 30 319 #define WATCHDOG_MAX_SECONDS 0x3ffffffff 322 const struct timespec *ts
326 && (
unsigned long) ts->tv_nsec < WATCHDOG_NANOSECONDS_PER_SECOND;
330 const struct timespec *ts
333 return _Watchdog_Is_valid_timespec( ts ) && ts->tv_sec >= 0;
337 struct timespec *now,
338 const struct timespec *delta
343 if ( !_Watchdog_Is_valid_interval_timespec( delta ) ) {
347 sec = (uint64_t) now->tv_sec;
348 sec += (uint64_t) delta->tv_sec;
349 now->tv_nsec += delta->tv_nsec;
352 if ( now->tv_nsec >= WATCHDOG_NANOSECONDS_PER_SECOND ) {
353 now->tv_nsec -= WATCHDOG_NANOSECONDS_PER_SECOND;
357 if ( sec <= INT64_MAX ) {
360 now->tv_sec = INT64_MAX;
367 const struct timespec *ts
377 uint64_t ticks = seconds;
385 const struct timespec *ts
390 _Assert( _Watchdog_Is_valid_timespec( ts ) );
391 _Assert( ts->tv_sec >= 0 );
392 _Assert( !_Watchdog_Is_far_future_timespec( ts ) );
394 ticks = (uint64_t) ts->tv_sec;
396 ticks |= (uint32_t) ts->tv_nsec;
405 ticks |= ( (uint64_t) 1000000000 * (uint32_t) sbt ) >> 32;
438 _Watchdog_Set_CPU( the_watchdog, cpu );
440 _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
443 _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
456 _Watchdog_Set_CPU( the_watchdog, cpu );
458 _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
460 _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
472 _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
477 _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
486 cpu = _Watchdog_Get_CPU( the_watchdog );
487 _Watchdog_Per_CPU_remove(
void _Watchdog_Insert(Watchdog_Header *header, Watchdog_Control *the_watchdog, uint64_t expire)
Inserts a watchdog into the set of scheduled watchdogs according to the specified expiration time...
Definition: watchdoginsert.c:28
void _Watchdog_Tick(struct Per_CPU_Control *cpu)
Performs a watchdog tick.
Definition: watchdogtick.c:54
Watchdog_Header Header[PER_CPU_WATCHDOG_COUNT]
Header for watchdogs.
Definition: percpu.h:416
The watchdog is scheduled and a black node in the red-black tree.
Definition: watchdogimpl.h:48
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:278
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
The watchdog is on a chain of pending watchdogs.
Definition: watchdogimpl.h:65
uint64_t expire
This field is the expiration time point.
Definition: watchdog.h:114
uint64_t ticks
Protects all watchdog operations on this processor.
Definition: percpu.h:409
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Cancel(Watchdog_Header *header, Watchdog_Control *the_watchdog, uint64_t now)
In case the watchdog is scheduled, then it is removed from the set of scheduled watchdogs.
Definition: watchdogimpl.h:247
The control block used to manage each watchdog timer.
Definition: watchdog.h:87
Red-black tree node.
Definition: rbtree.h:50
ISR lock control.
Definition: isrlock.h:56
Watchdog_Service_routine_entry routine
This field is the function to invoke.
Definition: watchdog.h:111
RTEMS_INLINE_ROUTINE void _Watchdog_Initialize(Watchdog_Control *the_watchdog, Watchdog_Service_routine_entry routine)
Initializes a watchdog with a new service routine.
Definition: watchdogimpl.h:187
RBTree_Node RBTree
this field is a red-black tree node structure and allows this to be placed on a red-black tree used t...
Definition: watchdog.h:96
void _Watchdog_Remove(Watchdog_Header *header, Watchdog_Control *the_watchdog)
In case the watchdog is scheduled, then it is removed from the set of scheduled watchdogs.
Definition: watchdogremove.c:28
Per CPU Core Structure.
Definition: percpu.h:290
RTEMS_INLINE_ROUTINE RBTree_Node * _RBTree_Right(const RBTree_Node *the_node)
Return pointer to the right of this node.
Definition: rbtree.h:324
#define _ISR_lock_Release(_lock, _context)
Releases an ISR lock inside an ISR disabled section.
Definition: isrlock.h:301
RTEMS_INLINE_ROUTINE RBTree_Node * _RBTree_Parent(const RBTree_Node *the_node)
Returns a pointer to the parent of this node.
Definition: rbtree.h:281
Watchdog_State
Watchdog states.
Definition: watchdogimpl.h:44
RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu)
Pre-initializes a watchdog.
Definition: watchdogimpl.h:168
The watchdog is inactive.
Definition: watchdogimpl.h:58
Constants and Structures Associated with Watchdog Timers.
The watchdog is scheduled and a red node in the red-black tree.
Definition: watchdogimpl.h:53
Inlined Routines Associated with Red-Black Trees.
#define WATCHDOG_BITS_FOR_1E9_NANOSECONDS
The bits necessary to store 1000000000 (= WATCHDOG_NANOSECONDS_PER_SECOND) nanoseconds.
Definition: watchdogimpl.h:311
#define WATCHDOG_MAX_SECONDS
The maximum number of seconds representable in the nanoseconds watchdog format.
Definition: watchdogimpl.h:319
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:36
RTEMS_INLINE_ROUTINE RBTree_Node * _RBTree_Left(const RBTree_Node *the_node)
Return pointer to the left of this node.
Definition: rbtree.h:297
struct Per_CPU_Control::@3973 Watchdog
Watchdog state for this processor.
union Watchdog_Control::@3983 Node
Nodes for the watchdog.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Index for tick clock per-CPU watchdog header.
Definition: percpu.h:259
RTEMS_INLINE_ROUTINE void _RBTree_Initialize_empty(RBTree_Control *the_rbtree)
Initialize this RBTree as empty.
Definition: rbtree.h:387
Watchdog_Service_routine(* Watchdog_Service_routine_entry)(Watchdog_Control *)
Pointer to a watchdog service routine.
Definition: watchdog.h:63
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77