![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @brief Inlined Routines from the POSIX Timer Manager 0007 * 0008 * This file contains the static inline implementation of the inlined routines 0009 * from the POSIX Timer Manager. 0010 */ 0011 0012 /* 0013 * COPYRIGHT (c) 1989-2013. 0014 * On-Line Applications Research Corporation (OAR). 0015 * 0016 * Redistribution and use in source and binary forms, with or without 0017 * modification, are permitted provided that the following conditions 0018 * are met: 0019 * 1. Redistributions of source code must retain the above copyright 0020 * notice, this list of conditions and the following disclaimer. 0021 * 2. Redistributions in binary form must reproduce the above copyright 0022 * notice, this list of conditions and the following disclaimer in the 0023 * documentation and/or other materials provided with the distribution. 0024 * 0025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0028 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0029 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0030 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0031 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0032 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0033 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0034 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0035 * POSSIBILITY OF SUCH DAMAGE. 0036 */ 0037 0038 #ifndef _RTEMS_POSIX_TIMERIMPL_H 0039 #define _RTEMS_POSIX_TIMERIMPL_H 0040 0041 #include <rtems/posix/timer.h> 0042 #include <rtems/score/objectimpl.h> 0043 #include <rtems/score/watchdogimpl.h> 0044 0045 #ifdef __cplusplus 0046 extern "C" { 0047 #endif 0048 0049 /** Timer is free */ 0050 #define POSIX_TIMER_STATE_FREE 0x01 0051 0052 /** Created timer but not running */ 0053 #define POSIX_TIMER_STATE_CREATE_NEW 0x02 0054 0055 /** Created timer and running */ 0056 #define POSIX_TIMER_STATE_CREATE_RUN 0x03 0057 0058 /** Created, ran and stopped timer */ 0059 #define POSIX_TIMER_STATE_CREATE_STOP 0x04 0060 0061 /** Indicates that the fire time is relative to the current one */ 0062 #define POSIX_TIMER_RELATIVE 0 0063 0064 /* 0065 * POSIX defines TIMER_ABSTIME but no constant for relative. So 0066 * we have one internally but we need to be careful it has a different 0067 * value. 0068 */ 0069 #if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME) 0070 #error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME" 0071 #endif 0072 0073 /** 0074 * @brief POSIX Timer Allocate 0075 * 0076 * This function allocates a timer control block from 0077 * the inactive chain of free timer control blocks. 0078 */ 0079 static inline POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) 0080 { 0081 return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information ); 0082 } 0083 0084 /** 0085 * @brief POSIX Timer Free 0086 * 0087 * This routine frees a timer control block to the 0088 * inactive chain of free timer control blocks. 0089 */ 0090 static inline void _POSIX_Timer_Free ( 0091 POSIX_Timer_Control *the_timer 0092 ) 0093 { 0094 _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object ); 0095 } 0096 0097 void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog ); 0098 0099 /** 0100 * @brief POSIX Timer Get 0101 * 0102 * This function maps timer IDs to timer control blocks. 0103 * If ID corresponds to a local timer, then it returns 0104 * the timer control pointer which maps to ID and location 0105 * is set to OBJECTS_LOCAL. Otherwise, location is set 0106 * to OBJECTS_ERROR and the returned value is undefined. 0107 */ 0108 static inline POSIX_Timer_Control *_POSIX_Timer_Get ( 0109 timer_t id, 0110 ISR_lock_Context *lock_context 0111 ) 0112 { 0113 return (POSIX_Timer_Control *) _Objects_Get( 0114 (Objects_Id) id, 0115 lock_context, 0116 &_POSIX_Timer_Information 0117 ); 0118 } 0119 0120 static inline Per_CPU_Control *_POSIX_Timer_Acquire_critical( 0121 POSIX_Timer_Control *ptimer, 0122 ISR_lock_Context *lock_context 0123 ) 0124 { 0125 Per_CPU_Control *cpu; 0126 0127 cpu = _Watchdog_Get_CPU( &ptimer->Timer ); 0128 _Watchdog_Per_CPU_acquire_critical( cpu, lock_context ); 0129 0130 return cpu; 0131 } 0132 0133 static inline void _POSIX_Timer_Release( 0134 Per_CPU_Control *cpu, 0135 ISR_lock_Context *lock_context 0136 ) 0137 { 0138 _Watchdog_Per_CPU_release_critical( cpu, lock_context ); 0139 _ISR_lock_ISR_enable( lock_context ); 0140 } 0141 0142 #ifdef __cplusplus 0143 } 0144 #endif 0145 0146 #endif 0147 /* end of include file */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |