diff --git a/README.md b/README.md index 1db2e20c..842c337c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,12 @@ This repository contains NASA's Platform Support Package (PSP), which is a frame This is a collection of APIs abstracting platform specific functionality to be located in the `psp` subdirectory of a cFS Mission Tree. The Core Flight System is bundled at , which includes build and execution instructions. -## Version History +## Changelog + +### Development Build: v1.6.0-rc4+dev41 + +- Add CFE_PSP_StatusToString and CFE_PSP_STATUS_C +- See ### Development Build: v1.6.0-rc4+dev38 diff --git a/fsw/inc/cfe_psp.h b/fsw/inc/cfe_psp.h index f3d6a54b..91f7e580 100644 --- a/fsw/inc/cfe_psp.h +++ b/fsw/inc/cfe_psp.h @@ -39,30 +39,12 @@ #include "common_types.h" #include "osapi.h" +#include "cfe_psp_error.h" + /* ** Macro Definitions */ -/* -** Error and return codes -*/ -#define CFE_PSP_SUCCESS (0) -#define CFE_PSP_ERROR (-1) -#define CFE_PSP_INVALID_POINTER (-2) -#define CFE_PSP_ERROR_ADDRESS_MISALIGNED (-3) -#define CFE_PSP_ERROR_TIMEOUT (-4) -#define CFE_PSP_INVALID_INT_NUM (-5) -#define CFE_PSP_INVALID_MEM_ADDR (-21) -#define CFE_PSP_INVALID_MEM_TYPE (-22) -#define CFE_PSP_INVALID_MEM_RANGE (-23) -#define CFE_PSP_INVALID_MEM_WORDSIZE (-24) -#define CFE_PSP_INVALID_MEM_SIZE (-25) -#define CFE_PSP_INVALID_MEM_ATTR (-26) -#define CFE_PSP_ERROR_NOT_IMPLEMENTED (-27) -#define CFE_PSP_INVALID_MODULE_NAME (-28) -#define CFE_PSP_INVALID_MODULE_ID (-29) -#define CFE_PSP_NO_EXCEPTION_DATA (-30) - /* ** Definitions for PSP PANIC types */ diff --git a/fsw/inc/cfe_psp_error.h b/fsw/inc/cfe_psp_error.h new file mode 100644 index 00000000..ded4bec1 --- /dev/null +++ b/fsw/inc/cfe_psp_error.h @@ -0,0 +1,82 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ +#ifndef CFE_PSP_ERROR_H +#define CFE_PSP_ERROR_H + +/** + * \file + * \brief cFE PSP Error header + */ + +#include "common_types.h" + +/** + * \brief PSP Status type for readability and potentially type safety + */ +typedef int32 CFE_PSP_Status_t; + +/** + * \brief PSP Status macro for literal + */ +#define CFE_PSP_STATUS_C(X) ((CFE_PSP_Status_t)(X)) + +/** + * \brief PSP Status converted to string length limit + * + * Used for sizing CFE_PSP_StatusString_t intended for use in printing CFE_PSP_Status_t values + * Sized for %ld (LONG_MIN) including NULL + */ +#define CFE_PSP_STATUS_STRING_LENGTH 12 + +/** + * @brief For the @ref CFE_PSP_StatusToString() function, to ensure + * everyone is making an array of the same length. + */ +typedef char CFE_PSP_StatusString_t[CFE_PSP_STATUS_STRING_LENGTH]; + +/** + * @brief Convert status to a string + * + * @param[in] status Status value to convert + * @param[out] status_string Buffer to store status converted to string + * + * @return Passed in string pointer + */ +char *CFE_PSP_StatusToString(CFE_PSP_Status_t status, CFE_PSP_StatusString_t *status_string); + +/* + * Error and return codes + */ +#define CFE_PSP_SUCCESS (CFE_PSP_STATUS_C(0)) +#define CFE_PSP_ERROR (CFE_PSP_STATUS_C(-1)) +#define CFE_PSP_INVALID_POINTER (CFE_PSP_STATUS_C(-2)) +#define CFE_PSP_ERROR_ADDRESS_MISALIGNED (CFE_PSP_STATUS_C(-3)) +#define CFE_PSP_ERROR_TIMEOUT (CFE_PSP_STATUS_C(-4)) +#define CFE_PSP_INVALID_INT_NUM (CFE_PSP_STATUS_C(-5)) +#define CFE_PSP_INVALID_MEM_ADDR (CFE_PSP_STATUS_C(-21)) +#define CFE_PSP_INVALID_MEM_TYPE (CFE_PSP_STATUS_C(-22)) +#define CFE_PSP_INVALID_MEM_RANGE (CFE_PSP_STATUS_C(-23)) +#define CFE_PSP_INVALID_MEM_WORDSIZE (CFE_PSP_STATUS_C(-24)) +#define CFE_PSP_INVALID_MEM_SIZE (CFE_PSP_STATUS_C(-25)) +#define CFE_PSP_INVALID_MEM_ATTR (CFE_PSP_STATUS_C(-26)) +#define CFE_PSP_ERROR_NOT_IMPLEMENTED (CFE_PSP_STATUS_C(-27)) +#define CFE_PSP_INVALID_MODULE_NAME (CFE_PSP_STATUS_C(-28)) +#define CFE_PSP_INVALID_MODULE_ID (CFE_PSP_STATUS_C(-29)) +#define CFE_PSP_NO_EXCEPTION_DATA (CFE_PSP_STATUS_C(-30)) + +#endif /* CFE_PSP_ERROR_H */ diff --git a/fsw/mcp750-vxworks/inc/psp_version.h b/fsw/mcp750-vxworks/inc/psp_version.h index ea09fa94..ab3662c8 100644 --- a/fsw/mcp750-vxworks/inc/psp_version.h +++ b/fsw/mcp750-vxworks/inc/psp_version.h @@ -27,7 +27,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 38 +#define CFE_PSP_IMPL_BUILD_NUMBER 41 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4" /* diff --git a/fsw/pc-linux/inc/psp_version.h b/fsw/pc-linux/inc/psp_version.h index ea09fa94..ab3662c8 100644 --- a/fsw/pc-linux/inc/psp_version.h +++ b/fsw/pc-linux/inc/psp_version.h @@ -27,7 +27,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 38 +#define CFE_PSP_IMPL_BUILD_NUMBER 41 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4" /* diff --git a/fsw/pc-rtems/inc/psp_version.h b/fsw/pc-rtems/inc/psp_version.h index ea09fa94..ab3662c8 100644 --- a/fsw/pc-rtems/inc/psp_version.h +++ b/fsw/pc-rtems/inc/psp_version.h @@ -27,7 +27,7 @@ /* * Development Build Macro Definitions */ -#define CFE_PSP_IMPL_BUILD_NUMBER 38 +#define CFE_PSP_IMPL_BUILD_NUMBER 41 #define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4" /* diff --git a/fsw/shared/CMakeLists.txt b/fsw/shared/CMakeLists.txt index 994c1998..77173a70 100644 --- a/fsw/shared/CMakeLists.txt +++ b/fsw/shared/CMakeLists.txt @@ -13,6 +13,7 @@ # Build the shared implementation as a library add_library(psp-${CFE_PSP_TARGETNAME}-shared OBJECT + src/cfe_psp_error.c src/cfe_psp_exceptionstorage.c src/cfe_psp_memrange.c src/cfe_psp_memutils.c diff --git a/fsw/shared/src/cfe_psp_error.c b/fsw/shared/src/cfe_psp_error.c new file mode 100644 index 00000000..b7a7cdb7 --- /dev/null +++ b/fsw/shared/src/cfe_psp_error.c @@ -0,0 +1,46 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * \file + * + * Implements error APIs + */ +#include + +#include "cfe_psp_error.h" + +/*---------------------------------------------------------------- + * + * Function: CFE_PSP_StatusToString + * + * Purpose: Implemented per public PSP API + * See description in API and header file for detail + * + *-----------------------------------------------------------------*/ +char *CFE_PSP_StatusToString(CFE_PSP_Status_t status, CFE_PSP_StatusString_t *status_string) +{ + char *string = NULL; + + if (status_string != NULL) + { + snprintf(*status_string, sizeof(*status_string), "%ld", (long)status); + string = *status_string; + } + return string; +} diff --git a/ut-stubs/cfe_psp_error_stubs.c b/ut-stubs/cfe_psp_error_stubs.c new file mode 100644 index 00000000..323a6c87 --- /dev/null +++ b/ut-stubs/cfe_psp_error_stubs.c @@ -0,0 +1,44 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ +#define CFE_PSP_ERROR_H + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cfe_psp_error header + */ + +#include "cfe_psp_error.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CFE_PSP_StatusToString() + * ---------------------------------------------------- + */ +char *CFE_PSP_StatusToString(CFE_PSP_Status_t status, CFE_PSP_StatusString_t *status_string) +{ + UT_GenStub_SetupReturnBuffer(CFE_PSP_StatusToString, char *); + + UT_GenStub_AddParam(CFE_PSP_StatusToString, CFE_PSP_Status_t, status); + UT_GenStub_AddParam(CFE_PSP_StatusToString, CFE_PSP_StatusString_t *, status_string); + + UT_GenStub_Execute(CFE_PSP_StatusToString, Basic, NULL); + + return UT_GenStub_GetReturnValue(CFE_PSP_StatusToString, char *); +}