1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Helper Routine for POSIX TIMERS |
---|
5 | * @ingroup POSIXAPI |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Helper routine for POSIX timers |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 1989-2007. |
---|
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 | #if HAVE_CONFIG_H |
---|
20 | #include "config.h" |
---|
21 | #endif |
---|
22 | |
---|
23 | #include <time.h> |
---|
24 | |
---|
25 | #include <rtems/system.h> |
---|
26 | #include <rtems/seterr.h> |
---|
27 | #include <rtems/score/isr.h> |
---|
28 | #include <rtems/score/watchdogimpl.h> |
---|
29 | #include <rtems/posix/timerimpl.h> |
---|
30 | #include <rtems/posix/ptimer.h> |
---|
31 | |
---|
32 | bool _POSIX_Timer_Insert_helper( |
---|
33 | Watchdog_Control *timer, |
---|
34 | Watchdog_Interval ticks, |
---|
35 | Objects_Id id, |
---|
36 | Watchdog_Service_routine_entry TSR, |
---|
37 | void *arg |
---|
38 | ) |
---|
39 | { |
---|
40 | ISR_Level level; |
---|
41 | |
---|
42 | _Watchdog_Remove_ticks( timer ); |
---|
43 | _ISR_Disable( level ); |
---|
44 | |
---|
45 | /* |
---|
46 | * Check to see if the watchdog has just been inserted by a |
---|
47 | * higher priority interrupt. If so, abandon this insert. |
---|
48 | */ |
---|
49 | if ( timer->state != WATCHDOG_INACTIVE ) { |
---|
50 | _ISR_Enable( level ); |
---|
51 | return false; |
---|
52 | } |
---|
53 | |
---|
54 | /* |
---|
55 | * OK. Now we now the timer was not rescheduled by an interrupt |
---|
56 | * so we can atomically initialize it as in use. |
---|
57 | */ |
---|
58 | _Watchdog_Initialize( timer, TSR, id, arg ); |
---|
59 | _Watchdog_Insert_ticks( timer, ticks ); |
---|
60 | _ISR_Enable( level ); |
---|
61 | return true; |
---|
62 | } |
---|