From 3c4b9cf1d90773af83b34e408f5efb4f99a9be30 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 26 Feb 2021 16:00:04 -0500 Subject: [PATCH] Fix #972, Reorganize CFE core into separate modules Significant reorganization of the CFE core directory and header file structure. All modules become separate subdirectories under fsw/modules. Additionally, the interfaces to CFE core (public and internal) are also separated into modules. CMake "interface libraries" and related constructs are used to manage the include paths to all the separate modules. --- CMakeLists.txt | 7 +- cmake/arch_build.cmake | 73 +- cmake/check_header.c.in | 4 + cmake/global_functions.cmake | 14 +- cmake/mission_build.cmake | 29 +- cmake/mission_defaults.cmake | 11 +- cmake/target/src/target_config.c | 2 +- fsw/cfe-core/src/inc/private/cfe_private.h | 338 ---- fsw/cfe-core/unit-test/CMakeLists.txt | 12 - modules/cfe_app_intf/CMakeLists.txt | 54 + modules/cfe_app_intf/arch_build.cmake | 19 + .../cfe_app_intf}/eds/base_types.xml | 0 .../cfe_app_intf}/eds/ccsds_spacepacket.xml | 0 .../cfe_app_intf}/eds/cfe_es.xml | 0 .../cfe_app_intf}/eds/cfe_evs.xml | 0 .../cfe_app_intf}/eds/cfe_fs.xml | 0 .../cfe_app_intf}/eds/cfe_sb.xml | 0 .../cfe_app_intf}/eds/cfe_tbl.xml | 0 .../cfe_app_intf}/eds/cfe_time.xml | 0 .../cfe_app_intf}/eds/config.xml | 0 .../cfe_app_intf/fsw}/inc/cfe.h | 9 +- .../cfe_app_intf/fsw/inc/cfe_endian.h | 12 +- .../cfe_app_intf/fsw}/inc/cfe_error.h | 0 modules/cfe_app_intf/fsw/inc/cfe_es.h | 1776 +++++++++++++++++ .../fsw/inc/cfe_es_api_typedefs.h | 194 ++ .../fsw}/inc/cfe_es_extern_typedefs.h | 2 +- modules/cfe_app_intf/fsw/inc/cfe_evs.h | 397 ++++ .../fsw/inc/cfe_evs_api_typedefs.h | 70 + .../fsw}/inc/cfe_evs_extern_typedefs.h | 2 +- modules/cfe_app_intf/fsw/inc/cfe_fs.h | 384 ++++ .../fsw/inc/cfe_fs_api_typedefs.h | 132 ++ .../fsw}/inc/cfe_fs_extern_typedefs.h | 2 +- .../cfe_app_intf/fsw/inc/cfe_msg.h | 8 +- .../fsw/inc/cfe_msg_api_typedefs.h | 25 + .../cfe_app_intf/fsw/inc/cfe_resourceid.h | 39 +- .../fsw/inc/cfe_resourceid_api_typedefs.h | 82 + modules/cfe_app_intf/fsw/inc/cfe_sb.h | 1380 +++++++++++++ .../fsw/inc/cfe_sb_api_typedefs.h | 190 ++ .../fsw}/inc/cfe_sb_extern_typedefs.h | 15 +- modules/cfe_app_intf/fsw/inc/cfe_tbl.h | 796 ++++++++ .../fsw/inc/cfe_tbl_api_typedefs.h | 127 ++ .../fsw}/inc/cfe_tbl_extern_typedefs.h | 4 +- .../cfe_app_intf/fsw}/inc/cfe_tbl_filedef.h | 0 modules/cfe_app_intf/fsw/inc/cfe_time.h | 788 ++++++++ .../fsw/inc/cfe_time_api_typedefs.h | 88 + .../fsw}/inc/cfe_time_extern_typedefs.h | 19 +- .../cfe_app_intf/fsw}/inc/cfe_version.h | 21 - .../cfe_app_intf}/mission_build.cmake | 0 modules/cfe_app_intf/ut-stubs/CMakeLists.txt | 41 + .../cfe_app_intf/ut-stubs/src}/ut_es_stubs.c | 27 +- .../cfe_app_intf/ut-stubs/src}/ut_evs_stubs.c | 4 +- .../cfe_app_intf/ut-stubs/src}/ut_fs_stubs.c | 0 .../cfe_app_intf/ut-stubs/src}/ut_msg_stubs.c | 0 .../ut-stubs/src}/ut_resourceid_stubs.c | 2 +- .../cfe_app_intf/ut-stubs/src}/ut_sb_stubs.c | 5 +- .../cfe_app_intf/ut-stubs/src}/ut_tbl_stubs.c | 4 +- .../ut-stubs/src}/ut_time_stubs.c | 2 +- modules/cfe_internal_intf/CMakeLists.txt | 34 + .../cfe_internal_intf}/arch_build.cmake | 6 - modules/cfe_internal_intf/eds/base_types.xml | 148 ++ modules/cfe_internal_intf/eds/config.xml | 59 + .../fsw/inc}/cfe_core_resourceid_basevalues.h | 0 .../fsw/inc}/cfe_es_erlog_typedef.h | 5 +- .../fsw/inc}/cfe_es_perfdata_typedef.h | 0 .../fsw/inc}/cfe_es_resetdata_typedef.h | 2 +- .../fsw/inc}/cfe_evs_log_typedef.h | 2 + .../fsw/inc}/cfe_sb_destination_typedef.h | 2 +- .../cfe_internal_intf/fsw/inc}/cfe_sbr.h | 51 +- .../fsw/inc/cfe_sbr_api_typedefs.h | 78 + .../fsw/inc/cfe_time_resetvars_typedef.h | 70 + .../cfe_internal_intf/ut-stubs/CMakeLists.txt | 33 + .../ut-stubs/inc/ut_osprintf_stubs.h | 103 + .../ut-stubs/inc/ut_support.h | 747 +++++++ .../ut-stubs/src/ut_osprintf_stubs.c | 168 ++ .../ut-stubs/src/ut_support.c | 753 +++++++ modules/es/CMakeLists.txt | 39 + .../es/fsw}/inc/cfe_es_events.h | 0 .../src => modules/es/fsw}/inc/cfe_es_msg.h | 4 +- .../es => modules/es/fsw/src}/cfe_es_api.c | 12 +- .../es => modules/es/fsw/src}/cfe_es_apps.c | 9 +- .../es => modules/es/fsw/src}/cfe_es_apps.h | 4 +- .../es/fsw/src}/cfe_es_backgroundtask.c | 6 +- .../es => modules/es/fsw/src}/cfe_es_cds.c | 9 +- .../es => modules/es/fsw/src}/cfe_es_cds.h | 4 - .../es/fsw/src}/cfe_es_cds_mempool.c | 8 +- .../es/fsw/src}/cfe_es_cds_mempool.h | 1 - .../es => modules/es/fsw/src}/cfe_es_erlog.c | 9 +- .../es/fsw/src}/cfe_es_generic_pool.c | 9 +- .../es/fsw/src}/cfe_es_generic_pool.h | 1 - .../es => modules/es/fsw/src}/cfe_es_global.h | 24 +- modules/es/fsw/src/cfe_es_internal.h | 60 + .../es => modules/es/fsw/src}/cfe_es_log.h | 6 +- .../es/fsw/src}/cfe_es_mempool.c | 9 +- .../es/fsw/src}/cfe_es_mempool.h | 1 + .../es => modules/es/fsw/src}/cfe_es_objtab.c | 4 +- .../es => modules/es/fsw/src}/cfe_es_perf.c | 11 +- .../es => modules/es/fsw/src}/cfe_es_perf.h | 10 +- .../es/fsw/src}/cfe_es_resource.c | 5 +- .../es/fsw/src}/cfe_es_resource.h | 4 +- .../es => modules/es/fsw/src}/cfe_es_start.c | 9 +- .../es => modules/es/fsw/src}/cfe_es_start.h | 2 +- .../es => modules/es/fsw/src}/cfe_es_syslog.c | 6 +- .../es => modules/es/fsw/src}/cfe_es_task.c | 16 +- .../es => modules/es/fsw/src}/cfe_es_task.h | 12 +- .../es => modules/es/fsw/src}/cfe_es_verify.h | 0 modules/es/ut-coverage/CMakeLists.txt | 7 + .../es/ut-coverage}/es_UT.c | 0 .../es/ut-coverage}/es_UT.h | 0 modules/evs/CMakeLists.txt | 33 + .../evs/fsw}/inc/cfe_evs_events.h | 0 .../src => modules/evs/fsw}/inc/cfe_evs_msg.h | 5 +- .../src/evs => modules/evs/fsw/src}/cfe_evs.c | 10 +- .../evs => modules/evs/fsw/src}/cfe_evs_log.c | 5 +- .../evs => modules/evs/fsw/src}/cfe_evs_log.h | 0 .../evs/fsw/src}/cfe_evs_task.c | 15 +- .../evs/fsw/src}/cfe_evs_task.h | 16 +- .../evs/fsw/src}/cfe_evs_utils.c | 10 +- .../evs/fsw/src}/cfe_evs_utils.h | 3 + .../evs/fsw/src}/cfe_evs_verify.h | 0 modules/evs/ut-coverage/CMakeLists.txt | 7 + .../evs/ut-coverage}/evs_UT.c | 0 .../evs/ut-coverage}/evs_UT.h | 0 modules/fs/CMakeLists.txt | 25 + .../fs => modules/fs/fsw/src}/cfe_fs_api.c | 10 +- modules/fs/fsw/src/cfe_fs_internal.h | 44 + .../fs => modules/fs/fsw/src}/cfe_fs_priv.c | 7 +- .../fs => modules/fs/fsw/src}/cfe_fs_priv.h | 4 +- modules/fs/ut-coverage/CMakeLists.txt | 7 + .../fs/ut-coverage}/fs_UT.c | 0 .../fs/ut-coverage}/fs_UT.h | 0 modules/msg/CMakeLists.txt | 36 +- .../src => modules/msg/fsw}/inc/ccsds_hdr.h | 1 - modules/msg/{ => fsw}/src/cfe_msg_ccsdsext.c | 2 +- modules/msg/{ => fsw}/src/cfe_msg_ccsdspri.c | 2 +- .../src}/cfe_msg_defaults.h | 1 + modules/msg/{ => fsw}/src/cfe_msg_init.c | 2 +- .../src/cfe_msg_initdefaulthdr_pri.c | 0 .../src/cfe_msg_initdefaulthdr_priext.c | 0 .../msg/{ => fsw}/src/cfe_msg_msgid_shared.c | 2 +- modules/msg/{ => fsw}/src/cfe_msg_msgid_v1.c | 3 +- modules/msg/{ => fsw}/src/cfe_msg_msgid_v2.c | 2 +- .../{private_inc => fsw/src}/cfe_msg_priv.h | 1 + .../{ => fsw}/src/cfe_msg_sechdr_checksum.c | 2 +- modules/msg/{ => fsw}/src/cfe_msg_sechdr_fc.c | 2 +- .../msg/{ => fsw}/src/cfe_msg_sechdr_time.c | 2 +- modules/msg/mission_build.cmake | 4 +- .../default_cfe_msg_hdr_pri.h | 23 +- .../default_cfe_msg_hdr_priext.h | 0 .../default_cfe_msg_sechdr.h | 0 .../CMakeLists.txt | 6 +- .../msg_UT.c | 0 .../test_cfe_msg_ccsdsext.c | 2 +- .../test_cfe_msg_ccsdsext.h | 0 .../test_cfe_msg_ccsdspri.c | 2 +- .../test_cfe_msg_ccsdspri.h | 0 .../test_cfe_msg_checksum.c | 2 +- .../test_cfe_msg_checksum.h | 0 .../test_cfe_msg_fc.c | 2 +- .../test_cfe_msg_fc.h | 0 .../test_cfe_msg_init.c | 2 +- .../test_cfe_msg_init.h | 0 .../test_cfe_msg_msgid.h | 0 .../test_cfe_msg_msgid_shared.c | 2 +- .../test_cfe_msg_msgid_shared.h | 0 .../test_cfe_msg_msgid_v1.c | 2 +- .../test_cfe_msg_msgid_v2.c | 2 +- .../test_cfe_msg_time.c | 2 +- .../test_cfe_msg_time.h | 0 .../test_msg_ext_not.c | 2 +- .../test_msg_not.c | 2 +- .../test_msg_not.h | 0 .../test_msg_pri_not.c | 2 +- .../test_msg_prionly.c | 2 +- .../test_msg_utils.h | 2 +- modules/resourceid/CMakeLists.txt | 8 +- modules/resourceid/arch_build.cmake | 13 - .../{ => fsw}/src/cfe_resourceid_api.c | 2 +- modules/resourceid/mission_build.cmake | 4 +- .../cfe_resourceid_osal_compatible.h | 0 .../cfe_resourceid_simple.h | 0 .../cfe_resourceid_strict.h | 0 .../CMakeLists.txt | 8 +- .../test_cfe_resourceid.c | 2 +- .../src/inc => modules/saved_inc}/cfe_es.h | 2 +- .../src/inc => modules/saved_inc}/cfe_evs.h | 0 .../src/inc => modules/saved_inc}/cfe_fs.h | 0 .../src/inc => modules/saved_inc}/cfe_sb.h | 3 +- .../src/inc => modules/saved_inc}/cfe_tbl.h | 2 +- .../src/inc => modules/saved_inc}/cfe_time.h | 17 - modules/sb/CMakeLists.txt | 39 + .../sb/fsw}/inc/cfe_sb_events.h | 0 .../src => modules/sb/fsw}/inc/cfe_sb_msg.h | 7 +- .../sb => modules/sb/fsw/src}/cfe_sb_api.c | 12 +- .../sb => modules/sb/fsw/src}/cfe_sb_buf.c | 6 +- .../sb => modules/sb/fsw/src}/cfe_sb_init.c | 10 +- modules/sb/fsw/src/cfe_sb_internal.h | 51 + .../sb/fsw/src}/cfe_sb_msg_id_util.c | 9 +- .../sb => modules/sb/fsw/src}/cfe_sb_priv.c | 12 +- .../sb => modules/sb/fsw/src}/cfe_sb_priv.h | 14 +- .../sb => modules/sb/fsw/src}/cfe_sb_task.c | 13 +- .../sb => modules/sb/fsw/src}/cfe_sb_util.c | 7 +- .../sb => modules/sb/fsw/src}/cfe_sb_verify.h | 0 modules/sb/ut-coverage/CMakeLists.txt | 7 + .../sb/ut-coverage}/sb_UT.c | 4 +- .../sb/ut-coverage}/sb_UT.h | 0 modules/sbr/CMakeLists.txt | 14 +- .../sbr/{ => fsw}/src/cfe_sbr_map_direct.c | 4 +- modules/sbr/{ => fsw}/src/cfe_sbr_map_hash.c | 4 +- .../{private_inc => fsw/src}/cfe_sbr_priv.h | 2 +- .../{ => fsw}/src/cfe_sbr_route_unsorted.c | 4 +- .../CMakeLists.txt | 14 +- .../test_cfe_sbr_map_direct.c | 2 +- .../test_cfe_sbr_map_hash.c | 2 +- .../test_cfe_sbr_route_unsorted.c | 2 +- modules/tbl/CMakeLists.txt | 33 + .../tbl/fsw}/inc/cfe_tbl_events.h | 0 .../src => modules/tbl/fsw}/inc/cfe_tbl_msg.h | 5 +- .../tbl => modules/tbl/fsw/src}/cfe_tbl_api.c | 8 +- .../tbl/fsw/src}/cfe_tbl_internal.c | 8 +- .../tbl/fsw/src}/cfe_tbl_internal.h | 15 +- .../tbl/fsw/src}/cfe_tbl_task.c | 9 +- .../tbl/fsw/src}/cfe_tbl_task.h | 2 - .../tbl/fsw/src}/cfe_tbl_task_cmds.c | 11 +- .../tbl/fsw/src}/cfe_tbl_task_cmds.h | 7 +- .../tbl/fsw/src}/cfe_tbl_verify.h | 0 modules/tbl/ut-coverage/CMakeLists.txt | 7 + .../tbl/ut-coverage}/tbl_UT.c | 2 +- .../tbl/ut-coverage}/tbl_UT.h | 0 modules/time/CMakeLists.txt | 33 + .../time/fsw}/inc/cfe_time_events.h | 0 .../time/fsw}/inc/cfe_time_msg.h | 4 +- .../time/fsw/src}/cfe_time_api.c | 2 + .../time/fsw/src}/cfe_time_task.c | 6 + .../time/fsw/src}/cfe_time_tone.c | 8 + .../time/fsw/src}/cfe_time_utils.c | 6 +- .../time/fsw/src}/cfe_time_utils.h | 5 +- .../time/fsw/src}/cfe_time_verify.h | 3 + modules/time/ut-coverage/CMakeLists.txt | 7 + .../time/ut-coverage}/time_UT.c | 0 .../time/ut-coverage}/time_UT.h | 0 240 files changed, 9620 insertions(+), 953 deletions(-) create mode 100644 cmake/check_header.c.in delete mode 100644 fsw/cfe-core/src/inc/private/cfe_private.h create mode 100644 modules/cfe_app_intf/CMakeLists.txt create mode 100644 modules/cfe_app_intf/arch_build.cmake rename {fsw/cfe-core => modules/cfe_app_intf}/eds/base_types.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/ccsds_spacepacket.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/cfe_es.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/cfe_evs.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/cfe_fs.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/cfe_sb.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/cfe_tbl.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/cfe_time.xml (100%) rename {fsw/cfe-core => modules/cfe_app_intf}/eds/config.xml (100%) rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe.h (92%) rename fsw/cfe-core/src/inc/ccsds.h => modules/cfe_app_intf/fsw/inc/cfe_endian.h (88%) rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_error.h (100%) create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_es.h create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_es_api_typedefs.h rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_es_extern_typedefs.h (99%) create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_evs.h create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_evs_api_typedefs.h rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_evs_extern_typedefs.h (99%) create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_fs.h create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_fs_api_typedefs.h rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_fs_extern_typedefs.h (99%) rename fsw/cfe-core/src/inc/cfe_msg_api.h => modules/cfe_app_intf/fsw/inc/cfe_msg.h (99%) rename fsw/cfe-core/src/inc/cfe_msg_typedefs.h => modules/cfe_app_intf/fsw/inc/cfe_msg_api_typedefs.h (84%) rename fsw/cfe-core/src/inc/cfe_resourceid_api.h => modules/cfe_app_intf/fsw/inc/cfe_resourceid.h (87%) create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_resourceid_api_typedefs.h create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_sb.h create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_sb_api_typedefs.h rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_sb_extern_typedefs.h (85%) create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_tbl.h create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_tbl_api_typedefs.h rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_tbl_extern_typedefs.h (96%) rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_tbl_filedef.h (100%) create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_time.h create mode 100644 modules/cfe_app_intf/fsw/inc/cfe_time_api_typedefs.h rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_time_extern_typedefs.h (91%) rename {fsw/cfe-core/src => modules/cfe_app_intf/fsw}/inc/cfe_version.h (81%) rename {fsw/cfe-core => modules/cfe_app_intf}/mission_build.cmake (100%) create mode 100644 modules/cfe_app_intf/ut-stubs/CMakeLists.txt rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_es_stubs.c (98%) rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_evs_stubs.c (99%) rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_fs_stubs.c (100%) rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_msg_stubs.c (100%) rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_resourceid_stubs.c (99%) rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_sb_stubs.c (99%) rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_tbl_stubs.c (99%) rename {fsw/cfe-core/ut-stubs => modules/cfe_app_intf/ut-stubs/src}/ut_time_stubs.c (99%) create mode 100644 modules/cfe_internal_intf/CMakeLists.txt rename {fsw/cfe-core => modules/cfe_internal_intf}/arch_build.cmake (79%) create mode 100644 modules/cfe_internal_intf/eds/base_types.xml create mode 100644 modules/cfe_internal_intf/eds/config.xml rename {fsw/cfe-core/src/inc/private => modules/cfe_internal_intf/fsw/inc}/cfe_core_resourceid_basevalues.h (100%) rename {fsw/cfe-core/src/inc/private => modules/cfe_internal_intf/fsw/inc}/cfe_es_erlog_typedef.h (95%) rename {fsw/cfe-core/src/inc/private => modules/cfe_internal_intf/fsw/inc}/cfe_es_perfdata_typedef.h (100%) rename {fsw/cfe-core/src/inc/private => modules/cfe_internal_intf/fsw/inc}/cfe_es_resetdata_typedef.h (96%) rename {fsw/cfe-core/src/inc/private => modules/cfe_internal_intf/fsw/inc}/cfe_evs_log_typedef.h (98%) rename {fsw/cfe-core/src/inc/private => modules/cfe_internal_intf/fsw/inc}/cfe_sb_destination_typedef.h (95%) rename {fsw/cfe-core/src/inc/private => modules/cfe_internal_intf/fsw/inc}/cfe_sbr.h (79%) create mode 100644 modules/cfe_internal_intf/fsw/inc/cfe_sbr_api_typedefs.h create mode 100644 modules/cfe_internal_intf/fsw/inc/cfe_time_resetvars_typedef.h create mode 100644 modules/cfe_internal_intf/ut-stubs/CMakeLists.txt create mode 100644 modules/cfe_internal_intf/ut-stubs/inc/ut_osprintf_stubs.h create mode 100644 modules/cfe_internal_intf/ut-stubs/inc/ut_support.h create mode 100644 modules/cfe_internal_intf/ut-stubs/src/ut_osprintf_stubs.c create mode 100644 modules/cfe_internal_intf/ut-stubs/src/ut_support.c create mode 100644 modules/es/CMakeLists.txt rename {fsw/cfe-core/src => modules/es/fsw}/inc/cfe_es_events.h (100%) rename {fsw/cfe-core/src => modules/es/fsw}/inc/cfe_es_msg.h (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_api.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_apps.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_apps.h (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_backgroundtask.c (98%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_cds.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_cds.h (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_cds_mempool.c (98%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_cds_mempool.h (98%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_erlog.c (98%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_generic_pool.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_generic_pool.h (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_global.h (91%) create mode 100644 modules/es/fsw/src/cfe_es_internal.h rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_log.h (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_mempool.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_mempool.h (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_objtab.c (98%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_perf.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_perf.h (96%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_resource.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_resource.h (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_start.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_start.h (98%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_syslog.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_task.c (99%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_task.h (97%) rename {fsw/cfe-core/src/es => modules/es/fsw/src}/cfe_es_verify.h (100%) create mode 100644 modules/es/ut-coverage/CMakeLists.txt rename {fsw/cfe-core/unit-test => modules/es/ut-coverage}/es_UT.c (100%) rename {fsw/cfe-core/unit-test => modules/es/ut-coverage}/es_UT.h (100%) create mode 100644 modules/evs/CMakeLists.txt rename {fsw/cfe-core/src => modules/evs/fsw}/inc/cfe_evs_events.h (100%) rename {fsw/cfe-core/src => modules/evs/fsw}/inc/cfe_evs_msg.h (99%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs.c (98%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs_log.c (98%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs_log.h (100%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs_task.c (99%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs_task.h (93%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs_utils.c (99%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs_utils.h (98%) rename {fsw/cfe-core/src/evs => modules/evs/fsw/src}/cfe_evs_verify.h (100%) create mode 100644 modules/evs/ut-coverage/CMakeLists.txt rename {fsw/cfe-core/unit-test => modules/evs/ut-coverage}/evs_UT.c (100%) rename {fsw/cfe-core/unit-test => modules/evs/ut-coverage}/evs_UT.h (100%) create mode 100644 modules/fs/CMakeLists.txt rename {fsw/cfe-core/src/fs => modules/fs/fsw/src}/cfe_fs_api.c (99%) create mode 100644 modules/fs/fsw/src/cfe_fs_internal.h rename {fsw/cfe-core/src/fs => modules/fs/fsw/src}/cfe_fs_priv.c (96%) rename {fsw/cfe-core/src/fs => modules/fs/fsw/src}/cfe_fs_priv.h (98%) create mode 100644 modules/fs/ut-coverage/CMakeLists.txt rename {fsw/cfe-core/unit-test => modules/fs/ut-coverage}/fs_UT.c (100%) rename {fsw/cfe-core/unit-test => modules/fs/ut-coverage}/fs_UT.h (100%) rename {fsw/cfe-core/src => modules/msg/fsw}/inc/ccsds_hdr.h (99%) rename modules/msg/{ => fsw}/src/cfe_msg_ccsdsext.c (99%) rename modules/msg/{ => fsw}/src/cfe_msg_ccsdspri.c (99%) rename modules/msg/{private_inc => fsw/src}/cfe_msg_defaults.h (98%) rename modules/msg/{ => fsw}/src/cfe_msg_init.c (98%) rename modules/msg/{ => fsw}/src/cfe_msg_initdefaulthdr_pri.c (100%) rename modules/msg/{ => fsw}/src/cfe_msg_initdefaulthdr_priext.c (100%) rename modules/msg/{ => fsw}/src/cfe_msg_msgid_shared.c (98%) rename modules/msg/{ => fsw}/src/cfe_msg_msgid_v1.c (98%) rename modules/msg/{ => fsw}/src/cfe_msg_msgid_v2.c (99%) rename modules/msg/{private_inc => fsw/src}/cfe_msg_priv.h (99%) rename modules/msg/{ => fsw}/src/cfe_msg_sechdr_checksum.c (99%) rename modules/msg/{ => fsw}/src/cfe_msg_sechdr_fc.c (99%) rename modules/msg/{ => fsw}/src/cfe_msg_sechdr_time.c (99%) rename modules/msg/{mission_inc => option_inc}/default_cfe_msg_hdr_pri.h (88%) rename modules/msg/{mission_inc => option_inc}/default_cfe_msg_hdr_priext.h (100%) rename modules/msg/{mission_inc => option_inc}/default_cfe_msg_sechdr.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/CMakeLists.txt (94%) rename modules/msg/{unit-test-coverage => ut-coverage}/msg_UT.c (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_ccsdsext.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_ccsdsext.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_ccsdspri.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_ccsdspri.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_checksum.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_checksum.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_fc.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_fc.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_init.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_init.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_msgid.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_msgid_shared.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_msgid_shared.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_msgid_v1.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_msgid_v2.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_time.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_cfe_msg_time.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_msg_ext_not.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_msg_not.c (98%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_msg_not.h (100%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_msg_pri_not.c (99%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_msg_prionly.c (97%) rename modules/msg/{unit-test-coverage => ut-coverage}/test_msg_utils.h (96%) delete mode 100644 modules/resourceid/arch_build.cmake rename modules/resourceid/{ => fsw}/src/cfe_resourceid_api.c (99%) rename modules/resourceid/{option => option_inc}/cfe_resourceid_osal_compatible.h (100%) rename modules/resourceid/{option => option_inc}/cfe_resourceid_simple.h (100%) rename modules/resourceid/{option => option_inc}/cfe_resourceid_strict.h (100%) rename modules/resourceid/{unit-test-coverage => ut-coverage}/CMakeLists.txt (82%) rename modules/resourceid/{unit-test-coverage => ut-coverage}/test_cfe_resourceid.c (99%) rename {fsw/cfe-core/src/inc => modules/saved_inc}/cfe_es.h (99%) rename {fsw/cfe-core/src/inc => modules/saved_inc}/cfe_evs.h (100%) rename {fsw/cfe-core/src/inc => modules/saved_inc}/cfe_fs.h (100%) rename {fsw/cfe-core/src/inc => modules/saved_inc}/cfe_sb.h (99%) rename {fsw/cfe-core/src/inc => modules/saved_inc}/cfe_tbl.h (99%) rename {fsw/cfe-core/src/inc => modules/saved_inc}/cfe_time.h (98%) create mode 100644 modules/sb/CMakeLists.txt rename {fsw/cfe-core/src => modules/sb/fsw}/inc/cfe_sb_events.h (100%) rename {fsw/cfe-core/src => modules/sb/fsw}/inc/cfe_sb_msg.h (99%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_api.c (99%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_buf.c (98%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_init.c (95%) create mode 100644 modules/sb/fsw/src/cfe_sb_internal.h rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_msg_id_util.c (93%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_priv.c (98%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_priv.h (98%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_task.c (99%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_util.c (98%) rename {fsw/cfe-core/src/sb => modules/sb/fsw/src}/cfe_sb_verify.h (100%) create mode 100644 modules/sb/ut-coverage/CMakeLists.txt rename {fsw/cfe-core/unit-test => modules/sb/ut-coverage}/sb_UT.c (99%) rename {fsw/cfe-core/unit-test => modules/sb/ut-coverage}/sb_UT.h (100%) rename modules/sbr/{ => fsw}/src/cfe_sbr_map_direct.c (98%) rename modules/sbr/{ => fsw}/src/cfe_sbr_map_hash.c (99%) rename modules/sbr/{private_inc => fsw/src}/cfe_sbr_priv.h (98%) rename modules/sbr/{ => fsw}/src/cfe_sbr_route_unsorted.c (99%) rename modules/sbr/{unit-test-coverage => ut-coverage}/CMakeLists.txt (78%) rename modules/sbr/{unit-test-coverage => ut-coverage}/test_cfe_sbr_map_direct.c (99%) rename modules/sbr/{unit-test-coverage => ut-coverage}/test_cfe_sbr_map_hash.c (99%) rename modules/sbr/{unit-test-coverage => ut-coverage}/test_cfe_sbr_route_unsorted.c (99%) create mode 100644 modules/tbl/CMakeLists.txt rename {fsw/cfe-core/src => modules/tbl/fsw}/inc/cfe_tbl_events.h (100%) rename {fsw/cfe-core/src => modules/tbl/fsw}/inc/cfe_tbl_msg.h (99%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_api.c (99%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_internal.c (99%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_internal.h (98%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_task.c (98%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_task.h (99%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_task_cmds.c (99%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_task_cmds.h (99%) rename {fsw/cfe-core/src/tbl => modules/tbl/fsw/src}/cfe_tbl_verify.h (100%) create mode 100644 modules/tbl/ut-coverage/CMakeLists.txt rename {fsw/cfe-core/unit-test => modules/tbl/ut-coverage}/tbl_UT.c (99%) rename {fsw/cfe-core/unit-test => modules/tbl/ut-coverage}/tbl_UT.h (100%) create mode 100644 modules/time/CMakeLists.txt rename {fsw/cfe-core/src => modules/time/fsw}/inc/cfe_time_events.h (100%) rename {fsw/cfe-core/src => modules/time/fsw}/inc/cfe_time_msg.h (99%) rename {fsw/cfe-core/src/time => modules/time/fsw/src}/cfe_time_api.c (99%) rename {fsw/cfe-core/src/time => modules/time/fsw/src}/cfe_time_task.c (99%) rename {fsw/cfe-core/src/time => modules/time/fsw/src}/cfe_time_tone.c (99%) rename {fsw/cfe-core/src/time => modules/time/fsw/src}/cfe_time_utils.c (99%) rename {fsw/cfe-core/src/time => modules/time/fsw/src}/cfe_time_utils.h (99%) rename {fsw/cfe-core/src/time => modules/time/fsw/src}/cfe_time_verify.h (99%) create mode 100644 modules/time/ut-coverage/CMakeLists.txt rename {fsw/cfe-core/unit-test => modules/time/ut-coverage}/time_UT.c (100%) rename {fsw/cfe-core/unit-test => modules/time/ut-coverage}/time_UT.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69218c849..4e1348424 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,9 +51,10 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) # (this is not required, and the directory can be empty/nonexistent) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../psp/cmake/Modules" ${CMAKE_MODULE_PATH}) -# The minimum CMake version is chosen because 2.6.4 is what is -# included by default with RHEL/Centos 5.x -cmake_minimum_required(VERSION 2.6.4) +# The minimum CMake version is chosen because v3.5.1 is what is +# available by default with Ubuntu 16.04 LTS at the time of development +# RHEL/CentOS users should install the "cmake3" package from EPEL repo +cmake_minimum_required(VERSION 3.5) # This top-level file does not define ANY targets directly but we know # that the subdirectories will at least use the "C" language, so diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index ec964ae59..599018089 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -62,7 +62,6 @@ endfunction(initialize_globals) function(add_psp_module MOD_NAME MOD_SRC_FILES) # Include the PSP shared directory so it can get to cfe_psp_module.h - include_directories(${MISSION_SOURCE_DIR}/psp/fsw/shared/inc) add_definitions(-D_CFE_PSP_MODULE_) # Create the module @@ -89,6 +88,7 @@ function(add_cfe_app APP_NAME APP_SRC_FILES) # Create the app module add_library(${APP_NAME} ${APPTYPE} ${APP_SRC_FILES} ${ARGN}) + target_link_libraries(${APP_NAME} cfe_app_intf) # An "install" step is only needed for dynamic/runtime loaded apps if (APP_DYNAMIC_TARGET_LIST) @@ -105,11 +105,6 @@ endfunction(add_cfe_app) # function(add_cfe_tables APP_NAME TBL_SRC_FILES) - # The table source must be compiled using the same "include_directories" - # as any other target, but it uses the "add_custom_command" so there is - # no automatic way to do this (at least in the older cmakes) - get_current_cflags(TBL_CFLAGS ${CMAKE_C_FLAGS}) - # Create the intermediate table objects using the target compiler, # then use "elf2cfetbl" to convert to a .tbl file set(TBL_LIST) @@ -148,6 +143,9 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) message("NOTE: Selected ${TBL_SRC} as source for ${TBLWE}") endif() + add_library(${TGT}_${TBLWE}-obj OBJECT ${TBL_SRC}) + target_link_libraries(${TGT}_${TBLWE}-obj PRIVATE cfe_app_intf) + # IMPORTANT: This rule assumes that the output filename of elf2cfetbl matches # the input file name but with a different extension (.o -> .tbl) # The actual output filename is embedded in the source file (.c), however @@ -156,9 +154,9 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES) # current content of a dependency (rightfully so). add_custom_command( OUTPUT "${TABLE_DESTDIR}/${TBLWE}.tbl" - COMMAND ${CMAKE_C_COMPILER} ${TBL_CFLAGS} -c -o ${TBLWE}.o ${TBL_SRC} - COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBLWE}.o - DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBL_SRC} + #COMMAND ${CMAKE_C_COMPILER} ${TBL_CFLAGS} -c -o ${TBLWE}.o ${TBL_SRC} + COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl $ + DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TGT}_${TBLWE}-obj WORKING_DIRECTORY ${TABLE_DESTDIR} ) # Create the install targets for all the tables @@ -254,6 +252,38 @@ function(cfs_app_do_install APP_NAME) endfunction(cfs_app_do_install) +################################################################## +# +# FUNCTION: cfs_app_check_intf +# +# Adds a special target that checks the structure of header files +# in the public interface for this module. A synthetic .c source file +# is created which has a "#include" of each individual header, which +# then compiled as part of the validation. The intent is to confirm +# that each header is valid in a standalone fashion and have no +# implicit prerequisites. +# +function(cfs_app_check_intf MODULE_NAME) + set(${MODULE_NAME}_hdrcheck_SOURCES) + foreach(HDR ${ARGN}) + configure_file(${CFE_SOURCE_DIR}/cmake/check_header.c.in ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c) + list(APPEND ${MODULE_NAME}_hdrcheck_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c) + endforeach(HDR ${ARGN}) + add_library(${MODULE_NAME}_headercheck OBJECT ${${MODULE_NAME}_hdrcheck_SOURCES}) + + # This causes the check to compile with the same set of defines and include dirs as specified + # in the "INTERFACE" properties of the actual module + target_link_libraries(${MODULE_NAME}_headercheck PRIVATE + cfe_app_intf + ${DEP} + ) + + # Build this as part of the synthetic "check-headers" target + add_dependencies(check-headers ${MODULE_NAME}_headercheck) +endfunction(cfs_app_check_intf) + + + ################################################################## # @@ -329,6 +359,7 @@ function(process_arch SYSVAR) # Generate a list of targets that share this system architecture set(INSTALL_TARGET_LIST ${TGTSYS_${SYSVAR}}) + message("INSTALL_TARGET_LIST=${INSTALL_TARGET_LIST}") # Assume use of an OSAL BSP of the same name as the CFE PSP # This can be overridden by the PSP-specific build_options but normally this is expected. @@ -350,6 +381,10 @@ function(process_arch SYSVAR) include_directories(${MISSION_BINARY_DIR}/inc) include_directories(${CMAKE_BINARY_DIR}/inc) + # Add a custom target for "headercheck" - this is a special target confirms that + # checks the sanity of headers within the public interface of modules + add_custom_target(check-headers) + # Configure OSAL target first, as it also determines important compiler flags add_subdirectory("${osal_MISSION_DIR}" osal) @@ -357,26 +392,6 @@ function(process_arch SYSVAR) # This can help with debugging if things go wrong. message(STATUS "PSP Selection: ${CFE_SYSTEM_PSPNAME}") - # Add all widely-used public headers to the include path chain - include_directories(${MISSION_SOURCE_DIR}/osal/src/os/inc) - include_directories(${MISSION_SOURCE_DIR}/psp/fsw/inc) - include_directories(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core/src/inc) - include_directories(${MISSION_SOURCE_DIR}/cfe/cmake/target/inc) - - # propagate any OSAL interface compile definitions and include directories to this build - # This is set as a directory property here at the top level so it will apply to all code. - # This includes MODULE libraries that do not directly/statically link with OSAL but still - # should be compiled with these flags. - get_target_property(OSAL_COMPILE_DEFINITIONS osal INTERFACE_COMPILE_DEFINITIONS) - get_target_property(OSAL_INCLUDE_DIRECTORIES osal INTERFACE_INCLUDE_DIRECTORIES) - - if (OSAL_COMPILE_DEFINITIONS) - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "${OSAL_COMPILE_DEFINITIONS}") - endif (OSAL_COMPILE_DEFINITIONS) - if (OSAL_INCLUDE_DIRECTORIES) - include_directories(${OSAL_INCLUDE_DIRECTORIES}) - endif (OSAL_INCLUDE_DIRECTORIES) - # Append the PSP and OSAL selections to the Doxyfile so it will be included # in the generated documentation automatically. # Also extract the "-D" options within CFLAGS and inform Doxygen about these diff --git a/cmake/check_header.c.in b/cmake/check_header.c.in new file mode 100644 index 000000000..a3a9d8031 --- /dev/null +++ b/cmake/check_header.c.in @@ -0,0 +1,4 @@ +#include "@HDR@" + +/* A no-op function so this compilation unit is not empty */ +void CheckHeader(void) {} diff --git a/cmake/global_functions.cmake b/cmake/global_functions.cmake index 6c5b437f2..f6acabaa2 100644 --- a/cmake/global_functions.cmake +++ b/cmake/global_functions.cmake @@ -278,6 +278,8 @@ endfunction(read_targetconfig) # function(get_current_cflags OUTPUT_LIST) + message(FATAL_ERROR "BROKEN!") + # Start by converting the supplied string to a list set(FLAGLIST) foreach (FLGSTR ${ARGN}) @@ -285,14 +287,16 @@ function(get_current_cflags OUTPUT_LIST) list(APPEND FLAGLIST ${TEMPFLG}) endforeach (FLGSTR ${ARGN}) - # Append any compile definitions from the directory properties - get_directory_property(CURRENT_DEFS COMPILE_DEFINITIONS) - foreach(DEF ${CURRENT_DEFS}) + # Append any compile definitions from the CFE API + get_target_property(CURRENT_DEFS cfe_app INTERFACE_COMPILE_DEFINITIONS) + message("DEFS=${CURRENT_DEFS}") + foreach(DEF $) list(APPEND FLAGLIST "-D${DEF}") endforeach(DEF ${CURRENT_DEFS}) - # Append any include directories from the directory properties - get_directory_property(CURRENT_INCDIRS INCLUDE_DIRECTORIES) + # Append any include directories from the CFE API + get_target_property(CURRENT_INCDIRS cfe_app INTERFACE_INCLUDE_DIRECTORIES) + message("INCDIRS=${CURRENT_INCDIRS}") foreach(INC ${CURRENT_INCDIRS}) list(APPEND FLAGLIST "-I${INC}") endforeach(INC ${CURRENT_INCDIRS}) diff --git a/cmake/mission_build.cmake b/cmake/mission_build.cmake index 7920af487..f9b9d8b28 100644 --- a/cmake/mission_build.cmake +++ b/cmake/mission_build.cmake @@ -161,7 +161,6 @@ function(generate_build_version_templates) endfunction(generate_build_version_templates) - ################################################################## # # FUNCTION: prepare @@ -249,7 +248,7 @@ function(prepare) foreach(APP ${MISSION_DEPS}) # OSAL is handled specially, as only part of it is used - if (NOT APP STREQUAL "osal" AND NOT APP STREQUAL "cfe-core") + if (NOT APP STREQUAL "osal") if (EXISTS "${${APP}_MISSION_DIR}/docs/${APP}.doxyfile.in") # If the module provides its own doxyfile, then include it directly # This allows for app-specific fine-tuning of the sources, based on its own source tree @@ -283,11 +282,19 @@ function(prepare) "${CMAKE_BINARY_DIR}/doc/osconfig-example.h") # The user guide should include the doxygen from the _public_ API files from CFE + OSAL + # NOTE: the userguide is built against the headers of the default core apps. Even if + # an alternate version of the module is in use, it should adhere to the same interface. file(GLOB MISSION_USERGUIDE_HEADERFILES - "${cfe-core_MISSION_DIR}/src/inc/*.h" + "${es_MISSION_DIR}/fsw/inc/*.h" + "${evs_MISSION_DIR}/fsw/inc/*.h" + "${fs_MISSION_DIR}/fsw/inc/*.h" + "${sb_MISSION_DIR}/fsw/inc/*.h" + "${tbl_MISSION_DIR}/fsw/inc/*.h" + "${time_MISSION_DIR}/fsw/inc/*.h" "${osal_MISSION_DIR}/src/os/inc/*.h" + "${psp_MISSION_DIR}/psp/fsw/inc/*.h" "${CMAKE_BINARY_DIR}/doc/osconfig-example.h" - "${MISSION_SOURCE_DIR}/psp/fsw/inc/*.h") + ) string(REPLACE ";" " \\\n" MISSION_USERGUIDE_HEADERFILES "${MISSION_USERGUIDE_HEADERFILES}") # OSAL API GUIDE include PUBLIC API @@ -312,7 +319,7 @@ function(prepare) add_custom_target(osalguide doxygen osalguide.doxyfile - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc") + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc") # Pull in any application-specific mission-scope configuration # This may include user configuration files such as cfe_mission_cfg.h, @@ -360,6 +367,18 @@ function(prepare) generate_build_version_templates() # Generate the tools for the native (host) arch + # Add all public include dirs for core components to include path for tools + include_directories( + ${cfe_app_intf_MISSION_DIR}/fsw/inc + #${es_MISSION_DIR}/fsw/inc + #${evs_MISSION_DIR}/fsw/inc + #${fs_MISSION_DIR}/fsw/inc + #${sb_MISSION_DIR}/fsw/inc + #${tbl_MISSION_DIR}/fsw/inc + #${time_MISSION_DIR}/fsw/inc + ${osal_MISSION_DIR}/src/os/inc + ${psp_MISSION_DIR}/psp/fsw/inc + ) add_subdirectory(${MISSION_SOURCE_DIR}/tools tools) # Add a dependency on the table generator tool as this is required for table builds diff --git a/cmake/mission_defaults.cmake b/cmake/mission_defaults.cmake index 2f7ee42c1..2a8d55834 100644 --- a/cmake/mission_defaults.cmake +++ b/cmake/mission_defaults.cmake @@ -10,8 +10,16 @@ # The "MISSION_CORE_MODULES" will be built and statically linked as part # of the CFE core executable on every target. These can be used to amend # or override parts of the CFE core on a mission-specific basis. +# The "intf" modules are headers only, and define the interface(s) between components set(MISSION_CORE_MODULES - "cfe-core" + "cfe_app_intf" + "cfe_internal_intf" + "es" + "evs" + "fs" + "sb" + "tbl" + "time" "osal" "psp" "msg" @@ -45,7 +53,6 @@ set(MISSION_MODULE_SEARCH_PATH # a variable named "_SEARCH_PATH". This is # used for locating cfe-core and osal which are not part # of the standard search path. -set(cfe-core_SEARCH_PATH "cfe/fsw") set(osal_SEARCH_PATH ".") set(psp_SEARCH_PATH ".") diff --git a/cmake/target/src/target_config.c b/cmake/target/src/target_config.c index 6bda3825c..d9d95f88b 100644 --- a/cmake/target/src/target_config.c +++ b/cmake/target/src/target_config.c @@ -37,7 +37,7 @@ #include "cfe_platform_cfg.h" #include "cfe_es.h" #include "cfe_time.h" -#include "private/cfe_es_resetdata_typedef.h" +#include "cfe_es_resetdata_typedef.h" #include "cfe_version.h" /* for CFE_VERSION_STRING */ #include "osapi-version.h" /* for OS_VERSION_STRING */ diff --git a/fsw/cfe-core/src/inc/private/cfe_private.h b/fsw/cfe-core/src/inc/private/cfe_private.h deleted file mode 100644 index e3738e493..000000000 --- a/fsw/cfe-core/src/inc/private/cfe_private.h +++ /dev/null @@ -1,338 +0,0 @@ -/* -** GSC-18128-1, "Core Flight Executive Version 6.7" -** -** Copyright (c) 2006-2019 United States Government as represented by -** the Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -/* - * cfe_private.h - * - * Created on: Dec 3, 2013 - * Author: jphickey - */ - -#ifndef CFE_PRIVATE_H_ -#define CFE_PRIVATE_H_ - -#include "common_types.h" -#include "cfe.h" - -#include "cfe_platform_cfg.h" /* Define platform configuration parameters */ - - -/*****************************************************************************/ -/** cFE Core task entry point prototypes *************************************/ -/*****************************************************************************/ -/* - * All cFE core apps should define an entry point and the prototype should be here - * These may also be called from the unit test - */ - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE TIME Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** -******************************************************************************/ -extern void CFE_TIME_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE SB Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** -******************************************************************************/ -extern void CFE_SB_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE EVS Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** -******************************************************************************/ -extern void CFE_EVS_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Core Application -** -** \par Description -** This is the entry point to the cFE ES Core Application. -** -** \par Assumptions, External Events, and Notes: -** None -** -** -******************************************************************************/ -extern void CFE_ES_TaskMain(void); - -/*****************************************************************************/ -/** -** \brief Entry Point for cFE Table Services Core Application -** -** \par Description -** This is the entry point to the cFE Table Services Core Application. -** This Application provides the ground interface to the cFE Table -** Services. -** -** \par Assumptions, External Events, and Notes: -** None -** -** -******************************************************************************/ -extern void CFE_TBL_TaskMain(void); - - - - -/*****************************************************************************/ -/** cFE Core task early init prototypes **************************************/ -/*****************************************************************************/ -/* - * cFE core apps may define an early init function and the prototype should be here - * These may also be called from the unit test - */ - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_EVS_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_SB_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_TIME_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the Table Services API Library -** -** \par Description -** Initializes the Table Services API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any TBL API's are called. -** -******************************************************************************/ -extern int32 CFE_TBL_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_ES_CDS_EarlyInit(void); - -/*****************************************************************************/ -/** -** \brief Initializes the cFE core module API Library -** -** \par Description -** Initializes the cFE core module API Library -** -** \par Assumptions, External Events, and Notes: -** -# This function MUST be called before any module API's are called. -** -******************************************************************************/ -extern int32 CFE_FS_EarlyInit(void); - - - -/*****************************************************************************/ -/** cFE Core task clean up prototypes ****************************************/ -/*****************************************************************************/ -/* - * cFE core apps may define a clean up function and the prototype should be here - * These may also be called from the unit test - */ -/*****************************************************************************/ -/** -** \brief Removes TBL resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees TBL services resources -** that have been allocated to the specified Application. -** -** \par Assumptions, External Events, and Notes: -** -# This function DOES NOT remove any critical tables associated with -** the specified application from the Critical Data Store. -** -******************************************************************************/ -extern int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId); - -/*****************************************************************************/ -/** -** \brief Removes SB resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees resources -** that have been allocated to the specified Application. -** -******************************************************************************/ -extern int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId); - -/*****************************************************************************/ -/** -** \brief Removes EVS resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees resources -** that have been allocated to the specified Application. -** -******************************************************************************/ -extern int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId); - -/*****************************************************************************/ -/** -** \brief Removes TIME resources associated with specified Application -** -** \par Description -** This function is called by cFE Executive Services to cleanup after -** an Application has been terminated. It frees resources -** that have been allocated to the specified Application. -** -******************************************************************************/ -extern int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId); - - -/*****************************************************************************/ -/** cFE Core task other function call prototypes *****************************/ -/*****************************************************************************/ -/* - * Functions that are used in a cFE core module other than the module that - * actually defines the function should be prototyped here. - * - * Including the prototype here allows the function to be called properly - * without redefining it at the point of use. - */ - -/*****************************************************************************/ -/** -** \brief Reserve space (or re-obtain previously reserved space) in the Critical Data Store (CDS) -** -** \par Description -** This routine is identical to #CFE_ES_RegisterCDS except it identifies the contents -** of the CDS as a critical table. This is crucial because a critical table CDS must -** only be deleted by cFE Table Services, not via an ES delete CDS command. Otherwise, -** Table Services may be out of sync with the contents of the CDS. -** -** \par Assumptions, External Events, and Notes: -** -# This function assumes input parameters are error free and have met size/value restrictions. -** -# The calling function is responsible for issuing any event messages associated with errors. -** -** \param[in, out] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle. *HandlePtr is the handle of the CDS block that can be used in #CFE_ES_CopyToCDS and #CFE_ES_RestoreFromCDS. -** -** \param[in] UserBlockSize The number of bytes needed in the CDS. -** -** \param[in] Name Pointer to character string containing the Application's local name for -** the CDS. -** -** \param[in] CriticalTbl Indicates whether the CDS is to be used as a Critical Table or not -** -** -** \return See return codes for #CFE_ES_RegisterCDS -** -******************************************************************************/ -int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, const char *Name, bool CriticalTbl); - -/*****************************************************************************/ -/** -** \brief Deletes the specified CDS from the CDS Registry and frees CDS Memory -** -** \par Description -** Removes the record of the specified CDS from the CDS Registry and -** frees the associated CDS memory for future use. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \param[in] CDSName - Pointer to character string containing complete -** CDS Name (of the format "AppName.CDSName"). -** -** \param[in] CalledByTblServices - Flag that identifies whether the CDS is supposed to -** be a Critical Table Image or not. -** -** \return #CFE_SUCCESS \copydoc CFE_SUCCESS -** \return #CFE_ES_CDS_WRONG_TYPE_ERR \copydoc CFE_ES_CDS_WRONG_TYPE_ERR -** \return #CFE_ES_CDS_OWNER_ACTIVE_ERR \copydoc CFE_ES_CDS_OWNER_ACTIVE_ERR -** \return #CFE_ES_ERR_NAME_NOT_FOUND \copydoc CFE_ES_ERR_NAME_NOT_FOUND -** \return Any of the return values from #CFE_ES_UpdateCDSRegistry -** \return Any of the return values from #CFE_ES_GenPoolPutBlock -** -******************************************************************************/ -int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices); - - - - -#endif /* CFE_PRIVATE_H_ */ diff --git a/fsw/cfe-core/unit-test/CMakeLists.txt b/fsw/cfe-core/unit-test/CMakeLists.txt index 9df8b60af..6dfc9632f 100644 --- a/fsw/cfe-core/unit-test/CMakeLists.txt +++ b/fsw/cfe-core/unit-test/CMakeLists.txt @@ -9,18 +9,6 @@ include_directories(${osal_MISSION_DIR}/ut_assert/inc) -# allow direct inclusion of module-private header files by UT code -# NOTE: this should be minimized and moved to a more targeted -# approach, where only each specific UT module does this. -include_directories( - ${cfe-core_MISSION_DIR}/src/es - ${cfe-core_MISSION_DIR}/src/evs - ${cfe-core_MISSION_DIR}/src/sb - ${cfe-core_MISSION_DIR}/src/tbl - ${cfe-core_MISSION_DIR}/src/time - ${cfe-core_MISSION_DIR}/src/fs -) - # CFE needs a supplemental test support hook library add_library(ut_cfe-core_support STATIC ut_support.c diff --git a/modules/cfe_app_intf/CMakeLists.txt b/modules/cfe_app_intf/CMakeLists.txt new file mode 100644 index 000000000..dc241eae3 --- /dev/null +++ b/modules/cfe_app_intf/CMakeLists.txt @@ -0,0 +1,54 @@ +################################################################## +# +# cFE Global/Public Application Interface +# +################################################################## + +# NOTE: This module is shared headers and configuration only, it has has no +# source files of its own. It just defines the intefaces betwen the CFE core +# modules and other private headers that define CFE internal shared data objects. +add_library(cfe_app_intf INTERFACE) + +# The fsw/inc here defines global/shared structures and interfaces +target_include_directories(cfe_app_intf INTERFACE fsw/inc) + +# The list of modules that comprise the "CFE app interface" +# This is the set of APIs that applications and libraries may call directly +# The include path to all of them is +set(cfe_app_intf_MODULES es evs fs msg resourceid sb tbl time osal psp) + +# Propagate any INTERFACE-level include dirs and compile defintions from +# the modules into this abstract interface target +foreach(MOD ${cfe_app_intf_MODULES}) + target_include_directories(cfe_app_intf INTERFACE + $ + ) + target_compile_definitions(cfe_app_intf INTERFACE + $ + ) +endforeach(MOD ${cfe_app_intf_MODULES}) + +# Add unit test coverage subdirectory +# This provides stubs for functions declared in fsw/inc +if (ENABLE_UNIT_TESTS) + add_subdirectory(ut-stubs) +endif (ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + cfe_resourceid.h + cfe_endian.h + cfe_msg.h + cfe_error.h + cfe.h + cfe_version.h + + cfe_es_extern_typedefs.h + cfe_evs_extern_typedefs.h + cfe_fs_extern_typedefs.h + cfe_sb_extern_typedefs.h + cfe_tbl_extern_typedefs.h + cfe_time_extern_typedefs.h + + cfe_tbl_filedef.h +) + diff --git a/modules/cfe_app_intf/arch_build.cmake b/modules/cfe_app_intf/arch_build.cmake new file mode 100644 index 000000000..053fbc40f --- /dev/null +++ b/modules/cfe_app_intf/arch_build.cmake @@ -0,0 +1,19 @@ +########################################################### +# +# 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 +# +########################################################### + +# Generate the "cfe_platform_cfg.h" and "cfe_msgids.h" header files +# these must come from mission config + +generate_config_includefile( + FILE_NAME "cfe_msgids.h" + MATCH_SUFFIX "msgids.h" + PREFIXES ${BUILD_CONFIG} +) + diff --git a/fsw/cfe-core/eds/base_types.xml b/modules/cfe_app_intf/eds/base_types.xml similarity index 100% rename from fsw/cfe-core/eds/base_types.xml rename to modules/cfe_app_intf/eds/base_types.xml diff --git a/fsw/cfe-core/eds/ccsds_spacepacket.xml b/modules/cfe_app_intf/eds/ccsds_spacepacket.xml similarity index 100% rename from fsw/cfe-core/eds/ccsds_spacepacket.xml rename to modules/cfe_app_intf/eds/ccsds_spacepacket.xml diff --git a/fsw/cfe-core/eds/cfe_es.xml b/modules/cfe_app_intf/eds/cfe_es.xml similarity index 100% rename from fsw/cfe-core/eds/cfe_es.xml rename to modules/cfe_app_intf/eds/cfe_es.xml diff --git a/fsw/cfe-core/eds/cfe_evs.xml b/modules/cfe_app_intf/eds/cfe_evs.xml similarity index 100% rename from fsw/cfe-core/eds/cfe_evs.xml rename to modules/cfe_app_intf/eds/cfe_evs.xml diff --git a/fsw/cfe-core/eds/cfe_fs.xml b/modules/cfe_app_intf/eds/cfe_fs.xml similarity index 100% rename from fsw/cfe-core/eds/cfe_fs.xml rename to modules/cfe_app_intf/eds/cfe_fs.xml diff --git a/fsw/cfe-core/eds/cfe_sb.xml b/modules/cfe_app_intf/eds/cfe_sb.xml similarity index 100% rename from fsw/cfe-core/eds/cfe_sb.xml rename to modules/cfe_app_intf/eds/cfe_sb.xml diff --git a/fsw/cfe-core/eds/cfe_tbl.xml b/modules/cfe_app_intf/eds/cfe_tbl.xml similarity index 100% rename from fsw/cfe-core/eds/cfe_tbl.xml rename to modules/cfe_app_intf/eds/cfe_tbl.xml diff --git a/fsw/cfe-core/eds/cfe_time.xml b/modules/cfe_app_intf/eds/cfe_time.xml similarity index 100% rename from fsw/cfe-core/eds/cfe_time.xml rename to modules/cfe_app_intf/eds/cfe_time.xml diff --git a/fsw/cfe-core/eds/config.xml b/modules/cfe_app_intf/eds/config.xml similarity index 100% rename from fsw/cfe-core/eds/config.xml rename to modules/cfe_app_intf/eds/config.xml diff --git a/fsw/cfe-core/src/inc/cfe.h b/modules/cfe_app_intf/fsw/inc/cfe.h similarity index 92% rename from fsw/cfe-core/src/inc/cfe.h rename to modules/cfe_app_intf/fsw/inc/cfe.h index b58931d00..d3a62f206 100644 --- a/fsw/cfe-core/src/inc/cfe.h +++ b/modules/cfe_app_intf/fsw/inc/cfe.h @@ -36,8 +36,8 @@ /* ** Ensure that header is included only once... */ -#ifndef _cfe_ -#define _cfe_ +#ifndef CFE_H +#define CFE_H #include "common_types.h" /* Define basic data types */ @@ -54,8 +54,9 @@ #include "cfe_time.h" /* Define Time Service API */ #include "cfe_tbl.h" /* Define Table Service API */ -#include "cfe_msg_api.h" /* Define Message API */ +#include "cfe_msg.h" /* Define Message API */ +#include "cfe_resourceid.h" /* Define ResourceID API */ #include "cfe_psp.h" /* Define Platform Support Package API */ -#endif /* _cfe_ */ +#endif /* CFE_H */ diff --git a/fsw/cfe-core/src/inc/ccsds.h b/modules/cfe_app_intf/fsw/inc/cfe_endian.h similarity index 88% rename from fsw/cfe-core/src/inc/ccsds.h rename to modules/cfe_app_intf/fsw/inc/cfe_endian.h index b928062f5..b43af6cbb 100644 --- a/fsw/cfe-core/src/inc/ccsds.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_endian.h @@ -19,22 +19,20 @@ */ /****************************************************************************** -** File: ccsds.h +** File: cfe_endian.h ** ** Purpose: -** Define typedefs and macros for CCSDS packet headers. +** Define macros to enforce big-endian/network byte order for 16 and 32 bit integers ** ******************************************************************************/ -#ifndef _ccsds_ -#define _ccsds_ +#ifndef CFE_ENDIAN_H +#define CFE_ENDIAN_H /* ** Include Files */ #include "common_types.h" -#include "cfe_mission_cfg.h" -#include "cfe_msg_hdr.h" /* Macro to convert 16/32 bit types from platform "endianness" to Big Endian */ @@ -46,4 +44,4 @@ #define CFE_MAKE_BIG32(n) ( (((n) << 24) & 0xFF000000) | (((n) << 8) & 0x00FF0000) | (((n) >> 8) & 0x0000FF00) | (((n) >> 24) & 0x000000FF) ) #endif -#endif /* _ccsds_ */ +#endif /* CFE_ENDIAN_H */ diff --git a/fsw/cfe-core/src/inc/cfe_error.h b/modules/cfe_app_intf/fsw/inc/cfe_error.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_error.h rename to modules/cfe_app_intf/fsw/inc/cfe_error.h diff --git a/modules/cfe_app_intf/fsw/inc/cfe_es.h b/modules/cfe_app_intf/fsw/inc/cfe_es.h new file mode 100644 index 000000000..c75746ffc --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_es.h @@ -0,0 +1,1776 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_es.h +** +** Purpose: +** Unit specification for Executive Services library functions and macros. +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +** Notes: +** +*/ + +#ifndef CFE_ES_API_H +#define CFE_ES_API_H + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_error.h" +#include "cfe_es_api_typedefs.h" + + +/* +** The OS_PRINTF macro may be defined by OSAL to enable +** printf-style argument checking. If using a version of OSAL +** that does not define this then define it as a no-op. +*/ +#ifndef OS_PRINTF +#define OS_PRINTF(m,n) +#endif + +/* +** Macro Definitions +*/ + +#define CFE_ES_DBIT(x) (1L << (x)) /* Places a one at bit positions 0 thru 31 */ +#define CFE_ES_DTEST(i,x) (((i) & CFE_ES_DBIT(x)) != 0) /* true iff bit x of i is set */ +#define CFE_ES_TEST_LONG_MASK(m,s) (CFE_ES_DTEST(m[(s)/32],(s)%32)) /* Test a bit within an array of 32-bit integers. */ + + +/*****************************************************************************/ +/* +** Exported Functions +*/ + +/*****************************************************************************/ + +/** @defgroup CFEAPIESResourceID cFE Resource ID APIs + * @{ + */ + +/** + * @brief Obtain an index value correlating to an ES Application ID + * + * This calculates a zero based integer value that may be used for indexing + * into a local resource table/array. + * + * Index values are only guaranteed to be unique for resources of the same + * type. For instance, the indices corresponding to two [valid] application + * IDs will never overlap, but the index of an application and a library ID + * may be the same. Furthermore, indices may be reused if a resource is + * deleted and re-created. + * + * @note There is no inverse of this function - indices cannot be converted + * back to the original AppID value. The caller should retain the original ID + * for future use. + * + * @param[in] AppID Application ID to convert + * @param[out] Idx Buffer where the calculated index will be stored + * + * @return Execution status, see @ref CFEReturnCodes + * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS + * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID + */ +CFE_Status_t CFE_ES_AppID_ToIndex(CFE_ES_AppId_t AppID, uint32 *Idx); + +/** + * @brief Obtain an index value correlating to an ES Library ID + * + * This calculates a zero based integer value that may be used for indexing + * into a local resource table/array. + * + * Index values are only guaranteed to be unique for resources of the same + * type. For instance, the indices corresponding to two [valid] Library + * IDs will never overlap, but the index of an Library and a library ID + * may be the same. Furthermore, indices may be reused if a resource is + * deleted and re-created. + * + * @note There is no inverse of this function - indices cannot be converted + * back to the original LibID value. The caller should retain the original ID + * for future use. + * + * @param[in] LibID Library ID to convert + * @param[out] Idx Buffer where the calculated index will be stored + * + * @return Execution status, see @ref CFEReturnCodes + * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS + * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID + */ +int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibID, uint32 *Idx); + +/** + * @brief Obtain an index value correlating to an ES Task ID + * + * This calculates a zero based integer value that may be used for indexing + * into a local resource table/array. + * + * Index values are only guaranteed to be unique for resources of the same + * type. For instance, the indices corresponding to two [valid] Task + * IDs will never overlap, but the index of an Task and a library ID + * may be the same. Furthermore, indices may be reused if a resource is + * deleted and re-created. + * + * @note There is no inverse of this function - indices cannot be converted + * back to the original TaskID value. The caller should retain the original ID + * for future use. + * + * @param[in] TaskID Task ID to convert + * @param[out] Idx Buffer where the calculated index will be stored + * + * @return Execution status, see @ref CFEReturnCodes + * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS + * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID + */ +CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx); + +/** + * @brief Obtain an index value correlating to an ES Counter ID + * + * This calculates a zero based integer value that may be used for indexing + * into a local resource table/array. + * + * Index values are only guaranteed to be unique for resources of the same + * type. For instance, the indices corresponding to two [valid] Counter + * IDs will never overlap, but the index of an Counter and a library ID + * may be the same. Furthermore, indices may be reused if a resource is + * deleted and re-created. + * + * @note There is no inverse of this function - indices cannot be converted + * back to the original CounterID value. The caller should retain the original ID + * for future use. + * + * @param[in] CounterID Counter ID to convert + * @param[out] Idx Buffer where the calculated index will be stored + * + * @return Execution status, see @ref CFEReturnCodes + * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS + * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID + */ +CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterID, uint32 *Idx); + +/** @} */ + + +/*****************************************************************************/ + +/** @defgroup CFEAPIESEntryExit cFE Entry/Exit APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief cFE Main Entry Point used by Board Support Package to start cFE +** +** \par Description +** cFE main entry point. This is the entry point into the cFE software. +** It is called only by the Board Support Package software. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] StartType Identifies whether this was a #CFE_PSP_RST_TYPE_POWERON or #CFE_PSP_RST_TYPE_PROCESSOR. +** +** \param[in] StartSubtype Specifies, in more detail, what caused the \c StartType identified above. +** See #CFE_PSP_RST_SUBTYPE_POWER_CYCLE for possible examples. +** +** \param[in] ModeId Identifies the source of the Boot as determined by the BSP. +** +** \param[in] StartFilePath Identifies the startup file to use to initialize the cFE apps. +** +** \sa #CFE_ES_ResetCFE +** +******************************************************************************/ +void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId , const char *StartFilePath ); + +/*****************************************************************************/ +/** +** \brief Reset the cFE Core and all cFE Applications +** +** \par Description +** This API causes an immediate reset of the cFE Kernel and all cFE Applications. +** The caller can specify whether the reset should clear all memory (#CFE_PSP_RST_TYPE_POWERON) +** or try to retain volatile memory areas (#CFE_PSP_RST_TYPE_PROCESSOR). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ResetType Identifies the type of reset desired. Allowable settings are: +** \arg #CFE_PSP_RST_TYPE_POWERON - Causes all memory to be cleared +** \arg #CFE_PSP_RST_TYPE_PROCESSOR - Attempts to retain volatile disk, critical data store and user reserved memory. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** \retval #CFE_ES_NOT_IMPLEMENTED \copybrief CFE_ES_NOT_IMPLEMENTED +** +** \sa #CFE_ES_Main +** +******************************************************************************/ +CFE_Status_t CFE_ES_ResetCFE(uint32 ResetType); +/**@}*/ + +/** @defgroup CFEAPIESAppControl cFE Application Control APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Restart a single cFE Application +** +** \par Description +** This API causes a cFE Application to be unloaded and restarted +** from the same file name as the last start. +** +** \par Assumptions, External Events, and Notes: +** The filename is checked for existance prior to load. A missing file +** will be reported and the reload operation will be aborted prior +** to unloading the app. +** +** Goes through the standard CFE_ES_CleanUpApp which unloads, +** then attempts a load using the original file name. +** +** In the event that an application cannot be reloaded due to a +** missing file or any other load issue, the application may no longer be +** restarted or reloaded when given a valid load file (the app has been +** deleted and no longer exists). To recover, the application +** may be started by loading the application via the ES_STARTAPP +** command (#CFE_ES_START_APP_CC). +** +** \param[in] AppID Identifies the application to be reset. +** +** \return Execution status, see \ref CFEReturnCodes +** +** \sa #CFE_ES_ReloadApp, #CFE_ES_DeleteApp +** +******************************************************************************/ +CFE_Status_t CFE_ES_RestartApp(CFE_ES_AppId_t AppID); + +/*****************************************************************************/ +/** +** \brief Reload a single cFE Application +** +** \par Description +** This API causes a cFE Application to be stopped and restarted from +** the specified file. +** +** \par Assumptions, External Events, and Notes: +** The filename is checked for existance prior to load. A missing file +** will be reported and the reload operation will be aborted prior +** to unloading the app. +** +** Goes through the standard CFE_ES_CleanUpApp which unloads, +** then attempts a load using the specified file name. +** +** In the event that an application cannot be reloaded due to +** a corrupt file, the application may no longer be reloaded when given a valid +** load file (it has been deleted and no longer exists). To recover, the +** application may be started by loading the application via the ES_STARTAPP +** command (#CFE_ES_START_APP_CC). +** +** \param[in] AppID Identifies the application to be reset. +** +** \param[in] AppFileName Identifies the new file to start. +** +** \return Execution status, see \ref CFEReturnCodes +** +** \sa #CFE_ES_RestartApp, #CFE_ES_DeleteApp, #CFE_ES_START_APP_CC +** +******************************************************************************/ +CFE_Status_t CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName); + +/*****************************************************************************/ +/** +** \brief Delete a cFE Application +** +** \par Description +** This API causes a cFE Application to be stopped deleted. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppID Identifies the application to be reset. +** +** \return Execution status, see \ref CFEReturnCodes +** +** \sa #CFE_ES_RestartApp, #CFE_ES_ReloadApp +** +******************************************************************************/ +CFE_Status_t CFE_ES_DeleteApp(CFE_ES_AppId_t AppID); +/**@}*/ + +/** @defgroup CFEAPIESAppBehavior cFE Application Behavior APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Exit a cFE Application +** +** \par Description +** This API is the "Exit Point" for the cFE application +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ExitStatus Acceptable values are: \arg #CFE_ES_RunStatus_APP_EXIT - \copybrief CFE_ES_RunStatus_APP_EXIT + \arg #CFE_ES_RunStatus_APP_ERROR - \copybrief CFE_ES_RunStatus_APP_ERROR + \arg #CFE_ES_RunStatus_CORE_APP_INIT_ERROR - \copybrief CFE_ES_RunStatus_CORE_APP_INIT_ERROR + \arg #CFE_ES_RunStatus_CORE_APP_RUNTIME_ERROR - \copybrief CFE_ES_RunStatus_CORE_APP_RUNTIME_ERROR +** +** +** \sa #CFE_ES_RunLoop, #CFE_ES_RegisterApp +** +******************************************************************************/ +void CFE_ES_ExitApp(uint32 ExitStatus); + + +/*****************************************************************************/ +/** +** \brief Check for Exit, Restart, or Reload commands +** +** \par Description +** This is the API that allows an app to check for exit requests from +** the system. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ExitStatus A pointer to a variable containing the Application's +** desired run status. Acceptable values are: +** \arg #CFE_ES_RunStatus_APP_RUN - \copybrief CFE_ES_RunStatus_APP_RUN +** \arg #CFE_ES_RunStatus_APP_EXIT - \copybrief CFE_ES_RunStatus_APP_EXIT +** \arg #CFE_ES_RunStatus_APP_ERROR - \copybrief CFE_ES_RunStatus_APP_ERROR +** +** \return Boolean indicating application should continue running +** \retval true Application should continue running +** \retval false Application should not continue running +** +** \sa #CFE_ES_ExitApp, #CFE_ES_RegisterApp +** +******************************************************************************/ +bool CFE_ES_RunLoop(uint32 *ExitStatus); + +/*****************************************************************************/ +/** +** \brief Allow an Application to Wait for a minimum global system state +** +** \par Description +** This is the API that allows an app to wait for the rest of the apps +** to complete a given stage of initialization before continuing. +** +** This gives finer grained control than #CFE_ES_WaitForStartupSync +** +** \par Assumptions, External Events, and Notes: +** This API assumes that the caller has also been initialized sufficiently +** to satisfy the global system state it is waiting for, and the apps own +** state will be updated accordingly. +** +** \param[in] TimeOutMilliseconds The timeout value in Milliseconds. +** This parameter must be at least 1000. Lower values +** will be rounded up. There is not an option to +** wait indefinitely to avoid hanging a critical +** application because a non-critical app did not start. +** +** \param[in] MinSystemState Determine the state of the App +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS State successfully achieved +** \retval #CFE_ES_OPERATION_TIMED_OUT Timeout was reached +** +** \sa #CFE_ES_RunLoop +** +******************************************************************************/ +CFE_Status_t CFE_ES_WaitForSystemState(uint32 MinSystemState, uint32 TimeOutMilliseconds); + +/*****************************************************************************/ +/** +** \brief Allow an Application to Wait for the "OPERATIONAL" global system state +** +** \par Description +** This is the API that allows an app to wait for the rest of the apps +** to complete their entire initialization before continuing. It is most +** useful for applications such as Health and Safety or the Scheduler that need +** to wait until applications exist and are running before sending out +** packets to them. +** +** This is a specialized wrapper for CFE_ES_WaitForSystemState for compatibility +** with applications using this API. +** +** \par Assumptions, External Events, and Notes: +** This API should only be called as the last item of an Apps initialization. +** In addition, this API should only be called by an App that is started +** from the ES Startup file. It should not be used by an App that is +** started after the system is running. ( Although it will cause no harm ) +** +** \param[in] TimeOutMilliseconds The timeout value in Milliseconds. +** This parameter must be at least 1000. Lower values +** will be rounded up. There is not an option to +** wait indefinitely to avoid hanging a critical +** application because a non-critical app did not start. +** +** +** \sa #CFE_ES_RunLoop +** +******************************************************************************/ +void CFE_ES_WaitForStartupSync(uint32 TimeOutMilliseconds); + +/*****************************************************************************/ +/** +** \brief Registers a cFE Application with the Executive Services +** +** \par Description +** This API registers the calling Application with the cFE. +** +** \par Assumptions, External Events, and Notes: +** NOTE: This function \b MUST be called before any other cFE API functions are called. +** +** \return Execution status, see \ref CFEReturnCodes +** +** \sa #CFE_ES_ExitApp, #CFE_ES_RunLoop +** +******************************************************************************/ +CFE_Status_t CFE_ES_RegisterApp(void); + +/*****************************************************************************/ +/** +** \ingroup CFEAPIESAppBehavior +** \brief Increments the execution counter for the calling task +** +** \par Description +** This routine increments the execution counter that is stored for +** the calling task. It can be called from cFE Application main tasks, child +** tasks, or cFE Core application main tasks. Normally, the call is not +** necessary from a cFE Application, since the CFE_ES_RunLoop call increments +** the counter for the Application. +** +** \par Assumptions, External Events, and Notes: +** NOTE: This API is not needed for Appplications that call the CFE_ES_RunLoop call. +** +** \sa #CFE_ES_RunLoop +** +******************************************************************************/ +void CFE_ES_IncrementTaskCounter(void); +/**@}*/ + +/** @defgroup CFEAPIESInfo cFE Information APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Return the most recent Reset Type +** +** \par Description +** Provides the caller with codes that identifies the type of Reset +** the processor most recently underwent. The caller can also obtain +** information on what caused the reset by supplying a pointer to a +** variable that will be filled with the Reset Sub-Type. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in, out] ResetSubtypePtr Pointer to \c uint32 type variable in which the Reset Sub-Type will be stored. +** The caller can set this pointer to NULL if the Sub-Type is of no interest. \n *ResetSubtypePtr If the provided pointer was not \c NULL, the Reset Sub-Type is stored at the given address. +** For a list of possible Sub-Type values, see \link #CFE_PSP_RST_SUBTYPE_POWER_CYCLE "Reset Sub-Types" \endlink. +** +** +** \return Processor reset type +** \retval #CFE_PSP_RST_TYPE_POWERON \copybrief CFE_PSP_RST_TYPE_POWERON +** \retval #CFE_PSP_RST_TYPE_PROCESSOR \copybrief CFE_PSP_RST_TYPE_PROCESSOR +** +** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo +** +******************************************************************************/ +int32 CFE_ES_GetResetType(uint32 *ResetSubtypePtr); + +/*****************************************************************************/ +/** +** \brief Get an Application ID for the calling Application +** +** \par Description +** This routine retrieves the cFE Application ID for the calling Application. +** +** \par Assumptions, External Events, and Notes: +** NOTE: \b All tasks associated with the Application would return the same Application ID. +** +** \param[out] AppIdPtr Pointer to variable that is to receive the Application's ID. +** *AppIdPtr will be set to the application ID of the calling Application. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetResetType, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName, #CFE_ES_GetTaskInfo +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetAppID(CFE_ES_AppId_t *AppIdPtr); + +/*****************************************************************************/ +/** +** \brief Get the task ID of the calling context +** +** \par Description +** This retrieves the current task context from OSAL +** +** \par Assumptions, External Events, and Notes: +** Applications which desire to call other CFE ES services such as +** CFE_ES_TaskGetInfo() should use this API rather than getting the ID +** from OSAL directly via OS_TaskGetId(). +** +** \param[out] TaskIdPtr Pointer to variable that is to receive the ID. +** Will be set to the ID of the calling task. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetTaskID(CFE_ES_TaskId_t *TaskIdPtr); + +/*****************************************************************************/ +/** +** \brief Get an Application ID associated with a specified Application name +** +** \par Description +** This routine retrieves the cFE Application ID associated with a +** specified Application name. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] AppIdPtr Pointer to variable that is to receive the Application's ID. +** \param[in] AppName Pointer to null terminated character string containing an Application name. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_NAME_NOT_FOUND \copybrief CFE_ES_ERR_NAME_NOT_FOUND +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppName, #CFE_ES_GetAppInfo +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetAppIDByName(CFE_ES_AppId_t *AppIdPtr, const char *AppName); + +/*****************************************************************************/ +/** +** \brief Get a Library ID associated with a specified Library name +** +** \par Description +** This routine retrieves the cFE Library ID associated with a +** specified Library name. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] LibIdPtr Pointer to variable that is to receive the Library's ID. +** \param[in] LibName Pointer to null terminated character string containing a Library name. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_NAME_NOT_FOUND \copybrief CFE_ES_ERR_NAME_NOT_FOUND +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetLibName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName); + +/*****************************************************************************/ +/** +** \brief Get an Application name for a specified Application ID +** +** \par Description +** This routine retrieves the cFE Application name associated with a +** specified Application ID. +** +** \par Assumptions, External Events, and Notes: +** In the case of a failure (#CFE_ES_ERR_RESOURCEID_NOT_VALID), an empty string is returned. +** +** \param[out] AppName Pointer to a character array of at least \c BufferLength in size that will +** be filled with the appropriate Application name. +** +** \param[in] AppId Application ID of Application whose name is being requested. +** +** \param[in] BufferLength The maximum number of characters, including the null terminator, that can be put +** into the \c AppName buffer. This routine will truncate the name to this length, +** if necessary. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppInfo +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetAppName(char *AppName, CFE_ES_AppId_t AppId, size_t BufferLength); + +/*****************************************************************************/ +/** +** \brief Get a Library name for a specified Library ID +** +** \par Description +** This routine retrieves the cFE Library name associated with a +** specified Library ID. +** +** \par Assumptions, External Events, and Notes: +** In the case of a failure (#CFE_ES_ERR_RESOURCEID_NOT_VALID), an empty string is returned. +** +** \param[out] LibName Pointer to a character array of at least \c BufferLength in size that will +** be filled with the Library name. +** +** \param[in] LibId Library ID of Library whose name is being requested. +** +** \param[in] BufferLength The maximum number of characters, including the null terminator, that can be put +** into the \c LibName buffer. This routine will truncate the name to this length, +** if necessary. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_GetLibIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t BufferLength); + +/*****************************************************************************/ +/** +** \brief Get Application Information given a specified App ID +** +** \par Description +** This routine retrieves the information about an App associated with a +** specified App ID. The information includes all of the information ES +** maintains for an application ( documented in the CFE_ES_AppInfo_t type ) +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] AppInfo Pointer to a structure that will be filled with +** resource name and memory addresses information. +** \param[in] AppId ID of application to obtain information about +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetAppID, #CFE_ES_GetAppIDByName, #CFE_ES_GetAppName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetAppInfo(CFE_ES_AppInfo_t *AppInfo, CFE_ES_AppId_t AppId); + +/*****************************************************************************/ +/** +** \brief Get Task Information given a specified Task ID +** +** \par Description +** This routine retrieves the information about a Task associated with a +** specified Task ID. The information includes Task Name, and Parent/Creator +** Application ID. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] TaskInfo Pointer to a \c CFE_ES_TaskInfo_t structure that holds the specific +** task information. *TaskInfo is the filled out \c CFE_ES_TaskInfo_t structure containing the +** Task Name, Parent App Name, Parent App ID among other fields. +** +** \param[in] TaskId Application ID of Application whose name is being requested. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetTaskID, #CFE_ES_GetTaskIDByName, #CFE_ES_GetTaskName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_TaskId_t TaskId); + +/*****************************************************************************/ +/** +** \brief Get Library Information given a specified Resource ID +** +** \par Description +** This routine retrieves the information about a Library +** associated with a specified ID. The information includes all of the +** information ES maintains for this resource type ( documented in +** the CFE_ES_AppInfo_t type ). +** +** This shares the same output structure as CFE_ES_GetAppInfo, such that +** informational commands can be executed against either applications or +** libraries. When applied to a library, the task information in the +** structure will be omitted, as libraries do not have tasks associated. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] LibInfo Pointer to a structure that will be filled with +** resource name and memory addresses information. +** \param[in] LibId ID of application to obtain information about +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetLibIDByName, #CFE_ES_GetLibName +** +******************************************************************************/ +int32 CFE_ES_GetLibInfo(CFE_ES_AppInfo_t *LibInfo, CFE_ES_LibId_t LibId); + +/*****************************************************************************/ +/** +** \brief Get Information given a specified Resource ID +** +** \par Description +** This routine retrieves the information about an Application or Library +** associated with a specified ID. +** +** This is a wrapper API that in turn calls either CFE_ES_GetAppInfo or +** CFE_ES_GetLibInfo if passed an AppId or LibId, respectively. +** +** This allows commands originally targeted to operate on AppIDs to be +** easily ported to operate on either Libraries or Applications, where +** relevant. +** +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] ModuleInfo Pointer to a structure that will be filled with +** resource name and memory addresses information. +** \param[in] ResourceId ID of application or library to obtain information about +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetLibInfo, #CFE_ES_GetAppInfo +** +******************************************************************************/ +int32 CFE_ES_GetModuleInfo(CFE_ES_AppInfo_t *ModuleInfo, CFE_ResourceId_t ResourceId); + +/**@}*/ + +/** @defgroup CFEAPIESChildTask cFE Child Task APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Registers a cFE Child task associated with a cFE Application +** +** \par Description +** This routine registers a cFE Child task and associates it with its parent +** cFE Application. +** +** \par Assumptions, External Events, and Notes: +** NOTE: This API \b MUST be called by the Child Task before any other cFE API calls are made. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_CHILD_TASK_REGISTER \copybrief CFE_ES_ERR_CHILD_TASK_REGISTER +** +** \sa #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask +** +******************************************************************************/ +CFE_Status_t CFE_ES_RegisterChildTask(void); + +/*****************************************************************************/ +/** +** \brief Creates a new task under an existing Application +** +** \par Description +** This routine creates a new task (a separate execution thread) owned by the calling Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in, out] TaskIdPtr A pointer to a variable that will be filled in with the new task's ID. *TaskIdPtr is the Task ID of the newly created child task. +** +** \param[in] TaskName A pointer to a string containing the desired name of the new task. +** This can be up to #OS_MAX_API_NAME characters, including the trailing null. +** +** \param[in] FunctionPtr A pointer to the function that will be spawned as a new task. This function +** must have the following signature: uint32 function(void). Input parameters +** for the new task are not supported. +** +** \param[in] StackPtr A pointer to the location where the child task's stack pointer should start. +** NOTE: Not all underlying operating systems support this parameter. +** The CFE_ES_TASK_STACK_ALLOCATE constant may be passed to indicate that the +** stack should be dynamically allocated. +** +** \param[in] StackSize The number of bytes to allocate for the new task's stack. +** +** \param[in] Priority The priority for the new task. Lower numbers are higher priority, with 0 being +** the highest priority. Applications cannot create tasks with a higher priority +** (lower number) than their own priority. +** +** \param[in] Flags Reserved for future expansion. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_CHILD_TASK_CREATE \copybrief CFE_ES_ERR_CHILD_TASK_CREATE +** +** \sa #CFE_ES_RegisterChildTask, #CFE_ES_DeleteChildTask, #CFE_ES_ExitChildTask +** +******************************************************************************/ +CFE_Status_t CFE_ES_CreateChildTask(CFE_ES_TaskId_t *TaskIdPtr, + const char *TaskName, + CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr, + CFE_ES_StackPointer_t StackPtr, + size_t StackSize, + CFE_ES_TaskPriority_Atom_t Priority, + uint32 Flags); + +/*****************************************************************************/ +/** +** \brief Get a Task ID associated with a specified Task name +** +** \par Description +** This routine retrieves the cFE Task ID associated with a +** specified Task name. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] TaskIdPtr Pointer to variable that is to receive the Task's ID. +** \param[in] TaskName Pointer to null terminated character string containing an Task name. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_NAME_NOT_FOUND \copybrief CFE_ES_ERR_NAME_NOT_FOUND +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetTaskName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName); + +/*****************************************************************************/ +/** +** \brief Get a Task name for a specified Task ID +** +** \par Description +** This routine retrieves the cFE Task name associated with a +** specified Task ID. +** +** \par Assumptions, External Events, and Notes: +** In the case of a failure (#CFE_ES_ERR_RESOURCEID_NOT_VALID), an empty string is returned. +** +** \param[out] TaskName Pointer to a character array of at least \c BufferLength in size that will +** be filled with the Task name. +** +** \param[in] TaskId Task ID of Task whose name is being requested. +** +** \param[in] BufferLength The maximum number of characters, including the null terminator, that can be put +** into the \c TaskName buffer. This routine will truncate the name to this length, +** if necessary. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_GetTaskIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength); + +/*****************************************************************************/ +/** +** \brief Deletes a task under an existing Application +** +** \par Description +** This routine deletes a task under an Application specified by the \c TaskId obtained +** when the child task was created using the #CFE_ES_CreateChildTask API. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TaskId The task ID previously obtained when the Child Task was created with the #CFE_ES_CreateChildTask API. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_NOT_IMPLEMENTED \copybrief CFE_ES_NOT_IMPLEMENTED +** +** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_ExitChildTask +** +******************************************************************************/ +CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId); + +/*****************************************************************************/ +/** +** \brief Exits a child task +** +** \par Description +** This routine allows the current executing child task to exit and +** be deleted by ES. +** +** \par Assumptions, External Events, and Notes: +** This function cannot be called from an Application's Main Task. +** +** \note This function does not return a value, but if it does return +** at all, it is assumed that the Task was either unregistered or +** this function was called from a cFE Application's main task. +** +** \sa #CFE_ES_RegisterChildTask, #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask +** +******************************************************************************/ +void CFE_ES_ExitChildTask(void); +/**@}*/ + +/** @defgroup CFEAPIESMisc cFE Miscellaneous APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Wakes up the CFE background task +** +** \par Description +** Normally the ES background task wakes up at a periodic interval. +** Whenever new background work is added, this can be used to wake the task early, +** which may reduce the delay between adding the job and the job getting processed. +** +** \par Assumptions, External Events, and Notes: +** Note the amount of work that the background task will perform is pro-rated +** based on the amount of time elapsed since the last wakeup. Waking the task +** early will not cause the background task to do more work than it otherwise +** would - it just reduces the delay before work starts initially. +** +** +******************************************************************************/ +void CFE_ES_BackgroundWakeup(void); + + +/*****************************************************************************/ +/** +** \brief Write a string to the cFE System Log +** +** \par Description +** This routine writes a formatted string to the cFE system log. This +** can be used to record very low-level errors that can't be reported +** using the Event Services. This function is used in place of printf +** for flight software. It should be used for significant startup events, +** critical errors, and conditionally compiled debug software. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] SpecStringPtr The format string for the log message. +** This is similar to the format string for a printf() call. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_SYS_LOG_FULL \copybrief CFE_ES_ERR_SYS_LOG_FULL +** +******************************************************************************/ +CFE_Status_t CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...) OS_PRINTF(1,2); + +/*****************************************************************************/ +/** +** \brief Calculate a CRC on a block of memory +** +** \par Description +** This routine calculates a cyclic redundancy check (CRC) on a block of memory. The CRC algorithm +** used is determined by the last parameter. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] DataPtr Pointer to the base of the memory block. +** +** \param[in] DataLength The number of bytes in the memory block. +** +** \param[in] InputCRC A starting value for use in the CRC calculation. This parameter +** allows the user to calculate the CRC of non-contiguous blocks as +** a single value. Nominally, the user should set this value to zero. +** +** \param[in] TypeCRC One of the following CRC algorithm selections: +** \arg \c CFE_MISSION_ES_CRC_8 - (Not currently implemented) +** \arg \c CFE_MISSION_ES_CRC_16 - a CRC-16 algorithm +** \arg \c CFE_MISSION_ES_CRC_32 - (not currently implemented) +** +** \return The result of the CRC calculation on the specified memory block, or error code \ref CFEReturnCodes +** +******************************************************************************/ +uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputCRC, uint32 TypeCRC); + +/*****************************************************************************/ +/** +** \ingroup CFEAPIESMisc +** \brief Notification that an asynchronous event was detected by the underlying OS/PSP +** +** \par Description +** This hook routine is called from the PSP when an exception or +** other asynchronous system event occurs +** +** \par Assumptions, External Events, and Notes: +** The PSP must guarantee that this function is only invoked from a +** context which may use OSAL primitives. In general this means that +** it shouldn't be _directly_ invoked from an ISR/signal context. +** +** +******************************************************************************/ +void CFE_ES_ProcessAsyncEvent(void); + +/**@}*/ + +/** @defgroup CFEAPIESCritData cFE Critical Data Store APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Reserve space (or re-obtain previously reserved space) in the Critical Data Store (CDS) +** +** \par Description +** This routine allocates a block of memory in the Critical Data Store and associates it with +** the calling Application. The memory can survive an Application restart as well as a Processor Reset. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in, out] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle. *HandlePtr is the handle of the CDS block that can be used in +** #CFE_ES_CopyToCDS and #CFE_ES_RestoreFromCDS. +** +** \param[in] BlockSize The number of bytes needed in the CDS. +** +** \param[in] Name A pointer to a character string containing an application +** unique name of #CFE_MISSION_ES_CDS_MAX_NAME_LENGTH characters or less. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS The memory block was successfully created in the CDS. +** \retval #CFE_ES_NOT_IMPLEMENTED The processor does not support a Critical Data Store. +** \retval #CFE_ES_CDS_ALREADY_EXISTS \copybrief CFE_ES_CDS_ALREADY_EXISTS +** \retval #CFE_ES_CDS_INVALID_SIZE \copybrief CFE_ES_CDS_INVALID_SIZE +** \retval #CFE_ES_CDS_INVALID_NAME \copybrief CFE_ES_CDS_INVALID_NAME +** \retval #CFE_ES_CDS_REGISTRY_FULL \copybrief CFE_ES_CDS_REGISTRY_FULL +** +** \sa #CFE_ES_CopyToCDS, #CFE_ES_RestoreFromCDS +** +******************************************************************************/ +CFE_Status_t CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *HandlePtr, size_t BlockSize, const char *Name); + +/*****************************************************************************/ +/** +** \brief Get a CDS Block ID associated with a specified CDS Block name +** +** \par Description +** This routine retrieves the CDS Block ID associated with a +** specified CDS Block name. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[out] BlockIdPtr Pointer to variable that is to receive the CDS Block ID. +** \param[in] BlockName Pointer to null terminated character string containing a CDS Block name. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_NAME_NOT_FOUND \copybrief CFE_ES_ERR_NAME_NOT_FOUND +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetCDSBlockName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_CDSHandle_t *BlockIdPtr, const char *BlockName); + +/*****************************************************************************/ +/** +** \brief Get a Block name for a specified Block ID +** +** \par Description +** This routine retrieves the cFE Block name associated with a +** specified Block ID. +** +** \par Assumptions, External Events, and Notes: +** In the case of a failure (#CFE_ES_ERR_RESOURCEID_NOT_VALID), an empty string is returned. +** +** \param[out] BlockName Pointer to a character array of at least \c BufferLength in size that will +** be filled with the CDS Block name. +** +** \param[in] BlockId Block ID/Handle of CDS registry entry whose name is being requested. +** +** \param[in] BufferLength The maximum number of characters, including the null terminator, that can be put +** into the \c BlockName buffer. This routine will truncate the name to this length, +** if necessary. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_GetCDSBlockIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_CDSHandle_t BlockId, size_t BufferLength); + + +/*****************************************************************************/ +/** +** \brief Save a block of data in the Critical Data Store (CDS) +** +** \par Description +** This routine copies a specified block of memory into the Critical Data Store that +** had been previously registered via #CFE_ES_RegisterCDS. The block of memory to be +** copied must be at least as big as the size specified when registering the CDS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Handle The handle of the CDS block that was previously obtained from #CFE_ES_RegisterCDS. +** +** \param[in] DataToCopy A Pointer to the block of memory to be copied into the CDS. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_RegisterCDS, #CFE_ES_RestoreFromCDS +** +*/ +CFE_Status_t CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy); + +/*****************************************************************************/ +/** +** \brief Recover a block of data from the Critical Data Store (CDS) +** +** \par Description +** This routine copies data from the Critical Data Store identified with the \c Handle into +** the area of memory pointed to by the \c RestoreToMemory pointer. The area of memory to +** be copied into must be at least as big as the size specified when registering the CDS. +** The recovery will indicate an error if the data integrity check maintained by the CDS +** indicates the contents of the CDS have changed. However, the contents will still be +** copied into the specified area of memory. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Handle The handle of the CDS block that was previously obtained from #CFE_ES_RegisterCDS. +** +** \param[in, out] RestoreToMemory A Pointer to the block of memory that is to be restored with the contents of the CDS. *RestoreToMemory is the contents of the specified CDS. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_CDS_BLOCK_CRC_ERR \copybrief CFE_ES_CDS_BLOCK_CRC_ERR +** +** \sa #CFE_ES_RegisterCDS, #CFE_ES_CopyToCDS +** +*/ +CFE_Status_t CFE_ES_RestoreFromCDS(void *RestoreToMemory, CFE_ES_CDSHandle_t Handle); +/**@}*/ + +/** @defgroup CFEAPIESMemManage cFE Memory Manager APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Initializes a memory pool created by an application without using a semaphore during processing. +** +** \par Description +** This routine initializes a pool of memory supplied by the calling application. When a memory pool +** created by this routine is processed, no mutex handling is performed. +** +** \par Assumptions, External Events, and Notes: +** -# The size of the pool must be an integral number of 32-bit words +** -# The start address of the pool must be 32-bit aligned +** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. +** +** \param[in, out] PoolID A pointer to the variable the caller wishes to have the memory pool handle kept in. *PoolID is the memory pool handle. +** +** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must +** be on a 32-bit boundary. +** +** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats +** +******************************************************************************/ +CFE_Status_t CFE_ES_PoolCreateNoSem(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, size_t Size); + +/*****************************************************************************/ +/** +** \brief Initializes a memory pool created by an application while using a semaphore during processing. +** +** \par Description +** This routine initializes a pool of memory supplied by the calling application. When a memory pool +** created by this routine is processed, mutex handling will be performed. +** +** \par Assumptions, External Events, and Notes: +** -# The size of the pool must be an integral number of 32-bit words +** -# The start address of the pool must be 32-bit aligned +** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. +** +** \param[in, out] PoolID A pointer to the variable the caller wishes to have the memory pool handle kept in. *PoolID is the memory pool handle. +** +** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must +** be on a 32-bit boundary. +** +** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats +** +******************************************************************************/ +CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, uint8 *MemPtr, size_t Size); + +/*****************************************************************************/ +/** +** \brief Initializes a memory pool created by an application with application specified block sizes. +** +** \par Description +** This routine initializes a pool of memory supplied by the calling application. +** +** \par Assumptions, External Events, and Notes: +** -# The size of the pool must be an integral number of 32-bit words +** -# The start address of the pool must be 32-bit aligned +** -# 168 bytes are used for internal bookkeeping, therefore, they will not be available for allocation. +** +** \param[in, out] PoolID A pointer to the variable the caller wishes to have the memory pool handle kept in. *PoolID is the memory pool handle. +** +** \param[in] MemPtr A Pointer to the pool of memory created by the calling application. This address must +** be on a 32-bit boundary. +** +** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit words. +** +** \param[in] NumBlockSizes The number of different block sizes specified in the \c BlockSizes array. If set equal to +** zero or if greater than 17, then default block sizes are used. +** +** \param[in] BlockSizes Pointer to an array of sizes to be used instead of the default block sizes specified by +** #CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 through #CFE_PLATFORM_ES_MAX_BLOCK_SIZE. If the pointer is equal to NULL, +** the default block sizes are used. +** +** \param[in] UseMutex Flag indicating whether the new memory pool will be processing with mutex handling or not. +** Valid parameter values are #CFE_ES_USE_MUTEX and #CFE_ES_NO_MUTEX +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats +** +******************************************************************************/ +CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, + uint8 *MemPtr, + size_t Size, + uint16 NumBlockSizes, + const size_t *BlockSizes, + bool UseMutex ); + + +/*****************************************************************************/ +/** +** \brief Deletes a memory pool that was previously created +** +** \par Description +** This routine removes the pool ID and frees the global table +** entry for future re-use. +** +** \par Assumptions, External Events, and Notes: +** All buffers associated with the pool become invalid after this call. +** The application should ensure that buffers/references to the +** pool are returned before deleting the pool. +** +** \param[in] PoolID The ID of the pool to delete +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats +** +******************************************************************************/ +int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID); + + +/*****************************************************************************/ +/** +** \brief Gets a buffer from the memory pool created by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem +** +** \par Description +** This routine obtains a block of memory from the memory pool supplied by the calling application. +** +** \par Assumptions, External Events, and Notes: +** -# The size allocated from the memory pool is, at a minimum, 12 bytes more than requested. +** +** \param[in, out] BufPtr A pointer to the Application's pointer in which will be stored the address of the allocated memory buffer. *BufPtr is the address of the requested buffer. +** +** \param[in] PoolID The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. +** +** \param[in] Size The size of the buffer requested. NOTE: The size allocated may be larger. +** +** \return Bytes Allocated, or error code \ref CFEReturnCodes +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_ERR_MEM_BLOCK_SIZE \copybrief CFE_ES_ERR_MEM_BLOCK_SIZE +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_PutPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_GetPoolBufInfo +** +******************************************************************************/ +int32 CFE_ES_GetPoolBuf(CFE_ES_MemPoolBuf_t *BufPtr, CFE_ES_MemHandle_t PoolID, size_t Size); + +/*****************************************************************************/ +/** +** \brief Gets info on a buffer previously allocated via #CFE_ES_GetPoolBuf +** +** \par Description +** This routine gets info on a buffer in the memory pool. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] PoolID The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. +** +** \param[in] BufPtr A pointer to the memory buffer to provide status for. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** \retval #CFE_ES_BUFFER_NOT_IN_POOL \copybrief CFE_ES_BUFFER_NOT_IN_POOL +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_PutPoolBuf +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetPoolBufInfo(CFE_ES_MemHandle_t PoolID, CFE_ES_MemPoolBuf_t BufPtr); + +/*****************************************************************************/ +/** +** \brief Releases a buffer from the memory pool that was previously allocated via #CFE_ES_GetPoolBuf +** +** \par Description +** This routine releases a buffer back into the memory pool. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] PoolID The handle to the memory pool as returned by #CFE_ES_PoolCreate or #CFE_ES_PoolCreateNoSem. +** +** \param[in] BufPtr A pointer to the memory buffer to be released. +** +** \return Bytes released, or error code \ref CFEReturnCodes +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_GetMemPoolStats, #CFE_ES_GetPoolBufInfo +** +******************************************************************************/ +int32 CFE_ES_PutPoolBuf(CFE_ES_MemHandle_t PoolID, CFE_ES_MemPoolBuf_t BufPtr); + +/*****************************************************************************/ +/** +** \brief Extracts the statistics maintained by the memory pool software +** +** \par Description +** This routine fills the #CFE_ES_MemPoolStats_t data structure with the statistics +** maintained by the memory pool software. These statistics can then be telemetered +** by the calling Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in, out] BufPtr Pointer to #CFE_ES_MemPoolStats_t data structure to be +** filled with memory statistics. *BufPtr is the Memory Pool Statistics stored in given data structure. +** +** \param[in] Handle The handle to the memory pool whose statistics are desired. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_PoolCreate, #CFE_ES_PoolCreateNoSem, #CFE_ES_PoolCreateEx, #CFE_ES_GetPoolBuf, #CFE_ES_PutPoolBuf +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHandle_t Handle); +/**@}*/ + +/** @defgroup CFEAPIESPerfMon cFE Performance Monitor APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Entry marker for use with Software Performance Analysis Tool. +** +** \par Description +** This macro logs the entry or start event/marker for the specified +** entry \c id. This macro, in conjunction with the #CFE_ES_PerfLogExit, +** is used by the Software Performance Analysis tool (see section 5.15). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] id Identifier of the specific event or marker. +** +** \sa #CFE_ES_PerfLogExit, #CFE_ES_PerfLogAdd +** +******************************************************************************/ +#define CFE_ES_PerfLogEntry(id) (CFE_ES_PerfLogAdd(id, 0)) + +/*****************************************************************************/ +/** +** \brief Exit marker for use with Software Performance Analysis Tool. +** +** \par Description +** This macro logs the exit or end event/marker for the specified +** entry \c id. This macro, in conjunction with the #CFE_ES_PerfLogEntry, +** is used by the Software Performance Analysis tool (see section 5.15). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] id Identifier of the specific event or marker. +** +** \sa #CFE_ES_PerfLogEntry, #CFE_ES_PerfLogAdd +** +******************************************************************************/ +#define CFE_ES_PerfLogExit(id) (CFE_ES_PerfLogAdd(id, 1)) + + +/*****************************************************************************/ +/** +** \brief Function called by #CFE_ES_PerfLogEntry and #CFE_ES_PerfLogExit macros +** +** \par Description +** This function logs the entry and exit marker for the specified +** \c id. This function is used by the Software Performance Analysis +** tool (see section 5.15). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Marker Identifier of the specific event or marker. +** \param[in] EntryExit Used to specify Entry(0) or Exit(1) +** +** \sa #CFE_ES_PerfLogEntry, #CFE_ES_PerfLogExit +** +******************************************************************************/ +void CFE_ES_PerfLogAdd(uint32 Marker, uint32 EntryExit); +/**@}*/ + +/** @defgroup CFEAPIESGenCount cFE Generic Counter APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Register a generic counter +** +** \par Description +** This routine registers a generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] *CounterName The Name of the generic counter. +** +** \param[out] *CounterIdPtr The Counter Id of the newly created counter. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_RegisterGenCounter(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName); + +/*****************************************************************************/ +/** +** \brief Delete a generic counter +** +** \par Description +** This routine deletes a previously registered generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter Id of the newly created counter. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_IncrementGenCounter, #CFE_ES_RegisterGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_DeleteGenCounter(CFE_ES_CounterId_t CounterId); + +/*****************************************************************************/ +/** +** \brief Increments the specified generic counter +** +** \par Description +** This routine increments the specified generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter to be incremented. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_IncrementGenCounter(CFE_ES_CounterId_t CounterId); + +/*****************************************************************************/ +/** +** \brief Set the specified generic counter +** +** \par Description +** This routine sets the specified generic counter to the specified value. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter to be set. +** +** \param[in] Count The new value of the Counter. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCount, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_SetGenCount(CFE_ES_CounterId_t CounterId, uint32 Count); + +/*****************************************************************************/ +/** +** \brief Get the specified generic counter count +** +** \par Description +** This routine gets the value of a generic counter. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[in] CounterId The Counter to get the value from. +** +** \param[in] *Count The value of the Counter. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_BAD_ARGUMENT \copybrief CFE_ES_BAD_ARGUMENT +** +** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_DeleteGenCounter, #CFE_ES_SetGenCount, #CFE_ES_IncrementGenCounter, #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetGenCount(CFE_ES_CounterId_t CounterId, uint32 *Count); + + +/*****************************************************************************/ +/** +** \brief Get the Id associated with a generic counter name +** +** \par Description +** This routine gets the Counter Id for a generic counter specified by name. +** +** \par Assumptions, External Events, and Notes: +** None. +** +** \param[out] CounterIdPtr Pointer to variable that is to receive the Counter's ID. +** \param[in] CounterName Pointer to null terminated character string containing a Counter name. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_NAME_NOT_FOUND \copybrief CFE_ES_ERR_NAME_NOT_FOUND +** \retval #CFE_ES_ERR_BUFFER \copybrief CFE_ES_ERR_BUFFER +** +** \sa #CFE_ES_GetGenCounterName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetGenCounterIDByName(CFE_ES_CounterId_t *CounterIdPtr, const char *CounterName); + +/*****************************************************************************/ +/** +** \brief Get a Counter name for a specified Counter ID +** +** \par Description +** This routine retrieves the cFE Counter name associated with a +** specified Counter ID. +** +** \par Assumptions, External Events, and Notes: +** In the case of a failure (#CFE_ES_ERR_RESOURCEID_NOT_VALID), an empty string is returned. +** +** \param[out] CounterName Pointer to a character array of at least \c BufferLength in size that will +** be filled with the Counter name. +** +** \param[in] CounterId ID of Counter whose name is being requested. +** +** \param[in] BufferLength The maximum number of characters, including the null terminator, that can be put +** into the \c CounterName buffer. This routine will truncate the name to this length, +** if necessary. +** +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_ES_ERR_RESOURCEID_NOT_VALID \copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID +** +** \sa #CFE_ES_GetGenCounterIDByName +** +******************************************************************************/ +CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_CounterId_t CounterId, size_t BufferLength); + +/**@}*/ + + +/* + * The internal APIs prototyped within this block are only intended to be invoked from + * other CFE core apps. They still need to be prototyped in the shared header such that + * they can be called from other core modules, but applications should not call these. + */ +#ifdef _CFE_CORE_ + +/** @defgroup CFEAPIESCoreInternal cFE Internal Executive Service APIs, internal to CFE core + * @{ + */ + + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE ES Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** +******************************************************************************/ +extern void CFE_ES_TaskMain(void); + + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_ES_CDS_EarlyInit(void); + + +/*****************************************************************************/ +/** +** \brief Reserve space (or re-obtain previously reserved space) in the Critical Data Store (CDS) +** +** \par Description +** This routine is identical to #CFE_ES_RegisterCDS except it identifies the contents +** of the CDS as a critical table. This is crucial because a critical table CDS must +** only be deleted by cFE Table Services, not via an ES delete CDS command. Otherwise, +** Table Services may be out of sync with the contents of the CDS. +** +** \par Assumptions, External Events, and Notes: +** -# This function assumes input parameters are error free and have met size/value restrictions. +** -# The calling function is responsible for issuing any event messages associated with errors. +** +** \param[in, out] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle. *HandlePtr is the handle of the CDS block that can be used in #CFE_ES_CopyToCDS and #CFE_ES_RestoreFromCDS. +** +** \param[in] UserBlockSize The number of bytes needed in the CDS. +** +** \param[in] Name Pointer to character string containing the Application's local name for +** the CDS. +** +** \param[in] CriticalTbl Indicates whether the CDS is to be used as a Critical Table or not +** +** +** \return See return codes for #CFE_ES_RegisterCDS +** +******************************************************************************/ +int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, const char *Name, bool CriticalTbl); + +/*****************************************************************************/ +/** +** \brief Deletes the specified CDS from the CDS Registry and frees CDS Memory +** +** \par Description +** Removes the record of the specified CDS from the CDS Registry and +** frees the associated CDS memory for future use. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] CDSName - Pointer to character string containing complete +** CDS Name (of the format "AppName.CDSName"). +** +** \param[in] CalledByTblServices - Flag that identifies whether the CDS is supposed to +** be a Critical Table Image or not. +** +** \return #CFE_SUCCESS \copydoc CFE_SUCCESS +** \return #CFE_ES_CDS_WRONG_TYPE_ERR \copydoc CFE_ES_CDS_WRONG_TYPE_ERR +** \return #CFE_ES_CDS_OWNER_ACTIVE_ERR \copydoc CFE_ES_CDS_OWNER_ACTIVE_ERR +** \return #CFE_ES_ERR_NAME_NOT_FOUND \copydoc CFE_ES_ERR_NAME_NOT_FOUND +** \return Any of the return values from #CFE_ES_UpdateCDSRegistry +** \return Any of the return values from #CFE_ES_GenPoolPutBlock +** +******************************************************************************/ +int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices); + + +/**@}*/ + +#endif /* _CFE_CORE_ */ + + + +#endif /* CFE_ES_API_H */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_es_api_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_es_api_typedefs.h new file mode 100644 index 000000000..e88839a1e --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_es_api_typedefs.h @@ -0,0 +1,194 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_es_api_typedefs.h +** +** Purpose: +** Unit specification for Executive Services library functions and macros. +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +** Notes: +** +*/ + +#ifndef CFE_ES_ABSTRACT_TYPES_H +#define CFE_ES_ABSTRACT_TYPES_H + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_es_extern_typedefs.h" +#include "cfe_es_msg.h" + + + +/* +** Note about reset type and subtypes: +** +** These values come from the PSP so the actual definition of these enumerations +** was moved to the PSP header file . +** +** In the future the Electronic Data sheets (EDS) for PSP/ES +** will define the exact values to use in telemetry messages. +*/ + +/* +** Reset types +*/ +/** \name Reset Type extensions */ +/** \{ */ +#define CFE_ES_APP_RESTART CFE_PSP_RST_TYPE_MAX /**< Application only was reset (extend the PSP enumeration here) */ +/** \} */ + + +/*****************************************************************************/ +/* +** Type Definitions +*/ + +/* +** Entry Function Prototypes +*/ +typedef void (*CFE_ES_TaskEntryFuncPtr_t)(void); /**< \brief Required Prototype of Task Main Functions */ +typedef int32 (*CFE_ES_LibraryEntryFuncPtr_t)(CFE_ES_LibId_t LibId); /**< \brief Required Prototype of Library Initialization Functions */ + +/** + * \brief Compatible typedef for ES child task entry point. + * + * All ES task functions (main + child) use the same entry point type. + */ +typedef CFE_ES_TaskEntryFuncPtr_t CFE_ES_ChildTaskMainFuncPtr_t; + +/** + * @brief Type for the stack pointer of tasks. + * + * This type is used in the CFE ES task API. + */ +typedef void* CFE_ES_StackPointer_t; /* aka osal_stackptr_t in proposed OSAL change */ + +/** + * \brief Pool Alignement + * + * Union that can be used for minimum memory alignment of ES memory pools on the target. + * It contains the longest native data types such that the alignment of this structure + * should reflect the largest possible alignment requirements for any data on this processor. + */ +typedef union CFE_ES_PoolAlign +{ + void *Ptr; /**< \brief Aligned pointer */ + /* note -- native types (int/double) are intentional here */ + long long int LongInt; /**< \brief Aligned Long Integer */ + long double LongDouble; /**< \brief Aligned Long Double */ +} CFE_ES_PoolAlign_t; + +/** + * \brief Static Pool Type + * + * A macro to help instantiate static memory pools that are correctly aligned. + * This resolves to a union type that contains a member called "Data" that will + * be correctly aligned to be a memory pool and sized according to the argument. + */ +#define CFE_ES_STATIC_POOL_TYPE(size) union { CFE_ES_PoolAlign_t Align; uint8 Data[size]; } + + +/** + * @brief Pointer type used for memory pool API + * + * This is used in the Get/Put API calls to refer to a pool buffer. + * + * This pointer is expected to be type cast to the real object + * type after getting a new buffer. Using void* allows this + * type conversion to occur easily. + * + * @note Older versions of CFE implemented the API using a uint32*, + * which required explicit type casting everywhere it was called. + * Although the API type is now void* to make usage easier, the + * pool buffers are aligned to machine requirements - typically 64 bits. + */ +typedef void* CFE_ES_MemPoolBuf_t; + +/** + * @brief Conversion macro to create buffer pointer from another type + * + * In cases where the actual buffer pointer is computed, this macro + * aids in converting the computed address (typically an OSAL "cpuaddr" + * type) into a buffer pointer. + * + * @note Any address calculation needs to take machine alignment + * requirements into account. + */ +#define CFE_ES_MEMPOOLBUF_C(x) ((CFE_ES_MemPoolBuf_t)(x)) + +/** \name Conversions for ES resource IDs */ +/** \{ */ + +/* + * Conversion macros for each ES resource ID subtype + * + * These accept a generic/non-specific CFE_ResourceId_t value + * and convert it to the corresponding resource-specific type. + * + * These should only be used when with the resource ID constants, + * or where the code has confirmed or is determining the generic + * identifier does correspond to a resource of that type. + */ +#define CFE_ES_APPID_C(val) ((CFE_ES_AppId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_TASKID_C(val) ((CFE_ES_TaskId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_LIBID_C(val) ((CFE_ES_LibId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_COUNTERID_C(val) ((CFE_ES_CounterId_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_MEMHANDLE_C(val) ((CFE_ES_MemHandle_t)CFE_RESOURCEID_WRAP(val)) +#define CFE_ES_CDSHANDLE_C(val) ((CFE_ES_CDSHandle_t)CFE_RESOURCEID_WRAP(val)) + +/** \} */ + +/** \name Type-specific initalizers for "undefined" resource IDs */ +/** \{ */ + +#define CFE_ES_APPID_UNDEFINED CFE_ES_APPID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_TASKID_UNDEFINED CFE_ES_TASKID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_LIBID_UNDEFINED CFE_ES_LIBID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_COUNTERID_UNDEFINED CFE_ES_COUNTERID_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_MEMHANDLE_UNDEFINED CFE_ES_MEMHANDLE_C(CFE_RESOURCEID_UNDEFINED) +#define CFE_ES_CDS_BAD_HANDLE CFE_ES_CDSHANDLE_C(CFE_RESOURCEID_UNDEFINED) +/** \} */ + +/** \name Task Stack Constants */ +/** \{ */ + +/** + * \brief Indicates that the stack for the child task should be dynamically allocated. + * + * This value may be supplied as the Stack Pointer argument to CFE_ES_ChildTaskCreate() + * to indicate that the stack should be dynamically allocated. + */ +#define CFE_ES_TASK_STACK_ALLOCATE NULL /* aka OS_TASK_STACK_ALLOCATE in proposed OSAL change */ +/** \} */ + +#define CFE_ES_NO_MUTEX false /**< \brief Indicates that the memory pool selection will not use a semaphore */ +#define CFE_ES_USE_MUTEX true /**< \brief Indicates that the memory pool selection will use a semaphore */ + + + +#endif /* CFE_ES_ABSTRACT_TYPES_H */ diff --git a/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_es_extern_typedefs.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h rename to modules/cfe_app_intf/fsw/inc/cfe_es_extern_typedefs.h index 36c2d1ee3..86e73fff9 100644 --- a/fsw/cfe-core/src/inc/cfe_es_extern_typedefs.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_es_extern_typedefs.h @@ -26,7 +26,7 @@ #ifdef CFE_EDS_ENABLED_BUILD /* Use the EDS generated version of these types */ -#include "cfe_es_eds_typedefs.h" +#include "cfe_es_eds_api_typedefs.h" #else /* Use the local definitions of these types */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_evs.h b/modules/cfe_app_intf/fsw/inc/cfe_evs.h new file mode 100644 index 000000000..0462f56aa --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_evs.h @@ -0,0 +1,397 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** Filename: cfe_evs.h +** +** Title: Event Services API Application Library Header File +** +** Purpose: +** Unit specification for Event services library functions and macros. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +**/ + +#ifndef CFE_EVS_API_H +#define CFE_EVS_API_H + +/********************************** Include Files ************************************/ +#include "common_types.h" /* Basic data types */ +#include "cfe_error.h" +#include "cfe_evs_api_typedefs.h" +#include "cfe_es_api_typedefs.h" +#include "cfe_time_api_typedefs.h" + + +/* +** Utility macros to make for simpler/more compact/readable code. +*/ +#define CFE_EVS_Send(E,T,...) CFE_EVS_SendEvent((E), CFE_EVS_EventType_##T, __VA_ARGS__) +#define CFE_EVS_SendDbg(E,...) CFE_EVS_Send(E, DEBUG, __VA_ARGS__) +#define CFE_EVS_SendInfo(E,...) CFE_EVS_Send(E, INFORMATION, __VA_ARGS__) +#define CFE_EVS_SendErr(E,...) CFE_EVS_Send(E, ERROR, __VA_ARGS__) +#define CFE_EVS_SendCrit(E,...) CFE_EVS_Send(E, CRITICAL, __VA_ARGS__) + + +/****************** Function Prototypes **********************/ + +/** @defgroup CFEAPIEVSReg cFE Registration APIs + * @{ + */ + +/** +** \brief Register an application for receiving event services +** +** \par Description +** This routine registers an application with event services and allocates/initializes +** the internal data structures used to support this application's events. An application +** may not send events unless it has called this routine. The routine also accepts a filter +** array structure for applications requiring event filtering. In the current implementation +** of the EVS, only the binary filtering scheme is supported. See section TBD of the cFE +** Application Programmer's Guide for a description of the behavior of binary filters. +** Applications may call #CFE_EVS_Register more than once, but each call will wipe out all +** filters registered by previous calls (filter registration is NOT cumulative). +** +** \par Assumptions, External Events, and Notes: +** Note: Event filters can be added, deleted or modified by ground commands. All filtering +** schemes include a default setting that results in no filtering (such as #CFE_EVS_NO_FILTER +** for binary filters). +** +** Filter Scheme: Binary
+** Code: CFE_EVS_EventFilter_BINARY
+** Filter Structure: +** \code +** typedef struct CFE_EVS_BinFilter { +** uint16 EventID, +** uint16 Mask ; +** } CFE_EVS_BinFilter_t; +** \endcode +** +** \param[in] Filters Pointer to an array of event message filters, or NULL if no filtering is desired. +** The structure of an event message filter depends on the FilterScheme selected. +** (see Filter Schemes mentioned above) +** +** \param[in] NumFilteredEvents The number of event message filters included in this call. This must be less than +** or equal to the maximum number of events allowed per application (#CFE_PLATFORM_EVS_MAX_EVENT_FILTERS). +** +** \param[in] FilterScheme The event filtering scheme that this application will use. For the first implementation of +** the event services, only filter type #CFE_EVS_EventFilter_BINARY will be supported. +** +** \return Execution status below or from #CFE_ES_GetAppID, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_EVS_APP_FILTER_OVERLOAD \copybrief CFE_EVS_APP_FILTER_OVERLOAD +** \retval #CFE_EVS_UNKNOWN_FILTER \copybrief CFE_EVS_UNKNOWN_FILTER +** \retval #CFE_EVS_APP_ILLEGAL_APP_ID \copybrief CFE_EVS_APP_ILLEGAL_APP_ID +** +** \sa #CFE_EVS_Unregister +** +**/ +CFE_Status_t CFE_EVS_Register (const void *Filters, /* Pointer to an array of filters */ + uint16 NumFilteredEvents, /* How many elements in the array? */ + uint16 FilterScheme); /* Filtering Algorithm to be implemented */ + +/** +** \brief Cleanup internal structures used by the event manager for the calling Application. +** +** \par Description +** This routine un-registers the calling application from receiving event services +** and removes and deletes the calling applications filters and counters from the +** internal event service filter and counter tables if registered. Applications +** must call this routine as part of their orderly shutdown process. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return Execution status below or from #CFE_ES_GetAppID/#CFE_ES_PutPoolBuf, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_EVS_APP_NOT_REGISTERED \copybrief CFE_EVS_APP_NOT_REGISTERED +** \retval #CFE_EVS_APP_ILLEGAL_APP_ID \copybrief CFE_EVS_APP_ILLEGAL_APP_ID +** +** \sa #CFE_EVS_Register +** +**/ +CFE_Status_t CFE_EVS_Unregister( void ); +/**@}*/ + +/** @defgroup CFEAPIEVSSend cFE Send Event APIs + * @{ + */ + +/** +** \brief Generate a software event. +** +** \par Description +** This routine generates a software event message. If the EventID is not filtered, +** the event will be sent as a software bus message, optionally logged in the local +** event log, and optionally sent as an ASCII text string out the enabled output port(s). +** +** \par Assumptions, External Events, and Notes: +** This API only works within the context of a registered application or core service. +** For messages outside the context of a registered appliction (for example early +** in app initialization or if registration fails) #CFE_ES_WriteToSysLog can be used +** for reporting. +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \param[in] EventType A numeric literal used to classify an event, one of: +** \arg #CFE_EVS_EventType_DEBUG +** \arg #CFE_EVS_EventType_INFORMATION +** \arg #CFE_EVS_EventType_ERROR +** \arg #CFE_EVS_EventType_CRITICAL +** +** \param[in] Spec A pointer to a null terminated text string describing the output format +** for the event. This is the same type of format string used for the ANSI +** \c printf function. Nominally the post-conversion string is limited to 80 +** characters, but this limit is configurable through the parameter +** #CFE_MISSION_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. +** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format +** string unless your application will be running in a system that supports +** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) +** in the format string; they will mess up the formatting when the events are +** displayed on the ground system. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_EVS_APP_NOT_REGISTERED \copybrief CFE_EVS_APP_NOT_REGISTERED +** \retval #CFE_EVS_APP_ILLEGAL_APP_ID \copybrief CFE_EVS_APP_ILLEGAL_APP_ID +** +** \sa #CFE_EVS_SendEventWithAppID, #CFE_EVS_SendTimedEvent +** +**/ +CFE_Status_t CFE_EVS_SendEvent (uint16 EventID, + uint16 EventType, + const char *Spec, ... ) OS_PRINTF(3,4); + + +/** +** \brief Generate a software event given the specified Application ID. +** +** \par Description +** This routine generates a software event message. If the EventID is not filtered, +** the event will be sent as a software bus message, optionally logged in the local +** event log, and optionally sent as an ASCII text string out the enabled output port(s). +** Note that this function should really only be used from within an API in order to +** preserve the context of an Application's event. In general, #CFE_EVS_SendEvent should be used. +** +** \par Assumptions, External Events, and Notes: +** The Application ID must correspond to a registered application or core service. +** For messages outside the context of a registered appliction (for example early +** in app initialization or if registration fails) #CFE_ES_WriteToSysLog can be used +** for reporting. +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \param[in] EventType A numeric literal used to classify an event, one of: +** \arg #CFE_EVS_EventType_DEBUG +** \arg #CFE_EVS_EventType_INFORMATION +** \arg #CFE_EVS_EventType_ERROR +** \arg #CFE_EVS_EventType_CRITICAL +** +** \param[in] AppID The Application ID from which the event message should appear. +** +** \param[in] Spec A pointer to a null terminated text string describing the output format +** for the event. This is the same type of format string used for the ANSI +** \c printf function. Nominally the post-conversion string is limited to 80 +** characters, but this limit is configurable through the parameter +** #CFE_MISSION_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. +** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format +** string unless your application will be running in a system that supports +** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) +** in the format string; they will mess up the formatting when the events are +** displayed on the ground system. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_EVS_APP_NOT_REGISTERED \copybrief CFE_EVS_APP_NOT_REGISTERED +** \retval #CFE_EVS_APP_ILLEGAL_APP_ID \copybrief CFE_EVS_APP_ILLEGAL_APP_ID +** +** \sa #CFE_EVS_SendEvent, #CFE_EVS_SendTimedEvent +** +**/ +CFE_Status_t CFE_EVS_SendEventWithAppID (uint16 EventID, + uint16 EventType, + CFE_ES_AppId_t AppID, + const char *Spec, ... ) OS_PRINTF(4,5); + + +/** +** \brief Generate a software event with a specific time tag. +** +** \par Description +** This routine is the same as #CFE_EVS_SendEvent except that the caller specifies the event time +** instead of having the EVS use the current spacecraft time. This routine should be used in +** situations where an error condition is detected at one time, but the event message is reported +** at a later time. +** +** \par Assumptions, External Events, and Notes: +** This API only works within the context of a registered application or core service. +** For messages outside the context of a registered appliction (for example early +** in app initialization or if registration fails) #CFE_ES_WriteToSysLog can be used +** for reporting. +** +** \param[in] Time The time to include in the event. This will usually be a time returned +** by the function #CFE_TIME_GetTime. +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \param[in] EventType A numeric literal used to classify an event, one of: +** \arg #CFE_EVS_EventType_DEBUG +** \arg #CFE_EVS_EventType_INFORMATION +** \arg #CFE_EVS_EventType_ERROR +** \arg #CFE_EVS_EventType_CRITICAL +** +** \param[in] Spec A pointer to a null terminated text string describing the output format +** for the event. This is the same type of format string used for the ANSI +** \c printf function. Nominally the post-conversion string is limited to 80 +** characters, but this limit is configurable through the parameter +** #CFE_MISSION_EVS_MAX_MESSAGE_LENGTH. Characters beyond the limit will be truncated. +** Do not use floating point conversions (%f, %e, %E, %g, and %G) in the format +** string unless your application will be running in a system that supports +** floating point arithmetic. Do not use non-printable characters (\\t, \\n, etc.) +** in the format string; they will mess up the formatting when the events are +** displayed on the ground system. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_EVS_APP_NOT_REGISTERED \copybrief CFE_EVS_APP_NOT_REGISTERED +** \retval #CFE_EVS_APP_ILLEGAL_APP_ID \copybrief CFE_EVS_APP_ILLEGAL_APP_ID +** +** \sa #CFE_EVS_SendEvent, #CFE_EVS_SendEventWithAppID +** +**/ +CFE_Status_t CFE_EVS_SendTimedEvent (CFE_TIME_SysTime_t Time, + uint16 EventID, + uint16 EventType, + const char *Spec, ... ) OS_PRINTF(4,5); +/**@}*/ + +/** @defgroup CFEAPIEVSResetFilter cFE Reset Event Filter APIs + * @{ + */ + +/** +** \brief Resets the calling application's event filter for a single event ID. +** +** \par Description +** The effect of resetting an event filter depends on the filter scheme. +** The #CFE_EVS_EventFilter_BINARY scheme resets the filter counter for the specified Event ID. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] EventID A numeric literal used to uniquely identify an application event. +** The \c EventID is defined and supplied by the application sending the event. +** +** \return Execution status below or from #CFE_ES_GetAppID, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_EVS_APP_NOT_REGISTERED \copybrief CFE_EVS_APP_NOT_REGISTERED +** \retval #CFE_EVS_APP_ILLEGAL_APP_ID \copybrief CFE_EVS_APP_ILLEGAL_APP_ID +** +** \sa #CFE_EVS_ResetAllFilters +** +**/ +CFE_Status_t CFE_EVS_ResetFilter (int16 EventID); + + +/** +** \brief Resets all of the calling application's event filters. +** +** \par Description +** This routine resets all the calling application's event filter counters to zero, providing a +** quick and convenient method for resetting event filters. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return Execution status below or from #CFE_ES_GetAppID, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_EVS_APP_NOT_REGISTERED \copybrief CFE_EVS_APP_NOT_REGISTERED +** \retval #CFE_EVS_APP_ILLEGAL_APP_ID \copybrief CFE_EVS_APP_ILLEGAL_APP_ID +** +** \sa #CFE_EVS_ResetFilter +** +**/ +CFE_Status_t CFE_EVS_ResetAllFilters ( void ); +/**@}*/ + + +/* + * The internal APIs prototyped within this block are only intended to be invoked from + * other CFE core apps. They still need to be prototyped in the shared header such that + * they can be called from other core modules, but applications should not call these. + */ +#ifdef _CFE_CORE_ + +/** @defgroup CFEAPIEVSCoreInternal cFE Internal Event Services APIs, internal to CFE core + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE EVS Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** +******************************************************************************/ +extern void CFE_EVS_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_EVS_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Removes EVS resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees resources +** that have been allocated to the specified Application. +** +******************************************************************************/ +extern int32 CFE_EVS_CleanUpApp(CFE_ES_AppId_t AppId); + + +/**@}*/ + +#endif /* _CFE_CORE_ */ + + +#endif /* CFE_EVS_API_H */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_evs_api_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_evs_api_typedefs.h new file mode 100644 index 000000000..427505193 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_evs_api_typedefs.h @@ -0,0 +1,70 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** Filename: cfe_evs.h +** +** Title: Event Services API Application Library Header File +** +** Purpose: +** Unit specification for Event services library functions and macros. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +**/ + +#ifndef CFE_EVS_ABSTRACT_TYPES_H +#define CFE_EVS_ABSTRACT_TYPES_H + +/********************************** Include Files ************************************/ +#include "common_types.h" /* Basic data types */ +#include "cfe_evs_extern_typedefs.h" + +/** \name Common Event Filter Mask Values */ +/** \{ */ +#define CFE_EVS_NO_FILTER 0x0000 /**< \brief Stops any filtering. All messages are sent. */ +#define CFE_EVS_FIRST_ONE_STOP 0xFFFF /**< \brief Sends the first event. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_TWO_STOP 0xFFFE /**< \brief Sends the first 2 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_4_STOP 0xFFFC /**< \brief Sends the first 4 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_8_STOP 0xFFF8 /**< \brief Sends the first 8 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_16_STOP 0xFFF0 /**< \brief Sends the first 16 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_32_STOP 0xFFE0 /**< \brief Sends the first 32 events. All remaining messages are filtered. */ +#define CFE_EVS_FIRST_64_STOP 0xFFC0 /**< \brief Sends the first 64 events. All remaining messages are filtered. */ +#define CFE_EVS_EVERY_OTHER_ONE 0x0001 /**< \brief Sends every other event. */ +#define CFE_EVS_EVERY_OTHER_TWO 0x0002 /**< \brief Sends two, filters one, sends two, filters one, etc */ +#define CFE_EVS_EVERY_FOURTH_ONE 0x0003 /**< \brief Sends every fourth event message. All others are filtered. */ +/** \} */ + + + +/****************** Structure Definitions *********************/ + +/** \brief Event message filter defintion structure */ +typedef struct CFE_EVS_BinFilter { + uint16 EventID; /**< \brief Numerical event identifier */ + uint16 Mask; /**< \brief Binary filter mask value */ + +} CFE_EVS_BinFilter_t; + + + +#endif /* CFE_EVS_ABSTRACT_TYPES_H */ diff --git a/fsw/cfe-core/src/inc/cfe_evs_extern_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_evs_extern_typedefs.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_evs_extern_typedefs.h rename to modules/cfe_app_intf/fsw/inc/cfe_evs_extern_typedefs.h index e0b701427..5021ef0f9 100644 --- a/fsw/cfe-core/src/inc/cfe_evs_extern_typedefs.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_evs_extern_typedefs.h @@ -26,7 +26,7 @@ #ifdef CFE_EDS_ENABLED_BUILD /* Use the EDS generated version of these types */ -#include "cfe_evs_eds_typedefs.h" +#include "cfe_evs_eds_api_typedefs.h" #else /* Use the local definitions of these types */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_fs.h b/modules/cfe_app_intf/fsw/inc/cfe_fs.h new file mode 100644 index 000000000..a75cff8fc --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_fs.h @@ -0,0 +1,384 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_fs.h +** +** Purpose: cFE File Services (FS) library API header file +** +** Author: S.Walling/Microtel +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_fs_ +#define _cfe_fs_ + + +/* +** Required header files... +*/ +#include "common_types.h" +#include "osconfig.h" +#include "cfe_platform_cfg.h" +#include "cfe_error.h" +#include "cfe_fs_api_typedefs.h" +#include "cfe_fs_extern_typedefs.h" + + +/** @defgroup CFEAPIFSHeader cFE File Header Management APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Read the contents of the Standard cFE File Header +** +** \par Description +** This API will fill the specified #CFE_FS_Header_t variable with the +** contents of the Standard cFE File Header of the file identified by +** the given File Descriptor. +** +** \par Assumptions, External Events, and Notes: +** -# The File has already been successfully opened using #OS_OpenCreate and +** the caller has a legitimate File Descriptor. +** +** \param[in] FileDes File Descriptor obtained from a previous call to #OS_OpenCreate +** that is associated with the file whose header is to be read. +** +** \param[in, out] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be +** filled with the contents of the Standard cFE File Header. *Hdr is the contents of the Standard cFE File Header for the specified file. +** +** \return Execution status, see \ref CFEReturnCodes +** +** \sa #CFE_FS_WriteHeader +** +******************************************************************************/ +CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes); + +/*****************************************************************************/ +/** +** \brief Initializes the contents of the Standard cFE File Header +** +** \par Description +** This API will clear the specified #CFE_FS_Header_t variable and +** initialize the description field with the specified value +** +** \param[in] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be +** cleared and initialized +** +** \param[in] *Description Initializes Header's Description +** +** \param[in] SubType Initializes Header's SubType +** +** \sa #CFE_FS_WriteHeader +** +******************************************************************************/ +void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 SubType); + +/*****************************************************************************/ +/** +** \brief Write the specified Standard cFE File Header to the specified file +** +** \par Description +** This API will output the specified #CFE_FS_Header_t variable, with some +** fields automatically updated, to the specified file as the Standard cFE +** File Header. This API will automatically populate the following fields +** in the specified #CFE_FS_Header_t: +** +** -# \link #CFE_FS_Header_t::ContentType \c ContentType \endlink - Filled with 0x63464531 ('cFE1') +** -# \link #CFE_FS_Header_t::Length \c Length \endlink - Filled with the sizeof(CFE_FS_Header_t) +** -# \link #CFE_FS_Header_t::SpacecraftID \c SpacecraftID \endlink - Filled with the Spacecraft ID +** -# \link #CFE_FS_Header_t::ProcessorID \c ProcessorID \endlink - Filled with the Processor ID +** -# \link #CFE_FS_Header_t::ApplicationID \c ApplicationID \endlink - Filled with the Application ID +** -# \link #CFE_FS_Header_t::TimeSeconds \c TimeSeconds \endlink - Filled with the Time, in seconds, as obtained by #CFE_TIME_GetTime +** -# \link #CFE_FS_Header_t::TimeSubSeconds \c TimeSubSeconds \endlink - Filled with the Time, subseconds, as obtained by #CFE_TIME_GetTime +** +** +** \par Assumptions, External Events, and Notes: +** -# The File has already been successfully opened using #OS_OpenCreate and +** the caller has a legitimate File Descriptor. +** -# The \c SubType field has been filled appropriately by the Application. +** -# The \c Description field has been filled appropriately by the Application. +** +** \param[in] FileDes File Descriptor obtained from a previous call to #OS_OpenCreate +** that is associated with the file whose header is to be read. +** +** \param[in, out] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be +** filled with the contents of the Standard cFE File Header. *Hdr is the contents of the Standard cFE File Header for the specified file. +** +** \return Execution status, see \ref CFEReturnCodes +** +** \sa #CFE_FS_ReadHeader +** +******************************************************************************/ +CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr); + +/*****************************************************************************/ +/** +** \brief Modifies the Time Stamp field in the Standard cFE File Header for the specified file +** +** \par Description +** This API will modify the \link #CFE_FS_Header_t::TimeSeconds timestamp \endlink found +** in the Standard cFE File Header of the specified file. The timestamp will be replaced +** with the time specified by the caller. +** +** \par Assumptions, External Events, and Notes: +** -# The File has already been successfully opened using #OS_OpenCreate and +** the caller has a legitimate File Descriptor. +** -# The \c NewTimestamp field has been filled appropriately by the Application. +** +** \param[in] FileDes File Descriptor obtained from a previous call to #OS_OpenCreate +** that is associated with the file whose header is to be read. +** +** \param[in] NewTimestamp A #CFE_TIME_SysTime_t data structure containing the desired time +** to be put into the file's Standard cFE File Header. +** +** \return Execution status, see \ref CFEReturnCodes +** +******************************************************************************/ +CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp); +/**@}*/ + + +/** @defgroup CFEAPIFSUtil cFE File Utility APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Get the default virtual mount point for a file category +** +** Certain classes of files generally reside in a common directory, mainly +** either the persistent storage (/cf typically) or ram disk (/ram typically). +** +** Ephemeral status files are generally in the ram disk while application +** modules and scripts are generally in the persistent storage. +** +** This returns the expected directory for a given class of files in the form +** of a virtual OSAL mount point string. +** +** \returns String containing the mount point, or NULL if unkown/invalid +*/ +const char *CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_t FileCategory); + +/*****************************************************************************/ +/** +** \brief Get the default filename extension for a file category +** +** Certain file types may have an extension that varies from system to system. +** This is primarily an issue for application modules which are ".so" on +** Linux systems, ".dll" on Windows, ".o" on VxWorks, ".obj" on RTEMS, and so on. +** +** This uses a combination of compile-time configuration and hints from the +** build environment to get the default/expected extension for a given file +** category. +** +** \returns String containing the extension, or NULL if unkown/invalid +*/ +const char *CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_t FileCategory); + + +/*****************************************************************************/ +/** +** \brief Parse a filename input from an input buffer into a local buffer +** +** \par Description +** This provides a more user friendly way to specify file names, +** using default values for the path and extension, which can +** vary from system to system. +** +** If InputBuffer is null or its length is zero, then DefaultInput +** is used as if it was the content of the input buffer. +** +** If either the pathname or extension is missing from the input, +** it will be added from defaults, with the complete fully-qualified +** filename stored in the output buffer. +** +** \par Assumptions, External Events, and Notes: +** -# The paths and filenames used here are the standard unix style +** filenames separated by "/" (path) and "." (extension) characters. +** -# Input Buffer has a fixed max length. Parsing will not exceed InputBufSize, +** and does not need to be null terminated. However parsing will stop +** at the first null char, when the input is shorter than the maximum. +** +** \param[out] OutputBuffer Buffer to store result. +** \param[in] InputBuffer A input buffer that may contain a file name (e.g. from command). +** \param[in] OutputBufSize Maximum Size of output buffer. +** \param[in] InputBufSize Maximum Size of input buffer. +** \param[in] DefaultInput Default value to use for input if InputBffer is empty +** \param[in] DefaultPath Default value to use for pathname if omitted from input +** \param[in] DefaultExtension Default value to use for extension if omitted from input +** +** \return Execution status, see \ref CFEReturnCodes +** +******************************************************************************/ +int32 CFE_FS_ParseInputFileNameEx(char *OutputBuffer, const char *InputBuffer, size_t OutputBufSize, size_t InputBufSize, + const char *DefaultInput, const char *DefaultPath, const char *DefaultExtension); + + +/*****************************************************************************/ +/** +** \brief Parse a filename string from the user into a local buffer +** +** \par Description +** Simplified API for CFE_FS_ParseInputFileNameEx() where input is +** always known to be a non-empty, null terminated string and the fixed-length +** input buffer not needed. For instance this may be used where +** the input is a fixed string from cfe_platform_cfg.h or similar. +** +** \par Assumptions, External Events, and Notes: +** The parameters are organized such that this is basically like strncpy() with an +** extra argument, and existing file name accesses which use a direct copy can +** easily change to use this instead. +** +** \sa CFE_FS_ParseInputFileNameEx() +** +** \param[out] OutputBuffer Buffer to store result. +** \param[in] InputName A null terminated input string +** \param[in] OutputBufSize Maximum Size of output buffer. +** \param[in] FileCategory The generalized category of file (implies default path/extension) +** +** \return Execution status, see \ref CFEReturnCodes +** +**--------------------------------------------------------------------------------------- +*/ +int32 CFE_FS_ParseInputFileName(char *OutputBuffer, const char *InputName, size_t OutputBufSize, CFE_FS_FileCategory_t FileCategory); + + +/*****************************************************************************/ +/** +** \brief Extracts the filename from a unix style path and filename string. +** +** \par Description +** This API will take the original unix path/filename combination and +** extract the base filename. Example: Given the path/filename : "/cf/apps/myapp.o.gz" +** this function will return the filename: "myapp.o.gz". +** +** \par Assumptions, External Events, and Notes: +** -# The paths and filenames used here are the standard unix style +** filenames separated by "/" characters. +** -# The extracted filename (including terminator) is no longer than #OS_MAX_PATH_LEN +** +** \param[in] OriginalPath The original path. +** \param[out] FileNameOnly The filename that is extracted from the path. +** +** \return Execution status, see \ref CFEReturnCodes +** +******************************************************************************/ +CFE_Status_t CFE_FS_ExtractFilenameFromPath(const char *OriginalPath, char *FileNameOnly); + +/*****************************************************************************/ +/** +** \brief Register a background file dump request +** +** \par Description +** Puts the previously-initialized metadata into the pending request queue +** +** \par Assumptions, External Events, and Notes: +** Metadata structure should be stored in a static memory area (not on heap) as it +** must persist and be accessible by the file writer task throughout the asynchronous +** job operation. +** +** \param[inout] Meta The background file write persistent state object +** +** \return Execution status, see \ref CFEReturnCodes +** +******************************************************************************/ +int32 CFE_FS_BackgroundFileDumpRequest(CFE_FS_FileWriteMetaData_t *Meta); + +/*****************************************************************************/ +/** +** \brief Query if a background file write request is currently pending +** +** \par Description +** This returns "true" while the request is on the background work queue +** This returns "false" once the request is complete and removed from the queue. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[inout] Meta The background file write persistent state object +** +** \return true if request is already pending, false if not +** +******************************************************************************/ +bool CFE_FS_BackgroundFileDumpIsPending(const CFE_FS_FileWriteMetaData_t *Meta); + +/*****************************************************************************/ +/** +** \brief Execute the background file write job(s) +** +** \par Description +** Runs the state machine associated with background file write requests +** +** \par Assumptions, External Events, and Notes: +** This should only be invoked as a background job from the ES background task, +** it should not be invoked directly. +** +** \param[in] ElapsedTime The amount of time passed since last invocation (ms) +** \param[in] Arg Not used/ignored +** +** \return true if jobs are pending, false if idle +** +******************************************************************************/ +bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg); + +/**@}*/ + + +/* + * The internal APIs prototyped within this block are only intended to be invoked from + * other CFE core apps. They still need to be prototyped in the shared header such that + * they can be called from other core modules, but applications should not call these. + */ +#ifdef _CFE_CORE_ + +/** @defgroup CFEAPIFSCoreInternal cFE Internal File Service APIs, internal to CFE core + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_FS_EarlyInit(void); + + +/**@}*/ + +#endif /* _CFE_CORE_ */ + + + +#endif /* _cfe_fs_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_fs_api_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_fs_api_typedefs.h new file mode 100644 index 000000000..0349ab5a9 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_fs_api_typedefs.h @@ -0,0 +1,132 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_fs_api_typedefs.h +** +** Purpose: cFE File Services (FS) library API header file +** +** Author: S.Walling/Microtel +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef CFE_FS_ABSTRACT_TYPES_H +#define CFE_FS_ABSTRACT_TYPES_H + + +/* +** Required header files... +*/ +#include "common_types.h" +#include "osconfig.h" +#include "cfe_fs_extern_typedefs.h" + +/** + * \brief Generalized file types/categories known to FS + * + * This defines different categories of files, where they + * may reside in different default locations of the virtualized file system. + * + * This is different from, and should not be confused with, the "SubType" + * field in the FS header. This value is only used at runtime for FS APIs + * and should not actually appear in any output file or message. + */ +typedef enum +{ + CFE_FS_FileCategory_UNKNOWN, /**< Placeholder, unknown file category */ + CFE_FS_FileCategory_DYNAMIC_MODULE, /**< Dynamically loadable apps/libraries (e.g. .so, .o, .dll, etc) */ + CFE_FS_FileCategory_BINARY_DATA_DUMP, /**< Binary log file generated by various data dump commands */ + CFE_FS_FileCategory_TEXT_LOG, /**< Text-based log file generated by various commands */ + CFE_FS_FileCategory_SCRIPT, /**< Text-based Script files (e.g. ES startup script) */ + CFE_FS_FileCategory_TEMP, /**< Temporary/Ephemeral files */ + CFE_FS_FileCategory_MAX /**< Placeholder, keep last */ +} CFE_FS_FileCategory_t; + +/* + * Because FS is a library not an app, it does not have its own context or + * event IDs. The file writer runs in the context of the ES background task + * on behalf of whatever App requested the file write. + * + * This is a list of abstract events associated with background file write jobs. + * An app requesting the file write must supply a callback function to translate + * these into its own event IDs for feedback (i.e. file complete, error conditions, etc). + */ +typedef enum +{ + CFE_FS_FileWriteEvent_UNDEFINED, /* placeholder, no-op, keep as 0 */ + + CFE_FS_FileWriteEvent_COMPLETE, /**< File is completed successfully */ + CFE_FS_FileWriteEvent_CREATE_ERROR, /**< Unable to create/open file */ + CFE_FS_FileWriteEvent_HEADER_WRITE_ERROR, /**< Unable to write FS header */ + CFE_FS_FileWriteEvent_RECORD_WRITE_ERROR, /**< Unable to write data record */ + + CFE_FS_FileWriteEvent_MAX /* placeholder, no-op, keep last */ + +} CFE_FS_FileWriteEvent_t; + + + +/** + * Data Getter routine provided by requester + * + * Outputs a data block. Should return true if the file is complete (last record/EOF), otherwise return false. + */ +typedef bool (*CFE_FS_FileWriteGetData_t)(void *Meta, uint32 RecordNum, void **Buffer, size_t *BufSize); + +/** + * Event generator routine provided by requester + * + * Invoked from certain points in the file write process. Implementation may invoke CFE_EVS_SendEvent() appropriately + * to inform of progress. + */ +typedef void (*CFE_FS_FileWriteOnEvent_t)(void *Meta, CFE_FS_FileWriteEvent_t Event, int32 Status, uint32 RecordNum, size_t BlockSize, size_t Position); + +/** + * \brief External Metadata/State object associated with background file writes + * + * Applications intending to schedule background file write jobs should instantiate + * this object in static/global data memory. This keeps track of the state of the + * file write request(s). + */ +typedef struct CFE_FS_FileWriteMetaData +{ + volatile bool IsPending; /**< Whether request is pending (volatile as it may be checked outside lock) */ + + char FileName[OS_MAX_PATH_LEN]; /**< Name of file to write */ + + /* Data for FS header */ + uint32 FileSubType; /**< Type of file to write (for FS header) */ + char Description[CFE_FS_HDR_DESC_MAX_LEN]; /**< Description of file (for FS header) */ + + CFE_FS_FileWriteGetData_t GetData; /**< Application callback to get a data record */ + CFE_FS_FileWriteOnEvent_t OnEvent; /**< Application callback for abstract event processing */ + +} CFE_FS_FileWriteMetaData_t; + + + +#endif /* CFE_FS_ABSTRACT_TYPES_H */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_fs_extern_typedefs.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h rename to modules/cfe_app_intf/fsw/inc/cfe_fs_extern_typedefs.h index 55c539e6e..0a379a654 100644 --- a/fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_fs_extern_typedefs.h @@ -26,7 +26,7 @@ #ifdef CFE_EDS_ENABLED_BUILD /* Use the EDS generated version of these types */ -#include "cfe_fs_eds_typedefs.h" +#include "cfe_fs_eds_api_typedefs.h" #else /* Use the local definitions of these types */ diff --git a/fsw/cfe-core/src/inc/cfe_msg_api.h b/modules/cfe_app_intf/fsw/inc/cfe_msg.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_msg_api.h rename to modules/cfe_app_intf/fsw/inc/cfe_msg.h index 3dfe24b4f..ba84ecaf9 100644 --- a/fsw/cfe-core/src/inc/cfe_msg_api.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_msg.h @@ -31,9 +31,11 @@ #include "common_types.h" #include "cfe_error.h" #include "cfe_msg_hdr.h" -#include "cfe_msg_typedefs.h" -#include "cfe_time.h" -#include "cfe_sb.h" +#include "cfe_msg_api_typedefs.h" + +#include "cfe_es_api_typedefs.h" +#include "cfe_sb_api_typedefs.h" +#include "cfe_time_api_typedefs.h" /** \defgroup CFEAPIMSGHeader cFE Message header APIs * \{ diff --git a/fsw/cfe-core/src/inc/cfe_msg_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_msg_api_typedefs.h similarity index 84% rename from fsw/cfe-core/src/inc/cfe_msg_typedefs.h rename to modules/cfe_app_intf/fsw/inc/cfe_msg_api_typedefs.h index 4df7bfd41..a2c5ee543 100644 --- a/fsw/cfe-core/src/inc/cfe_msg_typedefs.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_msg_api_typedefs.h @@ -87,4 +87,29 @@ typedef enum CFE_MSG_PlaybackFlag CFE_MSG_PlayFlag_Playback /**< \brief Playback */ } CFE_MSG_PlaybackFlag_t; +/* + * Abstract Message Base Types + * + * The concrete definition of these is provided by "cfe_msg_hdr.h" which is + * user-selectable depending on the actual desired message defintion. These + * abstract types are used in the API definition; the API is defined based + * on these abstract types, independent of the actual message definition. + */ + +/** + * \brief cFS generic base message + */ +typedef union CFE_MSG_Message CFE_MSG_Message_t; + +/** + * \brief cFS command header + */ +typedef struct CFE_MSG_CommandHeader CFE_MSG_CommandHeader_t; + +/** + * \brief cFS telemetry header + */ +typedef struct CFE_MSG_TelemetryHeader CFE_MSG_TelemetryHeader_t; + + #endif /* _cfe_msg_typedefs_ */ diff --git a/fsw/cfe-core/src/inc/cfe_resourceid_api.h b/modules/cfe_app_intf/fsw/inc/cfe_resourceid.h similarity index 87% rename from fsw/cfe-core/src/inc/cfe_resourceid_api.h rename to modules/cfe_app_intf/fsw/inc/cfe_resourceid.h index 6a1ef4d18..12f2fef27 100644 --- a/fsw/cfe-core/src/inc/cfe_resourceid_api.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_resourceid.h @@ -19,7 +19,7 @@ */ /** - * \file cfe_resourceid_api.h + * \file cfe_resourceid.h * * Contains global prototypes and definitions related to resource * management and related CFE resource IDs. @@ -40,43 +40,10 @@ #define CFE_RESOURCEID_API_H /* - * The basic resource ID typedef - * - * This is provided via the external resourceid library - * and may be customized by the user/mission preferences. + * The basic resource ID API definitions */ -#include "cfe_resourceid_typedef.h" +#include "cfe_resourceid_api_typedefs.h" -/* -** Defines -*/ - -/** \name Resource ID predefined values */ -/** \{ */ - - -/** - * @brief A resource ID value that represents an undefined/unused resource - * - * This constant may be used to initialize local variables of the - * CFE_ResourceId_t type to a safe value that will not alias a valid ID. - * - * By design, this value is also the result of zeroing a CFE_ResourceId_t - * type via standard functions like memset(), such that objects initialized - * using this method will also be set to safe values. - */ -#define CFE_RESOURCEID_UNDEFINED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0)) - -/** - * @brief A resource ID value that represents a reserved entry - * - * This is not a valid value for any resource type, but is used to mark - * table entries that are not available for use. For instance, this may - * be used while setting up an entry initially. - */ -#define CFE_RESOURCEID_RESERVED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0xFFFFFFFF)) - -/** \} */ /** \name Resource ID test/conversion macros and inline functions */ /** \{ */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_resourceid_api_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_resourceid_api_typedefs.h new file mode 100644 index 000000000..89a03bf3e --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_resourceid_api_typedefs.h @@ -0,0 +1,82 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/** + * \file cfe_resourceid_api_typedefs.h + * + * Contains global prototypes and definitions related to resource + * management and related CFE resource IDs. + * + * A CFE ES Resource ID is a common way to identify CFE-managed resources such + * as apps, tasks, counters, memory pools, CDS blocks, and other entities. + * + * Simple operations are provided as inline functions, which + * should alleviate the need to do direct manipulation of resource IDs: + * + * - Check for undefined ID value + * - Check for equality of two ID values + * - Convert ID to simple integer (typically for printing/logging) + * - Convert simple integer to ID (inverse of above) + */ + +#ifndef CFE_RESOURCEID_API_TYPEDEFS_H +#define CFE_RESOURCEID_API_TYPEDEFS_H + +/* + * The basic resource ID typedef + * + * This is provided via the external resourceid library + * and may be customized by the user/mission preferences. + */ +#include "cfe_resourceid_typedef.h" + +/* +** Defines +*/ + +/** \name Resource ID predefined values */ +/** \{ */ + + +/** + * @brief A resource ID value that represents an undefined/unused resource + * + * This constant may be used to initialize local variables of the + * CFE_ResourceId_t type to a safe value that will not alias a valid ID. + * + * By design, this value is also the result of zeroing a CFE_ResourceId_t + * type via standard functions like memset(), such that objects initialized + * using this method will also be set to safe values. + */ +#define CFE_RESOURCEID_UNDEFINED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0)) + +/** + * @brief A resource ID value that represents a reserved entry + * + * This is not a valid value for any resource type, but is used to mark + * table entries that are not available for use. For instance, this may + * be used while setting up an entry initially. + */ +#define CFE_RESOURCEID_RESERVED ((CFE_ResourceId_t) CFE_RESOURCEID_WRAP(0xFFFFFFFF)) + +/** \} */ + + +#endif /* CFE_RESOURCEID_API_TYPEDEFS_H */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_sb.h b/modules/cfe_app_intf/fsw/inc/cfe_sb.h new file mode 100644 index 000000000..039ccd8c4 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_sb.h @@ -0,0 +1,1380 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/****************************************************************************** +** File: cfe_sb.h +** +** Purpose: +** This header file contains all definitions for the cFE Software Bus +** Application Programmer's Interface. +** +** Author: R.McGraw/SSI +** +******************************************************************************/ + +#ifndef CFE_SB_API_H +#define CFE_SB_API_H + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_error.h" +#include "cfe_sb_api_typedefs.h" +#include "cfe_es_api_typedefs.h" + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/* only deprecated functions depend on TIME types */ +#include "cfe_time_api_typedefs.h" +#endif + +/* +** Macro Definitions +*/ +#define CFE_BIT(x) (1 << (x)) /**< \brief Places a one at bit positions 0 - 31*/ +#define CFE_SET(i,x) ((i) |= CFE_BIT(x)) /**< \brief Sets bit x of i */ +#define CFE_CLR(i,x) ((i) &= ~CFE_BIT(x)) /**< \brief Clears bit x of i */ +#define CFE_TST(i,x) (((i) & CFE_BIT(x)) != 0)/**< \brief true(non zero) if bit x of i is set */ + + +/****************** Function Prototypes **********************/ + +/** @defgroup CFEAPISBPipe cFE Pipe Management APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Creates a new software bus pipe. +** +** \par Description +** This routine creates and initializes an input pipe that the calling +** application can use to receive software bus messages. By default, no +** messages are routed to the new pipe. So, the application must use +** #CFE_SB_Subscribe to specify which messages it wants to receive on +** this pipe. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in, out] PipeIdPtr A pointer to a variable of type #CFE_SB_PipeId_t, +** which will be filled in with the pipe ID information +** by the #CFE_SB_CreatePipe routine. *PipeIdPtr is the identifier for the created pipe. +** +** \param[in] Depth The maximum number of messages that will be allowed on +** this pipe at one time. +** +** \param[in] PipeName A string to be used to identify this pipe in error messages +** and routing information telemetry. The string must be no +** longer than #OS_MAX_API_NAME (including terminator). +** Longer strings will be truncated. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_MAX_PIPES_MET \copybrief CFE_SB_MAX_PIPES_MET +** \retval #CFE_SB_PIPE_CR_ERR \copybrief CFE_SB_PIPE_CR_ERR +** +** \sa #CFE_SB_DeletePipe #CFE_SB_GetPipeOpts #CFE_SB_SetPipeOpts #CFE_SB_GetPipeIdByName +**/ +CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const char *PipeName); + +/*****************************************************************************/ +/** +** \brief Delete a software bus pipe. +** +** \par Description +** This routine deletes an input pipe and cleans up all data structures +** associated with the pipe. All subscriptions made for this pipe by +** calls to #CFE_SB_Subscribe will be automatically removed from the +** SB routing tables. Any messages in the pipe will be discarded. +** +** Applications should not call this routine for all of their +** SB pipes as part of their orderly shutdown process, as the +** pipe will be deleted by the support framework at the +** appropriate time. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] PipeId The pipe ID (obtained previously from #CFE_SB_CreatePipe) +** of the pipe to be deleted. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** +** \sa #CFE_SB_CreatePipe #CFE_SB_GetPipeOpts #CFE_SB_SetPipeOpts #CFE_SB_GetPipeIdByName +**/ +CFE_Status_t CFE_SB_DeletePipe(CFE_SB_PipeId_t PipeId); + +/** + * @brief Obtain an index value correlating to an SB Pipe ID + * + * This calculates a zero based integer value that may be used for indexing + * into a local resource table/array. + * + * Index values are only guaranteed to be unique for resources of the same + * type. For instance, the indices corresponding to two [valid] application + * IDs will never overlap, but the index of a pipe ID and an app ID + * may be the same. Furthermore, indices may be reused if a resource is + * deleted and re-created. + * + * @note There is no inverse of this function - indices cannot be converted + * back to the original PipeID value. The caller should retain the original ID + * for future use. + * + * @param[in] PipeID Pipe ID to convert + * @param[out] Idx Buffer where the calculated index will be stored + * + * @return Execution status, see @ref CFEReturnCodes + * @retval #CFE_SUCCESS @copybrief CFE_SUCCESS + * @retval #CFE_ES_ERR_RESOURCEID_NOT_VALID @copybrief CFE_ES_ERR_RESOURCEID_NOT_VALID + */ +CFE_Status_t CFE_SB_PipeId_ToIndex(CFE_SB_PipeId_t PipeID, uint32 *Idx); + + +/*****************************************************************************/ +/** +** \brief Set options on a pipe. +** +** \par Description +** This routine sets (or clears) options to alter the pipe's behavior. +** Options are (re)set every call to this routine. +** +** \param[in] PipeId The pipe ID of the pipe to set options on. +** +** \param[in] Opts A bit field of options. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** +** \sa #CFE_SB_CreatePipe #CFE_SB_DeletePipe #CFE_SB_GetPipeOpts #CFE_SB_GetPipeIdByName #CFE_SB_PIPEOPTS_IGNOREMINE +**/ +CFE_Status_t CFE_SB_SetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 Opts); + +/*****************************************************************************/ +/** +** \brief Get options on a pipe. +** +** \par Description +** This routine gets the current options on a pipe. +** +** \param[in] PipeId The pipe ID of the pipe to get options from. +** +** \param[out] *OptPtr A bit field of options. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** +** \sa #CFE_SB_CreatePipe #CFE_SB_DeletePipe #CFE_SB_SetPipeOpts #CFE_SB_GetPipeIdByName #CFE_SB_PIPEOPTS_IGNOREMINE +**/ +CFE_Status_t CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptPtr); + +/*****************************************************************************/ +/** +** \brief Get the pipe name for a given id. +** +** \par Description +** This routine finds the pipe name for a pipe id. +** +** \param[out] PipeNameBuf The buffer to receive the pipe name. +** +** \param[in] PipeNameSize The size (in chars) of the PipeName buffer. +** +** \param[in] PipeId The PipeId for that name. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** +** \sa #CFE_SB_CreatePipe #CFE_SB_DeletePipe #CFE_SB_SetPipeOpts #CFE_SB_GetPipeIdByName +**/ +CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Get pipe id by pipe name. +** +** \par Description +** This routine finds the pipe id for a pipe name. +** +** \param[in] PipeName The name of the pipe. +** +** \param[out] PipeIdPtr The PipeId for that name. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** +** \sa #CFE_SB_CreatePipe #CFE_SB_DeletePipe #CFE_SB_SetPipeOpts #CFE_SB_PIPEOPTS_IGNOREMINE +**/ +CFE_Status_t CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName); +/**@}*/ + +/** @defgroup CFEAPISBSubscription cFE Message Subscription Control APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Subscribe to a message on the software bus +** +** \par Description +** This routine adds the specified pipe to the destination list associated +** with the specified message ID. +** +** \par Assumptions, External Events, and Notes: +** Note: As subscriptions are received, the destinations are added to +** the head of a linked list. During the sending of a message, the list +** is traversed beginning at the head of the list. Therefore the +** message will first be sent to the last subscriber. If an application +** has timing constraints and needs to receive a message in the +** shortest possible time, the developer may consider holding off its +** subscription until other applications have subscribed to the message. +** +** \param[in] MsgId The message ID of the message to be subscribed to. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should be sent to. +** +** \param[in] Quality The requested Quality of Service (QoS) required of +** the messages. Most callers will use #CFE_SB_DEFAULT_QOS +** for this parameter. +** +** \param[in] MsgLim The maximum number of messages with this Message ID to +** allow in this pipe at the same time. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_MAX_MSGS_MET \copybrief CFE_SB_MAX_MSGS_MET +** \retval #CFE_SB_MAX_DESTS_MET \copybrief CFE_SB_MAX_DESTS_MET +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal +**/ +CFE_Status_t CFE_SB_SubscribeEx(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality, uint16 MsgLim); + +/*****************************************************************************/ +/** +** \brief Subscribe to a message on the software bus with default parameters +** +** \par Description +** This routine adds the specified pipe to the destination list for +** the specified message ID. This is the same as #CFE_SB_SubscribeEx +** with the Quality field set to #CFE_SB_DEFAULT_QOS and MsgLim set +** to #CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT (4). +** +** \par Assumptions, External Events, and Notes: +** Note: As subscriptions are received, the destinations are added to +** the head of a linked list. During the sending of a message, the list +** is traversed beginning at the head of the list. Therefore the +** message will first be sent to the last subscriber. If an application +** has timing constraints and needs to receive a message in the +** shortest possible time, the developer may consider holding off its +** subscription until other applications have subscribed to the message. +** +** \param[in] MsgId The message ID of the message to be subscribed to. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should be sent to. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_MAX_MSGS_MET \copybrief CFE_SB_MAX_MSGS_MET +** \retval #CFE_SB_MAX_DESTS_MET \copybrief CFE_SB_MAX_DESTS_MET +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +** +** \sa #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal +**/ +CFE_Status_t CFE_SB_Subscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Subscribe to a message while keeping the request local to a cpu +** +** \par Description +** This routine adds the specified pipe to the destination list for +** the specified message ID. This is similar to #CFE_SB_SubscribeEx +** with the Quality field set to #CFE_SB_DEFAULT_QOS and MsgLim set +** to #CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, but will not report the subscription. +** Subscription Reporting is enabled for interprocessor communication +** by way of the Software Bus Network (SBN) Application. +** +** \par Assumptions, External Events, and Notes: +** - This API is typically only used by Software Bus Network (SBN) Application +** +** \param[in] MsgId The message ID of the message to be subscribed to. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should be sent to. +** +** \param[in] MsgLim The maximum number of messages with this Message ID to +** allow in this pipe at the same time. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_MAX_MSGS_MET \copybrief CFE_SB_MAX_MSGS_MET +** \retval #CFE_SB_MAX_DESTS_MET \copybrief CFE_SB_MAX_DESTS_MET +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_Unsubscribe, #CFE_SB_UnsubscribeLocal +**/ +CFE_Status_t CFE_SB_SubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, uint16 MsgLim); + +/*****************************************************************************/ +/** +** \brief Remove a subscription to a message on the software bus +** +** \par Description +** This routine removes the specified pipe from the destination +** list for the specified message ID. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgId The message ID of the message to be unsubscribed. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should no longer be sent to. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_NO_SUBSCRIBERS \copybrief CFE_SB_NO_SUBSCRIBERS +** \retval #CFE_SB_INTERNAL_ERR \copybrief CFE_SB_INTERNAL_ERR +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_UnsubscribeLocal +**/ +CFE_Status_t CFE_SB_Unsubscribe(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); + +/*****************************************************************************/ +/** +** \brief Remove a subscription to a message on the software bus on the current CPU +** +** \par Description +** This routine removes the specified pipe from the destination +** list for the specified message ID on the current CPU. +** +** \par Assumptions, External Events, and Notes: +** - This API is typically only used by Software Bus Network (SBN) Application +** +** \param[in] MsgId The message ID of the message to be unsubscribed. +** +** \param[in] PipeId The pipe ID of the pipe the subscribed message +** should no longer be sent to. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_NO_SUBSCRIBERS \copybrief CFE_SB_NO_SUBSCRIBERS +** \retval #CFE_SB_INTERNAL_ERR \copybrief CFE_SB_INTERNAL_ERR +** +** \sa #CFE_SB_Subscribe, #CFE_SB_SubscribeEx, #CFE_SB_SubscribeLocal, #CFE_SB_Unsubscribe +**/ +CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId); +/**@}*/ + +/** @defgroup CFEAPISBMessage cFE Send/Receive Message APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Transmit a message +** +** \par Description +** This routine copies the specified message into a software bus +** buffer which is then transmitted to all subscribers. The +** software bus will read the message ID from the message header to +** determine which pipes should receive the message. +** +** \par Assumptions, External Events, and Notes: +** - This routine will not normally wait for the receiver tasks to +** process the message before returning control to the caller's task. +** - However, if a higher priority task is pending and subscribed to +** this message, that task may get to run before returning +** control to the caller. +** +** \param[in] MsgPtr A pointer to the message to be sent. This must point +** to the first byte of the message header. +** \param[in] IncrementSequenceCount Boolean to increment the internally tracked +** sequence count and update the message if the +** buffer contains a telemetry message +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +**/ +CFE_Status_t CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount); + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/*****************************************************************************/ +/** +** \brief DEPRECATED: Send a software bus message +** \deprecated Use CFE_SB_TransmitMsg +** +** \par Description +** This routine sends the specified message to all subscribers. The +** software bus will read the message ID from the message header to +** determine which pipes should receive the message. +** +** \par Assumptions, External Events, and Notes: +** - This routine will not normally wait for the receiver tasks to +** process the message before returning control to the caller's task. +** - However, if a higher priority task is pending and subscribed to +** this message, that task may get to run before returning +** control to the caller. +** - This function tracks and increments the source sequence counter +** of a telemetry message. +** +** \param[in] MsgPtr A pointer to the message to be sent. This must point +** to the first byte of the message header. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +**/ +CFE_Status_t CFE_SB_SendMsg(CFE_MSG_Message_t *MsgPtr); + +/*****************************************************************************/ +/** +** \brief DEPRECATED: Passes a software bus message +** \deprecated Use CFE_SB_TransmitMsg +** +** \par Description +** This routine sends the specified message to all subscribers. The +** software bus will read the message ID from the message header to +** determine which pipes should receive the message. This routine is +** intended to pass messages not generated by the sending application. +** +** \par Assumptions, External Events, and Notes: +** - This routine will not normally wait for the receiver tasks to +** process the message before returning control to the caller's task. +** - However, if a higher priority task is pending and subscribed to +** this message, that task may get to run before #CFE_SB_PassMsg +** returns control to the caller. +** - This routine will not modify the sequence counter in the message. +** +** \param[in] MsgPtr A pointer to the message to be sent. This must point +** to the first byte of the message header. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +**/ +CFE_Status_t CFE_SB_PassMsg(CFE_MSG_Message_t *MsgPtr); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/*****************************************************************************/ +/** +** \brief Receive a message from a software bus pipe +** +** \par Description +** This routine retrieves the next message from the specified pipe. +** If the pipe is empty, this routine will block until either a new +** message comes in or the timeout value is reached. +** +** \par Assumptions, External Events, and Notes: +** Note - If an error occurs in this API, the *BufPtr value may be NULL or +** random. Therefore, it is recommended that the return code be tested +** for CFE_SUCCESS before processing the message. +** +** \param[in, out] BufPtr A pointer to the software bus buffer to receive to. +** Typically a caller declares a ptr of type CFE_SB_Buffer_t +** (i.e. CFE_SB_Buffer_t *Ptr) then gives the address of that +** pointer (&Ptr) as this parmeter. After a successful +** receipt of a message, *BufPtr will point to the first +** byte of the software bus buffer. This should be +** used as a read-only pointer (in systems with an MMU, +** writes to this pointer may cause a memory protection fault). +** The *BufPtr is valid only until the next call to +** CFE_SB_ReceiveBuffer for the same pipe. +** +** \param[in] PipeId The pipe ID of the pipe containing the message to be obtained. +** +** \param[in] TimeOut The number of milliseconds to wait for a new message if the +** pipe is empty at the time of the call. This can also be set +** to #CFE_SB_POLL for a non-blocking receive or +** #CFE_SB_PEND_FOREVER to wait forever for a message to arrive. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_TIME_OUT \copybrief CFE_SB_TIME_OUT +** \retval #CFE_SB_PIPE_RD_ERR \copybrief CFE_SB_PIPE_RD_ERR +** \retval #CFE_SB_NO_MESSAGE \copybrief CFE_SB_NO_MESSAGE +**/ +CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut); + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/** + * \brief DEPRECATED: receive buffer + * \deprecated use CFE_SB_ReceiveBuffer + */ +CFE_Status_t CFE_SB_RcvMsg(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ +/**@}*/ + +/** @defgroup CFEAPISBZeroCopy cFE Zero Copy APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Get a buffer pointer to use for "zero copy" SB sends. +** +** \par Description +** This routine can be used to get a pointer to one of the software bus' +** internal memory buffers that are used for sending messages. The caller +** can use this memory buffer to build an SB message, then send it using +** the #CFE_SB_TransmitBuffer function. This interface is more complicated +** than the normal #CFE_SB_TransmitMsg interface, but it avoids an extra +** copy of the message from the user's memory buffer to the software bus +** internal buffer. The "zero copy" interface can be used to improve +** performance in high-rate, high-volume software bus traffic. +** +** \par Assumptions, External Events, and Notes: +** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for one +** call to #CFE_SB_TransmitBuffer. +** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is +** equivalent to a \c malloc() and #CFE_SB_TransmitBuffer is equivalent to +** a \c free(). +** -# Applications must not de-reference the message pointer (for reading +** or writing) after the call to #CFE_SB_TransmitBuffer. +** +** \param[in] MsgSize The size of the SB message buffer the caller wants +** (including the SB message header). +** +** \param[out] BufferHandle A handle that must be supplied when sending or releasing +** in zero copy mode. +** +** \return A pointer to a memory buffer that message data can be written to +** for use with #CFE_SB_TransmitBuffer. +**/ +CFE_SB_Buffer_t *CFE_SB_ZeroCopyGetPtr(size_t MsgSize, + CFE_SB_ZeroCopyHandle_t *BufferHandle); + +/*****************************************************************************/ +/** +** \brief Release an unused "zero copy" buffer pointer. +** +** \par Description +** This routine can be used to release a pointer to one of the software +** bus' internal memory buffers. +** +** \par Assumptions, External Events, and Notes: +** -# This function is not needed for normal "zero copy" transfers. It +** is needed only for cleanup when an application gets a pointer using +** #CFE_SB_ZeroCopyGetPtr, but (due to some error condition) never uses +** that pointer for a #CFE_SB_TransmitBuffer +** +** \param[in] Ptr2Release A pointer to the SB internal buffer. This must be a +** pointer returned by a call to #CFE_SB_ZeroCopyGetPtr, +** but never used in a call to #CFE_SB_TransmitBuffer. +** +** \param[in] ZeroCopyHandle This must be the handle supplied with the pointer +** when #CFE_SB_ZeroCopyGetPtr was called. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BUFFER_INVALID \copybrief CFE_SB_BUFFER_INVALID +**/ +CFE_Status_t CFE_SB_ZeroCopyReleasePtr(CFE_SB_Buffer_t *Ptr2Release, CFE_SB_ZeroCopyHandle_t ZeroCopyHandle); + +/*****************************************************************************/ +/** +** \brief Transmit a buffer +** +** \par Description +** This routine sends a message that has been created directly in an +** internal SB message buffer by an application (after a call to +** #CFE_SB_ZeroCopyGetPtr). This interface is more complicated than +** the normal #CFE_SB_TransmitMsg interface, but it avoids an extra copy of +** the message from the user's memory buffer to the software bus +** internal buffer. The "zero copy" interface can be used to improve +** performance in high-rate, high-volume software bus traffic. +** +** \par Assumptions, External Events, and Notes: +** -# A handle returned by #CFE_SB_ZeroCopyGetPtr is "consumed" by +** a _successful_ call to #CFE_SB_TransmitBuffer. +** -# If this function returns CFE_SUCCESS, this indicates the zero copy handle is +** now owned by software bus, and is no longer owned by the calling application, +** and should not be re-used. +** -# Howver if this function fails (returns any error status) it does not change +** the state of the buffer at all, meaning the calling application still owns it. +** (a failure means the buffer is left in the same state it was before the call). +** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is +** equivalent to a \c malloc() and a successful call to #CFE_SB_TransmitBuffer +** is equivalent to a \c free(). +** -# Applications must not de-reference the message pointer (for reading +** or writing) after a successful call to #CFE_SB_TransmitBuffer. +** -# This function will increment and apply the internally tracked +** sequence counter if set to do so. +** +** \param[in] BufPtr A pointer to the buffer to be sent. +** \param[in] ZeroCopyHandle The handle supplied by the #CFE_SB_ZeroCopyGetPtr call +** \param[in] IncrementSequenceCount Boolean to increment the internally tracked +** sequence count and update the message if the +** buffer contains a telemetry message +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +**/ +CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, + CFE_SB_ZeroCopyHandle_t ZeroCopyHandle, + bool IncrementSequenceCount); + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/*****************************************************************************/ +/** +** \brief DEPRECATED: Send an SB message in "zero copy" mode. +** \deprecated use CFE_SB_TransmitBuffer +** +** \par Description +** This routine sends a message that has been created directly in an +** internal SB message buffer by an application (after a call to +** #CFE_SB_ZeroCopyGetPtr). This interface is more complicated than +** the normal #CFE_SB_TransmitMsg interface, but it avoids an extra copy of +** the message from the user's memory buffer to the software bus +** internal buffer. The "zero copy" interface can be used to improve +** performance in high-rate, high-volume software bus traffic. +** +** \par Assumptions, External Events, and Notes: +** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for +** one call to #CFE_SB_TransmitBuffer. +** -# Callers must not use the same SB message buffer for multiple sends. +** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is +** equivalent to a \c malloc() and #CFE_SB_TransmitBuffer is equivalent +** to a \c free(). +** -# Applications must not de-reference the message pointer (for reading +** or writing) after the call to #CFE_SB_TransmitBuffer. +** -# This function tracks and increments the source sequence counter +** of a telemetry message. +** +** \param[in] BufPtr A pointer to the SB buffer to be sent. +** +** \param[in] BufferHandle The handle supplied with the #CFE_SB_ZeroCopyGetPtr call. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +** \retval #CFE_SB_BUFFER_INVALID \copybrief CFE_SB_BUFFER_INVALID +**/ +CFE_Status_t CFE_SB_ZeroCopySend(CFE_SB_Buffer_t *BufPtr, CFE_SB_ZeroCopyHandle_t BufferHandle); + +/*****************************************************************************/ +/** +** \brief DEPRECATED: Pass an SB message in "zero copy" mode. +** \deprecated use CFE_SB_TransmitBuffer +** +** \par Description +** This routine sends a message that has been created directly in an +** internal SB message buffer by an application (after a call to +** #CFE_SB_ZeroCopyGetPtr). This interface is more complicated than +** the normal #CFE_SB_TransmitMsg interface, but it avoids an extra copy of +** the message from the user's memory buffer to the software bus +** internal buffer. The "zero copy" interface can be used to improve +** performance in high-rate, high-volume software bus traffic. This +** version is intended to pass messages not generated by the caller +** (to preserve the source sequence count). +** +** \par Assumptions, External Events, and Notes: +** -# The pointer returned by #CFE_SB_ZeroCopyGetPtr is only good for +** one call to #CFE_SB_TransmitBuffer or #CFE_SB_ZeroCopyPass. +** -# Callers must not use the same SB message buffer for multiple sends. +** -# Applications should be written as if #CFE_SB_ZeroCopyGetPtr is +** equivalent to a \c malloc() and #CFE_SB_ZeroCopyPass is equivalent +** to a \c free(). +** -# Applications must not de-reference the message pointer (for reading +** or writing) after the call to #CFE_SB_ZeroCopyPass. +** -# This routine will not modify the sequence counter in a telemetry +** message +** +** \param[in] BufPtr A pointer to the SB buffer to be sent. +** +** \param[in] BufferHandle The handle supplied with the #CFE_SB_ZeroCopyGetPtr call. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT +** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG +** \retval #CFE_SB_BUF_ALOC_ERR \copybrief CFE_SB_BUF_ALOC_ERR +** \retval #CFE_SB_BUFFER_INVALID \copybrief CFE_SB_BUFFER_INVALID +**/ +CFE_Status_t CFE_SB_ZeroCopyPass(CFE_SB_Buffer_t *BufPtr, CFE_SB_ZeroCopyHandle_t BufferHandle); +/**@}*/ +#endif + +/** @defgroup CFEAPISBSetMessage cFE Setting Message Characteristics APIs + * @{ + */ + +#ifndef CFE_OMIT_DEPRECATED_6_8 + +/*****************************************************************************/ +/** +** \brief DEPRECATED - Initialize a buffer for a software bus message. +** \deprecated Use CFE_MSG_Init +** +** \par Description +** This routine fills in the header information needed to create a +** valid software bus message. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that will contain the message. +** This will point to the first byte of the message header. +** The \c void* data type allows the calling routine to use +** any data type when declaring its message buffer. +** +** \param[in] MsgId The message ID to put in the message header. +** +** \param[in] Length The total number of bytes of message data, including the SB +** message header . +** +** \param[in] Clear A flag indicating whether to clear the rest of the message: +** \arg true - fill sequence count and packet data with zeroes. +** \arg false - leave sequence count and packet data unchanged. +**/ +void CFE_SB_InitMsg(void *MsgPtr, + CFE_SB_MsgId_t MsgId, + size_t Length, + bool Clear ); + +/*****************************************************************************/ +/** +** \brief DEPRECATED - Sets the message ID of a software bus message. +** \deprecated Use CFE_MSG_SetMsgId +** +** \par Description +** This routine sets the Message ID in a software bus message header. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] MsgId The message ID to put into the message header. +**/ +void CFE_SB_SetMsgId(CFE_MSG_Message_t *MsgPtr, + CFE_SB_MsgId_t MsgId); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/*****************************************************************************/ +/** +** \brief Sets the length of user data in a software bus message. +** +** \par Description +** This routine sets the field in the SB message header that determines +** the size of the user data in a software bus message. SB message header +** formats can be different for each deployment of the cFE. So, applications +** should use this function rather than trying to poke a length value directly +** into their SB message buffers. +** +** \par Assumptions, External Events, and Notes: +** - You must set a valid message ID in the SB message header before +** calling this function. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] DataLength The length to set (size of the user data, in bytes). +**/ +void CFE_SB_SetUserDataLength(CFE_MSG_Message_t *MsgPtr,size_t DataLength); + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/*****************************************************************************/ +/** +** \brief DEPRECATED: Sets the total length of a software bus message. +** \deprecated Use CFE_MSG_SetSize +** +** \par Description +** This routine sets the field in the SB message header that determines +** the total length of the message. SB message header formats can be +** different for each deployment of the cFE. So, applications should +** use this function rather than trying to poke a length value directly +** into their SB message buffers. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] TotalLength The length to set (total size of the message, in bytes, +** including headers). +**/ +void CFE_SB_SetTotalMsgLength(CFE_MSG_Message_t *MsgPtr,size_t TotalLength); + +/*****************************************************************************/ +/** +** \brief Sets the time field in a software bus message. +** \deprecated Use CFE_MSG_SetMsgTime +** +** \par Description +** This routine sets the time of a software bus message. Most applications +** will want to use #CFE_SB_TimeStampMsg instead of this function. But, +** when needed, this API can be used to send a group of SB messages +** with identical time stamps. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not include +** a time field, then this routine will do nothing to the message contents +** and will return #CFE_SB_WRONG_MSG_TYPE. +** - Note default implementation of command messages do not have a time field +** and will trigger the #CFE_SB_WRONG_MSG_TYPE error +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] Time The time to include in the message. This will usually be a time +** returned by the function #CFE_TIME_GetTime. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_WRONG_MSG_TYPE \copybrief CFE_SB_WRONG_MSG_TYPE +**/ +CFE_Status_t CFE_SB_SetMsgTime(CFE_MSG_Message_t *MsgPtr, CFE_TIME_SysTime_t Time); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + + +/*****************************************************************************/ +/** +** \brief Sets the time field in a software bus message with the current spacecraft time. +** +** \par Description +** This routine sets the time of a software bus message with the current +** spacecraft time. This will be the same time that is returned by the +** function #CFE_TIME_GetTime. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a time field, then this routine will do nothing. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +**/ +void CFE_SB_TimeStampMsg(CFE_MSG_Message_t *MsgPtr); + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/*****************************************************************************/ +/** +** \brief DEPRECATED:Sets the command code field in a software bus message. +** \deprecated Use CFE_MSG_SetFcnCode +** +** \par Description +** This routine sets the command code of a software bus message (if SB +** messages are implemented as CCSDS packets, this will be the function code). +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a command code field, then this routine will do nothing to +** the message contents and will return #CFE_SB_WRONG_MSG_TYPE. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \param[in] CmdCode The command code to include in the message. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_SB_WRONG_MSG_TYPE \copybrief CFE_SB_WRONG_MSG_TYPE +**/ +CFE_Status_t CFE_SB_SetCmdCode(CFE_MSG_Message_t *MsgPtr, uint16 CmdCode); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/******************************************************************************/ +/** +** \brief Copies a string into a software bus message +** +** \par Description +** Strings within software bus messages have a defined/fixed maximum length, and +** may not necessarily be null terminated within the message. This presents a possible +** issue when using the C library functions to copy strings out of a message. +** +** This performs a very similar function to "strncpy()" except that the sizes +** of _both_ buffers are passed in. Neither buffer is required to be null-terminated, +** but copying will stop after the first termination character is encountered. +** +** If the destination buffer is not completely filled by the source data (such as if +** the supplied string was shorter than the allotted length) the destination buffer +** will be padded with NUL characters up to the size of the buffer, similar to what +** strncpy() does. This ensures that the entire destination buffer is set. +** +** \note +** If the source string buffer is already guaranteed to be null terminated, +** then there is no difference between the C library "strncpy()" function and this +** implementation. It is only necessary to use this when termination of the source +** buffer is not guaranteed. +** +** \param[out] DestStringPtr Pointer to destination buffer (component of SB message definition) +** \param[in] SourceStringPtr Pointer to source buffer +** \param[in] DestMaxSize Size of destination buffer as defined by the message definition +** \param[in] SourceMaxSize Size of source buffer +** +** \return Number of characters copied or error code, see \ref CFEReturnCodes +** +*/ +int32 CFE_SB_MessageStringSet(char *DestStringPtr, const char *SourceStringPtr, size_t DestMaxSize, size_t SourceMaxSize); +/**@}*/ + +/** @defgroup CFEAPIGetMessage cFE Getting Message Characteristics APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Get a pointer to the user data portion of a software bus message. +** +** \par Description +** This routine returns a pointer to the user data portion of a software +** bus message. SB message header formats can be different for each +** deployment of the cFE. So, applications should use this function and +** avoid hard coding offsets into their SB message buffers. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** +** \return A pointer to the first byte of user data within the software bus message. +**/ +void *CFE_SB_GetUserData(CFE_MSG_Message_t *MsgPtr); + +#ifndef CFE_OMIT_DEPRECATED_6_8 + +/*****************************************************************************/ +/** +** \brief DEPRECATED:Get the message ID of a software bus message. +** \deprecated Use CFE_MSG_GetMsgId +** +** \par Description +** This routine returns the message ID from a software bus message. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** +** \return The software bus Message ID from the message header. +**/ +CFE_SB_MsgId_t CFE_SB_GetMsgId(const CFE_MSG_Message_t *MsgPtr); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/*****************************************************************************/ +/** +** \brief Gets the length of user data in a software bus message. +** +** \par Description +** This routine returns the size of the user data in a software bus message. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \return The size (in bytes) of the user data in the software bus message. +**/ +size_t CFE_SB_GetUserDataLength(const CFE_MSG_Message_t *MsgPtr); + +#ifndef CFE_OMIT_DEPRECATED_6_8 + +/*****************************************************************************/ +/** +** \brief DEPRECATED: Gets the total length of a software bus message. +** \deprecated Use CFE_MSG_GetSize +** +** \par Description +** This routine returns the total size of the software bus message. +** +** \par Assumptions, External Events, and Notes: +** - For the CCSDS implementation of this API, the size is derived from +** the message header. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \return The total size (in bytes) of the software bus message, including headers. +**/ +size_t CFE_SB_GetTotalMsgLength(const CFE_MSG_Message_t *MsgPtr); + +/*****************************************************************************/ +/** +** \brief DEPRECATED: Gets the command code field from a software bus message. +** \deprecated Use CFE_MSG_GetFcnCode +** +** \par Description +** This routine gets the command code from a software bus message (if +** SB messages are implemented as CCSDS packets, this will be the function +** code). +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a command code field, then this routine will return a zero. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \return The command code included in the software bus message header (if present). +** Otherwise, returns a command code value of zero. +**/ +uint16 CFE_SB_GetCmdCode(CFE_MSG_Message_t *MsgPtr); + +/*****************************************************************************/ +/** +** \brief DEPRECATED: Gets the time field from a software bus message. +** \deprecated Use CFE_MSG_GetMsgTime +** +** \par Description +** This routine gets the time from a software bus message. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a time field, then this routine will return a zero time. +** - Note default implementation of command messages do not have a time field. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \return The system time included in the software bus message header (if present), +** otherwise, returns a time value of zero. +**/ +CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_MSG_Message_t *MsgPtr); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/******************************************************************************/ +/** +** \brief Copies a string out of a software bus message +** +** \par Description +** Strings within software bus messages have a defined/fixed maximum length, and +** may not necessarily be null terminated within the message. This presents a possible +** issue when using the C library functions to copy strings out of a message. +** +** This function should replace use of C library functions such as strcpy/strncpy +** when copying strings out of software bus messages to local storage buffers. +** +** Up to [SourceMaxSize] or [DestMaxSize-1] (whichever is smaller) characters will be +** coped from the source buffer to the destination buffer, and a NUL termination +** character will be written to the destination buffer as the last character. +** +** If the DefaultString pointer is non-NULL, it will be used in place of the source +** string if the source is an empty string. This is typically a string constant that +** comes from the platform configuration, allowing default values to be assumed for +** fields that are unspecified. +** +** IMPORTANT - the default string, if specified, must be null terminated. This will +** be the case if a string literal is passed in (the typical/expected use case). +** +** If the default is NULL, then only the source string will be copied, and the result +** will be an empty string if the source was empty. +** +** If the destination buffer is too small to store the entire string, it will be +** truncated, but it will still be null terminated. +** +** \param[out] DestStringPtr Pointer to destination buffer +** \param[in] SourceStringPtr Pointer to source buffer (component of SB message definition) +** \param[in] DefaultString Default string to use if source is empty +** \param[in] DestMaxSize Size of destination storage buffer (must be at least 2) +** \param[in] SourceMaxSize Size of source buffer as defined by the message definition +** +** \return Number of characters copied or error code, see \ref CFEReturnCodes +** +*/ +int32 CFE_SB_MessageStringGet(char *DestStringPtr, const char *SourceStringPtr, const char *DefaultString, size_t DestMaxSize, size_t SourceMaxSize); +/**@}*/ + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/** @defgroup CFEAPISBChecksum cFE Checksum Control APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief DEPRECATED:Gets the checksum field from a software bus message. +** \deprecated No use case +** +** \par Description +** This routine gets the checksum (or other message integrity check +** value) from a software bus message. The contents and location of +** this field will depend on the underlying implementation of software +** bus messages. It may be a checksum, a CRC, or some other algorithm. +** Users should not call this function as part of a message integrity +** check (call #CFE_SB_ValidateChecksum instead). +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a checksum field, then this routine will return a zero. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \return The checksum included in the software bus message header (if present), otherwise, +** returns a checksum value of zero. +**/ +uint16 CFE_SB_GetChecksum(CFE_MSG_Message_t *MsgPtr); + +/*****************************************************************************/ +/** +** \brief DEPRECATED:Calculates and sets the checksum of a software bus message +** \deprecated Use CFE_MSG_GenerateChecksum +** +** \par Description +** This routine calculates the checksum of a software bus message according +** to an implementation-defined algorithm. Then, it sets the checksum field +** in the message with the calculated value. The contents and location of +** this field will depend on the underlying implementation of software bus +** messages. It may be a checksum, a CRC, or some other algorithm. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a checksum field, then this routine will do nothing. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +**/ +void CFE_SB_GenerateChecksum(CFE_MSG_Message_t *MsgPtr); + +/*****************************************************************************/ +/** +** \brief DEPRECATED:Validates the checksum of a software bus message. +** \deprecated Use CFE_MSG_ValidateChecksum +** +** \par Description +** This routine calculates the expected checksum of a software bus message +** according to an implementation-defined algorithm. Then, it checks the +** calculated value against the value in the message's checksum. If the +** checksums do not match, this routine will generate an event message +** reporting the error. +** +** \par Assumptions, External Events, and Notes: +** - If the underlying implementation of software bus messages does not +** include a checksum field this routine will always return false. +** +** \param[in] MsgPtr A pointer to the buffer that contains the software bus message. +** This must point to the first byte of the message header. +** +** \return Boolean checksum result +** \retval true The checksum field in the packet is valid. +** \retval false The checksum field in the packet is not valid or the message type is wrong. +**/ +bool CFE_SB_ValidateChecksum(CFE_MSG_Message_t *MsgPtr); +/**@}*/ +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/** @defgroup CFEAPISBMessageID cFE Message ID APIs + * @{ + */ + +/*****************************************************************************/ +/** + * \brief Identifies whether a given CFE_SB_MsgId_t is valid + * + * \par Description + * Implements a basic sanity check on the value provided + * + * \return Boolean message ID validity indicator + * \retval true Message ID is within the valid range + * \retval false Message ID is not within the valid range + */ +bool CFE_SB_IsValidMsgId(CFE_SB_MsgId_t MsgId); + + +/*****************************************************************************/ +/** + * \brief Identifies whether two #CFE_SB_MsgId_t values are equal + * + * \par Description + * In cases where the #CFE_SB_MsgId_t type is not a simple integer + * type, it may not be possible to do a direct equality check. + * This inline function provides an abstraction for the equality + * check between two #CFE_SB_MsgId_t values. + * + * Applications should transition to using this function to compare + * MsgId values for equality to remain compatible with future versions + * of cFE. + * + * \return Boolean message ID equality indicator + * \retval true Message IDs are Equal + * \retval false Message IDs are not Equal + */ +static inline bool CFE_SB_MsgId_Equal(CFE_SB_MsgId_t MsgId1, CFE_SB_MsgId_t MsgId2) +{ + return CFE_SB_MSGID_UNWRAP_VALUE(MsgId1) == CFE_SB_MSGID_UNWRAP_VALUE(MsgId2); +} + +/*****************************************************************************/ +/** + * \brief Converts a #CFE_SB_MsgId_t to a normal integer + * + * \par Description + * In cases where the #CFE_SB_MsgId_t type is not a simple integer + * type, it is not possible to directly display the value in a + * printf-style statement, use it in a switch() statement, or other + * similar use cases. + * + * This inline function provides the ability to map a #CFE_SB_MsgId_t + * type back into a simple integer value. + * + * Applications should transition to using this function wherever a + * #CFE_SB_MsgId_t type needs to be used as an integer. + * + * \par Assumptions and Notes: + * This negates the type safety that was gained by using a non- + * integer type for the #CFE_SB_MsgId_t value. This should only be used + * in specific cases such as UI display (printf, events, etc) where the + * value is being sent externally. Any internal API calls should be + * updated to use the #CFE_SB_MsgId_t type directly, rather than an + * integer type. + * + * \return Integer representation of the #CFE_SB_MsgId_t + */ +static inline CFE_SB_MsgId_Atom_t CFE_SB_MsgIdToValue(CFE_SB_MsgId_t MsgId) +{ + return CFE_SB_MSGID_UNWRAP_VALUE(MsgId); +} + +/*****************************************************************************/ +/** + * \brief Converts a normal integer into a #CFE_SB_MsgId_t + * + * \par Description + * In cases where the #CFE_SB_MsgId_t type is not a simple integer + * type, it is not possible to directly use an integer value + * supplied via a define or similar method. + * + * This inline function provides the ability to map an integer value + * into a corresponding #CFE_SB_MsgId_t value. + * + * Applications should transition to using this function wherever an + * integer needs to be used for a #CFE_SB_MsgId_t. + * + * \par Assumptions and Notes: + * This negates the type safety that was gained by using a non- + * integer type for the #CFE_SB_MsgId_t value. This should only be + * used in specific cases where the value is coming from an external + * source. Any internal API calls should be updated to return the + * #CFE_SB_MsgId_t type directly, rather than an integer type. + * + * \return #CFE_SB_MsgId_t representation of the integer + */ +static inline CFE_SB_MsgId_t CFE_SB_ValueToMsgId(CFE_SB_MsgId_Atom_t MsgIdValue) +{ + CFE_SB_MsgId_t Result = CFE_SB_MSGID_WRAP_VALUE(MsgIdValue); + return Result; +} + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/*****************************************************************************/ +/** + * \brief Identifies packet type given message ID + + * + * Provides the packet type associated with the given message ID + * + * \return Packet type + * \retval #CFE_MSG_Type_Cmd Command packet type + * \retval #CFE_MSG_Type_Tlm Telemetry packet type + * \retval #CFE_MSG_Type_Invalid Invalid/unknown packet type + */ +uint32 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId); +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/**@}*/ + + +/* + * The internal APIs prototyped within this block are only intended to be invoked from + * other CFE core apps. They still need to be prototyped in the shared header such that + * they can be called from other core modules, but applications should not call these. + */ +#ifdef _CFE_CORE_ + +/** @defgroup CFEAPISBCoreInternal cFE Internal Software Bus APIs, internal to CFE core + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE SB Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** +******************************************************************************/ +extern void CFE_SB_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_SB_EarlyInit(void); + + +/*****************************************************************************/ +/** +** \brief Removes SB resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees resources +** that have been allocated to the specified Application. +** +******************************************************************************/ +extern int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId); + + +/**@}*/ + +#endif /* _CFE_CORE_ */ + + + +#endif /* CFE_SB_API_H */ +/*****************************************************************************/ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_sb_api_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_sb_api_typedefs.h new file mode 100644 index 000000000..942931395 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_sb_api_typedefs.h @@ -0,0 +1,190 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/****************************************************************************** +** File: cfe_sb.h +** +** Purpose: +** This header file contains all definitions for the cFE Software Bus +** Application Programmer's Interface. +** +** Author: R.McGraw/SSI +** +******************************************************************************/ + +#ifndef CFE_SB_API_TYPEDEFS_H +#define CFE_SB_API_TYPEDEFS_H + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_sb_extern_typedefs.h" +#include "cfe_msg_api_typedefs.h" +#include "cfe_resourceid_api_typedefs.h" +#include "cfe_msg_hdr.h" + +/* +** Defines +*/ +#define CFE_SB_POLL 0 /**< \brief Option used with #CFE_SB_ReceiveBuffer to request immediate pipe status */ +#define CFE_SB_PEND_FOREVER -1 /**< \brief Option used with #CFE_SB_ReceiveBuffer to force a wait for next message */ +#define CFE_SB_SUBSCRIPTION 0 /**< \brief Subtype specifier used in #CFE_SB_SingleSubscriptionTlm_t by SBN App */ +#define CFE_SB_UNSUBSCRIPTION 1 /**< \brief Subtype specified used in #CFE_SB_SingleSubscriptionTlm_t by SBN App */ + +/* ------------------------------------------------------ */ +/* Macro Constants for use with the CFE_SB_MsgId_t type */ +/* ------------------------------------------------------ */ + +/** + * \brief Translation macro to convert from MsgId integer values to opaque/abstract API values + * + * This conversion exists in macro form to allow compile-time evaluation for constants, and + * should not be used directly in application code. + * + * For applications, use the CFE_SB_ValueToMsgId() inline function instead. + * + * \sa CFE_SB_ValueToMsgId() + */ +#define CFE_SB_MSGID_WRAP_VALUE(val) ((CFE_SB_MsgId_t)(val)) + +/** + * \brief Translation macro to convert to MsgId integer values from opaque/abstract API values + * + * This conversion exists in macro form to allow compile-time evaluation for constants, and + * should not be used directly in application code. + * + * For applications, use the CFE_SB_MsgIdToValue() inline function instead. + * + * \sa CFE_SB_MsgIdToValue() + */ +#define CFE_SB_MSGID_UNWRAP_VALUE(mid) ((CFE_SB_MsgId_Atom_t)(mid)) + +/** + * \brief Reserved value for CFE_SB_MsgId_t that will not match any valid MsgId + * + * This rvalue macro can be used for static/compile-time data initialization to ensure that + * the initialized value does not alias to a valid MsgId object. + */ +#define CFE_SB_MSGID_RESERVED CFE_SB_MSGID_WRAP_VALUE(-1) + +/** + * \brief A literal of the CFE_SB_MsgId_t type representing an invalid ID + * + * This value should be used for runtime initialization of CFE_SB_MsgId_t values. + * + * \note This may be a compound literal in a future revision. Per C99, compound + * literals are lvalues, not rvalues, so this value should not be used in + * static/compile-time data initialization. For static data initialization + * purposes (rvalue), #CFE_SB_MSGID_RESERVED should be used instead. + * However, in the current implementation, they are equivalent. + */ +#define CFE_SB_INVALID_MSG_ID CFE_SB_MSGID_RESERVED + +#ifndef CFE_OMIT_DEPRECATED_6_8 +/** + * \defgroup CFESBPktTypeDefs cFE SB Packet Type Defines + * \{ + */ +#define CFE_SB_PKTTYPE_INVALID CFE_MSG_Type_Invalid /**< \brief #CFE_SB_GetPktType response if message type can not be determined */ +#define CFE_SB_PKTTYPE_CMD CFE_MSG_Type_Cmd /**< \brief #CFE_SB_GetPktType response for command packets */ +#define CFE_SB_PKTTYPE_TLM CFE_MSG_Type_Tlm /**< \brief #CFE_SB_GetPktType response for telemetry packets */ +/** \} */ +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/** + * \brief Cast/Convert a generic CFE_ResourceId_t to a CFE_SB_PipeId_t + */ +#define CFE_SB_PIPEID_C(val) ((CFE_SB_PipeId_t)CFE_RESOURCEID_WRAP(val)) + + +/** + * \brief A CFE_SB_PipeId_t value which is always invalid + * + * This may be used as a safe initializer for CFE_SB_PipeId_t values + */ +#define CFE_SB_INVALID_PIPE CFE_SB_PIPEID_C(CFE_RESOURCEID_UNDEFINED) + +/* +** Pipe option bit fields. +*/ +#define CFE_SB_PIPEOPTS_IGNOREMINE 0x00000001 /**< \brief Messages sent by the app that owns this pipe will not be sent to this pipe. */ + + +#define CFE_SB_DEFAULT_QOS ((CFE_SB_Qos_t) {0}) /**< \brief Default Qos macro */ + + +/* +** Type Definitions +*/ + +/** \brief Software Bus generic message */ +typedef union CFE_SB_Msg { + CFE_MSG_Message_t Msg; /**< \brief Base message type without enforced alignment */ + long long int LongInt; /**< \brief Align to support Long Integer */ + long double LongDouble; /**< \brief Align to support Long Double */ +} CFE_SB_Buffer_t; + +#ifndef CFE_OMIT_DEPRECATED_6_8 + +/** \brief Deperecated type to minimize required changes */ +typedef CFE_SB_Buffer_t CFE_SB_Msg_t; + +/** \brief Deperecated type to minimize required changes */ +typedef CFE_MSG_CommandHeader_t CFE_SB_CmdHdr_t; + +/** \brief Deperecated type to minimize required changes */ +typedef CFE_MSG_TelemetryHeader_t CFE_SB_TlmHdr_t; + +#define CFE_SB_CMD_HDR_SIZE (sizeof(CFE_MSG_CommandHeader_t))/**< \brief Size of command header */ +#define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t))/**< \brief Size of telemetry header */ + +/** \brief Pointer to an SB Message */ +typedef CFE_MSG_Message_t *CFE_SB_MsgPtr_t; + +/** \brief CFE_SB_MsgPayloadPtr_t defined as an opaque pointer to a message Payload portion */ +typedef uint8 *CFE_SB_MsgPayloadPtr_t; + +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + +/** \brief CFE_SB_ZeroCopyHandle_t to primitive type definition +** +** Software Zero Copy handle used in many SB APIs +*/ +typedef struct +{ + struct CFE_SB_BufferD* BufDscPtr; /* abstract descriptor reference (internal use) */ +} CFE_SB_ZeroCopyHandle_t; + + +#ifndef CFE_OMIT_DEPRECATED_6_8 + +#define CFE_SB_Default_Qos CFE_SB_DEFAULT_QOS /**< \deprecated use CFE_SB_DEFAULT_QOS */ + +#define CFE_SB_CMD_HDR_SIZE (sizeof(CFE_MSG_CommandHeader_t))/**< \brief Size of command header */ +#define CFE_SB_TLM_HDR_SIZE (sizeof(CFE_MSG_TelemetryHeader_t))/**< \brief Size of telemetry header */ + +#endif /* CFE_OMIT_DEPRECATED_6_8 */ + + + + +#endif /* CFE_SB_API_TYPEDEFS_H */ +/*****************************************************************************/ diff --git a/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_sb_extern_typedefs.h similarity index 85% rename from fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h rename to modules/cfe_app_intf/fsw/inc/cfe_sb_extern_typedefs.h index ae0b7fb3a..9566073ae 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_extern_typedefs.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_sb_extern_typedefs.h @@ -26,7 +26,7 @@ #ifdef CFE_EDS_ENABLED_BUILD /* Use the EDS generated version of these types */ -#include "cfe_sb_eds_typedefs.h" +#include "cfe_sb_eds_api_typedefs.h" #else /* Use the local definitions of these types */ @@ -35,6 +35,9 @@ #include "cfe_mission_cfg.h" #include "cfe_resourceid_typedef.h" + +#define CFE_SB_SUB_ENTRIES_PER_PKT 20 /**< \brief Configuration parameter used by SBN App */ + /** * @brief Label definitions associated with CFE_SB_QosPriority_Enum_t */ @@ -119,6 +122,16 @@ typedef CFE_SB_MsgId_Atom_t CFE_SB_MsgId_t; */ typedef CFE_RESOURCEID_BASE_TYPE CFE_SB_PipeId_t; +/** \brief Quality Of Service Type Definition +** +** Currently an unused parameter in #CFE_SB_SubscribeEx +** Intended to be used for interprocessor communication only +**/ +typedef struct { + uint8 Priority;/**< \brief Specify high(1) or low(0) message priority for off-board routing, currently unused */ + uint8 Reliability;/**< \brief Specify high(1) or low(0) message transfer reliability for off-board routing, currently unused */ +}CFE_SB_Qos_t; + #endif /* CFE_EDS_ENABLED_BUILD */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_tbl.h b/modules/cfe_app_intf/fsw/inc/cfe_tbl.h new file mode 100644 index 000000000..0666ee627 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_tbl.h @@ -0,0 +1,796 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_tbl.h +** +** Title: Table Services API Application Library Header File +** +** Purpose: +** Unit specification for Table services library functions and macros. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** Notes: +** +**/ + +#ifndef CFE_TBL_API_H +#define CFE_TBL_API_H + +/********************* Include Files ************************/ +#include "common_types.h" /* Basic Data Types */ +#include "cfe_error.h" +#include "cfe_tbl_api_typedefs.h" +#include "cfe_sb_api_typedefs.h" + + +/*************************** Function Prototypes ******************************/ + +/** \defgroup CFEAPITBLRegistration cFE Registration APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Register a table with cFE to obtain Table Management Services +** +** \par Description +** When an application is created and initialized, it is responsible for creating its table images via +** the TBL API. The application must inform the Table Service of the table name, table size and selection +** of optional table features. +** +** \par Assumptions, External Events, and Notes: +** Note: This function call can block. Therefore, interrupt service routines should NOT create +** their own tables. An application should create any table(s) and provide the handle(s) +** to the interrupt service routine. +** +** \param[in, out] TblHandlePtr a pointer to a #CFE_TBL_Handle_t type variable that will be assigned the +** table's handle. The table handle is required for other API calls when +** accessing the data contained in the table. *TblHandlePtr is the handle used to identify table to cFE when performing Table operations. +** This value is returned at the address specified by TblHandlePtr. +** +** \param[in] Name The application-specific name. This name will be combined with the name of the +** application to produce a processor specific name of the form +** "ApplicationName.TableName". The processor specific name will be used in commands +** for modifying or viewing the contents of the table. +** +** \param[in] Size The size, in bytes, of the table to be created. This is the size that will be +** allocated as a shared memory resource between the Table Management Service and +** the calling application. +** +** \param[in] TblOptionFlags Flag bits indicating selected options for table. A bitwise OR of the following +** option flags: +** \arg #CFE_TBL_OPT_DEFAULT - The default setting for table options is a +** combination of #CFE_TBL_OPT_SNGL_BUFFER and +** #CFE_TBL_OPT_LOAD_DUMP. See below for a +** description of these two options. This option +** is mutually exclusive with the +** #CFE_TBL_OPT_DBL_BUFFER, #CFE_TBL_OPT_DUMP_ONLY +** and #CFE_TBL_OPT_USR_DEF_ADDR options. +** \arg #CFE_TBL_OPT_SNGL_BUFFER - When this option is selected, the table will use +** a shared session table for performing table +** modifications and a memory copy from the session +** table to the "active" table buffer will occur +** when the table is updated. This is the preferred +** option since it will minimize memory usage. +** This option is mutually exclusive with the +** #CFE_TBL_OPT_DBL_BUFFER option +** \arg #CFE_TBL_OPT_DBL_BUFFER - When this option is selected, two instances of +** the table are created. One is considered the +** "active" table and the other the "inactive" table. +** Whenever table modifications occur, they do not +** require the use of a common session table. +** Modifications occur in the "inactive" buffer. +** Then, when it is time to update the table, +** the pointer to the "active" table is changed to +** point to the "inactive" buffer thus making it +** the new "active" buffer. This feature is most +** useful for time critical applications (ie - +** interrupt service routines, etc). This option is +** mutually exclusive with the +** #CFE_TBL_OPT_SNGL_BUFFER and #CFE_TBL_OPT_DEFAULT +** option. +** \arg #CFE_TBL_OPT_LOAD_DUMP - When this option is selected, the Table Service +** is allowed to perform all operations on the +** specified table. This option is mutually +** exclusive with the #CFE_TBL_OPT_DUMP_ONLY option. +** \arg #CFE_TBL_OPT_DUMP_ONLY - When this option is selected, the Table Service +** will not perform table loads to this table. This +** does not prevent, however, a task from writing +** to the table via an address obtained with the +** #CFE_TBL_GetAddress API function. This option is +** mutually exclusive with the #CFE_TBL_OPT_LOAD_DUMP +** and #CFE_TBL_OPT_DEFAULT options. If the Application wishes +** to specify their own block of memory as the Dump Only table, +** they need to also include the #CFE_TBL_OPT_USR_DEF_ADDR option +** explained below. +** \arg #CFE_TBL_OPT_NOT_USR_DEF - When this option is selected, Table Services allocates +** memory for the table and, in the case of a double buffered +** table, it allocates the same amount of memory again for the +** second buffer. This option is mutually exclusive with +** the #CFE_TBL_OPT_USR_DEF_ADDR option. +** \arg #CFE_TBL_OPT_USR_DEF_ADDR- When this option is selected, the Table Service +** will not allocate memory for the table. Table Services +** will require the Application to identify the location of the +** active table buffer via the #CFE_TBL_Load function. This +** option implies the #CFE_TBL_OPT_DUMP_ONLY and the +** #CFE_TBL_OPT_SNGL_BUFFER options and is mutually +** exclusive of the #CFE_TBL_OPT_DBL_BUFFER option. +** \arg #CFE_TBL_OPT_CRITICAL- When this option is selected, the Table Service +** will automatically allocate space in the Critical Data Store (CDS) +** for the table and insure that the contents in the CDS are the same +** as the contents of the currently active buffer for the table. +** This option is mutually exclusive of the #CFE_TBL_OPT_USR_DEF_ADDR +** and #CFE_TBL_OPT_DUMP_ONLY options. It should also be noted that +** the use of this option with double buffered tables will prevent +** the update of the double buffered table from being quick and +** it could be blocked. Therefore, critical tables should not be +** updated by Interrupt Service Routines. +** +** \param[in] TblValidationFuncPtr is a pointer to a function that will be executed in the context of the Table +** Management Service when the contents of a table need to be validated. If set +** to NULL, then the Table Management Service will assume any data is valid. If +** the value is not NULL, it must be a pointer to a function with the following +** prototype:
+** int32 CallbackFunc(void *TblPtr);
+** where
+** TblPtr will be a pointer to the table data that is to be verified. When the +** function returns #CFE_SUCCESS, the data is considered valid and ready for a commit. +** When the function returns a negative value, the data is considered invalid and an +** Event Message will be issued containing the returned value. If the function should +** return a positive number, the table is considered invalid and the return code is +** considered invalid. Validation functions \b must return either #CFE_SUCCESS or a negative +** number (whose value is at the developer's discretion). The validation function +** will be executed in the Application's context so that Event Messages describing the +** validation failure are possible from within the function. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_RECOVERED_TBL \copybrief CFE_TBL_INFO_RECOVERED_TBL +** \retval #CFE_TBL_ERR_DUPLICATE_DIFF_SIZE \copybrief CFE_TBL_ERR_DUPLICATE_DIFF_SIZE +** \retval #CFE_TBL_ERR_DUPLICATE_NOT_OWNED \copybrief CFE_TBL_ERR_DUPLICATE_NOT_OWNED +** \retval #CFE_TBL_ERR_REGISTRY_FULL \copybrief CFE_TBL_ERR_REGISTRY_FULL +** \retval #CFE_TBL_ERR_HANDLES_FULL \copybrief CFE_TBL_ERR_HANDLES_FULL +** \retval #CFE_TBL_ERR_INVALID_SIZE \copybrief CFE_TBL_ERR_INVALID_SIZE +** \retval #CFE_TBL_ERR_INVALID_NAME \copybrief CFE_TBL_ERR_INVALID_NAME +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** +** \sa #CFE_TBL_Unregister, #CFE_TBL_Share +**/ +CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ + const char *Name, /* Application specific name */ + size_t Size, /* Size, in bytes, of table */ + uint16 TblOptionFlags, /* Tbl Options Settings */ + CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr); /* Ptr to func that validates tbl */ + +/*****************************************************************************/ +/** +** \brief Obtain handle of table registered by another application +** +** \par Description +** After a table has been created, other applications can gain access +** to that table via the table handle. In order for two or more +** applications to share a table, the applications that do not create +** the table must obtain the handle using this function. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in, out] TblHandlePtr A pointer to a #CFE_TBL_Handle_t type variable +** that will be assigned the table's handle. The +** table handle is required for other API calls +** when accessing the data contained in the table. *TblHandlePtr is the handle used to identify table to cFE when performing Table operations. +** This value is returned at the address specified by TblHandlePtr. +** +** \param[in] TblName The processor specific name of the table. It is important to note +** that the processor specific table name is different from the table +** name specified in the #CFE_TBL_Register API call. The processor +** specific table name includes the name of the application that created +** the table. The name would be of the form "ApplicationName.TableName". +** An example of this would be "ACS.TamParams" for a table called "TamParams" +** that was registered by the application called "ACS". +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_ERR_HANDLES_FULL \copybrief CFE_TBL_ERR_HANDLES_FULL +** \retval #CFE_TBL_ERR_INVALID_NAME \copybrief CFE_TBL_ERR_INVALID_NAME +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** +** \sa #CFE_TBL_Unregister, #CFE_TBL_Register +** +******************************************************************************/ +CFE_Status_t CFE_TBL_Share(CFE_TBL_Handle_t *TblHandlePtr, const char *TblName); + +/*****************************************************************************/ +/** +** \brief Unregister a previously registered table and free associated resources +** +** \par Description +** When an application is being removed from the system, it should +** unregister those tables that it created. The application should +** call this function as a part of its cleanup process. The table +** will be removed from memory once all table addresses referencing +** it have been released. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, +** that identifies the Table to be unregistered. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \sa #CFE_TBL_Share, #CFE_TBL_Register +** +******************************************************************************/ +CFE_Status_t CFE_TBL_Unregister (CFE_TBL_Handle_t TblHandle); +/**@}*/ + +/** @defgroup CFEAPITBLManage cFE Manage Table Content APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Load a specified table with data from specified source +** +** \par Description +** Once an application has created a table (#CFE_TBL_Register), it must +** provide the values that initialize the contents of that table. The +** application accomplishes this with one of two different TBL API calls. +** This function call initializes the table with values that are held +** in a data structure. +** +** \par Assumptions, External Events, and Notes: +** This function call can block. Therefore, interrupt service routines +** should NOT initialize their own tables. An application should initialize +** any table(s) prior to providing the handle(s) to the interrupt service routine. +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be loaded. +** +** \param[in] SrcType Flag indicating the nature of the given \c SrcDataPtr below. +** This value can be any one of the following: +** \arg #CFE_TBL_SRC_FILE - \copybrief CFE_TBL_SRC_FILE +** \arg #CFE_TBL_SRC_ADDRESS - \copybrief CFE_TBL_SRC_ADDRESS +** +** \param[in] SrcDataPtr Pointer to either a character string specifying a filename or +** a memory address of a block of binary data to be loaded into a table or, +** if the table was registered with the #CFE_TBL_OPT_USR_DEF_ADDR option, +** the address of the active table buffer. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_WARN_SHORT_FILE \copybrief CFE_TBL_WARN_SHORT_FILE +** \retval #CFE_TBL_WARN_PARTIAL_LOAD \copybrief CFE_TBL_WARN_PARTIAL_LOAD +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_DUMP_ONLY \copybrief CFE_TBL_ERR_DUMP_ONLY +** \retval #CFE_TBL_ERR_ILLEGAL_SRC_TYPE \copybrief CFE_TBL_ERR_ILLEGAL_SRC_TYPE +** \retval #CFE_TBL_ERR_LOAD_IN_PROGRESS \copybrief CFE_TBL_ERR_LOAD_IN_PROGRESS +** \retval #CFE_TBL_ERR_NO_BUFFER_AVAIL \copybrief CFE_TBL_ERR_NO_BUFFER_AVAIL +** \retval #CFE_TBL_ERR_FILE_NOT_FOUND \copybrief CFE_TBL_ERR_FILE_NOT_FOUND +** \retval #CFE_TBL_ERR_FILE_TOO_LARGE \copybrief CFE_TBL_ERR_FILE_TOO_LARGE +** \retval #CFE_TBL_ERR_BAD_CONTENT_ID \copybrief CFE_TBL_ERR_BAD_CONTENT_ID +** \retval #CFE_TBL_ERR_PARTIAL_LOAD \copybrief CFE_TBL_ERR_PARTIAL_LOAD +** +** \sa #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_Manage +** +******************************************************************************/ +CFE_Status_t CFE_TBL_Load(CFE_TBL_Handle_t TblHandle, CFE_TBL_SrcEnum_t SrcType, const void *SrcDataPtr); + +/*****************************************************************************/ +/** +** \brief Update contents of a specified table, if an update is pending +** +** \par Description +** An application is \b required to perform a periodic check for an update +** for all the tables that it creates. Typically, the application that +** created the table would call this function at the start or conclusion +** of any routine processing cycle or at regular intervals. To determine +** whether an update is pending prior to making this call, the Application +** can use the #CFE_TBL_GetStatus API first. If a table update is pending, +** it will take place during this function call. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be updated. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_NO_UPDATE_PENDING \copybrief CFE_TBL_INFO_NO_UPDATE_PENDING +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \sa #CFE_TBL_Load, #CFE_TBL_Validate, #CFE_TBL_Manage +** +******************************************************************************/ +CFE_Status_t CFE_TBL_Update(CFE_TBL_Handle_t TblHandle); + +/*****************************************************************************/ +/** +** \brief Perform steps to validate the contents of a table image. +** +** \par Description +** An application is \b required to perform a periodic check for an update +** or a validation request for all the tables that it creates. Typically, +** the application that created the table would call this function at the +** start or conclusion of any routine processing cycle. To determine whether +** a validation request is pending prior to making this call, the Application +** can use the #CFE_TBL_GetStatus API first. If a table validation is pending, +** the Application would call this function to perform the necessary actions. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be managed. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_NO_VALIDATION_PENDING \copybrief CFE_TBL_INFO_NO_VALIDATION_PENDING +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \sa #CFE_TBL_Update, #CFE_TBL_Manage, #CFE_TBL_Load +** +******************************************************************************/ +CFE_Status_t CFE_TBL_Validate(CFE_TBL_Handle_t TblHandle); + +/*****************************************************************************/ +/** +** \brief Perform standard operations to maintain a table. +** +** \par Description +** An application is \b required to perform a periodic check for an update +** or a validation request for all the tables that it creates. Typically, +** the application that created the table would call this function at the +** start or conclusion of any routine processing cycle. If a table update +** or validation request is pending, this function would perform either or +** both before returning. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be managed. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \sa #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_Load, #CFE_TBL_DumpToBuffer +** +******************************************************************************/ +CFE_Status_t CFE_TBL_Manage(CFE_TBL_Handle_t TblHandle); + +/*****************************************************************************/ +/** +** \brief Copies the contents of a Dump Only Table to a shared buffer +** +** \par Description +** Copies contents of a Dump Only table to a shared buffer so that it +** can be written to a file by the Table Services routine. This function +** is called by the Application that owns the table in response to a #CFE_TBL_INFO_DUMP_PENDING +** status obtained via #CFE_TBL_GetStatus. +** +** \par Assumptions, External Events, and Notes: +** -# If the table does not have a dump pending status, nothing will occur (no error, no dump) +** -# Applications may wish to use this function in lieu of #CFE_TBL_Manage for their Dump Only tables +** +** \param[in] TblHandle Handle of Table to be dumped. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \sa #CFE_TBL_Manage +** +******************************************************************************/ +CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle); + +/*****************************************************************************/ +/** +** \brief Notify cFE Table Services that table contents have been modified by the Application +** +** \par Description +** This API notifies Table Services that the contents of the specified table has been +** modified by the Application. This notification is important when a table has been +** registered as "Critical" because Table Services can then update the contents of the +** table kept in the Critical Data Store. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle of Table that was modified. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \sa #CFE_TBL_Manage +** +******************************************************************************/ +CFE_Status_t CFE_TBL_Modified(CFE_TBL_Handle_t TblHandle); +/**@}*/ + +/** @defgroup CFEAPITBLAccess cFE Access Table Content APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Obtain the current address of the contents of the specified table +** +** \par Description +** When a table has been created and initialized, it is available to +** any application that can identify it with its unique handle. In +** order to view the data contained in the table, an application must +** call this function or #CFE_TBL_GetAddresses. +** +** \par Assumptions, External Events, and Notes: +** -# This call can be a blocking call when the table is not double buffered +** and is shared with another application of lower priority that just happens +** to be in the middle of a table update of the specific table. If this occurs, +** the application performing the table update will automatically have its +** priority elevated in order to release the resource as soon as possible. +** -# An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress or #CFE_TBL_ReleaseAddresses function prior to +** either a #CFE_TBL_Update call or any blocking call (e.g. - pending on software +** bus message, etc). Table updates cannot occur while table addresses have not +** been released. +** -# #CFE_TBL_ERR_NEVER_LOADED will be returned if the table has never been +** loaded (either from file or from a block of memory), but the function +** will still return a valid table pointer to a table with all zero content. +** This pointer mush be released with the #CFE_TBL_ReleaseAddress API before +** the table can be loaded with data. +** +** \param[in, out] TblPtr The address of a pointer that will be loaded with the address of +** the first byte of the table. This pointer can then be typecast +** by the calling application to the appropriate table data structure. *TblPtr is the address of the first byte of data associated with the specified table. +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table whose address is to be returned. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_UNREGISTERED \copybrief CFE_TBL_ERR_UNREGISTERED +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** +** \sa #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses +** +******************************************************************************/ +CFE_Status_t CFE_TBL_GetAddress(void **TblPtr, CFE_TBL_Handle_t TblHandle); + +/*****************************************************************************/ +/** +** \brief Release previously obtained pointer to the contents of the specified table +** +** \par Description +** Each application is \b required to release a table address obtained through +** the #CFE_TBL_GetAddress function. +** +** \par Assumptions, External Events, and Notes: +** An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress function prior to either a #CFE_TBL_Update call +** or any blocking call (e.g. - pending on software bus message, etc). +** Table updates cannot occur while table addresses have not been released. +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table whose address is to be released. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** +** \sa #CFE_TBL_GetAddress, #CFE_TBL_GetAddresses, #CFE_TBL_ReleaseAddresses +** +******************************************************************************/ +CFE_Status_t CFE_TBL_ReleaseAddress(CFE_TBL_Handle_t TblHandle); + +/*****************************************************************************/ +/** +** \brief Obtain the current addresses of an array of specified tables +** +** \par Description +** When a table has been created and initialized, it is available to +** any application that can identify it with its unique handle. In +** order to view the data contained in the table, an application must +** call this function or #CFE_TBL_GetAddresses. +** +** \par Assumptions, External Events, and Notes: +** -# This call can be a blocking call when the table is not double buffered +** and is shared with another application of lower priority that just happens +** to be in the middle of a table update of the specific table. If this occurs, +** the application performing the table update will automatically have its +** priority elevated in order to release the resource as soon as possible. +** -# An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress or #CFE_TBL_ReleaseAddresses function prior to +** either a #CFE_TBL_Update call or any blocking call (e.g. - pending on software +** bus message, etc). Table updates cannot occur while table addresses have not +** been released. +** -# #CFE_TBL_ERR_NEVER_LOADED will be returned if the table has never been +** loaded (either from file or from a block of memory), but the function +** will still return a valid table pointer to a table with all zero content. +** This pointer mush be released with the #CFE_TBL_ReleaseAddress API before +** the table can be loaded with data. +** +** \param[in, out] TblPtrs Array of Pointers to variables that calling Application +** wishes to hold the start addresses of the Tables. *TblPtrs is an array of addresses of the first byte of data associated with the +** specified tables. +** +** \param[in] NumTables Size of TblPtrs and TblHandles arrays. +** +** \param[in] TblHandles Array of Table Handles, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, +** of those tables whose start addresses are to be obtained. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_UNREGISTERED \copybrief CFE_TBL_ERR_UNREGISTERED +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** +** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_ReleaseAddresses +** +******************************************************************************/ +CFE_Status_t CFE_TBL_GetAddresses(void **TblPtrs[], uint16 NumTables, const CFE_TBL_Handle_t TblHandles[]); + +/*****************************************************************************/ +/** +** \brief Release the addresses of an array of specified tables +** +** \par Description +** Each application is \b required to release a table address obtained through +** the #CFE_TBL_GetAddress function. +** +** \par Assumptions, External Events, and Notes: +** An application must always release the returned table address using the +** #CFE_TBL_ReleaseAddress function prior to either a #CFE_TBL_Update call +** or any blocking call (e.g. - pending on software bus message, etc). +** Table updates cannot occur while table addresses have not been released. +** +** \param[in] NumTables Size of TblHandles array. +** +** \param[in] TblHandles Array of Table Handles, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, +** of those tables whose start addresses are to be released. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATED \copybrief CFE_TBL_INFO_UPDATED +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** \retval #CFE_TBL_ERR_NEVER_LOADED \copybrief CFE_TBL_ERR_NEVER_LOADED +** +** \sa #CFE_TBL_GetAddress, #CFE_TBL_ReleaseAddress, #CFE_TBL_GetAddresses +** +******************************************************************************/ +CFE_Status_t CFE_TBL_ReleaseAddresses(uint16 NumTables, const CFE_TBL_Handle_t TblHandles[]); +/**@}*/ + +/** @defgroup CFEAPITBLInfo cFE Get Table Information APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Obtain current status of pending actions for a table. +** +** \par Description +** An application is \b required to perform a periodic check for an update +** or a validation request for all the tables that it creates. Typically, +** the application that created the table would call this function at the +** start or conclusion of any routine processing cycle. If a table update +** or validation request is pending, the Application should follow up with +** a call to #CFE_TBL_Update or #CFE_TBL_Validate respectively. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TblHandle Handle, previously obtained from #CFE_TBL_Register or #CFE_TBL_Share, that +** identifies the Table to be managed. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_INFO_UPDATE_PENDING \copybrief CFE_TBL_INFO_UPDATE_PENDING +** \retval #CFE_TBL_INFO_VALIDATION_PENDING \copybrief CFE_TBL_INFO_VALIDATION_PENDING +** \retval #CFE_TBL_INFO_DUMP_PENDING \copybrief CFE_TBL_INFO_DUMP_PENDING +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \note Some status return codes are "success" while being non-zero. This +** behavior will change in the future. +** +** \sa #CFE_TBL_Manage, #CFE_TBL_Update, #CFE_TBL_Validate, #CFE_TBL_GetInfo +** +******************************************************************************/ +CFE_Status_t CFE_TBL_GetStatus(CFE_TBL_Handle_t TblHandle); + +/*****************************************************************************/ +/** +** \brief Obtain characteristics/information of/about a specified table. +** +** \par Description +** This API provides the registry information associated with the specified +** table. The function fills the given data structure with the data found +** in the Table Registry. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in, out] TblInfoPtr A pointer to a CFE_TBL_Info_t data structure that is to be populated +** with table characteristics and information. *TblInfoPtr is the description of the tables characteristics and registry information stored in +** the #CFE_TBL_Info_t data structure format. +** +** \param[in] TblName The processor specific name of the table. It is important to note +** that the processor specific table name is different from the table +** name specified in the #CFE_TBL_Register API call. The processor +** specific table name includes the name of the application that created +** the table. The name would be of the form "ApplicationName.TableName". +** An example of this would be "ACS.TamParams" for a table called "TamParams" +** that was registered by the application called "ACS". +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_ERR_INVALID_NAME \copybrief CFE_TBL_ERR_INVALID_NAME +** +** \sa #CFE_TBL_GetStatus +** +******************************************************************************/ +CFE_Status_t CFE_TBL_GetInfo(CFE_TBL_Info_t *TblInfoPtr, const char *TblName); + +/*****************************************************************************/ +/** +** \brief Instruct cFE Table Services to notify Application via message when table requires management +** +** \par Description +** This API instructs Table Services to send a message to the calling Application +** whenever the specified table requires management by the application. This feature +** allows applications to avoid polling table services via the #CFE_TBL_Manage call +** to determine whether a table requires updates, validation, etc. This API should +** be called following the #CFE_TBL_Register API whenever the owning application requires +** this feature. +** +** \par Assumptions, External Events, and Notes: +** - Only the application that owns the table is allowed to register a notification message +** - Recommend \b NOT using the ground command MID which typically impacts command counters. +** The typical approach is to use a unique MID for inter-task communications +** similar to how schedulers typically trigger application housekeeping messages. +** +** \param[in] TblHandle Handle of Table with which the message should be associated. +** +** \param[in] MsgId Message ID to be used in notification message sent by Table Services. +** +** \param[in] CommandCode Command Code value to be placed in secondary header of message +** sent by Table Services. +** +** \param[in] Parameter Application defined value to be passed as a parameter in the +** message sent by Table Services. Suggested use includes an application's +** table index that allows the same MsgId and Command Code to be used for +** all table management notifications. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TBL_ERR_BAD_APP_ID \copybrief CFE_TBL_ERR_BAD_APP_ID +** \retval #CFE_TBL_ERR_NO_ACCESS \copybrief CFE_TBL_ERR_NO_ACCESS +** \retval #CFE_TBL_ERR_INVALID_HANDLE \copybrief CFE_TBL_ERR_INVALID_HANDLE +** +** \sa #CFE_TBL_Register +** +******************************************************************************/ +CFE_Status_t CFE_TBL_NotifyByMessage(CFE_TBL_Handle_t TblHandle, CFE_SB_MsgId_t MsgId, CFE_MSG_FcnCode_t CommandCode, uint32 Parameter); +/**@}*/ + + +/* + * The internal APIs prototyped within this block are only intended to be invoked from + * other CFE core apps. They still need to be prototyped in the shared header such that + * they can be called from other core modules, but applications should not call these. + */ +#ifdef _CFE_CORE_ + +/** @defgroup CFEAPITBLCoreInternal cFE Internal Table Service APIs, internal to CFE core + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Table Services Core Application +** +** \par Description +** This is the entry point to the cFE Table Services Core Application. +** This Application provides the ground interface to the cFE Table +** Services. +** +** \par Assumptions, External Events, and Notes: +** None +** +** +******************************************************************************/ +extern void CFE_TBL_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Initializes the Table Services API Library +** +** \par Description +** Initializes the Table Services API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any TBL API's are called. +** +******************************************************************************/ +extern int32 CFE_TBL_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Removes TBL resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees TBL services resources +** that have been allocated to the specified Application. +** +** \par Assumptions, External Events, and Notes: +** -# This function DOES NOT remove any critical tables associated with +** the specified application from the Critical Data Store. +** +******************************************************************************/ +extern int32 CFE_TBL_CleanUpApp(CFE_ES_AppId_t AppId); + + +/**@}*/ + +#endif /* _CFE_CORE_ */ + + +#endif /* CFE_TBL_API_H */ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_tbl_api_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_tbl_api_typedefs.h new file mode 100644 index 000000000..6707c6791 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_tbl_api_typedefs.h @@ -0,0 +1,127 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_tbl.h +** +** Title: Table Services API Application Library Header File +** +** Purpose: +** Unit specification for Table services library functions and macros. +** +** Design Notes: +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** +** Notes: +** +**/ + +#ifndef CFE_TBL_ABSTRACT_TYPES_H +#define CFE_TBL_ABSTRACT_TYPES_H + +/********************* Include Files ************************/ +#include "common_types.h" /* Basic Data Types */ +#include "cfe_tbl_extern_typedefs.h" +#include "cfe_time_extern_typedefs.h" + +/** @defgroup CFETBLTypeOptions cFE Table Type Defines + * @{ + */ +#define CFE_TBL_OPT_BUFFER_MSK (0x0001) /**< \brief Table buffer mask */ +#define CFE_TBL_OPT_SNGL_BUFFER (0x0000) /**< \brief Single buffer table */ +#define CFE_TBL_OPT_DBL_BUFFER (0x0001) /**< \brief Double buffer table */ + +#define CFE_TBL_OPT_LD_DMP_MSK (0x0002) /**< \brief Table load/dump mask */ +#define CFE_TBL_OPT_LOAD_DUMP (0x0000) /**< \brief Load/Dump table */ +#define CFE_TBL_OPT_DUMP_ONLY (0x0002) /**< \brief Dump only table */ + +#define CFE_TBL_OPT_USR_DEF_MSK (0x0004) /**< \brief Table user defined mask */ +#define CFE_TBL_OPT_NOT_USR_DEF (0x0000) /**< \brief Not user defined table */ +#define CFE_TBL_OPT_USR_DEF_ADDR (0x0006) /**< \brief User Defined table, @note Automatically includes #CFE_TBL_OPT_DUMP_ONLY option */ + +#define CFE_TBL_OPT_CRITICAL_MSK (0x0008) /**< \brief Table critical mask */ +#define CFE_TBL_OPT_NOT_CRITICAL (0x0000) /**< \brief Not critical table */ +#define CFE_TBL_OPT_CRITICAL (0x0008) /**< \brief Critical table */ + +/** @brief Default table options */ +#define CFE_TBL_OPT_DEFAULT (CFE_TBL_OPT_SNGL_BUFFER | CFE_TBL_OPT_LOAD_DUMP) +/**@}*/ + +/** + * \brief Table maximum full name length + * + * The full length of table names is defined at the mission scope. + * This is defined here to support applications that depend on cfe_tbl.h + * providing this value. + */ +#define CFE_TBL_MAX_FULL_NAME_LEN (CFE_MISSION_TBL_MAX_FULL_NAME_LEN) + +/** \brief Bad table handle */ +#define CFE_TBL_BAD_TABLE_HANDLE (CFE_TBL_Handle_t) 0xFFFF + + +/****************** Data Type Definitions *********************/ + +/** \brief Table Callback Function */ +typedef int32 (*CFE_TBL_CallbackFuncPtr_t)(void *TblPtr); + +/** \brief Table Handle primitive */ +typedef int16 CFE_TBL_Handle_t; + +/** \brief Table Source */ +typedef enum CFE_TBL_SrcEnum +{ + CFE_TBL_SRC_FILE = 0, /**< \brief File source + When this option is selected, the \c SrcDataPtr + will be interpreted as a pointer to a null + terminated character string. The string should + specify the full path and filename of the file + containing the initial data contents of the table. */ + CFE_TBL_SRC_ADDRESS /**< \brief Address source + When this option is selected, the \c SrcDataPtr will + be interpreted as a pointer to a memory location + that is the beginning of the initialization data + for loading the table OR, in the case of a "user defined" + dump only table, the address of the active table itself. + The block of memory is assumed to be of the same size + specified in the #CFE_TBL_Register function Size parameter. */ +} CFE_TBL_SrcEnum_t; + +/** \brief Table Info */ +typedef struct CFE_TBL_Info +{ + size_t Size; /**< \brief Size, in bytes, of Table */ + uint32 NumUsers; /**< \brief Number of Apps with access to the table */ + uint32 FileCreateTimeSecs; /**< \brief File creation time from last file loaded into table */ + uint32 FileCreateTimeSubSecs; /**< \brief File creation time from last file loaded into table */ + uint32 Crc; /**< \brief Most recently calculated CRC by TBL services on table contents */ + CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */ + bool TableLoadedOnce; /**< \brief Flag indicating whether table has been loaded once or not */ + bool DumpOnly; /**< \brief Flag indicating Table is NOT to be loaded */ + bool DoubleBuffered; /**< \brief Flag indicating Table has a dedicated inactive buffer */ + bool UserDefAddr; /**< \brief Flag indicating Table address was defined by Owner Application */ + bool Critical; /**< \brief Flag indicating Table contents are maintained in a CDS */ + char LastFileLoaded[CFE_MISSION_MAX_PATH_LEN]; /**< \brief Filename of last file loaded into table */ +} CFE_TBL_Info_t; + + +#endif /* CFE_TBL_ABSTRACT_TYPES_H */ diff --git a/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_tbl_extern_typedefs.h similarity index 96% rename from fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h rename to modules/cfe_app_intf/fsw/inc/cfe_tbl_extern_typedefs.h index 10c05fa7b..bf3204de3 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_tbl_extern_typedefs.h @@ -26,14 +26,14 @@ #ifdef CFE_EDS_ENABLED_BUILD /* Use the EDS generated version of these types */ -#include "cfe_tbl_eds_typedefs.h" +#include "cfe_tbl_eds_api_typedefs.h" #else /* Use the local definitions of these types */ #include "common_types.h" #include "cfe_es_extern_typedefs.h" -#include /* for CFE_MISSION_TBL_MAX_FULL_NAME_LEN */ +#include "cfe_mission_cfg.h" /* for CFE_MISSION_TBL_MAX_FULL_NAME_LEN */ /** * @brief Label definitions associated with CFE_TBL_BufferSelect_Enum_t diff --git a/fsw/cfe-core/src/inc/cfe_tbl_filedef.h b/modules/cfe_app_intf/fsw/inc/cfe_tbl_filedef.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_tbl_filedef.h rename to modules/cfe_app_intf/fsw/inc/cfe_tbl_filedef.h diff --git a/modules/cfe_app_intf/fsw/inc/cfe_time.h b/modules/cfe_app_intf/fsw/inc/cfe_time.h new file mode 100644 index 000000000..a74f66d67 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_time.h @@ -0,0 +1,788 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_time.h +** +** Purpose: cFE Time Services (TIME) library API header file +** +** Author: S.Walling/Microtel +** +** Notes: +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef _cfe_time_ +#define _cfe_time_ + + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_error.h" +#include "cfe_time_api_typedefs.h" +#include "cfe_es_api_typedefs.h" + + +/** +** \brief Time Copy +** +** Macro to copy systime into another systime. +** Preferred to use this macro as it does not require the two arguments to be exactly the same type, +** it will work with any two structures that define "Seconds" and "Subseconds" members. +*/ +#define CFE_TIME_Copy(m,t) { (m)->Seconds = (t)->Seconds; (m)->Subseconds = (t)->Subseconds; } + + +/*****************************************************************************/ +/* +** Exported Functions +*/ + +/** @defgroup CFEAPITIMEGetCurrent cFE Get Current Time APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Get the current spacecraft time +** +** \par Description +** This routine returns the current spacecraft time. The time returned +** is either TAI (no leap seconds) or UTC (including leap seconds). This choice +** is made in the mission configuration file by defining either #CFE_MISSION_TIME_CFG_DEFAULT_TAI +** or #CFE_MISSION_TIME_CFG_DEFAULT_UTC as true at compile time. To maintain re-usability +** across missions, most applications should be using this function +** (or #CFE_TIME_GetTime) rather than the specific routines for getting UTC/TAI directly. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return The current spacecraft time in default format +** +** \sa #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetTime(void); + +/*****************************************************************************/ +/** +** \brief Get the current TAI (MET + SCTF) time +** +** \par Description +** This routine returns the current TAI time to the caller. TAI is an +** international time standard that does not include leap seconds. +** This routine should only be used in situations where TAI is absolutely +** required. Applications that call #CFE_TIME_GetTAI may not be portable +** to all missions. Maintenance of correct TAI in flight is not guaranteed +** under all mission operations scenarios. To maintain re-usability across +** missions, most applications should be using #CFE_TIME_GetTime, rather +** than the specific routines for getting UTC/TAI directly. +** +** \par Assumptions, External Events, and Notes: +** -# The "TAI" time returned is referenced to the mission-defined time epoch, +** which may or may not be the same as the standard TAI epoch. +** -# Even though TAI does not include leap seconds, the time returned by this +** function can still jump forward or backward without warning when the +** spacecraft clock is set or adjusted by operators. Applications using +** this function must be able to handle these time discontinuities gracefully. +** +** \return The current spacecraft time in TAI +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetTAI(void); + +/*****************************************************************************/ +/** +** \brief Get the current UTC (MET + SCTF - Leap Seconds) time +** +** \par Description +** This routine returns the current UTC time to the caller. This routine +** should only be used in situations where UTC is absolutely required. +** Applications that call #CFE_TIME_GetUTC may not be portable to all +** missions. Maintenance of correct UTC in flight is not guaranteed under +** all mission operations scenarios. If UTC is maintained in flight, it will +** jump backwards occasionally due to leap second adjustments. To maintain +** re-usability across missions, most applications should be using +** #CFE_TIME_GetTime, rather than the specific routines for getting +** UTC/TAI directly. +** +** \par Assumptions, External Events, and Notes: +** Note: The "UTC" time returned is referenced to the mission-defined time epoch, +** which may or may not be the same as the standard UTC epoch. +** +** \return The current spacecraft time in UTC +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetUTC(void); + +/*****************************************************************************/ +/** +** \brief Get the current value of the Mission Elapsed Time (MET). +** +** \par Description +** This routine returns the current mission-elapsed time (MET). MET is +** usually derived from a hardware-based clock that is not adjusted +** during normal operations. Callers of this routine should not assume +** that the MET return value has any specific relationship to any +** ground-based time standard. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return The current MET +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, +** #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs, #CFE_TIME_MET2SCTime +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetMET(void); + +/*****************************************************************************/ +/** +** \brief Get the current seconds count of the mission-elapsed time. +** +** \par Description +** This routine is the same as #CFE_TIME_GetMET, except that it +** returns only the integer seconds portion of the MET time. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return The current MET seconds +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETsubsecs, #CFE_TIME_MET2SCTime +** +******************************************************************************/ +uint32 CFE_TIME_GetMETseconds(void); + +/*****************************************************************************/ +/** +** \brief Get the current sub-seconds count of the mission-elapsed time. +** +** \par Description +** This routine is the same as #CFE_TIME_GetMET, except that it +** returns only the integer sub-seconds portion of the MET time. +** Each count is equal to 2^(-32) seconds. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return The current MET sub-seconds +** +** \sa #CFE_TIME_GetTime, #CFE_TIME_GetTAI, #CFE_TIME_GetUTC, #CFE_TIME_GetMET, +** #CFE_TIME_GetMETseconds, #CFE_TIME_MET2SCTime +** +******************************************************************************/ +uint32 CFE_TIME_GetMETsubsecs(void); +/**@}*/ + +/** @defgroup CFEAPITIMEGetInfo cFE Get Time Information APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Get the current value of the spacecraft time correction factor (STCF). +** +** \par Description +** This routine returns the current value of the spacecraft time correction +** factor. This is the delta time between the MET and the TAI time. +** Applications cannot set or adjust the STCF; that can only be done +** through ground commands. However, science applications may want to +** include the STCF in their data products to aid in time correlation +** during downstream science data processing. +** +** \par Assumptions, External Events, and Notes: +** Does not include leap seconds +** +** \return The current SCTF +** +** \sa #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockState, #CFE_TIME_GetClockInfo +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_GetSTCF(void); + +/*****************************************************************************/ +/** +** \brief Get the current value of the leap seconds counter. +** +** \par Description +** This routine returns the current value of the leap seconds counter. +** This is the delta seconds between international atomic time (TAI) +** and universal coordinated time (UTC). Applications cannot set or +** adjust the leap seconds; that can only be done through ground commands. +** However, science applications may want to include the leap seconds +** counter in their data products to aid in time correlation during +** downstream science data processing. Note that some mission operations +** teams do not maintain the leap seconds count, preferring to adjust the +** STCF instead. Users of this function should check with their mission +** ops team to see how they are planning to handle leap seconds. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns The current spacecraft leap seconds. +** +** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetClockState, #CFE_TIME_GetClockInfo +** +******************************************************************************/ +int16 CFE_TIME_GetLeapSeconds(void); + +/*****************************************************************************/ +/** +** \brief Get the current state of the spacecraft clock. +** +** \par Description +** This routine returns the spacecraft clock state. Applications that +** are highly dependent on valid time may want to call this routine +** before taking actions based on the times returned by the various +** clock routines +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return The current spacecraft clock state +** +** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockInfo +** +******************************************************************************/ +CFE_TIME_ClockState_Enum_t CFE_TIME_GetClockState(void); + +/*****************************************************************************/ +/** +** \brief Provides information about the spacecraft clock. +** +** \par Description +** This routine returns information on the spacecraft clock in a bit mask. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \return Spacecraft clock information, \ref CFETIMEClkStates. +** To extract the information from the +** returned value, the flags can be used as in the following:
+** if ((ReturnValue & CFE_TIME_FLAG_xxxxxx) == CFE_TIME_FLAG_xxxxxx) then +** the following definition of the \c CFE_TIME_FLAG_xxxxxx is true.
+** +** \sa #CFE_TIME_GetSTCF, #CFE_TIME_GetLeapSeconds, #CFE_TIME_GetClockState +** +******************************************************************************/ +uint16 CFE_TIME_GetClockInfo(void); +/**@}*/ + +/** @defgroup CFEAPITIMEArithmetic cFE Time Arithmetic APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Adds two time values +** +** \par Description +** This routine adds the two specified times and returns the result. +** Normally, at least one of the input times should be a value representing +** a delta time. Adding two absolute times together will not cause an error, +** but the result will probably be meaningless. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Time1 The first time to be added. +** +** \param[in] Time2 The second time to be added. +** +** \return The sum of the two times. +** If the sum is greater than the maximum value that can be stored in a +** #CFE_TIME_SysTime_t, the result will roll over (this is not considered an error). +** +** \sa #CFE_TIME_Subtract, #CFE_TIME_Compare +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_Add(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2); + +/*****************************************************************************/ +/** +** \brief Subtracts two time values +** +** \par Description +** This routine subtracts time2 from time1 and returns the result. The +** time values can represent either absolute or delta times, but not all +** combinations make sense. +** - AbsTime - AbsTime = DeltaTime +** - AbsTime - DeltaTime = AbsTime +** - DeltaTime - DeltaTime = DeltaTime +** - DeltaTime - AbsTime = garbage +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Time1 The base time. +** +** \param[in] Time2 The time to be subtracted from the base time. +** +** \return The result of subtracting the two times. +** If the subtraction results in an underflow, the result will +** roll over (this is not considered an error). +** +** \sa #CFE_TIME_Add, #CFE_TIME_Compare +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_Subtract(CFE_TIME_SysTime_t Time1, CFE_TIME_SysTime_t Time2); + +/*****************************************************************************/ +/** +** \brief Compares two time values +** +** \par Description +** This routine compares two time values to see which is "greater". It +** is important that applications use this function rather than trying +** to directly compare the component pieces of times. This function will +** handle roll-over cases seamlessly, which may not be intuitively obvious. +** The cFE's internal representation of time "rolls over" when the 32 bit +** seconds count reaches 0xFFFFFFFF. Also, subtracting a delta time from +** an absolute time close to the epoch could result in "roll under". The +** strange cases that result from these situations can be handled by defining +** the comparison function for times as follows: +** Plot the two times on the circumference of a circle where 0 is at the +** top and 0x80000000 is at the bottom. If the shortest arc from time A +** to time B runs clockwise around the circle, then time A is less than +** time B. If the shortest arc from A to B runs counter-clockwise, then +** time A is greater than time B. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] TimeA The first time to compare. +** +** \param[in] TimeB The second time to compare. +** +** \return The result of comparing the two times. +** \retval #CFE_TIME_EQUAL \copybrief CFE_TIME_EQUAL +** \retval #CFE_TIME_A_GT_B \copybrief CFE_TIME_A_GT_B +** \retval #CFE_TIME_A_LT_B \copybrief CFE_TIME_A_LT_B +** +** \sa #CFE_TIME_Add, #CFE_TIME_Subtract +** +******************************************************************************/ +CFE_TIME_Compare_t CFE_TIME_Compare(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_t TimeB); +/**@}*/ + +/** @defgroup CFEAPITIMEConvert cFE Time Conversion APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Convert specified MET into Spacecraft Time +** +** \par Description +** This function returns Spacecraft Time given MET. Note that Spacecraft +** Time is returned as either UTC or TAI depeneding on whether the mission +** configuration parameter #CFE_MISSION_TIME_CFG_DEFAULT_UTC or #CFE_MISSION_TIME_CFG_DEFAULT_TAI +** was set to true at compile time. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] METTime The MET to be converted. +** +** \return Spacecraft Time (UTC or TAI) corresponding to the specified MET +** +** \sa #CFE_TIME_GetMET, #CFE_TIME_GetMETseconds, #CFE_TIME_GetMETsubsecs, +** #CFE_TIME_Sub2MicroSecs, #CFE_TIME_Micro2SubSecs +** +******************************************************************************/ +CFE_TIME_SysTime_t CFE_TIME_MET2SCTime (CFE_TIME_SysTime_t METTime); + +/*****************************************************************************/ +/** +** \brief Converts a sub-seconds count to an equivalent number of microseconds +** +** \par Description +** This routine converts from a sub-seconds count +** (each tick is 1 / 2^32 seconds) to microseconds (each tick is 1e-06 seconds). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] SubSeconds The sub-seconds count to convert. +** +** \return The equivalent number of microseconds. +** +** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Micro2SubSecs, +** +******************************************************************************/ +uint32 CFE_TIME_Sub2MicroSecs(uint32 SubSeconds); + +/*****************************************************************************/ +/** +** \brief Converts a number of microseconds to an equivalent sub-seconds count. +** +** \par Description +** This routine converts from microseconds (each tick is 1e-06 seconds) +** to a subseconds count (each tick is 1 / 2^32 seconds). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MicroSeconds The sub-seconds count to convert. +** +** \return The equivalent number of subseconds. If the number of microseconds +** passed in is greater than one second, (i.e. > 999,999), the return +** value is equal to \c 0xffffffff. +** +** \sa #CFE_TIME_MET2SCTime, #CFE_TIME_Sub2MicroSecs, +** +******************************************************************************/ +uint32 CFE_TIME_Micro2SubSecs(uint32 MicroSeconds); + +/**@}*/ + +/** @defgroup CFEAPITIMEExternSource cFE External Time Source APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Provides the 1 Hz signal from an external source +** +** \par Description +** This routine provides a method for cFE TIME software to be notified +** of the occurance of the 1Hz tone signal without knowledge of the +** specific hardware design. Regardless of the source of the tone, +** this routine should be called as soon as possible after detection +** to allow cFE TIME software the opportunity to latch the local clock +** as close as possible to the instant of the tone. +** +** \par Assumptions, External Events, and Notes: +** - This routine may be called directly from within the context of an +** interrupt handler. +** +** \sa #CFE_TIME_ExternalMET, #CFE_TIME_ExternalGPS, #CFE_TIME_ExternalTime +** +******************************************************************************/ +void CFE_TIME_ExternalTone(void); + +/* +** Function prototypes (external time source)... +** +** If a Time Server has been configured to accept external time +** data, then one of the following functions will be enabled. +** +** If the Time Server has also been commanded to use the external +** time data (as opposed to getting time data from a local MET) +** then the Time Server will use the external data in computing +** time. +** +** However, regardless whether the external time data is accepted +** by the Time Server, these functions also act as the signal to +** create and distribute the "time at the tone" command packet. +*/ + + +/*****************************************************************************/ +/** +** \brief Provides the Mission Elapsed Time from an external source +** +** \par Description +** This routine provides a method to provide cFE TIME with MET acquired +** from an external source. There is a presumption that this function +** will be called at the appropriate time (relative to the tone) such +** that this call may be used by cFE TIME as the signal to generate the +** "time at the tone" data command. The "time at the tone" data command +** must arrive within the configuration parameter specified window for +** tone signal and data packet verification.

+** The MET value at the tone "should" have zero subseconds. Although the +** interface accepts non-zero values for sub-seconds, it may be harmful +** to other applications that expect zero subseconds at the moment of the +** tone. Any decision to use non-zero subseconds should be carefully considered. +** +** \par Assumptions, External Events, and Notes: +** - This routine is included in the API only when 3 specific configuration +** parameters are set to true. The first is #CFE_PLATFORM_TIME_CFG_SERVER which defines +** this instantiation of cFE TIME as a time server (not a client). The +** second required configuration parameter is #CFE_PLATFORM_TIME_CFG_SOURCE which +** enables time source selection commands to the cFE TIME task, and further +** enables configuration definitions for the selected type of external time +** data. The third configuration parameter required for this routine is +** #CFE_PLATFORM_TIME_CFG_SRC_MET, which indicates that the external time data consists +** of MET. +** +** \param[in] NewMET The MET value at the next (or previous) 1 Hz tone signal. +** +** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalGPS, #CFE_TIME_ExternalTime +** +******************************************************************************/ +void CFE_TIME_ExternalMET(CFE_TIME_SysTime_t NewMET); + + +/*****************************************************************************/ +/** +** \brief Provide the time from an external source that has data common to GPS receivers. +** +** \par Description +** This routine provides a method to provide cFE TIME with current time +** data acquired from an external source. There is a presumption that +** this function will be called at the appropriate time (relative to the +** tone) such that this call may be used by cFE TIME as the signal to +** generate the "time at the tone" data command. The "time at the tone" +** data command must arrive within the configuration parameter specified +** window for tone signal and data packet verification.

+** Internally, cFE TIME will calculate a new STCF as the difference between +** this new time value and the spacecraft MET value at the tone. This allows +** cFE TIME to always calculate time as the sum of MET and STCF. The value +** of STCF will change only as much as the drift factor between spacecraft +** MET and the external time source. +** +** \par Assumptions, External Events, and Notes: +** - This routine is included in the API only when 3 specific configuration +** parameters are set to true. The first is #CFE_PLATFORM_TIME_CFG_SERVER which defines this +** instantiation of cFE TIME as a time server (not a client). The second +** required configuration parameter is #CFE_PLATFORM_TIME_CFG_SOURCE which enables +** time source selection commands to the cFE TIME task, and further enables +** configuration definitions for the selected type of external time data. +** The third configuration parameter required for this routine is +** #CFE_PLATFORM_TIME_CFG_SRC_GPS, which indicates that the external time data consists +** of a time value relative to a known epoch, plus a leap seconds value. +** +** \param[in] NewTime The MET value at the next (or previous) 1 Hz tone signal. +** +** \param[in] NewLeaps The Leap Seconds value used to calculate time as UTC. +** +** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalMET, #CFE_TIME_ExternalTime +** +******************************************************************************/ +void CFE_TIME_ExternalGPS(CFE_TIME_SysTime_t NewTime, int16 NewLeaps); + +/*****************************************************************************/ +/** +** \brief Provide the time from an external source that measures time relative to a known epoch. +** +** \par Description +** This routine provides a method to provide cFE TIME with current time +** data acquired from an external source. There is a presumption that +** this function will be called at the appropriate time (relative to the +** tone) such that this call may be used by cFE TIME as the signal to +** generate the "time at the tone" data command. The "time at the tone" +** data command must arrive within the configuration specified window for +** tone signal and data packet verification.

+** Internally, cFE TIME will calculate a new STCF as the difference between +** this new time value and the spacecraft MET value at the tone. This allows +** cFE TIME to always calculate time as the sum of MET and STCF. The value +** of STCF will change only as much as the drift factor between spacecraft +** MET and the external time source. +** +** \par Assumptions, External Events, and Notes: +** - This routine is included in the API only when 3 specific configuration +** parameters are set to true. The first is #CFE_PLATFORM_TIME_CFG_SERVER which defines this +** instanciation of cFE TIME as a time server (not a client). The second +** required configuration parameter is #CFE_PLATFORM_TIME_CFG_SOURCE which enables +** time source selection commands to the cFE TIME task, and further enables +** configuration definitions for the selected type of external time data. +** The third configuration parameter required for this routine is +** #CFE_PLATFORM_TIME_CFG_SRC_TIME, which indicates that the external time data consists +** of a time value relative to a known epoch. +** +** \param[in] NewTime The MET value at the next (or previous) 1 Hz tone signal. +** +** \sa #CFE_TIME_ExternalTone, #CFE_TIME_ExternalMET, #CFE_TIME_ExternalGPS +** +******************************************************************************/ +void CFE_TIME_ExternalTime(CFE_TIME_SysTime_t NewTime); + +/*****************************************************************************/ +/** +** \brief Registers a callback function that is called whenever time synchronization occurs +** +** \par Description +** This routine passes a callback function pointer for an Application that wishes to +** be notified whenever a legitimate time synchronization signal (typically a 1 Hz) +** is received. +** +** \par Assumptions, External Events, and Notes: +** Only a single callback per application is supported, and this function should only +** be called from a single thread within each application (typically the apps main thread). +** If an application requires triggering multiple child tasks at 1Hz, it should distribute +** the timing signal internally, rather than registering for multiple callbacks. +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TIME_TOO_MANY_SYNCH_CALLBACKS \copybrief CFE_TIME_TOO_MANY_SYNCH_CALLBACKS +** +** \sa #CFE_TIME_UnregisterSynchCallback +** +******************************************************************************/ +CFE_Status_t CFE_TIME_RegisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr); + + +/*****************************************************************************/ +/** +** \brief Unregisters a callback function that is called whenever time synchronization occurs +** +** \par Description +** This routine removes the specified callback function pointer from the list +** of Callback functions that are called whenever a time synchronization (typically +** the 1Hz signal) is received. +** +** \par Assumptions, External Events, and Notes: +** Only a single callback per application is supported, and this function should only +** be called from a single thread within each application (typically the apps main thread). +** +** \return Execution status, see \ref CFEReturnCodes +** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS +** \retval #CFE_TIME_CALLBACK_NOT_REGISTERED \copybrief CFE_TIME_CALLBACK_NOT_REGISTERED +** +** \sa #CFE_TIME_RegisterSynchCallback +** +******************************************************************************/ +CFE_Status_t CFE_TIME_UnregisterSynchCallback(CFE_TIME_SynchCallbackPtr_t CallbackFuncPtr); +/**@}*/ + +/** @defgroup CFEAPITIMEMisc cFE Miscellaneous Time APIs + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Print a time value as a string +** +** \par Description +** This routine prints the specified time to the specified string buffer +** in the following format:

+** \c yyyy-ddd-hh:mm:ss.xxxxx\\0

+** where: +** - \c yyyy = year +** - \c ddd = Julian day of the year +** - \c hh = hour of the day (0 to 23) +** - \c mm = minute (0 to 59) +** - \c ss = second (0 to 59) +** - \c xxxxx = subsecond formatted as a decimal fraction (1/4 second = 0.25000) +** - \c \\0 = trailing null +** +** \par Assumptions, External Events, and Notes: +** - The value of the time argument is simply added to the configuration +** definitions for the ground epoch and converted into a fixed length +** string in the buffer provided by the caller. +** - A loss of data during the string conversion will occur if the +** computed year exceeds 9999. However, a year that large would +** require an unrealistic definition for the ground epoch since +** the maximum amount of time represented by a CFE_TIME_SysTime +** structure is approximately 136 years. +** +** \param[in, out] PrintBuffer Pointer to a character array of at least +** #CFE_TIME_PRINTED_STRING_SIZE characters in length. *PrintBuffer is the time as a character string as described above. +** +** \param[in] TimeToPrint The time to print into the character array. +** +******************************************************************************/ +void CFE_TIME_Print(char *PrintBuffer, CFE_TIME_SysTime_t TimeToPrint); + +/*****************************************************************************/ +/** +** \brief This function should be called from the system PSP layer once per second +** +** \par Description +** Drives the time processing logic from the system PSP layer. This must be called +** once per second based on a hardware interrupt or OS kernel signal. +** +** \par Assumptions, External Events, and Notes: +** This will update the global data structures accordingly, incrementing each +** by the 1Hz amount. +** +** +******************************************************************************/ +void CFE_TIME_Local1HzISR(void); +/**@}*/ + + +/* + * The internal APIs prototyped within this block are only intended to be invoked from + * other CFE core apps. They still need to be prototyped in the shared header such that + * they can be called from other core modules, but applications should not call these. + */ +#ifdef _CFE_CORE_ + +/** @defgroup CFEAPITIMECoreInternal cFE Internal Time APIs, internal to CFE core + * @{ + */ + +/*****************************************************************************/ +/** +** \brief Entry Point for cFE Core Application +** +** \par Description +** This is the entry point to the cFE TIME Core Application. +** +** \par Assumptions, External Events, and Notes: +** None +** +** +******************************************************************************/ +extern void CFE_TIME_TaskMain(void); + +/*****************************************************************************/ +/** +** \brief Initializes the cFE core module API Library +** +** \par Description +** Initializes the cFE core module API Library +** +** \par Assumptions, External Events, and Notes: +** -# This function MUST be called before any module API's are called. +** +******************************************************************************/ +extern int32 CFE_TIME_EarlyInit(void); + +/*****************************************************************************/ +/** +** \brief Removes TIME resources associated with specified Application +** +** \par Description +** This function is called by cFE Executive Services to cleanup after +** an Application has been terminated. It frees resources +** that have been allocated to the specified Application. +** +******************************************************************************/ +extern int32 CFE_TIME_CleanUpApp(CFE_ES_AppId_t AppId); + + +/**@}*/ + +#endif /* _CFE_CORE_ */ + + +#endif /* _cfe_time_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/modules/cfe_app_intf/fsw/inc/cfe_time_api_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_time_api_typedefs.h new file mode 100644 index 000000000..dafe8f511 --- /dev/null +++ b/modules/cfe_app_intf/fsw/inc/cfe_time_api_typedefs.h @@ -0,0 +1,88 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_time.h +** +** Purpose: cFE Time Services (TIME) library API header file +** +** Author: S.Walling/Microtel +** +** Notes: +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef CFE_TIME_API_TYPES_H +#define CFE_TIME_API_TYPES_H + + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_time_extern_typedefs.h" + +/*****************************************************************************/ +/* +** Macro Definitions +*/ + +#define CFE_TIME_PRINTED_STRING_SIZE 24 /**< \brief Required size of buffer to be passed into #CFE_TIME_Print (includes null terminator) */ + + +/*****************************************************************************/ +/* +** Type Definitions +*/ + +/** +** \brief Enumerated types identifying the relative relationships of two times +** +** \par Description +** Since time fields contain numbers that are relative to an epoch time, then it is possible for a time value +** to be "negative". This can lead to some confusion about what relationship exists between two time values. +** To resolve this confusion, the cFE provides the API #CFE_TIME_Compare which returns these enumerated values. +*/ +typedef enum CFE_TIME_Compare +{ + CFE_TIME_A_LT_B = -1, /**< \brief The first specified time is considered to be before the second specified time */ + CFE_TIME_EQUAL = 0, /**< \brief The two specified times are considered to be equal */ + CFE_TIME_A_GT_B = 1 /**< \brief The first specified time is considered to be after the second specified time */ +} CFE_TIME_Compare_t; + +/** +** \brief Time Synchronization Callback Function Ptr Type +** +** \par Description +** Applications that wish to get direct notification of the receipt of the cFE Time Synchronization signal +** (typically a 1 Hz signal), must register a callback function with the following prototype via the +** #CFE_TIME_RegisterSynchCallback API. +*/ +typedef int32 (*CFE_TIME_SynchCallbackPtr_t)(void); + + +#endif /* CFE_TIME_API_TYPES_H */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/fsw/cfe-core/src/inc/cfe_time_extern_typedefs.h b/modules/cfe_app_intf/fsw/inc/cfe_time_extern_typedefs.h similarity index 91% rename from fsw/cfe-core/src/inc/cfe_time_extern_typedefs.h rename to modules/cfe_app_intf/fsw/inc/cfe_time_extern_typedefs.h index cd8feff4d..c4a2fb570 100644 --- a/fsw/cfe-core/src/inc/cfe_time_extern_typedefs.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_time_extern_typedefs.h @@ -26,13 +26,30 @@ #ifdef CFE_EDS_ENABLED_BUILD /* Use the EDS generated version of these types */ -#include "cfe_time_eds_typedefs.h" +#include "cfe_time_eds_api_typedefs.h" #else /* Use the local definitions of these types */ #include "common_types.h" +/** +** \brief Data structure used to hold system time values +** +** \par Description +** The #CFE_TIME_SysTime_t data structure is used to hold time +** values. Time is referred to as the elapsed time (in seconds +** and subseconds) since a specified epoch time. The subseconds +** field contains the number of 2^(-32) second intervals that have +** elapsed since the epoch. +** +*/ +typedef struct CFE_TIME_SysTime +{ + uint32 Seconds; /**< \brief Number of seconds since epoch */ + uint32 Subseconds; /**< \brief Number of subseconds since epoch (LSB = 2^(-32) seconds) */ +} CFE_TIME_SysTime_t; + /** * @brief Label definitions associated with CFE_TIME_FlagBit_Enum_t */ diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/modules/cfe_app_intf/fsw/inc/cfe_version.h similarity index 81% rename from fsw/cfe-core/src/inc/cfe_version.h rename to modules/cfe_app_intf/fsw/inc/cfe_version.h index 94cb45b7c..bc0852284 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/modules/cfe_app_intf/fsw/inc/cfe_version.h @@ -30,8 +30,6 @@ * git to determine the most recent tag and commit id. * */ -#include - /* Development Build Macro Definitions */ @@ -63,23 +61,4 @@ ", Last Official Release: cfe v6.7.0" /* For full support please use this version */ -/*! @brief OSAL Version Definitions. - * @details Allows for backwards compatibility. @n - * This will be defined by osal in the future - */ -#ifndef OS_VERSION -#define OS_VERSION \ - CFE_STR(OS_MAJOR_VERSION) "." \ - CFE_STR(OS_MINOR_VERSION) "." \ - CFE_STR(OS_REVISION) "." \ - CFE_STR(OS_MISSION_REV) -#endif - -/*! @brief Combined string with formatted combination of all cFS component versions */ -#define CFS_VERSIONS \ -"cFS Versions:" \ - " cfe " CFE_SRC_VERSION \ - ", osal " OS_VERSION \ - ", psp " /* CFE_PSP_VERSION is defined at runtime */ - #endif /* _cfe_version_ */ diff --git a/fsw/cfe-core/mission_build.cmake b/modules/cfe_app_intf/mission_build.cmake similarity index 100% rename from fsw/cfe-core/mission_build.cmake rename to modules/cfe_app_intf/mission_build.cmake diff --git a/modules/cfe_app_intf/ut-stubs/CMakeLists.txt b/modules/cfe_app_intf/ut-stubs/CMakeLists.txt new file mode 100644 index 000000000..727e1116a --- /dev/null +++ b/modules/cfe_app_intf/ut-stubs/CMakeLists.txt @@ -0,0 +1,41 @@ +################################################################## +# +# cFE stub function build recipe +# +# This CMake file contains the recipe for building the stub function +# libraries that correlate with the CFE public API. This library supports +# unit testing of OTHER modules, where the test cases for those modules +# are linked with the stubs supplied here, rather than the normal CFE. +# +################################################################## + +# Reference the UT assert include directory +include_directories(${osal_MISSION_DIR}/ut_assert/inc) + +# +# Create the generic stubs library +# +add_library(ut_${DEP}_stubs STATIC + src/ut_es_stubs.c + src/ut_evs_stubs.c + src/ut_msg_stubs.c + src/ut_resourceid_stubs.c + src/ut_sb_stubs.c + src/ut_tbl_stubs.c + src/ut_time_stubs.c + src/ut_fs_stubs.c +) + +# Define _CFE_CORE_ within stubs to also reveal internal APIs in header +target_compile_definitions(ut_${DEP}_stubs PRIVATE _CFE_CORE_) + +# linking with the CFE stubs implies also linking +# with the OSAL and PSP stubs. This is in line with +# how the real application is linked, in that cfe-core +# executable also provides OSAL and PSP functions. +target_link_libraries(ut_${DEP}_stubs + cfe_app_intf + ut_psp-${CFE_SYSTEM_PSPNAME}_stubs + ut_osapi_stubs + ut_assert +) diff --git a/fsw/cfe-core/ut-stubs/ut_es_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_es_stubs.c similarity index 98% rename from fsw/cfe-core/ut-stubs/ut_es_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_es_stubs.c index 57b1bd105..122a366d6 100644 --- a/fsw/cfe-core/ut-stubs/ut_es_stubs.c +++ b/modules/cfe_app_intf/ut-stubs/src/ut_es_stubs.c @@ -33,12 +33,27 @@ ** Includes */ #include -#include "cfe.h" -#include "private/cfe_private.h" -#include "private/cfe_core_resourceid_basevalues.h" +#include "cfe_es.h" +#include "cfe_resourceid.h" +#include "cfe_resourceid_basevalue.h" + #include "utstubs.h" #include "utassert.h" +/* + * Assign ID base values for UT + */ +enum +{ + UT_CFE_ES_TASKID_BASE = CFE_RESOURCEID_MAKE_BASE(0x21), + UT_CFE_ES_APPID_BASE = CFE_RESOURCEID_MAKE_BASE(0x22), + UT_CFE_ES_LIBID_BASE = CFE_RESOURCEID_MAKE_BASE(0x23), + UT_CFE_ES_COUNTID_BASE = CFE_RESOURCEID_MAKE_BASE(0x24), + UT_CFE_ES_POOLID_BASE = CFE_RESOURCEID_MAKE_BASE(0x25), + UT_CFE_ES_CDSBLOCKID_BASE = CFE_RESOURCEID_MAKE_BASE(0x26) +}; + + /* * Unit-test stub definitions/limits * @@ -65,19 +80,19 @@ * Default value to return from calls that output an App ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_APPID CFE_ES_APPID_C(CFE_ResourceId_FromInteger(CFE_ES_APPID_BASE + 1)) +#define CFE_UT_ES_DEFAULT_APPID CFE_ES_APPID_C(CFE_ResourceId_FromInteger(UT_CFE_ES_APPID_BASE + 1)) /* * Default value to return from calls that output a Task ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_TASKID CFE_ES_TASKID_C(CFE_ResourceId_FromInteger(CFE_ES_TASKID_BASE + 1)) +#define CFE_UT_ES_DEFAULT_TASKID CFE_ES_TASKID_C(CFE_ResourceId_FromInteger(UT_CFE_ES_TASKID_BASE + 1)) /* * Default value to return from calls that output a CDS ID, if the * test case does not provide a value */ -#define CFE_UT_ES_DEFAULT_CDSID CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(CFE_ES_CDSBLOCKID_BASE + 1)) +#define CFE_UT_ES_DEFAULT_CDSID CFE_ES_CDSHANDLE_C(CFE_ResourceId_FromInteger(UT_CFE_ES_CDSBLOCKID_BASE + 1)) /* * Invalid value to output from calls as resource ID for the diff --git a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_evs_stubs.c similarity index 99% rename from fsw/cfe-core/ut-stubs/ut_evs_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_evs_stubs.c index 737c37b22..5e8b2233e 100644 --- a/fsw/cfe-core/ut-stubs/ut_evs_stubs.c +++ b/modules/cfe_app_intf/ut-stubs/src/ut_evs_stubs.c @@ -33,8 +33,8 @@ ** Includes */ #include -#include "cfe.h" -#include "private/cfe_private.h" +#include "cfe_evs.h" + #include "utstubs.h" #include "uttools.h" diff --git a/fsw/cfe-core/ut-stubs/ut_fs_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_fs_stubs.c similarity index 100% rename from fsw/cfe-core/ut-stubs/ut_fs_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_fs_stubs.c diff --git a/fsw/cfe-core/ut-stubs/ut_msg_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_msg_stubs.c similarity index 100% rename from fsw/cfe-core/ut-stubs/ut_msg_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_msg_stubs.c diff --git a/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_resourceid_stubs.c similarity index 99% rename from fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_resourceid_stubs.c index 8a540f4fe..403c89735 100644 --- a/fsw/cfe-core/ut-stubs/ut_resourceid_stubs.c +++ b/modules/cfe_app_intf/ut-stubs/src/ut_resourceid_stubs.c @@ -24,7 +24,7 @@ #include "osapi.h" #include "cfe.h" #include "utstubs.h" -#include "cfe_resourceid_api.h" +#include "cfe_resourceid.h" #include "cfe_resourceid_basevalue.h" diff --git a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_sb_stubs.c similarity index 99% rename from fsw/cfe-core/ut-stubs/ut_sb_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_sb_stubs.c index 30742c081..7c351f71e 100644 --- a/fsw/cfe-core/ut-stubs/ut_sb_stubs.c +++ b/modules/cfe_app_intf/ut-stubs/src/ut_sb_stubs.c @@ -33,8 +33,9 @@ ** Includes */ #include -#include "cfe.h" -#include "private/cfe_private.h" +#include "cfe_sb.h" +#include "cfe_time_extern_typedefs.h" + #include "utstubs.h" typedef struct diff --git a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_tbl_stubs.c similarity index 99% rename from fsw/cfe-core/ut-stubs/ut_tbl_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_tbl_stubs.c index f75ae4a35..31d4156ab 100644 --- a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c +++ b/modules/cfe_app_intf/ut-stubs/src/ut_tbl_stubs.c @@ -22,8 +22,8 @@ ** Includes */ #include -#include "cfe.h" -#include "private/cfe_private.h" +#include "cfe_tbl.h" + #include "utstubs.h" /* diff --git a/fsw/cfe-core/ut-stubs/ut_time_stubs.c b/modules/cfe_app_intf/ut-stubs/src/ut_time_stubs.c similarity index 99% rename from fsw/cfe-core/ut-stubs/ut_time_stubs.c rename to modules/cfe_app_intf/ut-stubs/src/ut_time_stubs.c index 6d86b9625..e3a1414dd 100644 --- a/fsw/cfe-core/ut-stubs/ut_time_stubs.c +++ b/modules/cfe_app_intf/ut-stubs/src/ut_time_stubs.c @@ -35,7 +35,7 @@ #include #include #include "cfe_time.h" -#include "private/cfe_private.h" + #include "utstubs.h" /* diff --git a/modules/cfe_internal_intf/CMakeLists.txt b/modules/cfe_internal_intf/CMakeLists.txt new file mode 100644 index 000000000..6367b70bd --- /dev/null +++ b/modules/cfe_internal_intf/CMakeLists.txt @@ -0,0 +1,34 @@ +################################################################## +# +# cFE Inter-module interface +# +################################################################## + + +add_library(cfe_internal_intf INTERFACE) + +# code compiled as CFE core internal will have _CFE_CORE_ macro set +target_compile_definitions(cfe_internal_intf INTERFACE _CFE_CORE_) + +target_include_directories(cfe_internal_intf INTERFACE + fsw/inc # includes shared among CFE core apps, not called/used by apps + ${CFE_SOURCE_DIR}/cmake/target/inc # to get at the "target_config.h" file when needed +) + +# also use all headers/definitions from public intf +target_link_libraries(cfe_internal_intf INTERFACE cfe_app_intf) + +# Add unit test coverage subdirectory +if (ENABLE_UNIT_TESTS) + add_subdirectory(ut-stubs) +endif (ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + cfe_es_erlog_typedef.h + cfe_evs_log_typedef.h + cfe_es_resetdata_typedef.h + cfe_sbr.h + cfe_sb_destination_typedef.h + cfe_es_perfdata_typedef.h + cfe_core_resourceid_basevalues.h +) diff --git a/fsw/cfe-core/arch_build.cmake b/modules/cfe_internal_intf/arch_build.cmake similarity index 79% rename from fsw/cfe-core/arch_build.cmake rename to modules/cfe_internal_intf/arch_build.cmake index 2f2f0d5d3..0de378fab 100644 --- a/fsw/cfe-core/arch_build.cmake +++ b/modules/cfe_internal_intf/arch_build.cmake @@ -17,9 +17,3 @@ generate_config_includefile( PREFIXES ${BUILD_CONFIG} ) -generate_config_includefile( - FILE_NAME "cfe_msgids.h" - MATCH_SUFFIX "msgids.h" - PREFIXES ${BUILD_CONFIG} -) - diff --git a/modules/cfe_internal_intf/eds/base_types.xml b/modules/cfe_internal_intf/eds/base_types.xml new file mode 100644 index 000000000..55d7c7679 --- /dev/null +++ b/modules/cfe_internal_intf/eds/base_types.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + single + + + + + + double + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/cfe_internal_intf/eds/config.xml b/modules/cfe_internal_intf/eds/config.xml new file mode 100644 index 000000000..1635b02e4 --- /dev/null +++ b/modules/cfe_internal_intf/eds/config.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h b/modules/cfe_internal_intf/fsw/inc/cfe_core_resourceid_basevalues.h similarity index 100% rename from fsw/cfe-core/src/inc/private/cfe_core_resourceid_basevalues.h rename to modules/cfe_internal_intf/fsw/inc/cfe_core_resourceid_basevalues.h diff --git a/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h b/modules/cfe_internal_intf/fsw/inc/cfe_es_erlog_typedef.h similarity index 95% rename from fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h rename to modules/cfe_internal_intf/fsw/inc/cfe_es_erlog_typedef.h index a2193ae5c..76b30a8eb 100644 --- a/fsw/cfe-core/src/inc/private/cfe_es_erlog_typedef.h +++ b/modules/cfe_internal_intf/fsw/inc/cfe_es_erlog_typedef.h @@ -32,7 +32,10 @@ #define CFE_ES_ERLOG_TYPEDEF_H_ #include -#include /* Needed for CFE_TIME_SysTime_t */ +#include + +#include /* Needed for CFE_TIME_SysTime_t */ +#include /* Needed for CFE_ES_AppId_t */ #define CFE_ES_ERLOG_DESCRIPTION_MAX_LENGTH 80 diff --git a/fsw/cfe-core/src/inc/private/cfe_es_perfdata_typedef.h b/modules/cfe_internal_intf/fsw/inc/cfe_es_perfdata_typedef.h similarity index 100% rename from fsw/cfe-core/src/inc/private/cfe_es_perfdata_typedef.h rename to modules/cfe_internal_intf/fsw/inc/cfe_es_perfdata_typedef.h diff --git a/fsw/cfe-core/src/inc/private/cfe_es_resetdata_typedef.h b/modules/cfe_internal_intf/fsw/inc/cfe_es_resetdata_typedef.h similarity index 96% rename from fsw/cfe-core/src/inc/private/cfe_es_resetdata_typedef.h rename to modules/cfe_internal_intf/fsw/inc/cfe_es_resetdata_typedef.h index 2c59613e0..75f17b8bf 100644 --- a/fsw/cfe-core/src/inc/private/cfe_es_resetdata_typedef.h +++ b/modules/cfe_internal_intf/fsw/inc/cfe_es_resetdata_typedef.h @@ -33,7 +33,7 @@ #include -#include /* Required for CFE_TIME_ResetVars_t definition */ +#include "cfe_time_resetvars_typedef.h" /* Required for CFE_TIME_ResetVars_t definition */ #include "cfe_es_erlog_typedef.h" /* Required for CFE_ES_ERLog_t definition */ #include "cfe_es_perfdata_typedef.h" /* Required for CFE_ES_PerfData_t definition */ #include "cfe_evs_log_typedef.h" /* Required for CFE_EVS_Log_t definition */ diff --git a/fsw/cfe-core/src/inc/private/cfe_evs_log_typedef.h b/modules/cfe_internal_intf/fsw/inc/cfe_evs_log_typedef.h similarity index 98% rename from fsw/cfe-core/src/inc/private/cfe_evs_log_typedef.h rename to modules/cfe_internal_intf/fsw/inc/cfe_evs_log_typedef.h index dc9a7303a..a312b6adc 100644 --- a/fsw/cfe-core/src/inc/private/cfe_evs_log_typedef.h +++ b/modules/cfe_internal_intf/fsw/inc/cfe_evs_log_typedef.h @@ -32,6 +32,8 @@ #define CFE_EVS_LOG_TYPEDEF_H_ #include +#include + #include "cfe_evs_msg.h" /* Required for CFE_EVS_LongEventTlm_t definition */ /* diff --git a/fsw/cfe-core/src/inc/private/cfe_sb_destination_typedef.h b/modules/cfe_internal_intf/fsw/inc/cfe_sb_destination_typedef.h similarity index 95% rename from fsw/cfe-core/src/inc/private/cfe_sb_destination_typedef.h rename to modules/cfe_internal_intf/fsw/inc/cfe_sb_destination_typedef.h index 8627b8476..5faf02a32 100644 --- a/fsw/cfe-core/src/inc/private/cfe_sb_destination_typedef.h +++ b/modules/cfe_internal_intf/fsw/inc/cfe_sb_destination_typedef.h @@ -27,7 +27,7 @@ #define CFE_SB_DESTINATION_TYPEDEF_H_ #include "common_types.h" -#include "cfe_sb.h" /* Required for CFE_SB_PipeId_t definition */ +#include "cfe_sb_extern_typedefs.h" /* Required for CFE_SB_PipeId_t definition */ /****************************************************************************** * This structure defines a DESTINATION DESCRIPTOR used to specify diff --git a/fsw/cfe-core/src/inc/private/cfe_sbr.h b/modules/cfe_internal_intf/fsw/inc/cfe_sbr.h similarity index 79% rename from fsw/cfe-core/src/inc/private/cfe_sbr.h rename to modules/cfe_internal_intf/fsw/inc/cfe_sbr.h index 63d00d2ba..0d22a106c 100644 --- a/fsw/cfe-core/src/inc/private/cfe_sbr.h +++ b/modules/cfe_internal_intf/fsw/inc/cfe_sbr.h @@ -26,55 +26,18 @@ * routing internal use. *****************************************************************************/ -#ifndef CFE_SBR_H_ -#define CFE_SBR_H_ +#ifndef CFE_SBR_H +#define CFE_SBR_H /* * Includes */ #include "common_types.h" -#include "private/cfe_sb_destination_typedef.h" -#include "cfe_sb.h" -#include "cfe_msg_typedefs.h" -#include "cfe_platform_cfg.h" - -/* - * Macro Definitions - */ - -/** \brief Invalid route id */ -#define CFE_SBR_INVALID_ROUTE_ID ((CFE_SBR_RouteId_t) {.RouteId = 0}) +#include "cfe_sbr_api_typedefs.h" +#include "cfe_msg_api_typedefs.h" +#include "cfe_sb_destination_typedef.h" -/****************************************************************************** - * Type Definitions - */ - -/** - * \brief Routing table id - * - * This is intended as a form of "strong typedef" where direct assignments should - * be restricted. Software bus uses numeric indexes into multiple tables to perform - * its duties, and it is important that these index values are distinct and separate - * and not mixed together. - * - * Using this holding structure prevents assignment directly into a different index - * or direct usage as numeric value. - */ -typedef struct -{ - CFE_SB_RouteId_Atom_t RouteId; /**< \brief Holding value, do not use directly in code */ -} CFE_SBR_RouteId_t; - -/** \brief Callback throttling structure */ -typedef struct -{ - uint32 StartIndex; /**< /brief 0 based index to start at */ - uint32 MaxLoop; /**< /brief Max number to process */ - uint32 NextIndex; /**< /brief Next start index (output), 0 if completed */ -} CFE_SBR_Throttle_t; - -/** \brief For each id callback function prototype */ -typedef void (*CFE_SBR_CallbackPtr_t)(CFE_SBR_RouteId_t RouteId, void *ArgPtr); +#include "cfe_platform_cfg.h" /****************************************************************************** * Function prototypes @@ -209,4 +172,4 @@ static inline CFE_SB_RouteId_Atom_t CFE_SBR_RouteIdToValue(CFE_SBR_RouteId_t Rou return (RouteId.RouteId - 1); } -#endif /* CFE_SBR_H_ */ +#endif /* CFE_SBR_H */ diff --git a/modules/cfe_internal_intf/fsw/inc/cfe_sbr_api_typedefs.h b/modules/cfe_internal_intf/fsw/inc/cfe_sbr_api_typedefs.h new file mode 100644 index 000000000..25ff71742 --- /dev/null +++ b/modules/cfe_internal_intf/fsw/inc/cfe_sbr_api_typedefs.h @@ -0,0 +1,78 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/****************************************************************************** + * File: cfe_sbr.h + * + * Purpose: + * Prototypes for private functions and type definitions for SB + * routing internal use. + *****************************************************************************/ + +#ifndef CFE_SBR_API_TYPEDEFS_H +#define CFE_SBR_API_TYPEDEFS_H + +/* + * Includes + */ +#include "common_types.h" +#include "cfe_sb_extern_typedefs.h" + +/* + * Macro Definitions + */ + +/** \brief Invalid route id */ +#define CFE_SBR_INVALID_ROUTE_ID ((CFE_SBR_RouteId_t) {.RouteId = 0}) + + +/****************************************************************************** + * Type Definitions + */ + +/** + * \brief Routing table id + * + * This is intended as a form of "strong typedef" where direct assignments should + * be restricted. Software bus uses numeric indexes into multiple tables to perform + * its duties, and it is important that these index values are distinct and separate + * and not mixed together. + * + * Using this holding structure prevents assignment directly into a different index + * or direct usage as numeric value. + */ +typedef struct +{ + CFE_SB_RouteId_Atom_t RouteId; /**< \brief Holding value, do not use directly in code */ +} CFE_SBR_RouteId_t; + +/** \brief Callback throttling structure */ +typedef struct +{ + uint32 StartIndex; /**< /brief 0 based index to start at */ + uint32 MaxLoop; /**< /brief Max number to process */ + uint32 NextIndex; /**< /brief Next start index (output), 0 if completed */ +} CFE_SBR_Throttle_t; + +/** \brief For each id callback function prototype */ +typedef void (*CFE_SBR_CallbackPtr_t)(CFE_SBR_RouteId_t RouteId, void *ArgPtr); + + +#endif /* CFE_SBR_API_TYPEDEFS_H */ diff --git a/modules/cfe_internal_intf/fsw/inc/cfe_time_resetvars_typedef.h b/modules/cfe_internal_intf/fsw/inc/cfe_time_resetvars_typedef.h new file mode 100644 index 000000000..6b231e2b9 --- /dev/null +++ b/modules/cfe_internal_intf/fsw/inc/cfe_time_resetvars_typedef.h @@ -0,0 +1,70 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: cfe_time.h +** +** Purpose: cFE Time Services (TIME) library API header file +** +** Author: S.Walling/Microtel +** +** Notes: +** +*/ + +/* +** Ensure that header is included only once... +*/ +#ifndef CFE_TIME_RESETVARS_TYPEDEF_H +#define CFE_TIME_RESETVARS_TYPEDEF_H + + +/* +** Includes +*/ +#include "common_types.h" +#include "cfe_time_extern_typedefs.h" + + +/** +** \brief Time related variables that are maintained through a Processor Reset +** +** \par Description +** The #CFE_TIME_ResetVars_t data structure contains those variables that are maintained +** in an area of memory that is not cleared during a Processor Reset. This allows the +** cFE Time Service to maintain time to the best of its ability after a Processor Reset. +*/ +typedef struct CFE_TIME_ResetVars +{ + uint32 Signature; /**< \brief Data validation signature used to verify data structure contents*/ + int16 LeapSeconds; /**< \brief Leap seconds value */ + uint16 ClockSignal; /**< \brief Current clock signal selection */ + CFE_TIME_SysTime_t CurrentMET; /**< \brief Current Mission Elapsed Time (MET) */ + CFE_TIME_SysTime_t CurrentSTCF; /**< \brief Current Spacecraft Time Correlation Factor (STCF) */ + CFE_TIME_SysTime_t CurrentDelay; /**< \brief Current time client delay value */ + +} CFE_TIME_ResetVars_t; + + +#endif /* CFE_TIME_RESETVARS_TYPEDEF_H */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/modules/cfe_internal_intf/ut-stubs/CMakeLists.txt b/modules/cfe_internal_intf/ut-stubs/CMakeLists.txt new file mode 100644 index 000000000..4a94bd40f --- /dev/null +++ b/modules/cfe_internal_intf/ut-stubs/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################## +# +# cFE stub function build recipe +# +# This CMake file contains the recipe for building the stub function +# libraries that correlate with the CFE public API. This library supports +# unit testing of OTHER modules, where the test cases for those modules +# are linked with the stubs supplied here, rather than the normal CFE. +# +################################################################## + +# +# Create the generic stubs library +# +add_library(ut_${DEP}_stubs STATIC + src/ut_osprintf_stubs.c + src/ut_support.c +) + +target_include_directories(ut_${DEP}_stubs PUBLIC inc) + + +# linking with the CFE stubs implies also linking +# with the OSAL and PSP stubs. This is in line with +# how the real application is linked, in that cfe-core +# executable also provides OSAL and PSP functions. +target_link_libraries(ut_${DEP}_stubs + cfe_internal_intf + ut_cfe_app_intf_stubs + ut_psp-${CFE_SYSTEM_PSPNAME}_stubs + ut_osapi_stubs + ut_assert +) diff --git a/modules/cfe_internal_intf/ut-stubs/inc/ut_osprintf_stubs.h b/modules/cfe_internal_intf/ut-stubs/inc/ut_osprintf_stubs.h new file mode 100644 index 000000000..377f20c14 --- /dev/null +++ b/modules/cfe_internal_intf/ut-stubs/inc/ut_osprintf_stubs.h @@ -0,0 +1,103 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: +** ut_osprintf_stubs.h +** +** Purpose: +** OS API unit test header +** +** References: +** 1. cFE Application Developers Guide +** 2. unit test standard 092503 +** 3. C Coding Standard 102904 +** +** Notes: +** 1. This is unit test code only, not for use in flight +** +*/ +#ifndef _UT_OSPRINTF_STUBS_H_ +#define _UT_OSPRINTF_STUBS_H_ + +#define UT_OSP_CORE_INIT 11 +#define UT_OSP_POR_MAX_PROC_RESETS 12 +#define UT_OSP_CORE_RUNTIME 13 +#define UT_OSP_CORE_APP_EXIT 14 +#define UT_OSP_PROC_RESET_COMMANDED 15 +#define UT_OSP_POR_COMMANDED 16 +#define UT_OSP_CANNOT_CALL_APP_MAIN 17 +#define UT_OSP_GET_APP_ID 18 +#define UT_OSP_MUTEX_TAKE 19 +#define UT_OSP_MUTEX_GIVE 20 +#define UT_OSP_CANNOT_RESTART_APP 21 +#define UT_OSP_INSUFF_FREE_SPACE 22 +#define UT_OSP_CREATE_VOLATILE 23 +#define UT_OSP_INIT_VOLATILE 24 +#define UT_OSP_MOUNT_VOLATILE 25 +#define UT_OSP_REMOUNT_VOLATILE 26 +#define UT_OSP_REFORMAT_VOLATILE 27 +#define UT_OSP_REMOVE_VOLATILE 28 +#define UT_OSP_UNMOUNT_VOLATILE 29 +#define UT_OSP_DETERMINE_BLOCKS 30 +#define UT_OSP_CORE_APP_CREATE 31 +#define UT_OSP_RECORD_USED 32 +#define UT_OSP_NO_FREE_APP_SLOTS 33 +#define UT_OSP_EARLYINIT 34 +#define UT_OSP_FUNCTION_POINTER 35 +#define UT_OSP_FILE_LINE_TOO_LONG 36 +#define UT_OSP_STARTUP_READ 37 +#define UT_OSP_CANNOT_OPEN_ES_APP_STARTUP 38 +#define UT_OSP_ES_APP_STARTUP_OPEN 39 +#define UT_OSP_COMMAND_PIPE 40 +#define UT_OSP_APP_INIT 41 +#define UT_OSP_REGISTER_APP 42 +#define UT_OSP_SHARED_LIBRARY_INIT 43 +#define UT_OSP_DECOMPRESS_LIBRARY 44 +#define UT_OSP_EXTRACT_FILENAME_CF 45 +#define UT_OSP_EXTRACT_FILENAME_UT46 46 +#define UT_OSP_LIB_PATH_FILE_TOO_LONG 47 +#define UT_OSP_LOAD_SHARED_LIBRARY 48 +#define UT_OSP_FIND_LIBRARY 49 +#define UT_OSP_LIBRARY_SLOTS 50 +#define UT_OSP_APP_CREATE 51 +#define UT_OSP_DECOMPRESS_APP 52 +#define UT_OSP_TABLE_SLOT_IN_USE 53 +#define UT_OSP_EXTRACT_FILENAME_UT 54 +#define UT_OSP_EXTRACT_FILENAME_UT55 55 +#define UT_OSP_CANNOT_FIND_SYMBOL 56 +#define UT_OSP_EXTRACT_FILENAME_UT57 57 +#define UT_OSP_APP_PATH_FILE_TOO_LONG 58 +#define UT_OSP_INVALID_LOG_MODE 59 +#define UT_OSP_SYSTEM_LOG_FULL 60 +#define UT_OSP_POR_HW_SPECIAL 61 +#define UT_OSP_POR_OTHER 62 +#define UT_OSP_POR_MAX_HW_SPECIAL 63 +#define UT_OSP_PROC_RESET_MAX_HW_SPECIAL 64 +#define UT_OSP_STARTUP_SYNC_FAIL_1 65 +#define UT_OSP_NO_FREE_CORE_APP_SLOTS 66 +#define UT_OSP_STARTUP_SYNC_FAIL_2 67 +#define UT_OSP_MODULE_UNLOAD_FAILED 68 +#define UT_OSP_TASKEXIT_BAD_CONTEXT 69 +#define UT_OSP_BACKGROUND_REGISTER 70 +#define UT_OSP_BACKGROUND_TAKE 71 + +#endif + diff --git a/modules/cfe_internal_intf/ut-stubs/inc/ut_support.h b/modules/cfe_internal_intf/ut-stubs/inc/ut_support.h new file mode 100644 index 000000000..6ff966828 --- /dev/null +++ b/modules/cfe_internal_intf/ut-stubs/inc/ut_support.h @@ -0,0 +1,747 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_support.h +** +** Purpose: +** Unit specification for Unit Test Stubs +** +** Notes: +** These routines contain a minimum amount of functionality required for +** unit testing full path coverage +** +*/ +#ifndef _UT_CFE_SUPPORT_H_ +#define _UT_CFE_SUPPORT_H_ + +/* +** Includes +*/ +#include + +#include "cfe.h" +#include "cfe_es_resetdata_typedef.h" + +#include "utassert.h" +#include "uttest.h" +#include "uttools.h" +#include "utbsp.h" +#include "utstubs.h" + +/* + * Conversion from old-style OS_printf stub + */ +extern const char *UT_OSP_MESSAGES[]; + +/* CDS type declarations */ +#define CFE_ES_CDS_CHECK_PATTERN 0x5a5a +#define CFE_ES_CDS_BLOCK_USED 0xaaaa +#define CFE_ES_CDS_BLOCK_UNUSED 0xdddd +#define CFE_ES_CDS_NUM_BLOCK_SIZES 17 + +/* MIN_BLOCK_SIZE must be < 16 bytes */ +#define CFE_ES_CDS_MIN_BLOCK_SIZE 8 +#define UT_EVENT_HISTORY_SIZE 64 +#define UT_MAX_MESSAGE_LENGTH 300 + +/* Macro to add a test to the UT assert list */ +#define UT_ADD_TEST(Func) UtTest_Add(Func, NULL, NULL, #Func) + + +/* Required to be defined for GetMsgId and SetMsgId stubs + * Actual macro defitiions are in cfe_sb_msg_id_utils.h + * #ifndef so that the actual macros are used for unit + * testing of SB + * */ +#ifndef CFE_SB_CMD_MESSAGE_TYPE +#define CFE_SB_CMD_MESSAGE_TYPE 0x0000080 +#endif + +#ifndef CFE_SB_RD_APID_FROM_MSGID +#define CFE_SB_RD_APID_FROM_MSGID(MsgId) (MsgId & 0x0000007F) +#endif + +#ifndef CFE_SB_RD_SUBSYS_ID_FROM_MSGID +#define CFE_SB_RD_SUBSYS_ID_FROM_MSGID(MsgId) ( (MsgId & 0x0000FF00) >> 8) +#endif + +#ifndef CFE_SB_RD_TYPE_FROM_MSGID +#define CFE_SB_RD_TYPE_FROM_MSGID(MsgId) ( (MsgId & CFE_SB_CMD_MESSAGE_TYPE) >> 7) +#endif + +/* + * NOTE: There are some UT cases in TBL that are dependent on + * the endianness of the local CPU. This "endian check" exists + * to provide hints to the test code. + * + * All endian-specific code should be replaced with endian-neutral + * code in future versions. This check will be removed in a future + * version once that is complete. No new test code should use this. + */ +#define UT_LITTLE_ENDIAN 1 +#define UT_BIG_ENDIAN 2 +extern uint8 UT_Endianess; + + +typedef struct +{ + CFE_SB_MsgId_t MsgId; + uint16 SnapshotOffset; + uint16 SnapshotSize; + uint16 Count; + void *SnapshotBuffer; +} UT_SoftwareBusSnapshot_Entry_t; + +/* + * Information to identify a message in the "Task Pipe" + * or message dispatch routines, to indicate which of + * the message handlers the routine should invoke. + * + * Initially, this is the combination of MsgID + Command Code, + * but this could be different for other implementations + * that utilize a more abstract dispatch table. + * + * Using this structure wrapper allows the task pipe function + * to evolve without necessarily breaking all the UT test + * cases that need to invoke a specific handler. + */ +typedef struct +{ + /** + * Invoke the handler for this MsgID + */ + CFE_SB_MsgId_t MsgId; + + /** + * Specifies the sub-command to invoke + * (ignored if the handler does not use command codes, + * set to zero in this case). + */ + CFE_MSG_FcnCode_t CommandCode; + +} UT_TaskPipeDispatchId_t; + +/* +** Functions +*/ +/*****************************************************************************/ +/** +** \brief Initialize unit test +** +** \par Description +** Set up logging file, initialize variables, and perform endian check. +** This function must be called prior to executing any of the cFE unit +** tests. +** +** \param[in] subsys Pointer to subsystem ID character string +** +** \returns +** This function does not return a value. +** +** \sa #UT_InitData, #UT_EndianCheck +** +******************************************************************************/ +void UT_Init(const char *subsys); + +/*****************************************************************************/ +/** +** \brief Initialize unit test variables +** +** \par Description +** This initialization function should be called prior to each unit test +** in order to set the variables to known states. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +** +** \sa #UT_ClearEventHistory, #UT_ResetPoolBufferIndex, #UT_SetOSFail, +** \sa #UT_SetBSPFail, #UT_SetRtnCode, #UT_ResetCDS +** +******************************************************************************/ +void UT_InitData(void); + +/*****************************************************************************/ +/** +** \brief Initialize the CDS +** +** \par Description +** Initialize the CDS values to all zeroes in preparation for the +** next test. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_ResetCDS(void); + +/*****************************************************************************/ +/** +** \brief Reset pool buffer index +** +** \par Description +** Reset pool buffer index to zero. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +/* Reset pool buffer array index */ +void UT_ResetPoolBufferIndex(void); + +/*****************************************************************************/ +/** +** \brief Output single test's pass/fail status +** +** \par Description +** Out the results and description for a single test, and update the +** pass/fail counters. +** +** \par Assumptions, External Events, and Notes: +** +** \param[in] test Equals 0 if the test failed; non-zero if the +** test passed +** +** \param[in] fun_name Character string pointer to the name of the function +** being tested +** +** \param[in] info Character string pointer to the description of the test +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_Report(const char *file, uint32 line, bool test, const char *fun_name, + const char *info); + +/*****************************************************************************/ +/** +** \brief Test pass/fail summary +** +** \par Description +** Output total number of tests passed and failed. +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_ReportFailures(void); + +/*****************************************************************************/ +/** +** \brief Send a message via the software bus +** +** \par Description +** Does the required work to send a software bus message. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] msg_ptr Pointer to the buffer that contains the software +** bus message +** +** \param[in] id Message ID to put into the message header +** +** \param[in] code Command code to include in the message +** +** \returns +** This function does not return a value. +******************************************************************************/ +void UT_CallTaskPipe(void (*TaskPipeFunc)(CFE_SB_Buffer_t*), CFE_MSG_Message_t *MsgPtr, size_t MsgSize, + UT_TaskPipeDispatchId_t DispatchId); + +/*****************************************************************************/ +/** +** \brief A UT-Assert compatible hook function to get a snapshot of a software bus message +** +** \par Description +** Captures a user-specified piece of information out of the software bus message +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** Passes through the return code from the handler +** +******************************************************************************/ +int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCount, + const UT_StubContext_t *Context); + +/*****************************************************************************/ +/** +** \brief Set the application ID returned by unit test stubs +** +** \par Description +** Set the application ID value returned by the unit test CFS stub +** functions. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] AppID_in Application ID +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_SetAppID(CFE_ES_AppId_t AppID_in); + +/*****************************************************************************/ +/** +** \brief Set the return code of CFE_PSP_GetResetArea and the data validation +** signature +** +** \par Description +** Set the return code of CFE_PSP_GetResetArea and the data validation +** signature. +** +** \param[in] status CFE_PSP_GetResetArea return code +** +** \param[in] Signature Data validation signature used to verify data +** structure contents +** +** \param[in] ClockSignal Clock signal type +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_SetStatusBSPResetArea(int32 status, uint32 Signature, + uint32 ClockSignal); + +/*****************************************************************************/ +/** +** \brief Set the contents of the buffer to read +** +** \par Description +** Set the contents of the buffer to read; e.g., the startup script. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Buff Pointer to information to place into the buffer +** +** \param[in] NumBytes Length in bytes of the buffer contents +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_SetReadBuffer(void *Buff, int NumBytes); + +/*****************************************************************************/ +/** +** \brief Set the contents of the header to read +** +** \par Description +** Set the contents of the header to read. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Hdr Pointer to information to place into the header +** +** \param[in] NumBytes Length in bytes of the header contents +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_SetReadHeader(void *Hdr, int NumBytes); + +/*****************************************************************************/ +/** +** \brief Set the dummy function return code +** +** \par Description +** Used to set the return code when ES is starting tasks by pointers; +** the dummy function is started instead of actually tasks. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Return Dummy function return code +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_SetDummyFuncRtn(int Return); + +/*****************************************************************************/ +/** +** \brief Set the size of the ES reset area +** +** \par Description +** Set the size of the ES reset area that will be returned by calls +** to the CFE_PSP_GetResetArea stub function. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Size Reset area size +** +** \returns +** This function does not return a value. +** +** \sa +** +******************************************************************************/ +void UT_SetSizeofESResetArea(int32 Size); + +/*****************************************************************************/ +/** +** \brief Set the CDS size returned by the BSP +** +** \par Description +** Set the CDS size returned by the BSP. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] Size CDS size +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +uint8* UT_SetCDSSize(int32 Size); + +/*****************************************************************************/ +/** +** \brief Set BSP time +** +** \par Description +** Set the time to be returned by calls to the CFE_PSP_GetTime stub +** function. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] seconds Time, seconds +** +** \param[in] microsecs Time, microseconds +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_SetBSP_Time(uint32 seconds, uint32 microsecs); + +/*****************************************************************************/ +/** +** \brief Clear the event history +** +** \par Description +** Clear the event history so that one test's event messages won't be + confused with a subsequent test (some tests depend on an accurate + count of the number of messages generated for that test). +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +** +** \sa +** +******************************************************************************/ +void UT_ClearEventHistory(void); + +/*****************************************************************************/ +/** +** \brief Search the event history for a specified event ID +** +** \par Description +** Search the event history for a specified event ID. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] EventIDToSearchFor Event ID to search for in the event history +** +** \returns +** true if the event ID to search for is found in the event history; +** false if the event ID is not found. +** +******************************************************************************/ +bool UT_EventIsInHistory(uint16 EventIDToSearchFor); + +/*****************************************************************************/ +/** +** \brief Search the syslog history for a specified log message template +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] LogMsgToSearchFor Template to search for in the syslog history +** +** \returns +** Number of matches of the template found in the history +** +******************************************************************************/ +uint32 UT_SyslogIsInHistory(const char *LogMsgToSearchFor); + +/*****************************************************************************/ +/** +** \brief Search the printf history for a specified message template +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] MsgToSearchFor Template to search for in the syslog history +** +** \returns +** Number of matches of the template found in the history +** +******************************************************************************/ +uint32 UT_PrintfIsInHistory(const char *MsgToSearchFor); + +/*****************************************************************************/ +/** +** \brief Return number of events issued +** +** \par Description +** Return number of events issued since the last UT_ClearEventHistory +** call. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** Number of events issued. +** +******************************************************************************/ +uint16 UT_GetNumEventsSent(void); + +/*****************************************************************************/ +/** +** \brief Display the contents of a packet +** +** \par Description +** Display the contents of a packet. The contents is displayed as a +** series of bytes in hexadecimal. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param[in] ptr Pointer to packet to display +** +** \param[in] size Size of packet in bytes +** +** \returns +** This function does not return a value. +** +******************************************************************************/ +void UT_DisplayPkt(CFE_MSG_Message_t *MsgPtr, size_t size); + +/*****************************************************************************/ +/** +** \brief Gets a reference to the CFE ES Reset Data Object +** +** \par Description +** Some CFE test casess may need to check or modify the reset data +** that is maintained by CFE ES. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** Pointer to simulated reset data object +** +******************************************************************************/ +CFE_ES_ResetData_t *UT_GetResetDataPtr(void); + + +/*****************************************************************************/ +/** +** \brief Add a test as a member of a subgroup. +** +** \par Description +** Allow tests to be grouped together +** +** This is just a wrapper around UtTest_Add() that registers +** a test with a "GroupName.TestName" convention. Purely an +** organizational/identification helper for units which have +** lots of tests. +** +** \par Assumptions, External Events, and Notes: +** None +** +******************************************************************************/ +void UT_AddSubTest(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), + const char *GroupName, const char *TestName); + +/** \brief Function to be called by the SETUP() macro */ +void UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); + +/*****************************************************************************/ +/** +** \brief Checks the successful execution of a setup function. +** +** \par Description +** Many tests require a number of steps of setup to configure CFE such +** that the actual test can be performed. Failure of any setup steps +** result in a text message and the test being considered failed. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** +******************************************************************************/ +#define SETUP(FN) (UT_SETUP_impl(__FILE__, __LINE__, __func__, (#FN), (FN))) + +/** \brief Function to be called by the ASSERT() macro */ +void UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); + +/*****************************************************************************/ +/** +** \brief Asserts the nominal execution of the function being tested. +** +** \par Description +** The core of each unit test is the execution of the function being tested. +** This function and macro should be used to test the nominal execution of the +** function; the expectation is that it will return CFE_SUCCESS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #SETUP, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** +******************************************************************************/ +#define ASSERT(FN) (UT_ASSERT_impl(__FILE__, __LINE__, __func__, (#FN), (FN))) + +/** \brief Function to be called by the ASSERT_EQ() macro */ +void UT_ASSERT_EQ_impl(const char *FileName, int LineNum, + const char *FnName, int32 FnRet, const char *ExpName, int32 Exp); + +/*****************************************************************************/ +/** +** \brief Asserts the expected execution of the function being tested. +** +** \par Description +** The core of each unit test is the execution of the function being tested. +** This function and macro should be used to test the execution of the function +** and comparing the return status against the expected return status specified, +** when the return status expected is not CFE_SUCCESS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #SETUP, #ASSERT, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** +******************************************************************************/ +#define ASSERT_EQ(FN,EXP) (UT_ASSERT_EQ_impl(__FILE__, __LINE__, (#FN), (FN), (#EXP), (EXP))) + + +/** \brief Function to be called by the ASSERT_EQ() macro */ +void UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, + const char *ExpName, bool Exp); + +/*****************************************************************************/ +/** +** \brief Asserts the expected execution of the function being tested. +** +** \par Description +** The core of each unit test is the execution of the function being tested. +** This function and macro should be used to test the execution of the function +** and comparing the return status against the expected return status specified, +** when the return status expected is not CFE_SUCCESS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #SETUP, #ASSERT, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** +******************************************************************************/ +#define ASSERT_TRUE(EXP) (UT_ASSERT_TRUE_impl(__FILE__, __LINE__, __func__, (#EXP), (EXP))) + +/** \brief Function to be called by the EVTCNT() macro */ +void UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp); + +/*****************************************************************************/ +/** +** \brief Ensures that the test generated the expected number of events. +** +** \par Description +** Most tests will generate a number of events, and the number generated +** should be checked via this macro. If the number of events is different, +** the test is considered to have failed and an error is reported. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTSENT, #REPORT, #TEARDOWN +** +******************************************************************************/ +#define EVTCNT(EXP) (UT_EVTCNT_impl(__FILE__, __LINE__, __func__, (EXP))) + +/** \brief Function to be called by the EVTSENT() macro */ +void UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId); + +/*****************************************************************************/ +/** +** \brief Ensures that the test generated the expected event. +** +** \par Description +** Most tests will generate a number of events, and this function and macro check whether an +** event was generated. If not, the test is considered to have failed and an error is reported. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #REPORT, #TEARDOWN +** +******************************************************************************/ +#define EVTSENT(EVT) (UT_EVTSENT_impl(__FILE__, __LINE__, __func__, (#EVT), (EVT))) + +/** \brief Function to be called by the TEARDOWN() macro */ +void UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); +/*****************************************************************************/ +/** +** \brief Checks the successful execution of a teardown function. +** +** \par Description +** Many tests require a number of steps of setup to configure CFE such that the actual test +** can be performed, and undoing that configuration is the role of the teardown steps. Failure +** of any teardown steps result in a text message and the test being considered failed. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT +** +******************************************************************************/ +#define TEARDOWN(FN) (UT_TEARDOWN_impl(__FILE__, __LINE__, __func__, (#FN), (FN))) + +#endif /* __UT_STUBS_H_ */ diff --git a/modules/cfe_internal_intf/ut-stubs/src/ut_osprintf_stubs.c b/modules/cfe_internal_intf/ut-stubs/src/ut_osprintf_stubs.c new file mode 100644 index 000000000..ffbf45f48 --- /dev/null +++ b/modules/cfe_internal_intf/ut-stubs/src/ut_osprintf_stubs.c @@ -0,0 +1,168 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_osprintf_stubs.c +** +** Purpose: +** Unit test stubs for Operating System routines +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ + +#include "ut_support.h" +#include "ut_osprintf_stubs.h" + + +/* +** Global variables +*/ + +const char *UT_OSP_MESSAGES[] = +{ + [0] = NULL, /* Message 0 is reserved */ + /* ES Startup: Error Mounting Volatile(RAM) Volume. EC = 0x~ */ + [UT_OSP_MOUNT_VOLATILE] = "ES Startup: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + /* CFE_ES_ExitApp: CORE Application CFE_ES Had a Runtime Error. */ + [UT_OSP_CORE_RUNTIME] = "CFE_ES_ExitApp: CORE Application %s Had a Runtime Error.\n", + /* ES:Call to CFE_ES_RegisterApp Failed, RC = 0x~ */ + [UT_OSP_REGISTER_APP] = "ES:Call to CFE_ES_RegisterApp Failed, RC = 0x%08X\n", + /* ES Startup: OS_TaskCreate error creating core App: CFE_TBL: EC = 0x~ */ + [UT_OSP_CORE_APP_CREATE] = "ES Startup: OS_TaskCreate error creating core App: %s: EC = 0x%08X\n", + /* ES Startup: Error returned when calling function: CFE_TBL_EarlyInit: EC = 0x~ */ + [UT_OSP_EARLYINIT] = "ES Startup: Error returned when calling function: %s: EC = 0x%08X\n", + /* ES Startup: Could not find Library Init symbol:TST_LIB_Init. EC = 0x~ */ + [UT_OSP_FIND_LIBRARY] = "ES Startup: Could not find Library Init symbol:%s. EC = %d\n", + /* POWER ON RESET due to max proc resets (HW Spec Cmd). */ + [UT_OSP_POR_MAX_HW_SPECIAL] = "POWER ON RESET due to max proc resets (HW Spec Cmd).\n", + /* CFE_ES_ExitChildTask Error: Cannot Call from a cFE App Main Task. ID = ~ */ + [UT_OSP_CANNOT_CALL_APP_MAIN] = "CFE_ES_ExitChildTask Error: Cannot Call from a cFE App Main Task. ID = %d\n", + /* ES Startup: bad function pointer ( table entry = 1). */ + [UT_OSP_FUNCTION_POINTER] = "ES Startup: bad function pointer ( table entry = %d).\n", + /* ES Startup: Error Reading Startup file. EC = 0x~ */ + [UT_OSP_STARTUP_READ] = "ES Startup: Error Reading Startup file. EC = 0x%08X\n", + /* PROCESSOR RESET called from CFE_ES_ResetCFE (Commanded). */ + [UT_OSP_PROC_RESET_COMMANDED] = "PROCESSOR RESET called from CFE_ES_ResetCFE (Commanded).\n", + /* ES SharedData Mutex Take Err Stat=0x~,App=1,Func=TestAPI,Line=12345 */ + [UT_OSP_MUTEX_TAKE] = "ES SharedData Mutex Take Err Stat=0x%x,Func=%s,Line=%d\n", + /* ES Startup: Startup Sync failed - Applications may not have all started */ + [UT_OSP_STARTUP_SYNC_FAIL_1] = "ES Startup: Startup Sync failed - Applications may not have all started\n", + /* Warning: System Log full, log entry discarded. */ + [UT_OSP_SYSTEM_LOG_FULL] = "Warning: System Log full, log entry discarded.\n", + /* ES Startup: ES Startup File Line is too long: 137 bytes. */ + [UT_OSP_FILE_LINE_TOO_LONG] = "ES Startup: ES Startup File Line is too long: %u bytes.\n", + /* ES Startup: Load Shared Library Init Error. */ + [UT_OSP_SHARED_LIBRARY_INIT] = "ES Startup: Load Shared Library Init Error = 0x%08x\n", + /* ES Startup: Error Removing Volatile(RAM) Volume. EC = 0x~ */ + [UT_OSP_REMOVE_VOLATILE] = "ES Startup: Error Removing Volatile(RAM) Volume. EC = 0x%08X\n", + /* POWER ON RESET due to other cause (See Subtype). */ + [UT_OSP_POR_OTHER] = "POWER ON RESET due to other cause (See Subtype).\n", + /* ES Startup: Error Determining Blocks Free on Volume. EC = 0x~ */ + [UT_OSP_DETERMINE_BLOCKS] = "ES Startup: Error Determining Blocks Free on Volume. EC = 0x%08X\n", + /* ES Startup: Startup Sync failed - Applications may not have all initialized */ + [UT_OSP_STARTUP_SYNC_FAIL_2] = "ES Startup: Startup Sync failed - Applications may not have all initialized\n", + /* ES Startup: No free library slots available */ + [UT_OSP_LIBRARY_SLOTS] = "ES Startup: No free library slots available\n", + /* ES Startup: Unable to extract filename from path: ut/filename.gz. */ + [UT_OSP_EXTRACT_FILENAME_UT] = "ES Startup: Unable to extract filename from path: %s.\n", + /* ES Startup: Application path plus file name length (~) exceeds max allowed (~) */ + [UT_OSP_APP_PATH_FILE_TOO_LONG] = "ES Startup: Application path plus file name length (%d) exceeds max allowed (%d)\n", + /* ES Startup: Error Re-Formating Volatile(RAM) Volume. EC = 0x~ */ + [UT_OSP_REFORMAT_VOLATILE] = "ES Startup: Error Re-Formating Volatile(RAM) Volume. EC = 0x%08X\n", + /* ES Startup: Could not load cFE application file:ut/filename.x. EC = 0x~ */ + [UT_OSP_EXTRACT_FILENAME_UT55] = "ES Startup: Could not load file:%s. EC = 0x%08X\n", + /* ES Startup: Unable to extract filename from path: ut46/ */ + [UT_OSP_EXTRACT_FILENAME_UT46] = "ES Startup: Unable to extract filename from path: %s.\n", + /* ES Startup: No free application slots available */ + [UT_OSP_NO_FREE_APP_SLOTS] = "ES Startup: No free application slots available\n", + /* ES Startup: Unable to extract filename from path: ut57/ */ + [UT_OSP_EXTRACT_FILENAME_UT57] = "ES Startup: Unable to extract filename from path: %s.\n", + /* ES SharedData Mutex Give Err Stat=0x~,App=1,Func=TestAPI,Line=98765 */ + [UT_OSP_MUTEX_GIVE] = "ES SharedData Mutex Give Err Stat=0x%x,Func=%s,Line=%d\n", + /* ES Startup: Could not find symbol:EntryPoint. EC = 0x~ */ + [UT_OSP_CANNOT_FIND_SYMBOL] = "ES Startup: Could not find symbol:%s. EC = 0x%08X\n", + /* ES Startup: Error Initializing Volatile(RAM) Volume. EC = 0x~ */ + [UT_OSP_INIT_VOLATILE] = "ES Startup: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n", + /* ES:Application Init Failed,RC=0x~ */ + [UT_OSP_APP_INIT] = "ES:Application Init Failed,RC=0x%08X\n", + /* POWER ON RESET due to max proc resets (Commanded). */ + [UT_OSP_POR_MAX_PROC_RESETS] = "POWER ON RESET due to max proc resets (Commanded).\n", + /* CFE_ES_RestartApp: Cannot Restart Application appName, It is not running. */ + [UT_OSP_CANNOT_RESTART_APP] = "CFE_ES_RestartApp: Cannot Restart Application %s, It is not running.\n", + /* ES Startup: Insufficent Free Space on Volatile Disk, Reformatting. */ + [UT_OSP_INSUFF_FREE_SPACE] = "ES Startup: Insufficent Free Space on Volatile Disk, Reformatting.\n", + /* ES Startup: Could not load cFE Shared Library */ + [UT_OSP_LOAD_SHARED_LIBRARY] = "ES Startup: Could not load cFE Shared Library\n", + /* POWER ON RESET due to HW Special Cmd (Hw Spec Cmd). */ + [UT_OSP_POR_HW_SPECIAL] = "POWER ON RESET due to HW Special Cmd (Hw Spec Cmd).\n", + /* ES Startup: AppCreate Error: TaskCreate AppName Failed. EC = 0x~! */ + [UT_OSP_APP_CREATE] = "ES Startup: AppCreate Error: TaskCreate %s Failed. EC = 0x%08X!\n", + /* ES Startup: Error Creating Volatile(RAM) Volume. EC = 0x~ */ + [UT_OSP_CREATE_VOLATILE] = "ES Startup: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n", + /* ES Startup: Failed to unload APP: AppName. EC = 0x~ */ + [UT_OSP_MODULE_UNLOAD_FAILED] = "ES Startup: Failed to unload: %s. EC = 0x%08X\n", + /* POWERON RESET called from CFE_ES_ResetCFE (Commanded). */ + [UT_OSP_POR_COMMANDED] = "POWERON RESET called from CFE_ES_ResetCFE (Commanded).\n", + /* ES Startup: Error Re-Mounting Volatile(RAM) Volume. EC = 0x~ */ + [UT_OSP_REMOUNT_VOLATILE] = "ES Startup: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + /* CFE_ES_ExitApp, Cannot Exit CORE Application CFE_ES */ + [UT_OSP_CORE_APP_EXIT] = "CFE_ES_ExitApp, Cannot Exit CORE Application %s\n", + /* ES Startup: Opened ES App Startup file: */ + [UT_OSP_ES_APP_STARTUP_OPEN] = "ES Startup: Opened ES App Startup file: %s\n", + /* CFE_ES_ExitApp: CORE Application CFE_ES Had an Init Error. */ + [UT_OSP_CORE_INIT] = "CFE_ES_ExitApp: CORE Application %s Had an Init Error.\n", + /* PROCESSOR RESET due to Hardware Special Command (HW Spec Cmd). */ + [UT_OSP_PROC_RESET_MAX_HW_SPECIAL] = "PROCESSOR RESET due to Hardware Special Command (HW Spec Cmd).\n", + /* ES:Error reading cmd pipe,RC=0x~ */ + [UT_OSP_COMMAND_PIPE] = "ES:Error reading cmd pipe,RC=0x%08X\n", + /* ES Startup: Error Un-Mounting Volatile(RAM) Volume. EC = 0x~ */ + [UT_OSP_UNMOUNT_VOLATILE] = "ES Startup: Error Un-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + /* ES Startup: Error: ES_TaskTable slot in use at task creation! */ + [UT_OSP_TABLE_SLOT_IN_USE] = "ES Startup: Error: ES_TaskTable slot in use at task creation!\n", + /* ES Startup: Error, Can't Open ES App Startup file: */ + [UT_OSP_CANNOT_OPEN_ES_APP_STARTUP] = "ES Startup: Error, Can't Open ES App Startup file: %s EC = 0x%08X\n", + /* ES Startup: Unable to extract filename from path: /cf/apps/tst_lib.bundle.gz. */ + [UT_OSP_EXTRACT_FILENAME_CF] = "ES Startup: Unable to extract filename from path: %s.\n", + /* Warning: Invalid System Log mode, log entry discarded. */ + [UT_OSP_INVALID_LOG_MODE] = "Warning: Invalid System Log mode, log entry discarded.\n", + /* ES Startup: Library path plus file name length (~) exceeds max allowed (~) */ + [UT_OSP_LIB_PATH_FILE_TOO_LONG] = "ES Startup: Library path plus file name length (%d) exceeds max allowed (%d)\n", + /* ES Startup: Unable to decompress Application File: ut/filename.gz */ + [UT_OSP_DECOMPRESS_APP] = "ES Startup: Unable to decompress Application File: %s\n", + /* ES Startup: Unable to decompress library file: /cf/apps/tst_lib.bundle.gz */ + [UT_OSP_DECOMPRESS_LIBRARY] = "ES Startup: Unable to decompress library file: %s\n", + /* CFE_ES_ExitChildTask Error Calling CFE_ES_GetAppID. Task ID = ~, RC = 0x~ */ + [UT_OSP_GET_APP_ID] = "CFE_ES_ExitChildTask Error Calling CFE_ES_GetAppID. Task ID = %d, RC = 0x%08X\n", + /* ES Startup: Error, No free application slots available for CORE App! */ + [UT_OSP_NO_FREE_CORE_APP_SLOTS] = "ES Startup: Error, No free application slots available for CORE App!\n", + /* ES Startup: CFE_ES_Global.TaskTable record used error for App: CFE_EVS, continuing. */ + [UT_OSP_RECORD_USED] = "ES Startup: Error: ES_TaskTable slot for ID %lx in use at task creation!\n", + /* CFE_ES_ExitChildTask called from invalid task context */ + [UT_OSP_TASKEXIT_BAD_CONTEXT] = "CFE_ES_ExitChildTask called from invalid task context\n", + [UT_OSP_BACKGROUND_REGISTER] = "CFE_ES: Background Task Failed to register: %08lx\n", + [UT_OSP_BACKGROUND_TAKE] = "CFE_ES: Failed to take background sem: %08lx\n", +}; + diff --git a/modules/cfe_internal_intf/ut-stubs/src/ut_support.c b/modules/cfe_internal_intf/ut-stubs/src/ut_support.c new file mode 100644 index 000000000..79d123557 --- /dev/null +++ b/modules/cfe_internal_intf/ut-stubs/src/ut_support.c @@ -0,0 +1,753 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: ut_support.c +** +** Purpose: +** Unit test stubs +** +** Notes: +** Minimal work is done, only what is required for unit testing +** +*/ + +/* +** Includes +*/ +#include "ut_support.h" + +#include + +/* +** Global variables +*/ +uint8 UT_Endianess; + +static char UT_appname[80]; +static char UT_subsys[5]; +static CFE_ES_AppId_t UT_AppID; +static uint32 UT_LastCDSSize = 0; + +typedef union +{ + long long int AlignLong; + long double AlignDbl; + void *AlignPtr; + char Content[128 * 1024]; +} UT_Buffer_t; + +static UT_Buffer_t UT_CFE_ES_MemoryPool; +static UT_Buffer_t UT_CDS_Data; +static UT_Buffer_t UT_SyslogBuffer; +static UT_Buffer_t UT_PrintfBuffer; +static union +{ + UT_Buffer_t Buff; + CFE_ES_ResetData_t ResetData; +} UT_CFE_ES_ResetData; + +static uint16 UT_SendEventHistory[UT_EVENT_HISTORY_SIZE]; +static uint16 UT_SendTimedEventHistory[UT_EVENT_HISTORY_SIZE]; +static uint16 UT_SendEventAppIDHistory[UT_EVENT_HISTORY_SIZE * 10]; + + +extern int32 dummy_function(void); + +/* +** Functions +*/ +/* +** Initialize unit test +*/ +void UT_Init(const char *subsys) +{ + int8 i; + + /* Copy the application name for later use */ + strncpy(UT_subsys, subsys, sizeof(UT_subsys)-1); + UT_subsys[sizeof(UT_subsys)-1] = 0; + snprintf(UT_appname, 80, "ut_cfe_%s", subsys); + + /* Convert to upper case */ + for (i = 0; i < strlen(UT_subsys); ++i) + { + if (UT_subsys[i] >= 'a' && UT_subsys[i] <= 'z') + { + UT_subsys[i] = (UT_subsys[i] - 'a') + 'A'; + } + } + + UT_InitData(); + + /* + * NOTE: There are some UT cases in TBL that are dependent on + * the endianness of the local CPU. This "endian check" exists + * to provide hints to the test code. + * + * All endian-specific code should be replaced with endian-neutral + * code in future versions. This check will be removed in a future + * version once that is complete. No new test code should use this. + */ + int32 EndianCheck = 0x01020304; + + if ((*(char *) &EndianCheck) == 0x04) + { + UT_Endianess = UT_LITTLE_ENDIAN; + } + else + { + UT_Endianess = UT_BIG_ENDIAN; + } + +} + +/* +** Initialize unit test variables +*/ +void UT_InitData(void) +{ + /* + * Purge all entries in the entire stub table + */ + UT_ResetState(0); + + /* + * Set up entries to capture Events and Syslog writes + * These are frequently needed by many tests + */ + UT_SyslogBuffer.AlignLong = 0; + UT_SetDataBuffer(UT_KEY(CFE_ES_WriteToSysLog), &UT_SyslogBuffer, sizeof(UT_SyslogBuffer), false); + + UT_PrintfBuffer.AlignLong = 0; + UT_SetDataBuffer(UT_KEY(OS_printf), &UT_PrintfBuffer, sizeof(UT_PrintfBuffer), false); + + + /* + * Set up the CFE_ES reset area + */ + UT_SetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), &UT_CFE_ES_ResetData, sizeof(UT_CFE_ES_ResetData), false); + + /* + * Set up the CDS area + */ + UT_SetCDSSize(UT_LastCDSSize); + + /* + * Set up for the CFE_SB_ReceiveBuffer() call. + * + * The existing test cases assume that this will return success once, + * followed by a timeout response. + * + * Specific test cases may provide an actual message buffer to return for + * the first call, or they may override this default behavior entirely. + */ + UT_SetDeferredRetcode(UT_KEY(CFE_SB_ReceiveBuffer), 2, CFE_SB_TIME_OUT); + + /* + * Set up CFE_ES_GetAppName() and friends + * This should return the UT_appname + */ + UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppName), (uint8*)UT_appname, sizeof(UT_appname), false); + + /* + * Reset the OSAL stubs to the default state + */ + OS_API_Init(); + + UT_ClearEventHistory(); + UT_ResetPoolBufferIndex(); + +} + +void UT_ResetCDS(void) +{ + memset(&UT_CDS_Data, 0, sizeof(UT_CDS_Data)); +} + +/* +** Reset pool buffer index +*/ +void UT_ResetPoolBufferIndex(void) +{ + /* + * Initialize the buffer which ES mempool will allocate from + * Set the whole memory space to a pattern. + */ + UT_ResetState(UT_KEY(CFE_ES_GetPoolBuf)); + UT_SetDataBuffer(UT_KEY(CFE_ES_GetPoolBuf), &UT_CFE_ES_MemoryPool, sizeof(UT_CFE_ES_MemoryPool), false); +} + +/* +** Output single test's pass/fail status +*/ +void UT_Report(const char *file, uint32 line, bool test, const char *fun_name, + const char *info) +{ + UtAssertEx(test, UtAssert_GetContext(), file, line, "%s - %s", fun_name, + info); +} + +/* +** Calls the specified "task pipe" function +** +** This first sets up the various stubs according to the test case, +** then invokes the pipe function. +*/ +void UT_CallTaskPipe(void (*TaskPipeFunc)(CFE_SB_Buffer_t *), CFE_MSG_Message_t *MsgPtr, size_t MsgSize, + UT_TaskPipeDispatchId_t DispatchId) +{ + union + { + CFE_SB_Buffer_t Buf; + uint8 Bytes[CFE_MISSION_SB_MAX_SB_MSG_SIZE]; + } SBBuf; + + /* Copy message into aligned SB buffer */ + memcpy(SBBuf.Bytes, MsgPtr, MsgSize); + + /* Set up for the typical task pipe related calls */ + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &DispatchId.MsgId, sizeof(DispatchId.MsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &DispatchId.CommandCode, sizeof(DispatchId.CommandCode), false); + + /* If 0 size passed in, set buffers for calls in the command length failure reporting */ + if (MsgSize == 0) + { + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &DispatchId.MsgId, sizeof(DispatchId.MsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &DispatchId.CommandCode, sizeof(DispatchId.CommandCode), false); + } + + /* + * Finally, call the actual task pipe requested. + */ + TaskPipeFunc(&SBBuf.Buf); +} + +int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) +{ + UT_SoftwareBusSnapshot_Entry_t *Snapshot = UserObj; + const CFE_MSG_Message_t *MsgPtr; + + if (Context->ArgCount > 0) + { + MsgPtr = Context->ArgPtr[0]; + } + else + { + MsgPtr = NULL; + } + + if (MsgPtr != NULL && Snapshot != NULL) + { + ++Snapshot->Count; + if (Snapshot->SnapshotSize > 0 && Snapshot->SnapshotBuffer != NULL) + { + memcpy(Snapshot->SnapshotBuffer, &MsgPtr->Byte[Snapshot->SnapshotOffset], + Snapshot->SnapshotSize); + } + } + + return StubRetcode; +} + +/* +** Set the application ID returned by unit test stubs +*/ +void UT_SetAppID(CFE_ES_AppId_t AppID_in) +{ + UT_AppID = AppID_in; + UT_SetDataBuffer(UT_KEY(CFE_ES_GetAppID), (uint8*)&UT_AppID, sizeof(UT_AppID), false); +} + +/* +** Set the return code of CFE_PSP_GetResetArea and the data validation +** signature +*/ +void UT_SetStatusBSPResetArea(int32 status, uint32 Signature, uint32 ClockSignal) +{ + UT_CFE_ES_ResetData.ResetData.TimeResetVars.Signature = Signature; + UT_CFE_ES_ResetData.ResetData.TimeResetVars.ClockSignal = ClockSignal; + if (status != 0) + { + UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_GetResetArea), status); + } + else + { + UT_ClearDefaultReturnValue(UT_KEY(CFE_PSP_GetResetArea)); + } +} + +/* +** Set the contents of the buffer to read +*/ +void UT_SetReadBuffer(void *Buff, int NumBytes) +{ + UT_SetDataBuffer(UT_KEY(OS_read), Buff, NumBytes, true); +} + +/* +** Set the contents of the header to read +*/ +void UT_SetReadHeader(void *Hdr, int NumBytes) +{ + UT_SetDataBuffer(UT_KEY(CFE_FS_ReadHeader), Hdr, NumBytes, true); +} + +/* +** Set the dummy function return code +*/ +void UT_SetDummyFuncRtn(int Return) +{ + UT_SetDefaultReturnValue(UT_KEY(dummy_function), Return); +} + +/* +** Set the size of the ES reset area +*/ +void UT_SetSizeofESResetArea(int32 Size) +{ + UT_ResetState(UT_KEY(CFE_PSP_GetResetArea)); + if (Size > 0) + { + if (Size > sizeof(UT_CFE_ES_ResetData)) + { + UtAssert_Abort("Reset area size too large"); + Size = sizeof(UT_CFE_ES_ResetData); + } + UT_SetDataBuffer(UT_KEY(CFE_PSP_GetResetArea), &UT_CFE_ES_ResetData, Size, false); + } +} + +/* +** Set the CDS size returned by the BSP +*/ +uint8* UT_SetCDSSize(int32 Size) +{ + UT_ResetState(UT_KEY(CFE_PSP_GetCDSSize)); + UT_ResetState(UT_KEY(CFE_PSP_ReadFromCDS)); + UT_ResetState(UT_KEY(CFE_PSP_WriteToCDS)); + if (Size <= 0) + { + UT_LastCDSSize = 0; + return NULL; + } + + if (Size > sizeof(UT_CDS_Data)) + { + UtAssert_Abort("Size of CDS too large"); + Size = sizeof(UT_CDS_Data); + } + UT_SetDataBuffer(UT_KEY(CFE_PSP_GetCDSSize), &UT_CDS_Data, Size, false); + UT_SetDataBuffer(UT_KEY(CFE_PSP_ReadFromCDS), &UT_CDS_Data, Size, false); + UT_SetDataBuffer(UT_KEY(CFE_PSP_WriteToCDS), &UT_CDS_Data, Size, false); + UT_LastCDSSize = Size; + return (uint8*)UT_CDS_Data.Content; +} + +/* +** Set BSP time +*/ +void UT_SetBSP_Time(uint32 seconds, uint32 microsecs) +{ + OS_time_t BSP_Time; + + BSP_Time = OS_TimeAssembleFromNanoseconds(seconds, microsecs * 1000); + + UT_SetDataBuffer(UT_KEY(CFE_PSP_GetTime), &BSP_Time, sizeof(BSP_Time), true); +} + +void UT_ClearEventHistory(void) +{ + UT_ResetState(UT_KEY(CFE_EVS_SendEvent)); + UT_ResetState(UT_KEY(CFE_EVS_SendEventWithAppID)); + UT_ResetState(UT_KEY(CFE_EVS_SendTimedEvent)); + UT_SetDataBuffer(UT_KEY(CFE_EVS_SendEvent), UT_SendEventHistory, sizeof(UT_SendEventHistory), false); + UT_SetDataBuffer(UT_KEY(CFE_EVS_SendTimedEvent), UT_SendTimedEventHistory, sizeof(UT_SendTimedEventHistory), false); + UT_SetDataBuffer(UT_KEY(CFE_EVS_SendEventWithAppID), UT_SendEventAppIDHistory, sizeof(UT_SendEventAppIDHistory), false); +} + +static bool UT_CheckEventHistoryFromFunc(UT_EntryKey_t Func, uint16 EventIDToSearchFor) +{ + bool Result = false; + size_t Position; + size_t MaxSize; + uint16 *EvBuf; + + UT_GetDataBuffer(Func, (void**)&EvBuf, &MaxSize, &Position); + if (EvBuf != NULL && MaxSize > 0) + { + Position /= sizeof(*EvBuf); + while (Position > 0) + { + if (*EvBuf == EventIDToSearchFor) + { + Result = true; + break; + } + ++EvBuf; + --Position; + } + } + + return Result; +} + + +/* +** Search the event history for a specified event ID +*/ +bool UT_EventIsInHistory(uint16 EventIDToSearchFor) +{ + return (UT_CheckEventHistoryFromFunc(UT_KEY(CFE_EVS_SendEvent),EventIDToSearchFor) || + UT_CheckEventHistoryFromFunc(UT_KEY(CFE_EVS_SendEventWithAppID),EventIDToSearchFor) || + UT_CheckEventHistoryFromFunc(UT_KEY(CFE_EVS_SendTimedEvent),EventIDToSearchFor)); +} + +/* +** Return number of events issued +*/ +uint16 UT_GetNumEventsSent(void) +{ + uint16 Total = 0; + size_t Position; + size_t MaxSize; + void *EvBuf; + + UT_GetDataBuffer(UT_KEY(CFE_EVS_SendEvent), &EvBuf, &MaxSize, &Position); + Total += Position / sizeof(uint16); + UT_GetDataBuffer(UT_KEY(CFE_EVS_SendEventWithAppID), &EvBuf, &MaxSize, &Position); + Total += Position / sizeof(uint16); + UT_GetDataBuffer(UT_KEY(CFE_EVS_SendTimedEvent), &EvBuf, &MaxSize, &Position); + Total += Position / sizeof(uint16); + + return Total; +} + +/* +** Display the contents of a packet +*/ +void UT_DisplayPkt(CFE_MSG_Message_t *MsgPtr, size_t size) +{ + uint8 *BytePtr = MsgPtr->Byte; + size_t i; + size_t BufSize = UT_MAX_MESSAGE_LENGTH; + char DisplayMsg[UT_MAX_MESSAGE_LENGTH]; + char *msgPtr = DisplayMsg; + + DisplayMsg[0] = '\0'; + + for (i = 0; i < size && BufSize > 3; i++) + { + snprintf(msgPtr, BufSize, "%02x ", *BytePtr); + msgPtr += 3; + BufSize -= 3; + ++BytePtr; + } + + UtPrintf("%s", DisplayMsg); +} + + +CFE_ES_ResetData_t *UT_GetResetDataPtr(void) +{ + return &UT_CFE_ES_ResetData.ResetData; +} + +/* +** Compare two strings using printf-style conversion specifiers. +** +** Determines if the TestStr could have been an output from a printf-style call +** using FormatStr. Common conversions specifiers in FormatStr are recognized: +** %c, %d, %f, %F, %g, %G, %i, %u, %s, %p, %x, %X, and %% +** +** To keep it simple this just skips over the conversion specifier entirely, +** it does not validate whether the content of the string could have come from +** that conversion specifier or not. In essence any conversion specifier is +** treated as a wildcard that matches any string. +** +** HOWEVER - this could be enhanced in the future, if necessary, to actually +** perform that validation by e.g. passing the string to "sscanf()" or similar +** and checking if the reverse conversion was successful. +** +** NOTE this logic is not foolproof - particularly where %s is in use, as the +** content of the string could alias the next part of the format string. +** This does not seem to be an issue for the strings generated by CFE. +** +** But on the upside this concession avoids a far more complicated issue of +** needing a fully-fledged implementation of printf in the OS_printf stub. +*/ +static int UT_StrCmpFormatStr(const char *FormatStr, const char *TestStr, uint32 FormatLength, uint32 TestLength) +{ + const char *ChunkStart; + const char *ChunkEnd; + const char *TestStart; + int WildCard; + int MatchGood; + size_t ChunkLen; + + /* Step through each character in both strings */ + ChunkStart = FormatStr; + TestStart = TestStr; + WildCard = 1; + MatchGood = 1; + while (FormatLength > 0) + { + if (*ChunkStart == '%') + { + /* At a Conversion specifier - Find the END of it */ + do + { + --FormatLength; + ++ChunkStart; + } + while (FormatLength > 0 && strchr("%cdfFgGiuspxX ",*ChunkStart) == NULL); + + if (FormatLength == 0) + { + /* Invalid format string */ + MatchGood = 0; + break; + } + + if (*ChunkStart != '%') + { + WildCard = 1; + ++ChunkStart; + --FormatLength; + } + else if (TestLength > 0 && *TestStart == '%') + { + MatchGood = 1; + ++TestStart; + --TestLength; + } + else + { + /* Insufficient length on TestString */ + MatchGood = 0; + break; + } + } + else + { + /* Matchable content - Find the NEXT conversion specifier in the format string */ + MatchGood = 0; + ChunkEnd = memchr(ChunkStart, '%', FormatLength); + if (ChunkEnd != NULL) + { + ChunkLen = ChunkEnd - ChunkStart; + } + else + { + ChunkLen = FormatLength; + } + + while (TestLength >= ChunkLen) + { + if (memcmp(ChunkStart, TestStart, ChunkLen) == 0) + { + MatchGood = 1; + break; + } + if (!WildCard) + { + break; + } + ++TestStart; + --TestLength; + } + + if (!MatchGood) + { + break; + } + + WildCard = 0; + ChunkStart += ChunkLen; + TestStart += ChunkLen; + TestLength -= ChunkLen; + FormatLength -= ChunkLen; + } + } + + return MatchGood; +} + +/* + * A string comparison function that will match exact strings only + * (Printf style conversion strings are compared literally) + */ +static int UT_StrCmpExact(const char *RefStr, const char *TestStr, uint32 RefLength, uint32 TestLength) +{ + return (RefLength == TestLength && memcmp(RefStr, TestStr, RefLength) == 0); +} + +static uint32 UT_GetMessageCount(const char *Msg, UT_Buffer_t *Buf, + int (*Comparator)(const char *, const char *, uint32, uint32)) +{ + uint32 Count = 0; + uint32 MsgLen = strlen(Msg); + char *Start = Buf->Content; + char *End; + + while (MsgLen > 0 && Msg[MsgLen-1] == '\n') + { + --MsgLen; + } + + while(1) + { + End = strchr(Start, '\n'); + if (End == NULL) + { + End = Start + strlen(Start); + } + + if (Start == End) + { + break; + } + + if (Comparator(Msg, Start, MsgLen, End - Start)) + { + ++Count; + } + + if (*End == 0) + { + break; + } + + Start = End + 1; + } + + return Count; +} + +uint32 UT_SyslogIsInHistory(const char *LogMsgToSearchFor) +{ + return UT_GetMessageCount(LogMsgToSearchFor, &UT_SyslogBuffer, UT_StrCmpExact); +} + +uint32 UT_PrintfIsInHistory(const char *MsgToSearchFor) +{ + return UT_GetMessageCount(MsgToSearchFor, &UT_PrintfBuffer, UT_StrCmpFormatStr); +} + +void UT_AddSubTest(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), const char *GroupName, const char *TestName) +{ + char CompleteTestName[128]; + const char *GroupPtr; + const char *TestPtr; + + /* Remove any common prefix between the two names. + * They are often function names that all start with "Test_XXX" + * and this repetitive information just becomes clutter. + */ + GroupPtr = GroupName; + TestPtr = TestName; + while (*GroupPtr != 0 && *GroupPtr == *TestPtr) + { + ++GroupPtr; + ++TestPtr; + } + + /* + * Only break at an underscore(_) to avoid weird effects + */ + while(TestPtr > TestName && *TestPtr != '_') + { + --TestPtr; + } + if (*TestPtr == '_') + { + ++TestPtr; + } + + /* + * Remove a remaining "Test_" prefix on the group name. + * Again just to remove common repetitive content + */ + GroupPtr = GroupName; + if (strncmp(GroupPtr, "Test_", 5) == 0) + { + GroupPtr += 5; + } + + (void)snprintf(CompleteTestName, sizeof(CompleteTestName), "%s.%s", GroupPtr, TestPtr); + + /* + * Note that UtTest_Add() does not copy the string - it retains the passed-in pointer. + * Therefore it must be duplicated. + * + * This isn't an issue on Linux as the memory is freed when the process exits, but + * might be an issue on VxWorks. + */ + + UtTest_Add(Test, Setup, Teardown, strdup(CompleteTestName)); +} + +void UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +{ + UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TSF, FileName, LineNum, "%s - Setup - %s returned 0x%lx", + TestName, FnName, (long int)FnRet); +} + +void UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +{ + UtAssertEx(FnRet == CFE_SUCCESS, UtAssert_GetContext(), FileName, LineNum, "%s - %s returned 0x%lx, expected CFE_SUCCESS", + TestName, FnName, (long int)FnRet); +} + +void UT_ASSERT_EQ_impl(const char *FileName, int LineNum, + const char *FnName, int32 FnRet, const char *ExpName, int32 Exp) +{ + UtAssertEx(FnRet == Exp, UtAssert_GetContext(), FileName, LineNum, "%s - value %ld 0x%lx, expected %s[%ld 0x%lx]", + FnName, (long)FnRet, (long)FnRet, ExpName, (long)Exp, (long)Exp); +} + +void UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, + const char *ExpName, bool Exp) +{ + UtAssertEx(Exp, UtAssert_GetContext(), FileName, LineNum, "%s - %s", + TestName, ExpName); +} + +void UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp) +{ + int32 CntSent = UT_GetNumEventsSent(); + + UtAssertEx(CntSent == CntExp, UtAssert_GetContext(), FileName, LineNum, "%s - event count (sent %ld, expected %ld)", + TestName, (long int)CntSent, (long int)CntExp); +} + +void UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId) +{ + UtAssertEx(UT_EventIsInHistory(EvtId), UtAssert_GetContext(), FileName, LineNum, "%s - sent event %s [%ld]", + TestName, EvtName, (long int)EvtId); +} + +void UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +{ + UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TTF, FileName, LineNum, "%s - Teardown failed (%s returned 0x%lx)", + TestName, FnName, (long int)FnRet); +} + diff --git a/modules/es/CMakeLists.txt b/modules/es/CMakeLists.txt new file mode 100644 index 000000000..ab6b47b1b --- /dev/null +++ b/modules/es/CMakeLists.txt @@ -0,0 +1,39 @@ +################################################################## +# +# cFE Executive Services (ES) module CMake build recipe +# +################################################################## + +project(CFE_ES C) + +# Executive services source files +set(es_SOURCES + fsw/src/cfe_es_api.c + fsw/src/cfe_es_apps.c + fsw/src/cfe_es_backgroundtask.c + fsw/src/cfe_es_cds.c + fsw/src/cfe_es_cds_mempool.c + fsw/src/cfe_es_erlog.c + fsw/src/cfe_es_generic_pool.c + fsw/src/cfe_es_mempool.c + fsw/src/cfe_es_objtab.c + fsw/src/cfe_es_perf.c + fsw/src/cfe_es_resource.c + fsw/src/cfe_es_start.c + fsw/src/cfe_es_syslog.c + fsw/src/cfe_es_task.c +) +add_library(es STATIC ${es_SOURCES}) + +target_include_directories(es PUBLIC fsw/inc) +target_link_libraries(es PRIVATE cfe_internal_intf) + +# Add unit test coverage subdirectory +if (ENABLE_UNIT_TESTS) + add_subdirectory(ut-coverage) +endif (ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + cfe_es_msg.h + cfe_es_events.h +) diff --git a/fsw/cfe-core/src/inc/cfe_es_events.h b/modules/es/fsw/inc/cfe_es_events.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_es_events.h rename to modules/es/fsw/inc/cfe_es_events.h diff --git a/fsw/cfe-core/src/inc/cfe_es_msg.h b/modules/es/fsw/inc/cfe_es_msg.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_es_msg.h rename to modules/es/fsw/inc/cfe_es_msg.h index de4bd34e9..06c27b930 100644 --- a/fsw/cfe-core/src/inc/cfe_es_msg.h +++ b/modules/es/fsw/inc/cfe_es_msg.h @@ -38,8 +38,10 @@ /* ** Includes */ +#include "common_types.h" /* Basic data types */ +#include "cfe_msg_hdr.h" /* for header definitions */ #include "cfe_es_extern_typedefs.h" -#include "cfe_sb.h" + /* ** ES task command packet command codes diff --git a/fsw/cfe-core/src/es/cfe_es_api.c b/modules/es/fsw/src/cfe_es_api.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_api.c rename to modules/es/fsw/src/cfe_es_api.c index f2618019b..85f8fdf09 100644 --- a/fsw/cfe-core/src/es/cfe_es_api.c +++ b/modules/es/fsw/src/cfe_es_api.c @@ -36,17 +36,7 @@ /* ** Required header files. */ -#include "private/cfe_private.h" -#include "cfe_es.h" -#include "cfe_es_apps.h" -#include "cfe_es_global.h" -#include "cfe_es_events.h" -#include "cfe_es_cds.h" -#include "cfe_es_cds_mempool.h" -#include "cfe_es_task.h" -#include "cfe_es_resource.h" -#include "cfe_psp.h" -#include "cfe_es_log.h" +#include "cfe_es_internal.h" #include diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/modules/es/fsw/src/cfe_es_apps.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_apps.c rename to modules/es/fsw/src/cfe_es_apps.c index 4802ba75e..5c2b493ef 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/modules/es/fsw/src/cfe_es_apps.c @@ -36,14 +36,7 @@ /* ** Includes */ -#include "private/cfe_private.h" -#include "cfe_es.h" -#include "cfe_psp.h" -#include "cfe_es_global.h" -#include "cfe_es_task.h" -#include "cfe_es_apps.h" -#include "cfe_es_log.h" -#include "cfe_es_resource.h" +#include "cfe_es_internal.h" #include #include /* memset() */ diff --git a/fsw/cfe-core/src/es/cfe_es_apps.h b/modules/es/fsw/src/cfe_es_apps.h similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_apps.h rename to modules/es/fsw/src/cfe_es_apps.h index 2e6bf558d..d776f044d 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.h +++ b/modules/es/fsw/src/cfe_es_apps.h @@ -40,7 +40,9 @@ ** Include Files */ #include "common_types.h" -#include "osapi.h" + +#include "cfe_es_api_typedefs.h" +#include "cfe_fs_api_typedefs.h" /* ** Macro Definitions diff --git a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c b/modules/es/fsw/src/cfe_es_backgroundtask.c similarity index 98% rename from fsw/cfe-core/src/es/cfe_es_backgroundtask.c rename to modules/es/fsw/src/cfe_es_backgroundtask.c index 93b70867e..3b3508647 100644 --- a/fsw/cfe-core/src/es/cfe_es_backgroundtask.c +++ b/modules/es/fsw/src/cfe_es_backgroundtask.c @@ -35,11 +35,7 @@ #include -#include "osapi.h" -#include "private/cfe_private.h" -#include "cfe_es_perf.h" -#include "cfe_es_global.h" -#include "cfe_es_task.h" +#include "cfe_es_internal.h" #define CFE_ES_BACKGROUND_SEM_NAME "ES_BG_SEM" #define CFE_ES_BACKGROUND_CHILD_NAME "ES_BG_TASK" diff --git a/fsw/cfe-core/src/es/cfe_es_cds.c b/modules/es/fsw/src/cfe_es_cds.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_cds.c rename to modules/es/fsw/src/cfe_es_cds.c index 4efd36cd8..a6872c126 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.c +++ b/modules/es/fsw/src/cfe_es_cds.c @@ -38,14 +38,7 @@ /* ** Required header files. */ -#include "private/cfe_private.h" -#include "cfe_es_apps.h" -#include "cfe_es_cds.h" -#include "cfe_es_global.h" -#include "cfe_es_resource.h" -#include "cfe_es_log.h" -#include "cfe_psp.h" -#include "cfe_es_cds_mempool.h" +#include "cfe_es_internal.h" #include #include diff --git a/fsw/cfe-core/src/es/cfe_es_cds.h b/modules/es/fsw/src/cfe_es_cds.h similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_cds.h rename to modules/es/fsw/src/cfe_es_cds.h index d4168f448..e57de070e 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds.h +++ b/modules/es/fsw/src/cfe_es_cds.h @@ -42,10 +42,6 @@ ** Include Files */ #include "common_types.h" -#include "osapi.h" -#include "cfe_es_apps.h" -#include "cfe_platform_cfg.h" -#include "cfe_es.h" #include "cfe_es_generic_pool.h" /* diff --git a/fsw/cfe-core/src/es/cfe_es_cds_mempool.c b/modules/es/fsw/src/cfe_es_cds_mempool.c similarity index 98% rename from fsw/cfe-core/src/es/cfe_es_cds_mempool.c rename to modules/es/fsw/src/cfe_es_cds_mempool.c index a3acfc3a9..765195f93 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds_mempool.c +++ b/modules/es/fsw/src/cfe_es_cds_mempool.c @@ -38,13 +38,7 @@ #include #include -#include "private/cfe_private.h" -#include "cfe_es.h" -#include "cfe_psp.h" -#include "cfe_es_generic_pool.h" -#include "cfe_es_cds_mempool.h" -#include "cfe_es_global.h" -#include "cfe_es_log.h" +#include "cfe_es_internal.h" /*****************************************************************************/ /* diff --git a/fsw/cfe-core/src/es/cfe_es_cds_mempool.h b/modules/es/fsw/src/cfe_es_cds_mempool.h similarity index 98% rename from fsw/cfe-core/src/es/cfe_es_cds_mempool.h rename to modules/es/fsw/src/cfe_es_cds_mempool.h index abacf5a7e..53e07ac3e 100644 --- a/fsw/cfe-core/src/es/cfe_es_cds_mempool.h +++ b/modules/es/fsw/src/cfe_es_cds_mempool.h @@ -41,7 +41,6 @@ /* ** Include Files */ -#include "private/cfe_private.h" #include "cfe_es_cds.h" /* diff --git a/fsw/cfe-core/src/es/cfe_es_erlog.c b/modules/es/fsw/src/cfe_es_erlog.c similarity index 98% rename from fsw/cfe-core/src/es/cfe_es_erlog.c rename to modules/es/fsw/src/cfe_es_erlog.c index 1ebd390ef..d3d7a7689 100644 --- a/fsw/cfe-core/src/es/cfe_es_erlog.c +++ b/modules/es/fsw/src/cfe_es_erlog.c @@ -38,14 +38,7 @@ /* ** Required header files. */ -#include "private/cfe_private.h" -#include "cfe_es.h" -#include "cfe_es_apps.h" -#include "cfe_es_global.h" -#include "cfe_es_resource.h" -#include "cfe_es_log.h" -#include "cfe_es_task.h" -#include "cfe_psp.h" +#include "cfe_es_internal.h" #include #include diff --git a/fsw/cfe-core/src/es/cfe_es_generic_pool.c b/modules/es/fsw/src/cfe_es_generic_pool.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_generic_pool.c rename to modules/es/fsw/src/cfe_es_generic_pool.c index d8b76bcb1..1d13e50de 100644 --- a/fsw/cfe-core/src/es/cfe_es_generic_pool.c +++ b/modules/es/fsw/src/cfe_es_generic_pool.c @@ -34,17 +34,12 @@ /* ** Includes */ +#include "cfe_es_internal.h" + #include #include #include -#include "common_types.h" -#include "osapi.h" -#include "cfe_es.h" -#include "cfe_es_generic_pool.h" -#include "cfe_es_global.h" -#include "cfe_platform_cfg.h" - /*****************************************************************************/ /* diff --git a/fsw/cfe-core/src/es/cfe_es_generic_pool.h b/modules/es/fsw/src/cfe_es_generic_pool.h similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_generic_pool.h rename to modules/es/fsw/src/cfe_es_generic_pool.h index 2796ed1eb..fb1947e78 100644 --- a/fsw/cfe-core/src/es/cfe_es_generic_pool.h +++ b/modules/es/fsw/src/cfe_es_generic_pool.h @@ -42,7 +42,6 @@ ** Include Files */ #include "common_types.h" -#include "private/cfe_private.h" /* ** Macro Definitions diff --git a/fsw/cfe-core/src/es/cfe_es_global.h b/modules/es/fsw/src/cfe_es_global.h similarity index 91% rename from fsw/cfe-core/src/es/cfe_es_global.h rename to modules/es/fsw/src/cfe_es_global.h index 0965ef9ea..369f0eec6 100644 --- a/fsw/cfe-core/src/es/cfe_es_global.h +++ b/modules/es/fsw/src/cfe_es_global.h @@ -35,24 +35,16 @@ #define _cfe_es_global_ /* -** Includes: +** Includes */ -#include "osapi.h" -#include "private/cfe_private.h" -#include "private/cfe_es_resetdata_typedef.h" -#include "cfe_es.h" -#include "cfe_es_apps.h" +#include "common_types.h" +#include "cfe_es_api_typedefs.h" + +#include "cfe_es_erlog_typedef.h" +#include "cfe_es_resetdata_typedef.h" #include "cfe_es_cds.h" -#include "cfe_es_perf.h" -#include "cfe_es_generic_pool.h" -#include "cfe_es_mempool.h" -#include "cfe_es_cds_mempool.h" -#include "cfe_time.h" -#include "cfe_platform_cfg.h" -#include "cfe_evs.h" -#include "cfe_psp.h" - -#include + +#include /* for sig_atomic_t */ /* diff --git a/modules/es/fsw/src/cfe_es_internal.h b/modules/es/fsw/src/cfe_es_internal.h new file mode 100644 index 000000000..1449fc0dc --- /dev/null +++ b/modules/es/fsw/src/cfe_es_internal.h @@ -0,0 +1,60 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** File: +** cfe_es_global.h +** +** Purpose: +** This file contains the ES global data definitions. +** +** References: +** Flight Software Branch C Coding Standard Version 1.0a +** cFE Flight Software Application Developers Guide +** +*/ + +#ifndef CFE_ES_INTERNAL_H +#define CFE_ES_INTERNAL_H + +/* +** Includes +*/ +#include "cfe.h" +#include "cfe_platform_cfg.h" + +#include "cfe_msgids.h" +#include "cfe_perfids.h" + +#include "cfe_es_apps.h" +#include "cfe_es_cds.h" +#include "cfe_es_perf.h" +#include "cfe_es_generic_pool.h" +#include "cfe_es_mempool.h" +#include "cfe_es_global.h" +#include "cfe_es_cds_mempool.h" +#include "cfe_es_events.h" +#include "cfe_es_start.h" +#include "cfe_es_task.h" +#include "cfe_es_resource.h" +#include "cfe_es_log.h" + + +#endif diff --git a/fsw/cfe-core/src/es/cfe_es_log.h b/modules/es/fsw/src/cfe_es_log.h similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_log.h rename to modules/es/fsw/src/cfe_es_log.h index e52ae1c0a..4c168274e 100644 --- a/fsw/cfe-core/src/es/cfe_es_log.h +++ b/modules/es/fsw/src/cfe_es_log.h @@ -41,9 +41,9 @@ /* ** Include Files */ -#include "cfe.h" -#include "cfe_es.h" -#include "cfe_es_global.h" +#include "common_types.h" +#include "cfe_es_api_typedefs.h" +#include "cfe_time_api_typedefs.h" #include /* required for "va_list" */ diff --git a/fsw/cfe-core/src/es/cfe_es_mempool.c b/modules/es/fsw/src/cfe_es_mempool.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_mempool.c rename to modules/es/fsw/src/cfe_es_mempool.c index 66a833a42..c9f426e50 100644 --- a/fsw/cfe-core/src/es/cfe_es_mempool.c +++ b/modules/es/fsw/src/cfe_es_mempool.c @@ -34,17 +34,12 @@ /* ** Includes */ +#include "cfe_es_internal.h" + #include #include #include -#include "private/cfe_private.h" -#include "cfe_es_generic_pool.h" -#include "cfe_es.h" -#include "cfe_es_task.h" -#include "cfe_es_log.h" -#include "cfe_es_resource.h" - /** * Macro that determines the native alignment requirement of a specific type * diff --git a/fsw/cfe-core/src/es/cfe_es_mempool.h b/modules/es/fsw/src/cfe_es_mempool.h similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_mempool.h rename to modules/es/fsw/src/cfe_es_mempool.h index d94724faa..c8627925d 100644 --- a/fsw/cfe-core/src/es/cfe_es_mempool.h +++ b/modules/es/fsw/src/cfe_es_mempool.h @@ -34,6 +34,7 @@ ** Include Files */ #include "common_types.h" +#include "cfe_resourceid.h" #include "cfe_es_generic_pool.h" typedef struct diff --git a/fsw/cfe-core/src/es/cfe_es_objtab.c b/modules/es/fsw/src/cfe_es_objtab.c similarity index 98% rename from fsw/cfe-core/src/es/cfe_es_objtab.c rename to modules/es/fsw/src/cfe_es_objtab.c index 18c4c3287..97e831176 100644 --- a/fsw/cfe-core/src/es/cfe_es_objtab.c +++ b/modules/es/fsw/src/cfe_es_objtab.c @@ -36,9 +36,7 @@ /* ** Include files */ -#include "private/cfe_private.h" -#include "cfe_es_global.h" -#include "cfe_es_start.h" +#include "cfe_es_internal.h" /* ** diff --git a/fsw/cfe-core/src/es/cfe_es_perf.c b/modules/es/fsw/src/cfe_es_perf.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_perf.c rename to modules/es/fsw/src/cfe_es_perf.c index bb957a35e..7d8c79204 100644 --- a/fsw/cfe-core/src/es/cfe_es_perf.c +++ b/modules/es/fsw/src/cfe_es_perf.c @@ -29,17 +29,8 @@ /* ** Include Section */ +#include "cfe_es_internal.h" -#include "osapi.h" -#include "private/cfe_private.h" -#include "cfe_es_perf.h" -#include "cfe_es_log.h" -#include "cfe_es_global.h" -#include "cfe_es_start.h" -#include "cfe_es_events.h" -#include "cfe_es_task.h" -#include "cfe_fs.h" -#include "cfe_psp.h" #include diff --git a/fsw/cfe-core/src/es/cfe_es_perf.h b/modules/es/fsw/src/cfe_es_perf.h similarity index 96% rename from fsw/cfe-core/src/es/cfe_es_perf.h rename to modules/es/fsw/src/cfe_es_perf.h index 74cd370e6..ce2b2ac76 100644 --- a/fsw/cfe-core/src/es/cfe_es_perf.h +++ b/modules/es/fsw/src/cfe_es_perf.h @@ -37,14 +37,8 @@ ** Include Files */ #include "common_types.h" -#include "osapi.h" -#include "cfe_es.h" -#include "cfe_es_msg.h" -#include "cfe_es_events.h" -#include "cfe_sb.h" -#include "cfe_evs.h" -#include "cfe_perfids.h" -#include "cfe_psp.h" +#include "osconfig.h" +#include "cfe_es_api_typedefs.h" /* ** Defines diff --git a/fsw/cfe-core/src/es/cfe_es_resource.c b/modules/es/fsw/src/cfe_es_resource.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_resource.c rename to modules/es/fsw/src/cfe_es_resource.c index 4af1cacea..24a566342 100644 --- a/fsw/cfe-core/src/es/cfe_es_resource.c +++ b/modules/es/fsw/src/cfe_es_resource.c @@ -33,13 +33,12 @@ /* ** Includes */ +#include "cfe_es_internal.h" + #include #include #include -#include "cfe_platform_cfg.h" -#include "cfe_es_resource.h" - /*********************************************************************/ /* diff --git a/fsw/cfe-core/src/es/cfe_es_resource.h b/modules/es/fsw/src/cfe_es_resource.h similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_resource.h rename to modules/es/fsw/src/cfe_es_resource.h index efdb8280a..ad30b13a9 100644 --- a/fsw/cfe-core/src/es/cfe_es_resource.h +++ b/modules/es/fsw/src/cfe_es_resource.h @@ -34,8 +34,8 @@ /* ** Include Files */ -#include "cfe_resourceid_api.h" -#include "private/cfe_core_resourceid_basevalues.h" +#include "cfe_resourceid.h" +#include "cfe_core_resourceid_basevalues.h" #include "cfe_es_global.h" diff --git a/fsw/cfe-core/src/es/cfe_es_start.c b/modules/es/fsw/src/cfe_es_start.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_start.c rename to modules/es/fsw/src/cfe_es_start.c index da0538c4c..9e545415a 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.c +++ b/modules/es/fsw/src/cfe_es_start.c @@ -37,14 +37,7 @@ ** Includes */ -#include "private/cfe_private.h" -#include "cfe_es.h" -#include "cfe_es_global.h" -#include "cfe_es_resource.h" -#include "cfe_es_start.h" -#include "cfe_es_apps.h" -#include "cfe_es_log.h" -#include "cfe_psp.h" +#include "cfe_es_internal.h" #include #include diff --git a/fsw/cfe-core/src/es/cfe_es_start.h b/modules/es/fsw/src/cfe_es_start.h similarity index 98% rename from fsw/cfe-core/src/es/cfe_es_start.h rename to modules/es/fsw/src/cfe_es_start.h index 119df0a5a..0fa233a78 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.h +++ b/modules/es/fsw/src/cfe_es_start.h @@ -41,7 +41,7 @@ ** Include Files */ -#include "cfe.h" +#include "cfe_es_api_typedefs.h" /* ** Macro Definitions diff --git a/fsw/cfe-core/src/es/cfe_es_syslog.c b/modules/es/fsw/src/cfe_es_syslog.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_syslog.c rename to modules/es/fsw/src/cfe_es_syslog.c index 1da1738af..9c0012627 100644 --- a/fsw/cfe-core/src/es/cfe_es_syslog.c +++ b/modules/es/fsw/src/cfe_es_syslog.c @@ -51,11 +51,7 @@ /* ** Required header files. */ -#include "cfe.h" -#include "cfe_es.h" -#include "cfe_es_global.h" -#include "cfe_es_task.h" -#include "cfe_es_log.h" +#include "cfe_es_internal.h" #include #include diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c similarity index 99% rename from fsw/cfe-core/src/es/cfe_es_task.c rename to modules/es/fsw/src/cfe_es_task.c index 5182a21f9..2b1be9362 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -36,20 +36,10 @@ /* ** Includes */ -#include "private/cfe_private.h" -#include "cfe_platform_cfg.h" +#include "cfe_es_internal.h" + #include "cfe_version.h" -#include "cfe_es_global.h" -#include "cfe_es_apps.h" -#include "cfe_es_resource.h" -#include "cfe_es_events.h" -#include "cfe_es_verify.h" -#include "cfe_es_task.h" -#include "cfe_es_log.h" -#include "cfe_es_cds.h" -#include "cfe_fs.h" -#include "cfe_psp.h" -#include "cfe_msgids.h" +#include "target_config.h" #include diff --git a/fsw/cfe-core/src/es/cfe_es_task.h b/modules/es/fsw/src/cfe_es_task.h similarity index 97% rename from fsw/cfe-core/src/es/cfe_es_task.h rename to modules/es/fsw/src/cfe_es_task.h index fb8d69cf6..1854943cf 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.h +++ b/modules/es/fsw/src/cfe_es_task.h @@ -38,13 +38,11 @@ /* ** Includes */ -#include "cfe.h" -#include "cfe_es.h" -#include "cfe_es_apps.h" -#include "cfe_es_events.h" -#include "cfe_es_msg.h" -#include "cfe_es_perf.h" -#include "private/cfe_es_erlog_typedef.h" +#include "cfe_es_api_typedefs.h" +#include "cfe_fs_api_typedefs.h" +#include "cfe_sb_api_typedefs.h" + +#include "cfe_es_erlog_typedef.h" /*************************************************************************/ diff --git a/fsw/cfe-core/src/es/cfe_es_verify.h b/modules/es/fsw/src/cfe_es_verify.h similarity index 100% rename from fsw/cfe-core/src/es/cfe_es_verify.h rename to modules/es/fsw/src/cfe_es_verify.h diff --git a/modules/es/ut-coverage/CMakeLists.txt b/modules/es/ut-coverage/CMakeLists.txt new file mode 100644 index 000000000..11e674c02 --- /dev/null +++ b/modules/es/ut-coverage/CMakeLists.txt @@ -0,0 +1,7 @@ +################################################################## +# +# cFE unit test CMake build recipe +# +################################################################## + +# Nothing yet - placeholder for future use diff --git a/fsw/cfe-core/unit-test/es_UT.c b/modules/es/ut-coverage/es_UT.c similarity index 100% rename from fsw/cfe-core/unit-test/es_UT.c rename to modules/es/ut-coverage/es_UT.c diff --git a/fsw/cfe-core/unit-test/es_UT.h b/modules/es/ut-coverage/es_UT.h similarity index 100% rename from fsw/cfe-core/unit-test/es_UT.h rename to modules/es/ut-coverage/es_UT.h diff --git a/modules/evs/CMakeLists.txt b/modules/evs/CMakeLists.txt new file mode 100644 index 000000000..849583a6c --- /dev/null +++ b/modules/evs/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################## +# +# cFE Event Services (EVS) module CMake build recipe +# +################################################################## + +project(CFE_EVS C) + +# Event services source files +set(evs_SOURCES + fsw/src/cfe_evs.c + fsw/src/cfe_evs_log.c + fsw/src/cfe_evs_task.c + fsw/src/cfe_evs_utils.c + fsw/src/cfe_evs.c + fsw/src/cfe_evs_log.c + fsw/src/cfe_evs_task.c + fsw/src/cfe_evs_utils.c +) +add_library(evs STATIC ${evs_SOURCES}) + +target_include_directories(evs PUBLIC fsw/inc) +target_link_libraries(evs PRIVATE cfe_internal_intf) + +# Add unit test coverage subdirectory +if(ENABLE_UNIT_TESTS) + add_subdirectory(ut-coverage) +endif(ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + cfe_evs_msg.h + cfe_evs_events.h +) diff --git a/fsw/cfe-core/src/inc/cfe_evs_events.h b/modules/evs/fsw/inc/cfe_evs_events.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_evs_events.h rename to modules/evs/fsw/inc/cfe_evs_events.h diff --git a/fsw/cfe-core/src/inc/cfe_evs_msg.h b/modules/evs/fsw/inc/cfe_evs_msg.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_evs_msg.h rename to modules/evs/fsw/inc/cfe_evs_msg.h index cfefb1514..c5434ea70 100644 --- a/fsw/cfe-core/src/inc/cfe_evs_msg.h +++ b/modules/evs/fsw/inc/cfe_evs_msg.h @@ -37,10 +37,9 @@ /********************************** Include Files ************************************/ #include "common_types.h" /* Basic data types */ +#include "cfe_msg_hdr.h" /* for header definitions */ #include "cfe_evs_extern_typedefs.h" /* for EVS-specific types such as CFE_EVS_LogMode_Enum_t */ -#include "cfe_time.h" /* Time library function definitions */ -#include "cfe_sb.h" -#include "cfe_es.h" +#include "cfe_es_extern_typedefs.h" /* for CFE_ES_AppId_t type */ /** \name Event Services Command Codes */ diff --git a/fsw/cfe-core/src/evs/cfe_evs.c b/modules/evs/fsw/src/cfe_evs.c similarity index 98% rename from fsw/cfe-core/src/evs/cfe_evs.c rename to modules/evs/fsw/src/cfe_evs.c index ac6c32318..3ece6ef62 100644 --- a/fsw/cfe-core/src/evs/cfe_evs.c +++ b/modules/evs/fsw/src/cfe_evs.c @@ -30,12 +30,14 @@ */ /* Include Files */ -#include "cfe_evs.h" /* EVS library function definitions */ -#include "cfe_evs_task.h" /* EVS internal definitions */ -#include "cfe_evs_utils.h" /* EVS utility function definitions */ #include "common_types.h" /* Basic data types */ -#include "cfe_es.h" /* Executive Service definitions */ #include "cfe_error.h" /* cFE error code definitions */ +#include "cfe_evs.h" /* EVS library function definitions */ +#include "cfe_evs_task.h" /* EVS internal definitions */ +#include "cfe_evs_utils.h" /* EVS utility function definitions */ + +#include "cfe_es.h" +#include "cfe_time.h" #include #include diff --git a/fsw/cfe-core/src/evs/cfe_evs_log.c b/modules/evs/fsw/src/cfe_evs_log.c similarity index 98% rename from fsw/cfe-core/src/evs/cfe_evs_log.c rename to modules/evs/fsw/src/cfe_evs_log.c index bcb59955a..126b0a9d1 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_log.c +++ b/modules/evs/fsw/src/cfe_evs_log.c @@ -29,14 +29,15 @@ */ /* Include Files */ +#include "cfe_evs.h" /* EVS API definitions */ +#include "cfe_evs_events.h" /* EVS event IDs */ #include "cfe_evs_task.h" /* EVS internal definitions */ #include "cfe_evs_log.h" /* EVS log file definitions */ -#include "cfe_evs.h" /* EVS API definitions */ #include "cfe_evs_utils.h" /* EVS utility function definitions */ -#include "cfe_fs.h" /* File Service definitions */ #include "cfe_error.h" /* cFE error code definitions */ #include "cfe_psp.h" /* Get reset area function prototype */ +#include "cfe_fs.h" /* File Service definitions */ #include diff --git a/fsw/cfe-core/src/evs/cfe_evs_log.h b/modules/evs/fsw/src/cfe_evs_log.h similarity index 100% rename from fsw/cfe-core/src/evs/cfe_evs_log.h rename to modules/evs/fsw/src/cfe_evs_log.h diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/modules/evs/fsw/src/cfe_evs_task.c similarity index 99% rename from fsw/cfe-core/src/evs/cfe_evs_task.c rename to modules/evs/fsw/src/cfe_evs_task.c index 928e529a5..852cc1f96 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/modules/evs/fsw/src/cfe_evs_task.c @@ -30,21 +30,28 @@ */ /* Include Files */ +#include "cfe_evs.h" /* EVS API definitions */ #include "cfe_evs_task.h" /* EVS internal definitions */ #include "cfe_evs_log.h" /* EVS log file definitions */ #include "cfe_evs_utils.h" /* EVS utility function definitions */ -#include "cfe_evs.h" /* EVS API definitions */ + +#include "cfe_msgids.h" +#include "cfe_perfids.h" #include #include "cfe_version.h" /* cFE version definitions */ #include "cfe_error.h" /* cFE error code definitions */ -#include "cfe_es.h" /* Executive Service definitions */ -#include "cfe_fs.h" /* File Service definitions */ #include "cfe_psp.h" /* cFE Platform Support Package definitions */ #include "osapi.h" /* OS API file system definitions */ -#include "private/cfe_es_resetdata_typedef.h" /* Definition of CFE_ES_ResetData_t */ +#include "cfe_es_resetdata_typedef.h" /* Definition of CFE_ES_ResetData_t */ + +#include "cfe_es.h" /* Executive Service definitions */ +#include "cfe_fs.h" /* File Service definitions */ +#include "cfe_msg.h" /* Message definitions */ +#include "cfe_sb.h" /* Software Bus definitions */ + /* Global Data */ CFE_EVS_Global_t CFE_EVS_Global; diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.h b/modules/evs/fsw/src/cfe_evs_task.h similarity index 93% rename from fsw/cfe-core/src/evs/cfe_evs_task.h rename to modules/evs/fsw/src/cfe_evs_task.h index 079e1118f..f9dbf7c87 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.h +++ b/modules/evs/fsw/src/cfe_evs_task.h @@ -42,15 +42,13 @@ #define _cfe_evs_task_ /********************************** Include Files ************************************/ -#include "private/cfe_private.h" -#include "private/cfe_evs_log_typedef.h" -#include "cfe_sb.h" /* Software Bus library function definitions */ -#include "cfe_msgids.h" /* Software Bus Message ID definitions */ -#include "cfe_es.h" /* Memory Pool definitions */ -#include "osapi.h" /* OS definitions */ -#include "cfe_evs_msg.h" /* EVS message definitions */ -#include "cfe_evs_verify.h" -#include "cfe_evs.h" +#include "common_types.h" +#include "cfe_platform_cfg.h" +#include "cfe_mission_cfg.h" +#include "osconfig.h" +#include "cfe_evs_api_typedefs.h" +#include "cfe_evs_log_typedef.h" +#include "cfe_sb_api_typedefs.h" #include "cfe_evs_events.h" /********************* Macro and Constant Type Definitions ***************************/ diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.c b/modules/evs/fsw/src/cfe_evs_utils.c similarity index 99% rename from fsw/cfe-core/src/evs/cfe_evs_utils.c rename to modules/evs/fsw/src/cfe_evs_utils.c index ad80eb88a..6eb645b14 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_utils.c +++ b/modules/evs/fsw/src/cfe_evs_utils.c @@ -29,11 +29,14 @@ */ /* Include Files */ -#include "cfe_evs.h" /* EVS library function definitions */ +#include "cfe_evs.h" /* EVS library function definitions */ #include "cfe_evs_log.h" /* EVS local event log definitions */ #include "cfe_evs_task.h" /* EVS internal definitions */ #include "cfe_evs_utils.h" /* EVS utility function definitions */ +#include "cfe_msgids.h" +#include "cfe_perfids.h" + #include #include @@ -41,8 +44,11 @@ #include "common_types.h" /* Basic data types */ #include "osapi.h" /* OS API interface definitions */ #include "cfe_psp.h" /* cFE PSP glue functions */ -#include "cfe_sb.h" /* Software Bus library function definitions */ + #include "cfe_es.h" +#include "cfe_sb.h" +#include "cfe_msg.h" +#include "cfe_time.h" /* Local Function Prototypes */ void EVS_SendViaPorts (CFE_EVS_LongEventTlm_t *EVS_PktPtr); diff --git a/fsw/cfe-core/src/evs/cfe_evs_utils.h b/modules/evs/fsw/src/cfe_evs_utils.h similarity index 98% rename from fsw/cfe-core/src/evs/cfe_evs_utils.h rename to modules/evs/fsw/src/cfe_evs_utils.h index b2ee70d84..eb82998c1 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_utils.h +++ b/modules/evs/fsw/src/cfe_evs_utils.h @@ -44,6 +44,9 @@ /********************* Include Files ************************/ #include "cfe_evs_task.h" /* EVS internal definitions */ +#include "cfe_resourceid.h" +#include "cfe_es_api_typedefs.h" +#include "cfe_time_api_typedefs.h" /* ============== Section I: Macro and Constant Type Definitions =========== */ diff --git a/fsw/cfe-core/src/evs/cfe_evs_verify.h b/modules/evs/fsw/src/cfe_evs_verify.h similarity index 100% rename from fsw/cfe-core/src/evs/cfe_evs_verify.h rename to modules/evs/fsw/src/cfe_evs_verify.h diff --git a/modules/evs/ut-coverage/CMakeLists.txt b/modules/evs/ut-coverage/CMakeLists.txt new file mode 100644 index 000000000..11e674c02 --- /dev/null +++ b/modules/evs/ut-coverage/CMakeLists.txt @@ -0,0 +1,7 @@ +################################################################## +# +# cFE unit test CMake build recipe +# +################################################################## + +# Nothing yet - placeholder for future use diff --git a/fsw/cfe-core/unit-test/evs_UT.c b/modules/evs/ut-coverage/evs_UT.c similarity index 100% rename from fsw/cfe-core/unit-test/evs_UT.c rename to modules/evs/ut-coverage/evs_UT.c diff --git a/fsw/cfe-core/unit-test/evs_UT.h b/modules/evs/ut-coverage/evs_UT.h similarity index 100% rename from fsw/cfe-core/unit-test/evs_UT.h rename to modules/evs/ut-coverage/evs_UT.h diff --git a/modules/fs/CMakeLists.txt b/modules/fs/CMakeLists.txt new file mode 100644 index 000000000..3259f2be0 --- /dev/null +++ b/modules/fs/CMakeLists.txt @@ -0,0 +1,25 @@ +################################################################## +# +# cFE File Services (FS) module CMake build recipe +# +################################################################## + +project(CFE_FS C) + +# File services source files +set(fs_SOURCES + fsw/src/cfe_fs_api.c + fsw/src/cfe_fs_priv.c + fsw/src/cfe_fs_api.c + fsw/src/cfe_fs_priv.c +) +add_library(fs STATIC ${fs_SOURCES}) + +target_include_directories(fs PUBLIC fsw/inc) +target_link_libraries(fs PRIVATE cfe_internal_intf) + +# Add unit test coverage subdirectory +if(ENABLE_UNIT_TESTS) + add_subdirectory(ut-coverage) +endif(ENABLE_UNIT_TESTS) + diff --git a/fsw/cfe-core/src/fs/cfe_fs_api.c b/modules/fs/fsw/src/cfe_fs_api.c similarity index 99% rename from fsw/cfe-core/src/fs/cfe_fs_api.c rename to modules/fs/fsw/src/cfe_fs_api.c index fd2e9ef5f..648c40702 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_api.c +++ b/modules/fs/fsw/src/cfe_fs_api.c @@ -33,19 +33,13 @@ /* ** Required header files... */ -#include "private/cfe_private.h" -#include "cfe_fs_priv.h" -#include "cfe_fs.h" -#include "cfe_time.h" -#include "osapi.h" -#include "cfe_psp.h" -#include "cfe_es.h" +#include "cfe_fs_internal.h" + #include /* The target config allows refs into global CONFIGDATA object(s) */ #include "target_config.h" - /* * Fixed default file system extensions (not platform dependent) */ diff --git a/modules/fs/fsw/src/cfe_fs_internal.h b/modules/fs/fsw/src/cfe_fs_internal.h new file mode 100644 index 000000000..a04a53b68 --- /dev/null +++ b/modules/fs/fsw/src/cfe_fs_internal.h @@ -0,0 +1,44 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/****************************************************************************** +** File: cfe_fs_priv.h +** +** Purpose: +** This header file contains prototypes for private functions and type +** definitions for FS internal use. +** +** Author: A. Cudmore/NASA GSFC +** +** +******************************************************************************/ + +#ifndef CFE_FS_INTERNAL_H +#define CFE_FS_INTERNAL_H + +/* +** Includes +*/ +#include "cfe.h" +#include "cfe_fs_priv.h" + + +#endif /* CFE_FS_INTERNAL_H */ +/*****************************************************************************/ diff --git a/fsw/cfe-core/src/fs/cfe_fs_priv.c b/modules/fs/fsw/src/cfe_fs_priv.c similarity index 96% rename from fsw/cfe-core/src/fs/cfe_fs_priv.c rename to modules/fs/fsw/src/cfe_fs_priv.c index b0d0785f8..db426f9b8 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_priv.c +++ b/modules/fs/fsw/src/cfe_fs_priv.c @@ -33,14 +33,11 @@ /* ** Required header files */ -#include "osapi.h" -#include "private/cfe_private.h" -#include "cfe_es.h" -#include "cfe_fs.h" -#include "cfe_fs_priv.h" +#include "cfe_fs_internal.h" #include + /* ** Global data ** diff --git a/fsw/cfe-core/src/fs/cfe_fs_priv.h b/modules/fs/fsw/src/cfe_fs_priv.h similarity index 98% rename from fsw/cfe-core/src/fs/cfe_fs_priv.h rename to modules/fs/fsw/src/cfe_fs_priv.h index c2826b466..0c26cafb7 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_priv.h +++ b/modules/fs/fsw/src/cfe_fs_priv.h @@ -37,8 +37,8 @@ ** Includes */ #include "common_types.h" -#include "cfe_fs.h" -#include "cfe_es.h" +#include "cfe_fs_api_typedefs.h" +#include "cfe_es_api_typedefs.h" /* ** Macro Definitions diff --git a/modules/fs/ut-coverage/CMakeLists.txt b/modules/fs/ut-coverage/CMakeLists.txt new file mode 100644 index 000000000..11e674c02 --- /dev/null +++ b/modules/fs/ut-coverage/CMakeLists.txt @@ -0,0 +1,7 @@ +################################################################## +# +# cFE unit test CMake build recipe +# +################################################################## + +# Nothing yet - placeholder for future use diff --git a/fsw/cfe-core/unit-test/fs_UT.c b/modules/fs/ut-coverage/fs_UT.c similarity index 100% rename from fsw/cfe-core/unit-test/fs_UT.c rename to modules/fs/ut-coverage/fs_UT.c diff --git a/fsw/cfe-core/unit-test/fs_UT.h b/modules/fs/ut-coverage/fs_UT.h similarity index 100% rename from fsw/cfe-core/unit-test/fs_UT.h rename to modules/fs/ut-coverage/fs_UT.h diff --git a/modules/msg/CMakeLists.txt b/modules/msg/CMakeLists.txt index d1abfb5eb..5f177d291 100644 --- a/modules/msg/CMakeLists.txt +++ b/modules/msg/CMakeLists.txt @@ -16,35 +16,35 @@ # Add the basic set of files which are always built # Defined as absolute so this list can also be used to build unit tests set(${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_ccsdspri.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_init.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_msgid_shared.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_sechdr_checksum.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_sechdr_fc.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_sechdr_time.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_ccsdspri.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_init.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_shared.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_sechdr_checksum.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_sechdr_fc.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_sechdr_time.c ) # Source selection for if CCSDS extended header is included, and MsgId version use if (MISSION_INCLUDE_CCSDSEXT_HEADER) message(STATUS "CCSDS primary and extended header included in message header") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_ccsdsext.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_initdefaulthdr_priext.c) + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_ccsdsext.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_initdefaulthdr_priext.c) if (MISSION_MSGID_V2) # MsgId v2 or v1 can be used with extended headers message(STATUS "Message Id version 2 in use (MsgId V2)") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_msgid_v2.c) + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_v2.c) else (MISSION_MSGID_V2) message(STATUS "Message Id version 1 in use (MsgId V1)") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_msgid_v1.c) + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_v1.c) endif (MISSION_MSGID_V2) else (MISSION_INCLUDE_CCSDSEXT_HEADER) message(STATUS "CCSDS primary header included in message header (not including CCSDS extended header)") message(STATUS "Message Id version 1 in use (MsgId V1)") list(APPEND ${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_initdefaulthdr_pri.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_msg_msgid_v1.c) + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_initdefaulthdr_pri.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_msg_msgid_v1.c) if (MISSION_MSGID_V2) message(FATAL_ERROR "Message Id (MsgId) version 2 can only be used if MISSION_INCLUDE_CCSDSEXT_HEADER is set") endif (MISSION_MSGID_V2) @@ -53,10 +53,16 @@ endif (MISSION_INCLUDE_CCSDSEXT_HEADER) # Module library add_library(${DEP} STATIC ${${DEP}_SRC}) -# Add private include -target_include_directories(${DEP} PRIVATE private_inc) +target_include_directories(${DEP} PUBLIC fsw/inc) + +target_link_libraries(${DEP} PRIVATE cfe_internal_intf) # Add unit test coverage subdirectory if(ENABLE_UNIT_TESTS) - add_subdirectory(unit-test-coverage) + add_subdirectory(ut-coverage) endif(ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + ccsds_hdr.h + cfe_msg_api_typedefs.h +) diff --git a/fsw/cfe-core/src/inc/ccsds_hdr.h b/modules/msg/fsw/inc/ccsds_hdr.h similarity index 99% rename from fsw/cfe-core/src/inc/ccsds_hdr.h rename to modules/msg/fsw/inc/ccsds_hdr.h index ec523dce1..efcbc5eb8 100644 --- a/fsw/cfe-core/src/inc/ccsds_hdr.h +++ b/modules/msg/fsw/inc/ccsds_hdr.h @@ -32,7 +32,6 @@ */ #include "common_types.h" -#include "cfe_mission_cfg.h" /* * Type Definitions diff --git a/modules/msg/src/cfe_msg_ccsdsext.c b/modules/msg/fsw/src/cfe_msg_ccsdsext.c similarity index 99% rename from modules/msg/src/cfe_msg_ccsdsext.c rename to modules/msg/fsw/src/cfe_msg_ccsdsext.c index 658e9ac7d..e8b91684b 100644 --- a/modules/msg/src/cfe_msg_ccsdsext.c +++ b/modules/msg/fsw/src/cfe_msg_ccsdsext.c @@ -21,7 +21,7 @@ /****************************************************************************** * Message CCSDS extended header implementations */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_msg_defaults.h" #include "cfe_error.h" diff --git a/modules/msg/src/cfe_msg_ccsdspri.c b/modules/msg/fsw/src/cfe_msg_ccsdspri.c similarity index 99% rename from modules/msg/src/cfe_msg_ccsdspri.c rename to modules/msg/fsw/src/cfe_msg_ccsdspri.c index 1d1f9698a..780b93d23 100644 --- a/modules/msg/src/cfe_msg_ccsdspri.c +++ b/modules/msg/fsw/src/cfe_msg_ccsdspri.c @@ -21,7 +21,7 @@ /****************************************************************************** * Message CCSDS Primary header implementations */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_msg_defaults.h" #include "cfe_error.h" diff --git a/modules/msg/private_inc/cfe_msg_defaults.h b/modules/msg/fsw/src/cfe_msg_defaults.h similarity index 98% rename from modules/msg/private_inc/cfe_msg_defaults.h rename to modules/msg/fsw/src/cfe_msg_defaults.h index b93b0a1ae..cd25862ba 100644 --- a/modules/msg/private_inc/cfe_msg_defaults.h +++ b/modules/msg/fsw/src/cfe_msg_defaults.h @@ -31,6 +31,7 @@ */ #include "cfe_platform_cfg.h" #include "cfe_mission_cfg.h" +#include "cfe_msg_api_typedefs.h" /* * Defines diff --git a/modules/msg/src/cfe_msg_init.c b/modules/msg/fsw/src/cfe_msg_init.c similarity index 98% rename from modules/msg/src/cfe_msg_init.c rename to modules/msg/fsw/src/cfe_msg_init.c index 664b8c3dc..b116601d3 100644 --- a/modules/msg/src/cfe_msg_init.c +++ b/modules/msg/fsw/src/cfe_msg_init.c @@ -21,7 +21,7 @@ /****************************************************************************** * Message initialization */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_msg_defaults.h" #include "string.h" diff --git a/modules/msg/src/cfe_msg_initdefaulthdr_pri.c b/modules/msg/fsw/src/cfe_msg_initdefaulthdr_pri.c similarity index 100% rename from modules/msg/src/cfe_msg_initdefaulthdr_pri.c rename to modules/msg/fsw/src/cfe_msg_initdefaulthdr_pri.c diff --git a/modules/msg/src/cfe_msg_initdefaulthdr_priext.c b/modules/msg/fsw/src/cfe_msg_initdefaulthdr_priext.c similarity index 100% rename from modules/msg/src/cfe_msg_initdefaulthdr_priext.c rename to modules/msg/fsw/src/cfe_msg_initdefaulthdr_priext.c diff --git a/modules/msg/src/cfe_msg_msgid_shared.c b/modules/msg/fsw/src/cfe_msg_msgid_shared.c similarity index 98% rename from modules/msg/src/cfe_msg_msgid_shared.c rename to modules/msg/fsw/src/cfe_msg_msgid_shared.c index 79caaac7f..8cb31a322 100644 --- a/modules/msg/src/cfe_msg_msgid_shared.c +++ b/modules/msg/fsw/src/cfe_msg_msgid_shared.c @@ -21,7 +21,7 @@ /****************************************************************************** * Message id access functions, shared cFS implementation */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_error.h" diff --git a/modules/msg/src/cfe_msg_msgid_v1.c b/modules/msg/fsw/src/cfe_msg_msgid_v1.c similarity index 98% rename from modules/msg/src/cfe_msg_msgid_v1.c rename to modules/msg/fsw/src/cfe_msg_msgid_v1.c index 8b79ec3d3..47c002a0c 100644 --- a/modules/msg/src/cfe_msg_msgid_v1.c +++ b/modules/msg/fsw/src/cfe_msg_msgid_v1.c @@ -21,10 +21,11 @@ /****************************************************************************** * Message id access functions, cFS version 1 implementation */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_error.h" #include "cfe_platform_cfg.h" +#include "cfe_sb.h" /****************************************************************************** * Get message id - See API and header file for details diff --git a/modules/msg/src/cfe_msg_msgid_v2.c b/modules/msg/fsw/src/cfe_msg_msgid_v2.c similarity index 99% rename from modules/msg/src/cfe_msg_msgid_v2.c rename to modules/msg/fsw/src/cfe_msg_msgid_v2.c index 6845f9755..4e2c3b3fc 100644 --- a/modules/msg/src/cfe_msg_msgid_v2.c +++ b/modules/msg/fsw/src/cfe_msg_msgid_v2.c @@ -37,7 +37,7 @@ * | APID Qualifier |C/T flg | Pri Hdr APID | * +-+-+-+-+-+-+-+-+|--------|+-+-+-+-+-+-+-+ */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_error.h" #include "cfe_platform_cfg.h" diff --git a/modules/msg/private_inc/cfe_msg_priv.h b/modules/msg/fsw/src/cfe_msg_priv.h similarity index 99% rename from modules/msg/private_inc/cfe_msg_priv.h rename to modules/msg/fsw/src/cfe_msg_priv.h index 32d785715..ddd2c3d14 100644 --- a/modules/msg/private_inc/cfe_msg_priv.h +++ b/modules/msg/fsw/src/cfe_msg_priv.h @@ -30,6 +30,7 @@ * Includes */ #include "common_types.h" +#include "cfe_msg_hdr.h" /*****************************************************************************/ /** diff --git a/modules/msg/src/cfe_msg_sechdr_checksum.c b/modules/msg/fsw/src/cfe_msg_sechdr_checksum.c similarity index 99% rename from modules/msg/src/cfe_msg_sechdr_checksum.c rename to modules/msg/fsw/src/cfe_msg_sechdr_checksum.c index a958250ab..4a40d8ad5 100644 --- a/modules/msg/src/cfe_msg_sechdr_checksum.c +++ b/modules/msg/fsw/src/cfe_msg_sechdr_checksum.c @@ -21,7 +21,7 @@ /****************************************************************************** * Checksum field access functions */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" /******************************************************************************/ diff --git a/modules/msg/src/cfe_msg_sechdr_fc.c b/modules/msg/fsw/src/cfe_msg_sechdr_fc.c similarity index 99% rename from modules/msg/src/cfe_msg_sechdr_fc.c rename to modules/msg/fsw/src/cfe_msg_sechdr_fc.c index aa1c5abc9..34cd53c21 100644 --- a/modules/msg/src/cfe_msg_sechdr_fc.c +++ b/modules/msg/fsw/src/cfe_msg_sechdr_fc.c @@ -21,7 +21,7 @@ /****************************************************************************** * Function code field access functions */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #define CFE_MSG_FC_MASK 0x7F /**< \brief Function code mask */ diff --git a/modules/msg/src/cfe_msg_sechdr_time.c b/modules/msg/fsw/src/cfe_msg_sechdr_time.c similarity index 99% rename from modules/msg/src/cfe_msg_sechdr_time.c rename to modules/msg/fsw/src/cfe_msg_sechdr_time.c index 71d8d7a84..314676709 100644 --- a/modules/msg/src/cfe_msg_sechdr_time.c +++ b/modules/msg/fsw/src/cfe_msg_sechdr_time.c @@ -22,7 +22,7 @@ * Time field access functions - cFS default 32 bit seconds, 16 bit subseconds * in big endian format */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "cfe_msg_priv.h" #include "cfe_error.h" #include diff --git a/modules/msg/mission_build.cmake b/modules/msg/mission_build.cmake index b34a3f6e5..2ff86e581 100644 --- a/modules/msg/mission_build.cmake +++ b/modules/msg/mission_build.cmake @@ -18,10 +18,10 @@ endif (MISSION_INCLUDE_CCSDSEXT_HEADER) # Generate the header definition files, use local default for this module) generate_config_includefile( FILE_NAME "cfe_msg_hdr.h" - FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/mission_inc/${MSG_HDR_FILE}" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option_inc/${MSG_HDR_FILE}" ) generate_config_includefile( FILE_NAME "cfe_msg_sechdr.h" - FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/mission_inc/default_cfe_msg_sechdr.h" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option_inc/default_cfe_msg_sechdr.h" ) diff --git a/modules/msg/mission_inc/default_cfe_msg_hdr_pri.h b/modules/msg/option_inc/default_cfe_msg_hdr_pri.h similarity index 88% rename from modules/msg/mission_inc/default_cfe_msg_hdr_pri.h rename to modules/msg/option_inc/default_cfe_msg_hdr_pri.h index 4ff9880bf..f51260b4a 100644 --- a/modules/msg/mission_inc/default_cfe_msg_hdr_pri.h +++ b/modules/msg/option_inc/default_cfe_msg_hdr_pri.h @@ -34,6 +34,7 @@ #include "common_types.h" #include "ccsds_hdr.h" #include "cfe_msg_sechdr.h" +#include "cfe_msg_api_typedefs.h" /* * Type Definitions @@ -56,34 +57,36 @@ typedef struct /** * \brief cFS generic base message + * + * This provides the definition of CFE_MSG_Message_t */ -typedef union +union CFE_MSG_Message { CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */ uint8 Byte[sizeof(CCSDS_SpacePacket_t)]; /**< \brief Byte level access */ -} CFE_MSG_Message_t; +}; /** * \brief cFS command header + * + * This provides the definition of CFE_MSG_CommandHeader_t */ -typedef struct +struct CFE_MSG_CommandHeader { - CFE_MSG_Message_t Msg; /**< \brief Base message */ CFE_MSG_CommandSecondaryHeader_t Sec; /**< \brief Secondary header */ - -} CFE_MSG_CommandHeader_t; +}; /** * \brief cFS telemetry header + * + * This provides the definition of CFE_MSG_TelemetryHeader_t */ -typedef struct +struct CFE_MSG_TelemetryHeader { - CFE_MSG_Message_t Msg; /**< \brief Base message */ CFE_MSG_TelemetrySecondaryHeader_t Sec; /**< \brief Secondary header */ uint8 Spare[4]; /**< \brief Padding to end on 64 bit boundary */ - -} CFE_MSG_TelemetryHeader_t; +}; #endif /* _cfe_msg_hdr_ */ diff --git a/modules/msg/mission_inc/default_cfe_msg_hdr_priext.h b/modules/msg/option_inc/default_cfe_msg_hdr_priext.h similarity index 100% rename from modules/msg/mission_inc/default_cfe_msg_hdr_priext.h rename to modules/msg/option_inc/default_cfe_msg_hdr_priext.h diff --git a/modules/msg/mission_inc/default_cfe_msg_sechdr.h b/modules/msg/option_inc/default_cfe_msg_sechdr.h similarity index 100% rename from modules/msg/mission_inc/default_cfe_msg_sechdr.h rename to modules/msg/option_inc/default_cfe_msg_sechdr.h diff --git a/modules/msg/unit-test-coverage/CMakeLists.txt b/modules/msg/ut-coverage/CMakeLists.txt similarity index 94% rename from modules/msg/unit-test-coverage/CMakeLists.txt rename to modules/msg/ut-coverage/CMakeLists.txt index dd06ff924..a0b12cb8a 100644 --- a/modules/msg/unit-test-coverage/CMakeLists.txt +++ b/modules/msg/ut-coverage/CMakeLists.txt @@ -48,14 +48,14 @@ endif (MISSION_MSGID_V2) add_executable(${DEP}_UT ${ut_${DEP}_tests}) # Add include to get private defaults -target_include_directories(${DEP}_UT PRIVATE ../private_inc) +target_include_directories(${DEP}_UT PRIVATE ../fsw/src) # Also add the UT_COVERAGE_LINK_FLAGS to the link command # This should enable coverage analysis on platforms that support this target_link_libraries(${DEP}_UT ${UT_COVERAGE_LINK_FLAGS} - ut_cfe-core_support - ut_cfe-core_stubs + ut_cfe_internal_intf_stubs + ut_cfe_app_intf_stubs ut_assert) add_test(${DEP}_UT ${DEP}_UT) diff --git a/modules/msg/unit-test-coverage/msg_UT.c b/modules/msg/ut-coverage/msg_UT.c similarity index 100% rename from modules/msg/unit-test-coverage/msg_UT.c rename to modules/msg/ut-coverage/msg_UT.c diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_ccsdsext.c b/modules/msg/ut-coverage/test_cfe_msg_ccsdsext.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_ccsdsext.c rename to modules/msg/ut-coverage/test_cfe_msg_ccsdsext.c index 07c2decac..f7eaed5b4 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_ccsdsext.c +++ b/modules/msg/ut-coverage/test_cfe_msg_ccsdsext.c @@ -27,7 +27,7 @@ */ #include "utassert.h" #include "ut_support.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" #include "test_msg_utils.h" #include "test_cfe_msg_ccsdsext.h" diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_ccsdsext.h b/modules/msg/ut-coverage/test_cfe_msg_ccsdsext.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_ccsdsext.h rename to modules/msg/ut-coverage/test_cfe_msg_ccsdsext.h diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_ccsdspri.c b/modules/msg/ut-coverage/test_cfe_msg_ccsdspri.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_ccsdspri.c rename to modules/msg/ut-coverage/test_cfe_msg_ccsdspri.c index daffa4947..816ed4f83 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_ccsdspri.c +++ b/modules/msg/ut-coverage/test_cfe_msg_ccsdspri.c @@ -27,7 +27,7 @@ */ #include "utassert.h" #include "ut_support.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" #include "test_msg_utils.h" #include "test_cfe_msg_ccsdspri.h" diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_ccsdspri.h b/modules/msg/ut-coverage/test_cfe_msg_ccsdspri.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_ccsdspri.h rename to modules/msg/ut-coverage/test_cfe_msg_ccsdspri.h diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_checksum.c b/modules/msg/ut-coverage/test_cfe_msg_checksum.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_checksum.c rename to modules/msg/ut-coverage/test_cfe_msg_checksum.c index ba2b8b7a2..c1b3b98eb 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_checksum.c +++ b/modules/msg/ut-coverage/test_cfe_msg_checksum.c @@ -29,7 +29,7 @@ #include "ut_support.h" #include "test_msg_not.h" #include "test_msg_utils.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_cfe_msg_checksum.h" #include "cfe_error.h" #include diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_checksum.h b/modules/msg/ut-coverage/test_cfe_msg_checksum.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_checksum.h rename to modules/msg/ut-coverage/test_cfe_msg_checksum.h diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_fc.c b/modules/msg/ut-coverage/test_cfe_msg_fc.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_fc.c rename to modules/msg/ut-coverage/test_cfe_msg_fc.c index 41828a2a0..88a907a68 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_fc.c +++ b/modules/msg/ut-coverage/test_cfe_msg_fc.c @@ -29,7 +29,7 @@ #include "ut_support.h" #include "test_msg_not.h" #include "test_msg_utils.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_cfe_msg_fc.h" #include "cfe_error.h" #include diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_fc.h b/modules/msg/ut-coverage/test_cfe_msg_fc.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_fc.h rename to modules/msg/ut-coverage/test_cfe_msg_fc.h diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_init.c b/modules/msg/ut-coverage/test_cfe_msg_init.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_init.c rename to modules/msg/ut-coverage/test_cfe_msg_init.c index 4c2cb4a5d..ef2353017 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_init.c +++ b/modules/msg/ut-coverage/test_cfe_msg_init.c @@ -29,7 +29,7 @@ #include "ut_support.h" #include "test_msg_not.h" #include "test_msg_utils.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_cfe_msg_init.h" #include "cfe_error.h" #include "cfe_msg_defaults.h" diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_init.h b/modules/msg/ut-coverage/test_cfe_msg_init.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_init.h rename to modules/msg/ut-coverage/test_cfe_msg_init.h diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_msgid.h b/modules/msg/ut-coverage/test_cfe_msg_msgid.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_msgid.h rename to modules/msg/ut-coverage/test_cfe_msg_msgid.h diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_msgid_shared.c b/modules/msg/ut-coverage/test_cfe_msg_msgid_shared.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_msgid_shared.c rename to modules/msg/ut-coverage/test_cfe_msg_msgid_shared.c index 16e4bcc9e..817308ff0 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_msgid_shared.c +++ b/modules/msg/ut-coverage/test_cfe_msg_msgid_shared.c @@ -27,7 +27,7 @@ */ #include "utassert.h" #include "ut_support.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" #include "test_msg_utils.h" #include "test_cfe_msg_msgid_shared.h" diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_msgid_shared.h b/modules/msg/ut-coverage/test_cfe_msg_msgid_shared.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_msgid_shared.h rename to modules/msg/ut-coverage/test_cfe_msg_msgid_shared.h diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_msgid_v1.c b/modules/msg/ut-coverage/test_cfe_msg_msgid_v1.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_msgid_v1.c rename to modules/msg/ut-coverage/test_cfe_msg_msgid_v1.c index 3afce7943..3f7ddd646 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_msgid_v1.c +++ b/modules/msg/ut-coverage/test_cfe_msg_msgid_v1.c @@ -24,7 +24,7 @@ #include "utassert.h" #include "ut_support.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" #include "test_msg_utils.h" #include "test_cfe_msg_msgid.h" diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_msgid_v2.c b/modules/msg/ut-coverage/test_cfe_msg_msgid_v2.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_msgid_v2.c rename to modules/msg/ut-coverage/test_cfe_msg_msgid_v2.c index a64664f73..ff0ef54fc 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_msgid_v2.c +++ b/modules/msg/ut-coverage/test_cfe_msg_msgid_v2.c @@ -27,7 +27,7 @@ */ #include "utassert.h" #include "ut_support.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" #include "test_msg_utils.h" #include "test_cfe_msg_msgid.h" diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_time.c b/modules/msg/ut-coverage/test_cfe_msg_time.c similarity index 99% rename from modules/msg/unit-test-coverage/test_cfe_msg_time.c rename to modules/msg/ut-coverage/test_cfe_msg_time.c index 657dbe227..c72eab80c 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_time.c +++ b/modules/msg/ut-coverage/test_cfe_msg_time.c @@ -29,7 +29,7 @@ #include "ut_support.h" #include "test_msg_not.h" #include "test_msg_utils.h" -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_cfe_msg_time.h" #include "cfe_error.h" #include diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_time.h b/modules/msg/ut-coverage/test_cfe_msg_time.h similarity index 100% rename from modules/msg/unit-test-coverage/test_cfe_msg_time.h rename to modules/msg/ut-coverage/test_cfe_msg_time.h diff --git a/modules/msg/unit-test-coverage/test_msg_ext_not.c b/modules/msg/ut-coverage/test_msg_ext_not.c similarity index 99% rename from modules/msg/unit-test-coverage/test_msg_ext_not.c rename to modules/msg/ut-coverage/test_msg_ext_not.c index d764bfabd..7bda6257a 100644 --- a/modules/msg/unit-test-coverage/test_msg_ext_not.c +++ b/modules/msg/ut-coverage/test_msg_ext_not.c @@ -25,7 +25,7 @@ /* * Includes */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" unsigned int Test_MSG_Ext_NotZero(const CFE_MSG_Message_t *MsgPtr) diff --git a/modules/msg/unit-test-coverage/test_msg_not.c b/modules/msg/ut-coverage/test_msg_not.c similarity index 98% rename from modules/msg/unit-test-coverage/test_msg_not.c rename to modules/msg/ut-coverage/test_msg_not.c index 8d7d60e86..39595129b 100644 --- a/modules/msg/unit-test-coverage/test_msg_not.c +++ b/modules/msg/ut-coverage/test_msg_not.c @@ -25,7 +25,7 @@ /* * Includes */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" unsigned int Test_MSG_NotZero(const CFE_MSG_Message_t *MsgPtr) diff --git a/modules/msg/unit-test-coverage/test_msg_not.h b/modules/msg/ut-coverage/test_msg_not.h similarity index 100% rename from modules/msg/unit-test-coverage/test_msg_not.h rename to modules/msg/ut-coverage/test_msg_not.h diff --git a/modules/msg/unit-test-coverage/test_msg_pri_not.c b/modules/msg/ut-coverage/test_msg_pri_not.c similarity index 99% rename from modules/msg/unit-test-coverage/test_msg_pri_not.c rename to modules/msg/ut-coverage/test_msg_pri_not.c index 3f35cf3b0..4c8e81afd 100644 --- a/modules/msg/unit-test-coverage/test_msg_pri_not.c +++ b/modules/msg/ut-coverage/test_msg_pri_not.c @@ -26,7 +26,7 @@ * Includes */ #include "test_cfe_msg_ccsdspri.h" /* For TEST_MSG_SIZE_OFFSET */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" unsigned int Test_MSG_Pri_NotZero(const CFE_MSG_Message_t *MsgPtr) diff --git a/modules/msg/unit-test-coverage/test_msg_prionly.c b/modules/msg/ut-coverage/test_msg_prionly.c similarity index 97% rename from modules/msg/unit-test-coverage/test_msg_prionly.c rename to modules/msg/ut-coverage/test_msg_prionly.c index 6df77d970..c85f95e5b 100644 --- a/modules/msg/unit-test-coverage/test_msg_prionly.c +++ b/modules/msg/ut-coverage/test_msg_prionly.c @@ -25,7 +25,7 @@ /* * Includes */ -#include "cfe_msg_api.h" +#include "cfe_msg.h" #include "test_msg_not.h" #include "test_cfe_msg_ccsdsext.h" diff --git a/modules/msg/unit-test-coverage/test_msg_utils.h b/modules/msg/ut-coverage/test_msg_utils.h similarity index 96% rename from modules/msg/unit-test-coverage/test_msg_utils.h rename to modules/msg/ut-coverage/test_msg_utils.h index e79eeda90..f95a9c017 100644 --- a/modules/msg/unit-test-coverage/test_msg_utils.h +++ b/modules/msg/ut-coverage/test_msg_utils.h @@ -27,7 +27,7 @@ /* * Includes */ -#include "cfe_msg_typedefs.h" +#include "cfe_msg_api_typedefs.h" /* * Defines diff --git a/modules/resourceid/CMakeLists.txt b/modules/resourceid/CMakeLists.txt index 5550cb33d..3bebdd1a7 100644 --- a/modules/resourceid/CMakeLists.txt +++ b/modules/resourceid/CMakeLists.txt @@ -7,12 +7,14 @@ project(CFE_RESOURCEID C) # Module library -set(resourceid_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_resourceid_api.c) +set(resourceid_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_resourceid_api.c +) add_library(resourceid STATIC ${resourceid_SOURCES}) -target_include_directories(resourceid PUBLIC inc) +target_link_libraries(resourceid PRIVATE cfe_internal_intf) # Add unit test coverage subdirectory if(ENABLE_UNIT_TESTS) - add_subdirectory(unit-test-coverage) + add_subdirectory(ut-coverage) endif(ENABLE_UNIT_TESTS) diff --git a/modules/resourceid/arch_build.cmake b/modules/resourceid/arch_build.cmake deleted file mode 100644 index 9d77078a7..000000000 --- a/modules/resourceid/arch_build.cmake +++ /dev/null @@ -1,13 +0,0 @@ -########################################################### -# -# Resource ID arch 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 -# -########################################################### - -# allow all other code to refer to the public API in the "inc" dir -# ideally this should use an interface library instead -include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) diff --git a/modules/resourceid/src/cfe_resourceid_api.c b/modules/resourceid/fsw/src/cfe_resourceid_api.c similarity index 99% rename from modules/resourceid/src/cfe_resourceid_api.c rename to modules/resourceid/fsw/src/cfe_resourceid_api.c index fd7a16718..531976151 100644 --- a/modules/resourceid/src/cfe_resourceid_api.c +++ b/modules/resourceid/fsw/src/cfe_resourceid_api.c @@ -38,7 +38,7 @@ #include #include "cfe.h" -#include "cfe_resourceid_api.h" +#include "cfe_resourceid.h" #include "cfe_resourceid_basevalue.h" diff --git a/modules/resourceid/mission_build.cmake b/modules/resourceid/mission_build.cmake index 31bd3e9d0..0b9a02189 100644 --- a/modules/resourceid/mission_build.cmake +++ b/modules/resourceid/mission_build.cmake @@ -18,7 +18,7 @@ endif () # Generate the header definition files, use local default for this module) generate_config_includefile( FILE_NAME "cfe_resourceid_typedef.h" - FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option/${RESOURCEID_HDR_FILE}" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option_inc/${RESOURCEID_HDR_FILE}" ) # Resource ID base value header @@ -26,7 +26,7 @@ generate_config_includefile( # but missions can provide their own if desired to override this. generate_config_includefile( FILE_NAME "cfe_resourceid_basevalue.h" - FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option/cfe_resourceid_osal_compatible.h" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/option_inc/cfe_resourceid_osal_compatible.h" ) include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) diff --git a/modules/resourceid/option/cfe_resourceid_osal_compatible.h b/modules/resourceid/option_inc/cfe_resourceid_osal_compatible.h similarity index 100% rename from modules/resourceid/option/cfe_resourceid_osal_compatible.h rename to modules/resourceid/option_inc/cfe_resourceid_osal_compatible.h diff --git a/modules/resourceid/option/cfe_resourceid_simple.h b/modules/resourceid/option_inc/cfe_resourceid_simple.h similarity index 100% rename from modules/resourceid/option/cfe_resourceid_simple.h rename to modules/resourceid/option_inc/cfe_resourceid_simple.h diff --git a/modules/resourceid/option/cfe_resourceid_strict.h b/modules/resourceid/option_inc/cfe_resourceid_strict.h similarity index 100% rename from modules/resourceid/option/cfe_resourceid_strict.h rename to modules/resourceid/option_inc/cfe_resourceid_strict.h diff --git a/modules/resourceid/unit-test-coverage/CMakeLists.txt b/modules/resourceid/ut-coverage/CMakeLists.txt similarity index 82% rename from modules/resourceid/unit-test-coverage/CMakeLists.txt rename to modules/resourceid/ut-coverage/CMakeLists.txt index 42ca3bde8..a8eae2d53 100644 --- a/modules/resourceid/unit-test-coverage/CMakeLists.txt +++ b/modules/resourceid/ut-coverage/CMakeLists.txt @@ -9,7 +9,12 @@ # Unit test object library sources, options, and includes add_library(ut_resourceid_OBJS OBJECT ${resourceid_SOURCES}) -target_compile_options(ut_resourceid_OBJS PRIVATE ${UT_COVERAGE_COMPILE_FLAGS}) +target_compile_options(ut_resourceid_OBJS PRIVATE + ${UT_COVERAGE_COMPILE_FLAGS} +) +target_include_directories(ut_resourceid_OBJS PRIVATE + $ +) # Add executable add_executable(resourceid_UT test_cfe_resourceid.c $) @@ -21,6 +26,7 @@ target_include_directories(resourceid_UT PRIVATE ${CFE_RESOURCEID_SOURCE_DIR}/op # This should enable coverage analysis on platforms that support this target_link_libraries(resourceid_UT ${UT_COVERAGE_LINK_FLAGS} + ut_cfe_internal_intf_stubs ut_assert) add_test(resourceid_UT resourceid_UT) diff --git a/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c b/modules/resourceid/ut-coverage/test_cfe_resourceid.c similarity index 99% rename from modules/resourceid/unit-test-coverage/test_cfe_resourceid.c rename to modules/resourceid/ut-coverage/test_cfe_resourceid.c index df59ffeaa..16b562dab 100644 --- a/modules/resourceid/unit-test-coverage/test_cfe_resourceid.c +++ b/modules/resourceid/ut-coverage/test_cfe_resourceid.c @@ -22,7 +22,7 @@ * Includes */ #include "cfe.h" -#include "cfe_resourceid_api.h" +#include "cfe_resourceid.h" #include "cfe_resourceid_basevalue.h" #include "utassert.h" #include "utstubs.h" diff --git a/fsw/cfe-core/src/inc/cfe_es.h b/modules/saved_inc/cfe_es.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_es.h rename to modules/saved_inc/cfe_es.h index 2e00165bf..8bb02a92e 100644 --- a/fsw/cfe-core/src/inc/cfe_es.h +++ b/modules/saved_inc/cfe_es.h @@ -43,7 +43,7 @@ #include "cfe_mission_cfg.h" #include "cfe_perfids.h" #include "cfe_error.h" -#include "cfe_resourceid_api.h" +#include "cfe_resourceid.h" /*****************************************************************************/ diff --git a/fsw/cfe-core/src/inc/cfe_evs.h b/modules/saved_inc/cfe_evs.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_evs.h rename to modules/saved_inc/cfe_evs.h diff --git a/fsw/cfe-core/src/inc/cfe_fs.h b/modules/saved_inc/cfe_fs.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_fs.h rename to modules/saved_inc/cfe_fs.h diff --git a/fsw/cfe-core/src/inc/cfe_sb.h b/modules/saved_inc/cfe_sb.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_sb.h rename to modules/saved_inc/cfe_sb.h index aa7862e37..d27068ced 100644 --- a/fsw/cfe-core/src/inc/cfe_sb.h +++ b/modules/saved_inc/cfe_sb.h @@ -41,9 +41,8 @@ #include "cfe_psp.h" #include "common_types.h" #include "cfe_mission_cfg.h" -#include "ccsds.h" #include "cfe_time.h" - +#include "cfe_msg_hdr.h" /* ** Defines diff --git a/fsw/cfe-core/src/inc/cfe_tbl.h b/modules/saved_inc/cfe_tbl.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_tbl.h rename to modules/saved_inc/cfe_tbl.h index 653d57be1..2c27cb53a 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl.h +++ b/modules/saved_inc/cfe_tbl.h @@ -45,7 +45,7 @@ #include "common_types.h" /* Basic Data Types */ #include "cfe_time.h" #include "osconfig.h" -#include "cfe_msg_typedefs.h" +#include "cfe_msg_api_typedefs.h" /******************* Macro Definitions ***********************/ diff --git a/fsw/cfe-core/src/inc/cfe_time.h b/modules/saved_inc/cfe_time.h similarity index 98% rename from fsw/cfe-core/src/inc/cfe_time.h rename to modules/saved_inc/cfe_time.h index 71ddc162f..97dd53cca 100644 --- a/fsw/cfe-core/src/inc/cfe_time.h +++ b/modules/saved_inc/cfe_time.h @@ -56,23 +56,6 @@ ** Type Definitions */ -/** -** \brief Data structure used to hold system time values -** -** \par Description -** The #CFE_TIME_SysTime_t data structure is used to hold time -** values. Time is referred to as the elapsed time (in seconds -** and subseconds) since a specified epoch time. The subseconds -** field contains the number of 2^(-32) second intervals that have -** elapsed since the epoch. -** -*/ -typedef struct CFE_TIME_SysTime -{ - uint32 Seconds; /**< \brief Number of seconds since epoch */ - uint32 Subseconds; /**< \brief Number of subseconds since epoch (LSB = 2^(-32) seconds) */ -} CFE_TIME_SysTime_t; - /** ** \brief Time Copy ** diff --git a/modules/sb/CMakeLists.txt b/modules/sb/CMakeLists.txt new file mode 100644 index 000000000..b72cabbc9 --- /dev/null +++ b/modules/sb/CMakeLists.txt @@ -0,0 +1,39 @@ +################################################################## +# +# cFE Software Bus (SB) module CMake build recipe +# +################################################################## + +project(CFE_SB C) + +# Software Bus source files +set(sb_SOURCES + fsw/src/cfe_sb_api.c + fsw/src/cfe_sb_buf.c + fsw/src/cfe_sb_init.c + fsw/src/cfe_sb_msg_id_util.c + fsw/src/cfe_sb_priv.c + fsw/src/cfe_sb_task.c + fsw/src/cfe_sb_util.c + fsw/src/cfe_sb_api.c + fsw/src/cfe_sb_buf.c + fsw/src/cfe_sb_init.c + fsw/src/cfe_sb_msg_id_util.c + fsw/src/cfe_sb_priv.c + fsw/src/cfe_sb_task.c + fsw/src/cfe_sb_util.c +) +add_library(sb STATIC ${sb_SOURCES}) + +target_include_directories(sb PUBLIC fsw/inc) +target_link_libraries(sb PRIVATE cfe_internal_intf) + +# Add unit test coverage subdirectory +if(ENABLE_UNIT_TESTS) + add_subdirectory(ut-coverage) +endif(ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + cfe_sb_msg.h + cfe_sb_events.h +) diff --git a/fsw/cfe-core/src/inc/cfe_sb_events.h b/modules/sb/fsw/inc/cfe_sb_events.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_sb_events.h rename to modules/sb/fsw/inc/cfe_sb_events.h diff --git a/fsw/cfe-core/src/inc/cfe_sb_msg.h b/modules/sb/fsw/inc/cfe_sb_msg.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_sb_msg.h rename to modules/sb/fsw/inc/cfe_sb_msg.h index e504f4b37..4912ea7e4 100644 --- a/fsw/cfe-core/src/inc/cfe_sb_msg.h +++ b/modules/sb/fsw/inc/cfe_sb_msg.h @@ -35,9 +35,10 @@ /* ** Includes */ -#include "common_types.h" -#include "cfe_sb.h" -#include "cfe_es.h" +#include "common_types.h" /* Basic data types */ +#include "cfe_msg_hdr.h" /* for header definitions */ +#include "cfe_sb_extern_typedefs.h" +#include "cfe_es_extern_typedefs.h" /**************************************** diff --git a/fsw/cfe-core/src/sb/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c similarity index 99% rename from fsw/cfe-core/src/sb/cfe_sb_api.c rename to modules/sb/fsw/src/cfe_sb_api.c index ba2eff5af..80099dd72 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -58,17 +58,9 @@ /* ** Include Files */ -#include "common_types.h" -#include "private/cfe_private.h" -#include "cfe_sb_events.h" -#include "cfe_sb_priv.h" -#include "cfe_sb.h" -#include "osapi.h" -#include "cfe_es.h" -#include "cfe_psp.h" -#include "cfe_error.h" +#include "cfe_sb_internal.h" + #include -#include "private/cfe_core_resourceid_basevalues.h" /* * Macro to reflect size of PipeDepthStats Telemetry array - diff --git a/fsw/cfe-core/src/sb/cfe_sb_buf.c b/modules/sb/fsw/src/cfe_sb_buf.c similarity index 98% rename from fsw/cfe-core/src/sb/cfe_sb_buf.c rename to modules/sb/fsw/src/cfe_sb_buf.c index ab87523e9..43f19339b 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_buf.c +++ b/modules/sb/fsw/src/cfe_sb_buf.c @@ -33,11 +33,7 @@ ** Include Files */ -#include "cfe_sb_priv.h" -#include "cfe_sb_events.h" -#include "osapi.h" -#include "cfe_es.h" -#include "cfe_error.h" +#include "cfe_sb_internal.h" /* * The actual message content of a SB Buffer Descriptor is the diff --git a/fsw/cfe-core/src/sb/cfe_sb_init.c b/modules/sb/fsw/src/cfe_sb_init.c similarity index 95% rename from fsw/cfe-core/src/sb/cfe_sb_init.c rename to modules/sb/fsw/src/cfe_sb_init.c index 561f88b48..745ad1dc7 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_init.c +++ b/modules/sb/fsw/src/cfe_sb_init.c @@ -32,15 +32,7 @@ ** Include Files */ -#include "cfe_sb_priv.h" -#include "cfe_sb.h" -#include "osapi.h" -#include "cfe_msgids.h" -#include "cfe_es.h" -#include "cfe_psp.h" -#include "cfe_error.h" -#include "cfe_sb_events.h" -#include "private/cfe_core_resourceid_basevalues.h" +#include "cfe_sb_internal.h" #include diff --git a/modules/sb/fsw/src/cfe_sb_internal.h b/modules/sb/fsw/src/cfe_sb_internal.h new file mode 100644 index 000000000..8cad7f4ee --- /dev/null +++ b/modules/sb/fsw/src/cfe_sb_internal.h @@ -0,0 +1,51 @@ +/* +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/****************************************************************************** +** File: cfe_sb_priv.h +** +** Purpose: +** This header file contains prototypes for private functions and type +** definitions for SB internal use. +** +** Author: R.McGraw/SSI +** +******************************************************************************/ + +#ifndef CFE_SB_INTERNAL_H +#define CFE_SB_INTERNAL_H + +/* +** Includes +*/ +#include "cfe.h" +#include "cfe_platform_cfg.h" +#include "cfe_msgids.h" +#include "cfe_perfids.h" +#include "cfe_sb_priv.h" +#include "cfe_sb_events.h" +#include "cfe_sb_destination_typedef.h" +#include "cfe_sb_msg.h" +#include "cfe_sbr.h" +#include "cfe_core_resourceid_basevalues.h" + + +#endif /* CFE_SB_INTERNAL_H */ +/*****************************************************************************/ diff --git a/fsw/cfe-core/src/sb/cfe_sb_msg_id_util.c b/modules/sb/fsw/src/cfe_sb_msg_id_util.c similarity index 93% rename from fsw/cfe-core/src/sb/cfe_sb_msg_id_util.c rename to modules/sb/fsw/src/cfe_sb_msg_id_util.c index 299dc931e..d30a51781 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_msg_id_util.c +++ b/modules/sb/fsw/src/cfe_sb_msg_id_util.c @@ -26,13 +26,8 @@ /* ** Include Files */ -#include "cfe_mission_cfg.h" -#include "ccsds.h" -#include "cfe_sb.h" -#include "osapi.h" -#include "cfe_error.h" -#include "cfe_sb_priv.h" -#include "cfe_msg_api.h" +#include "cfe_sb_internal.h" + #ifndef CFE_OMIT_DEPRECATED_6_8 /* diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.c b/modules/sb/fsw/src/cfe_sb_priv.c similarity index 98% rename from fsw/cfe-core/src/sb/cfe_sb_priv.c rename to modules/sb/fsw/src/cfe_sb_priv.c index fa478e631..6d620303b 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.c +++ b/modules/sb/fsw/src/cfe_sb_priv.c @@ -76,16 +76,8 @@ ** Include Files */ -#include "common_types.h" -#include "osapi.h" -#include "private/cfe_private.h" -#include "cfe_sb_priv.h" -#include "cfe_sb.h" -#include "ccsds.h" -#include "cfe_error.h" -#include "cfe_es.h" -#include "cfe_msg_api.h" -#include "cfe_msgids.h" +#include "cfe_sb_internal.h" + #include /****************************************************************************** diff --git a/fsw/cfe-core/src/sb/cfe_sb_priv.h b/modules/sb/fsw/src/cfe_sb_priv.h similarity index 98% rename from fsw/cfe-core/src/sb/cfe_sb_priv.h rename to modules/sb/fsw/src/cfe_sb_priv.h index de6e5096f..08d8cafaf 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_priv.h +++ b/modules/sb/fsw/src/cfe_sb_priv.h @@ -35,14 +35,16 @@ /* ** Includes */ +#include "cfe_platform_cfg.h" #include "common_types.h" -#include "private/cfe_private.h" -#include "private/cfe_sb_destination_typedef.h" -#include "cfe_sb.h" +#include "cfe_sb_api_typedefs.h" +#include "cfe_es_api_typedefs.h" +#include "cfe_sbr_api_typedefs.h" +#include "cfe_msg_api_typedefs.h" +#include "cfe_fs_api_typedefs.h" +#include "cfe_resourceid_api_typedefs.h" +#include "cfe_sb_destination_typedef.h" #include "cfe_sb_msg.h" -#include "cfe_time.h" -#include "cfe_es.h" -#include "private/cfe_sbr.h" /* ** Macro Definitions diff --git a/fsw/cfe-core/src/sb/cfe_sb_task.c b/modules/sb/fsw/src/cfe_sb_task.c similarity index 99% rename from fsw/cfe-core/src/sb/cfe_sb_task.c rename to modules/sb/fsw/src/cfe_sb_task.c index 69451816c..25dcf01db 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_task.c +++ b/modules/sb/fsw/src/cfe_sb_task.c @@ -30,18 +30,9 @@ /* Include Files */ -#include "cfe_sb.h" -#include "cfe_sb_events.h" -#include "cfe_evs.h" -#include "cfe_sb_priv.h" -#include "osapi.h" +#include "cfe_sb_internal.h" #include "cfe_version.h" -#include "cfe_msgids.h" -#include "cfe_error.h" -#include "cfe_es.h" -#include "cfe_psp.h" -#include "cfe_es_msg.h" -#include "cfe_sb_verify.h" + #include /* Task Globals */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_util.c b/modules/sb/fsw/src/cfe_sb_util.c similarity index 98% rename from fsw/cfe-core/src/sb/cfe_sb_util.c rename to modules/sb/fsw/src/cfe_sb_util.c index e8501a49b..e1581445a 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_util.c +++ b/modules/sb/fsw/src/cfe_sb_util.c @@ -34,12 +34,7 @@ ** Include Files */ -#include "cfe_sb.h" -#include "ccsds.h" -#include "osapi.h" -#include "cfe_error.h" -#include "cfe_msg_api.h" -#include "cfe_es.h" +#include "cfe_sb_internal.h" #include diff --git a/fsw/cfe-core/src/sb/cfe_sb_verify.h b/modules/sb/fsw/src/cfe_sb_verify.h similarity index 100% rename from fsw/cfe-core/src/sb/cfe_sb_verify.h rename to modules/sb/fsw/src/cfe_sb_verify.h diff --git a/modules/sb/ut-coverage/CMakeLists.txt b/modules/sb/ut-coverage/CMakeLists.txt new file mode 100644 index 000000000..11e674c02 --- /dev/null +++ b/modules/sb/ut-coverage/CMakeLists.txt @@ -0,0 +1,7 @@ +################################################################## +# +# cFE unit test CMake build recipe +# +################################################################## + +# Nothing yet - placeholder for future use diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/modules/sb/ut-coverage/sb_UT.c similarity index 99% rename from fsw/cfe-core/unit-test/sb_UT.c rename to modules/sb/ut-coverage/sb_UT.c index 535b4d215..0e0f26f7f 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/modules/sb/ut-coverage/sb_UT.c @@ -39,8 +39,8 @@ ** Includes */ #include "sb_UT.h" -#include "cfe_msg_api.h" -#include "private/cfe_core_resourceid_basevalues.h" +#include "cfe_msg.h" +#include "cfe_core_resourceid_basevalues.h" /* * A method to add an SB "Subtest" diff --git a/fsw/cfe-core/unit-test/sb_UT.h b/modules/sb/ut-coverage/sb_UT.h similarity index 100% rename from fsw/cfe-core/unit-test/sb_UT.h rename to modules/sb/ut-coverage/sb_UT.h diff --git a/modules/sbr/CMakeLists.txt b/modules/sbr/CMakeLists.txt index 615589ca3..a5d3c6be7 100644 --- a/modules/sbr/CMakeLists.txt +++ b/modules/sbr/CMakeLists.txt @@ -13,6 +13,8 @@ # ################################################################## +project(CFE_SBR C) + if (NOT MISSION_MSGMAP_IMPLEMENTATION) set(MISSION_MSGMAP_IMPLEMENTATION "DIRECT") endif (NOT MISSION_MSGMAP_IMPLEMENTATION) @@ -20,13 +22,13 @@ endif (NOT MISSION_MSGMAP_IMPLEMENTATION) if (MISSION_MSGMAP_IMPLEMENTATION STREQUAL "DIRECT") message(STATUS "Using direct map software bus routing implementation") set(${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_map_direct.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_route_unsorted.c) + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_sbr_map_direct.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_sbr_route_unsorted.c) elseif (MISSION_MSGMAP_IMPLEMENTATION STREQUAL "HASH") message(STATUS "Using hashed map software bus routing implementation") set(${DEP}_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_map_hash.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/cfe_sbr_route_unsorted.c) + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_sbr_map_hash.c + ${CMAKE_CURRENT_SOURCE_DIR}/fsw/src/cfe_sbr_route_unsorted.c) else() message(ERROR "Invalid software bush routing implementation selected:" MISSION_MSGMAP_IMPLEMENTATION) endif() @@ -36,8 +38,10 @@ add_library(${DEP} STATIC ${${DEP}_SRC}) # Add private include target_include_directories(${DEP} PRIVATE private_inc) +target_link_libraries(sbr PRIVATE cfe_internal_intf) # Add unit test coverage subdirectory if(ENABLE_UNIT_TESTS) - add_subdirectory(unit-test-coverage) + add_subdirectory(ut-coverage) endif(ENABLE_UNIT_TESTS) + diff --git a/modules/sbr/src/cfe_sbr_map_direct.c b/modules/sbr/fsw/src/cfe_sbr_map_direct.c similarity index 98% rename from modules/sbr/src/cfe_sbr_map_direct.c rename to modules/sbr/fsw/src/cfe_sbr_map_direct.c index 1545bf4ef..8aab2d0fa 100644 --- a/modules/sbr/src/cfe_sbr_map_direct.c +++ b/modules/sbr/fsw/src/cfe_sbr_map_direct.c @@ -32,10 +32,12 @@ */ #include "common_types.h" -#include "private/cfe_sbr.h" +#include "cfe_sbr.h" #include "cfe_sbr_priv.h" #include +#include "cfe_sb.h" + /* * Macro Definitions */ diff --git a/modules/sbr/src/cfe_sbr_map_hash.c b/modules/sbr/fsw/src/cfe_sbr_map_hash.c similarity index 99% rename from modules/sbr/src/cfe_sbr_map_hash.c rename to modules/sbr/fsw/src/cfe_sbr_map_hash.c index dd9b8bd5c..44a85dc8e 100644 --- a/modules/sbr/src/cfe_sbr_map_hash.c +++ b/modules/sbr/fsw/src/cfe_sbr_map_hash.c @@ -32,8 +32,10 @@ */ #include "common_types.h" -#include "private/cfe_sbr.h" +#include "cfe_sbr.h" #include "cfe_sbr_priv.h" +#include "cfe_sb.h" + #include #include diff --git a/modules/sbr/private_inc/cfe_sbr_priv.h b/modules/sbr/fsw/src/cfe_sbr_priv.h similarity index 98% rename from modules/sbr/private_inc/cfe_sbr_priv.h rename to modules/sbr/fsw/src/cfe_sbr_priv.h index ecabbb6bb..308185a05 100644 --- a/modules/sbr/private_inc/cfe_sbr_priv.h +++ b/modules/sbr/fsw/src/cfe_sbr_priv.h @@ -29,7 +29,7 @@ /* * Includes */ -#include "private/cfe_sbr.h" +#include "cfe_sbr.h" /****************************************************************************** diff --git a/modules/sbr/src/cfe_sbr_route_unsorted.c b/modules/sbr/fsw/src/cfe_sbr_route_unsorted.c similarity index 99% rename from modules/sbr/src/cfe_sbr_route_unsorted.c rename to modules/sbr/fsw/src/cfe_sbr_route_unsorted.c index d47aa4eb1..40404fc53 100644 --- a/modules/sbr/src/cfe_sbr_route_unsorted.c +++ b/modules/sbr/fsw/src/cfe_sbr_route_unsorted.c @@ -33,10 +33,12 @@ */ #include "common_types.h" -#include "private/cfe_sbr.h" +#include "cfe_sbr.h" #include "cfe_sbr_priv.h" #include +#include "cfe_sb.h" + /****************************************************************************** * Type Definitions */ diff --git a/modules/sbr/unit-test-coverage/CMakeLists.txt b/modules/sbr/ut-coverage/CMakeLists.txt similarity index 78% rename from modules/sbr/unit-test-coverage/CMakeLists.txt rename to modules/sbr/ut-coverage/CMakeLists.txt index 95b22232e..637c098a1 100644 --- a/modules/sbr/unit-test-coverage/CMakeLists.txt +++ b/modules/sbr/ut-coverage/CMakeLists.txt @@ -17,18 +17,18 @@ set(SBR_TEST_SET ${SBR_TEST_MAP_DIRECT} ${SBR_TEST_MAP_HASH} ${SBR_TEST_ROUTE_UN # Add configured map implementation to routing test source if (MISSION_MSGMAP_IMPLEMENTATION STREQUAL "DIRECT") - set(${SBR_TEST_ROUTE_UNSORTED}_SRC ../src/cfe_sbr_map_direct.c) + set(${SBR_TEST_ROUTE_UNSORTED}_SRC ${CFE_SBR_SOURCE_DIR}/fsw/src/cfe_sbr_map_direct.c) elseif (MISSION_MSGMAP_IMPLEMENTATION STREQUAL "HASH") - set(${SBR_TEST_ROUTE_UNSORTED}_SRC ../src/cfe_sbr_map_hash.c) + set(${SBR_TEST_ROUTE_UNSORTED}_SRC ${CFE_SBR_SOURCE_DIR}/fsw/src/cfe_sbr_map_hash.c) endif() # Add route implementation to map hash -set(${SBR_TEST_MAP_HASH}_SRC ../src/cfe_sbr_route_unsorted.c) +set(${SBR_TEST_MAP_HASH}_SRC ${CFE_SBR_SOURCE_DIR}/fsw/src/cfe_sbr_route_unsorted.c) foreach(SBR_TEST ${SBR_TEST_SET}) # Unit test object library sources, options, and includes - add_library(ut_${SBR_TEST}_objs OBJECT ${${SBR_TEST}_SRC} ../src/cfe_${SBR_TEST}.c) + add_library(ut_${SBR_TEST}_objs OBJECT ${${SBR_TEST}_SRC} ${CFE_SBR_SOURCE_DIR}/fsw/src/cfe_${SBR_TEST}.c) target_compile_options(ut_${SBR_TEST}_objs PRIVATE ${UT_COVERAGE_COMPILE_FLAGS}) target_include_directories(ut_${SBR_TEST}_objs PRIVATE $) @@ -41,14 +41,14 @@ foreach(SBR_TEST ${SBR_TEST_SET}) add_executable(${SBR_TEST}_UT ${ut_${SBR_TEST}_tests}) # Add include to get private defaults - target_include_directories(${SBR_TEST}_UT PRIVATE ../private_inc) + target_include_directories(${SBR_TEST}_UT PRIVATE ../fsw/src) # Also add the UT_COVERAGE_LINK_FLAGS to the link command # This should enable coverage analysis on platforms that support this target_link_libraries(${SBR_TEST}_UT ${UT_COVERAGE_LINK_FLAGS} - ut_cfe-core_support - ut_cfe-core_stubs + ut_cfe_internal_intf_stubs + ut_cfe_app_intf_stubs ut_assert) add_test(${SBR_TEST}_UT ${SBR_TEST}_UT) diff --git a/modules/sbr/unit-test-coverage/test_cfe_sbr_map_direct.c b/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c similarity index 99% rename from modules/sbr/unit-test-coverage/test_cfe_sbr_map_direct.c rename to modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c index c78c41e2a..f0ed6c102 100644 --- a/modules/sbr/unit-test-coverage/test_cfe_sbr_map_direct.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c @@ -27,7 +27,7 @@ */ #include "utassert.h" #include "ut_support.h" -#include "private/cfe_sbr.h" +#include "cfe_sbr.h" #include "cfe_sbr_priv.h" #include diff --git a/modules/sbr/unit-test-coverage/test_cfe_sbr_map_hash.c b/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c similarity index 99% rename from modules/sbr/unit-test-coverage/test_cfe_sbr_map_hash.c rename to modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c index 1ba6c0db2..0b7586ad4 100644 --- a/modules/sbr/unit-test-coverage/test_cfe_sbr_map_hash.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c @@ -27,7 +27,7 @@ */ #include "utassert.h" #include "ut_support.h" -#include "private/cfe_sbr.h" +#include "cfe_sbr.h" #include "cfe_sbr_priv.h" /* diff --git a/modules/sbr/unit-test-coverage/test_cfe_sbr_route_unsorted.c b/modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c similarity index 99% rename from modules/sbr/unit-test-coverage/test_cfe_sbr_route_unsorted.c rename to modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c index 2c202d6e0..22f436664 100644 --- a/modules/sbr/unit-test-coverage/test_cfe_sbr_route_unsorted.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c @@ -27,7 +27,7 @@ */ #include "utassert.h" #include "ut_support.h" -#include "private/cfe_sbr.h" +#include "cfe_sbr.h" #include "cfe_sbr_priv.h" /* Callback function for testing */ diff --git a/modules/tbl/CMakeLists.txt b/modules/tbl/CMakeLists.txt new file mode 100644 index 000000000..1c5ffbf70 --- /dev/null +++ b/modules/tbl/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################## +# +# cFE Table Services (TBL) module CMake build recipe +# +################################################################## + +project(CFE_TBL C) + +# Table Services source files +set(tbl_SOURCES + fsw/src/cfe_tbl_api.c + fsw/src/cfe_tbl_internal.c + fsw/src/cfe_tbl_task.c + fsw/src/cfe_tbl_task_cmds.c + fsw/src/cfe_tbl_api.c + fsw/src/cfe_tbl_internal.c + fsw/src/cfe_tbl_task.c + fsw/src/cfe_tbl_task_cmds.c +) +add_library(tbl STATIC ${tbl_SOURCES}) + +target_include_directories(tbl PUBLIC fsw/inc) +target_link_libraries(tbl PRIVATE cfe_internal_intf) + +# Add unit test coverage subdirectory +if(ENABLE_UNIT_TESTS) + add_subdirectory(ut-coverage) +endif(ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + cfe_tbl_msg.h + cfe_tbl_events.h +) diff --git a/fsw/cfe-core/src/inc/cfe_tbl_events.h b/modules/tbl/fsw/inc/cfe_tbl_events.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_tbl_events.h rename to modules/tbl/fsw/inc/cfe_tbl_events.h diff --git a/fsw/cfe-core/src/inc/cfe_tbl_msg.h b/modules/tbl/fsw/inc/cfe_tbl_msg.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_tbl_msg.h rename to modules/tbl/fsw/inc/cfe_tbl_msg.h index e4d83d211..54a9ad1a5 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl_msg.h +++ b/modules/tbl/fsw/inc/cfe_tbl_msg.h @@ -38,7 +38,10 @@ /* ** Required header files... */ -#include "cfe.h" +#include "common_types.h" /* Basic data types */ +#include "cfe_msg_hdr.h" /* for header definitions */ +#include "cfe_tbl_extern_typedefs.h" +#include "cfe_time_extern_typedefs.h" /*************************************************************************/ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/modules/tbl/fsw/src/cfe_tbl_api.c similarity index 99% rename from fsw/cfe-core/src/tbl/cfe_tbl_api.c rename to modules/tbl/fsw/src/cfe_tbl_api.c index 1b58a2e69..e430b7dc2 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/modules/tbl/fsw/src/cfe_tbl_api.c @@ -33,13 +33,9 @@ /* ** Required header files... */ -#include -#include "private/cfe_private.h" -#include "cfe_es.h" -#include "cfe_tbl.h" -#include "cfe_error.h" #include "cfe_tbl_internal.h" -#include "cfe_psp.h" + +#include /* ** Local Macros diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/modules/tbl/fsw/src/cfe_tbl_internal.c similarity index 99% rename from fsw/cfe-core/src/tbl/cfe_tbl_internal.c rename to modules/tbl/fsw/src/cfe_tbl_internal.c index c50b6b116..49254d173 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c +++ b/modules/tbl/fsw/src/cfe_tbl_internal.c @@ -33,14 +33,8 @@ /* ** Required header files... */ -#include "cfe_msgids.h" #include "cfe_tbl_internal.h" -#include "cfe_tbl_events.h" -#include "cfe_error.h" -#include "cfe_es.h" -#include "cfe_evs.h" -#include "cfe_fs.h" -#include "cfe_psp.h" + #include #include diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h b/modules/tbl/fsw/src/cfe_tbl_internal.h similarity index 98% rename from fsw/cfe-core/src/tbl/cfe_tbl_internal.h rename to modules/tbl/fsw/src/cfe_tbl_internal.h index 7fbdb25c3..a94205fa8 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.h +++ b/modules/tbl/fsw/src/cfe_tbl_internal.h @@ -29,15 +29,20 @@ ** */ -#ifndef _cfe_tbl_internal_ -#define _cfe_tbl_internal_ +#ifndef CFE_TBL_INTERNAL_H +#define CFE_TBL_INTERNAL_H /* ** Required header files... */ -#include "cfe_tbl.h" +#include "cfe.h" +#include "cfe_platform_cfg.h" +#include "cfe_msgids.h" +#include "cfe_perfids.h" #include "cfe_tbl_task.h" -#include "cfe_tbl_filedef.h" +#include "cfe_tbl_task_cmds.h" +#include "cfe_tbl_events.h" +#include "cfe_tbl_msg.h" /********************* Macro and Constant Type Definitions ***************************/ @@ -595,4 +600,4 @@ extern CFE_TBL_Global_t CFE_TBL_Global; -#endif /* _cfe_tbl_internal_ */ +#endif /* CFE_TBL_INTERNAL_H */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.c b/modules/tbl/fsw/src/cfe_tbl_task.c similarity index 98% rename from fsw/cfe-core/src/tbl/cfe_tbl_task.c rename to modules/tbl/fsw/src/cfe_tbl_task.c index 3583e8cd3..adfde2280 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.c +++ b/modules/tbl/fsw/src/cfe_tbl_task.c @@ -33,14 +33,9 @@ /* ** Required header files */ -#include "private/cfe_private.h" -#include "cfe_version.h" #include "cfe_tbl_internal.h" -#include "cfe_tbl_events.h" -#include "cfe_tbl_msg.h" -#include "cfe_tbl_task_cmds.h" -#include "cfe_tbl_verify.h" -#include "cfe_msgids.h" +#include "cfe_version.h" + #include diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.h b/modules/tbl/fsw/src/cfe_tbl_task.h similarity index 99% rename from fsw/cfe-core/src/tbl/cfe_tbl_task.h rename to modules/tbl/fsw/src/cfe_tbl_task.h index e17ddf804..2c88fb7a1 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.h +++ b/modules/tbl/fsw/src/cfe_tbl_task.h @@ -39,8 +39,6 @@ /* ** Required header files */ -#include "private/cfe_private.h" -#include "cfe_tbl_events.h" #include "cfe_tbl_msg.h" diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c similarity index 99% rename from fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c rename to modules/tbl/fsw/src/cfe_tbl_task_cmds.c index 23b335760..e70e02e94 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c @@ -33,16 +33,9 @@ /* ** Required header files */ -#include "cfe_version.h" -#include "cfe_evs.h" -#include "cfe_es.h" -#include "cfe_sb.h" -#include "cfe_fs.h" -#include "cfe_psp.h" #include "cfe_tbl_internal.h" -#include "cfe_tbl_events.h" -#include "cfe_tbl_msg.h" -#include "cfe_tbl_task_cmds.h" +#include "cfe_version.h" + #include diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h b/modules/tbl/fsw/src/cfe_tbl_task_cmds.h similarity index 99% rename from fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h rename to modules/tbl/fsw/src/cfe_tbl_task_cmds.h index fb04b98af..d77f435e3 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h +++ b/modules/tbl/fsw/src/cfe_tbl_task_cmds.h @@ -35,7 +35,12 @@ /* ** Required header files */ -#include "cfe.h" +#include "common_types.h" +#include "cfe_tbl_task.h" +#include "cfe_tbl_msg.h" +#include "cfe_error.h" + +#include "cfe_sb_extern_typedefs.h" /********************* Macro and Constant Type Definitions ***************************/ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_verify.h b/modules/tbl/fsw/src/cfe_tbl_verify.h similarity index 100% rename from fsw/cfe-core/src/tbl/cfe_tbl_verify.h rename to modules/tbl/fsw/src/cfe_tbl_verify.h diff --git a/modules/tbl/ut-coverage/CMakeLists.txt b/modules/tbl/ut-coverage/CMakeLists.txt new file mode 100644 index 000000000..11e674c02 --- /dev/null +++ b/modules/tbl/ut-coverage/CMakeLists.txt @@ -0,0 +1,7 @@ +################################################################## +# +# cFE unit test CMake build recipe +# +################################################################## + +# Nothing yet - placeholder for future use diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/modules/tbl/ut-coverage/tbl_UT.c similarity index 99% rename from fsw/cfe-core/unit-test/tbl_UT.c rename to modules/tbl/ut-coverage/tbl_UT.c index b05d508b4..6a4e869a7 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/modules/tbl/ut-coverage/tbl_UT.c @@ -39,7 +39,7 @@ ** Includes */ #include "tbl_UT.h" -#include "private/cfe_core_resourceid_basevalues.h" +#include "cfe_core_resourceid_basevalues.h" /* ** External global variables diff --git a/fsw/cfe-core/unit-test/tbl_UT.h b/modules/tbl/ut-coverage/tbl_UT.h similarity index 100% rename from fsw/cfe-core/unit-test/tbl_UT.h rename to modules/tbl/ut-coverage/tbl_UT.h diff --git a/modules/time/CMakeLists.txt b/modules/time/CMakeLists.txt new file mode 100644 index 000000000..3644cce5b --- /dev/null +++ b/modules/time/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################## +# +# cFE Time Services (TIME) module CMake build recipe +# +################################################################## + +project(CFE_TIME C) + +# Time Services source files +set(time_SOURCES + fsw/src/cfe_time_api.c + fsw/src/cfe_time_task.c + fsw/src/cfe_time_tone.c + fsw/src/cfe_time_utils.c + fsw/src/cfe_time_api.c + fsw/src/cfe_time_task.c + fsw/src/cfe_time_tone.c + fsw/src/cfe_time_utils.c +) +add_library(time STATIC ${time_SOURCES}) + +target_include_directories(time PUBLIC fsw/inc) +target_link_libraries(time PRIVATE cfe_internal_intf) + +# Add unit test coverage subdirectory +if(ENABLE_UNIT_TESTS) + add_subdirectory(ut-coverage) +endif(ENABLE_UNIT_TESTS) + +cfs_app_check_intf(${DEP} + cfe_time_events.h + cfe_time_msg.h +) diff --git a/fsw/cfe-core/src/inc/cfe_time_events.h b/modules/time/fsw/inc/cfe_time_events.h similarity index 100% rename from fsw/cfe-core/src/inc/cfe_time_events.h rename to modules/time/fsw/inc/cfe_time_events.h diff --git a/fsw/cfe-core/src/inc/cfe_time_msg.h b/modules/time/fsw/inc/cfe_time_msg.h similarity index 99% rename from fsw/cfe-core/src/inc/cfe_time_msg.h rename to modules/time/fsw/inc/cfe_time_msg.h index 2345a05b8..7d952188b 100644 --- a/fsw/cfe-core/src/inc/cfe_time_msg.h +++ b/modules/time/fsw/inc/cfe_time_msg.h @@ -38,7 +38,9 @@ /* ** Required header files... */ -#include "cfe.h" +#include "common_types.h" /* Basic data types */ +#include "cfe_msg_hdr.h" /* for header definitions */ +#include "cfe_time_extern_typedefs.h" /*************************************************************************/ diff --git a/fsw/cfe-core/src/time/cfe_time_api.c b/modules/time/fsw/src/cfe_time_api.c similarity index 99% rename from fsw/cfe-core/src/time/cfe_time_api.c rename to modules/time/fsw/src/cfe_time_api.c index bab936009..d3a6b6507 100644 --- a/fsw/cfe-core/src/time/cfe_time_api.c +++ b/modules/time/fsw/src/cfe_time_api.c @@ -35,6 +35,8 @@ */ #include "cfe_time_utils.h" +#include "cfe_es.h" + #include /* diff --git a/fsw/cfe-core/src/time/cfe_time_task.c b/modules/time/fsw/src/cfe_time_task.c similarity index 99% rename from fsw/cfe-core/src/time/cfe_time_task.c rename to modules/time/fsw/src/cfe_time_task.c index 66e6bb9f0..3457b4b83 100644 --- a/fsw/cfe-core/src/time/cfe_time_task.c +++ b/modules/time/fsw/src/cfe_time_task.c @@ -36,6 +36,12 @@ #include "cfe_time_utils.h" #include "cfe_version.h" #include "cfe_msgids.h" +#include "cfe_perfids.h" + +#include "cfe_es.h" +#include "cfe_evs.h" +#include "cfe_msg.h" +#include "cfe_sb.h" /* ** Time task global data... diff --git a/fsw/cfe-core/src/time/cfe_time_tone.c b/modules/time/fsw/src/cfe_time_tone.c similarity index 99% rename from fsw/cfe-core/src/time/cfe_time_tone.c rename to modules/time/fsw/src/cfe_time_tone.c index 1505d6a73..77a896a4f 100644 --- a/fsw/cfe-core/src/time/cfe_time_tone.c +++ b/modules/time/fsw/src/cfe_time_tone.c @@ -42,6 +42,14 @@ */ #include "cfe_time_utils.h" +#include "cfe_msgids.h" +#include "cfe_perfids.h" + +#include "cfe_es.h" +#include "cfe_evs.h" +#include "cfe_msg.h" +#include "cfe_sb.h" + #include /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/fsw/cfe-core/src/time/cfe_time_utils.c b/modules/time/fsw/src/cfe_time_utils.c similarity index 99% rename from fsw/cfe-core/src/time/cfe_time_utils.c rename to modules/time/fsw/src/cfe_time_utils.c index 9718fbad0..85b1de2fb 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.c +++ b/modules/time/fsw/src/cfe_time_utils.c @@ -34,7 +34,11 @@ */ #include "cfe_time_utils.h" #include "cfe_msgids.h" -#include "private/cfe_es_resetdata_typedef.h" +#include "cfe_es_resetdata_typedef.h" + +#include "cfe_es.h" +#include "cfe_msg.h" +#include "cfe_sb.h" #include diff --git a/fsw/cfe-core/src/time/cfe_time_utils.h b/modules/time/fsw/src/cfe_time_utils.h similarity index 99% rename from fsw/cfe-core/src/time/cfe_time_utils.h rename to modules/time/fsw/src/cfe_time_utils.h index 2e52298bd..a367528e2 100644 --- a/fsw/cfe-core/src/time/cfe_time_utils.h +++ b/modules/time/fsw/src/cfe_time_utils.h @@ -38,13 +38,16 @@ /* ** Required header files... */ +#include "cfe_time.h" #include "cfe_platform_cfg.h" -#include "cfe.h" #include "cfe_time_verify.h" #include "cfe_time_msg.h" #include "cfe_time_events.h" #include "cfe_psp.h" +#include "cfe_sb_api_typedefs.h" +#include "cfe_es_api_typedefs.h" + /*************************************************************************/ #define CFE_TIME_NEGATIVE 0x80000000 /* ~ 68 * 31,536,000 seconds */ diff --git a/fsw/cfe-core/src/time/cfe_time_verify.h b/modules/time/fsw/src/cfe_time_verify.h similarity index 99% rename from fsw/cfe-core/src/time/cfe_time_verify.h rename to modules/time/fsw/src/cfe_time_verify.h index c754d37ff..539805df0 100644 --- a/fsw/cfe-core/src/time/cfe_time_verify.h +++ b/modules/time/fsw/src/cfe_time_verify.h @@ -36,6 +36,9 @@ #ifndef _cfe_time_verify_ #define _cfe_time_verify_ +#include "cfe_mission_cfg.h" +#include "cfe_platform_cfg.h" + /*************************************************************************/ /* diff --git a/modules/time/ut-coverage/CMakeLists.txt b/modules/time/ut-coverage/CMakeLists.txt new file mode 100644 index 000000000..11e674c02 --- /dev/null +++ b/modules/time/ut-coverage/CMakeLists.txt @@ -0,0 +1,7 @@ +################################################################## +# +# cFE unit test CMake build recipe +# +################################################################## + +# Nothing yet - placeholder for future use diff --git a/fsw/cfe-core/unit-test/time_UT.c b/modules/time/ut-coverage/time_UT.c similarity index 100% rename from fsw/cfe-core/unit-test/time_UT.c rename to modules/time/ut-coverage/time_UT.c diff --git a/fsw/cfe-core/unit-test/time_UT.h b/modules/time/ut-coverage/time_UT.h similarity index 100% rename from fsw/cfe-core/unit-test/time_UT.h rename to modules/time/ut-coverage/time_UT.h