source: rtems/cpukit/score/src/watchdogtick.c @ 3a4e044

5
Last change on this file since 3a4e044 was 3a4e044, checked in by Sebastian Huber <sebastian.huber@…>, on 12/22/17 at 09:35:47

score: Rename _Watchdog_Realtime_from_*()

Rename _Watchdog_Realtime_from_*() to _Watchdog_Ticks_from_*().

Update #3264.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * Copyright (c) 2015, 2016 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/score/watchdogimpl.h>
20#include <rtems/score/schedulerimpl.h>
21#include <rtems/score/threaddispatch.h>
22#include <rtems/score/timecounter.h>
23
24void _Watchdog_Do_tickle(
25  Watchdog_Header  *header,
26  Watchdog_Control *first,
27  uint64_t          now,
28#ifdef RTEMS_SMP
29  ISR_lock_Control *lock,
30#endif
31  ISR_lock_Context *lock_context
32)
33{
34  do {
35    if ( first->expire <= now ) {
36      Watchdog_Service_routine_entry routine;
37
38      _Watchdog_Next_first( header, first );
39      _RBTree_Extract( &header->Watchdogs, &first->Node.RBTree );
40      _Watchdog_Set_state( first, WATCHDOG_INACTIVE );
41      routine = first->routine;
42
43      _ISR_lock_Release_and_ISR_enable( lock, lock_context );
44      ( *routine )( first );
45      _ISR_lock_ISR_disable_and_acquire( lock, lock_context );
46    } else {
47      break;
48    }
49
50    first = _Watchdog_Header_first( header );
51  } while ( first != NULL );
52}
53
54void _Watchdog_Tick( Per_CPU_Control *cpu )
55{
56  ISR_lock_Context  lock_context;
57  Watchdog_Header  *header;
58  Watchdog_Control *first;
59  uint64_t          ticks;
60  struct timespec   now;
61
62  if ( _Per_CPU_Is_boot_processor( cpu ) ) {
63    ++_Watchdog_Ticks_since_boot;
64  }
65
66  _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context );
67
68  ticks = cpu->Watchdog.ticks;
69  _Assert( ticks < UINT64_MAX );
70  ++ticks;
71  cpu->Watchdog.ticks = ticks;
72
73  header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ];
74  first = _Watchdog_Header_first( header );
75
76  if ( first != NULL ) {
77    _Watchdog_Tickle(
78      header,
79      first,
80      ticks,
81      &cpu->Watchdog.Lock,
82      &lock_context
83    );
84  }
85
86  header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ];
87  first = _Watchdog_Header_first( header );
88
89  if ( first != NULL ) {
90    _Timecounter_Getnanotime( &now );
91    _Watchdog_Tickle(
92      header,
93      first,
94      _Watchdog_Ticks_from_timespec( &now ),
95      &cpu->Watchdog.Lock,
96      &lock_context
97    );
98  }
99
100  _ISR_lock_Release_and_ISR_enable( &cpu->Watchdog.Lock, &lock_context );
101
102  _Scheduler_Tick( cpu );
103}
Note: See TracBrowser for help on using the repository browser.