Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #618, Use osal_id_t in RTEMS implementation #619

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/os/rtems/src/os-impl-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti
** It is convenient to use the OSAL ID in here, as we know it is already unique
** and trying to use the real name would be less than useful (only 4 chars)
*/
r_name = OS_global_bin_sem_table[sem_id].active_id;
r_name = OS_ObjectIdToInteger(OS_global_bin_sem_table[sem_id].active_id);

/* Check to make sure the sem value is going to be either 0 or 1 */
if (sem_initial_value > 1)
Expand Down
2 changes: 1 addition & 1 deletion src/os/rtems/src/os-impl-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id)
** It is convenient to use the OSAL ID in here, as we know it is already unique
** and trying to use the real name would be less than useful (only 4 chars)
*/
r_name = OS_global_console_table[local_id].active_id;
r_name = OS_ObjectIdToInteger(OS_global_console_table[local_id].active_id);
status = rtems_semaphore_create( r_name, 0,
RTEMS_PRIORITY,
0,
Expand Down
2 changes: 1 addition & 1 deletion src/os/rtems/src/os-impl-countsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op
** It is convenient to use the OSAL ID in here, as we know it is already unique
** and trying to use the real name would be less than useful (only 4 chars)
*/
r_name = OS_global_count_sem_table[sem_id].active_id;
r_name = OS_ObjectIdToInteger(OS_global_count_sem_table[sem_id].active_id);
status = rtems_semaphore_create( r_name, sem_initial_value,
OSAL_COUNT_SEM_ATTRIBS,
0,
Expand Down
2 changes: 1 addition & 1 deletion src/os/rtems/src/os-impl-mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options)
/*
** Try to create the mutex
*/
r_name = OS_global_mutex_table[sem_id].active_id;
r_name = OS_ObjectIdToInteger(OS_global_mutex_table[sem_id].active_id);
status = rtems_semaphore_create ( r_name, 1,
OSAL_MUTEX_ATTRIBS ,
0,
Expand Down
2 changes: 1 addition & 1 deletion src/os/rtems/src/os-impl-queues.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags)
** It is convenient to use the OSAL queue ID in here, as we know it is already unique
** and trying to use the real queue name would be less than useful (only 4 chars)
*/
r_name = OS_global_queue_table[queue_id].active_id;
r_name = OS_ObjectIdToInteger(OS_global_queue_table[queue_id].active_id);

/*
** Create the message queue.
Expand Down
14 changes: 7 additions & 7 deletions src/os/rtems/src/os-impl-tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS];
---------------------------------------------------------------------------------------*/
static rtems_task OS_RtemsEntry(rtems_task_argument arg)
{
OS_TaskEntryPoint((uint32)arg);
OS_TaskEntryPoint(OS_ObjectIdFromInteger(arg));
} /* end OS_RtemsEntry */


Expand Down Expand Up @@ -106,7 +106,7 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags)
** It is convenient to use the OSAL task ID in here, as we know it is already unique
** and trying to use the real task name would be less than useful (only 4 chars)
*/
r_name = OS_global_task_table[task_id].active_id;
r_name = OS_ObjectIdToInteger(OS_global_task_table[task_id].active_id);
r_mode = RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0);

/*
Expand Down Expand Up @@ -138,7 +138,7 @@ int32 OS_TaskCreate_Impl (uint32 task_id, uint32 flags)
/* will place the task in 'ready for scheduling' state */
status = rtems_task_start (OS_impl_task_table[task_id].id, /*rtems task id*/
(rtems_task_entry) OS_RtemsEntry, /* task entry point */
(rtems_task_argument) OS_global_task_table[task_id].active_id ); /* passed argument */
(rtems_task_argument) OS_ObjectIdToInteger(OS_global_task_table[task_id].active_id) ); /* passed argument */

if (status != RTEMS_SUCCESSFUL )
{
Expand Down Expand Up @@ -300,9 +300,9 @@ int32 OS_TaskRegister_Impl (osal_id_t global_task_id)
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
uint32 OS_TaskGetId_Impl (void)
osal_id_t OS_TaskGetId_Impl (void)
{
uint32 global_task_id;
osal_id_t global_task_id;
rtems_id task_self;
rtems_name self_name;
rtems_status_code status;
Expand All @@ -313,11 +313,11 @@ uint32 OS_TaskGetId_Impl (void)
status = rtems_object_get_classic_name(task_self, &self_name);
if (status == RTEMS_SUCCESSFUL)
{
global_task_id = self_name;
global_task_id = OS_ObjectIdFromInteger(self_name);
}
else
{
global_task_id = 0;
global_task_id = OS_OBJECT_ID_UNDEFINED;
}

return global_task_id;
Expand Down
22 changes: 14 additions & 8 deletions src/os/rtems/src/os-impl-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ static rtems_timer_service_routine OS_TimeBase_ISR(rtems_id rtems_timer_id, void
OS_impl_timebase_internal_record_t *local;

user_data.opaque_arg = arg;
OS_ConvertToArrayIndex(user_data.value, &local_id);
OS_ConvertToArrayIndex(user_data.id, &local_id);
local = &OS_impl_timebase_table[local_id];
if (OS_global_timebase_table[local_id].active_id == user_data.value)
if (OS_ObjectIdEqual(OS_global_timebase_table[local_id].active_id, user_data.id))
{
/*
* Reset the timer, but only if an interval was selected
Expand Down Expand Up @@ -299,12 +299,18 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
rtems_status_code rtems_sc;
OS_impl_timebase_internal_record_t *local;
OS_common_record_t *global;
rtems_name r_name;


return_code = OS_SUCCESS;
local = &OS_impl_timebase_table[timer_id];
global = &OS_global_timebase_table[timer_id];

/*
* The RTEMS classic name for dependent resources
*/
r_name = OS_ObjectIdToInteger(global->active_id);

/*
* Set up the necessary OS constructs
*
Expand All @@ -323,7 +329,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
* The tick_sem is a simple semaphore posted by the ISR and taken by the
* timebase helper task (created later).
*/
rtems_sc = rtems_semaphore_create (global->active_id, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0,
rtems_sc = rtems_semaphore_create (r_name, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0,
&local->tick_sem);
if ( rtems_sc != RTEMS_SUCCESSFUL )
{
Expand All @@ -334,7 +340,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
/*
* The handler_mutex is deals with access to the callback list for this timebase
*/
rtems_sc = rtems_semaphore_create (global->active_id, 1, OSAL_TIMEBASE_MUTEX_ATTRIBS, 0,
rtems_sc = rtems_semaphore_create (r_name, 1, OSAL_TIMEBASE_MUTEX_ATTRIBS, 0,
&local->handler_mutex);

if ( rtems_sc != RTEMS_SUCCESSFUL )
Expand All @@ -344,7 +350,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
return_code = OS_TIMER_ERR_INTERNAL;
}

rtems_sc = rtems_timer_create(global->active_id, &local->rtems_timer_id);
rtems_sc = rtems_timer_create(r_name, &local->rtems_timer_id);
if ( rtems_sc != RTEMS_SUCCESSFUL )
{
OS_DEBUG("Error: Timer object could not be created: %d\n",(int)rtems_sc);
Expand Down Expand Up @@ -372,7 +378,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
* the priority is set to RTEMS_MINIMUM_PRIORITY.
*/
rtems_sc = rtems_task_create(
global->active_id,
r_name,
RTEMS_MINIMUM_PRIORITY + 1,
0,
RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0),
Expand All @@ -391,7 +397,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
/* will place the task in 'ready for scheduling' state */
rtems_sc = rtems_task_start (local->handler_task, /*rtems task id*/
(rtems_task_entry) OS_TimeBase_CallbackThread, /* task entry point */
(rtems_task_argument) global->active_id ); /* passed argument */
(rtems_task_argument) OS_ObjectIdToInteger(global->active_id) ); /* passed argument */

if (rtems_sc != RTEMS_SUCCESSFUL )
{
Expand Down Expand Up @@ -471,7 +477,7 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time
OS_UsecsToTicks(start_time, &start_ticks);

user_data.opaque_arg = NULL;
user_data.value = OS_global_timebase_table[timer_id].active_id;
user_data.id = OS_global_timebase_table[timer_id].active_id;

status = rtems_timer_fire_after(local->rtems_timer_id, start_ticks,
OS_TimeBase_ISR, user_data.opaque_arg );
Expand Down