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

osal Integration Candidate: 2020-11-24 #662

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

## Version History

### Development Build: 5.1.0-rc1+dev91

- Rename `UT_SetForceFail` to `UT_SetDefaultReturnValue` since some functions that retain more than 1 value are not necessarily failing
- Add a 5th timer to TimerTest functional to test the one shot (zero-length time interval) case.
- Ensure all APIs use the proper type. Sizes are now size_t; these will now be 64 bits on a 64 bit platform.
- Fix build issue on VxWorks 6.9 by using the 3 argument form of `open()`. Passing `0` as the mode solves the build issue. This parameter is ignored when not creating a file.
- The address calculations now use `unsigned long` instead of `long` to ensure that all rounding and base address adjustments behave the same way in the event that the addresses lie in the upper half of memory (i.e. start with a 1 bit) which would put it in the negative range of a long type.
- See <https://github.com/nasa/osal/pull/662>


### Development Build: 5.1.0-rc1+dev75

- Ensure that the handle is not NULL before invoking dlclose(). In particular the handle will be NULL for static modules. Shutdown after CTRL+C occurs normally (no segfault).
Expand Down
2 changes: 1 addition & 1 deletion src/bsp/generic-linux/src/bsp_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void OS_BSP_ExecTput(const char *cap, const char *param)
OS_BSP_ConsoleOutput_Impl
See full description in header
------------------------------------------------------------------*/
void OS_BSP_ConsoleOutput_Impl(const char *Str, uint32 DataLen)
void OS_BSP_ConsoleOutput_Impl(const char *Str, size_t DataLen)
{
ssize_t WriteLen;

Expand Down
2 changes: 1 addition & 1 deletion src/bsp/generic-linux/src/bsp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void OS_BSP_Initialize(void)
{
if (fgets(buffer, sizeof(buffer), fp) != NULL)
{
OS_BSP_Global.MaxQueueDepth = strtoul(buffer, NULL, 10);
OS_BSP_Global.MaxQueueDepth = OSAL_BLOCKCOUNT_C(strtoul(buffer, NULL, 10));
BSP_DEBUG("Maximum user msg queue depth = %u\n", (unsigned int)OS_BSP_Global.MaxQueueDepth);
}
fclose(fp);
Expand Down
2 changes: 1 addition & 1 deletion src/bsp/generic-vxworks/src/bsp_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
OS_BSP_ConsoleOutput_Impl
See full description in header
------------------------------------------------------------------*/
void OS_BSP_ConsoleOutput_Impl(const char *Str, uint32 DataLen)
void OS_BSP_ConsoleOutput_Impl(const char *Str, size_t DataLen)
{
while (DataLen > 0)
{
Expand Down
10 changes: 5 additions & 5 deletions src/bsp/shared/inc/bsp-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@
*/
typedef struct
{
uint32 ArgC; /* number of boot/startup parameters in ArgV */
char **ArgV; /* strings for boot/startup parameters */
int32 AppStatus; /* value which can be returned to the OS (0=nominal) */
uint32 MaxQueueDepth; /* Queue depth limit supported by BSP (0=no limit) */
uint32 ArgC; /* number of boot/startup parameters in ArgV */
char ** ArgV; /* strings for boot/startup parameters */
int32 AppStatus; /* value which can be returned to the OS (0=nominal) */
osal_blockcount_t MaxQueueDepth; /* Queue depth limit supported by BSP (0=no limit) */
} OS_BSP_GlobalData_t;

/*
Expand All @@ -118,7 +118,7 @@ extern OS_BSP_GlobalData_t OS_BSP_Global;

Note: This should write the string as-is without buffering.
------------------------------------------------------------------*/
void OS_BSP_ConsoleOutput_Impl(const char *Str, uint32 DataLen);
void OS_BSP_ConsoleOutput_Impl(const char *Str, size_t DataLen);

/*----------------------------------------------------------------
Function: OS_BSP_ConsoleSetMode_Impl
Expand Down
36 changes: 36 additions & 0 deletions src/os/inc/common_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ extern "C"
*/
typedef uint32_t osal_id_t;

/**
* A type used to represent a number of blocks or buffers
*
* This is used with file system and queue implementations.
*/
typedef size_t osal_blockcount_t;

/**
* A type used to represent an index into a table structure
*
* This is used when referring directly to a table index as
* opposed to an object ID. It is primarily intended for
* internal use, but is also output from public APIs such as
* OS_ObjectIdToArrayIndex().
*/
typedef uint32 osal_index_t;

/**
* A type used to represent the runtime type or category of an OSAL object
*/
typedef uint32 osal_objtype_t;

#ifndef NULL /* pointer to nothing */
#define NULL ((void *)0)
#endif
Expand Down Expand Up @@ -150,4 +172,18 @@ extern "C"
}
#endif

/*
* Type macros for literals
*
* These macros enforce that a literal or other value is
* interpreted as the intended type. Although implicit
* conversions between these types are often possible, using
* this makes it explicit in the code where a type conversion
* is expected.
*/
#define OSAL_SIZE_C(X) ((size_t)(X))
#define OSAL_BLOCKCOUNT_C(X) ((osal_blockcount_t)(X))
#define OSAL_INDEX_C(X) ((osal_index_t)(X))
#define OSAL_OBJTYPE_C(X) ((osal_objtype_t)(X))

#endif /* _common_types_ */
57 changes: 39 additions & 18 deletions src/os/inc/osapi-os-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,34 @@
*/
#define OS_ERROR_NAME_LENGTH 35

/**
* @brief Type to be used for OSAL task priorities.
*
* OSAL priorities are in reverse order, and range
* from 0 (highest; will preempt all other tasks) to
* 255 (lowest; will not preempt any other task).
*/
typedef uint8_t osal_priority_t;

#define OSAL_PRIORITY_C(X) ((osal_priority_t) {X})

/**
* @brief Type to be used for OSAL stack pointer.
*/
typedef void *osal_stackptr_t;

#define OSAL_STACKPTR_C(X) ((osal_stackptr_t) {X})
#define OSAL_TASK_STACK_ALLOCATE OSAL_STACKPTR_C(NULL)

/* Object property structures */

/** @brief OSAL task properties */
typedef struct
{
char name[OS_MAX_API_NAME];
osal_id_t creator;
uint32 stack_size;
uint32 priority;
char name[OS_MAX_API_NAME];
osal_id_t creator;
size_t stack_size;
osal_priority_t priority;
} OS_task_prop_t;

/** @brief OSAL queue properties */
Expand Down Expand Up @@ -140,9 +159,9 @@ typedef struct
*/
typedef struct
{
uint32 free_bytes;
uint32 free_blocks;
uint32 largest_free_block;
size_t free_bytes;
osal_blockcount_t free_blocks;
size_t largest_free_block;
} OS_heap_prop_t;

/**
Expand Down Expand Up @@ -467,7 +486,7 @@ static inline bool OS_ObjectIdDefined(osal_id_t object_id)
* #OS_INVALID_POINTER if the passed-in buffer is invalid
* #OS_ERR_NAME_TOO_LONG if the name will not fit in the buffer provided
*/
int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size);
int32 OS_GetResourceName(osal_id_t object_id, char *buffer, size_t buffer_size);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -480,7 +499,7 @@ int32 OS_GetResourceName(osal_id_t object_id, char *buffer, uint32 buffer_size);
* @return The object type portion of the object_id, see @ref OSObjectTypes for
* expected values
*/
uint32 OS_IdentifyObject(osal_id_t object_id);
osal_objtype_t OS_IdentifyObject(osal_id_t object_id);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -506,7 +525,7 @@ uint32 OS_IdentifyObject(osal_id_t object_id);
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INCORRECT_OBJ_TYPE @copybrief OS_ERR_INCORRECT_OBJ_TYPE
*/
int32 OS_ConvertToArrayIndex(osal_id_t object_id, uint32 *ArrayIndex);
int32 OS_ConvertToArrayIndex(osal_id_t object_id, osal_index_t *ArrayIndex);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -537,7 +556,7 @@ int32 OS_ConvertToArrayIndex(osal_id_t object_id, uint32 *ArrayIndex);
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INCORRECT_OBJ_TYPE @copybrief OS_ERR_INCORRECT_OBJ_TYPE
* */
int32 OS_ObjectIdToArrayIndex(uint32 idtype, osal_id_t object_id, uint32 *ArrayIndex);
int32 OS_ObjectIdToArrayIndex(osal_objtype_t idtype, osal_id_t object_id, osal_index_t *ArrayIndex);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -566,7 +585,8 @@ void OS_ForEachObject(osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void
* @param[in] callback_ptr Function to invoke for each matching object ID
* @param[in] callback_arg Opaque Argument to pass to callback function
*/
void OS_ForEachObjectOfType(uint32 objtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg);
void OS_ForEachObjectOfType(osal_objtype_t objtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr,
void *callback_arg);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -617,8 +637,8 @@ int32 OS_RegisterEventHandler(OS_EventHandler_t handler);
* @retval #OS_ERR_NAME_TAKEN if the name specified is already used by a task
* @retval #OS_ERROR if an unspecified/other error occurs
*/
int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, osal_task_entry function_pointer, uint32 *stack_pointer,
uint32 stack_size, uint32 priority, uint32 flags);
int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, osal_task_entry function_pointer,
osal_stackptr_t stack_pointer, size_t stack_size, osal_priority_t priority, uint32 flags);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -687,7 +707,7 @@ int32 OS_TaskDelay(uint32 millisecond);
* @retval #OS_ERR_INVALID_PRIORITY if the priority is greater than the max allowed
* @retval #OS_ERROR if the OS call to change the priority fails
*/
int32 OS_TaskSetPriority(osal_id_t task_id, uint32 new_priority);
int32 OS_TaskSetPriority(osal_id_t task_id, osal_priority_t new_priority);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -797,7 +817,8 @@ int32 OS_TaskFindIdBySystemData(osal_id_t *task_id, const void *sysdata, size_t
* @retval #OS_QUEUE_INVALID_SIZE if the queue depth exceeds the limit
* @retval #OS_ERROR if the OS create call fails
*/
int32 OS_QueueCreate(osal_id_t *queue_id, const char *queue_name, uint32 queue_depth, uint32 data_size, uint32 flags);
int32 OS_QueueCreate(osal_id_t *queue_id, const char *queue_name, osal_blockcount_t queue_depth, size_t data_size,
uint32 flags);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -839,7 +860,7 @@ int32 OS_QueueDelete(osal_id_t queue_id);
* @retval #OS_QUEUE_TIMEOUT if the timeout was OS_PEND and the time expired
* @retval #OS_QUEUE_INVALID_SIZE if the size copied from the queue was not correct
*/
int32 OS_QueueGet(osal_id_t queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout);
int32 OS_QueueGet(osal_id_t queue_id, void *data, size_t size, size_t *size_copied, int32 timeout);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -857,7 +878,7 @@ int32 OS_QueueGet(osal_id_t queue_id, void *data, uint32 size, uint32 *size_copi
* @retval #OS_QUEUE_FULL if the queue cannot accept another message
* @retval #OS_ERROR if the OS call returns an error
*/
int32 OS_QueuePut(osal_id_t queue_id, const void *data, uint32 size, uint32 flags);
int32 OS_QueuePut(osal_id_t queue_id, const void *data, size_t size, uint32 flags);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down
14 changes: 7 additions & 7 deletions src/os/inc/osapi-os-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ typedef struct
{
uint32 FileModeBits;
int32 FileTime;
uint32 FileSize;
size_t FileSize;
} os_fstat_t;

/**
Expand Down Expand Up @@ -285,7 +285,7 @@ int32 OS_close(osal_id_t filedes);
* @retval #OS_ERROR if OS call failed
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
*/
int32 OS_read(osal_id_t filedes, void *buffer, uint32 nbytes);
int32 OS_read(osal_id_t filedes, void *buffer, size_t nbytes);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -306,7 +306,7 @@ int32 OS_read(osal_id_t filedes, void *buffer, uint32 nbytes);
* @retval #OS_ERROR if OS call failed
* @retval #OS_ERR_INVALID_ID if the file descriptor passed in is invalid
*/
int32 OS_write(osal_id_t filedes, const void *buffer, uint32 nbytes);
int32 OS_write(osal_id_t filedes, const void *buffer, size_t nbytes);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -337,7 +337,7 @@ int32 OS_write(osal_id_t filedes, const void *buffer, uint32 nbytes);
* @return Byte count on success, zero for timeout, or appropriate error code,
* see @ref OSReturnCodes
*/
int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout);
int32 OS_TimedRead(osal_id_t filedes, void *buffer, size_t nbytes, int32 timeout);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -368,7 +368,7 @@ int32 OS_TimedRead(osal_id_t filedes, void *buffer, uint32 nbytes, int32 timeout
* @return Byte count on success, zero for timeout, or appropriate error code,
* see @ref OSReturnCodes
*/
int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, uint32 nbytes, int32 timeout);
int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, size_t nbytes, int32 timeout);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -715,7 +715,7 @@ int32 OS_FileSysAddFixedMap(osal_id_t *filesys_id, const char *phys_path, const
* @retval #OS_FS_ERR_DEVICE_NOT_FREE if the volume table is full
* @retval #OS_SUCCESS on creating the disk
*/
int32 OS_mkfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks);
int32 OS_mkfs(char *address, const char *devname, const char *volname, size_t blocksize, osal_blockcount_t numblocks);
/*-------------------------------------------------------------------------------------*/
/**
* @brief Mounts a file system
Expand Down Expand Up @@ -754,7 +754,7 @@ int32 OS_mount(const char *devname, const char *mountpoint);
* @retval #OS_FS_ERR_DEVICE_NOT_FREE if the volume table is full
* @retval #OS_FS_ERR_DRIVE_NOT_CREATED on error
*/
int32 OS_initfs(char *address, const char *devname, const char *volname, uint32 blocksize, uint32 numblocks);
int32 OS_initfs(char *address, const char *devname, const char *volname, size_t blocksize, osal_blockcount_t numblocks);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-os-loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int32 OS_ModuleSymbolLookup(osal_id_t module_id, cpuaddr *symbol_address, const
* @retval #OS_ERR_NOT_IMPLEMENTED @copybrief OS_ERR_NOT_IMPLEMENTED
* @retval #OS_ERROR if the symbol table could not be read or dumped
*/
int32 OS_SymbolTableDump(const char *filename, uint32 size_limit);
int32 OS_SymbolTableDump(const char *filename, size_t size_limit);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down
10 changes: 5 additions & 5 deletions src/os/inc/osapi-os-net.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ typedef union
*/
typedef struct
{
uint32 ActualLength; /**< @brief Length of the actual address data */
size_t ActualLength; /**< @brief Length of the actual address data */
OS_SockAddrData_t AddrData; /**< @brief Abstract Address data */
} OS_SockAddr_t;

Expand Down Expand Up @@ -162,7 +162,7 @@ int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr);
int32 OS_SocketAddrToString(char *buffer, size_t buflen, const OS_SockAddr_t *Addr);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -317,7 +317,7 @@ int32 OS_SocketAccept(osal_id_t sock_id, osal_id_t *connsock_id, OS_SockAddr_t *
*
* @return Count of actual bytes received or error status, see @ref OSReturnCodes
*/
int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout);
int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, size_t buflen, OS_SockAddr_t *RemoteAddr, int32 timeout);

/*-------------------------------------------------------------------------------------*/
/**
Expand All @@ -334,7 +334,7 @@ int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, uint32 buflen, OS_SockA
*
* @return Count of actual bytes sent or error status, see @ref OSReturnCodes
*/
int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr);
int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, size_t buflen, const OS_SockAddr_t *RemoteAddr);

/*-------------------------------------------------------------------------------------*/
/**
Expand Down Expand Up @@ -400,7 +400,7 @@ int32 OS_NetworkGetID(void);
*
* @return Execution status, see @ref OSReturnCodes
*/
int32 OS_NetworkGetHostName(char *host_name, uint32 name_len);
int32 OS_NetworkGetHostName(char *host_name, size_t name_len);
/**@}*/

#endif
4 changes: 2 additions & 2 deletions src/os/inc/osapi-os-timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
/*
** Typedefs
*/
typedef void (*OS_TimerCallback_t)(osal_id_t timer_id); /**< @brief Timer callback */
typedef uint32 (*OS_TimerSync_t)(uint32 timer_id); /**< @brief Timer sync */
typedef void (*OS_TimerCallback_t)(osal_id_t timer_id); /**< @brief Timer callback */
typedef uint32 (*OS_TimerSync_t)(osal_index_t timer_id); /**< @brief Timer sync */

/** @brief Timer properties */
typedef struct
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 75
#define OS_BUILD_NUMBER 91
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
Loading