source: rtems/cpukit/rtems/src/timerfireafter.c @ 4b48ece0

4.115
Last change on this file since 4b48ece0 was 4b48ece0, checked in by Sebastian Huber <sebastian.huber@…>, on 07/22/13 at 08:21:03

score: Create watchdog implementation header

Move implementation specific parts of watchdog.h and watchdog.inl into
new header file watchdogimpl.h. The watchdog.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Timer Fire After
5 *  @ingroup ClassicTimer
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/object.h>
25#include <rtems/score/thread.h>
26#include <rtems/rtems/timer.h>
27#include <rtems/score/tod.h>
28#include <rtems/score/watchdogimpl.h>
29
30rtems_status_code rtems_timer_fire_after(
31  rtems_id                           id,
32  rtems_interval                     ticks,
33  rtems_timer_service_routine_entry  routine,
34  void                              *user_data
35)
36{
37  Timer_Control      *the_timer;
38  Objects_Locations   location;
39  ISR_Level           level;
40
41  if ( ticks == 0 )
42    return RTEMS_INVALID_NUMBER;
43
44  if ( !routine )
45    return RTEMS_INVALID_ADDRESS;
46
47  the_timer = _Timer_Get( id, &location );
48  switch ( location ) {
49
50    case OBJECTS_LOCAL:
51      (void) _Watchdog_Remove( &the_timer->Ticker );
52
53      _ISR_Disable( level );
54
55        /*
56         *  Check to see if the watchdog has just been inserted by a
57         *  higher priority interrupt.  If so, abandon this insert.
58         */
59
60        if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) {
61          _ISR_Enable( level );
62          _Objects_Put( &the_timer->Object );
63          return RTEMS_SUCCESSFUL;
64        }
65
66        /*
67         *  OK.  Now we now the timer was not rescheduled by an interrupt
68         *  so we can atomically initialize it as in use.
69         */
70
71        the_timer->the_class = TIMER_INTERVAL;
72        _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
73      _ISR_Enable( level );
74
75
76      _Watchdog_Insert_ticks( &the_timer->Ticker, ticks );
77      _Objects_Put( &the_timer->Object );
78      return RTEMS_SUCCESSFUL;
79
80#if defined(RTEMS_MULTIPROCESSING)
81    case OBJECTS_REMOTE:            /* should never return this */
82#endif
83    case OBJECTS_ERROR:
84      break;
85  }
86
87  return RTEMS_INVALID_ID;
88}
Note: See TracBrowser for help on using the repository browser.