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

Integration candidate 2020-10-13 #621

Merged
merged 5 commits into from
Oct 13, 2020
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History

### Development Build: 5.1.0-rc1+dev55

- Deprecate `OS_open` and `OS_creat` to and replaced them with by `OS_OpenCreate`, which implements both functions via flags, and follows the correct OSAL API patterns.
- Change use of uint32 for ID to the correct typedef. Also use ObjectIdFromInteger/ObjectIdToInteger where it is intended to convert these values to integers e.g. for the "name" fields in RTEMS.
- See <https://github.com/nasa/osal/pull/621>

### Development Build: 5.1.0-rc1+dev49

- Adds an event callback mechanism to certain state changes in OSAL. This allows the CFE PSP to be notified at these points, and therefore it can add platform-specific functionality.
Expand Down
10 changes: 10 additions & 0 deletions src/os/inc/osapi-os-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ typedef enum
* @{
*/

#ifndef OSAL_OMIT_DEPRECATED

/*-------------------------------------------------------------------------------------*/
/**
* @brief Creates a file specified by path
Expand All @@ -199,6 +201,9 @@ typedef enum
* @retval #OS_FS_ERR_NAME_TOO_LONG if the name of the file is too long
* @retval #OS_ERROR if permissions are unknown or OS call fails
* @retval #OS_ERR_NO_FREE_IDS if there are no free file descriptors left
*
* @deprecated Replaced by OS_OpenCreate() with flags set to
* OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE.
*/
int32 OS_creat (const char *path, int32 access);

Expand All @@ -225,9 +230,14 @@ int32 OS_creat (const char *path, int32 access);
* @retval #OS_FS_ERR_NAME_TOO_LONG if the name of the file is too long
* @retval #OS_ERROR if permissions are unknown or OS call fails
* @retval #OS_ERR_NO_FREE_IDS if there are no free file descriptors left
*
* @deprecated Replaced by OS_OpenCreate() with flags set to
* OS_FILE_FLAG_NONE.
*/
int32 OS_open (const char *path, int32 access, uint32 mode);

#endif

/*-------------------------------------------------------------------------------------*/
/**
* @brief Open or create a file
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 49
#define OS_BUILD_NUMBER 55
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
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 @@ -104,7 +104,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 @@ -106,7 +106,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 @@ -94,7 +94,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 @@ -63,7 +63,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 @@ -107,7 +107,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 @@ -139,7 +139,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 @@ -314,9 +314,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 @@ -327,11 +327,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
23 changes: 22 additions & 1 deletion src/os/shared/src/osapi-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
OS_common_record_t *record;
char local_path[OS_MAX_LOCAL_PATH_LEN];

if (filedes == NULL)
{
return OS_INVALID_POINTER;
}

/*
** Check for a valid access mode
*/
if (access != OS_WRITE_ONLY &&
access != OS_READ_ONLY &&
access != OS_READ_WRITE)
{
return OS_ERROR;
}

/*
* Translate the path
*/
Expand Down Expand Up @@ -127,6 +142,12 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
} /* end OS_OpenCreate */


/*
* The OS_open and OS_creat functions are deprecated, replaced by
* the generic OS_OpenCreate above
*/
#ifndef OSAL_OMIT_DEPRECATED

/*----------------------------------------------------------------
*
* Function: OS_creat
Expand Down Expand Up @@ -205,7 +226,7 @@ int32 OS_open (const char *path, int32 access, uint32 mode)
return return_code;
} /* end OS_open */


#endif

/*----------------------------------------------------------------
*
Expand Down
Loading