diff --git a/CMakeLists.txt b/CMakeLists.txt index 5482b0ae..79bdb5bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,19 +26,39 @@ target_include_directories(psp_module_api INTERFACE $ # 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/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 96% rename from fsw/shared/src/cfe_psp_eeprom.c rename to fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c index 3bf74294..fd4e8f89 100644 --- a/fsw/shared/src/cfe_psp_eeprom.c +++ b/fsw/modules/eeprom_direct/cfe_psp_eeprom_direct.c @@ -38,6 +38,16 @@ #include #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 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..63505926 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,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); } 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 05806af0..b977467c 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..f24dcdc4 100644 --- a/fsw/shared/inc/cfe_psp_module.h +++ b/fsw/shared/inc/cfe_psp_module.h @@ -111,4 +111,11 @@ 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..1854ee96 100644 --- a/fsw/shared/src/cfe_psp_module.c +++ b/fsw/shared/src/cfe_psp_module.c @@ -47,11 +47,11 @@ 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 +59,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 +75,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..f59e9fbc 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,8 @@ #include +CFE_StaticModuleLoadEntry_t CFE_PSP_BASE_MODULE_LIST[] = {{NULL}}; + Target_CfeConfigData GLOBAL_CFE_CONFIGDATA = { /**