RTEMS: cpukit/include/rtems/posix/timerimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
timerimpl.h
Go to the documentation of this file.
1
10/*
11 * COPYRIGHT (c) 1989-2013.
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#ifndef _RTEMS_POSIX_TIMERIMPL_H
20#define _RTEMS_POSIX_TIMERIMPL_H
21
22#include <rtems/posix/timer.h>
23#include <rtems/score/objectimpl.h>
24#include <rtems/score/watchdogimpl.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
31#define POSIX_TIMER_STATE_FREE 0x01
32
34#define POSIX_TIMER_STATE_CREATE_NEW 0x02
35
37#define POSIX_TIMER_STATE_CREATE_RUN 0x03
38
40#define POSIX_TIMER_STATE_CREATE_STOP 0x04
41
43#define POSIX_TIMER_RELATIVE 0
44
45/*
46 * POSIX defines TIMER_ABSTIME but no constant for relative. So
47 * we have one internally but we need to be careful it has a different
48 * value.
49 */
50#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME)
51#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME"
52#endif
53
60 RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
61{
62 return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information );
63}
64
71 RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free (
72 POSIX_Timer_Control *the_timer
73)
74{
75 _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
76}
77
78void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog );
79
89 RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
90 timer_t id,
91 ISR_lock_Context *lock_context
92)
93{
94 return (POSIX_Timer_Control *) _Objects_Get(
95 (Objects_Id) id,
96 lock_context,
97 &_POSIX_Timer_Information
98 );
99}
100
101 RTEMS_INLINE_ROUTINE Per_CPU_Control *_POSIX_Timer_Acquire_critical(
102 POSIX_Timer_Control *ptimer,
103 ISR_lock_Context *lock_context
104)
105{
106 Per_CPU_Control *cpu;
107
108 cpu = _Watchdog_Get_CPU( &ptimer->Timer );
109 _Watchdog_Per_CPU_acquire_critical( cpu, lock_context );
110
111 return cpu;
112}
113
114 RTEMS_INLINE_ROUTINE void _POSIX_Timer_Release(
115 Per_CPU_Control *cpu,
116 ISR_lock_Context *lock_context
117)
118{
119 _Watchdog_Per_CPU_release_critical( cpu, lock_context );
120 _ISR_lock_ISR_enable( lock_context );
121}
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif
128/* end of include file */
timer.h
POSIX Timers Internal Support.
_POSIX_Timer_Information
Objects_Information _POSIX_Timer_Information
The POSIX Timer objects information.
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_ISR_lock_ISR_enable
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:419
_Objects_Free
RTEMS_INLINE_ROUTINE void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectimpl.h:930
_Objects_Allocate
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:42
Objects_Id
uint32_t Objects_Id
Definition: object.h:80
_Objects_Get
Objects_Control * _Objects_Get(Objects_Id id, ISR_lock_Context *lock_context, const Objects_Information *information)
Maps the specified object identifier to the associated local object control block.
Definition: objectgetlocal.c:28
_Watchdog_Per_CPU_acquire_critical
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_acquire_critical(Per_CPU_Control *cpu, ISR_lock_Context *lock_context)
Acquires the per cpu watchdog lock in a critical section.
Definition: watchdogimpl.h:561
_Watchdog_Per_CPU_release_critical
RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical(Per_CPU_Control *cpu, ISR_lock_Context *lock_context)
Releases the per cpu watchdog lock in a critical section.
Definition: watchdogimpl.h:575
_Watchdog_Get_CPU
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Watchdog_Get_CPU(const Watchdog_Control *the_watchdog)
Gets the watchdog's cpu.
Definition: watchdogimpl.h:177
objectimpl.h
Inlined Routines in the Object Handler.
_POSIX_Timer_Get
RTEMS_INLINE_ROUTINE POSIX_Timer_Control * _POSIX_Timer_Get(timer_t id, ISR_lock_Context *lock_context)
POSIX Timer Get.
Definition: timerimpl.h:89
_POSIX_Timer_Allocate
RTEMS_INLINE_ROUTINE POSIX_Timer_Control * _POSIX_Timer_Allocate(void)
POSIX Timer Allocate.
Definition: timerimpl.h:60
_POSIX_Timer_Free
RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free(POSIX_Timer_Control *the_timer)
POSIX Timer Free.
Definition: timerimpl.h:71
ISR_lock_Context
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
POSIX_Timer_Control
Definition: timer.h:41
Per_CPU_Control
Per CPU Core Structure.
Definition: percpu.h:347
Watchdog_Control
The control block used to manage each watchdog timer.
Definition: watchdog.h:90
watchdogimpl.h
Inlined Routines in the Watchdog Handler.