diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-07 16:01:57 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-14 09:06:27 +0100 |
commit | 77e6eba7146ba2e2074b719eec01cc7c40bbe98b (patch) | |
tree | ec87c51ccd9c53cb65067a2a06a75d29b32387f3 /cpukit/rtems/src | |
parent | pc386: Fix linker usage issues with -r and function sections (diff) | |
download | rtems-77e6eba7146ba2e2074b719eec01cc7c40bbe98b.tar.bz2 |
score: Add and use _Objects_Get_local()
This simplifies the handling with local-only objects.
Update #2555.
Diffstat (limited to 'cpukit/rtems/src')
-rw-r--r-- | cpukit/rtems/src/timercancel.c | 26 | ||||
-rw-r--r-- | cpukit/rtems/src/timercreate.c | 72 | ||||
-rw-r--r-- | cpukit/rtems/src/timerdelete.c | 36 | ||||
-rw-r--r-- | cpukit/rtems/src/timergetinfo.c | 39 | ||||
-rw-r--r-- | cpukit/rtems/src/timerreset.c | 74 |
5 files changed, 92 insertions, 155 deletions
diff --git a/cpukit/rtems/src/timercancel.c b/cpukit/rtems/src/timercancel.c index 5d4343e776..a69f38e72a 100644 --- a/cpukit/rtems/src/timercancel.c +++ b/cpukit/rtems/src/timercancel.c @@ -20,25 +20,17 @@ rtems_status_code rtems_timer_cancel( rtems_id id ) { - Timer_Control *the_timer; - Objects_Locations location; - ISR_lock_Context lock_context; - Per_CPU_Control *cpu; + Timer_Control *the_timer; + ISR_lock_Context lock_context; - the_timer = _Timer_Get( id, &location, &lock_context ); - switch ( location ) { + the_timer = _Timer_Get( id, &lock_context ); + if ( the_timer != NULL ) { + Per_CPU_Control *cpu; - case OBJECTS_LOCAL: - cpu = _Timer_Acquire_critical( the_timer, &lock_context ); - _Timer_Cancel( cpu, the_timer ); - _Timer_Release( cpu, &lock_context ); - return RTEMS_SUCCESSFUL; - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* should never return this */ -#endif - case OBJECTS_ERROR: - break; + cpu = _Timer_Acquire_critical( the_timer, &lock_context ); + _Timer_Cancel( cpu, the_timer ); + _Timer_Release( cpu, &lock_context ); + return RTEMS_SUCCESSFUL; } return RTEMS_INVALID_ID; diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c index 80c1356278..fc6d43e6dc 100644 --- a/cpukit/rtems/src/timercreate.c +++ b/cpukit/rtems/src/timercreate.c @@ -54,46 +54,38 @@ rtems_status_code _Timer_Fire( Watchdog_Service_routine_entry adaptor ) { - Timer_Control *the_timer; - Objects_Locations location; - ISR_lock_Context lock_context; - Per_CPU_Control *cpu; - - the_timer = _Timer_Get( id, &location, &lock_context ); - switch ( location ) { - - case OBJECTS_LOCAL: - cpu = _Timer_Acquire_critical( the_timer, &lock_context ); - _Timer_Cancel( cpu, the_timer ); - _Watchdog_Initialize( &the_timer->Ticker, adaptor ); - the_timer->the_class = the_class; - the_timer->routine = routine; - the_timer->user_data = user_data; - the_timer->initial = interval; - the_timer->start_time = _Timer_Get_CPU_ticks( cpu ); - - if ( _Timer_Is_interval_class( the_class ) ) { - _Watchdog_Insert( - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], - &the_timer->Ticker, - cpu->Watchdog.ticks + interval - ); - } else { - _Watchdog_Insert( - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ], - &the_timer->Ticker, - _Watchdog_Ticks_from_seconds( interval ) - ); - } - - _Timer_Release( cpu, &lock_context ); - return RTEMS_SUCCESSFUL; - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* should never return this */ -#endif - case OBJECTS_ERROR: - break; + Timer_Control *the_timer; + ISR_lock_Context lock_context; + + the_timer = _Timer_Get( id, &lock_context ); + if ( the_timer != NULL ) { + Per_CPU_Control *cpu; + + cpu = _Timer_Acquire_critical( the_timer, &lock_context ); + _Timer_Cancel( cpu, the_timer ); + _Watchdog_Initialize( &the_timer->Ticker, adaptor ); + the_timer->the_class = the_class; + the_timer->routine = routine; + the_timer->user_data = user_data; + the_timer->initial = interval; + the_timer->start_time = _Timer_Get_CPU_ticks( cpu ); + + if ( _Timer_Is_interval_class( the_class ) ) { + _Watchdog_Insert( + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], + &the_timer->Ticker, + cpu->Watchdog.ticks + interval + ); + } else { + _Watchdog_Insert( + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ], + &the_timer->Ticker, + _Watchdog_Ticks_from_seconds( interval ) + ); + } + + _Timer_Release( cpu, &lock_context ); + return RTEMS_SUCCESSFUL; } return RTEMS_INVALID_ID; diff --git a/cpukit/rtems/src/timerdelete.c b/cpukit/rtems/src/timerdelete.c index 9c413976c4..8b23c31093 100644 --- a/cpukit/rtems/src/timerdelete.c +++ b/cpukit/rtems/src/timerdelete.c @@ -24,32 +24,24 @@ rtems_status_code rtems_timer_delete( rtems_id id ) { - Timer_Control *the_timer; - Objects_Locations location; - ISR_lock_Context lock_context; - Per_CPU_Control *cpu; + Timer_Control *the_timer; + ISR_lock_Context lock_context; _Objects_Allocator_lock(); - the_timer = _Timer_Get( id, &location, &lock_context ); - switch ( location ) { - - case OBJECTS_LOCAL: - _Objects_Close( &_Timer_Information, &the_timer->Object ); - cpu = _Timer_Acquire_critical( the_timer, &lock_context ); - _Timer_Cancel( cpu, the_timer ); - _Timer_Release( cpu, &lock_context ); - _Timer_Free( the_timer ); - _Objects_Allocator_unlock(); - return RTEMS_SUCCESSFUL; - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* should never return this */ -#endif - case OBJECTS_ERROR: - break; + + the_timer = _Timer_Get( id, &lock_context ); + if ( the_timer != NULL ) { + Per_CPU_Control *cpu; + + _Objects_Close( &_Timer_Information, &the_timer->Object ); + cpu = _Timer_Acquire_critical( the_timer, &lock_context ); + _Timer_Cancel( cpu, the_timer ); + _Timer_Release( cpu, &lock_context ); + _Timer_Free( the_timer ); + _Objects_Allocator_unlock(); + return RTEMS_SUCCESSFUL; } _Objects_Allocator_unlock(); - return RTEMS_INVALID_ID; } diff --git a/cpukit/rtems/src/timergetinfo.c b/cpukit/rtems/src/timergetinfo.c index a11861c63e..804b0cf3b0 100644 --- a/cpukit/rtems/src/timergetinfo.c +++ b/cpukit/rtems/src/timergetinfo.c @@ -18,43 +18,30 @@ #include "config.h" #endif -#include <rtems/system.h> -#include <rtems/rtems/status.h> -#include <rtems/rtems/support.h> -#include <rtems/score/thread.h> #include <rtems/rtems/timerimpl.h> -#include <rtems/score/watchdog.h> rtems_status_code rtems_timer_get_information( rtems_id id, rtems_timer_information *the_info ) { - Timer_Control *the_timer; - Objects_Locations location; - ISR_lock_Context lock_context; - Per_CPU_Control *cpu; + Timer_Control *the_timer; + ISR_lock_Context lock_context; if ( !the_info ) return RTEMS_INVALID_ADDRESS; - the_timer = _Timer_Get( id, &location, &lock_context ); - switch ( location ) { - - case OBJECTS_LOCAL: - cpu = _Timer_Acquire_critical( the_timer, &lock_context ); - the_info->the_class = the_timer->the_class; - the_info->initial = the_timer->initial; - the_info->start_time = the_timer->start_time; - the_info->stop_time = the_timer->stop_time; - _Timer_Release( cpu, &lock_context ); - return RTEMS_SUCCESSFUL; - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* should never return this */ -#endif - case OBJECTS_ERROR: - break; + the_timer = _Timer_Get( id, &lock_context ); + if ( the_timer != NULL ) { + Per_CPU_Control *cpu; + + cpu = _Timer_Acquire_critical( the_timer, &lock_context ); + the_info->the_class = the_timer->the_class; + the_info->initial = the_timer->initial; + the_info->start_time = the_timer->start_time; + the_info->stop_time = the_timer->stop_time; + _Timer_Release( cpu, &lock_context ); + return RTEMS_SUCCESSFUL; } return RTEMS_INVALID_ID; diff --git a/cpukit/rtems/src/timerreset.c b/cpukit/rtems/src/timerreset.c index 72c912baa3..a4090152b3 100644 --- a/cpukit/rtems/src/timerreset.c +++ b/cpukit/rtems/src/timerreset.c @@ -18,62 +18,36 @@ #include "config.h" #endif -#include <rtems/system.h> -#include <rtems/rtems/status.h> -#include <rtems/rtems/support.h> -#include <rtems/score/thread.h> #include <rtems/rtems/timerimpl.h> -#include <rtems/score/watchdogimpl.h> - -/* - * rtems_timer_reset - * - * This directive allows a thread to reset a timer. - * - * Input parameters: - * id - timer id - * - * Output parameters: - * RTEMS_SUCCESSFUL - if successful - * error code - if unsuccessful - */ rtems_status_code rtems_timer_reset( rtems_id id ) { - Timer_Control *the_timer; - Objects_Locations location; - ISR_lock_Context lock_context; - Per_CPU_Control *cpu; - rtems_status_code status; - - the_timer = _Timer_Get( id, &location, &lock_context ); - switch ( location ) { - - case OBJECTS_LOCAL: - cpu = _Timer_Acquire_critical( the_timer, &lock_context ); - - if ( _Timer_Is_interval_class( the_timer->the_class ) ) { - _Timer_Cancel( cpu, the_timer ); - _Watchdog_Insert( - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], - &the_timer->Ticker, - cpu->Watchdog.ticks + the_timer->initial - ); - status = RTEMS_SUCCESSFUL; - } else { - status = RTEMS_NOT_DEFINED; - } - - _Timer_Release( cpu, &lock_context ); - return status; - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* should never return this */ -#endif - case OBJECTS_ERROR: - break; + Timer_Control *the_timer; + ISR_lock_Context lock_context; + + the_timer = _Timer_Get( id, &lock_context ); + if ( the_timer != NULL ) { + Per_CPU_Control *cpu; + rtems_status_code status; + + cpu = _Timer_Acquire_critical( the_timer, &lock_context ); + + if ( _Timer_Is_interval_class( the_timer->the_class ) ) { + _Timer_Cancel( cpu, the_timer ); + _Watchdog_Insert( + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], + &the_timer->Ticker, + cpu->Watchdog.ticks + the_timer->initial + ); + status = RTEMS_SUCCESSFUL; + } else { + status = RTEMS_NOT_DEFINED; + } + + _Timer_Release( cpu, &lock_context ); + return status; } return RTEMS_INVALID_ID; |