Skip to content

Commit 350f57e

Browse files
committed
Fix #2507, add EDS cmake hooks
Adds CFE_EDS_ENABLED_BUILD option at the top level, along with other logic that is tied in only when this is set TRUE. By default it is set to FALSE, so it does not change any existing workflows yet. Also added are the keys for two configuration values for reflecting EDS DB objects (pointers) and some minor cleanup.
1 parent 37f1d28 commit 350f57e

13 files changed

+236
-20
lines changed

CMakeLists.txt

+15-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ project(CFE C)
6666
# Allow unit tests to be added by any recipe
6767
enable_testing()
6868

69+
# This switch determines whether to use EDS framework
70+
# By default it is set OFF/false as this is a new/experimental feature.
71+
option(CFE_EDS_ENABLED_BUILD "Use EDS framework" OFF)
72+
73+
# Always create directories to hold generated files/wrappers
74+
# EDS makes signficant use of generated files. In non-EDS builds
75+
# some headers and wrapper files are also generated. Directories
76+
# may simply remain empty if not used/needed in the current config.
77+
file(MAKE_DIRECTORY
78+
"${CMAKE_BINARY_DIR}/eds"
79+
"${CMAKE_BINARY_DIR}/obj"
80+
"${CMAKE_BINARY_DIR}/inc"
81+
"${CMAKE_BINARY_DIR}/src"
82+
)
83+
6984
# Include the global routines
7085
include("cmake/global_functions.cmake")
7186

@@ -123,4 +138,3 @@ prepare()
123138
foreach(SYSVAR ${TGTSYS_LIST})
124139
process_arch(${SYSVAR})
125140
endforeach(SYSVAR ${TGTSYS_LIST})
126-

cmake/arch_build.cmake

+11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ function(add_cfe_app APP_NAME APP_SRC_FILES)
101101
add_library(${APP_NAME} ${APPTYPE} ${APP_SRC_FILES} ${ARGN})
102102
target_link_libraries(${APP_NAME} core_api)
103103

104+
# If using "local" EDS linkage, then link the app with the EDS library here.
105+
# Note that the linker will only pull in the compilation unit that actually
106+
# resolves an undefined symbol, which in this case would be the app-specific
107+
# DATATYPE_DB object if one is referenced at all.
108+
#
109+
# By linking with the respective application like this, the net result is that
110+
# only the _referenced_ EDS DBs (i.e. those for loaded apps) are held in memory.
111+
if (CFE_EDS_ENABLED_BUILD AND CFE_EDS_LINK_MODE STREQUAL LOCAL)
112+
target_link_libraries($(APP_NAME) cfe_edsdb_static)
113+
endif()
114+
104115
# An "install" step is only needed for dynamic/runtime loaded apps
105116
if (APP_DYNAMIC_TARGET_LIST)
106117
cfs_app_do_install(${APP_NAME} ${APP_DYNAMIC_TARGET_LIST})

cmake/global_functions.cmake

+15-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010

1111
include(CMakeParseArguments)
1212

13+
# This is done here at the global level so this definition is used for
14+
# ALL code on ALL targets, including host-side tools. Ideally, this should
15+
# only be necessary on the core_api interface, but it does not fully propagate
16+
# to all unit test targets. If/when that issue is resolved, this can be removed.
17+
if (CFE_EDS_ENABLED_BUILD)
18+
19+
# Propagate the setting to a C preprocessor define of the same name
20+
# The CFE_EDS_ENABLED_BUILD switch indicates that any
21+
# compile-time preprocessor blocks should be enabled in this build
22+
add_definitions(-DCFE_EDS_ENABLED_BUILD)
23+
24+
endif(CFE_EDS_ENABLED_BUILD)
25+
26+
1327
##################################################################
1428
#
1529
# FUNCTION: cfe_locate_implementation_file
@@ -58,7 +72,7 @@ function(cfe_locate_implementation_file OUTPUT_VAR FILE_NAME)
5872
string(REPLACE ${MISSION_SOURCE_DIR} "" RELATIVEDIR ${BASEDIR})
5973

6074
# A target-specific prefixed filename gets priority over a direct filename match
61-
# But do not include this variant if the prefix is already part of the relative search path
75+
# But do not include this variant if the prefix is already part of the relative search path
6276
foreach (PREFIX ${LOCATEIMPL_ARG_PREFIX})
6377
if (NOT "${RELATIVEDIR}" MATCHES "/${PREFIX}/")
6478
list(APPEND IMPL_SEARCH_PATH "${BASEDIR}${PREFIX}_${FILE_NAME}")

cmake/mission_build.cmake

+2-7
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,6 @@ function(prepare)
293293
add_definitions(-DSIMULATION=${SIMULATION})
294294
endif (SIMULATION)
295295

296-
# Create directories to hold generated files/wrappers
297-
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/eds")
298-
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/obj")
299-
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/inc")
300-
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/src")
301-
302296
# Certain runtime variables need to be "exported" to the subordinate build, such as
303297
# the specific arch settings and the location of all the apps. This list is collected
304298
# during this function execution and exported at the end.
@@ -548,7 +542,7 @@ function(process_arch TARGETSYSTEM)
548542
# convert to a string which is safe for a directory name
549543
string(REGEX REPLACE "[^A-Za-z0-9]" "_" ARCH_CONFIG_NAME "${BUILD_CONFIG}")
550544
set(ARCH_BINARY_DIR "${CMAKE_BINARY_DIR}/${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}")
551-
file(MAKE_DIRECTORY "${ARCH_BINARY_DIR}" "${ARCH_BINARY_DIR}/inc")
545+
file(MAKE_DIRECTORY "${ARCH_BINARY_DIR}")
552546

553547
message(STATUS "Configuring for system arch: ${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}")
554548

@@ -578,6 +572,7 @@ function(process_arch TARGETSYSTEM)
578572
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
579573
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
580574
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=${CMAKE_EXPORT_COMPILE_COMMANDS}
575+
-DCFE_EDS_ENABLED_BUILD:BOOL=${CFE_EDS_ENABLED_BUILD}
581576
${SELECTED_TOOLCHAIN_FILE}
582577
${CFE_SOURCE_DIR}
583578
WORKING_DIRECTORY

cmake/mission_defaults.cmake

+35
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,41 @@ set(MISSION_MODULE_SEARCH_PATH
6767
set(osal_SEARCH_PATH ".")
6868
set(psp_SEARCH_PATH ".")
6969

70+
# Account for differences when EDS is enabled
71+
if(CFE_EDS_ENABLED_BUILD)
72+
73+
# The EDS database is an object (or set of objects) generated by the tools from the EDS files.
74+
# This can be linked into CFE either as a whole (GLOBAL) or as part of each app (LOCAL).
75+
#
76+
# LOCAL mode may use less memory by only only including DB objects for the apps that are
77+
# originating or terminating CFS message traffic, but GLOBAL mode is simpler as it ensures
78+
# that the entire DB is accessible by any app, even for data definitions that are not its own.
79+
#
80+
# NOTE: If running CI/TO, SBN, or other "generic" apps that relay SB traffic (or otherwise
81+
# handle data that may not have originated on the same CFE instance) then it is recommended
82+
# to stay with GLOBAL mode.
83+
if (NOT DEFINED CFE_EDS_LINK_MODE)
84+
set(CFE_EDS_LINK_MODE GLOBAL)
85+
endif()
86+
87+
# The standard msg module is not used in EDS build, edslib provides an alternate
88+
list(REMOVE_ITEM MISSION_CORE_MODULES msg)
89+
90+
list(APPEND MISSION_CORE_MODULES
91+
"edslib"
92+
"missionlib"
93+
"edsmsg"
94+
)
95+
96+
list(APPEND MISSION_MODULE_SEARCH_PATH
97+
"tools/eds/cfecfs" # CFE/CFS modules and extensions from EdsLib
98+
)
99+
100+
# edslib exists directly under tools/eds (EDS runtime libraries)
101+
set(edslib_SEARCH_PATH "tools/eds")
102+
103+
endif(CFE_EDS_ENABLED_BUILD)
104+
70105
# Include "cfe_assert" library in all builds, because it is included
71106
# in the default startup script. It should not have any effect if not
72107
# used.

cmake/target/CMakeLists.txt

+31-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,37 @@ set(CFE_LINK_NORMAL_LIBS
193193
${${TGTNAME}_STATIC_APPLIST}
194194
)
195195

196+
# If EDS is enabled, then the generated dictionary objects are linked with CFE.
197+
# This can be done statically or dynamically, depending on user preferences.
198+
if (CFE_EDS_ENABLED_BUILD)
199+
200+
# Determine EDS object linking mode for final executable.
201+
# This should be configured via the toolchain file,
202+
# with the default being FALSE (static link)
203+
if (CFE_EDS_LINK_MODE STREQUAL GLOBAL)
204+
205+
# In this mode the full EDS object is statically linked
206+
# In addition, also pull in the runtime lib, which
207+
# supports script language bindings and UI display
208+
list(APPEND CFE_LINK_WHOLE_LIBS
209+
cfe_edsdb_static
210+
edslib_runtime_static
211+
)
212+
213+
endif()
214+
215+
list(APPEND CFE_LINK_WHOLE_LIBS
216+
cfe_missionlib_runtime_static
217+
cfe_missionlib_interfacedb_static
218+
)
219+
220+
# Set a preprocessor define so the source will reference the right thing
221+
target_compile_definitions(core-${TGTNAME} PRIVATE
222+
CFE_EDS_LINK_MODE_${CFE_EDS_LINK_MODE}
223+
)
224+
225+
endif(CFE_EDS_ENABLED_BUILD)
226+
196227
# Handle the list of "embedded files" that should be linked into CFE.
197228
# These are arbitrary files in the mission config that are converted
198229
# into C data structures and linked with the executable. This is
@@ -276,4 +307,3 @@ target_link_libraries(core-${TGTNAME}
276307
# This is implemented in a separate function so
277308
# it may be overridden in an OS-specific manner if necessary.
278309
cfe_exec_do_install(${TGTNAME})
279-

cmake/target/inc/target_config.h

+34
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ typedef const struct
8989
const void *Value;
9090
} CFE_ConfigKeyValue_t;
9191

92+
/**
93+
* The "EdsLib_DatabaseObject" is an abstract structure here.
94+
*/
95+
typedef struct EdsLib_DatabaseObject CFE_EdsDbObject_t;
96+
typedef struct CFE_MissionLib_SoftwareBus_Interface CFE_SbIntfDbObject_t;
97+
9298
/**
9399
* Core Flight Executive configuration information.
94100
*/
@@ -196,6 +202,34 @@ typedef const struct
196202
CFE_ConfigName_t * CoreModuleList; /**< List of CFE core support module names that are statically linked */
197203
CFE_ConfigName_t
198204
*StaticAppList; /**< List of additional CFS Applications that are statically linked into this binary */
205+
206+
/**
207+
* Normal read-only EDS Database object
208+
*
209+
* This EDS DB object pointer is always initialized to be non-null.
210+
* It is qualified as "const" and used for all EDS query requests.
211+
*/
212+
const CFE_EdsDbObject_t *EdsDb;
213+
214+
/**
215+
* Dynamic EDS Database object
216+
*
217+
* This provides a writable (non-const) pointer to the same EDS object as above,
218+
* but only when when dynamic EDS link mode is selected. It will be set NULL
219+
* when static EDS link mode is selected.
220+
*
221+
* This can checked by runtime code to determine the EDS link mode. If it is
222+
* NULL this means the EDS DB is fixed/static and no runtime registration is needed.
223+
* If this pointer is non-null then the EDS DB is dynamic and runtime registration
224+
* is needed.
225+
*/
226+
CFE_EdsDbObject_t *DynamicEdsDb;
227+
228+
/**
229+
* Software bus interface EDS object (MsgId mappings)
230+
*/
231+
const CFE_SbIntfDbObject_t *SbIntfDb;
232+
199233
} Target_ConfigData;
200234

201235
/**

cmake/target/src/target_config.c

+79-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,78 @@ extern CFE_ConfigKeyValue_t CFE_MODULE_VERSION_TABLE[];
126126
*/
127127
extern CFE_StaticModuleLoadEntry_t CFE_PSP_MODULE_LIST[];
128128

129+
#ifdef CFE_EDS_ENABLED_BUILD
130+
131+
#include "cfe_mission_eds_parameters.h"
132+
#include "cfe_mission_eds_interface_parameters.h"
133+
134+
#define CFE_SB_INTF_DB_PTR &CFE_SOFTWAREBUS_INTERFACE
135+
136+
#endif /* CFE_EDS_ENABLED_BUILD */
137+
138+
/*
139+
* Determine the proper values for populating the EDS-related
140+
* fields of the configuration structure. This depends on the
141+
* selected linkage mode (static or dynamic).
142+
*/
143+
144+
/*
145+
* Static (const) EDS object link mode:
146+
* Only the const pointer gets assigned to the EDS object, and the
147+
* non-const pointer gets set NULL. There are no "write" operations
148+
* in this mode -- registration and de-registration is not necessary.
149+
*/
150+
#ifdef CFE_EDS_LINK_MODE_GLOBAL
151+
152+
/* This mode is simple, just point directly at the object defined in the external DB */
153+
#define CFE_CONST_EDS_DB_PTR &EDS_DATABASE
154+
155+
#endif /* CFE_EDS_LINK_MODE_GLOBAL */
156+
157+
/*
158+
* Dynamic (non-const) runtime EDS database object
159+
* This is filled in as additional EDS datasheet objects are registered
160+
*/
161+
#ifdef CFE_EDS_LINK_MODE_LOCAL
162+
163+
static EdsLib_DataTypeDB_t CFE_DYNAMIC_EDS_TABLE[EDS_MAX_DATASHEETS] = {NULL};
164+
165+
static EdsLib_DatabaseObject_t CFE_DYNAMIC_EDSDB_OBJECT = {.AppTableSize = EDS_MAX_DATASHEETS,
166+
.DataTypeDB_Table = CFE_DYNAMIC_EDS_TABLE};
167+
168+
/* The object registered in config points at the local (empty) object */
169+
#define CFE_NONCONST_EDS_DB_PTR &CFE_DYNAMIC_EDSDB_OBJECT
170+
171+
#endif /* CFE_EDS_LINK_MODE_LOCAL */
172+
173+
/*
174+
* For all of these DB objects, use NULL if not defined.
175+
* This covers the case where EDS is not being used.
176+
*/
177+
#ifndef CFE_NONCONST_EDS_DB_PTR
178+
#define CFE_NONCONST_EDS_DB_PTR NULL
179+
#endif
180+
181+
/*
182+
* Note that the non-const object can be used as a const object,
183+
* but not the other way around. This can also be NULL.
184+
*/
185+
#ifndef CFE_CONST_EDS_DB_PTR
186+
#define CFE_CONST_EDS_DB_PTR CFE_NONCONST_EDS_DB_PTR
187+
#endif
188+
189+
/*
190+
* The SB intf DB serves as the lookup table for identification
191+
* of the software bus messages. This can also be NULL if
192+
* EDS is not being used.
193+
*/
194+
#ifndef CFE_SB_INTF_DB_PTR
195+
#define CFE_SB_INTF_DB_PTR NULL
196+
#endif
197+
198+
/* Disable clang-format for the rest of this file, to preserve columns in the struct defs */
199+
/* clang-format off */
200+
129201
/**
130202
* A structure that encapsulates all the CFE static configuration
131203
*/
@@ -152,7 +224,9 @@ Target_CfeConfigData GLOBAL_CFE_CONFIGDATA = {
152224
.UserReservedSize = CFE_PLATFORM_ES_USER_RESERVED_SIZE,
153225

154226
.RamDiskSectorSize = CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE,
155-
.RamDiskTotalSectors = CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS};
227+
.RamDiskTotalSectors = CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS
228+
};
229+
156230

157231
/**
158232
* Instantiation of global system-wide configuration struct
@@ -176,4 +250,8 @@ Target_ConfigData GLOBAL_CONFIGDATA = {
176250
.ModuleVersionList = CFE_MODULE_VERSION_TABLE,
177251
.CoreModuleList = CFE_CORE_MODULE_LIST,
178252
.StaticAppList = CFE_STATIC_APP_LIST,
253+
.EdsDb = CFE_CONST_EDS_DB_PTR,
254+
.DynamicEdsDb = CFE_NONCONST_EDS_DB_PTR,
255+
.SbIntfDb = CFE_SB_INTF_DB_PTR
179256
};
257+

modules/config/fsw/src/cfe_config_init.c

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ void CFE_Config_SetupBasicBuildInfo(void)
177177
KeyVal = CFE_Config_FindTargetKeyValue(GLOBAL_CONFIGDATA.ModuleVersionList, "MISSION");
178178
CFE_Config_SetString(CFE_CONFIGID_MISSION_SRCVER, KeyVal);
179179

180+
/* Global mission EDS runtime DB */
181+
CFE_Config_SetObjPointer(CFE_CONFIGID_MISSION_EDS_DB, GLOBAL_CONFIGDATA.EdsDb);
182+
CFE_Config_SetObjPointer(CFE_CONFIGID_MISSION_SBINTF_DB, GLOBAL_CONFIGDATA.SbIntfDb);
183+
180184
/* propagate the version numbers from version.h */
181185
CFE_Config_SetValue(CFE_CONFIGID_CORE_VERSION_MAJOR, CFE_MAJOR_VERSION);
182186
CFE_Config_SetValue(CFE_CONFIGID_CORE_VERSION_MINOR, CFE_MINOR_VERSION);

modules/config/mission_build.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ set(GENERATED_IDNAME_MAP_LIST)
1818
list(APPEND CFE_CONFIG_IDS
1919
MISSION_NAME
2020
MISSION_SRCVER
21+
MISSION_EDS_DB
22+
MISSION_SBINTF_DB
2123

2224
CORE_VERSION_MAJOR
2325
CORE_VERSION_MINOR

modules/core_api/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ add_library(core_api INTERFACE)
1212
# The fsw/inc here defines global/shared structures and interfaces
1313
target_include_directories(core_api INTERFACE fsw/inc)
1414

15+
# Propagate the setting to a C preprocessor define of the same name
16+
# The CFE_EDS_ENABLED_BUILD switch indicates that any
17+
# compile-time preprocessor blocks should be enabled in this build
18+
if (CFE_EDS_ENABLED_BUILD)
19+
target_compile_definitions(core_api INTERFACE CFE_EDS_ENABLED_BUILD)
20+
endif()
21+
1522
# Propagate any INTERFACE-level include dirs and compile definitions from
1623
# the modules into this abstract interface target
1724
foreach(MOD ${MISSION_CORE_MODULES})
@@ -46,4 +53,3 @@ cfs_app_check_intf(core_api
4653

4754
cfe_tbl_filedef.h
4855
)
49-

modules/evs/fsw/src/cfe_evs_task.c

-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ CFE_EVS_Global_t CFE_EVS_Global;
4343
/* Defines */
4444
#define CFE_EVS_PANIC_DELAY 500 /**< \brief Task delay before PSP panic */
4545

46-
/*
47-
** Local function prototypes.
48-
*/
49-
void CFE_EVS_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr, CFE_SB_MsgId_t MsgId);
50-
bool CFE_EVS_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength);
51-
5246
/* Function Definitions */
5347

5448
/*----------------------------------------------------------------

0 commit comments

Comments
 (0)