Skip to content

Commit 2b6f2d1

Browse files
authored
Merge pull request #619 from jphickey/fix-618-rtems-osal-id
Fix #618, Use osal_id_t in RTEMS implementation
2 parents 19dec8c + 39e004f commit 2b6f2d1

7 files changed

+26
-20
lines changed

src/os/rtems/src/os-impl-binsem.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int32 OS_BinSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 opti
104104
** It is convenient to use the OSAL ID in here, as we know it is already unique
105105
** and trying to use the real name would be less than useful (only 4 chars)
106106
*/
107-
r_name = OS_global_bin_sem_table[sem_id].active_id;
107+
r_name = OS_ObjectIdToInteger(OS_global_bin_sem_table[sem_id].active_id);
108108

109109
/* Check to make sure the sem value is going to be either 0 or 1 */
110110
if (sem_initial_value > 1)

src/os/rtems/src/os-impl-console.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ int32 OS_ConsoleCreate_Impl(uint32 local_id)
156156
** It is convenient to use the OSAL ID in here, as we know it is already unique
157157
** and trying to use the real name would be less than useful (only 4 chars)
158158
*/
159-
r_name = OS_global_console_table[local_id].active_id;
159+
r_name = OS_ObjectIdToInteger(OS_global_console_table[local_id].active_id);
160160
status = rtems_semaphore_create( r_name, 0,
161161
RTEMS_PRIORITY,
162162
0,

src/os/rtems/src/os-impl-countsem.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int32 OS_CountSemCreate_Impl (uint32 sem_id, uint32 sem_initial_value, uint32 op
106106
** It is convenient to use the OSAL ID in here, as we know it is already unique
107107
** and trying to use the real name would be less than useful (only 4 chars)
108108
*/
109-
r_name = OS_global_count_sem_table[sem_id].active_id;
109+
r_name = OS_ObjectIdToInteger(OS_global_count_sem_table[sem_id].active_id);
110110
status = rtems_semaphore_create( r_name, sem_initial_value,
111111
OSAL_COUNT_SEM_ATTRIBS,
112112
0,

src/os/rtems/src/os-impl-mutex.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int32 OS_MutSemCreate_Impl (uint32 sem_id, uint32 options)
9999
/*
100100
** Try to create the mutex
101101
*/
102-
r_name = OS_global_mutex_table[sem_id].active_id;
102+
r_name = OS_ObjectIdToInteger(OS_global_mutex_table[sem_id].active_id);
103103
status = rtems_semaphore_create ( r_name, 1,
104104
OSAL_MUTEX_ATTRIBS ,
105105
0,

src/os/rtems/src/os-impl-queues.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int32 OS_QueueCreate_Impl (uint32 queue_id, uint32 flags)
9494
** It is convenient to use the OSAL queue ID in here, as we know it is already unique
9595
** and trying to use the real queue name would be less than useful (only 4 chars)
9696
*/
97-
r_name = OS_global_queue_table[queue_id].active_id;
97+
r_name = OS_ObjectIdToInteger(OS_global_queue_table[queue_id].active_id);
9898

9999
/*
100100
** Create the message queue.

src/os/rtems/src/os-impl-tasks.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ OS_impl_task_internal_record_t OS_impl_task_table [OS_MAX_TASKS];
6363
---------------------------------------------------------------------------------------*/
6464
static rtems_task OS_RtemsEntry(rtems_task_argument arg)
6565
{
66-
OS_TaskEntryPoint((uint32)arg);
66+
OS_TaskEntryPoint(OS_ObjectIdFromInteger(arg));
6767
} /* end OS_RtemsEntry */
6868

6969

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

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

144144
if (status != RTEMS_SUCCESSFUL )
145145
{
@@ -314,9 +314,9 @@ int32 OS_TaskRegister_Impl (osal_id_t global_task_id)
314314
* See prototype for argument/return detail
315315
*
316316
*-----------------------------------------------------------------*/
317-
uint32 OS_TaskGetId_Impl (void)
317+
osal_id_t OS_TaskGetId_Impl (void)
318318
{
319-
uint32 global_task_id;
319+
osal_id_t global_task_id;
320320
rtems_id task_self;
321321
rtems_name self_name;
322322
rtems_status_code status;
@@ -327,11 +327,11 @@ uint32 OS_TaskGetId_Impl (void)
327327
status = rtems_object_get_classic_name(task_self, &self_name);
328328
if (status == RTEMS_SUCCESSFUL)
329329
{
330-
global_task_id = self_name;
330+
global_task_id = OS_ObjectIdFromInteger(self_name);
331331
}
332332
else
333333
{
334-
global_task_id = 0;
334+
global_task_id = OS_OBJECT_ID_UNDEFINED;
335335
}
336336

337337
return global_task_id;

src/os/rtems/src/os-impl-timebase.c

+14-8
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ static rtems_timer_service_routine OS_TimeBase_ISR(rtems_id rtems_timer_id, void
126126
OS_impl_timebase_internal_record_t *local;
127127

128128
user_data.opaque_arg = arg;
129-
OS_ConvertToArrayIndex(user_data.value, &local_id);
129+
OS_ConvertToArrayIndex(user_data.id, &local_id);
130130
local = &OS_impl_timebase_table[local_id];
131-
if (OS_global_timebase_table[local_id].active_id == user_data.value)
131+
if (OS_ObjectIdEqual(OS_global_timebase_table[local_id].active_id, user_data.id))
132132
{
133133
/*
134134
* Reset the timer, but only if an interval was selected
@@ -299,12 +299,18 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
299299
rtems_status_code rtems_sc;
300300
OS_impl_timebase_internal_record_t *local;
301301
OS_common_record_t *global;
302+
rtems_name r_name;
302303

303304

304305
return_code = OS_SUCCESS;
305306
local = &OS_impl_timebase_table[timer_id];
306307
global = &OS_global_timebase_table[timer_id];
307308

309+
/*
310+
* The RTEMS classic name for dependent resources
311+
*/
312+
r_name = OS_ObjectIdToInteger(global->active_id);
313+
308314
/*
309315
* Set up the necessary OS constructs
310316
*
@@ -323,7 +329,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
323329
* The tick_sem is a simple semaphore posted by the ISR and taken by the
324330
* timebase helper task (created later).
325331
*/
326-
rtems_sc = rtems_semaphore_create (global->active_id, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0,
332+
rtems_sc = rtems_semaphore_create (r_name, 0, RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_PRIORITY, 0,
327333
&local->tick_sem);
328334
if ( rtems_sc != RTEMS_SUCCESSFUL )
329335
{
@@ -334,7 +340,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
334340
/*
335341
* The handler_mutex is deals with access to the callback list for this timebase
336342
*/
337-
rtems_sc = rtems_semaphore_create (global->active_id, 1, OSAL_TIMEBASE_MUTEX_ATTRIBS, 0,
343+
rtems_sc = rtems_semaphore_create (r_name, 1, OSAL_TIMEBASE_MUTEX_ATTRIBS, 0,
338344
&local->handler_mutex);
339345

340346
if ( rtems_sc != RTEMS_SUCCESSFUL )
@@ -344,7 +350,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
344350
return_code = OS_TIMER_ERR_INTERNAL;
345351
}
346352

347-
rtems_sc = rtems_timer_create(global->active_id, &local->rtems_timer_id);
353+
rtems_sc = rtems_timer_create(r_name, &local->rtems_timer_id);
348354
if ( rtems_sc != RTEMS_SUCCESSFUL )
349355
{
350356
OS_DEBUG("Error: Timer object could not be created: %d\n",(int)rtems_sc);
@@ -372,7 +378,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
372378
* the priority is set to RTEMS_MINIMUM_PRIORITY.
373379
*/
374380
rtems_sc = rtems_task_create(
375-
global->active_id,
381+
r_name,
376382
RTEMS_MINIMUM_PRIORITY + 1,
377383
0,
378384
RTEMS_PREEMPT | RTEMS_NO_ASR | RTEMS_NO_TIMESLICE | RTEMS_INTERRUPT_LEVEL(0),
@@ -391,7 +397,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id)
391397
/* will place the task in 'ready for scheduling' state */
392398
rtems_sc = rtems_task_start (local->handler_task, /*rtems task id*/
393399
(rtems_task_entry) OS_TimeBase_CallbackThread, /* task entry point */
394-
(rtems_task_argument) global->active_id ); /* passed argument */
400+
(rtems_task_argument) OS_ObjectIdToInteger(global->active_id) ); /* passed argument */
395401

396402
if (rtems_sc != RTEMS_SUCCESSFUL )
397403
{
@@ -471,7 +477,7 @@ int32 OS_TimeBaseSet_Impl(uint32 timer_id, int32 start_time, int32 interval_time
471477
OS_UsecsToTicks(start_time, &start_ticks);
472478

473479
user_data.opaque_arg = NULL;
474-
user_data.value = OS_global_timebase_table[timer_id].active_id;
480+
user_data.id = OS_global_timebase_table[timer_id].active_id;
475481

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

0 commit comments

Comments
 (0)