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 } } }, \ 105 header->
first = NULL;
153 return RB_COLOR( &the_watchdog->
Node.
RBTree, Node );
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;
union Watchdog_Control::@33 Node
Nodes for the watchdog.
Watchdog_Service_routine(* Watchdog_Service_routine_entry)(Watchdog_Control *)
Pointer to a watchdog service routine.
static __inline__ uint64_t _Watchdog_Ticks_from_sbintime(int64_t sbt)
Converts the sbintime in ticks.
static __inline__ 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.
The watchdog is inactive.
struct Per_CPU_Control * cpu
This field references the processor of this watchdog control.
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Watchdog_Header Header[PER_CPU_WATCHDOG_COUNT]
Header for watchdogs.
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...
static __inline__ void _Watchdog_Next_first(Watchdog_Header *header, Watchdog_Control *the_watchdog)
Sets the first node of the header.
ISR_lock_Control Lock
This lock protects some members of this structure.
static __inline__ RBTree_Node * _RBTree_Right(const RBTree_Node *the_node)
Returns pointer to the right of this node.
static __inline__ uint64_t _Watchdog_Ticks_from_timespec(const struct timespec *ts)
Converts the timespec in ticks.
static __inline__ Watchdog_State _Watchdog_Get_state(const Watchdog_Control *the_watchdog)
Gets the state of the watchdog.
uint64_t expire
This field is the expiration time point.
uint64_t ticks
Protects all watchdog operations on this processor.
The control block used to manage each watchdog timer.
static __inline__ void _RBTree_Initialize_empty(RBTree_Control *the_rbtree)
Initializes this RBTree as empty.
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...
Watchdog_State
Watchdog states.
static __inline__ bool _Watchdog_Is_valid_timespec(const struct timespec *ts)
Checks if the timespec is a valid timespec for a watchdog.
Constants and Structures Associated with Watchdog Timers.
Watchdog_Service_routine_entry routine
This field is the function to invoke.
static __inline__ bool _Watchdog_Is_scheduled(const Watchdog_Control *the_watchdog)
Checks if the watchdog is scheduled.
static __inline__ void _Watchdog_Preinitialize(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu)
Pre-initializes a watchdog.
Information for the Assert Handler.
static __inline__ 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...
static __inline__ bool _Watchdog_Is_valid_interval_timespec(const struct timespec *ts)
Checks if the timespec is a valid interval timespec for a watchdog.
The watchdog is scheduled and a black node in the red-black tree.
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...
static __inline__ Per_CPU_Control * _Watchdog_Get_CPU(const Watchdog_Control *the_watchdog)
Gets the watchdog's cpu.
static __inline__ uint64_t _Watchdog_Ticks_from_seconds(uint32_t seconds)
Converts the seconds to ticks.
static __inline__ 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...
#define WATCHDOG_MAX_SECONDS
The maximum number of seconds representable in the nanoseconds watchdog format.
struct Per_CPU_Control::@13 Watchdog
Watchdog state for this processor.
static __inline__ RBTree_Node * _RBTree_Parent(const RBTree_Node *the_node)
Returns a pointer to the parent of this node.
static __inline__ 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.
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
static __inline__ 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.
#define _ISR_lock_Release(_lock, _context)
Releases an ISR lock inside an ISR disabled section.
static __inline__ 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...
static __inline__ void _Watchdog_Header_destroy(Watchdog_Header *header)
Destroys the watchdog header.
The watchdog is on a chain of pending watchdogs.
static __inline__ void _Watchdog_Initialize(Watchdog_Control *the_watchdog, Watchdog_Service_routine_entry routine)
Initializes a watchdog with a new service routine.
Inlined Routines Associated with Red-Black Trees.
The watchdog is scheduled and a red node in the red-black tree.
static __inline__ void _Watchdog_Per_CPU_remove_ticks(Watchdog_Control *the_watchdog)
Removes the watchdog from the cpu and the scheduled watchdogs.
static __inline__ RBTree_Node * _RBTree_Left(const RBTree_Node *the_node)
Returns pointer to the left of this node.
Per_CPU_State state
Indicates the current state of the CPU.
void _Watchdog_Do_tickle(Watchdog_Header *header, Watchdog_Control *first, uint64_t now, ISR_lock_Control *lock, ISR_lock_Context *lock_context)
Calls the routine of each not expired watchdog control node.
static __inline__ Watchdog_Control * _Watchdog_Header_first(const Watchdog_Header *header)
Returns the first of the watchdog header.
#define WATCHDOG_BITS_FOR_1E9_NANOSECONDS
The bits necessary to store 1000000000 (= WATCHDOG_NANOSECONDS_PER_SECOND) nanoseconds.
Constants for the watchdog ticks.
static __inline__ 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.
Local ISR lock context for acquire and release pairs.
#define RTEMS_INLINE_ROUTINE
Gives a hint to the compiler in a function declaration to inline this function.
Index for tick clock per-CPU watchdog header.
static __inline__ bool _Watchdog_Is_far_future_timespec(const struct timespec *ts)
Checks if the timespec is too far in the future.
static __inline__ void _Watchdog_Set_state(Watchdog_Control *the_watchdog, Watchdog_State state)
Sets the state of the watchdog.
static __inline__ void _Watchdog_Set_CPU(Watchdog_Control *the_watchdog, Per_CPU_Control *cpu)
Sets the cpu for the watchdog.
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
static __inline__ void _Watchdog_Header_initialize(Watchdog_Header *header)
Initializes the watchdog header.
void _Watchdog_Tick(struct Per_CPU_Control *cpu)
Performs a watchdog tick.