Skip to content

Commit

Permalink
Merge IC:Caelum-rc4+dev11: psp v1.6.0-rc4+dev41
Browse files Browse the repository at this point in the history
- Add CFE_PSP_StatusToString and CFE_PSP_STATUS_C
- See <nasa/cFS#505>
  • Loading branch information
astrogeco committed Jun 22, 2022
2 parents 4bf1eef + aa25819 commit a8ae3bc
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 24 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/nasa/cFS>, 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 <https://github.com/nasa/cFS/pull/505>

### Development Build: v1.6.0-rc4+dev38

Expand Down
22 changes: 2 additions & 20 deletions fsw/inc/cfe_psp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
82 changes: 82 additions & 0 deletions fsw/inc/cfe_psp_error.h
Original file line number Diff line number Diff line change
@@ -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 */
2 changes: 1 addition & 1 deletion fsw/mcp750-vxworks/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/*
Expand Down
2 changes: 1 addition & 1 deletion fsw/pc-linux/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/*
Expand Down
2 changes: 1 addition & 1 deletion fsw/pc-rtems/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/*
Expand Down
1 change: 1 addition & 0 deletions fsw/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions fsw/shared/src/cfe_psp_error.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>

#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;
}
44 changes: 44 additions & 0 deletions ut-stubs/cfe_psp_error_stubs.c
Original file line number Diff line number Diff line change
@@ -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 *);
}

0 comments on commit a8ae3bc

Please sign in to comment.