mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-30 15:49:23 +08:00
score: Add and use _Objects_Get_local()
This simplifies the handling with local-only objects. Update #2555.
This commit is contained in:
@@ -94,14 +94,12 @@ void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog );
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
|
||||
timer_t id,
|
||||
Objects_Locations *location,
|
||||
ISR_lock_Context *lock_context
|
||||
)
|
||||
{
|
||||
return (POSIX_Timer_Control *) _Objects_Get_isr_disable(
|
||||
return (POSIX_Timer_Control *) _Objects_Get_local(
|
||||
&_POSIX_Timer_Information,
|
||||
(Objects_Id) id,
|
||||
location,
|
||||
lock_context
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,33 +44,25 @@ int timer_delete(
|
||||
* because rtems_timer_delete stops the timer before deleting it.
|
||||
*/
|
||||
POSIX_Timer_Control *ptimer;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
_Objects_Allocator_lock();
|
||||
ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
|
||||
switch ( location ) {
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
_Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
ptimer->state = POSIX_TIMER_STATE_FREE;
|
||||
_Watchdog_Remove(
|
||||
&cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
|
||||
&ptimer->Timer
|
||||
);
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
_POSIX_Timer_Free( ptimer );
|
||||
_Objects_Allocator_unlock();
|
||||
ptimer = _POSIX_Timer_Get( timerid, &lock_context );
|
||||
if ( ptimer != NULL ) {
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
return 0;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
#endif
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
_Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
ptimer->state = POSIX_TIMER_STATE_FREE;
|
||||
_Watchdog_Remove(
|
||||
&cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
|
||||
&ptimer->Timer
|
||||
);
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
_POSIX_Timer_Free( ptimer );
|
||||
_Objects_Allocator_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
_Objects_Allocator_unlock();
|
||||
|
||||
@@ -30,27 +30,19 @@ int timer_getoverrun(
|
||||
timer_t timerid
|
||||
)
|
||||
{
|
||||
int overrun;
|
||||
POSIX_Timer_Control *ptimer;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
|
||||
switch ( location ) {
|
||||
ptimer = _POSIX_Timer_Get( timerid, &lock_context );
|
||||
if ( ptimer != NULL ) {
|
||||
Per_CPU_Control *cpu;
|
||||
int overrun;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
overrun = ptimer->overrun;
|
||||
ptimer->overrun = 0;
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
return overrun;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
#endif
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
overrun = ptimer->overrun;
|
||||
ptimer->overrun = 0;
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
return overrun;
|
||||
}
|
||||
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
@@ -41,40 +41,31 @@ int timer_gettime(
|
||||
)
|
||||
{
|
||||
POSIX_Timer_Control *ptimer;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Per_CPU_Control *cpu;
|
||||
uint64_t now;
|
||||
uint32_t remaining;
|
||||
|
||||
if ( !value )
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
|
||||
switch ( location ) {
|
||||
ptimer = _POSIX_Timer_Get( timerid, &lock_context );
|
||||
if ( ptimer != NULL ) {
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
now = cpu->Watchdog.ticks;
|
||||
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
now = cpu->Watchdog.ticks;
|
||||
if ( now < ptimer->Timer.expire ) {
|
||||
remaining = (uint32_t) ( ptimer->Timer.expire - now );
|
||||
} else {
|
||||
remaining = 0;
|
||||
}
|
||||
|
||||
if ( now < ptimer->Timer.expire ) {
|
||||
remaining = (uint32_t) ( ptimer->Timer.expire - now );
|
||||
} else {
|
||||
remaining = 0;
|
||||
}
|
||||
_Timespec_From_ticks( remaining, &value->it_value );
|
||||
value->it_interval = ptimer->timer_data.it_interval;
|
||||
|
||||
_Timespec_From_ticks( remaining, &value->it_value );
|
||||
value->it_interval = ptimer->timer_data.it_interval;
|
||||
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
return 0;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
#endif
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
@@ -107,9 +107,7 @@ int timer_settime(
|
||||
)
|
||||
{
|
||||
POSIX_Timer_Control *ptimer;
|
||||
Objects_Locations location;
|
||||
ISR_lock_Context lock_context;
|
||||
Per_CPU_Control *cpu;
|
||||
uint32_t initial_period;
|
||||
struct itimerspec normalize;
|
||||
|
||||
@@ -148,53 +146,47 @@ int timer_settime(
|
||||
* or start it again
|
||||
*/
|
||||
|
||||
ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
|
||||
switch ( location ) {
|
||||
ptimer = _POSIX_Timer_Get( timerid, &lock_context );
|
||||
if ( ptimer != NULL ) {
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
|
||||
|
||||
/* Stop the timer */
|
||||
_Watchdog_Remove(
|
||||
&cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
|
||||
&ptimer->Timer
|
||||
);
|
||||
/* Stop the timer */
|
||||
_Watchdog_Remove(
|
||||
&cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
|
||||
&ptimer->Timer
|
||||
);
|
||||
|
||||
/* First, it verifies if the timer must be stopped */
|
||||
if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
|
||||
/* The old data of the timer are returned */
|
||||
if ( ovalue )
|
||||
*ovalue = ptimer->timer_data;
|
||||
/* The new data are set */
|
||||
ptimer->timer_data = normalize;
|
||||
/* Indicates that the timer is created and stopped */
|
||||
ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
|
||||
/* Returns with success */
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Convert from seconds and nanoseconds to ticks */
|
||||
ptimer->ticks = _Timespec_To_ticks( &value->it_interval );
|
||||
initial_period = _Timespec_To_ticks( &normalize.it_value );
|
||||
|
||||
_POSIX_Timer_Insert( ptimer, cpu, initial_period );
|
||||
|
||||
/*
|
||||
* The timer has been started and is running. So we return the
|
||||
* old ones in "ovalue"
|
||||
*/
|
||||
/* First, it verifies if the timer must be stopped */
|
||||
if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
|
||||
/* The old data of the timer are returned */
|
||||
if ( ovalue )
|
||||
*ovalue = ptimer->timer_data;
|
||||
/* The new data are set */
|
||||
ptimer->timer_data = normalize;
|
||||
/* Indicates that the timer is created and stopped */
|
||||
ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
|
||||
/* Returns with success */
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE:
|
||||
#endif
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
/* Convert from seconds and nanoseconds to ticks */
|
||||
ptimer->ticks = _Timespec_To_ticks( &value->it_interval );
|
||||
initial_period = _Timespec_To_ticks( &normalize.it_value );
|
||||
|
||||
_POSIX_Timer_Insert( ptimer, cpu, initial_period );
|
||||
|
||||
/*
|
||||
* The timer has been started and is running. So we return the
|
||||
* old ones in "ovalue"
|
||||
*/
|
||||
if ( ovalue )
|
||||
*ovalue = ptimer->timer_data;
|
||||
ptimer->timer_data = normalize;
|
||||
_POSIX_Timer_Release( cpu, &lock_context );
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
|
||||
@@ -84,14 +84,12 @@ RTEMS_INLINE_ROUTINE void _Timer_Free (
|
||||
|
||||
RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get(
|
||||
Objects_Id id,
|
||||
Objects_Locations *location,
|
||||
ISR_lock_Context *lock_context
|
||||
)
|
||||
{
|
||||
return (Timer_Control *) _Objects_Get_isr_disable(
|
||||
return (Timer_Control *) _Objects_Get_local(
|
||||
&_Timer_Information,
|
||||
id,
|
||||
location,
|
||||
lock_context
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
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 );
|
||||
_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 );
|
||||
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 )
|
||||
);
|
||||
}
|
||||
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_Release( cpu, &lock_context );
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
|
||||
@@ -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;
|
||||
the_timer = _Timer_Get( id, &lock_context );
|
||||
if ( the_timer != NULL ) {
|
||||
Per_CPU_Control *cpu;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
case OBJECTS_REMOTE: /* should never return this */
|
||||
#endif
|
||||
case OBJECTS_ERROR:
|
||||
break;
|
||||
_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;
|
||||
}
|
||||
|
||||
@@ -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 ) {
|
||||
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 );
|
||||
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;
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
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;
|
||||
rtems_status_code status;
|
||||
|
||||
case OBJECTS_LOCAL:
|
||||
cpu = _Timer_Acquire_critical( the_timer, &lock_context );
|
||||
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;
|
||||
}
|
||||
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_Release( cpu, &lock_context );
|
||||
return status;
|
||||
}
|
||||
|
||||
return RTEMS_INVALID_ID;
|
||||
|
||||
@@ -214,6 +214,7 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
|
||||
src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
|
||||
src/objectnamespaceremove.c \
|
||||
src/objectactivecount.c
|
||||
libscore_a_SOURCES += src/objectgetlocal.c
|
||||
|
||||
## SCHEDULER_C_FILES
|
||||
libscore_a_SOURCES += src/log2table.c
|
||||
|
||||
@@ -558,6 +558,29 @@ Objects_Control *_Objects_Get_isr_disable(
|
||||
ISR_lock_Context *lock_context
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Maps the specified object identifier to the associated local object
|
||||
* control block.
|
||||
*
|
||||
* In this function interrupts are disabled during the object lookup. In case
|
||||
* an associated object exists, then interrupts remain disabled, otherwise the
|
||||
* previous interrupt state is restored.
|
||||
*
|
||||
* @param information The object class information block.
|
||||
* @param[in] id The object identifier.
|
||||
* @param[in] lock_context The interrupt lock context.
|
||||
*
|
||||
* @retval NULL No associated object exists.
|
||||
* @retval other The pointer to the associated object control block.
|
||||
* Interrupts are now disabled and must be restored using the specified lock
|
||||
* context via _ISR_lock_ISR_enable() or _ISR_lock_Release_and_ISR_enable().
|
||||
*/
|
||||
Objects_Control *_Objects_Get_local(
|
||||
const Objects_Information *information,
|
||||
Objects_Id id,
|
||||
ISR_lock_Context *lock_context
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Maps object ids to object control blocks.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Object Get Local
|
||||
* @ingroup ScoreObject
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/score/objectimpl.h>
|
||||
|
||||
Objects_Control *_Objects_Get_local(
|
||||
const Objects_Information *information,
|
||||
Objects_Id id,
|
||||
ISR_lock_Context *lock_context
|
||||
)
|
||||
{
|
||||
uint32_t index;
|
||||
|
||||
index = id - information->minimum_id + 1;
|
||||
|
||||
if ( information->maximum >= index ) {
|
||||
Objects_Control *the_object;
|
||||
|
||||
_ISR_lock_ISR_disable( lock_context );
|
||||
|
||||
the_object = information->local_table[ index ];
|
||||
if ( the_object != NULL ) {
|
||||
/* ISR disabled on behalf of caller */
|
||||
return the_object;
|
||||
}
|
||||
|
||||
_ISR_lock_ISR_enable( lock_context );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user