File indexing completed on 2025-05-11 08:24:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifdef HAVE_CONFIG_H
0037 #include "config.h"
0038 #endif
0039
0040 #include "tx-support.h"
0041
0042 #include <rtems/test.h>
0043 #include <rtems/rtems/timerimpl.h>
0044 #include <rtems/score/todimpl.h>
0045
0046 rtems_id GetTimerServerTaskId( void )
0047 {
0048 if ( _Timer_server == NULL ) {
0049 return RTEMS_INVALID_ID;
0050 }
0051 return _Timer_server->server_id;
0052 }
0053
0054 bool DeleteTimerServer( void )
0055 {
0056 Timer_server_Control *server;
0057
0058 server = _Timer_server;
0059
0060 if ( server == NULL ) {
0061 return false;
0062 }
0063
0064 DeleteTask( server->server_id );
0065 _ISR_lock_Destroy( &server->Lock );
0066 T_true( _Chain_Is_empty( &server->Pending ) );
0067 _Timer_server = NULL;
0068
0069 return true;
0070 }
0071
0072 Timer_Classes GetTimerClass( rtems_id id )
0073 {
0074
0075 Timer_Classes result = TIMER_DORMANT;
0076 Timer_Control *the_timer;
0077 ISR_lock_Context lock_context;
0078 Per_CPU_Control *cpu;
0079
0080 the_timer = _Timer_Get( id, &lock_context );
0081 if ( the_timer != NULL ) {
0082 cpu = _Timer_Acquire_critical( the_timer, &lock_context );
0083 result = the_timer->the_class;
0084 _Timer_Release( cpu, &lock_context );
0085 }
0086
0087 return result;
0088 }
0089
0090 void GetTimerSchedulingData(
0091 rtems_id id,
0092 Timer_Scheduling_Data *data
0093 )
0094 {
0095
0096 Timer_Control *the_timer;
0097 ISR_lock_Context lock_context;
0098 Per_CPU_Control *cpu;
0099
0100 if ( data == NULL ) {
0101 return;
0102 }
0103
0104 the_timer = _Timer_Get( id, &lock_context );
0105 if ( the_timer != NULL ) {
0106 cpu = _Timer_Acquire_critical( the_timer, &lock_context );
0107 data->routine = the_timer->routine;
0108 data->user_data = the_timer->user_data;
0109 data->interval = the_timer->initial;
0110 _Timer_Release( cpu, &lock_context );
0111 }
0112 }
0113
0114 Timer_States GetTimerState( rtems_id id )
0115 {
0116
0117 Timer_States result = TIMER_INVALID;
0118 Timer_Control *the_timer;
0119 ISR_lock_Context lock_context;
0120 Per_CPU_Control *cpu;
0121 Timer_Classes the_class;
0122 Timer_server_Control *timer_server = _Timer_server;
0123 ISR_lock_Context lock_context_server;
0124
0125 the_timer = _Timer_Get( id, &lock_context );
0126 if ( the_timer != NULL ) {
0127 result = TIMER_INACTIVE;
0128 cpu = _Timer_Acquire_critical( the_timer, &lock_context );
0129 the_class = the_timer->the_class;
0130
0131 if ( _Watchdog_Is_scheduled( &the_timer->Ticker ) ) {
0132 result = TIMER_SCHEDULED;
0133 } else if ( _Timer_Is_on_task_class( the_class ) ) {
0134 _Assert( timer_server != NULL );
0135 _Timer_server_Acquire_critical( timer_server, &lock_context_server );
0136 if ( _Watchdog_Get_state( &the_timer->Ticker ) == WATCHDOG_PENDING ) {
0137 result = TIMER_PENDING;
0138 }
0139 _Timer_server_Release_critical( timer_server, &lock_context_server );
0140 }
0141 _Timer_Release( cpu, &lock_context );
0142 }
0143
0144 return result;
0145 }
0146
0147 void UnsetClock( void )
0148 {
0149 _TOD.is_set = false;
0150 }