source: rtems/cpukit/rtems/src/timerserverfireafter.c @ a2e3f33

4.115
Last change on this file since a2e3f33 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:50:54

score: Create object implementation header

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

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