Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #263, modular psp implementation #264

Merged
merged 13 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,60 @@ if (NOT CFE_SYSTEM_PSPNAME)
endif()

set(CFE_PSP_TARGETNAME "${CFE_SYSTEM_PSPNAME}")
add_definitions(-D_CFE_PSP_)
add_definitions(-D_CFE_PSP_) # macro to indicate PSP scope

# The PSP is currently built in two parts, consisting of a fully platform-specific
# module combined with a shared component which is built for multiple targets.
# The "psp_module_api" defines the interface between internal PSP components
add_library(psp_module_api INTERFACE)
target_compile_definitions(psp_module_api INTERFACE
$<TARGET_PROPERTY:osal,INTERFACE_COMPILE_DEFINITIONS> # use defs from OSAL
)
target_include_directories(psp_module_api INTERFACE
fsw/inc # public API
fsw/shared/inc # all PSP shared headers
fsw/${CFE_PSP_TARGETNAME}/inc # all impl headers
${CFE_SOURCE_DIR}/cmake/target/inc # for sysconfig
$<TARGET_PROPERTY:osal,INTERFACE_INCLUDE_DIRECTORIES> # use headers from OSAL
)

# Translate the CFE_PSP_TARGETNAME to a set of additional modules to build
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/fsw/${CFE_PSP_TARGETNAME}/psp_module_list.cmake" PSP_TARGET_MODULE_LIST REGEX "^[a-zA-Z]")

# The PSP is currently built in modular parts, consisting of a platform-specific
# module(s) combined with a shared component which is built for multiple targets.
# The "shared" component is compiled using headers from the platform-specific module
# so it is still ultimately a platform-specific binary, and it all gets wrapped into
# a single PSP static library target.
include_directories(fsw/shared/inc)
add_subdirectory(fsw/${CFE_PSP_TARGETNAME} ${CFE_PSP_TARGETNAME}-impl)
add_subdirectory(fsw/shared ${CFE_PSP_TARGETNAME}-shared)

# Generate a list of PSP modules along with a pointer to its API structure/entry point
set(GENERATED_EXTERNS)
set(GENERATED_KEYVALS)
foreach(PSPMOD ${PSP_TARGET_MODULE_LIST})
add_subdirectory(fsw/modules/${PSPMOD} ${PSPMOD}-${CFE_PSP_TARGETNAME}-impl)
list(APPEND GENERATED_EXTERNS "extern CFE_PSP_ModuleApi_t CFE_PSP_${PSPMOD}_API;\n")
list(APPEND GENERATED_KEYVALS "{ .Name = \"${PSPMOD}\", .Api = &CFE_PSP_${PSPMOD}_API },\n")
endforeach()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/module_list.c.in ${CMAKE_CURRENT_BINARY_DIR}/${CFE_PSP_TARGETNAME}_module_list.c @ONLY)

add_library(psp-${CFE_PSP_TARGETNAME} STATIC
${CMAKE_CURRENT_BINARY_DIR}/${CFE_PSP_TARGETNAME}_module_list.c
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-shared>
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-impl>
)

target_link_libraries(psp-${CFE_PSP_TARGETNAME} PUBLIC
${PSP_TARGET_MODULE_LIST}
)
target_link_libraries(psp-${CFE_PSP_TARGETNAME} PRIVATE
psp_module_api
)

target_include_directories(psp-${CFE_PSP_TARGETNAME} INTERFACE
fsw/inc
)


if (ENABLE_UNIT_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ut-stubs)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit-test-coverage)
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ This is a collection of APIs abstracting platform specific functionality to be l

## Version History

### Development Build: v1.5.0-rc1+dev82

- HOTFIX 20210312, updates to work with older CMake
- See <https://github.com/nasa/PSP/pull/268>

### Development Build: v1.5.0-rc1+dev76

- Fix #246, remove unused code.
- Fix #254, use CMake to publish interface details
- Fix #256, add PSP version API
- Fix #258, Add Testing Tools to the Security Policy
- See <https://github.com/nasa/PSP/pull/260>

### Development Build: 1.5.0-rc1+dev68

- Updates continuous integration workfow by adding static analysis with timeout and code format check. Adds status badges to ReadMe and removes old TravisCI artifacts.
Expand Down
30 changes: 28 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,34 @@ For general cFS vulnerabilities please [open a cFS framework issue](https://gith

In either case please use the "Bug Report" template and provide as much information as possible. Apply appropraite labels for each report. For security related reports, tag the issue with the "security" label.

## Testing

**Disclaimer: nasa/PSP is not responsible for any liability incurred under the [Apache License 2.0](https://github.com/nasa/PSP/blob/main/LICENSE).**

Testing is an important aspect our team values to improve PSP.

To view tools used for the cFS bundle, see our [top-level security policy](https://github.com/nasa/cFS/security/policy).

### CodeQL

The [PSP CodeQL GitHub Actions workflow](https://github.com/nasa/PSP/actions/workflows/codeql-build.yml) is available to the public. To review the results, fork the PSP repository and run the CodeQL workflow.

CodeQL is ran for every push and pull-request on all branches of PSP in GitHub Actions.

For the CodeQL GitHub Actions setup, visit https://github.com/github/codeql-action.

### Cppcheck

The [PSP Cppcheck GitHub Actions workflow and results](https://github.com/nasa/PSP/actions/workflows/static-analysis.yml) are available to the public. To view the results, select a workflow and download the artifacts.

Cppcheck is ran for every push on the main branch and every pull request on all branches of PSP in Github Actions.

For more information about Cppcheck, visit http://cppcheck.sourceforge.net/.

## Additional Support

For additional support, email us at [email protected]. For help using OSAL and cFS, [subscribe to our mailing list](https://lists.nasa.gov/mailman/listinfo/cfs-community) that includes all the community members/users of the NASA core Flight Software (cFS) product line. The mailing list is used to communicate any information related to the cFS product such as current releases, bug findings and fixes, enhancement requests, community meeting notifications, sending out meeting minutes, etc.
For additional support, submit a GitHub issue. You can also email the cfs community at [email protected].

You can subscribe to the mailing list [here](https://lists.nasa.gov/mailman/listinfo/cfs-community) that includes all the community members/users of the NASA core Flight Software (cFS) product line. The mailing list is used to communicate any information related to the cFS product such as current releases, bug findings and fixes, enhancement requests, community meeting notifications, sending out meeting minutes, etc.

If you wish to report a cybersecurity incident or concern please contact the NASA Security Operations Center either by phone at 1-877-627-2732 or via email address [email protected].
If you wish to report a cybersecurity incident or concern, please contact the NASA Security Operations Center either by phone at 1-877-627-2732 or via email address [email protected].
12 changes: 12 additions & 0 deletions cmake/module_list.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This file is generated via CMake - do not edit in place */
#include "cfe_psp_module.h"

@GENERATED_EXTERNS@

CFE_StaticModuleLoadEntry_t CFE_PSP_BASE_MODULE_LIST[] =
{
@GENERATED_KEYVALS@
{ NULL }
};

/* END OF FILE */
55 changes: 55 additions & 0 deletions fsw/inc/cfe_psp.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,59 @@ int32 CFE_PSP_EepromWriteDisable(uint32 Bank);
int32 CFE_PSP_EepromPowerUp(uint32 Bank);
int32 CFE_PSP_EepromPowerDown(uint32 Bank);

/**
* \brief Obtain the PSP version/baseline identifier string
*
* This retrieves the PSP version identifier string without extra info
*
* \returns Version string. This is a fixed string and cannot be NULL.
*/
const char *CFE_PSP_GetVersionString(void);

/**
* \brief Obtain the version code name
*
* This retrieves the PSP code name. This is a compatibility indicator for the
* overall NASA CFS ecosystem. All modular components which are intended to
* interoperate should report the same code name.
*
* \returns Code name. This is a fixed string and cannot be NULL.
*/
const char *CFE_PSP_GetVersionCodeName(void);

/**
* \brief Obtain the PSP numeric version numbers as uint8 values
*
* This retrieves the numeric PSP version identifier as an array of 4 uint8 values.
*
* The array of numeric values is in order of precedence:
* [0] = Major Number
* [1] = Minor Number
* [2] = Revision Number
* [3] = Mission Revision
*
* The "Mission Revision" (last output) also indicates whether this is an
* official release, a patched release, or a development version.
* 0 indicates an official release
* 1-254 local patch level (reserved for mission use)
* 255 indicates a development build
*
* \param[out] VersionNumbers A fixed-size array to be filled with the version numbers
*/
void CFE_PSP_GetVersionNumber(uint8 VersionNumbers[4]);

/**
* \brief Obtain the PSP library numeric build number
*
* The build number is a monotonically increasing number that (coarsely)
* reflects the number of commits/changes that have been merged since the
* epoch release. During development cycles this number should increase
* after each subsequent merge/modification.
*
* Like other version information, this is a fixed number assigned at compile time.
*
* \returns The OSAL library build number
*/
uint32 CFE_PSP_GetBuildNumber(void);

#endif /* _cfe_psp_ */
12 changes: 7 additions & 5 deletions fsw/inc/cfe_psp_configdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@
*/
typedef const struct
{
uint8 MajorVersion;
uint8 MinorVersion;
uint8 Revision;
uint8 MissionRev;
char VersionString[32];
uint8 MajorVersion;
uint8 MinorVersion;
uint8 Revision;
uint8 MissionRev;
const char *VersionString; /**< The simple semantic version identifier */
const char *VersionCodeName; /**< Cross-module compatiblity indicator */
uint32 BuildNumber;
} CFE_PSP_VersionInfo_t;

/**
Expand Down
13 changes: 10 additions & 3 deletions fsw/mcp750-vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# This contains the fully platform-specific code to
# run CFE on this target.

include_directories(inc)

# Build the mcp750-vxworks implementation as a library
add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_exception.c
Expand All @@ -18,5 +16,14 @@ add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_start.c
src/cfe_psp_support.c
src/cfe_psp_timer.c
src/cfe_psp_watchdog.c)
src/cfe_psp_watchdog.c
)
target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE
$<TARGET_PROPERTY:psp_module_api,INTERFACE_COMPILE_DEFINITIONS>
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
inc
$<TARGET_PROPERTY:psp_module_api,INTERFACE_INCLUDE_DIRECTORIES>
)

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 @@ -29,7 +29,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 68
#define CFE_PSP_IMPL_BUILD_NUMBER 82
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1"

/*
Expand Down
4 changes: 4 additions & 0 deletions fsw/mcp750-vxworks/psp_module_list.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is a list of modules that is included as a fixed/base set
# when this PSP is selected. They must exist under fsw/modules

eeprom_direct
3 changes: 3 additions & 0 deletions fsw/modules/eeprom_direct/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Create the module
add_psp_module(eeprom_direct cfe_psp_eeprom_direct.c)
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
#include <stdio.h>

#include "cfe_psp.h"
#include "cfe_psp_module.h"

CFE_PSP_MODULE_DECLARE_SIMPLE(eeprom_direct);

void eeprom_direct_Init(uint32 PspModuleId)
{
/* Inform the user that this module is in use */
printf("CFE_PSP: Using DIRECT memory mapped EEPROM implementation\n");
}

/*
** global memory
Expand Down
6 changes: 5 additions & 1 deletion fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ void eeprom_mmap_file_Init(uint32 PspModuleId)
cpuaddr eeprom_address;
uint32 eeprom_size;

/* Inform the user that this module is in use */
printf("CFE_PSP: Using MMAP simulated EEPROM implementation\n");

/*
** Create the simulated EEPROM segment by mapping a memory segment to a file.
** Since the file will be saved, the "EEPROM" contents will be preserved.
Expand All @@ -187,7 +190,8 @@ void eeprom_mmap_file_Init(uint32 PspModuleId)
/*
** Install the 2nd memory range as the mapped file ( EEPROM )
*/
Status = CFE_PSP_MemRangeSet(1, CFE_PSP_MEM_EEPROM, eeprom_address, eeprom_size, CFE_PSP_MEM_SIZE_DWORD, 0);
Status = CFE_PSP_MemRangeSet(1, CFE_PSP_MEM_EEPROM, eeprom_address, eeprom_size, CFE_PSP_MEM_SIZE_DWORD,
CFE_PSP_MEM_ATTR_READWRITE);
OS_printf("CFE_PSP: EEPROM Range (2) created: Start Address = %08lX, Size = %08X Status = %d\n",
(unsigned long)eeprom_address, (unsigned int)eeprom_size, Status);
}
Expand Down
3 changes: 2 additions & 1 deletion fsw/modules/eeprom_stub/cfe_psp_eeprom_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ CFE_PSP_MODULE_DECLARE_SIMPLE(eeprom_stub);

void eeprom_stub_Init(uint32 PspModuleId)
{
/* Nothing to init */
/* Inform the user that this module is in use */
printf("CFE_PSP: Using STUB EEPROM implementation\n");
}

int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value)
Expand Down
11 changes: 8 additions & 3 deletions fsw/pc-linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# This contains the fully platform-specific code to
# run CFE on this target.

include_directories(inc)

# Build the pc-linux implementation as a library
add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_exception.c
Expand All @@ -25,4 +23,11 @@ add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
# Code outside the pc-linux PSP should _not_ depend on this.
target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE
_GNU_SOURCE
)
$<TARGET_PROPERTY:psp_module_api,INTERFACE_COMPILE_DEFINITIONS>
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
inc
$<TARGET_PROPERTY:psp_module_api,INTERFACE_INCLUDE_DIRECTORIES>
)

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 @@ -29,7 +29,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 68
#define CFE_PSP_IMPL_BUILD_NUMBER 82
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1"

/*
Expand Down
4 changes: 4 additions & 0 deletions fsw/pc-linux/psp_module_list.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is a list of modules that is included as a fixed/base set
# when this PSP is selected. They must exist under fsw/modules

eeprom_mmap_file
15 changes: 12 additions & 3 deletions fsw/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# This contains the fully platform-specific code to
# run CFE on this target.

include_directories(inc)

# Build the pc-rtems implementation as a library
add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_exception.c
Expand All @@ -18,5 +16,16 @@ add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_start.c
src/cfe_psp_support.c
src/cfe_psp_timer.c
src/cfe_psp_watchdog.c)
src/cfe_psp_watchdog.c
)

target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE
$<TARGET_PROPERTY:psp_module_api,INTERFACE_COMPILE_DEFINITIONS>
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE
inc
$<TARGET_PROPERTY:psp_module_api,INTERFACE_INCLUDE_DIRECTORIES>
)


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 @@ -29,7 +29,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 68
#define CFE_PSP_IMPL_BUILD_NUMBER 82
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1"

/*
Expand Down
4 changes: 4 additions & 0 deletions fsw/pc-rtems/psp_module_list.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is a list of modules that is included as a fixed/base set
# when this PSP is selected. They must exist under fsw/modules

eeprom_stub
Loading