source: rtems/cpukit/rtems/src/timerserverfireafter.c @ 90d8567

5
Last change on this file since 90d8567 was 2903090, checked in by Sebastian Huber <sebastian.huber@…>, on 04/15/15 at 09:26:46

score: Add header to _Watchdog_Remove()

Add watchdog header parameter to _Watchdog_Remove() to be in line with
the other operations. Add _Watchdog_Remove_ticks() and
_Watchdog_Remove_seconds() for convenience.

Update #2307.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Timer Server 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.org/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/thread.h>
25#include <rtems/rtems/timerimpl.h>
26#include <rtems/score/watchdogimpl.h>
27
28rtems_status_code rtems_timer_server_fire_after(
29  rtems_id                           id,
30  rtems_interval                     ticks,
31  rtems_timer_service_routine_entry  routine,
32  void                              *user_data
33)
34{
35  Timer_Control        *the_timer;
36  Objects_Locations     location;
37  ISR_Level             level;
38  Timer_server_Control *timer_server = _Timer_server;
39
40  if ( !timer_server )
41    return RTEMS_INCORRECT_STATE;
42
43  if ( !routine )
44    return RTEMS_INVALID_ADDRESS;
45
46  if ( ticks == 0 )
47    return RTEMS_INVALID_NUMBER;
48
49  the_timer = _Timer_Get( id, &location );
50  switch ( location ) {
51
52    case OBJECTS_LOCAL:
53      _Timer_Cancel( the_timer );
54
55      _ISR_Disable( level );
56
57        /*
58         *  Check to see if the watchdog has just been inserted by a
59         *  higher priority interrupt.  If so, abandon this insert.
60         */
61
62        if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) {
63          _ISR_Enable( level );
64          _Objects_Put( &the_timer->Object );
65          return RTEMS_SUCCESSFUL;
66        }
67
68        /*
69         *  OK.  Now we now the timer was not rescheduled by an interrupt
70         *  so we can atomically initialize it as in use.
71         */
72
73        the_timer->the_class = TIMER_INTERVAL_ON_TASK;
74        _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
75        the_timer->Ticker.initial = ticks;
76      _ISR_Enable( level );
77
78      (*timer_server->schedule_operation)( timer_server, the_timer );
79
80      _Objects_Put( &the_timer->Object );
81      return RTEMS_SUCCESSFUL;
82
83#if defined(RTEMS_MULTIPROCESSING)
84    case OBJECTS_REMOTE:            /* should never return this */
85#endif
86    case OBJECTS_ERROR:
87      break;
88  }
89
90  return RTEMS_INVALID_ID;
91}
Note: See TracBrowser for help on using the repository browser.