Skip to content

Commit

Permalink
Merge pull request #343 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
PSP Integration candidate: Caelum-rc4+dev9
  • Loading branch information
astrogeco committed May 19, 2022
2 parents 62bf885 + 22dd578 commit 925fb36
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
codeql:
name: Codeql
uses: nasa/cFS/.github/workflows/codeql-build.yml@main
uses: nasa/cFS/.github/workflows/codeql-reusable.yml@main
with:
make-prep: 'make prep'
make: 'make psp-pc-linux && make native/default_cpu1/psp/unit-test-coverage/ && make native/default_cpu1/psp/ut-stubs/'
component-path: psp
make: 'make -C build/native/default_cpu1/psp'
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ This is a collection of APIs abstracting platform specific functionality to be l

## Version History


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

- Update codeql workflow for reusable updates
- Add cpu affinity example
- Update RTEMS CMake Platform File
- See <https://github.com/nasa/PSP/pull/343> and <https://github.com/nasa/cFS/pull/471>

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

- Standardize version.h
Expand Down
57 changes: 33 additions & 24 deletions cmake/Modules/Platform/RTEMS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,54 @@ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
set(CMAKE_SHARED_MODULE_C_FLAGS "")
set(CMAKE_SHARED_MODULE_CXX_FLAGS "")

# Set the CMAKE_EXE_EXPORTS_C_FLAG which is for executables
# using dynamic loading/linking
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")


# Include the system specs directly within the COMPILE_OBJECT definitions
# This way it does not need to be done via CMAKE_C_FLAGS and it simplifies
# the process in general.
set(RTEMS_SYS_SPECS_FLAGS "-B${RTEMS_TARGET_PATH}/${RTEMS_BSP}/lib -specs bsp_specs -qrtems")
# Note that the specs vary between RTEMS 5, RTEMS 6, and the Gaisler RCC version of RTEMS 5
# These differences are accounted for in the toolchain file in the RTEMS_BSP_SPECS macro
set(RTEMS_SYS_SPECS_FLAGS "-B${RTEMS_TARGET_PATH}/${RTEMS_BSP}/lib ${RTEMS_BSP_SPECS_FLAGS} -qrtems")

# Basic command templates for compiling C and C++ code
set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${RTEMS_SYS_SPECS_FLAGS} ${RTEMS_BSP_C_FLAGS} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${RTEMS_SYS_SPECS_FLAGS} ${RTEMS_BSP_CXX_FLAGS} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")


# This creates a simple relocatable object file, not a shared library
set(CMAKE_SHARED_OBJECT_LINKER_FLAGS -r)
set(CMAKE_C_CREATE_SHARED_MODULE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> ${CMAKE_SHARED_OBJECT_LINKER_FLAGS} <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_MODULE})
set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_MODULE})
set(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_C_CREATE_SHARED_MODULE})

# Additional link flags for entry point and relocation address
# RTEMS uses "Init" rather than "main" as its entry point
# This flag ensures that the Init symbol is not dropped at link time.
set(RTEMS_SYS_LINKFLAGS "-u Init")
if (RTEMS_RELOCADDR)
set(RTEMS_SYS_LINKFLAGS "${RTEMS_SYS_LINKFLAGS} -Wl,-Ttext,${RTEMS_RELOCADDR}")
endif (RTEMS_RELOCADDR)

# The link procedure to support dynamic loading using the RTEMS dlopen()
# First create a "prelink" executable using a typical link procedure
# Then run "rtems-syms" and re-link the output into a final executable
set(CMAKE_C_LINK_EXECUTABLE
"<CMAKE_C_COMPILER> ${RTEMS_SYS_SPECS_FLAGS} ${RTEMS_BSP_C_FLAGS} <FLAGS> ${RTEMS_SYS_LINKFLAGS} -o <TARGET>-prelink <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>"
"${RTEMS_TOOLS_PREFIX}/bin/rtems-syms -v -e -c ${RTEMS_BSP_C_FLAGS} -C <CMAKE_C_COMPILER> -o <TARGET>-dl-sym.o <TARGET>-prelink"
"<CMAKE_C_COMPILER> ${RTEMS_SYS_SPECS_FLAGS} ${RTEMS_BSP_C_FLAGS} <FLAGS> ${RTEMS_SYS_LINKFLAGS} -o <TARGET> <TARGET>-dl-sym.o <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>")

set(RTEMS_TARGET_PATH
# If RTEMS_DYNAMIC_LOAD is defined in the toolchain file, the executable will be a loadable object
# similar to vxWorks. This allows the system to be built, then loaded on an RTEMS runtime image using
# the RTEMS dynamic loader
# If RTEMS_DYNAMIC_LOAD is not defined, then a traditional linked executable will be created.
if(RTEMS_DYNAMIC_LOAD)
# Dynamic load is just a shared library
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <LINK_FLAGS> -o <TARGET> ${CMAKE_SHARED_OBJECT_LINKER_FLAGS} <OBJECTS> <LINK_LIBRARIES>")
else()
# Set the CMAKE_EXE_EXPORTS_C_FLAG which is for executables
# using dynamic loading/linking
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")

# Additional link flags for entry point and relocation address
# RTEMS uses "Init" rather than "main" as its entry point
# This flag ensures that the Init symbol is not dropped at link time.
set(RTEMS_SYS_LINKFLAGS "-u Init")
if (RTEMS_RELOCADDR)
set(RTEMS_SYS_LINKFLAGS "${RTEMS_SYS_LINKFLAGS} -Wl,-Ttext,${RTEMS_RELOCADDR}")
endif (RTEMS_RELOCADDR)

# The link procedure to support dynamic loading using the RTEMS dlopen()
# First create a "prelink" executable using a typical link procedure
# Then run "rtems-syms" and re-link the output into a final executable
set(CMAKE_C_LINK_EXECUTABLE
"<CMAKE_C_COMPILER> ${RTEMS_SYS_SPECS_FLAGS} ${RTEMS_BSP_C_FLAGS} <FLAGS> ${RTEMS_SYS_LINKFLAGS} -o <TARGET>-prelink <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>"
"${RTEMS_TOOLS_PREFIX}/bin/rtems-syms -v -e -c ${RTEMS_BSP_C_FLAGS} -C <CMAKE_C_COMPILER> -o <TARGET>-dl-sym.o <TARGET>-prelink"
"<CMAKE_C_COMPILER> ${RTEMS_SYS_SPECS_FLAGS} ${RTEMS_BSP_C_FLAGS} <FLAGS> ${RTEMS_SYS_LINKFLAGS} -o <TARGET> <TARGET>-dl-sym.o <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>")
endif(RTEMS_DYNAMIC_LOAD)

SET(RTEMS_TARGET_PATH
"${RTEMS_BSP_PREFIX}/${CMAKE_SYSTEM_PROCESSOR}-rtems${CMAKE_SYSTEM_VERSION}")

set(RTEMS_TOOLS_PATH
Expand Down
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 21
#define CFE_PSP_IMPL_BUILD_NUMBER 34
#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 21
#define CFE_PSP_IMPL_BUILD_NUMBER 34
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4"

/*
Expand Down
18 changes: 17 additions & 1 deletion fsw/pc-linux/src/cfe_psp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ static const struct option longOpts[] = {{"reset", required_argument, NULL, 'R'}
*/
int32 CFE_PSP_OS_EventHandler(OS_Event_t event, osal_id_t object_id, void *data)
{
char taskname[OS_MAX_API_NAME];
char taskname[OS_MAX_API_NAME];
cpu_set_t cpuset;

switch (event)
{
Expand All @@ -170,6 +171,21 @@ int32 CFE_PSP_OS_EventHandler(OS_Event_t event, osal_id_t object_id, void *data)
/* Get the name from OSAL and propagate to the pthread/system layer */
if (OS_GetResourceName(object_id, taskname, sizeof(taskname)) == OS_SUCCESS)
{
/*
* Example mechanism for setting thread affinity
*
* Could assign based on task name, pattern within name (CFE_* on 0,
* *_CN where N is desired core), round robin or whatever the requrements are.
*
* Just assigning all "CFE_*" tasks to core zero and let the rest float.
*/
if (strncmp(taskname, "CFE_", 4) == 0)
{
CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);
pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
}

/*
* glibc/kernel has an internal limit for this name.
* If the OSAL name is longer, just truncate it.
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 21
#define CFE_PSP_IMPL_BUILD_NUMBER 34
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.6.0-rc4"

/*
Expand Down

0 comments on commit 925fb36

Please sign in to comment.