RTEMS CPU Kit with SuperCore  4.11.2
watchdogimpl.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2004.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_WATCHDOGIMPL_H
20 #define _RTEMS_SCORE_WATCHDOGIMPL_H
21 
22 #include <rtems/score/watchdog.h>
23 #include <rtems/score/assert.h>
24 #include <rtems/score/chainimpl.h>
25 #include <rtems/score/isrlock.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
41 #define WATCHDOG_INITIALIZER( routine, id, user_data ) \
42  { \
43  { NULL, NULL }, \
44  WATCHDOG_INACTIVE, \
45  0, 0, 0, 0, \
46  ( routine ), ( id ), ( user_data ) \
47  }
48 
53 typedef struct {
58 
63 
70 
74 typedef struct {
78  ISR_LOCK_MEMBER( Lock )
79 
80 
83  Chain_Control Watchdogs;
84 
91  Chain_Control Iterators;
93 
100 
107 
108 RTEMS_INLINE_ROUTINE void _Watchdog_Acquire(
109  Watchdog_Header *header,
110  ISR_lock_Context *lock_context
111 )
112 {
113  _ISR_lock_ISR_disable_and_acquire( &header->Lock, lock_context );
114 }
115 
116 RTEMS_INLINE_ROUTINE void _Watchdog_Release(
117  Watchdog_Header *header,
118  ISR_lock_Context *lock_context
119 )
120 {
121  _ISR_lock_Release_and_ISR_enable( &header->Lock, lock_context );
122 }
123 
124 RTEMS_INLINE_ROUTINE void _Watchdog_Flash(
125  Watchdog_Header *header,
126  ISR_lock_Context *lock_context
127 )
128 {
129  _ISR_lock_Flash( &header->Lock, lock_context );
130 }
131 
140 
146 void _Watchdog_Tick( void );
147 
159  Watchdog_Header *header,
160  Watchdog_Control *the_watchdog
161 );
162 
171  Watchdog_Header *header,
172  Watchdog_Interval units
173 );
174 
187  Watchdog_Header *header,
188  Watchdog_Interval units
189 );
190 
201  Watchdog_Header *header,
202  Watchdog_Interval units
203 );
204 
219  Watchdog_Header *header,
220  Watchdog_Interval units,
221  ISR_lock_Context *lock_context
222 );
223 
235 void _Watchdog_Insert (
236  Watchdog_Header *header,
237  Watchdog_Control *the_watchdog
238 );
239 
254  Watchdog_Header *header,
255  Watchdog_Control *the_watchdog,
256  ISR_lock_Context *lock_context
257 );
258 
269 void _Watchdog_Tickle (
270  Watchdog_Header *header
271 );
272 
282  Watchdog_Control *the_watchdog
283 )
284 {
285  the_watchdog->state = WATCHDOG_INACTIVE;
286 #if defined(RTEMS_DEBUG)
287  the_watchdog->routine = NULL;
288  the_watchdog->id = 0;
289  the_watchdog->user_data = NULL;
290 #endif
291 }
292 
300  Watchdog_Control *the_watchdog,
302  Objects_Id id,
303  void *user_data
304 )
305 {
306  _Assert( the_watchdog->state == WATCHDOG_INACTIVE );
307  the_watchdog->routine = routine;
308  the_watchdog->id = id;
309  the_watchdog->user_data = user_data;
310 }
311 
318  Watchdog_Control *the_watchdog
319 )
320 {
321 
322  return ( the_watchdog->state == WATCHDOG_ACTIVE );
323 
324 }
325 
332  Watchdog_Control *the_watchdog
333 )
334 {
335 
336  the_watchdog->state = WATCHDOG_ACTIVE;
337 
338 }
339 
346 {
347 
349 
350 }
351 
358 {
359 
361 
362 }
363 
372  Watchdog_Control *the_watchdog,
373  Watchdog_Interval units
374 )
375 {
376 
377  the_watchdog->initial = units;
378 
379  _Watchdog_Insert( &_Watchdog_Ticks_header, the_watchdog );
380 
381 }
382 
391  Watchdog_Control *the_watchdog,
392  Watchdog_Interval units
393 )
394 {
395 
396  the_watchdog->initial = units;
397 
398  _Watchdog_Insert( &_Watchdog_Seconds_header, the_watchdog );
399 
400 }
401 
402 RTEMS_INLINE_ROUTINE Watchdog_States _Watchdog_Remove_ticks(
403  Watchdog_Control *the_watchdog
404 )
405 {
406  return _Watchdog_Remove( &_Watchdog_Ticks_header, the_watchdog );
407 }
408 
409 RTEMS_INLINE_ROUTINE Watchdog_States _Watchdog_Remove_seconds(
410  Watchdog_Control *the_watchdog
411 )
412 {
413  return _Watchdog_Remove( &_Watchdog_Seconds_header, the_watchdog );
414 }
415 
424  Watchdog_Control *the_watchdog
425 )
426 {
427 
428  _Watchdog_Remove_ticks( the_watchdog );
429 
430  _Watchdog_Insert( &_Watchdog_Ticks_header, the_watchdog );
431 
432 }
433 
440  Watchdog_Control *the_watchdog
441 )
442 {
443 
444  return ( (Watchdog_Control *) the_watchdog->Node.next );
445 
446 }
447 
454  Watchdog_Control *the_watchdog
455 )
456 {
457 
458  return ( (Watchdog_Control *) the_watchdog->Node.previous );
459 
460 }
461 
468  Watchdog_Header *header
469 )
470 {
471 
472  return ( (Watchdog_Control *) _Chain_First( &header->Watchdogs ) );
473 
474 }
475 
482  Watchdog_Header *header
483 )
484 {
485 
486  return ( (Watchdog_Control *) _Chain_Last( &header->Watchdogs ) );
487 
488 }
489 
490 RTEMS_INLINE_ROUTINE bool _Watchdog_Is_empty(
491  const Watchdog_Header *header
492 )
493 {
494  return _Chain_Is_empty( &header->Watchdogs );
495 }
496 
497 RTEMS_INLINE_ROUTINE void _Watchdog_Header_initialize(
498  Watchdog_Header *header
499 )
500 {
501  _ISR_lock_Initialize( &header->Lock, "Watchdog" );
504 }
505 
508 #ifdef __cplusplus
509 }
510 #endif
511 
512 #endif
513 /* end of include file */
This is used to manage each element (node) which is placed on a chain.
Definition: chain.h:65
Chain_Node * previous
This points to the node immediate prior to this one on this chain.
Definition: chain.h:69
RTEMS_INLINE_ROUTINE void _Watchdog_Activate(Watchdog_Control *the_watchdog)
This routine activates THE_WATCHDOG timer which is already on a watchdog chain.
Definition: watchdogimpl.h:331
RTEMS_INLINE_ROUTINE void _Watchdog_Reset_ticks(Watchdog_Control *the_watchdog)
This routine resets THE_WATCHDOG timer to its state at INSERT time.
Definition: watchdogimpl.h:423
RTEMS_INLINE_ROUTINE void _Watchdog_Tickle_ticks(void)
This routine is invoked at each clock tick to update the ticks watchdog chain.
Definition: watchdogimpl.h:345
#define _ISR_lock_ISR_disable_and_acquire(_lock, _context)
Acquires an ISR lock.
Definition: isrlock.h:205
void _Watchdog_Adjust_backward_locked(Watchdog_Header *header, Watchdog_Interval units)
Adjusts the watchdogs in backward direction in a locked context.
Definition: watchdogadjust.c:23
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:89
RTEMS_INLINE_ROUTINE Watchdog_Control * _Watchdog_Next(Watchdog_Control *the_watchdog)
This routine returns a pointer to the watchdog timer following THE_WATCHDOG on the watchdog chain...
Definition: watchdogimpl.h:439
The control block used to manage each watchdog timer.
Definition: watchdog.h:98
Chain_Node Node
A node for a Watchdog_Header::Iterators chain.
Definition: watchdogimpl.h:57
RTEMS_INLINE_ROUTINE Watchdog_Control * _Watchdog_First(Watchdog_Header *header)
This routine returns a pointer to the first watchdog timer on the watchdog chain HEADER.
Definition: watchdogimpl.h:467
This is used to manage a chain.
Definition: chain.h:83
void _Watchdog_Tick(void)
Triggers a watchdog tick.
Definition: watchdogtick.c:25
#define _ISR_lock_Initialize(_lock, _name)
Initializes an ISR lock.
Definition: isrlock.h:167
void _Watchdog_Insert(Watchdog_Header *header, Watchdog_Control *the_watchdog)
Inserts the_watchdog into the header watchdog chain for a time of units.
Definition: watchdoginsert.c:115
Constants and Structures Associated with Watchdog Timers.
void _Watchdog_Handler_initialization(void)
Initialize the watchdog handler.
Definition: watchdog.c:26
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initialize this chain as empty.
Definition: chainimpl.h:613
void _Watchdog_Tickle(Watchdog_Header *header)
This routine is invoked at appropriate intervals to update the header watchdog chain.
Definition: watchdogremove.c:116
Watchdog_Service_routine_entry routine
This field is the function to invoke.
Definition: watchdog.h:114
Watchdog_Interval initial
This field is the initially requested interval.
Definition: watchdog.h:106
RTEMS_INLINE_ROUTINE bool _Chain_Is_empty(const Chain_Control *the_chain)
Is the chain empty.
Definition: chainimpl.h:499
Watchdog_States
Set of the states which a watchdog timer may be at any given time.
Definition: watchdog.h:81
Chain_Node Node
This field is a Chain Node structure and allows this to be placed on chains for set management...
Definition: watchdog.h:102
Chain_Node * next
This points to the node after this one on this chain.
Definition: chain.h:67
Watchdog_States state
This field is the state of the watchdog.
Definition: watchdog.h:104
Chain_Node * current
The current watchdog of the chain on the way to insert the new watchdog.
Definition: watchdogimpl.h:68
RTEMS_INLINE_ROUTINE void _Watchdog_Insert_seconds(Watchdog_Control *the_watchdog, Watchdog_Interval units)
This routine inserts THE_WATCHDOG into the seconds watchdog chain for a time of UNITS seconds...
Definition: watchdogimpl.h:390
void _Watchdog_Adjust_forward_locked(Watchdog_Header *header, Watchdog_Interval units, ISR_lock_Context *lock_context)
Adjusts the watchdogs in forward direction in a locked context.
Definition: watchdogadjust.c:45
This is the state when the watchdog is off all chains.
Definition: watchdog.h:83
#define _ISR_lock_Flash(_lock, _context)
Flashes an ISR lock.
Definition: isrlock.h:309
void _Watchdog_Adjust_backward(Watchdog_Header *header, Watchdog_Interval units)
Adjusts the header watchdog chain in the backward direction for units ticks.
Definition: watchdogadjust.c:33
void _Watchdog_Insert_locked(Watchdog_Header *header, Watchdog_Control *the_watchdog, ISR_lock_Context *lock_context)
Inserts the watchdog in a locked context.
Definition: watchdoginsert.c:52
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Last(Chain_Control *the_chain)
Return pointer to chain&#39;s last node.
Definition: chainimpl.h:400
#define _ISR_lock_Release_and_ISR_enable(_lock, _context)
Releases an ISR lock.
Definition: isrlock.h:230
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:83
RTEMS_INLINE_ROUTINE Watchdog_Control * _Watchdog_Last(Watchdog_Header *header)
This routine returns a pointer to the last watchdog timer on the watchdog chain HEADER.
Definition: watchdogimpl.h:481
Chain Handler API.
This is the state when the watchdog is on a chain, and allowed to fire.
Definition: watchdog.h:89
RTEMS_INLINE_ROUTINE void _Watchdog_Tickle_seconds(void)
This routine is invoked at each clock tick to update the seconds watchdog chain.
Definition: watchdogimpl.h:357
RTEMS_INLINE_ROUTINE void _Watchdog_Initialize(Watchdog_Control *the_watchdog, Watchdog_Service_routine_entry routine, Objects_Id id, void *user_data)
This routine initializes the specified watchdog.
Definition: watchdogimpl.h:299
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_First(Chain_Control *the_chain)
Return pointer to chain&#39;s first node.
Definition: chainimpl.h:366
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdog.h:47
Watchdog header.
Definition: watchdogimpl.h:74
void _Watchdog_Adjust_forward(Watchdog_Header *header, Watchdog_Interval units)
Adjusts the header watchdog chain in the forward direction for units ticks.
Definition: watchdogadjust.c:70
RTEMS_INLINE_ROUTINE Watchdog_Control * _Watchdog_Previous(Watchdog_Control *the_watchdog)
This routine returns a pointer to the watchdog timer preceding THE_WATCHDOG on the watchdog chain...
Definition: watchdogimpl.h:453
Chain_Control Watchdogs
ISR lock to protect this watchdog chain.
Definition: watchdogimpl.h:83
Iterator item to synchronize concurrent insert, remove and tickle operations.
Definition: watchdogimpl.h:53
Watchdog_Service_routine(* Watchdog_Service_routine_entry)(Objects_Id, void *)
Pointer to a watchdog service routine.
Definition: watchdog.h:61
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize(Watchdog_Control *the_watchdog)
Pre-initializes a watchdog.
Definition: watchdogimpl.h:281
Watchdog_States _Watchdog_Remove(Watchdog_Header *header, Watchdog_Control *the_watchdog)
Removes the_watchdog from the watchdog chain.
Definition: watchdogremove.c:80
void * user_data
This field is an untyped pointer to user data that is passed to the watchdog handler routine...
Definition: watchdog.h:120
RTEMS_INLINE_ROUTINE bool _Watchdog_Is_active(Watchdog_Control *the_watchdog)
This routine returns true if the watchdog timer is in the ACTIVE state, and false otherwise...
Definition: watchdogimpl.h:317
uint32_t Objects_Id
The following type defines the control block used to manage object IDs.
Definition: object.h:122
Objects_Id id
This field is the Id to pass as an argument to the routine.
Definition: watchdog.h:116
#define SCORE_EXTERN
The following ensures that all data is declared in the space of the initialization routine for either...
Definition: basedefs.h:81
ISR Locks.
Chain_Control Iterators
Currently active iterators.
Definition: watchdogimpl.h:91
SCORE_EXTERN Watchdog_Header _Watchdog_Seconds_header
Watchdog chain which is managed at second boundaries.
Definition: watchdogimpl.h:106
SCORE_EXTERN Watchdog_Header _Watchdog_Ticks_header
Watchdog chain which is managed at ticks.
Definition: watchdogimpl.h:99
RTEMS_INLINE_ROUTINE void _Watchdog_Insert_ticks(Watchdog_Control *the_watchdog, Watchdog_Interval units)
This routine inserts THE_WATCHDOG into the ticks watchdog chain for a time of UNITS ticks...
Definition: watchdogimpl.h:371
Watchdog_Interval delta_interval
The current delta interval of the new watchdog to insert.
Definition: watchdogimpl.h:62