21 #ifndef _RTEMS_SCORE_WATCHDOGIMPL_H 22 #define _RTEMS_SCORE_WATCHDOGIMPL_H 31 #include <sys/types.h> 32 #include <sys/timespec.h> 78 #if defined(RTEMS_SMP) 79 #define WATCHDOG_INITIALIZER( routine ) \ 81 { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ 82 &_Per_CPU_Information[ 0 ].per_cpu, \ 87 #define WATCHDOG_INITIALIZER( routine ) \ 89 { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ 153 return RB_COLOR( &the_watchdog->
Node.
RBTree, Node );
167 RB_COLOR( &the_watchdog->
Node.
RBTree, Node ) = state;
181 #if defined(RTEMS_SMP) 182 return the_watchdog->cpu;
184 return _Per_CPU_Get_by_index( 0 );
199 #if defined(RTEMS_SMP) 200 the_watchdog->cpu = cpu;
222 #if defined(RTEMS_DEBUG) 242 the_watchdog->
routine = routine;
260 #
if defined(RTEMS_SMP)
266 #if defined(RTEMS_SMP) 267 #define _Watchdog_Tickle( header, first, now, lock, lock_context ) \ 268 _Watchdog_Do_tickle( header, first, now, lock, lock_context ) 270 #define _Watchdog_Tickle( header, first, now, lock, lock_context ) \ 271 _Watchdog_Do_tickle( header, first, now, lock_context ) 327 expire = the_watchdog->
expire;
329 if ( now < expire ) {
330 remaining = expire - now;
373 if ( node !=
NULL ) {
380 header->
first = node;
389 #define WATCHDOG_MAXIMUM_TICKS UINT64_MAX 391 #define WATCHDOG_NANOSECONDS_PER_SECOND 1000000000 401 #define WATCHDOG_BITS_FOR_1E9_NANOSECONDS 30 409 #define WATCHDOG_MAX_SECONDS 0x3ffffffff 420 const struct timespec *ts
424 && (
unsigned long) ts->tv_nsec < WATCHDOG_NANOSECONDS_PER_SECOND;
436 const struct timespec *ts
453 struct timespec *now,
454 const struct timespec *delta
463 sec = (uint64_t) now->tv_sec;
464 sec += (uint64_t) delta->tv_sec;
465 now->tv_nsec += delta->tv_nsec;
468 if ( now->tv_nsec >= WATCHDOG_NANOSECONDS_PER_SECOND ) {
469 now->tv_nsec -= WATCHDOG_NANOSECONDS_PER_SECOND;
473 if ( sec <= INT64_MAX ) {
476 now->tv_sec = INT64_MAX;
491 const struct timespec *ts
508 uint64_t ticks = seconds;
523 const struct timespec *ts
532 ticks = (uint64_t) ts->tv_sec;
534 ticks |= (uint32_t) ts->tv_nsec;
550 ticks |= ( (uint64_t) 1000000000 * (uint32_t) sbt ) >> 32;
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu, Watchdog_Header *header)
Removes the watchdog from the cpu and the scheduled watchdogs.
Definition: watchdogimpl.h:649
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu, Watchdog_Header *header, uint64_t expire)
Sets the watchdog's cpu and inserts it with the given expiration time in the scheduled watchdogs.
Definition: watchdogimpl.h:625
Watchdog_Service_routine(* Watchdog_Service_routine_entry)(Watchdog_Control *)
Pointer to a watchdog service routine.
Definition: watchdog.h:66
RTEMS_INLINE_ROUTINE void _Watchdog_Set_CPU(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu)
Sets the cpu for the watchdog.
Definition: watchdogimpl.h:194
RTEMS_INLINE_ROUTINE void _Watchdog_Header_destroy(Watchdog_Header *header)
Destroys the watchdog header.
Definition: watchdogimpl.h:127
The watchdog is inactive.
Definition: watchdogimpl.h:61
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:236
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
Watchdog_Header Header[PER_CPU_WATCHDOG_COUNT]
Header for watchdogs.
Definition: percpu.h:474
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:29
RTEMS_INLINE_ROUTINE void _RBTree_Initialize_empty(RBTree_Control *the_rbtree)
Initializes this RBTree as empty.
Definition: rbtree.h:410
uint64_t expire
This field is the expiration time point.
Definition: watchdog.h:117
uint64_t ticks
Protects all watchdog operations on this processor.
Definition: percpu.h:467
The control block used to manage each watchdog timer.
Definition: watchdog.h:90
RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_interval_timespec(const struct timespec *ts)
Checks if the timespec is a valid interval timespec for a watchdog.
Definition: watchdogimpl.h:435
void _Watchdog_Remove(Watchdog_Header *header, Watchdog_Control *the_watchdog)
In the case the watchdog is scheduled, then it is removed from the set of scheduled watchdogs.
Definition: watchdogremove.c:29
RTEMS_INLINE_ROUTINE bool _Watchdog_Is_scheduled(const Watchdog_Control *the_watchdog)
Checks if the watchdog is scheduled.
Definition: watchdogimpl.h:348
Watchdog_State
Watchdog states.
Definition: watchdogimpl.h:47
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Watchdog_Get_CPU(const Watchdog_Control *the_watchdog)
Gets the watchdog's cpu.
Definition: watchdogimpl.h:177
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove_ticks(Watchdog_Control *the_watchdog)
Removes the watchdog from the cpu and the scheduled watchdogs.
Definition: watchdogimpl.h:670
Red-black tree node.
Definition: rbtree.h:55
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Cancel(Watchdog_Header *header, Watchdog_Control *the_watchdog, uint64_t now)
In the case the watchdog is scheduled, then it is removed from the set of scheduled watchdogs.
Definition: watchdogimpl.h:318
RTEMS_INLINE_ROUTINE void _Watchdog_Next_first(Watchdog_Header *header, Watchdog_Control *the_watchdog)
Sets the first node of the header.
Definition: watchdogimpl.h:366
union Watchdog_Control::@3987 Node
Nodes for the watchdog.
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_sbintime(int64_t sbt)
Converts the sbintime in ticks.
Definition: watchdogimpl.h:546
ISR lock control.
Definition: isrlock.h:56
Watchdog_Service_routine_entry routine
This field is the function to invoke.
Definition: watchdog.h:114
RTEMS_INLINE_ROUTINE Watchdog_Control * _Watchdog_Header_first(const Watchdog_Header *header)
Returns the first of the watchdog header.
Definition: watchdogimpl.h:115
Information for the Assert Handler.
RTEMS_INLINE_ROUTINE void _Watchdog_Set_state(Watchdog_Control *the_watchdog, Watchdog_State state)
Sets the state of the watchdog.
Definition: watchdogimpl.h:162
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_seconds(uint32_t seconds)
Converts the seconds to ticks.
Definition: watchdogimpl.h:504
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_timespec(const struct timespec *ts)
Converts the timespec in ticks.
Definition: watchdogimpl.h:522
RTEMS_INLINE_ROUTINE void _Watchdog_Header_initialize(Watchdog_Header *header)
Initializes the watchdog header.
Definition: watchdogimpl.h:100
The watchdog is scheduled and a black node in the red-black tree.
Definition: watchdogimpl.h:51
RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu)
Pre-initializes a watchdog.
Definition: watchdogimpl.h:214
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:99
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical(Per_CPU_Control *cpu, ISR_lock_Context *lock_context)
Releases the per cpu watchdog lock in a critical section.
Definition: watchdogimpl.h:575
Per CPU Core Structure.
Definition: percpu.h:347
#define WATCHDOG_MAX_SECONDS
The maximum number of seconds representable in the nanoseconds watchdog format.
Definition: watchdogimpl.h:409
void _Watchdog_Do_tickle(Watchdog_Header *header, Watchdog_Control *first, uint64_t now, ISR_lock_Context *lock_context)
Calls the routine of each not expired watchdog control node.
Definition: watchdogtick.c:24
RTEMS_INLINE_ROUTINE const struct timespec * _Watchdog_Future_timespec(struct timespec *now, const struct timespec *delta)
Adds the delta timespec to the current time if the delta is a valid interval timespec.
Definition: watchdogimpl.h:452
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:293
#define _ISR_lock_Release(_lock, _context)
Releases an ISR lock inside an ISR disabled section.
Definition: isrlock.h:316
Constants and Structures Associated with Watchdog Timers.
The watchdog is on a chain of pending watchdogs.
Definition: watchdogimpl.h:68
Inlined Routines Associated with Red-Black Trees.
The watchdog is scheduled and a red node in the red-black tree.
Definition: watchdogimpl.h:56
RTEMS_INLINE_ROUTINE RBTree_Node * _RBTree_Left(const RBTree_Node *the_node)
Returns pointer to the left of this node.
Definition: rbtree.h:311
RTEMS_INLINE_ROUTINE Watchdog_State _Watchdog_Get_state(const Watchdog_Control *the_watchdog)
Gets the state of the watchdog.
Definition: watchdogimpl.h:149
#define WATCHDOG_BITS_FOR_1E9_NANOSECONDS
The bits necessary to store 1000000000 (= WATCHDOG_NANOSECONDS_PER_SECOND) nanoseconds.
Definition: watchdogimpl.h:401
RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_timespec(const struct timespec *ts)
Checks if the timespec is too far in the future.
Definition: watchdogimpl.h:490
Constants for the watchdog ticks.
RTEMS_INLINE_ROUTINE RBTree_Node * _RBTree_Parent(const RBTree_Node *the_node)
Returns a pointer to the parent of this node.
Definition: rbtree.h:295
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Index for tick clock per-CPU watchdog header.
Definition: percpu.h:316
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_timespec(const struct timespec *ts)
Checks if the timespec is a valid timespec for a watchdog.
Definition: watchdogimpl.h:419
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_acquire_critical(Per_CPU_Control *cpu, ISR_lock_Context *lock_context)
Acquires the per cpu watchdog lock in a critical section.
Definition: watchdogimpl.h:561
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_ticks(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu, Watchdog_Interval ticks)
Sets the watchdog's cpu to the given instance and sets its expiration time to the watchdog expiration...
Definition: watchdogimpl.h:593
struct Per_CPU_Control::@3977 Watchdog
Watchdog state for this processor.
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
RTEMS_INLINE_ROUTINE RBTree_Node * _RBTree_Right(const RBTree_Node *the_node)
Returns pointer to the right of this node.
Definition: rbtree.h:342
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
void _Watchdog_Tick(struct Per_CPU_Control *cpu)
Performs a watchdog tick.
Definition: watchdogtick.c:54