diff --git a/CMakeLists.txt b/CMakeLists.txt index a7765f0e..0a951b84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,23 +21,44 @@ target_compile_definitions(psp_module_api INTERFACE target_include_directories(psp_module_api INTERFACE fsw/inc # public API fsw/shared/inc # all PSP shared headers + ${CMAKE_CURRENT_LIST_DIR}/fsw/${CFE_PSP_TARGETNAME}/inc # platform-specific headers ${CFE_SOURCE_DIR}/cmake/target/inc # for sysconfig $ # 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 two parts, consisting of a fully platform-specific -# module combined with a shared component which is built for multiple targets. +# 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. 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_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 diff --git a/arch_build.cmake b/arch_build.cmake new file mode 100644 index 00000000..a9b6bcce --- /dev/null +++ b/arch_build.cmake @@ -0,0 +1,37 @@ +########################################################### +# +# CFE arch/platform build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +## Check that PSPNAME is set properly for this arch +#if (NOT CFE_SYSTEM_PSPNAME) +# if (CMAKE_CROSSCOMPILING) +# message(FATAL_ERROR "Cross-compile toolchain ${CMAKE_TOOLCHAIN_FILE} must define CFE_SYSTEM_PSPNAME") +# elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR +# "${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN") +# # Export the variables determined here up to the parent scope +# SET(CFE_SYSTEM_PSPNAME "pc-linux") +# else () +# # Not cross compiling and host system is not recognized +# message(FATAL_ERROR "Do not know how to set CFE_SYSTEM_PSPNAME on ${CMAKE_SYSTEM_NAME} system") +# endif() +#endif (NOT CFE_SYSTEM_PSPNAME) +# +## Translate the CFE_SYSTEM_PSPNAME to a set of modules +#file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/cfe_pspdef_${CFE_SYSTEM_PSPNAME}.cmake" PSP_BASE_MODULE_LIST REGEX "^[a-zA-Z]") +# +## PREPEND the fixed module list to the user-specified module list for every CPU that shares this PSP +## Note the user may have listed extra modules in their targets.cmake, and order is important. +## JPHFIX - cleanup +#message("PSP_MODULE_LIST=${PSP_BASE_MODULE_LIST}") +#foreach(TGTNAME ${TGTSYS_${TARGETSYSTEM}}) +# message("${TGTNAME}_PSP_MODULELIST (orig)=${${TGTNAME}_PSP_MODULELIST}") +# set(${TGTNAME}_PSP_MODULELIST ${PSP_BASE_MODULE_LIST} ${${TGTNAME}_PSP_MODULELIST}) +# message("${TGTNAME}_PSP_MODULELIST (fixed)=${${TGTNAME}_PSP_MODULELIST}") +#endforeach() + diff --git a/cmake/module_list.c.in b/cmake/module_list.c.in new file mode 100644 index 00000000..6795cd6d --- /dev/null +++ b/cmake/module_list.c.in @@ -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 */ diff --git a/fsw/mcp750-vxworks/psp_module_list.cmake b/fsw/mcp750-vxworks/psp_module_list.cmake new file mode 100644 index 00000000..ba9cd802 --- /dev/null +++ b/fsw/mcp750-vxworks/psp_module_list.cmake @@ -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 diff --git a/fsw/modules/eeprom_direct/CMakeLists.txt b/fsw/modules/eeprom_direct/CMakeLists.txt new file mode 100644 index 00000000..fe7a9a57 --- /dev/null +++ b/fsw/modules/eeprom_direct/CMakeLists.txt @@ -0,0 +1,3 @@ + +# Create the module +add_psp_module(eeprom_direct cfe_psp_eeprom_direct.c) diff --git a/fsw/shared/src/cfe_psp_eeprom.c b/fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c similarity index 100% rename from fsw/shared/src/cfe_psp_eeprom.c rename to fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c diff --git a/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c b/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c index f4915b66..c3daf62d 100644 --- a/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c +++ b/fsw/modules/eeprom_mmap_file/cfe_psp_eeprom_mmap_file.c @@ -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. @@ -187,7 +190,7 @@ 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); } diff --git a/fsw/modules/eeprom_stub/cfe_psp_eeprom_stub.c b/fsw/modules/eeprom_stub/cfe_psp_eeprom_stub.c index a2df1424..ca9d936f 100644 --- a/fsw/modules/eeprom_stub/cfe_psp_eeprom_stub.c +++ b/fsw/modules/eeprom_stub/cfe_psp_eeprom_stub.c @@ -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) diff --git a/fsw/pc-linux/psp_module_list.cmake b/fsw/pc-linux/psp_module_list.cmake new file mode 100644 index 00000000..54ffb4c5 --- /dev/null +++ b/fsw/pc-linux/psp_module_list.cmake @@ -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 diff --git a/fsw/pc-rtems/psp_module_list.cmake b/fsw/pc-rtems/psp_module_list.cmake new file mode 100644 index 00000000..38b24e37 --- /dev/null +++ b/fsw/pc-rtems/psp_module_list.cmake @@ -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 diff --git a/fsw/shared/CMakeLists.txt b/fsw/shared/CMakeLists.txt index 0f9ab127..15aa5b1b 100644 --- a/fsw/shared/CMakeLists.txt +++ b/fsw/shared/CMakeLists.txt @@ -14,7 +14,6 @@ # Build the shared implementation as a library add_library(psp-${CFE_PSP_TARGETNAME}-shared OBJECT src/cfe_psp_configdata.c - src/cfe_psp_eeprom.c src/cfe_psp_exceptionstorage.c src/cfe_psp_memrange.c src/cfe_psp_memutils.c diff --git a/fsw/shared/inc/cfe_psp_module.h b/fsw/shared/inc/cfe_psp_module.h index ee4e6157..f25afb4d 100644 --- a/fsw/shared/inc/cfe_psp_module.h +++ b/fsw/shared/inc/cfe_psp_module.h @@ -111,4 +111,12 @@ int32 CFE_PSP_Module_FindByName(const char *ModuleName, uint32 *PspModuleId); */ int32 CFE_PSP_Module_GetAPIEntry(uint32 PspModuleId, CFE_PSP_ModuleApi_t **API); + +/** + * \brief A list of fixed/base modules associated with the PSP + * + * This list should be generated by the build system based on the user-selected PSP + */ +extern CFE_StaticModuleLoadEntry_t CFE_PSP_BASE_MODULE_LIST[]; + #endif /* CFE_PSP_MODULE_H_ */ diff --git a/fsw/shared/src/cfe_psp_module.c b/fsw/shared/src/cfe_psp_module.c index 5e2c0830..fc5f12d2 100644 --- a/fsw/shared/src/cfe_psp_module.c +++ b/fsw/shared/src/cfe_psp_module.c @@ -46,12 +46,13 @@ static uint32 CFE_PSP_ModuleCount = 0; + /*************************************************** - * Function Name: CFE_PSP_ModuleInit + * Function Name: CFE_PSP_ModuleInitList * - * See prototype for full description + * Helper function to initalize a list of modules (not externally called) */ -void CFE_PSP_ModuleInit(void) +void CFE_PSP_ModuleInitList(CFE_StaticModuleLoadEntry_t *ListPtr) { CFE_StaticModuleLoadEntry_t *Entry; CFE_PSP_ModuleApi_t * ApiPtr; @@ -59,7 +60,7 @@ void CFE_PSP_ModuleInit(void) /* * Call the init function for all statically linked modules */ - Entry = GLOBAL_CONFIGDATA.PspModuleList; + Entry = ListPtr; if (Entry != NULL) { while (Entry->Name != NULL) @@ -75,6 +76,20 @@ void CFE_PSP_ModuleInit(void) } } +/*************************************************** + * Function Name: CFE_PSP_ModuleInit + * + * See prototype for full description + */ +void CFE_PSP_ModuleInit(void) +{ + /* First initialize the fixed set of modules for this PSP */ + CFE_PSP_ModuleInitList(CFE_PSP_BASE_MODULE_LIST); + + /* Then initialize any user-selected extension modules */ + CFE_PSP_ModuleInitList(GLOBAL_CONFIGDATA.PspModuleList); +} + /*************************************************** * Function Name: CFE_PSP_Module_GetAPIEntry * diff --git a/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c b/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c index 7deb1f8b..a7e466fd 100644 --- a/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c +++ b/unit-test-coverage/ut-stubs/src/cfe-configdata-stubs.c @@ -19,6 +19,11 @@ #include +CFE_StaticModuleLoadEntry_t CFE_PSP_BASE_MODULE_LIST[] = +{ + { NULL } +}; + Target_CfeConfigData GLOBAL_CFE_CONFIGDATA = { /**