diff --git a/CMakeLists.txt b/CMakeLists.txt index fbf5f2571..4a1487b62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,10 +184,7 @@ target_include_directories(osal_${OSAL_SYSTEM_OSTYPE}_impl PRIVATE ${OSAL_SOURCE_DIR}/src/bsp/shared ) -# Define the external "osal" static library target -# This is a combination of the generic parts with the low level -# system-specific parts -add_library(osal STATIC +set(OSAL_SRCLIST src/os/shared/src/osapi-binsem.c src/os/shared/src/osapi-clock.c src/os/shared/src/osapi-common.c @@ -210,6 +207,20 @@ add_library(osal STATIC src/os/shared/src/osapi-task.c src/os/shared/src/osapi-timebase.c src/os/shared/src/osapi-time.c +) + +if (OSAL_CONFIG_DEBUG_PRINTF) + list(APPEND OSAL_SRCLIST + src/os/shared/src/osapi-debug.c + ) +endif (OSAL_CONFIG_DEBUG_PRINTF) + + +# Define the external "osal" static library target +# This is a combination of the generic parts with the low level +# system-specific parts +add_library(osal STATIC + ${OSAL_SRCLIST} $ ) diff --git a/default_config.cmake b/default_config.cmake index 4e2d9c6f3..1ab851eda 100644 --- a/default_config.cmake +++ b/default_config.cmake @@ -49,7 +49,7 @@ set(OSAL_CONFIG_INCLUDE_NETWORK FALSE) # For deployments which are always statically linked, this may be set # FALSE for a smaller library size and reduced linking requirements. # -set(OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER FALSE) +set(OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER TRUE) # @@ -91,7 +91,7 @@ set(OSAL_CONFIG_INCLUDE_STATIC_LOADER TRUE) # - If the user does not have permission to create elevated priority tasks, then the tasks will # be created at the default priority (no error). # -set(OSAL_CONFIG_DEBUG_PERMISSIVE_MODE FALSE) +set(OSAL_CONFIG_DEBUG_PERMISSIVE_MODE TRUE) # # OSAL_CONFIG_DEBUG_PRINTF diff --git a/src/os/portable/os-impl-posix-dl-loader.c b/src/os/portable/os-impl-posix-dl-loader.c index 81028d0df..756c162aa 100644 --- a/src/os/portable/os-impl-posix-dl-loader.c +++ b/src/os/portable/os-impl-posix-dl-loader.c @@ -35,8 +35,9 @@ */ #include #include -#include "os-impl.h" + #include "os-impl-loader.h" +#include "osapi-module-impl.h" diff --git a/src/os/portable/os-impl-posix-dl-symtab.c b/src/os/portable/os-impl-posix-dl-symtab.c index 2a0813653..6c54f2061 100644 --- a/src/os/portable/os-impl-posix-dl-symtab.c +++ b/src/os/portable/os-impl-posix-dl-symtab.c @@ -35,9 +35,9 @@ */ #include #include -#include "os-impl.h" -#include "os-impl-loader.h" +#include "os-impl-loader.h" +#include "osapi-module-impl.h" /**************************************************************************************** DEFINES diff --git a/src/os/portable/os-impl-posix-files.c b/src/os/portable/os-impl-posix-files.c index 5edafd69c..f618bdf49 100644 --- a/src/os/portable/os-impl-posix-files.c +++ b/src/os/portable/os-impl-posix-files.c @@ -36,7 +36,6 @@ #include "os-impl-files.h" #include "osapi-file-impl.h" -#include "osapi-common-impl.h" /**************************************************************************************** diff --git a/src/os/portable/os-impl-posix-gettime.c b/src/os/portable/os-impl-posix-gettime.c index 3514faa57..ec631c5b3 100644 --- a/src/os/portable/os-impl-posix-gettime.c +++ b/src/os/portable/os-impl-posix-gettime.c @@ -39,7 +39,6 @@ #include #include "os-impl-gettime.h" -#include "osapi-common-impl.h" #include "osapi-clock-impl.h" diff --git a/src/os/portable/os-impl-posix-io.c b/src/os/portable/os-impl-posix-io.c index 16c0d48d5..238014061 100644 --- a/src/os/portable/os-impl-posix-io.c +++ b/src/os/portable/os-impl-posix-io.c @@ -37,7 +37,6 @@ #include "os-impl-io.h" #include "osapi-file-impl.h" -#include "osapi-common-impl.h" #include "osapi-select-impl.h" diff --git a/src/os/posix/CMakeLists.txt b/src/os/posix/CMakeLists.txt index 53e87312f..e89019d73 100644 --- a/src/os/posix/CMakeLists.txt +++ b/src/os/posix/CMakeLists.txt @@ -14,10 +14,12 @@ set(POSIX_BASE_SRCLIST src/os-impl-console.c src/os-impl-countsem.c src/os-impl-dirs.c + src/os-impl-errors.c src/os-impl-files.c src/os-impl-filesys.c src/os-impl-fpu.c src/os-impl-heap.c + src/os-impl-idmap.c src/os-impl-interrupts.c src/os-impl-mutex.c src/os-impl-queues.c @@ -40,7 +42,7 @@ set(POSIX_IMPL_SRCLIST # then build the module loader if (OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER) list(APPEND POSIX_IMPL_SRCLIST - src/os-impl-module.c + src/os-impl-loader.c ../portable/os-impl-posix-dl-loader.c ../portable/os-impl-posix-dl-symtab.c ) diff --git a/src/os/posix/inc/os-posix.h b/src/os/posix/inc/os-posix.h index 9371aa9fd..792325cf8 100644 --- a/src/os/posix/inc/os-posix.h +++ b/src/os/posix/inc/os-posix.h @@ -44,9 +44,10 @@ #include #include -#include "common_types.h" -#include "osapi.h" -#include "osapi-common-impl.h" +/* + * Use the global definitions from the shared layer + */ +#include /**************************************************************************************** DEFINES @@ -99,6 +100,8 @@ int32 OS_Posix_StreamAPI_Impl_Init(void); int32 OS_Posix_DirAPI_Impl_Init(void); int32 OS_Posix_FileSysAPI_Impl_Init(void); +int32 OS_Posix_TableMutex_Init(uint32 idtype); + int32 OS_Posix_InternalTaskCreate_Impl (pthread_t *pthr, uint32 priority, size_t stacksz, PthreadFuncPtr_t entry, void *entry_arg); void OS_Posix_CompAbsDelayTime( uint32 msecs , struct timespec * tm); diff --git a/src/os/posix/src/os-impl-common.c b/src/os/posix/src/os-impl-common.c index 3dc0a9ef7..1494bf887 100644 --- a/src/os/posix/src/os-impl-common.c +++ b/src/os/posix/src/os-impl-common.c @@ -24,7 +24,6 @@ #include "os-posix.h" #include "bsp-impl.h" -#include #include "os-impl-tasks.h" #include "os-impl-queues.h" @@ -32,137 +31,13 @@ #include "os-impl-countsem.h" #include "os-impl-mutex.h" +#include "osapi-common-impl.h" +#include "osapi-idmap-impl.h" #include "osapi-errors-impl.h" -typedef struct -{ - pthread_mutex_t mutex; - sigset_t sigmask; -} POSIX_GlobalLock_t; - -static POSIX_GlobalLock_t OS_global_task_table_mut; -static POSIX_GlobalLock_t OS_queue_table_mut; -static POSIX_GlobalLock_t OS_bin_sem_table_mut; -static POSIX_GlobalLock_t OS_mutex_table_mut; -static POSIX_GlobalLock_t OS_count_sem_table_mut; -static POSIX_GlobalLock_t OS_stream_table_mut; -static POSIX_GlobalLock_t OS_dir_table_mut; -static POSIX_GlobalLock_t OS_timebase_table_mut; -static POSIX_GlobalLock_t OS_module_table_mut; -static POSIX_GlobalLock_t OS_filesys_table_mut; -static POSIX_GlobalLock_t OS_console_mut; - -static POSIX_GlobalLock_t * const MUTEX_TABLE[] = - { - [OS_OBJECT_TYPE_UNDEFINED] = NULL, - [OS_OBJECT_TYPE_OS_TASK] = &OS_global_task_table_mut, - [OS_OBJECT_TYPE_OS_QUEUE] = &OS_queue_table_mut, - [OS_OBJECT_TYPE_OS_COUNTSEM] = &OS_count_sem_table_mut, - [OS_OBJECT_TYPE_OS_BINSEM] = &OS_bin_sem_table_mut, - [OS_OBJECT_TYPE_OS_MUTEX] = &OS_mutex_table_mut, - [OS_OBJECT_TYPE_OS_STREAM] = &OS_stream_table_mut, - [OS_OBJECT_TYPE_OS_DIR] = &OS_dir_table_mut, - [OS_OBJECT_TYPE_OS_TIMEBASE] = &OS_timebase_table_mut, - [OS_OBJECT_TYPE_OS_MODULE] = &OS_module_table_mut, - [OS_OBJECT_TYPE_OS_FILESYS] = &OS_filesys_table_mut, - [OS_OBJECT_TYPE_OS_CONSOLE] = &OS_console_mut, - }; - POSIX_GlobalVars_t POSIX_GlobalVars = { 0 }; -enum -{ - MUTEX_TABLE_SIZE = (sizeof(MUTEX_TABLE) / sizeof(MUTEX_TABLE[0])) -}; - -const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = { { 0, NULL } }; - - -/*---------------------------------------------------------------- - * - * Function: OS_Lock_Global_Impl - * - * Purpose: Implemented per internal OSAL API - * See prototype in os-impl.h for argument/return detail - * - *-----------------------------------------------------------------*/ -int32 OS_Lock_Global_Impl(uint32 idtype) -{ - POSIX_GlobalLock_t *mut; - sigset_t previous; - - if (idtype < MUTEX_TABLE_SIZE) - { - mut = MUTEX_TABLE[idtype]; - } - else - { - mut = NULL; - } - - if (mut == NULL) - { - return OS_ERROR; - } - - if (pthread_sigmask(SIG_SETMASK, &POSIX_GlobalVars.MaximumSigMask, &previous) != 0) - { - return OS_ERROR; - } - - if (pthread_mutex_lock(&mut->mutex) != 0) - { - return OS_ERROR; - } - - /* Only set values inside the GlobalLock _after_ it is locked */ - mut->sigmask = previous; - - return OS_SUCCESS; -} /* end OS_Lock_Global_Impl */ - - -/*---------------------------------------------------------------- - * - * Function: OS_Unlock_Global_Impl - * - * Purpose: Implemented per internal OSAL API - * See prototype in os-impl.h for argument/return detail - * - *-----------------------------------------------------------------*/ -int32 OS_Unlock_Global_Impl(uint32 idtype) -{ - POSIX_GlobalLock_t *mut; - sigset_t previous; - - if (idtype < MUTEX_TABLE_SIZE) - { - mut = MUTEX_TABLE[idtype]; - } - else - { - mut = NULL; - } - - if (mut == NULL) - { - return OS_ERROR; - } - - /* Only get values inside the GlobalLock _before_ it is unlocked */ - previous = mut->sigmask; - - if (pthread_mutex_unlock(&mut->mutex) != 0) - { - return OS_ERROR; - } - - pthread_sigmask(SIG_SETMASK, &previous, NULL); - - return OS_SUCCESS; -} /* end OS_Unlock_Global_Impl */ - /*--------------------------------------------------------------------------------------- Name: OS_API_Impl_Init @@ -174,98 +49,53 @@ int32 OS_Unlock_Global_Impl(uint32 idtype) ---------------------------------------------------------------------------------------*/ int32 OS_API_Impl_Init(uint32 idtype) { - int ret; - int32 return_code = OS_SUCCESS; - pthread_mutexattr_t mutex_attr; - - do - { - /* Initialize the table mutex for the given idtype */ - if (idtype < MUTEX_TABLE_SIZE && MUTEX_TABLE[idtype] != NULL) - { - /* - ** initialize the pthread mutex attribute structure with default values - */ - ret = pthread_mutexattr_init(&mutex_attr); - if ( ret != 0 ) - { - OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n",strerror(ret)); - return_code = OS_ERROR; - break; - } + int32 return_code; - /* - ** Allow the mutex to use priority inheritance - */ - ret = pthread_mutexattr_setprotocol(&mutex_attr,PTHREAD_PRIO_INHERIT) ; - if ( ret != 0 ) - { - OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n",strerror(ret)); - return_code = OS_ERROR; - break; - } - - /* - ** Set the mutex type to RECURSIVE so a thread can do nested locks - ** TBD - not sure if this is really desired, but keep it for now. - */ - ret = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); - if ( ret != 0 ) - { - OS_DEBUG("Error: pthread_mutexattr_settype failed: %s\n",strerror(ret)); - return_code = OS_ERROR; - break; - } + return_code = OS_Posix_TableMutex_Init(idtype); + if (return_code != OS_SUCCESS) + { + return return_code; + } - ret = pthread_mutex_init(&MUTEX_TABLE[idtype]->mutex, &mutex_attr); - if ( ret != 0 ) - { - OS_DEBUG("Error: pthread_mutex_init failed: %s\n",strerror(ret)); - return_code = OS_ERROR; - break; - } - } - switch(idtype) - { - case OS_OBJECT_TYPE_OS_TASK: - return_code = OS_Posix_TaskAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - return_code = OS_Posix_QueueAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - return_code = OS_Posix_BinSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - return_code = OS_Posix_CountSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - return_code = OS_Posix_MutexAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MODULE: - return_code = OS_Posix_ModuleAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - return_code = OS_Posix_TimeBaseAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_STREAM: - return_code = OS_Posix_StreamAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_DIR: - return_code = OS_Posix_DirAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_FILESYS: - return_code = OS_Posix_FileSysAPI_Impl_Init(); - break; - default: - break; - } - } - while (0); + switch(idtype) + { + case OS_OBJECT_TYPE_OS_TASK: + return_code = OS_Posix_TaskAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + return_code = OS_Posix_QueueAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + return_code = OS_Posix_BinSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return_code = OS_Posix_CountSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + return_code = OS_Posix_MutexAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MODULE: + return_code = OS_Posix_ModuleAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return_code = OS_Posix_TimeBaseAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_STREAM: + return_code = OS_Posix_StreamAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_DIR: + return_code = OS_Posix_DirAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_FILESYS: + return_code = OS_Posix_FileSysAPI_Impl_Init(); + break; + default: + break; + } - return(return_code); + return(return_code); } /* end OS_API_Impl_Init */ @@ -277,7 +107,7 @@ int32 OS_API_Impl_Init(uint32 idtype) * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -void OS_IdleLoop_Impl() +void OS_IdleLoop_Impl(void) { /* * Unblock signals and wait for something to occur @@ -299,7 +129,7 @@ void OS_IdleLoop_Impl() * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ApplicationShutdown_Impl() +void OS_ApplicationShutdown_Impl(void) { /* * Raise a signal that is unblocked in OS_IdleLoop(), diff --git a/src/os/posix/src/os-impl-errors.c b/src/os/posix/src/os-impl-errors.c new file mode 100644 index 000000000..c41f597d0 --- /dev/null +++ b/src/os/posix/src/os-impl-errors.c @@ -0,0 +1,30 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + + +/** + * \file os-impl-common.c + * \ingroup posix + * \author joseph.p.hickey@nasa.gov + * + */ + +/**************************************************************************************** + INCLUDE FILES + ***************************************************************************************/ + +#include "os-posix.h" + +#include "osapi-errors-impl.h" + +const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = { { 0, NULL } }; + diff --git a/src/os/posix/src/os-impl-idmap.c b/src/os/posix/src/os-impl-idmap.c new file mode 100644 index 000000000..61a2c52b3 --- /dev/null +++ b/src/os/posix/src/os-impl-idmap.c @@ -0,0 +1,228 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + + +/** + * \file os-impl-idmap.c + * \ingroup posix + * \author joseph.p.hickey@nasa.gov + * + */ + +/**************************************************************************************** + INCLUDE FILES + ***************************************************************************************/ + +#include "os-posix.h" +#include "bsp-impl.h" +#include + +#include "osapi-idmap-impl.h" + +typedef struct +{ + pthread_mutex_t mutex; + sigset_t sigmask; +} POSIX_GlobalLock_t; + +static POSIX_GlobalLock_t OS_global_task_table_mut; +static POSIX_GlobalLock_t OS_queue_table_mut; +static POSIX_GlobalLock_t OS_bin_sem_table_mut; +static POSIX_GlobalLock_t OS_mutex_table_mut; +static POSIX_GlobalLock_t OS_count_sem_table_mut; +static POSIX_GlobalLock_t OS_stream_table_mut; +static POSIX_GlobalLock_t OS_dir_table_mut; +static POSIX_GlobalLock_t OS_timebase_table_mut; +static POSIX_GlobalLock_t OS_module_table_mut; +static POSIX_GlobalLock_t OS_filesys_table_mut; +static POSIX_GlobalLock_t OS_console_mut; + +static POSIX_GlobalLock_t * const MUTEX_TABLE[] = + { + [OS_OBJECT_TYPE_UNDEFINED] = NULL, + [OS_OBJECT_TYPE_OS_TASK] = &OS_global_task_table_mut, + [OS_OBJECT_TYPE_OS_QUEUE] = &OS_queue_table_mut, + [OS_OBJECT_TYPE_OS_COUNTSEM] = &OS_count_sem_table_mut, + [OS_OBJECT_TYPE_OS_BINSEM] = &OS_bin_sem_table_mut, + [OS_OBJECT_TYPE_OS_MUTEX] = &OS_mutex_table_mut, + [OS_OBJECT_TYPE_OS_STREAM] = &OS_stream_table_mut, + [OS_OBJECT_TYPE_OS_DIR] = &OS_dir_table_mut, + [OS_OBJECT_TYPE_OS_TIMEBASE] = &OS_timebase_table_mut, + [OS_OBJECT_TYPE_OS_MODULE] = &OS_module_table_mut, + [OS_OBJECT_TYPE_OS_FILESYS] = &OS_filesys_table_mut, + [OS_OBJECT_TYPE_OS_CONSOLE] = &OS_console_mut, + }; + +enum +{ + MUTEX_TABLE_SIZE = (sizeof(MUTEX_TABLE) / sizeof(MUTEX_TABLE[0])) +}; + +/*---------------------------------------------------------------- + * + * Function: OS_Lock_Global_Impl + * + * Purpose: Implemented per internal OSAL API + * See prototype in os-impl.h for argument/return detail + * + *-----------------------------------------------------------------*/ +int32 OS_Lock_Global_Impl(uint32 idtype) +{ + POSIX_GlobalLock_t *mut; + sigset_t previous; + + if (idtype < MUTEX_TABLE_SIZE) + { + mut = MUTEX_TABLE[idtype]; + } + else + { + mut = NULL; + } + + if (mut == NULL) + { + return OS_ERROR; + } + + if (pthread_sigmask(SIG_SETMASK, &POSIX_GlobalVars.MaximumSigMask, &previous) != 0) + { + return OS_ERROR; + } + + if (pthread_mutex_lock(&mut->mutex) != 0) + { + return OS_ERROR; + } + + /* Only set values inside the GlobalLock _after_ it is locked */ + mut->sigmask = previous; + + return OS_SUCCESS; +} /* end OS_Lock_Global_Impl */ + + +/*---------------------------------------------------------------- + * + * Function: OS_Unlock_Global_Impl + * + * Purpose: Implemented per internal OSAL API + * See prototype in os-impl.h for argument/return detail + * + *-----------------------------------------------------------------*/ +int32 OS_Unlock_Global_Impl(uint32 idtype) +{ + POSIX_GlobalLock_t *mut; + sigset_t previous; + + if (idtype < MUTEX_TABLE_SIZE) + { + mut = MUTEX_TABLE[idtype]; + } + else + { + mut = NULL; + } + + if (mut == NULL) + { + return OS_ERROR; + } + + /* Only get values inside the GlobalLock _before_ it is unlocked */ + previous = mut->sigmask; + + if (pthread_mutex_unlock(&mut->mutex) != 0) + { + return OS_ERROR; + } + + pthread_sigmask(SIG_SETMASK, &previous, NULL); + + return OS_SUCCESS; +} /* end OS_Unlock_Global_Impl */ + + +/*--------------------------------------------------------------------------------------- + Name: OS_Posix_TableMutex_Init + + Purpose: Initialize the mutex that the OS API uses for the shared state tables + + returns: OS_SUCCESS or OS_ERROR +---------------------------------------------------------------------------------------*/ +int32 OS_Posix_TableMutex_Init(uint32 idtype) +{ + int ret; + int32 return_code = OS_SUCCESS; + pthread_mutexattr_t mutex_attr; + + do + { + if (idtype >= MUTEX_TABLE_SIZE) + { + break; + } + + /* Initialize the table mutex for the given idtype */ + if (MUTEX_TABLE[idtype] == NULL) + { + break; + } + + /* + ** initialize the pthread mutex attribute structure with default values + */ + ret = pthread_mutexattr_init(&mutex_attr); + if ( ret != 0 ) + { + OS_DEBUG("Error: pthread_mutexattr_init failed: %s\n",strerror(ret)); + return_code = OS_ERROR; + break; + } + + /* + ** Allow the mutex to use priority inheritance + */ + ret = pthread_mutexattr_setprotocol(&mutex_attr,PTHREAD_PRIO_INHERIT) ; + if ( ret != 0 ) + { + OS_DEBUG("Error: pthread_mutexattr_setprotocol failed: %s\n",strerror(ret)); + return_code = OS_ERROR; + break; + } + + /* + ** Set the mutex type to RECURSIVE so a thread can do nested locks + ** TBD - not sure if this is really desired, but keep it for now. + */ + ret = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); + if ( ret != 0 ) + { + OS_DEBUG("Error: pthread_mutexattr_settype failed: %s\n",strerror(ret)); + return_code = OS_ERROR; + break; + } + + ret = pthread_mutex_init(&MUTEX_TABLE[idtype]->mutex, &mutex_attr); + if ( ret != 0 ) + { + OS_DEBUG("Error: pthread_mutex_init failed: %s\n",strerror(ret)); + return_code = OS_ERROR; + break; + } + } + while (0); + + + return(return_code); +} /* end OS_Posix_TableMutex_Init */ + diff --git a/src/os/posix/src/os-impl-loader.c b/src/os/posix/src/os-impl-loader.c index f3cb300c9..7e02b1196 100644 --- a/src/os/posix/src/os-impl-loader.c +++ b/src/os/posix/src/os-impl-loader.c @@ -24,8 +24,8 @@ #include #include -#include "os-impl.h" #include "os-impl-loader.h" +#include "osapi-module-impl.h" OS_impl_module_internal_record_t OS_impl_module_table[OS_MAX_MODULES]; diff --git a/src/os/posix/src/os-impl-queues.c b/src/os/posix/src/os-impl-queues.c index 78057b769..97d8b3b4b 100644 --- a/src/os/posix/src/os-impl-queues.c +++ b/src/os/posix/src/os-impl-queues.c @@ -47,11 +47,11 @@ int32 OS_Posix_QueueAPI_Impl_Init(void) memset(OS_impl_queue_table, 0, sizeof(OS_impl_queue_table)); /* - * Automatic truncation is dependent on the OSAL_DEBUG_PERMISSIVE_MODE compile-time define - so - * creating a too-large message queue on a target without OSAL_DEBUG_PERMISSIVE_MODE will fail + * Automatic truncation is dependent on the OSAL_CONFIG_DEBUG_PERMISSIVE_MODE compile-time define - so + * creating a too-large message queue on a target without OSAL_CONFIG_DEBUG_PERMISSIVE_MODE will fail * with an OS error as intended. */ -#ifdef OSAL_DEBUG_PERMISSIVE_MODE +#ifdef OSAL_CONFIG_DEBUG_PERMISSIVE_MODE /* * Use the BSP-provided limit */ diff --git a/src/os/posix/src/os-impl-timebase.c b/src/os/posix/src/os-impl-timebase.c index 480a93d56..aa4c6c3f2 100644 --- a/src/os/posix/src/os-impl-timebase.c +++ b/src/os/posix/src/os-impl-timebase.c @@ -38,6 +38,7 @@ #include "osapi-timebase-impl.h" #include "osapi-idmap-impl.h" +#include "osapi-common-impl.h" /**************************************************************************************** diff --git a/src/os/shared/inc/osapi-binsem-impl.h b/src/os/shared/inc/osapi-binsem-impl.h index 2e539d08a..80f4bf897 100644 --- a/src/os/shared/inc/osapi-binsem-impl.h +++ b/src/os/shared/inc/osapi-binsem-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_BINSEM_H_ #define INCLUDE_OSAPI_BINSEM_H_ -#include +#include /* other objects that have only an API name and no other data */ typedef struct diff --git a/src/os/shared/inc/osapi-clock-impl.h b/src/os/shared/inc/osapi-clock-impl.h index 20f2236c8..5dc220815 100644 --- a/src/os/shared/inc/osapi-clock-impl.h +++ b/src/os/shared/inc/osapi-clock-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_CLOCK_H_ #define INCLUDE_OSAPI_CLOCK_H_ -#include +#include /* diff --git a/src/os/shared/inc/osapi-common-impl.h b/src/os/shared/inc/osapi-common-impl.h index a09d784bc..a74cce39f 100644 --- a/src/os/shared/inc/osapi-common-impl.h +++ b/src/os/shared/inc/osapi-common-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_COMMON_H_ #define INCLUDE_OSAPI_COMMON_H_ -#include +#include /* * A "magic number" that when written to the "ShutdownFlag" member @@ -32,7 +32,7 @@ /* Global variables that are common between implementations */ -typedef struct +struct OS_shared_global_vars { bool Initialized; @@ -54,22 +54,7 @@ typedef struct uint8 DebugLevel; #endif -} OS_SharedGlobalVars_t; - -/* - * Wrapper for encoding of other types into a generic void* type required as argument - * to callbacks and pthread entry/return values, etc. - * - * Note this can only encode types with sizes <= sizeof(void*) - */ -typedef union -{ - void *opaque_arg; - OS_ArgCallback_t arg_callback_func; - OS_TimerCallback_t timer_callback_func; - osal_task_entry entry_func; - uint32 value; -} OS_U32ValueWrapper_t; +}; /* @@ -77,22 +62,6 @@ typedef union */ extern OS_SharedGlobalVars_t OS_SharedGlobalVars; - -/* - * The "OS_DEBUG" is a no-op unless OSAL_CONFIG_DEBUG_PRINTF is enabled. - * When enabled, it is a macro that includes function/line number info. - */ -#if defined(OSAL_CONFIG_DEBUG_PRINTF) -/* Debug printfs are compiled in, but also can be disabled by a run-time flag. - * Note that the ##__VA_ARGS__ syntax works on GCC but might need tweaks for other compilers... */ -#define OS_DEBUG_LEV(l,...) do { if (OS_SharedGlobalVars.DebugLevel >= l) printf("%s():%d:", __func__,__LINE__); printf(__VA_ARGS__); } while (0) -#define OS_DEBUG(...) OS_DEBUG_LEV(1,__VA_ARGS__) -#else -/* Debug printfs are not compiled in at all */ -#define OS_DEBUG(...) -#endif - - /*--------------------------------------------------------------------------------------- Name: OS_API_Impl_Init @@ -146,31 +115,6 @@ void OS_ApplicationShutdown_Impl (void); -/* - * Table locking and unlocking for global objects can be done at the shared code - * layer but the actual implementation is OS-specific - */ - - -/*---------------------------------------------------------------- - Function: OS_Lock_Global_Impl - - Purpose: Locks the global table identified by "idtype" - - Returns: OS_SUCCESS on success, or relevant error code - ------------------------------------------------------------------*/ -int32 OS_Lock_Global_Impl(uint32 idtype); - -/*---------------------------------------------------------------- - Function: OS_Unlock_Global_Impl - - Purpose: Unlocks the global table identified by "idtype" - - Returns: OS_SUCCESS on success, or relevant error code - ------------------------------------------------------------------*/ -int32 OS_Unlock_Global_Impl(uint32 idtype); - - #endif /* INCLUDE_OSAPI_COMMON_H_ */ diff --git a/src/os/shared/inc/osapi-countsem-impl.h b/src/os/shared/inc/osapi-countsem-impl.h index 2422c3737..7035398fd 100644 --- a/src/os/shared/inc/osapi-countsem-impl.h +++ b/src/os/shared/inc/osapi-countsem-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_COUNTSEM_H_ #define INCLUDE_OSAPI_COUNTSEM_H_ -#include +#include /* other objects that have only an API name and no other data */ diff --git a/src/os/shared/inc/osapi-dir-impl.h b/src/os/shared/inc/osapi-dir-impl.h index 4a2c936fb..2d5c86217 100644 --- a/src/os/shared/inc/osapi-dir-impl.h +++ b/src/os/shared/inc/osapi-dir-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_DIR_H_ #define INCLUDE_OSAPI_DIR_H_ -#include +#include /* directory objects */ typedef struct diff --git a/src/os/shared/inc/osapi-errors-impl.h b/src/os/shared/inc/osapi-errors-impl.h index 7c90543f0..42c3ea26a 100644 --- a/src/os/shared/inc/osapi-errors-impl.h +++ b/src/os/shared/inc/osapi-errors-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_ERRORS_H_ #define INCLUDE_OSAPI_ERRORS_H_ -#include +#include /* Mapping of integer error number to name */ diff --git a/src/os/shared/inc/osapi-file-impl.h b/src/os/shared/inc/osapi-file-impl.h index 64f4f862e..194693f96 100644 --- a/src/os/shared/inc/osapi-file-impl.h +++ b/src/os/shared/inc/osapi-file-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_FILE_H_ #define INCLUDE_OSAPI_FILE_H_ -#include +#include /* * Flags that can be used with opening of a file (bitmask) diff --git a/src/os/shared/inc/osapi-filesys-impl.h b/src/os/shared/inc/osapi-filesys-impl.h index 14ac7561c..15d9ebeec 100644 --- a/src/os/shared/inc/osapi-filesys-impl.h +++ b/src/os/shared/inc/osapi-filesys-impl.h @@ -21,10 +21,7 @@ #ifndef INCLUDE_OSAPI_FILESYS_H_ #define INCLUDE_OSAPI_FILESYS_H_ -#include - -/* jphfix - find a way around this dependency */ -#include +#include /** * This flag will be set on the internal record to indicate diff --git a/src/os/shared/inc/osapi-fpu-impl.h b/src/os/shared/inc/osapi-fpu-impl.h index 7997c9f55..8c92e91be 100644 --- a/src/os/shared/inc/osapi-fpu-impl.h +++ b/src/os/shared/inc/osapi-fpu-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_FPU_H_ #define INCLUDE_OSAPI_FPU_H_ -#include +#include #ifndef OSAL_OMIT_DEPRECATED diff --git a/src/os/shared/inc/osapi-heap-impl.h b/src/os/shared/inc/osapi-heap-impl.h index 3e6223082..387945eb7 100644 --- a/src/os/shared/inc/osapi-heap-impl.h +++ b/src/os/shared/inc/osapi-heap-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_HEAP_H_ #define INCLUDE_OSAPI_HEAP_H_ -#include +#include /**************************************************************************************** diff --git a/src/os/shared/inc/osapi-idmap-impl.h b/src/os/shared/inc/osapi-idmap-impl.h index e204a4cc0..37fbccb17 100644 --- a/src/os/shared/inc/osapi-idmap-impl.h +++ b/src/os/shared/inc/osapi-idmap-impl.h @@ -21,19 +21,22 @@ #ifndef INCLUDE_OSAPI_IDMAP_H_ #define INCLUDE_OSAPI_IDMAP_H_ -#include +#include #define OS_OBJECT_EXCL_REQ_FLAG 0x0001 -typedef struct +/* + * This supplies a non-abstract definition of "OS_common_record_t" + */ +struct OS_common_record { const char *name_entry; uint32 active_id; uint32 creator; uint16 refcount; uint16 flags; -}OS_common_record_t; +}; /* @@ -92,6 +95,32 @@ extern OS_common_record_t * const OS_global_console_table; int32 OS_ObjectIdInit (void); +/* + * Table locking and unlocking for global objects can be done at the shared code + * layer but the actual implementation is OS-specific + */ + + +/*---------------------------------------------------------------- + Function: OS_Lock_Global_Impl + + Purpose: Locks the global table identified by "idtype" + + Returns: OS_SUCCESS on success, or relevant error code + ------------------------------------------------------------------*/ +int32 OS_Lock_Global_Impl(uint32 idtype); + +/*---------------------------------------------------------------- + Function: OS_Unlock_Global_Impl + + Purpose: Unlocks the global table identified by "idtype" + + Returns: OS_SUCCESS on success, or relevant error code + ------------------------------------------------------------------*/ +int32 OS_Unlock_Global_Impl(uint32 idtype); + + + /* Function prototypes for routines implemented in common layers but private to OSAL diff --git a/src/os/shared/inc/osapi-interrupts-impl.h b/src/os/shared/inc/osapi-interrupts-impl.h index 58c1955d6..ab97160aa 100644 --- a/src/os/shared/inc/osapi-interrupts-impl.h +++ b/src/os/shared/inc/osapi-interrupts-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_INTERRUPTS_H_ #define INCLUDE_OSAPI_INTERRUPTS_H_ -#include +#include #ifndef OSAL_OMIT_DEPRECATED diff --git a/src/os/shared/inc/osapi-module-impl.h b/src/os/shared/inc/osapi-module-impl.h index e0a6ea894..c0a4cdb94 100644 --- a/src/os/shared/inc/osapi-module-impl.h +++ b/src/os/shared/inc/osapi-module-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_MODULE_H_ #define INCLUDE_OSAPI_MODULE_H_ -#include +#include typedef struct diff --git a/src/os/shared/inc/osapi-mutex-impl.h b/src/os/shared/inc/osapi-mutex-impl.h index d72d09743..bb41b8837 100644 --- a/src/os/shared/inc/osapi-mutex-impl.h +++ b/src/os/shared/inc/osapi-mutex-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_MUTEX_H_ #define INCLUDE_OSAPI_MUTEX_H_ -#include +#include typedef struct diff --git a/src/os/shared/inc/osapi-network-impl.h b/src/os/shared/inc/osapi-network-impl.h index 9e1f218e0..a6100255a 100644 --- a/src/os/shared/inc/osapi-network-impl.h +++ b/src/os/shared/inc/osapi-network-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_NETWORK_H_ #define INCLUDE_OSAPI_NETWORK_H_ -#include +#include diff --git a/src/os/shared/inc/osapi-printf-impl.h b/src/os/shared/inc/osapi-printf-impl.h index 639f4bbeb..dc6207299 100644 --- a/src/os/shared/inc/osapi-printf-impl.h +++ b/src/os/shared/inc/osapi-printf-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_PRINTF_H_ #define INCLUDE_OSAPI_PRINTF_H_ -#include +#include /* * Variables related to the console buffer. diff --git a/src/os/shared/inc/osapi-queue-impl.h b/src/os/shared/inc/osapi-queue-impl.h index ae3c373f7..528a3bc6e 100644 --- a/src/os/shared/inc/osapi-queue-impl.h +++ b/src/os/shared/inc/osapi-queue-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_QUEUE_H_ #define INCLUDE_OSAPI_QUEUE_H_ -#include +#include typedef struct diff --git a/src/os/shared/inc/osapi-select-impl.h b/src/os/shared/inc/osapi-select-impl.h index 06087787b..5d61a5644 100644 --- a/src/os/shared/inc/osapi-select-impl.h +++ b/src/os/shared/inc/osapi-select-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_SELECT_H_ #define INCLUDE_OSAPI_SELECT_H_ -#include +#include /* diff --git a/src/os/shared/inc/osapi-shared-globaldefs.h b/src/os/shared/inc/osapi-shared-globaldefs.h new file mode 100644 index 000000000..a426690ba --- /dev/null +++ b/src/os/shared/inc/osapi-shared-globaldefs.h @@ -0,0 +1,79 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + + +/** + * \file osapi-shared-globaldefs.h + * \ingroup shared + * \author joseph.p.hickey@nasa.gov + * + * Internal type/macro definitions used across the "shared" OSAPI layer. + * These definitions are internal to OSAL but shared/referenced across all subsystems + * so they are put into a common header file. + */ + +#ifndef INCLUDE_OSAPI_SHARED_GLOBALDEFS_H_ +#define INCLUDE_OSAPI_SHARED_GLOBALDEFS_H_ + +/* All subsystems reference the public API */ +#include + +/* + * The "common_record" is part of the generic ID mapping - + * Functions in the internal API may use this as an abstract pointer. + */ +struct OS_common_record; +typedef struct OS_common_record OS_common_record_t; + +/* + * The "OS_shared_global_vars" keeps global state - + * Functions in the internal API may use this as an abstract pointer. + */ +struct OS_shared_global_vars; +typedef struct OS_shared_global_vars OS_SharedGlobalVars_t; + +/* + * Wrapper for encoding of other types into a generic void* type required as argument + * to callbacks and pthread entry/return values, etc. + * + * Note this can only encode types with sizes <= sizeof(void*) + */ +typedef union +{ + void *opaque_arg; + OS_ArgCallback_t arg_callback_func; + OS_TimerCallback_t timer_callback_func; + osal_task_entry entry_func; + uint32 value; +} OS_U32ValueWrapper_t; + + + +/* + * The "OS_DEBUG" is a no-op unless OSAL_CONFIG_DEBUG_PRINTF is enabled. + * When enabled, it is a macro that includes function/line number info. + */ +#if defined(OSAL_CONFIG_DEBUG_PRINTF) +extern void OS_DebugPrintf(uint32 Level, const char *Func, uint32 Line, const char *Format, ...); +/* Debug printfs are compiled in, but also can be disabled by a run-time flag. + * Note that the ##__VA_ARGS__ syntax works on GCC but might need tweaks for other compilers... */ +#define OS_DEBUG_LEV(l,...) OS_DebugPrintf(l, __func__, __LINE__, __VA_ARGS__); +#define OS_DEBUG(...) OS_DEBUG_LEV(1,__VA_ARGS__) +#else +/* Debug printfs are not compiled in at all */ +#define OS_DEBUG(...) +#endif + + + +#endif /* INCLUDE_OSAPI_SHARED_GLOBALDEFS_H_ */ + diff --git a/src/os/shared/inc/osapi-sockets-impl.h b/src/os/shared/inc/osapi-sockets-impl.h index d583c77f7..5a3fe6173 100644 --- a/src/os/shared/inc/osapi-sockets-impl.h +++ b/src/os/shared/inc/osapi-sockets-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_SOCKETS_H_ #define INCLUDE_OSAPI_SOCKETS_H_ -#include +#include /* * Sockets API abstraction layer @@ -163,14 +163,11 @@ int32 OS_SocketAddrGetPort_Impl(uint16 *PortNum, const OS_SockAddr_t *Addr); ------------------------------------------------------------------*/ int32 OS_SocketAddrSetPort_Impl(OS_SockAddr_t *Addr, uint16 PortNum); -/* jphfix clean up this dependency */ -#include - /* * Internal helper functions * Not normally called outside the local unit, except during unit test */ -void OS_CreateSocketName(OS_stream_internal_record_t *sock, const OS_SockAddr_t *Addr, const char *parent_name); +void OS_CreateSocketName(uint32 local_id, const OS_SockAddr_t *Addr, const char *parent_name); #endif /* INCLUDE_OSAPI_SOCKETS_H_ */ diff --git a/src/os/shared/inc/osapi-task-impl.h b/src/os/shared/inc/osapi-task-impl.h index ed2c45161..0d8efcfeb 100644 --- a/src/os/shared/inc/osapi-task-impl.h +++ b/src/os/shared/inc/osapi-task-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_TASK_H_ #define INCLUDE_OSAPI_TASK_H_ -#include +#include /*tasks */ typedef struct diff --git a/src/os/shared/inc/osapi-time-impl.h b/src/os/shared/inc/osapi-time-impl.h index 25b234d9a..e4a08bd92 100644 --- a/src/os/shared/inc/osapi-time-impl.h +++ b/src/os/shared/inc/osapi-time-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_TIME_H_ #define INCLUDE_OSAPI_TIME_H_ -#include +#include #define TIMECB_FLAG_DEDICATED_TIMEBASE 0x1 diff --git a/src/os/shared/inc/osapi-timebase-impl.h b/src/os/shared/inc/osapi-timebase-impl.h index 1398cdf54..b6785727a 100644 --- a/src/os/shared/inc/osapi-timebase-impl.h +++ b/src/os/shared/inc/osapi-timebase-impl.h @@ -21,7 +21,7 @@ #ifndef INCLUDE_OSAPI_TIMEBASE_H_ #define INCLUDE_OSAPI_TIMEBASE_H_ -#include +#include typedef struct diff --git a/src/os/shared/src/osapi-binsem.c b/src/os/shared/src/osapi-binsem.c index a44eaf990..205d7244d 100644 --- a/src/os/shared/src/osapi-binsem.c +++ b/src/os/shared/src/osapi-binsem.c @@ -32,7 +32,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-binsem-impl.h" +#include "osapi-idmap-impl.h" /* * Sanity checks on the user-supplied configuration diff --git a/src/os/shared/src/osapi-clock.c b/src/os/shared/src/osapi-clock.c index 523043b27..e927d362d 100644 --- a/src/os/shared/src/osapi-clock.c +++ b/src/os/shared/src/osapi-clock.c @@ -32,7 +32,7 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-clock-impl.h" /*---------------------------------------------------------------- diff --git a/src/os/shared/src/osapi-common.c b/src/os/shared/src/osapi-common.c index c7f2b96bb..41cf8ffc6 100644 --- a/src/os/shared/src/osapi-common.c +++ b/src/os/shared/src/osapi-common.c @@ -34,7 +34,22 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-binsem-impl.h" +#include "osapi-common-impl.h" +#include "osapi-countsem-impl.h" +#include "osapi-dir-impl.h" +#include "osapi-file-impl.h" +#include "osapi-filesys-impl.h" +#include "osapi-idmap-impl.h" +#include "osapi-module-impl.h" +#include "osapi-mutex-impl.h" +#include "osapi-network-impl.h" +#include "osapi-printf-impl.h" +#include "osapi-queue-impl.h" +#include "osapi-sockets-impl.h" +#include "osapi-task-impl.h" +#include "osapi-timebase-impl.h" +#include "osapi-time-impl.h" OS_SharedGlobalVars_t OS_SharedGlobalVars = { @@ -43,6 +58,9 @@ OS_SharedGlobalVars_t OS_SharedGlobalVars = .ShutdownFlag = 0, .MicroSecPerTick = 0, /* invalid, _must_ be set by implementation init */ .TicksPerSecond = 0, /* invalid, _must_ be set by implementation init */ +#if defined(OSAL_CONFIG_DEBUG_PRINTF) + .DebugLevel = 1, +#endif }; /* diff --git a/src/os/shared/src/osapi-countsem.c b/src/os/shared/src/osapi-countsem.c index 4cffacd83..0862c92da 100644 --- a/src/os/shared/src/osapi-countsem.c +++ b/src/os/shared/src/osapi-countsem.c @@ -32,7 +32,9 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-countsem-impl.h" +#include "osapi-idmap-impl.h" + /* * Sanity checks on the user-supplied configuration diff --git a/src/os/shared/src/osapi-debug.c b/src/os/shared/src/osapi-debug.c new file mode 100644 index 000000000..303d0fbdf --- /dev/null +++ b/src/os/shared/src/osapi-debug.c @@ -0,0 +1,63 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + + +/** + * \file osapi-debug.c + * \ingroup shared + * \author joseph.p.hickey@nasa.gov + * + * Contains the implementation for OS_DEBUG(). + * + * This is only compiled in when OSAL_CONFIG_DEBUG_PRINTF is enabled. + */ + +/**************************************************************************************** + INCLUDE FILES + ***************************************************************************************/ +#include +#include +#include +#include + + +/* + * User defined include files + */ +#include "osapi-shared-globaldefs.h" +#include "osapi-common-impl.h" + +#define OS_DEBUG_OUTPUT_STREAM stdout + + + +/*---------------------------------------------------------------- + * + * Function: OS_DebugPrintf + * + * Purpose: Outputs a single debug statement to the console + * + *-----------------------------------------------------------------*/ +void OS_DebugPrintf(uint32 Level, const char *Func, uint32 Line, const char *Format, ...) +{ + va_list va; + + if (OS_SharedGlobalVars.DebugLevel >= Level) + { + va_start(va, Format); + fprintf(OS_DEBUG_OUTPUT_STREAM, "%s():%d:",Func,Line); + vfprintf(OS_DEBUG_OUTPUT_STREAM, Format, va); + va_end(va); + } + +} /* end OS_DebugPrintf */ + diff --git a/src/os/shared/src/osapi-dir.c b/src/os/shared/src/osapi-dir.c index 96c4370d6..f158b9143 100644 --- a/src/os/shared/src/osapi-dir.c +++ b/src/os/shared/src/osapi-dir.c @@ -32,7 +32,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-dir-impl.h" +#include "osapi-idmap-impl.h" /* diff --git a/src/os/shared/src/osapi-errors.c b/src/os/shared/src/osapi-errors.c index dc04ff997..a82ee01ce 100644 --- a/src/os/shared/src/osapi-errors.c +++ b/src/os/shared/src/osapi-errors.c @@ -31,7 +31,7 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-errors-impl.h" /** * Global error name table diff --git a/src/os/shared/src/osapi-file.c b/src/os/shared/src/osapi-file.c index 9dfd6189c..d9e2dca23 100644 --- a/src/os/shared/src/osapi-file.c +++ b/src/os/shared/src/osapi-file.c @@ -31,7 +31,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-file-impl.h" +#include "osapi-idmap-impl.h" /* diff --git a/src/os/shared/src/osapi-filesys.c b/src/os/shared/src/osapi-filesys.c index 8b10aec2e..e9339187e 100644 --- a/src/os/shared/src/osapi-filesys.c +++ b/src/os/shared/src/osapi-filesys.c @@ -33,7 +33,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-filesys-impl.h" +#include "osapi-idmap-impl.h" enum { diff --git a/src/os/shared/src/osapi-heap.c b/src/os/shared/src/osapi-heap.c index a33fe9f1d..0e940b983 100644 --- a/src/os/shared/src/osapi-heap.c +++ b/src/os/shared/src/osapi-heap.c @@ -32,7 +32,7 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-heap-impl.h" diff --git a/src/os/shared/src/osapi-idmap.c b/src/os/shared/src/osapi-idmap.c index cfd82e4c3..e3984f383 100644 --- a/src/os/shared/src/osapi-idmap.c +++ b/src/os/shared/src/osapi-idmap.c @@ -45,7 +45,9 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-common-impl.h" +#include "osapi-idmap-impl.h" +#include "osapi-task-impl.h" typedef enum { diff --git a/src/os/shared/src/osapi-interrupts.c b/src/os/shared/src/osapi-interrupts.c index a06524344..052dbee20 100644 --- a/src/os/shared/src/osapi-interrupts.c +++ b/src/os/shared/src/osapi-interrupts.c @@ -32,7 +32,7 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-interrupts-impl.h" #ifndef OSAL_OMIT_DEPRECATED /* Remove file and remove from build when deleted */ /* Optionally remove from sources once source selection is in cmake options */ diff --git a/src/os/shared/src/osapi-module.c b/src/os/shared/src/osapi-module.c index c66fe8e0e..4632835d1 100644 --- a/src/os/shared/src/osapi-module.c +++ b/src/os/shared/src/osapi-module.c @@ -31,7 +31,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-module-impl.h" +#include "osapi-idmap-impl.h" /* * Sanity checks on the user-supplied configuration diff --git a/src/os/shared/src/osapi-mutex.c b/src/os/shared/src/osapi-mutex.c index f1e5bfd9d..4f0ca888a 100644 --- a/src/os/shared/src/osapi-mutex.c +++ b/src/os/shared/src/osapi-mutex.c @@ -32,7 +32,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-idmap-impl.h" +#include "osapi-mutex-impl.h" /* diff --git a/src/os/shared/src/osapi-network.c b/src/os/shared/src/osapi-network.c index 948adec9b..337e775d4 100644 --- a/src/os/shared/src/osapi-network.c +++ b/src/os/shared/src/osapi-network.c @@ -31,7 +31,7 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-network-impl.h" /**************************************************************************************** diff --git a/src/os/shared/src/osapi-no-module.c b/src/os/shared/src/osapi-no-module.c deleted file mode 100644 index 9c2b715f3..000000000 --- a/src/os/shared/src/osapi-no-module.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * - * Copyright (c) 2020, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - * - */ - - -/** - * \file osapi-no-module.c - * \ingroup shared - * \author joseph.p.hickey@nasa.gov - * - * This file contains some of the OS APIs abstraction layer code - * that is shared/common across all OS-specific implementations. - */ - -/**************************************************************************************** - INCLUDE FILES - ***************************************************************************************/ -#include -#include -#include -#include - -/* - * User defined include files - */ -#include "osapi-shared-internal.h" - -/* - * Sanity checks on the user-supplied configuration - * The relevent OS_MAX limit should be defined - * - * OS_MAX_MODULES is allowed to be zero in which case the - * table is not instantiated. - */ -#if !defined(OS_MAX_MODULES) || (OS_MAX_MODULES < 0) -#error "osconfig.h must define OS_MAX_ to a valid value" -#endif - - -enum -{ - LOCAL_NUM_OBJECTS = OS_MAX_MODULES, - LOCAL_OBJID_TYPE = OS_OBJECT_TYPE_OS_MODULE -}; - -/* - * Only instantiate the "OS_module_table" if - * OS_MAX_MODULES configuration is greater than 0. - * It is allowed to be zero on statically linked apps. - */ -#if (OS_MAX_MODULES > 0) -OS_module_internal_record_t OS_module_table[OS_MAX_MODULES]; -#endif - -/* - * If the "OS_STATIC_LOADER" directive is enabled, - * then the user application/BSP must provide a symbol - * called "OS_STATIC_SYMBOL_TABLE" which will provide - * user-defined mappings of symbol names to addresses. - * - * Note - when compiling unit tests, the UT code will - * supply a custom definition for OS_STATIC_SYMTABLE_SOURCE - */ -#if !defined(OS_STATIC_SYMTABLE_SOURCE) && defined(OSAL_CONFIG_INCLUDE_STATIC_LOADER) -/* use default symbol name for static table */ -#define OS_STATIC_SYMTABLE_SOURCE OS_STATIC_SYMBOL_TABLE -#endif - -#ifdef OS_STATIC_SYMTABLE_SOURCE -/* the BSP should supply the static symbol table when this is set */ -extern OS_static_symbol_record_t OS_STATIC_SYMTABLE_SOURCE[]; -#else -/* there is no static symbol table, use NULL */ -#define OS_STATIC_SYMTABLE_SOURCE NULL -#endif /* OS_STATIC_SYMTABLE_SOURCE */ - -/*---------------------------------------------------------------- - * - * Function: OS_SymbolLookup_Static - * - * Purpose: Local helper routine, not part of OSAL API. - * Checks for a symbol name in the static symbol table - * - *-----------------------------------------------------------------*/ -static int32 OS_SymbolLookup_Static(cpuaddr *SymbolAddress, const char *SymbolName) -{ - int32 return_code = OS_ERR_NOT_IMPLEMENTED; - OS_static_symbol_record_t *StaticSym = OS_STATIC_SYMTABLE_SOURCE; - - while (StaticSym != NULL) - { - if (StaticSym->Name == NULL) - { - /* end of list -- - * Return "OS_ERROR" to indicate that an actual search was done - * with a not-found result, vs. not searching at all. */ - return_code = OS_ERROR; - break; - } - if (strcmp(StaticSym->Name, SymbolName) == 0) - { - /* found matching symbol */ - *SymbolAddress = (cpuaddr)StaticSym->Address; - return_code = OS_SUCCESS; - break; - } - - ++StaticSym; - } - - return return_code; -} /* end OS_SymbolLookup_Static */ - - -/*---------------------------------------------------------------- - * - * Function: OS_ModuleLoad_Static - * - * Purpose: Local helper routine, not part of OSAL API. - * Checks for a module name in the static symbol table - * - *-----------------------------------------------------------------*/ -static int32 OS_ModuleLoad_Static(const char *ModuleName) -{ - int32 return_code = OS_ERR_NAME_NOT_FOUND; - OS_static_symbol_record_t *StaticSym = OS_STATIC_SYMTABLE_SOURCE; - - while (StaticSym != NULL) - { - if (StaticSym->Name == NULL) - { - /* end of list */ - break; - } - if (StaticSym->Module != NULL && - strcmp(StaticSym->Module, ModuleName) == 0) - { - /* found matching module name */ - return_code = OS_SUCCESS; - break; - } - - ++StaticSym; - } - - return return_code; -} /* end OS_ModuleLoad_Static */ - -/**************************************************************************************** - Module API - ***************************************************************************************/ - - -/*---------------------------------------------------------------- - * - * Function: OS_ModuleAPI_Init - * - * Purpose: Local helper routine, not part of OSAL API. - * Init function for OS-independent layer - * - *-----------------------------------------------------------------*/ -int32 OS_ModuleAPI_Init(void) -{ -#if (OS_MAX_MODULES > 0) - memset(OS_module_table, 0, sizeof(OS_module_table)); -#endif - return OS_SUCCESS; -} /* end OS_ModuleAPI_Init */ - - -/*---------------------------------------------------------------- - * - * Function: OS_ModuleLoad - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *filename ) -{ - char translated_path[OS_MAX_LOCAL_PATH_LEN]; - int32 return_code; - uint32 local_id; - OS_common_record_t *record; - - /* - ** Check parameters - */ - if (( filename == NULL ) || (module_id == NULL ) || (module_name == NULL)) - { - return(OS_INVALID_POINTER); - } - - if (strlen(module_name) >= OS_MAX_API_NAME) - { - return(OS_ERR_NAME_TOO_LONG); - } - - /* - * Check the statically-linked module list. - * If a matching entry is found, this means its - * already effectively "loaded" through static linkage. - * Return success without any more action. - */ - return_code = OS_ModuleLoad_Static(module_name); - if (return_code == OS_SUCCESS) - { - *module_id = 0; - return OS_SUCCESS; - } - - /* - ** Translate the filename to the Host System - */ - return_code = OS_TranslatePath(filename, translated_path); - if ( return_code != OS_SUCCESS ) - { - return(return_code); - } - - /* Note - the common ObjectIdAllocate routine will lock the object type and leave it locked. */ - return_code = OS_ObjectIdAllocateNew(LOCAL_OBJID_TYPE, module_name, &local_id, &record); - if(return_code == OS_SUCCESS) - { - /* - * Save all the data to our own internal module table, but - * only if OS_MAX_MODULES is greater than 0 - */ -#if (OS_MAX_MODULES > 0) - memset(&OS_module_table[local_id], 0, sizeof(OS_module_internal_record_t)); - strncpy(OS_module_table[local_id].module_name, module_name, OS_MAX_API_NAME); - strncpy(OS_module_table[local_id].file_name, filename, OS_MAX_PATH_LEN); - record->name_entry = OS_module_table[local_id].module_name; - - /* Now call the OS-specific implementation. This reads info from the module table. */ - return_code = OS_ModuleLoad_Impl(local_id, translated_path); -#endif - - /* Check result, finalize record, and unlock global table. */ - return_code = OS_ObjectIdFinalizeNew(return_code, record, module_id); - } - - return(return_code); - -} /* end OS_ModuleLoad */ - -/*---------------------------------------------------------------- - * - * Function: OS_ModuleUnload - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_ModuleUnload ( uint32 module_id ) -{ - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_EXCLUSIVE,LOCAL_OBJID_TYPE, module_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - /* - * Only call the implementation if the loader is enabled - */ - return_code = OS_ModuleUnload_Impl(local_id); - - if (return_code == OS_SUCCESS) - { - /* Clear the ID to zero */ - record->active_id = 0; - } - - /* Unlock the global from OS_ObjectIdGetAndLock() */ - OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE); - } - - return return_code; -} /* end OS_ModuleUnload */ - -/*---------------------------------------------------------------- - * - * Function: OS_ModuleInfo - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_ModuleInfo ( uint32 module_id, OS_module_prop_t *module_prop ) -{ - OS_common_record_t *record; - int32 return_code; - uint32 local_id; - - /* Check parameters */ - if (module_prop == NULL) - { - return OS_INVALID_POINTER; - } - - memset(module_prop,0,sizeof(OS_module_prop_t)); - - return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL,LOCAL_OBJID_TYPE, module_id, &local_id, &record); - if (return_code == OS_SUCCESS) - { - -#if (OS_MAX_MODULES > 0) - strncpy(module_prop->name, record->name_entry, OS_MAX_API_NAME - 1); - strncpy(module_prop->filename, OS_module_table[local_id].file_name, OS_MAX_API_NAME - 1); - /* module_prop->creator = record->creator; */ - - return_code = OS_ModuleGetInfo_Impl(local_id, module_prop); -#endif - - OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE); - } - - return return_code; - -} /* end OS_ModuleInfo */ - - -/*---------------------------------------------------------------- - * - * Function: OS_SymbolLookup - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SymbolLookup( cpuaddr *SymbolAddress, const char *SymbolName ) -{ - int32 return_code; - int32 status; - - /* - ** Check parameters - */ - if (( SymbolAddress == NULL ) || (SymbolName == NULL )) - { - return(OS_INVALID_POINTER); - } - - /* - * if the module loader is included, then call the - * OS symbol lookup implementation function first. - */ - return_code = OS_SymbolLookup_Impl(SymbolAddress, SymbolName); - - /* - * If the OS call did not find the symbol or the loader is - * disabled, then check if a static symbol table is present - */ - if (return_code != OS_SUCCESS) - { - status = OS_SymbolLookup_Static(SymbolAddress, SymbolName); - - /* - * NOTE: - * The OS_ERR_NOT_IMPLEMENTED code should only be returned - * if _neither_ the SymbolLookup_Impl _nor_ the static table - * lookup capabilities are implemented. - * - * If either of these are implemented then the returned - * value should be OS_ERROR for a not-found result. - */ - if (status == OS_SUCCESS || - return_code == OS_ERR_NOT_IMPLEMENTED) - { - return_code = status; - } - } - - return (return_code); - -} /* end OS_SymbolLookup */ - -/*---------------------------------------------------------------- - * - * Function: OS_SymbolTableDump - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SymbolTableDump ( const char *filename, uint32 SizeLimit ) -{ - int32 return_code; - char translated_path[OS_MAX_LOCAL_PATH_LEN]; - - /* - ** Check parameters - */ - if (filename == NULL) - { - return(OS_INVALID_POINTER); - } - - /* - ** Translate the filename to the Host System - */ - return_code = OS_TranslatePath(filename, translated_path); - if ( return_code != OS_SUCCESS ) - { - return(return_code); - } - - - /* - * Locking the global ensures only one symbol table dump - * can be executing. It also prevents module loading/unloading - * while the dump is occurring. - * - * Because calls to this function are serialized, the - * underlying implementation may safely use globals for - * state storage. - */ - OS_Lock_Global_Impl(LOCAL_OBJID_TYPE); - - return_code = OS_SymbolTableDump_Impl(translated_path, SizeLimit); - - OS_Unlock_Global_Impl(LOCAL_OBJID_TYPE); - - return(return_code); - -} /* end OS_SymbolTableDump */ - - - diff --git a/src/os/shared/src/osapi-no-network.c b/src/os/shared/src/osapi-no-network.c deleted file mode 100644 index 81cae0aba..000000000 --- a/src/os/shared/src/osapi-no-network.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * Copyright (c) 2020, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - * - */ - - -/** - * \file osapi-no-network.c - * \ingroup shared - * \author joseph.p.hickey@nasa.gov - * - * This file contains some of the OS APIs abstraction layer code - * that is shared/common across all OS-specific implementations. - */ - -/**************************************************************************************** - INCLUDE FILES - ***************************************************************************************/ -#include -#include -#include - - -/* - * User defined include files - */ -#include "osapi-shared-internal.h" - - -/**************************************************************************************** - NETWORK API - ***************************************************************************************/ - -/*---------------------------------------------------------------- - * - * Function: OS_NetworkAPI_Init - * - * Purpose: Local helper routine, not part of OSAL API. - * - *-----------------------------------------------------------------*/ -int32 OS_NetworkAPI_Init(void) -{ - return OS_SUCCESS; -} /* end OS_NetworkAPI_Init */ - - - -/*---------------------------------------------------------------- - * - * Function: OS_NetworkGetHostName - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_NetworkGetHostName (char *host_name, uint32 name_len) -{ - uint32 return_code; - - if ( host_name == NULL) - { - return_code = OS_INVALID_POINTER; - } - else if ( name_len == 0 ) - { - return_code = OS_ERROR; - } - else - { - /* delegate to low-level API */ - return_code = OS_NetworkGetHostName_Impl(host_name, name_len); - - if (return_code != OS_SUCCESS) - { - /* return an empty string on failure, just in case */ - host_name[0] = 0; - } - } - - return(return_code); -} /* end OS_NetworkGetHostName */ - - - - -/*---------------------------------------------------------------- - * - * Function: OS_NetworkGetID - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_NetworkGetID (void) -{ - int32 IdBuf; - - /* always delegate to low-level API */ - if (OS_NetworkGetID_Impl(&IdBuf) != OS_SUCCESS) - { - /* return a hardcoded value on failure */ - return (-1); - } - - return IdBuf; - -} /* end OS_NetworkGetID */ - - diff --git a/src/os/shared/src/osapi-no-sockets.c b/src/os/shared/src/osapi-no-sockets.c deleted file mode 100644 index 28a96f799..000000000 --- a/src/os/shared/src/osapi-no-sockets.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * - * Copyright (c) 2020, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - * - */ - - -/** - * \file osapi-no-sockets.c - * \ingroup shared - * \author joseph.p.hickey@nasa.gov - * - * This file contains some of the OS APIs abstraction layer code - * that is shared/common across all OS-specific implementations. - * - * All functions in this file return OS_ERR_NOT_IMPLEMENTED. This source - * is used in cases when the network functionality is disabled by config. - */ - -/**************************************************************************************** - INCLUDE FILES - ***************************************************************************************/ -#include -#include -#include -#include - - -/* - * User defined include files - */ -#include "osapi-shared-internal.h" - -/**************************************************************************************** - Init Functions - ***************************************************************************************/ - - -/*---------------------------------------------------------------- - * - * Function: OS_SocketAPI_Init - * - * Purpose: Local helper routine, not part of OSAL API. - * - *-----------------------------------------------------------------*/ -int32 OS_SocketAPI_Init(void) -{ - /* - * Placeholder - nothing right now - * also serves to make this a non-empty compilation unit for - * cases where OS_INCLUDE_NETWORK is off - */ - return OS_SUCCESS; -} /* end OS_SocketAPI_Init */ - - -/*---------------------------------------------------------------- - * - * Function: OS_SocketOpen - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketOpen */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketBind - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketBind */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketAccept - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, int32 timeout) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketAccept */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketConnect - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketConnect(uint32 sock_id, const OS_SockAddr_t *Addr, int32 Timeout) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketConnect */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketRecvFrom - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketRecvFrom(uint32 sock_id, void *buffer, uint32 buflen, OS_SockAddr_t *RemoteAddr, int32 timeout) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketRecvFrom */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketSendTo - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketSendTo(uint32 sock_id, const void *buffer, uint32 buflen, const OS_SockAddr_t *RemoteAddr) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketSendTo */ - - -/*---------------------------------------------------------------- - * - * Function: OS_SocketGetIdByName - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketGetIdByName */ - - -/*---------------------------------------------------------------- - * - * Function: OS_SocketGetInfo - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketGetInfo (uint32 sock_id, OS_socket_prop_t *sock_prop) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketGetInfo */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketAddrInit - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketAddrInit */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketAddrToString - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketAddrToString(char *buffer, uint32 buflen, const OS_SockAddr_t *Addr) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketAddrToString */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketAddrFromString - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketAddrFromString */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketAddrGetPort - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketAddrGetPort */ - -/*---------------------------------------------------------------- - * - * Function: OS_SocketAddrSetPort - * - * Purpose: Implemented per public OSAL API - * See description in API and header file for detail - * - *-----------------------------------------------------------------*/ -int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) -{ - return OS_ERR_NOT_IMPLEMENTED; -} /* end OS_SocketAddrSetPort */ - diff --git a/src/os/shared/src/osapi-printf.c b/src/os/shared/src/osapi-printf.c index 3a74be4fe..7c4b04bc3 100644 --- a/src/os/shared/src/osapi-printf.c +++ b/src/os/shared/src/osapi-printf.c @@ -45,7 +45,10 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-common-impl.h" +#include "osapi-idmap-impl.h" +#include "osapi-printf-impl.h" + /* reserve buffer memory for the printf console device */ static char OS_printf_buffer_mem[(sizeof(OS_PRINTF_CONSOLE_NAME) + OS_BUFFER_SIZE) * OS_BUFFER_MSG_DEPTH]; @@ -86,7 +89,8 @@ int32 OS_ConsoleAPI_Init(void) console = &OS_console_table[local_id]; record->name_entry = console->device_name; - strcpy(console->device_name, OS_PRINTF_CONSOLE_NAME); + strncpy(console->device_name, OS_PRINTF_CONSOLE_NAME, sizeof(console->device_name)-1); + console->device_name[sizeof(console->device_name)-1] = 0; /* * Initialize the ring buffer pointers diff --git a/src/os/shared/src/osapi-queue.c b/src/os/shared/src/osapi-queue.c index fde733ada..3782945dd 100644 --- a/src/os/shared/src/osapi-queue.c +++ b/src/os/shared/src/osapi-queue.c @@ -36,8 +36,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" - +#include "osapi-queue-impl.h" +#include "osapi-idmap-impl.h" /* * Sanity checks on the user-supplied configuration diff --git a/src/os/shared/src/osapi-select.c b/src/os/shared/src/osapi-select.c index 979e4acba..fae4b52d7 100644 --- a/src/os/shared/src/osapi-select.c +++ b/src/os/shared/src/osapi-select.c @@ -35,7 +35,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-idmap-impl.h" +#include "osapi-select-impl.h" /* diff --git a/src/os/shared/src/osapi-shared-internal.h b/src/os/shared/src/osapi-shared-internal.h deleted file mode 100644 index bf796e9d7..000000000 --- a/src/os/shared/src/osapi-shared-internal.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * Copyright (c) 2020, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - * - */ - - -/** - * \file os-impl.h - * \ingroup shared - * \author joseph.p.hickey@nasa.gov - * - * Purpose: Contains functions prototype definitions and variables declarations - * for the OS Abstraction Layer, Core OS module - */ - -/* - * NOTE - CONVENTION WITHIN THIS LAYER: - * This file contains function prototypes and type declarations that define the - * interface between the OS-specific and the shared portions of the OSAPI. - * - * Functions that end in "_Impl" are _OS Specific_ and should be implemented - * within the appropriate OS-specific directory (i.e. posix, rtems, vxworks, etc) - * - * NONE of the functions or variables within this file are supposed to be public -- - * i.e. these are private to OSAL and not exposed to the code above this layer. - * - */ - -#ifndef INCLUDE_OS_IMPL_H_ -#define INCLUDE_OS_IMPL_H_ - - -#include "osapi.h" -#include "osapi-binsem-impl.h" -#include "osapi-clock-impl.h" -#include "osapi-common-impl.h" -#include "osapi-countsem-impl.h" -#include "osapi-dir-impl.h" -#include "osapi-errors-impl.h" -#include "osapi-file-impl.h" -#include "osapi-filesys-impl.h" -#include "osapi-fpu-impl.h" -#include "osapi-heap-impl.h" -#include "osapi-idmap-impl.h" -#include "osapi-interrupts-impl.h" -#include "osapi-module-impl.h" -#include "osapi-mutex-impl.h" -#include "osapi-network-impl.h" -#include "osapi-printf-impl.h" -#include "osapi-queue-impl.h" -#include "osapi-select-impl.h" -#include "osapi-sockets-impl.h" -#include "osapi-task-impl.h" -#include "osapi-timebase-impl.h" -#include "osapi-time-impl.h" - -/* - * Types shared between the implementations and shared code - */ - -/* - * OS_U32ValueWrapper_t must be equal in size to a "void*" as it is used in places - * where a void* argument is required. This compile-time assert ensures that. - * If this fails, then it means one of the types within the union is too large. - */ -CompileTimeAssert(sizeof(OS_U32ValueWrapper_t) == sizeof(void *), U32ValueWrapperSize); - -/**************************************************************************************** - INITIALIZATION FUNCTIONS - ****************************************************************************************/ - -/* - * Initialization functions for each of the common sub-layers - * These functions may or may not do anything, but the hook is provided nonetheless. - */ - - - -/********************* - END os-impl.h - *********************/ - -#endif /* INCLUDE_OS_IMPL_H_ */ - diff --git a/src/os/shared/src/osapi-sockets.c b/src/os/shared/src/osapi-sockets.c index 609581c45..c590b7cfe 100644 --- a/src/os/shared/src/osapi-sockets.c +++ b/src/os/shared/src/osapi-sockets.c @@ -33,7 +33,10 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-idmap-impl.h" +#include "osapi-file-impl.h" +#include "osapi-sockets-impl.h" + /* * Global data for the API @@ -78,10 +81,11 @@ int32 OS_SocketAPI_Init(void) * Purpose: Local helper routine, not part of OSAL API. * *-----------------------------------------------------------------*/ -void OS_CreateSocketName(OS_stream_internal_record_t *sock, const OS_SockAddr_t *Addr, const char *parent_name) +void OS_CreateSocketName(uint32 local_id, const OS_SockAddr_t *Addr, const char *parent_name) { int32 len; uint16 port; + OS_stream_internal_record_t *sock = &OS_stream_table[local_id]; if (OS_SocketAddrToString_Impl(sock->stream_name, OS_MAX_API_NAME, Addr) != OS_SUCCESS) { @@ -184,7 +188,7 @@ int32 OS_SocketBind(uint32 sock_id, const OS_SockAddr_t *Addr) if (return_code == OS_SUCCESS) { - OS_CreateSocketName(&OS_stream_table[local_id], Addr, NULL); + OS_CreateSocketName(local_id, Addr, NULL); record->name_entry = OS_stream_table[local_id].stream_name; OS_stream_table[local_id].stream_state |= OS_STREAM_STATE_BOUND; } @@ -274,7 +278,7 @@ int32 OS_SocketAccept(uint32 sock_id, uint32 *connsock_id, OS_SockAddr_t *Addr, if (return_code == OS_SUCCESS) { /* Generate an entry name based on the remote address */ - OS_CreateSocketName(&OS_stream_table[conn_id], Addr, record->name_entry); + OS_CreateSocketName(conn_id, Addr, record->name_entry); connrecord->name_entry = OS_stream_table[conn_id].stream_name; OS_stream_table[conn_id].stream_state |= OS_STREAM_STATE_CONNECTED; } diff --git a/src/os/shared/src/osapi-task.c b/src/os/shared/src/osapi-task.c index 907f771ea..c24425193 100644 --- a/src/os/shared/src/osapi-task.c +++ b/src/os/shared/src/osapi-task.c @@ -37,7 +37,8 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-task-impl.h" +#include "osapi-idmap-impl.h" /* diff --git a/src/os/shared/src/osapi-time.c b/src/os/shared/src/osapi-time.c index 6c5c23c03..91bcddacf 100644 --- a/src/os/shared/src/osapi-time.c +++ b/src/os/shared/src/osapi-time.c @@ -34,7 +34,12 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-common-impl.h" +#include "osapi-idmap-impl.h" +#include "osapi-timebase-impl.h" +#include "osapi-time-impl.h" +#include "osapi-task-impl.h" + /* * Sanity checks on the user-supplied configuration diff --git a/src/os/shared/src/osapi-timebase.c b/src/os/shared/src/osapi-timebase.c index a886adbe6..5b55de8c5 100644 --- a/src/os/shared/src/osapi-timebase.c +++ b/src/os/shared/src/osapi-timebase.c @@ -35,7 +35,11 @@ /* * User defined include files */ -#include "osapi-shared-internal.h" +#include "osapi-timebase-impl.h" +#include "osapi-common-impl.h" +#include "osapi-idmap-impl.h" +#include "osapi-task-impl.h" +#include "osapi-time-impl.h" /* diff --git a/src/os/vxworks/CMakeLists.txt b/src/os/vxworks/CMakeLists.txt index e59f29e40..0379ad640 100644 --- a/src/os/vxworks/CMakeLists.txt +++ b/src/os/vxworks/CMakeLists.txt @@ -13,11 +13,13 @@ set(VXWORKS_BASE_SRCLIST src/os-impl-common.c src/os-impl-console.c src/os-impl-countsem.c + src/os-impl-errors.c src/os-impl-dirs.c src/os-impl-files.c src/os-impl-filesys.c src/os-impl-fpu.c src/os-impl-heap.c + src/os-impl-idmap.c src/os-impl-interrupts.c src/os-impl-mutex.c src/os-impl-queues.c diff --git a/src/os/vxworks/inc/os-vxworks.h b/src/os/vxworks/inc/os-vxworks.h index 35d009dd5..91da2de98 100644 --- a/src/os/vxworks/inc/os-vxworks.h +++ b/src/os/vxworks/inc/os-vxworks.h @@ -35,10 +35,7 @@ #include #include -#include "common_types.h" -#include "osapi.h" -#include "osapi-common-impl.h" -#include "osapi-idmap-impl.h" +#include /**************************************************************************************** @@ -88,5 +85,7 @@ int32 OS_VxWorks_GenericSemTake(SEM_ID vxid, int sys_ticks); int32 OS_VxWorks_GenericSemGive(SEM_ID vxid); +int32 OS_VxWorks_TableMutex_Init(uint32 idtype); + #endif /* INCLUDE_OS_VXWORKS_H_ */ diff --git a/src/os/vxworks/src/os-impl-binsem.c b/src/os/vxworks/src/os-impl-binsem.c index e87ab7a88..112b07fe7 100644 --- a/src/os/vxworks/src/os-impl-binsem.c +++ b/src/os/vxworks/src/os-impl-binsem.c @@ -25,7 +25,6 @@ #include "os-impl-binsem.h" #include "osapi-binsem-impl.h" -#include "osapi-common-impl.h" /**************************************************************************************** DEFINES diff --git a/src/os/vxworks/src/os-impl-common.c b/src/os/vxworks/src/os-impl-common.c index 0e66838fd..f8de95e82 100644 --- a/src/os/vxworks/src/os-impl-common.c +++ b/src/os/vxworks/src/os-impl-common.c @@ -24,7 +24,6 @@ #include "os-vxworks.h" #include "osapi-common-impl.h" -#include "osapi-errors-impl.h" #include #include @@ -43,106 +42,6 @@ static TASK_ID OS_idle_task_id; -VX_MUTEX_SEMAPHORE(OS_task_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_queue_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_bin_sem_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_mutex_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_count_sem_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_stream_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_dir_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_timebase_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_module_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_filesys_table_mut_mem); -VX_MUTEX_SEMAPHORE(OS_console_mut_mem); - -VxWorks_GlobalMutex_t VX_MUTEX_TABLE[] = -{ - [OS_OBJECT_TYPE_UNDEFINED] = { NULL }, - [OS_OBJECT_TYPE_OS_TASK] = { .mem = OS_task_table_mut_mem }, - [OS_OBJECT_TYPE_OS_QUEUE] = { .mem = OS_queue_table_mut_mem }, - [OS_OBJECT_TYPE_OS_COUNTSEM] = { .mem = OS_count_sem_table_mut_mem }, - [OS_OBJECT_TYPE_OS_BINSEM] = { .mem = OS_bin_sem_table_mut_mem }, - [OS_OBJECT_TYPE_OS_MUTEX] = { .mem = OS_mutex_table_mut_mem }, - [OS_OBJECT_TYPE_OS_STREAM] = { .mem = OS_stream_table_mut_mem }, - [OS_OBJECT_TYPE_OS_DIR] = { .mem = OS_dir_table_mut_mem }, - [OS_OBJECT_TYPE_OS_TIMEBASE] = { .mem = OS_timebase_table_mut_mem }, - [OS_OBJECT_TYPE_OS_MODULE] = { .mem = OS_module_table_mut_mem }, - [OS_OBJECT_TYPE_OS_FILESYS] = { .mem = OS_filesys_table_mut_mem }, - [OS_OBJECT_TYPE_OS_CONSOLE] = { .mem = OS_console_mut_mem }, -}; - -enum -{ - VX_MUTEX_TABLE_SIZE = (sizeof(VX_MUTEX_TABLE) / sizeof(VX_MUTEX_TABLE[0])) -}; - -const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = { { 0, NULL } }; - -/*---------------------------------------------------------------- - * - * Function: OS_Lock_Global_Impl - * - * Purpose: Implemented per internal OSAL API - * See prototype in os-impl.h for argument/return detail - * - *-----------------------------------------------------------------*/ -int32 OS_Lock_Global_Impl(uint32 idtype) -{ - VxWorks_GlobalMutex_t *mut; - - if (idtype >= VX_MUTEX_TABLE_SIZE) - { - return OS_ERROR; - } - - mut = &VX_MUTEX_TABLE[idtype]; - if (mut->vxid == (SEM_ID)0) - { - return OS_ERROR; - } - - if (semTake(mut->vxid, WAIT_FOREVER) != OK) - { - OS_DEBUG("semTake() - vxWorks errno %d\n",errno); - return OS_ERROR; - } - - return OS_SUCCESS; -} /* end OS_Lock_Global_Impl */ - -/*---------------------------------------------------------------- - * - * Function: OS_Unlock_Global_Impl - * - * Purpose: Implemented per internal OSAL API - * See prototype in os-impl.h for argument/return detail - * - *-----------------------------------------------------------------*/ -int32 OS_Unlock_Global_Impl(uint32 idtype) -{ - VxWorks_GlobalMutex_t *mut; - - if (idtype >= VX_MUTEX_TABLE_SIZE) - { - return OS_ERROR; - } - - mut = &VX_MUTEX_TABLE[idtype]; - if (mut->vxid == (SEM_ID)0) - { - return OS_ERROR; - } - - if (semGive(mut->vxid) != OK) - { - OS_DEBUG("semGive() - vxWorks errno %d\n",errno); - return OS_ERROR; - } - - return OS_SUCCESS; -} /* end OS_Unlock_Global_Impl */ - - /**************************************************************************************** INITIALIZATION FUNCTION @@ -158,63 +57,48 @@ int32 OS_Unlock_Global_Impl(uint32 idtype) *-----------------------------------------------------------------*/ int32 OS_API_Impl_Init(uint32 idtype) { - int32 return_code = OS_SUCCESS; - SEM_ID semid; + int32 return_code; - do - { - /* Initialize the table mutex for the given idtype */ - if (idtype < VX_MUTEX_TABLE_SIZE && VX_MUTEX_TABLE[idtype].mem != NULL) - { - semid = semMInitialize (VX_MUTEX_TABLE[idtype].mem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); - - if ( semid == (SEM_ID)0 ) - { - OS_DEBUG("Error: semMInitialize() failed - vxWorks errno %d\n",errno); - return_code = OS_ERROR; - break; - } - - VX_MUTEX_TABLE[idtype].vxid = semid; - } - - switch(idtype) - { - case OS_OBJECT_TYPE_OS_TASK: - return_code = OS_VxWorks_TaskAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_QUEUE: - return_code = OS_VxWorks_QueueAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_BINSEM: - return_code = OS_VxWorks_BinSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_COUNTSEM: - return_code = OS_VxWorks_CountSemAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MUTEX: - return_code = OS_VxWorks_MutexAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_MODULE: - return_code = OS_VxWorks_ModuleAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_TIMEBASE: - return_code = OS_VxWorks_TimeBaseAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_STREAM: - return_code = OS_VxWorks_StreamAPI_Impl_Init(); - break; - case OS_OBJECT_TYPE_OS_DIR: - return_code = OS_VxWorks_DirAPI_Impl_Init(); - break; - default: - break; - } - } - while (0); + return_code = OS_VxWorks_TableMutex_Init(idtype); + if (return_code != OS_SUCCESS) + { + return return_code; + } + switch(idtype) + { + case OS_OBJECT_TYPE_OS_TASK: + return_code = OS_VxWorks_TaskAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_QUEUE: + return_code = OS_VxWorks_QueueAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_BINSEM: + return_code = OS_VxWorks_BinSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_COUNTSEM: + return_code = OS_VxWorks_CountSemAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MUTEX: + return_code = OS_VxWorks_MutexAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_MODULE: + return_code = OS_VxWorks_ModuleAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_TIMEBASE: + return_code = OS_VxWorks_TimeBaseAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_STREAM: + return_code = OS_VxWorks_StreamAPI_Impl_Init(); + break; + case OS_OBJECT_TYPE_OS_DIR: + return_code = OS_VxWorks_DirAPI_Impl_Init(); + break; + default: + break; + } - return(return_code); + return(return_code); } /* end OS_API_Impl_Init */ @@ -226,7 +110,7 @@ int32 OS_API_Impl_Init(uint32 idtype) * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -void OS_IdleLoop_Impl() +void OS_IdleLoop_Impl(void) { TASK_ID tid = taskIdSelf(); OS_idle_task_id = tid; @@ -242,7 +126,7 @@ void OS_IdleLoop_Impl() * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -void OS_ApplicationShutdown_Impl() +void OS_ApplicationShutdown_Impl(void) { taskResume(OS_idle_task_id); } /* end OS_ApplicationShutdown_Impl */ diff --git a/src/os/vxworks/src/os-impl-console.c b/src/os/vxworks/src/os-impl-console.c index 0198e8f75..b14f4c917 100644 --- a/src/os/vxworks/src/os-impl-console.c +++ b/src/os/vxworks/src/os-impl-console.c @@ -25,7 +25,6 @@ #include "os-impl-console.h" #include "osapi-printf-impl.h" -#include "osapi-common-impl.h" /**************************************************************************************** DEFINES diff --git a/src/os/vxworks/src/os-impl-errors.c b/src/os/vxworks/src/os-impl-errors.c new file mode 100644 index 000000000..cc7c491b5 --- /dev/null +++ b/src/os/vxworks/src/os-impl-errors.c @@ -0,0 +1,36 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + + +/** + * \file os-impl-errors.c + * \ingroup vxworks + * \author joseph.p.hickey@nasa.gov + * + */ +/**************************************************************************************** + INCLUDE FILES +****************************************************************************************/ + +#include "os-vxworks.h" +#include "osapi-errors-impl.h" + +/**************************************************************************************** + DEFINES +****************************************************************************************/ + +/**************************************************************************************** + GLOBAL DATA +****************************************************************************************/ + +const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = { { 0, NULL } }; + diff --git a/src/os/vxworks/src/os-impl-filesys.c b/src/os/vxworks/src/os-impl-filesys.c index 0dd96d007..9e606be35 100644 --- a/src/os/vxworks/src/os-impl-filesys.c +++ b/src/os/vxworks/src/os-impl-filesys.c @@ -26,7 +26,6 @@ #include "os-impl-filesys.h" #include "osapi-filesys-impl.h" -#include "osapi-common-impl.h" #include "osapi-idmap-impl.h" diff --git a/src/os/vxworks/src/os-impl-idmap.c b/src/os/vxworks/src/os-impl-idmap.c new file mode 100644 index 000000000..fffef4537 --- /dev/null +++ b/src/os/vxworks/src/os-impl-idmap.c @@ -0,0 +1,174 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + */ + + +/** + * \file os-impl-common.c + * \ingroup vxworks + * \author joseph.p.hickey@nasa.gov + * + */ +/**************************************************************************************** + INCLUDE FILES +****************************************************************************************/ + +#include "os-vxworks.h" +#include "osapi-idmap-impl.h" + +#include +#include +#include +#include + +/**************************************************************************************** + DEFINES +****************************************************************************************/ + +/**************************************************************************************** + GLOBAL DATA +****************************************************************************************/ + +VX_MUTEX_SEMAPHORE(OS_task_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_queue_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_bin_sem_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_mutex_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_count_sem_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_stream_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_dir_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_timebase_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_module_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_filesys_table_mut_mem); +VX_MUTEX_SEMAPHORE(OS_console_mut_mem); + +VxWorks_GlobalMutex_t VX_MUTEX_TABLE[] = +{ + [OS_OBJECT_TYPE_UNDEFINED] = { NULL }, + [OS_OBJECT_TYPE_OS_TASK] = { .mem = OS_task_table_mut_mem }, + [OS_OBJECT_TYPE_OS_QUEUE] = { .mem = OS_queue_table_mut_mem }, + [OS_OBJECT_TYPE_OS_COUNTSEM] = { .mem = OS_count_sem_table_mut_mem }, + [OS_OBJECT_TYPE_OS_BINSEM] = { .mem = OS_bin_sem_table_mut_mem }, + [OS_OBJECT_TYPE_OS_MUTEX] = { .mem = OS_mutex_table_mut_mem }, + [OS_OBJECT_TYPE_OS_STREAM] = { .mem = OS_stream_table_mut_mem }, + [OS_OBJECT_TYPE_OS_DIR] = { .mem = OS_dir_table_mut_mem }, + [OS_OBJECT_TYPE_OS_TIMEBASE] = { .mem = OS_timebase_table_mut_mem }, + [OS_OBJECT_TYPE_OS_MODULE] = { .mem = OS_module_table_mut_mem }, + [OS_OBJECT_TYPE_OS_FILESYS] = { .mem = OS_filesys_table_mut_mem }, + [OS_OBJECT_TYPE_OS_CONSOLE] = { .mem = OS_console_mut_mem }, +}; + +enum +{ + VX_MUTEX_TABLE_SIZE = (sizeof(VX_MUTEX_TABLE) / sizeof(VX_MUTEX_TABLE[0])) +}; + +/*---------------------------------------------------------------- + * + * Function: OS_Lock_Global_Impl + * + * Purpose: Implemented per internal OSAL API + * See prototype in os-impl.h for argument/return detail + * + *-----------------------------------------------------------------*/ +int32 OS_Lock_Global_Impl(uint32 idtype) +{ + VxWorks_GlobalMutex_t *mut; + + if (idtype >= VX_MUTEX_TABLE_SIZE) + { + return OS_ERROR; + } + + mut = &VX_MUTEX_TABLE[idtype]; + if (mut->vxid == (SEM_ID)0) + { + return OS_ERROR; + } + + if (semTake(mut->vxid, WAIT_FOREVER) != OK) + { + OS_DEBUG("semTake() - vxWorks errno %d\n",errno); + return OS_ERROR; + } + + return OS_SUCCESS; +} /* end OS_Lock_Global_Impl */ + +/*---------------------------------------------------------------- + * + * Function: OS_Unlock_Global_Impl + * + * Purpose: Implemented per internal OSAL API + * See prototype in os-impl.h for argument/return detail + * + *-----------------------------------------------------------------*/ +int32 OS_Unlock_Global_Impl(uint32 idtype) +{ + VxWorks_GlobalMutex_t *mut; + + if (idtype >= VX_MUTEX_TABLE_SIZE) + { + return OS_ERROR; + } + + mut = &VX_MUTEX_TABLE[idtype]; + if (mut->vxid == (SEM_ID)0) + { + return OS_ERROR; + } + + if (semGive(mut->vxid) != OK) + { + OS_DEBUG("semGive() - vxWorks errno %d\n",errno); + return OS_ERROR; + } + + return OS_SUCCESS; +} /* end OS_Unlock_Global_Impl */ + + + +/**************************************************************************************** + INITIALIZATION FUNCTION +****************************************************************************************/ + +/*---------------------------------------------------------------- + * + * Function: OS_VxWorks_TableMutex_Init + * + * Purpose: Initialize the tables that the OS API uses to keep track of information + * about objects + * + *-----------------------------------------------------------------*/ +int32 OS_VxWorks_TableMutex_Init(uint32 idtype) +{ + int32 return_code = OS_SUCCESS; + SEM_ID semid; + + /* Initialize the table mutex for the given idtype */ + if (idtype < VX_MUTEX_TABLE_SIZE && VX_MUTEX_TABLE[idtype].mem != NULL) + { + semid = semMInitialize (VX_MUTEX_TABLE[idtype].mem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); + + if ( semid == (SEM_ID)0 ) + { + OS_DEBUG("Error: semMInitialize() failed - vxWorks errno %d\n",errno); + return_code = OS_ERROR; + } + else + { + VX_MUTEX_TABLE[idtype].vxid = semid; + } + } + + return(return_code); +} /* end OS_VxWorks_TableMutex_Init */ + diff --git a/src/os/vxworks/src/os-impl-mutex.c b/src/os/vxworks/src/os-impl-mutex.c index 55bde15c3..b24cd204d 100644 --- a/src/os/vxworks/src/os-impl-mutex.c +++ b/src/os/vxworks/src/os-impl-mutex.c @@ -25,7 +25,6 @@ #include "os-impl-mutex.h" #include "osapi-mutex-impl.h" -#include "osapi-common-impl.h" #include diff --git a/src/os/vxworks/src/os-impl-tasks.c b/src/os/vxworks/src/os-impl-tasks.c index 4460baeab..b6867531c 100644 --- a/src/os/vxworks/src/os-impl-tasks.c +++ b/src/os/vxworks/src/os-impl-tasks.c @@ -25,7 +25,6 @@ #include "os-impl-tasks.h" #include "osapi-task-impl.h" -#include "osapi-common-impl.h" #include "osapi-idmap-impl.h" #include diff --git a/src/os/vxworks/src/os-impl-timebase.c b/src/os/vxworks/src/os-impl-timebase.c index 74c321329..ac84f176a 100644 --- a/src/os/vxworks/src/os-impl-timebase.c +++ b/src/os/vxworks/src/os-impl-timebase.c @@ -24,6 +24,9 @@ #include "os-vxworks.h" #include "os-impl-timebase.h" + +#include "osapi-common-impl.h" +#include "osapi-idmap-impl.h" #include "osapi-timebase-impl.h" #include diff --git a/src/unit-test-coverage/portable/CMakeLists.txt b/src/unit-test-coverage/portable/CMakeLists.txt deleted file mode 100644 index f4ec53e33..000000000 --- a/src/unit-test-coverage/portable/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# CMake snippet for building the shared OSAL layer coverage tests - -set(MODULE_LIST - #bsd-select - #bsd-sockets - #console-bsp - #no-loader - #no-network - #no-sockets - #no-symtab - #posix-dirs - #posix-dl-loader - #posix-dl-symtab - posix-files - posix-gettime - posix-io - #posix-network -) - -# This unit test is allowed to directly include any internal file in -# the respective set under test. - -# The "ut-stubs" contains additional stubs specific to this sub-module -#jphfix add_subdirectory(ut-stubs) -#add_subdirectory(adaptors) - -# Add all coverage tests in the src dir -foreach(MODNAME ${MODULE_LIST}) - add_coverage_testrunner( - "coverage-${SETNAME}-${MODNAME}" - "${OSAL_SOURCE_DIR}/src/os/${SETNAME}/os-impl-${MODNAME}.c" - "${CMAKE_CURRENT_SOURCE_DIR}/src/coveragetest-${MODNAME}.c" - ut-adaptor-${SETNAME} - ) -endforeach(MODNAME ${MODULE_LIST}) - -#jphfix -#set(MODULE_LINK_MAP_posixio osfileapi) -#set(MODULE_LINK_MAP_posixfile osfileapi) -#set(MODULE_LINK_MAP_printf osapi) -#set(MODULE_LINK_MAP_posixgettime ostimer) - -#add_coverage_tests(${SETNAME} ${MODULE_LIST}) - diff --git a/src/unit-test-coverage/portable/adaptors/CMakeLists.txt b/src/unit-test-coverage/portable/adaptors/CMakeLists.txt deleted file mode 100644 index 529818a5e..000000000 --- a/src/unit-test-coverage/portable/adaptors/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (c) 2019, United States government as represented by the -# administrator of the National Aeronautics Space Administration. -# All rights reserved. This software was created at NASA Goddard -# Space Flight Center pursuant to government contracts. -# -# This is governed by the NASA Open Source Agreement and may be used, -# distributed and modified only according to the terms of that agreement. -# - - -# "Adaptors" help enable the unit test code to reach functions/objects that -# are otherwise not exposed. This is generally required for any OSAL subsystem -# which tracks an internal resource state (i.e. anything with a table). - -# NOTE: These source files are compile with OVERRIDES on the headers just like -# the FSW code is compiled. This is how it is able to include internal headers -# which otherwise would fail. But that also means that adaptor code cannot call -# any library functions, as this would also reach a stub, not the real function. - -add_library(ut-adaptor-${SETNAME} STATIC - #src/ut-adaptor-bsd-select.c - #src/ut-adaptor-bsd-sockets.c - #src/ut-adaptor-console-bsp.c - #src/ut-adaptor-no-loader.c - #src/ut-adaptor-no-network.c - #src/ut-adaptor-no-sockets.c - #src/ut-adaptor-no-symtab.c - #src/ut-adaptor-posix-dirs.c - #src/ut-adaptor-posix-dl-loader.c - #src/ut-adaptor-posix-dl-symtab.c - src/ut-adaptor-posix-files.c - src/ut-adaptor-posix-gettime.c - src/ut-adaptor-posix-io.c - #src/ut-adaptor-posix-network.c -) - -# the "override_inc" dir contains replacement versions of the C-library include files. -target_include_directories(ut-adaptor-${SETNAME} PRIVATE - ${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/override_inc -) - -target_include_directories(ut-adaptor-${SETNAME} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/inc -) diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c index 04a148d7c..315a779db 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-files.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-files.c @@ -164,6 +164,7 @@ void Test_OS_FileRename_Impl (void) void Osapi_Test_Setup(void) { UT_ResetState(0); + memset(OS_stream_table, 0, sizeof(OS_stream_table)); } /* diff --git a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c index 0af216132..ec3f1a95d 100644 --- a/src/unit-test-coverage/portable/src/coveragetest-posix-io.c +++ b/src/unit-test-coverage/portable/src/coveragetest-posix-io.c @@ -22,6 +22,7 @@ #include "ut-adaptor-portable-posix-io.h" #include "osapi-file-impl.h" +#include "osapi-idmap-impl.h" #include "osapi-select-impl.h" #include @@ -137,6 +138,8 @@ void Test_OS_GenericWrite_Impl(void) void Osapi_Test_Setup(void) { UT_ResetState(0); + memset(OS_stream_table, 0, sizeof(OS_stream_table)); + memset(OS_global_stream_table, 0, sizeof(OS_common_record_t) * OS_MAX_NUM_OPEN_FILES); } /* diff --git a/src/unit-test-coverage/portable/src/os-portable-coveragetest.h b/src/unit-test-coverage/portable/src/os-portable-coveragetest.h index 0965910f8..c2ed2b9c8 100644 --- a/src/unit-test-coverage/portable/src/os-portable-coveragetest.h +++ b/src/unit-test-coverage/portable/src/os-portable-coveragetest.h @@ -31,6 +31,8 @@ #include +#include "osapi-shared-globaldefs.h" + #define OSAPI_TEST_FUNCTION_RC(func,args,exp) \ { \ diff --git a/src/unit-test-coverage/shared/modules_removed/CMakeLists.txt b/src/unit-test-coverage/shared/modules_removed/CMakeLists.txt deleted file mode 100644 index 4cd649bbd..000000000 --- a/src/unit-test-coverage/shared/modules_removed/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (c) 2019, United States government as represented by the -# administrator of the National Aeronautics Space Administration. -# All rights reserved. This software was created at NASA Goddard -# Space Flight Center pursuant to government contracts. -# -# This is governed by the NASA Open Source Agreement and may be used, -# distributed and modified only according to the terms of that agreement. -# - -# -------------------------------------- -# OSAL SHARED LAYER FOR COVERAGE TESTING -# -------------------------------------- - -# This CMake recipe snippet builds the _actual_ OSAL shared API (not a stub) -# However it differs from the regular non-UT build in the following ways: -# - Each sub-module is compiled to a separate "OBJECT" library -# this simplifies the testrunner linking by allow only one specific -# object file to be linked into each test -# - Each sub-module is wrapped to divert C library calls to the -# stub (OCS) counterpart -# - UT_COVERAGE_COMPILE_FLAGS are enabled to include any code coverage instrumentation - -# the "override_inc" dir contains replacement versions of the C-library include files. -include_directories(${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/inc) -include_directories(${OSALCOVERAGE_SOURCE_DIR}/ut-stubs/override_inc) - -foreach(MODULE ${MODULE_LIST}) - if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/ut-osapi-${MODULE}.c) - add_library(ut_${SETNAME}_${MODULE} OBJECT - src/ut-osapi-${MODULE}.c - ) - target_compile_options(ut_${SETNAME}_${MODULE} PRIVATE - ${UT_COVERAGE_COMPILE_FLAGS} - ) - endif () -endforeach() - diff --git a/src/unit-test-coverage/shared/modules_removed/Makefile b/src/unit-test-coverage/shared/modules_removed/Makefile deleted file mode 100644 index dc2e1ae13..000000000 --- a/src/unit-test-coverage/shared/modules_removed/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -# -# Makefile for ut osal -# - -# -# INCLUDES specifies the search paths for include files outside of the current directory. -# Note that the -I is required. -# -INCLUDES += -I./inc -INCLUDES += -I../ut-stubs/inc -INCLUDES += -I$(OSAL)/src/os/inc -INCLUDES += -I$(OSAL)/build/inc -INCLUDES += -I$(OSAL)/src - - -# -# UT_OBJS specifies unit test object files. -# -UT_OBJS := osapi.o -UT_OBJS += osfileapi.o -UT_OBJS += osfilesys.o -UT_OBJS += osloader.o -UT_OBJS += osnetwork.o -UT_OBJS += ostimer.o - -############################################################################### - -COMPILER=gcc -LINKER=ld - -# -# Compiler and Linker Options -# -ENABLE_GCOV = TRUE -ifeq ($(ENABLE_GCOV), TRUE) -GCOV_COPT = --coverage -GCOV_LOPT = --coverage -endif - -#WARNINGS = -Wall -W -ansi -Werror -Wstrict-prototypes -Wundef -WARNINGS = -Wall -Wstrict-prototypes -DEBUGGER = -g - -COPT = $(WARNINGS) $(DEBUGGER) $(GCOV_COPT) -DOSAPI_NO_SPECIAL_ATTRIBS -DSOFTWARE_LITTLE_BIT_ORDER -D_EL -D_ix86_ $(OSAL_M32) - -LOPT = $(GCOV_LOPT) $(OSAL_M32) - -############################################################################### -## "C" COMPILER RULE -## -%.o: src/%.c - $(COMPILER) -c $(COPT) $(INCLUDES) $< - -############################################################################## -## - -all: $(UT_OBJS) - -clean :: - rm -f *.o *.exe *.gcda *.gcno *.gcov gmon.out - -gcov :: - @echo - @gcov -b $(UT_OBJS:.o=.gcda) | \ - awk -f $(OSAL)/build/gcov-parse.awk - @rm -f *.gcda *.gcno - @echo - -# end of file - diff --git a/src/unit-test-coverage/shared/modules_removed/README.txt b/src/unit-test-coverage/shared/modules_removed/README.txt deleted file mode 100644 index 0b40586c3..000000000 --- a/src/unit-test-coverage/shared/modules_removed/README.txt +++ /dev/null @@ -1,38 +0,0 @@ -UT-OSAL README FILE -=================== - -The objective here is to build the OSAL source code but with all calls/references to the underlying -OS remapped to "stub" implementations and/or local definitions of those identifiers. - -The "inc" subdirectory includes empty files for _ALL_ of the header files included by the OSAL source -code. The "inc" subdirectory is in the compiler search path so these empty files will be used in -place of the real system header file. THIS IS THE ONLY PLACE WHERE THESE EMPTY STUBS SHOULD BE -USED IN PLACE OF THE REAL FILE. - -Two exceptions are made: - - maps to the real one, so we have accurate fixed-width types. - - -The paradigm used here: -- Each source file in OSAL has a wrapper here with the same name. - -- First the wrapper includes a header with any "extra" logic that the test case needs to add - This is optional and used in cases where the test needs access to static/private data structures. - -- Then the wrapper #include's "stub-map-to-real.h" - This is an important file that has #define macros that map all identifiers typically supplied - by the C library to one with a "VCS_" prefix. For example, "strcmp" will become "VCS_strcmp". - -- Then it #include's the unmodified OSAL source code, adding that exact code into the same compilation - unit, with the stub-remap macros in place. - - In the same example as above, all calls to "strcmp()" (a library function) will become calls to - "VCS_strcmp" with the same arguments. The implementation of VCS_strcmp() is provided by the test case. - -- Finally the implementation for any "extra" logic is directly implmemented in the wrapper file. - Because this is in the same compilation unit as the OSAL source code, it can access variables that - are defined "static". IMPORTANT: The implementation of these wrappers will also have all stub-mapping - active, so these must avoid using C library calls as they will NOT go to the C library. - - - \ No newline at end of file diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-binsem.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-binsem.h deleted file mode 100644 index 79e97b105..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-binsem.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_BINSEM_H_ -#define _OSAL_UT_OSAPI_BINSEM_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_BINSEM_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-clock.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-clock.h deleted file mode 100644 index 3cb39bbdc..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-clock.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_CLOCK_H_ -#define _OSAL_UT_OSAPI_CLOCK_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_CLOCK_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-common.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-common.h deleted file mode 100644 index df24cee6a..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-common.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_COMMON_H_ -#define _OSAL_UT_OSAPI_COMMON_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_COMMON_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-countsem.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-countsem.h deleted file mode 100644 index 78a0b98b3..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-countsem.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_COUNTSEM_H_ -#define _OSAL_UT_OSAPI_COUNTSEM_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_COUNTSEM_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-dir.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-dir.h deleted file mode 100644 index 3b8c82012..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-dir.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_DIR_H_ -#define _OSAL_UT_OSAPI_DIR_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_DIR_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-errors.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-errors.h deleted file mode 100644 index 529055de4..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-errors.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_ERRORS_H_ -#define _OSAL_UT_OSAPI_ERRORS_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_ERRORS_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-file.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-file.h deleted file mode 100644 index b6ef1d13f..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-file.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_FILE_H_ -#define _OSAL_UT_OSAPI_FILE_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_FILE_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-filesys.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-filesys.h deleted file mode 100644 index c8e38974b..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-filesys.h +++ /dev/null @@ -1,29 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_FILESYS_H_ -#define _OSAL_UT_OSAPI_FILESYS_H_ - -#include -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - -bool Osapi_Internal_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_record_t *obj); -int32 Osapi_Internal_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, const OS_VolumeInfo_t *Vol); - - -#endif /* _OSAL_UT_OSAPI_FILESYS_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-fpu.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-fpu.h deleted file mode 100644 index f35e5fa2d..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-fpu.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_FPU_H_ -#define _OSAL_UT_OSAPI_FPU_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_FPU_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-heap.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-heap.h deleted file mode 100644 index 4c19b5ebe..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-heap.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_HEAP_H_ -#define _OSAL_UT_OSAPI_HEAP_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_HEAP_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-idmap.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-idmap.h deleted file mode 100644 index 09717c307..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-idmap.h +++ /dev/null @@ -1,38 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_IDMAP_H_ -#define _OSAL_UT_OSAPI_IDMAP_H_ - -#include -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - -/** - * Wrapper around the OS_ObjectIdFindNext call so the test code can invoke it - * (it is defined as static) - */ -int32 Osapi_Call_ObjectIdFindNext(uint32 idtype, uint32 *array_index, OS_common_record_t **record); - -/** - * Wrapper around the OS_ObjectIdConvertLock call so the test code can invoke it - * (it is defined as static) - */ -int32 Osapi_Call_ObjectIdConvertLock(OS_lock_mode_t lock_mode, uint32 idtype, uint32 reference_id, OS_common_record_t *obj); - - -#endif /* _OSAL_UT_OSAPI_IDMAP_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-interrupts.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-interrupts.h deleted file mode 100644 index c735c77ed..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-interrupts.h +++ /dev/null @@ -1,24 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_INTERRUPTS_H_ -#define _OSAL_UT_OSAPI_INTERRUPTS_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - -#endif /* _OSAL_UT_OSAPI_INTERRUPTS_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-module.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-module.h deleted file mode 100644 index 60dbb8b2d..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-module.h +++ /dev/null @@ -1,5 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ - -#endif /* _OSAL_UT_OSAPI_MODULE_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-mutex.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-mutex.h deleted file mode 100644 index 2663c0ea8..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-mutex.h +++ /dev/null @@ -1,24 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_MUTEX_H_ -#define _OSAL_UT_OSAPI_MUTEX_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - -#endif /* _OSAL_UT_OSAPI_MUTEX_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-network.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-network.h deleted file mode 100644 index f746a3f8f..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-network.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_NETWORK_H_ -#define _OSAL_UT_OSAPI_NETWORK_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_NETWORK_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-printf.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-printf.h deleted file mode 100644 index cb3c5ae8c..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-printf.h +++ /dev/null @@ -1,26 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_PRINTF_H_ -#define _OSAL_UT_OSAPI_PRINTF_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_PRINTF_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-queue.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-queue.h deleted file mode 100644 index 8a3fcf2ad..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-queue.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_QUEUE_H_ -#define _OSAL_UT_OSAPI_QUEUE_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_QUEUE_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-select.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-select.h deleted file mode 100644 index 556a083b2..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-select.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_SELECT_H_ -#define _OSAL_UT_OSAPI_SELECT_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_SELECT_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-sockets.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-sockets.h deleted file mode 100644 index fec3c5ce4..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-sockets.h +++ /dev/null @@ -1,31 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_SOCKETS_H_ -#define _OSAL_UT_OSAPI_SOCKETS_H_ - -#include -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - -/** - * Invoke the OS_CreateSocketName() static helper function - */ -void Osapi_Call_CreateSocketName_Static(OS_stream_internal_record_t *sock, - const OS_SockAddr_t *Addr, const char *parent_name); - -#endif /* _OSAL_UT_OSAPI_SOCKETS_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-task.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-task.h deleted file mode 100644 index b9ebb95f2..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-task.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_TASK_H_ -#define _OSAL_UT_OSAPI_TASK_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_TASK_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-time.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-time.h deleted file mode 100644 index 81bec46f0..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-time.h +++ /dev/null @@ -1,26 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_TIME_H_ -#define _OSAL_UT_OSAPI_TIME_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_TIME_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-timebase.h b/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-timebase.h deleted file mode 100644 index 885822679..000000000 --- a/src/unit-test-coverage/shared/modules_removed/inc/ut-osapi-timebase.h +++ /dev/null @@ -1,25 +0,0 @@ -/* OSAL coverage stub replacement for file mode bits - * this file is shared by several UT replacement headers */ -#ifndef _OSAL_UT_OSAPI_TIMEBASE_H_ -#define _OSAL_UT_OSAPI_TIMEBASE_H_ - -#include - -/***************************************************** - * - * UT FUNCTION PROTOTYPES - * - * These are functions that need to be invoked by UT - * but are not exposed directly through the implementation API. - * - *****************************************************/ - -/** - * Purges all state tables and resets back to initial conditions - * Helps avoid cross-test dependencies - */ -void Osapi_Internal_ResetState(void); - - -#endif /* _OSAL_UT_OSAPI_TIMEBASE_H_ */ - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-binsem.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-binsem.c deleted file mode 100644 index 6839ead86..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-binsem.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-binsem.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-binsem.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-clock.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-clock.c deleted file mode 100644 index 30aab8328..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-clock.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-clock.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-clock.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-common.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-common.c deleted file mode 100644 index 1c6895c17..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-common.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-common.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-common.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-countsem.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-countsem.c deleted file mode 100644 index 951b86d67..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-countsem.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-countsem.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-countsem.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-dir.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-dir.c deleted file mode 100644 index 5c1d85ef5..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-dir.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-dir.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-dir.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-errors.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-errors.c deleted file mode 100644 index c106acd60..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-errors.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-errors.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-errors.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-file.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-file.c deleted file mode 100644 index cfd1f6c3c..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-file.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-file.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-file.c" - -/* - * Stub objects to satisfy linking requirements - - */ -OS_common_record_t OS_stub_file_table[OS_MAX_NUM_OPEN_FILES]; - -OS_common_record_t * const OS_global_stream_table = OS_stub_file_table; - -OS_SharedGlobalVars_t OS_SharedGlobalVars = - { - .Initialized = false - }; - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-filesys.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-filesys.c deleted file mode 100644 index eef3dd0cd..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-filesys.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-filesys.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-filesys.c" - -/* - * Stub objects to satisfy linking requirements - - */ -OS_common_record_t OS_stub_filesys_table[OS_MAX_FILE_SYSTEMS]; -OS_common_record_t OS_stub_stream_table[OS_MAX_NUM_OPEN_FILES]; -OS_common_record_t * const OS_global_filesys_table = OS_stub_filesys_table; -OS_common_record_t * const OS_global_stream_table = OS_stub_stream_table; - -OS_SharedGlobalVars_t OS_SharedGlobalVars = - { - .Initialized = false - }; - -/* - * Provide a wrapper so the UT can invoke OS_FileSys_FindVirtMountPoint() - */ -bool Osapi_Internal_FileSys_FindVirtMountPoint(void *ref, uint32 local_id, const OS_common_record_t *obj) -{ - return OS_FileSys_FindVirtMountPoint(ref, local_id, obj); -} - -/* - * Provide a wrapper so the UT can invoke OS_FileSys_InitLocalFromVolTable() - */ -int32 Osapi_Internal_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, const OS_VolumeInfo_t *Vol) -{ - return OS_FileSys_InitLocalFromVolTable(local, Vol); -} - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-fpu.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-fpu.c deleted file mode 100644 index 83a6f8074..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-fpu.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-fpu.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-fpu.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-heap.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-heap.c deleted file mode 100644 index 933af12e4..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-heap.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-heap.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-heap.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-idmap.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-idmap.c deleted file mode 100644 index 50ac5e041..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-idmap.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-idmap.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-idmap.c" - -OS_SharedGlobalVars_t OS_SharedGlobalVars = - { - .Initialized = false - }; - -int32 Osapi_Call_ObjectIdFindNext(uint32 idtype, uint32 *array_index, OS_common_record_t **record) -{ - return OS_ObjectIdFindNext(idtype, array_index, record); -} - -int32 Osapi_Call_ObjectIdConvertLock(OS_lock_mode_t lock_mode, uint32 idtype, uint32 reference_id, OS_common_record_t *obj) -{ - return OS_ObjectIdConvertLock(lock_mode, idtype, reference_id, obj); -} diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-interrupts.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-interrupts.c deleted file mode 100644 index 6a09c9036..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-interrupts.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-interrupts.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-interrupts.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-module.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-module.c deleted file mode 100644 index 9c8e266cf..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-module.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-module.h" - -/* - * The UT test case provides its own static symbol table - */ -#define OS_STATIC_SYMTABLE_SOURCE OS_UT_STATIC_SYMBOL_TABLE - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-module.c" - - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-mutex.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-mutex.c deleted file mode 100644 index b1679f380..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-mutex.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-mutex.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-mutex.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-network.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-network.c deleted file mode 100644 index 614adaf8b..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-network.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-network.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-network.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-printf.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-printf.c deleted file mode 100644 index 52f18eff9..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-printf.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-printf.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-printf.c" - -OS_common_record_t OS_stub_console_table[OS_MAX_TASKS]; -OS_common_record_t * const OS_global_console_table = OS_stub_console_table; - -OS_SharedGlobalVars_t OS_SharedGlobalVars = - { - .Initialized = false - }; - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-queue.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-queue.c deleted file mode 100644 index b75a1655b..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-queue.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-queue.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-queue.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-select.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-select.c deleted file mode 100644 index 08f3b1562..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-select.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-select.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-select.c" - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-sockets.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-sockets.c deleted file mode 100644 index 8a68e7516..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-sockets.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-sockets.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-sockets.c" - -/* Global variables to satisfy external link symbols */ -OS_stream_internal_record_t OS_stream_table[OS_MAX_NUM_OPEN_FILES]; -OS_common_record_t OS_stub_socket_table[OS_MAX_NUM_OPEN_FILES]; -OS_common_record_t * const OS_global_stream_table = OS_stub_socket_table; - -void Osapi_Call_CreateSocketName_Static(OS_stream_internal_record_t *sock, const OS_SockAddr_t *Addr, const char *parent_name) -{ - OS_CreateSocketName(sock, Addr, parent_name); -} - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-task.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-task.c deleted file mode 100644 index 09fc647da..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-task.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-task.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-task.c" - -/* Stub objects to satisfy linking requirements - - */ -OS_common_record_t OS_stub_task_table[OS_MAX_TASKS]; -OS_common_record_t * const OS_global_task_table = OS_stub_task_table; diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-time.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-time.c deleted file mode 100644 index 74ec80abe..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-time.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-time.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-time.c" - - -/* Stub objects to satisfy linking requirements - - * the time module may look up entities in the timebase table - */ -OS_timebase_internal_record_t OS_timebase_table[OS_MAX_TIMEBASES]; -OS_common_record_t OS_stub_timebase_table[OS_MAX_TIMEBASES]; -OS_common_record_t OS_stub_timecb_table[OS_MAX_TIMERS]; - -OS_common_record_t * const OS_global_timebase_table = OS_stub_timebase_table; -OS_common_record_t * const OS_global_timecb_table = OS_stub_timecb_table; - -OS_SharedGlobalVars_t OS_SharedGlobalVars = - { - .Initialized = false - }; - diff --git a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-timebase.c b/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-timebase.c deleted file mode 100644 index 0c17797a2..000000000 --- a/src/unit-test-coverage/shared/modules_removed/src/ut-osapi-timebase.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019, United States government as represented by the - * administrator of the National Aeronautics Space Administration. - * All rights reserved. This software was created at NASA Goddard - * Space Flight Center pursuant to government contracts. - * - * This is governed by the NASA Open Source Agreement and may be used, - * distributed and modified only according to the terms of that agreement. - */ - -/* pull in the OSAL configuration */ -#include "osconfig.h" -#include "ut-osapi-timebase.h" - -/* - * Now include all extra logic required to stub-out subsequent calls to - * library functions and replace with our own - */ -#include "osapi-timebase.c" - -/* Stub objects to satisfy linking requirements - - * the time module may look up entities in the timebase table - */ -OS_timecb_internal_record_t OS_timecb_table[OS_MAX_TIMERS]; -OS_common_record_t OS_stub_timebase_table[OS_MAX_TIMEBASES]; -OS_common_record_t OS_stub_timecb_table[OS_MAX_TIMERS]; - -OS_common_record_t * const OS_global_timebase_table = OS_stub_timebase_table; -OS_common_record_t * const OS_global_timecb_table = OS_stub_timecb_table; - - -OS_SharedGlobalVars_t OS_SharedGlobalVars = - { - .Initialized = false - }; - diff --git a/src/unit-test-coverage/shared/src/coveragetest-file.c b/src/unit-test-coverage/shared/src/coveragetest-file.c index d0c79c3e2..5dad35b2e 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-file.c +++ b/src/unit-test-coverage/shared/src/coveragetest-file.c @@ -24,6 +24,7 @@ #include "os-shared-coveragetest.h" #include "osapi-file-impl.h" +#include "osapi-idmap-impl.h" #include @@ -466,6 +467,8 @@ void Test_OS_ShellOutputToFile(void) void Osapi_Test_Setup(void) { UT_ResetState(0); + memset(OS_stream_table, 0, sizeof(OS_stream_table)); + memset(OS_global_stream_table, 0, sizeof(OS_common_record_t) * OS_MAX_NUM_OPEN_FILES); } /* diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index de0bdcd9f..ab6197ef8 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -24,6 +24,7 @@ #include "os-shared-coveragetest.h" #include "osapi-idmap-impl.h" +#include "osapi-common-impl.h" #include @@ -558,7 +559,7 @@ void Test_OS_ObjectIdAllocateNew(void) * This test case mainly focuses on additional error checking */ int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; //OS_ObjectIdAllocate(); + int32 actual = ~OS_SUCCESS; uint32 objid = 0xFFFFFFFF; OS_common_record_t *rptr = NULL; @@ -652,8 +653,16 @@ void Test_OS_ForEachObject(void) void Osapi_Test_Setup(void) { UT_ResetState(0); + /* for sanity also clear out the task table, which is used by several test cases */ memset(OS_global_task_table, 0, OS_MAX_TASKS * sizeof(OS_common_record_t)); + + /* + * The OS_SharedGlobalVars is also used here, but set the + * "Initialized" field to true by default, as this is needed by most tests. + */ + memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); + OS_SharedGlobalVars.Initialized = true; } /* diff --git a/src/unit-test-coverage/shared/src/coveragetest-printf.c b/src/unit-test-coverage/shared/src/coveragetest-printf.c index 920f5779b..d92c9ae9f 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-printf.c +++ b/src/unit-test-coverage/shared/src/coveragetest-printf.c @@ -24,6 +24,7 @@ #include "os-shared-coveragetest.h" #include "osapi-printf-impl.h" +#include "osapi-common-impl.h" #include @@ -104,6 +105,7 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); memset(OS_console_table, 0, sizeof(OS_console_table)); + memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); OS_console_table[0].BufBase = TestConsoleBuffer; OS_console_table[0].BufSize = sizeof(TestConsoleBuffer); } diff --git a/src/unit-test-coverage/shared/src/coveragetest-sockets.c b/src/unit-test-coverage/shared/src/coveragetest-sockets.c index 515427182..18da66c9f 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-sockets.c +++ b/src/unit-test-coverage/shared/src/coveragetest-sockets.c @@ -24,6 +24,8 @@ #include "os-shared-coveragetest.h" #include "osapi-sockets-impl.h" +#include "osapi-idmap-impl.h" +#include "osapi-file-impl.h" #include @@ -54,19 +56,16 @@ void Test_OS_CreateSocketName(void) * * This focuses on coverage paths, as this function does not return a value */ - OS_stream_internal_record_t testrec; OS_SockAddr_t testaddr; - memset(&testrec, 'x', sizeof(testrec)); - memset(&testaddr, 0, sizeof(testaddr)); UT_SetForceFail(UT_KEY(OS_SocketAddrToString_Impl), OS_ERROR); - OS_CreateSocketName(&testrec, &testaddr, "ut"); + OS_CreateSocketName(0, &testaddr, "ut"); /* * The function should have called snprintf() to create the name */ UtAssert_True(UT_GetStubCount(UT_KEY(OCS_snprintf)) == 2, "OS_CreateSocketName() invoked snprintf()"); - UtAssert_True(testrec.stream_name[0] != 'x', "OS_CreateSocketName() set stream name"); + UtAssert_True(OS_stream_table[0].stream_name[0] != 'x', "OS_CreateSocketName() set stream name"); } /***************************************************************************** @@ -463,6 +462,8 @@ void Test_OS_SocketAddr (void) void Osapi_Test_Setup(void) { UT_ResetState(0); + memset(OS_stream_table, 0, sizeof(OS_stream_table)); + memset(OS_global_stream_table, 0, sizeof(OS_common_record_t) * OS_MAX_NUM_OPEN_FILES); } /* diff --git a/src/unit-test-coverage/shared/src/coveragetest-timebase.c b/src/unit-test-coverage/shared/src/coveragetest-timebase.c index 167bc977f..fc499750a 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/shared/src/coveragetest-timebase.c @@ -27,6 +27,7 @@ #include "osapi-timebase-impl.h" #include "osapi-time-impl.h" #include "osapi-task-impl.h" +#include "osapi-common-impl.h" #include diff --git a/src/unit-test-coverage/shared/src/os-shared-coveragetest.h b/src/unit-test-coverage/shared/src/os-shared-coveragetest.h index 278683c51..8baf49fe8 100644 --- a/src/unit-test-coverage/shared/src/os-shared-coveragetest.h +++ b/src/unit-test-coverage/shared/src/os-shared-coveragetest.h @@ -16,7 +16,7 @@ #include #include -#include "osapi-common-impl.h" +//jphfix #include "osapi-common-impl.h" #include "osapi-idmap-impl.h" /* diff --git a/src/unit-test-coverage/ut-stubs/CMakeLists.txt b/src/unit-test-coverage/ut-stubs/CMakeLists.txt index cbf5d1903..a1a26a9c6 100644 --- a/src/unit-test-coverage/ut-stubs/CMakeLists.txt +++ b/src/unit-test-coverage/ut-stubs/CMakeLists.txt @@ -81,12 +81,26 @@ target_include_directories(ut_libc_stubs PUBLIC # OSAL calls used by or implemented by the shared layer. These # are not public API calls. This is only compiled if used. add_library(ut_osapi_impl_stubs STATIC EXCLUDE_FROM_ALL - src/osapi-base-impl-stubs.c - src/osapi-file-impl-stubs.c - src/osapi-filesys-impl-stubs.c - src/osapi-loader-impl-stubs.c + src/osapi-binsem-impl-stubs.c + src/osapi-common-impl-stubs.c + src/osapi-console-impl-stubs.c + src/osapi-countsem-impl-stubs.c + src/osapi-error-impl-stubs.c + src/osapi-file-impl-stubs.c + src/osapi-filesys-impl-stubs.c + src/osapi-fpu-impl-stubs.c + src/osapi-heap-impl-stubs.c + src/osapi-idmap-impl-stubs.c + src/osapi-loader-impl-stubs.c + src/osapi-mutex-impl-stubs.c src/osapi-network-impl-stubs.c - src/osapi-select-impl-stubs.c + src/osapi-queue-impl-stubs.c + src/osapi-select-impl-stubs.c + src/osapi-shared-common-stubs.c + src/osapi-shared-debug-stubs.c + src/osapi-shared-idmap-stubs.c + src/osapi-shared-objtable-stubs.c + src/osapi-task-impl-stubs.c src/osapi-timer-impl-stubs.c ) @@ -97,5 +111,6 @@ add_library(ut_osapi_shared_stubs STATIC EXCLUDE_FROM_ALL src/osapi-shared-common-stubs.c src/osapi-shared-idmap-stubs.c src/osapi-shared-objtable-stubs.c + src/osapi-shared-debug-stubs.c ) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c deleted file mode 100644 index ae2779101..000000000 --- a/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @file impl-stubs.c - * - * UT assert stubs for low-level implementation functions. - * These are prototyped in the "os-impl.h" file within the shared API - */ - -#include -#include -#include -#include - -#include "utstubs.h" - -#include "osapi-binsem-impl.h" -#include "osapi-clock-impl.h" -#include "osapi-common-impl.h" -#include "osapi-countsem-impl.h" -#include "osapi-dir-impl.h" -#include "osapi-errors-impl.h" -#include "osapi-file-impl.h" -#include "osapi-filesys-impl.h" -#include "osapi-fpu-impl.h" -#include "osapi-heap-impl.h" -#include "osapi-idmap-impl.h" -#include "osapi-interrupts-impl.h" -#include "osapi-module-impl.h" -#include "osapi-mutex-impl.h" -#include "osapi-network-impl.h" -#include "osapi-printf-impl.h" -#include "osapi-queue-impl.h" -#include "osapi-select-impl.h" -#include "osapi-sockets-impl.h" -#include "osapi-task-impl.h" -#include "osapi-timebase-impl.h" -#include "osapi-time-impl.h" - -const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = -{ - { -4444, "UT_ERROR" }, - { 0, NULL } -}; - - -UT_DEFAULT_STUB(OS_API_Impl_Init, (uint32 idtype)) - -void OS_IdleLoop_Impl (void) -{ - UT_DEFAULT_IMPL(OS_IdleLoop_Impl); -} - -void OS_ApplicationShutdown_Impl (void) -{ - UT_DEFAULT_IMPL(OS_ApplicationShutdown_Impl); -} - -/* -** Function prototypes for routines implemented in OS-specific layers -*/ - -/* - * Table locking and unlocking for global objects can be done at the shared code - * layer but the actual implementation is OS-specific - */ -UT_DEFAULT_STUB(OS_Lock_Global_Impl,(uint32 idtype)) -UT_DEFAULT_STUB(OS_Unlock_Global_Impl,(uint32 idtype)) - - - -/* -** Task API -*/ -UT_DEFAULT_STUB(OS_TaskMatch_Impl,(uint32 task_id)) -UT_DEFAULT_STUB(OS_TaskCreate_Impl,(uint32 task_id, uint32 flags)) -UT_DEFAULT_STUB(OS_TaskDelete_Impl,(uint32 task_id)) -void OS_TaskExit_Impl (void) -{ - UT_DEFAULT_IMPL(OS_TaskExit_Impl); -} - -UT_DEFAULT_STUB(OS_TaskDelay_Impl,(uint32 millisecond)) -UT_DEFAULT_STUB(OS_TaskSetPriority_Impl,(uint32 task_id, uint32 new_priority)) -uint32 OS_TaskGetId_Impl (void) -{ - return UT_DEFAULT_IMPL(OS_TaskGetId_Impl); -} -UT_DEFAULT_STUB(OS_TaskGetInfo_Impl,(uint32 task_id, OS_task_prop_t *task_prop)) -UT_DEFAULT_STUB(OS_TaskRegister_Impl,(uint32 global_task_id)) - -/* -** Message Queue API -*/ - -/* -** Queue Create now has the Queue ID returned to the caller. -*/ -UT_DEFAULT_STUB(OS_QueueCreate_Impl,(uint32 queue_id, uint32 flags)) -UT_DEFAULT_STUB(OS_QueueDelete_Impl,(uint32 queue_id)) -UT_DEFAULT_STUB(OS_QueueGet_Impl,(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout)) -UT_DEFAULT_STUB(OS_QueuePut_Impl,(uint32 queue_id, const void *data, uint32 size, uint32 flags)) -UT_DEFAULT_STUB(OS_QueueGetInfo_Impl,(uint32 queue_id, OS_queue_prop_t *queue_prop)) - -/* -** Semaphore API -*/ - -UT_DEFAULT_STUB(OS_BinSemCreate_Impl,(uint32 sem_id, uint32 sem_initial_value, uint32 options)) -UT_DEFAULT_STUB(OS_BinSemFlush_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemGive_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemTake_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemTimedWait_Impl,(uint32 sem_id, uint32 msecs)) -UT_DEFAULT_STUB(OS_BinSemDelete_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_BinSemGetInfo_Impl,(uint32 sem_id, OS_bin_sem_prop_t *bin_prop)) - -UT_DEFAULT_STUB(OS_CountSemCreate_Impl,(uint32 sem_id, uint32 sem_initial_value, uint32 options)) -UT_DEFAULT_STUB(OS_CountSemGive_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_CountSemTake_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_CountSemTimedWait_Impl,(uint32 sem_id, uint32 msecs)) -UT_DEFAULT_STUB(OS_CountSemDelete_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_CountSemGetInfo_Impl,(uint32 sem_id, OS_count_sem_prop_t *count_prop)) - -/* -** Mutex API -*/ - -UT_DEFAULT_STUB(OS_MutSemCreate_Impl,(uint32 sem_id, uint32 options)) -UT_DEFAULT_STUB(OS_MutSemGive_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_MutSemTake_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_MutSemDelete_Impl,(uint32 sem_id)) -UT_DEFAULT_STUB(OS_MutSemGetInfo_Impl,(uint32 sem_id, OS_mutex_prop_t *mut_prop)) - -/* -** Console output API (printf) -*/ -void OS_ConsoleWakeup_Impl(uint32 local_id) -{ - UT_DEFAULT_IMPL(OS_ConsoleWakeup_Impl); -} -int32 OS_ConsoleCreate_Impl(uint32 local_id) -{ - return UT_DEFAULT_IMPL(OS_ConsoleCreate_Impl); -} -void OS_ConsoleOutput_Impl(uint32 local_id) -{ - UT_DEFAULT_IMPL(OS_ConsoleOutput_Impl); -} - -#ifndef OSAL_OMIT_DEPRECATED -/* -** Shared memory API -*/ -UT_DEFAULT_STUB(OS_ShMemInit_Impl,(void)) -UT_DEFAULT_STUB(OS_ShMemCreate_Impl,(uint32 *Id, uint32 NBytes, char* SegName)) -UT_DEFAULT_STUB(OS_ShMemSemTake_Impl,(uint32 Id)) -UT_DEFAULT_STUB(OS_ShMemSemGive_Impl,(uint32 Id)) -UT_DEFAULT_STUB(OS_ShMemAttach_Impl,(uint32 * Address, uint32 Id)) -UT_DEFAULT_STUB(OS_ShMemGetIdByName_Impl,(uint32 *ShMemId, const char *SegName )) -#endif /* OSAL_OMIT_DEPRECATED */ - - -/* -** Call to exit the running application -** Normally embedded applications run forever, but for debugging purposes -** (unit testing for example) this is needed in order to end the test -*/ -void OS_ApplicationExit_Impl(int32 Status) -{ - UT_DEFAULT_IMPL(OS_ApplicationExit_Impl); -} - -/* - * Heap API low-level handler - */ -UT_DEFAULT_STUB(OS_HeapGetInfo_Impl,(OS_heap_prop_t *heap_prop)) - -/* - * FPU API low-level handlers - */ -UT_DEFAULT_STUB(OS_FPUExcAttachHandler_Impl,(uint32 ExceptionNumber, osal_task_entry ExceptionHandler,int32 parameter)) -UT_DEFAULT_STUB(OS_FPUExcEnable_Impl,(int32 ExceptionNumber)) -UT_DEFAULT_STUB(OS_FPUExcDisable_Impl,(int32 ExceptionNumber)) -UT_DEFAULT_STUB(OS_FPUExcSetMask_Impl,(uint32 mask)) -UT_DEFAULT_STUB(OS_FPUExcGetMask_Impl,(uint32 *mask)) - diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c new file mode 100644 index 000000000..dc0f93d73 --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-binsem-impl-stubs.c @@ -0,0 +1,29 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-binsem-impl.h" + + +/* +** Semaphore API +*/ + +UT_DEFAULT_STUB(OS_BinSemCreate_Impl,(uint32 sem_id, uint32 sem_initial_value, uint32 options)) +UT_DEFAULT_STUB(OS_BinSemFlush_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemGive_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemTake_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemTimedWait_Impl,(uint32 sem_id, uint32 msecs)) +UT_DEFAULT_STUB(OS_BinSemDelete_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_BinSemGetInfo_Impl,(uint32 sem_id, OS_bin_sem_prop_t *bin_prop)) + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-common-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-common-impl-stubs.c new file mode 100644 index 000000000..11db5b97a --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-common-impl-stubs.c @@ -0,0 +1,28 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-common-impl.h" + +UT_DEFAULT_STUB(OS_API_Impl_Init, (uint32 idtype)) + +void OS_IdleLoop_Impl (void) +{ + UT_DEFAULT_IMPL(OS_IdleLoop_Impl); +} + +void OS_ApplicationShutdown_Impl (void) +{ + UT_DEFAULT_IMPL(OS_ApplicationShutdown_Impl); +} + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c new file mode 100644 index 000000000..ab5a8172f --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-console-impl-stubs.c @@ -0,0 +1,32 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-printf-impl.h" + +/* +** Console output API (printf) +*/ +void OS_ConsoleWakeup_Impl(uint32 local_id) +{ + UT_DEFAULT_IMPL(OS_ConsoleWakeup_Impl); +} +int32 OS_ConsoleCreate_Impl(uint32 local_id) +{ + return UT_DEFAULT_IMPL(OS_ConsoleCreate_Impl); +} +void OS_ConsoleOutput_Impl(uint32 local_id) +{ + UT_DEFAULT_IMPL(OS_ConsoleOutput_Impl); +} + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c new file mode 100644 index 000000000..1f8e016ab --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-countsem-impl-stubs.c @@ -0,0 +1,27 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-countsem-impl.h" + +/* +** Semaphore API +*/ + +UT_DEFAULT_STUB(OS_CountSemCreate_Impl,(uint32 sem_id, uint32 sem_initial_value, uint32 options)) +UT_DEFAULT_STUB(OS_CountSemGive_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_CountSemTake_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_CountSemTimedWait_Impl,(uint32 sem_id, uint32 msecs)) +UT_DEFAULT_STUB(OS_CountSemDelete_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_CountSemGetInfo_Impl,(uint32 sem_id, OS_count_sem_prop_t *count_prop)) + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-error-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-error-impl-stubs.c new file mode 100644 index 000000000..62ee6d973 --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-error-impl-stubs.c @@ -0,0 +1,22 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-errors-impl.h" + +const OS_ErrorTable_Entry_t OS_IMPL_ERROR_NAME_TABLE[] = +{ + { -4444, "UT_ERROR" }, + { 0, NULL } +}; + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-fpu-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-fpu-impl-stubs.c new file mode 100644 index 000000000..3733b0f00 --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-fpu-impl-stubs.c @@ -0,0 +1,25 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-fpu-impl.h" + +/* + * FPU API low-level handlers + */ +UT_DEFAULT_STUB(OS_FPUExcAttachHandler_Impl,(uint32 ExceptionNumber, osal_task_entry ExceptionHandler,int32 parameter)) +UT_DEFAULT_STUB(OS_FPUExcEnable_Impl,(int32 ExceptionNumber)) +UT_DEFAULT_STUB(OS_FPUExcDisable_Impl,(int32 ExceptionNumber)) +UT_DEFAULT_STUB(OS_FPUExcSetMask_Impl,(uint32 mask)) +UT_DEFAULT_STUB(OS_FPUExcGetMask_Impl,(uint32 *mask)) + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-heap-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-heap-impl-stubs.c new file mode 100644 index 000000000..f15d9d90a --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-heap-impl-stubs.c @@ -0,0 +1,20 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-heap-impl.h" + +/* + * Heap API low-level handler + */ +UT_DEFAULT_STUB(OS_HeapGetInfo_Impl,(OS_heap_prop_t *heap_prop)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-idmap-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-idmap-impl-stubs.c new file mode 100644 index 000000000..2a3b2653e --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-idmap-impl-stubs.c @@ -0,0 +1,24 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-idmap-impl.h" + +/* + * Table locking and unlocking for global objects can be done at the shared code + * layer but the actual implementation is OS-specific + */ +UT_DEFAULT_STUB(OS_Lock_Global_Impl,(uint32 idtype)) +UT_DEFAULT_STUB(OS_Unlock_Global_Impl,(uint32 idtype)) + + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c new file mode 100644 index 000000000..8c678e9bf --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-mutex-impl-stubs.c @@ -0,0 +1,27 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-mutex-impl.h" + + +/* +** Mutex API +*/ + +UT_DEFAULT_STUB(OS_MutSemCreate_Impl,(uint32 sem_id, uint32 options)) +UT_DEFAULT_STUB(OS_MutSemGive_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_MutSemTake_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_MutSemDelete_Impl,(uint32 sem_id)) +UT_DEFAULT_STUB(OS_MutSemGetInfo_Impl,(uint32 sem_id, OS_mutex_prop_t *mut_prop)) + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c new file mode 100644 index 000000000..684e04c85 --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-queue-impl-stubs.c @@ -0,0 +1,26 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-queue-impl.h" + +/* +** Message Queue API +*/ + +UT_DEFAULT_STUB(OS_QueueCreate_Impl,(uint32 queue_id, uint32 flags)) +UT_DEFAULT_STUB(OS_QueueDelete_Impl,(uint32 queue_id)) +UT_DEFAULT_STUB(OS_QueueGet_Impl,(uint32 queue_id, void *data, uint32 size, uint32 *size_copied, int32 timeout)) +UT_DEFAULT_STUB(OS_QueuePut_Impl,(uint32 queue_id, const void *data, uint32 size, uint32 flags)) +UT_DEFAULT_STUB(OS_QueueGetInfo_Impl,(uint32 queue_id, OS_queue_prop_t *queue_prop)) + diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-shared-debug-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-shared-debug-stubs.c new file mode 100644 index 000000000..11622ecee --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-shared-debug-stubs.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2004-2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Glenn + * Research Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + */ + +/** + * \file osapi-shared-debug.c + * + * Created on: April 20, 2020 + * Author: joseph.p.hickey@nasa.gov + * + * Stub implementations for the functions defined in the OSAL API + */ + +#include "osapi-shared-globaldefs.h" + +/***************************************************************************** + * + * Stub function for OS_DebugPrintf() + * This is only relevant when building OSAL with OSAL_CONFIG_DEBUG_PRINTF enabled + * + *****************************************************************************/ +void OS_DebugPrintf(uint32 Level, const char *Func, uint32 Line, const char *Format, ...) +{ +} diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c new file mode 100644 index 000000000..ead5e7345 --- /dev/null +++ b/src/unit-test-coverage/ut-stubs/src/osapi-task-impl-stubs.c @@ -0,0 +1,37 @@ +/** + * @file impl-stubs.c + * + * UT assert stubs for low-level implementation functions. + * These are prototyped in the "os-impl.h" file within the shared API + */ + +#include +#include +#include +#include + +#include "utstubs.h" + +#include "osapi-task-impl.h" + + +/* +** Task API +*/ +UT_DEFAULT_STUB(OS_TaskMatch_Impl,(uint32 task_id)) +UT_DEFAULT_STUB(OS_TaskCreate_Impl,(uint32 task_id, uint32 flags)) +UT_DEFAULT_STUB(OS_TaskDelete_Impl,(uint32 task_id)) +void OS_TaskExit_Impl (void) +{ + UT_DEFAULT_IMPL(OS_TaskExit_Impl); +} + +UT_DEFAULT_STUB(OS_TaskDelay_Impl,(uint32 millisecond)) +UT_DEFAULT_STUB(OS_TaskSetPriority_Impl,(uint32 task_id, uint32 new_priority)) +uint32 OS_TaskGetId_Impl (void) +{ + return UT_DEFAULT_IMPL(OS_TaskGetId_Impl); +} +UT_DEFAULT_STUB(OS_TaskGetInfo_Impl,(uint32 task_id, OS_task_prop_t *task_prop)) +UT_DEFAULT_STUB(OS_TaskRegister_Impl,(uint32 global_task_id)) + diff --git a/src/unit-test-coverage/vxworks/CMakeLists.txt b/src/unit-test-coverage/vxworks/CMakeLists.txt index f85e8247c..98b33b6de 100644 --- a/src/unit-test-coverage/vxworks/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/CMakeLists.txt @@ -8,6 +8,7 @@ set(VXWORKS_MODULE_LIST dirs files filesys + idmap heap loader mutex diff --git a/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt b/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt index e2ae1bb0f..2d67f51f8 100644 --- a/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/adaptors/CMakeLists.txt @@ -26,6 +26,7 @@ add_library(ut-adaptor-${SETNAME} STATIC src/ut-adaptor-dirs.c src/ut-adaptor-files.c src/ut-adaptor-filesys.c + src/ut-adaptor-idmap.c src/ut-adaptor-loader.c src/ut-adaptor-mutex.c src/ut-adaptor-queues.c diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h index c0ff6fb63..ac56742d6 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-binsem.h @@ -41,10 +41,7 @@ extern size_t const UT_Ref_OS_impl_bin_sem_table_SIZE; extern const UT_EntryKey_t UT_StubKey_GenericSemTake; extern const UT_EntryKey_t UT_StubKey_GenericSemGive; - extern int32 UT_Call_OS_VxWorks_BinSemAPI_Impl_Init(void); - - #endif /* _UT_ADAPTOR_BINSEM_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h index cadc8b98e..b8e6c434e 100644 --- a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-common.h @@ -23,6 +23,7 @@ #define _UT_ADAPTOR_COMMON_H_ #include +#include #include /***************************************************** @@ -34,12 +35,19 @@ * *****************************************************/ -int32 UT_Call_OS_API_Impl_Init(uint32 idtype); void UT_CommonTest_SetImplTableMutex(uint32 idtype, OCS_SEM_ID vxid); extern int32 OS_VxWorks_GenericSemTake(OCS_SEM_ID vxid, int sys_ticks); extern int32 OS_VxWorks_GenericSemGive(OCS_SEM_ID vxid); +/* + * This also needs to expose the keys for the stubs to + * helper functions that the test case needs to configure. + * + * This is because the test case cannot directly include + * the internal header file which provides this API. + */ +extern const UT_EntryKey_t UT_StubKey_OS_VxWorks_TableMutex_Init; #endif /* _UT_ADAPTOR_COMMON_H_ */ diff --git a/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-idmap.h b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-idmap.h new file mode 100644 index 000000000..799e8acdd --- /dev/null +++ b/src/unit-test-coverage/vxworks/adaptors/inc/ut-adaptor-idmap.h @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + * + */ + + +/** + * \file ut-adaptor-idmap.h + * \ingroup adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +#ifndef _UT_ADAPTOR_IDMAP_H_ +#define _UT_ADAPTOR_IDMAP_H_ + +#include +#include + +/***************************************************** + * + * UT FUNCTION PROTOTYPES + * + * These are functions that need to be invoked by UT + * but are not part of the implementation API. + * + *****************************************************/ +int32 UT_Call_OS_VxWorks_TableMutex_Init(uint32 idtype); +void UT_IdMapTest_SetImplTableMutex(uint32 idtype, OCS_SEM_ID vxid); + + +#endif /* _UT_ADAPTOR_IDMAP_H_ */ + diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c index 203cb7af5..c47a2ad9a 100644 --- a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-common.c @@ -26,16 +26,6 @@ #include #include "ut-adaptor-common.h" -#include "osapi-common-impl.h" -int32 UT_Call_OS_API_Impl_Init(uint32 idtype) -{ - return OS_API_Impl_Init(idtype); -} - - -void UT_CommonTest_SetImplTableMutex(uint32 idtype, OCS_SEM_ID vxid) -{ - VX_MUTEX_TABLE[idtype].vxid = vxid; -} +const UT_EntryKey_t UT_StubKey_OS_VxWorks_TableMutex_Init = UT_KEY(OS_VxWorks_TableMutex_Init); diff --git a/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-idmap.c b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-idmap.c new file mode 100644 index 000000000..e606eff68 --- /dev/null +++ b/src/unit-test-coverage/vxworks/adaptors/src/ut-adaptor-idmap.c @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + * + */ + + +/** + * \file ut-osapi.c + * \ingroup adaptors + * \author joseph.p.hickey@nasa.gov + * + */ + +/* pull in the OSAL configuration */ +#include +#include +#include + +#include +#include "ut-adaptor-idmap.h" + +int32 UT_Call_OS_VxWorks_TableMutex_Init(uint32 idtype) +{ + return OS_VxWorks_TableMutex_Init(idtype); +} + +void UT_IdMapTest_SetImplTableMutex(uint32 idtype, OCS_SEM_ID vxid) +{ + VX_MUTEX_TABLE[idtype].vxid = vxid; +} + diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c index 2c0fb5873..8ed34e800 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-binsem.c @@ -27,7 +27,6 @@ #include "ut-adaptor-binsem.h" #include "osapi-binsem-impl.h" -#include "osapi-common-impl.h" #include "osapi-idmap-impl.h" #include @@ -130,7 +129,6 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_bin_sem_table, 0, sizeof(OS_bin_sem_table)); memset(OS_global_bin_sem_table, 0, sizeof(OS_common_record_t) * OS_MAX_BIN_SEMAPHORES); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-common.c b/src/unit-test-coverage/vxworks/src/coveragetest-common.c index 7c7dc0f06..3d9a042af 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-common.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-common.c @@ -30,62 +30,25 @@ OCS_SEM TestGlobalSem; -void Test_OS_Lock_Global_Impl(void) -{ - /* - * Test Case For: - * int32 OS_Lock_Global_Impl(uint32 idtype) - */ - OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(10000), OS_ERROR); - - /* - * Confirm that if vxid is 0/NULL that the function returns error - * and does not call semTake. - */ - UT_CommonTest_SetImplTableMutex(OS_OBJECT_TYPE_OS_TASK, (OCS_SEM_ID)0); - OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); - UtAssert_True(UT_GetStubCount(UT_KEY(OCS_semTake)) == 0, "semTake() NOT called"); - - UT_CommonTest_SetImplTableMutex(OS_OBJECT_TYPE_OS_TASK, &TestGlobalSem); - OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); - UtAssert_True(UT_GetStubCount(UT_KEY(OCS_semTake)) == 1, "semTake() called"); - - UT_SetForceFail(UT_KEY(OCS_semTake), -1); - OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); -} - -void Test_OS_Unlock_Global_Impl(void) -{ - /* - * Test Case For: - * int32 OS_Unlock_Global_Impl(uint32 idtype) - */ - OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(10000), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(0), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semGive), -1); - OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); -} - void Test_OS_API_Impl_Init(void) { /* * Test Case For: * int32 OS_API_Impl_Init(uint32 idtype) */ - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(0), OS_SUCCESS); - UT_SetForceFail(UT_KEY(OCS_semMInitialize), -1); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); - UT_ClearForceFail(UT_KEY(OCS_semMInitialize)); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_QUEUE), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_BINSEM), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_COUNTSEM), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_MUTEX), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_MODULE), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TIMEBASE), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_STREAM), OS_SUCCESS); - OSAPI_TEST_FUNCTION_RC(UT_Call_OS_API_Impl_Init(OS_OBJECT_TYPE_OS_DIR), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(0), OS_SUCCESS); + UT_SetForceFail(UT_StubKey_OS_VxWorks_TableMutex_Init, OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); + UT_ClearForceFail(UT_StubKey_OS_VxWorks_TableMutex_Init); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_QUEUE), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_BINSEM), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_COUNTSEM), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_MUTEX), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_MODULE), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_TIMEBASE), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_STREAM), OS_SUCCESS); + OSAPI_TEST_FUNCTION_RC(OS_API_Impl_Init(OS_OBJECT_TYPE_OS_DIR), OS_SUCCESS); } void Test_OS_IdleLoop_Impl(void) @@ -171,8 +134,6 @@ void Osapi_Test_Teardown(void) */ void UtTest_Setup(void) { - ADD_TEST(OS_Lock_Global_Impl); - ADD_TEST(OS_Unlock_Global_Impl); ADD_TEST(OS_API_Impl_Init); ADD_TEST(OS_IdleLoop_Impl); ADD_TEST(OS_ApplicationShutdown_Impl); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-console.c b/src/unit-test-coverage/vxworks/src/coveragetest-console.c index e6fe7a03b..1c88c8e71 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-console.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-console.c @@ -98,7 +98,6 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_console_table, 0, sizeof(OS_console_table)); memset(OS_global_console_table, 0, sizeof(OS_common_record_t) * OS_MAX_CONSOLES); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c index eb7288c81..86446dfa2 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c @@ -103,7 +103,7 @@ void Test_OS_CountSemGetInfo_Impl(void) void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); + memset(OS_count_sem_table, 0, sizeof(OS_count_sem_table)); memset(OS_global_count_sem_table, 0, sizeof(OS_common_record_t) * OS_MAX_BIN_SEMAPHORES); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c index fbc710580..95234edeb 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-filesys.c @@ -169,7 +169,6 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_filesys_table, 0, sizeof(OS_filesys_table)); memset(OS_global_filesys_table, 0, sizeof(OS_common_record_t) * OS_MAX_FILE_SYSTEMS); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c b/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c new file mode 100644 index 000000000..57cf5a7d5 --- /dev/null +++ b/src/unit-test-coverage/vxworks/src/coveragetest-idmap.c @@ -0,0 +1,119 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + * + */ + + +/** + * \file coveragetest-idmap.c + * \ingroup vxworks + * \author joseph.p.hickey@nasa.gov + * + */ + +#include "os-vxworks-coveragetest.h" +#include "ut-adaptor-idmap.h" + +#include "osapi-idmap-impl.h" + +#include +#include + +OCS_SEM TestGlobalSem; + + +void Test_OS_Lock_Global_Impl(void) +{ + /* + * Test Case For: + * int32 OS_Lock_Global_Impl(uint32 idtype) + */ + OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(10000), OS_ERROR); + + /* + * Confirm that if vxid is 0/NULL that the function returns error + * and does not call semTake. + */ + UT_IdMapTest_SetImplTableMutex(OS_OBJECT_TYPE_OS_TASK, (OCS_SEM_ID)0); + OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); + UtAssert_True(UT_GetStubCount(UT_KEY(OCS_semTake)) == 0, "semTake() NOT called"); + + UT_IdMapTest_SetImplTableMutex(OS_OBJECT_TYPE_OS_TASK, &TestGlobalSem); + OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); + UtAssert_True(UT_GetStubCount(UT_KEY(OCS_semTake)) == 1, "semTake() called"); + + UT_SetForceFail(UT_KEY(OCS_semTake), -1); + OSAPI_TEST_FUNCTION_RC(OS_Lock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); +} + +void Test_OS_Unlock_Global_Impl(void) +{ + /* + * Test Case For: + * int32 OS_Unlock_Global_Impl(uint32 idtype) + */ + OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(10000), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(0), OS_ERROR); + OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); + UT_SetForceFail(UT_KEY(OCS_semGive), -1); + OSAPI_TEST_FUNCTION_RC(OS_Unlock_Global_Impl(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); +} + +void Test_OS_API_Impl_Init(void) +{ + /* + * Test Case For: + * int32 OS_API_Impl_Init(uint32 idtype) + */ + OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TableMutex_Init(0), OS_SUCCESS); + UT_SetForceFail(UT_KEY(OCS_semMInitialize), -1); + OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TableMutex_Init(OS_OBJECT_TYPE_OS_TASK), OS_ERROR); + UT_ClearForceFail(UT_KEY(OCS_semMInitialize)); + OSAPI_TEST_FUNCTION_RC(UT_Call_OS_VxWorks_TableMutex_Init(OS_OBJECT_TYPE_OS_TASK), OS_SUCCESS); +} + + +/* ------------------- End of test cases --------------------------------------*/ + +/* Osapi_Test_Setup + * + * Purpose: + * Called by the unit test tool to set up the app prior to each test + */ +void Osapi_Test_Setup(void) +{ + UT_ResetState(0); +} + +/* + * Osapi_Test_Teardown + * + * Purpose: + * Called by the unit test tool to tear down the app after each test + */ +void Osapi_Test_Teardown(void) +{ + +} + +/* UtTest_Setup + * + * Purpose: + * Registers the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(OS_Lock_Global_Impl); + ADD_TEST(OS_Unlock_Global_Impl); + ADD_TEST(OS_API_Impl_Init); +} + + diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c index ed2b23783..6b24ed466 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-loader.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-loader.c @@ -98,8 +98,6 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); - - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_module_table, 0, sizeof(OS_module_table)); memset(OS_global_module_table, 0, sizeof(OS_common_record_t) * OS_MAX_MODULES); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c index 5861acee2..fe9a56929 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-queues.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-queues.c @@ -134,7 +134,6 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_queue_table, 0, sizeof(OS_queue_table)); memset(OS_global_queue_table, 0, sizeof(OS_common_record_t) * OS_MAX_QUEUES); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c index 2bbc411aa..bb9477d65 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c @@ -23,7 +23,7 @@ #include "ut-adaptor-tasks.h" #include "osapi-task-impl.h" -#include "osapi-common-impl.h" +//jphfix #include "osapi-common-impl.h" #include "osapi-idmap-impl.h" #include @@ -202,7 +202,6 @@ void Test_OS_TaskGetInfo_Impl(void) void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_task_table, 0, sizeof(OS_task_table)); memset(OS_global_task_table, 0, sizeof(OS_common_record_t) * OS_MAX_TASKS); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c index 499c56304..9d5635407 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c @@ -239,7 +239,6 @@ void Osapi_Test_Setup(void) { UT_ResetState(0); - memset(&OS_SharedGlobalVars, 0, sizeof(OS_SharedGlobalVars)); memset(OS_timebase_table, 0, sizeof(OS_timebase_table)); memset(OS_global_timebase_table, 0, sizeof(OS_common_record_t) * OS_MAX_BIN_SEMAPHORES); diff --git a/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h b/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h index 7b6899491..f9c7a8135 100644 --- a/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h +++ b/src/unit-test-coverage/vxworks/src/os-vxworks-coveragetest.h @@ -30,7 +30,7 @@ #include #include -#include "osapi-common-impl.h" +//jphfix #include "osapi-common-impl.h" #include "osapi-idmap-impl.h" diff --git a/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt b/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt index b7fa5bdc0..fd7a0c8a6 100644 --- a/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt +++ b/src/unit-test-coverage/vxworks/ut-stubs/CMakeLists.txt @@ -4,6 +4,7 @@ add_library(ut_vxworks_impl_stubs src/vxworks-os-impl-countsem-stubs.c src/vxworks-os-impl-dir-stubs.c src/vxworks-os-impl-file-stubs.c + src/vxworks-os-impl-idmap-stubs.c src/vxworks-os-impl-module-stubs.c src/vxworks-os-impl-mutex-stubs.c src/vxworks-os-impl-queue-stubs.c diff --git a/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-idmap-stubs.c b/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-idmap-stubs.c new file mode 100644 index 000000000..c599c7187 --- /dev/null +++ b/src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-idmap-stubs.c @@ -0,0 +1,26 @@ +/* + * + * Copyright (c) 2020, United States government as represented by the + * administrator of the National Aeronautics Space Administration. + * All rights reserved. This software was created at NASA Goddard + * Space Flight Center pursuant to government contracts. + * + * This is governed by the NASA Open Source Agreement and may be used, + * distributed and modified only according to the terms of that agreement. + * + * + */ + + +/** + * \file osapi-impl-vxworks-stubs.c + * \ingroup ut-stubs + * \author joseph.p.hickey@nasa.gov + * + */ +#include +#include +#include "utstubs.h" + +UT_DEFAULT_STUB(OS_VxWorks_TableMutex_Init, (uint32 idtype)) + diff --git a/src/ut-stubs/osapi-utstub-idmap.c b/src/ut-stubs/osapi-utstub-idmap.c index 51274efaf..35b55ae73 100644 --- a/src/ut-stubs/osapi-utstub-idmap.c +++ b/src/ut-stubs/osapi-utstub-idmap.c @@ -30,7 +30,7 @@ #include "utstub-helpers.h" #include "osapi-idmap-impl.h" -#include "osapi-common-impl.h" +//jphfix #include "osapi-common-impl.h" UT_DEFAULT_STUB(OS_ObjectIdInit,(void))