Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration candidate 2019-10-09 #378

Merged
merged 4 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix #25: Ensure table file header definition is consistent
To ensure consistency in the size of the CFE_TBL_FileHdr_t struct,
this should be constrained to use only mission-scope definitions.

Also simplifies the structure definitions by _NOT_ padding strings
out to 32 bit multiples.  The default size of the strings are
already 32 bit multiples so this is just unnecessary complexity.
There is also no major issue if not 32 bit aligned, as the
compiler will add it automatically where needed.

Add a note in the related cfe_mission_cfg.h descriptions to
affected values, that these should be kept as a multiple of 4
to maintain alignment.

Updated for 2019-09-16 code review:
 - Added compile-time verification that the configuration
   directives are actually multiples of 4.
  • Loading branch information
jphickey committed Oct 8, 2019
commit 8fe60c31eee5ce00853da9cd980aac96dc8978b8
83 changes: 65 additions & 18 deletions cmake/sample_defs/sample_mission_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@
**
**
** \par Limits
** Not Applicable
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
**
*/
#define CFE_MISSION_ES_CDS_MAX_NAME_LENGTH 16

Expand All @@ -310,7 +312,7 @@
** \cfeevscfg Maximum Event Message Length
**
** \par Description:
** Indicates the maximum length (in characers) of the formatted text
** Indicates the maximum length (in characters) of the formatted text
** string portion of an event message
**
** \par Limits
Expand Down Expand Up @@ -349,7 +351,8 @@
** form: "ApplicationName.TblName"
**
** \par Limits
** Not Applicable
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
*/
#define CFE_MISSION_TBL_MAX_NAME_LENGTH 16

Expand Down Expand Up @@ -500,6 +503,8 @@
** Note this affects the size of messages, so it must not cause any message
** to exceed the max length.
**
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
*/
#define CFE_MISSION_ES_MAX_SHELL_CMD 64

Expand All @@ -522,6 +527,9 @@
** Note this affects the size of messages, so it must not cause any message
** to exceed the max length.
**
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
**
*/
#define CFE_MISSION_ES_MAX_SHELL_PKT 64

Expand All @@ -547,7 +555,8 @@
**
** \par Description:
** Indicates the maximum length (in characters) of the entire table name
** within software bus messages
** within software bus messages, in "AppName.TableName" notation.
**
** This affects the layout of command/telemetry messages but does not affect run
** time behavior or internal allocation.
**
Expand All @@ -556,8 +565,10 @@
** Note this affects the size of messages, so it must not cause any message
** to exceed the max length.
**
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
*/
#define CFE_MISSION_TBL_MAX_FULL_NAME_LEN (CFE_MISSION_TBL_MAX_NAME_LENGTH + CFE_MISSION_MAX_API_LEN + 2)
#define CFE_MISSION_TBL_MAX_FULL_NAME_LEN (CFE_MISSION_TBL_MAX_NAME_LENGTH + CFE_MISSION_MAX_API_LEN + 4)

/**
** \cfesbcfg Maximum Number of pipes that SB command/telemetry messages may hold
Expand All @@ -578,43 +589,76 @@


/**
** \cfemissioncfg cFE Maximum length for filenames in messages
** \cfemissioncfg cFE Maximum length for pathnames within data exchange structures
**
** \par Description:
** The value of this constant dictates the size of filenames within SB messages.
** The value of this constant dictates the size of pathnames within all structures
** used for external data exchange, such as Software bus messages and table definitions.
** This is typically the same as OS_MAX_PATH_LEN but that is OSAL dependent --
** and as such it definable on a per-processor/OS basis and hence may be different
** across multiple processors. Since this defines a message format, it must be
** consistent across ALL processors exchanging SB messages.
** across multiple processors. It is recommended to set this to the value of the
** largest OS_MAX_PATH_LEN in use on any CPU on the mission.
**
** This affects the layout of command/telemetry messages but does not affect run
** time behavior or internal allocation.
** This affects only the layout of command/telemetry messages and table definitions;
** internal allocation may use the platform-specific OS_MAX_PATH_LEN value.
**
** \par Limits
** All CPUs within the same SB domain (mission) must share the same definition
** All CPUs within the same SB domain (mission) and ground tools must share the
** same definition.
** Note this affects the size of messages, so it must not cause any message
** to exceed the max length.
**
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
*/
#define CFE_MISSION_MAX_PATH_LEN 64

/**
** \cfemissioncfg cFE Maximum length for API names in messages
** \cfemissioncfg cFE Maximum length for filenames within data exchange structures
**
** \par Description:
** The value of this constant dictates the size of API names within SB messages.
** The value of this constant dictates the size of filenames within all structures
** used for external data exchange, such as Software bus messages and table definitions.
** This is typically the same as OS_MAX_FILE_LEN but that is OSAL dependent --
** and as such it definable on a per-processor/OS basis and hence may be different
** across multiple processors. It is recommended to set this to the value of the
** largest OS_MAX_FILE_LEN in use on any CPU on the mission.
**
** This affects only the layout of command/telemetry messages and table definitions;
** internal allocation may use the platform-specific OS_MAX_FILE_LEN value.
**
** \par Limits
** All CPUs within the same SB domain (mission) and ground tools must share the
** same definition.
** Note this affects the size of messages, so it must not cause any message
** to exceed the max length.
**
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
*/
#define CFE_MISSION_MAX_FILE_LEN 20

/**
** \cfemissioncfg cFE Maximum length for API names within data exchange structures
**
** \par Description:
** The value of this constant dictates the size of filenames within all structures
** used for external data exchange, such as Software bus messages and table definitions.
** This is typically the same as OS_MAX_API_LEN but that is OSAL dependent --
** and as such it definable on a per-processor/OS basis and hence may be different
** across multiple processors.
** across multiple processors. It is recommended to set this to the value of the
** largest OS_MAX_API_LEN in use on any CPU on the mission.
**
** This affects the layout of command/telemetry messages but does not affect run
** time behavior or internal allocation.
** This affects only the layout of command/telemetry messages and table definitions;
** internal allocation may use the platform-specific OS_MAX_API_LEN value.
**
** \par Limits
** All CPUs within the same SB domain (mission) must share the same definition
** Note this affects the size of messages, so it must not cause any message
** to exceed the max length.
**
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
*/
#define CFE_MISSION_MAX_API_LEN 20

Expand All @@ -632,8 +676,11 @@
** All CPUs within the same SB domain (mission) must share the same definition
** Note this affects the size of messages, so it must not cause any message
** to exceed the max length.
**
** This value should be kept as a multiple of 4, to maintain alignment of
** any possible neighboring fields without implicit padding.
*/
#define CFE_MISSION_ES_CDS_MAX_NAME_LEN (CFE_MISSION_ES_CDS_MAX_NAME_LENGTH + CFE_MISSION_MAX_API_LEN + 2)
#define CFE_MISSION_ES_CDS_MAX_NAME_LEN (CFE_MISSION_ES_CDS_MAX_NAME_LENGTH + CFE_MISSION_MAX_API_LEN + 4)


/*
Expand Down
24 changes: 24 additions & 0 deletions fsw/cfe-core/src/es/cfe_es_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,29 @@
#error CFE_PLATFORM_ES_START_TASK_STACK_SIZE must be greater than or equal to 2048
#endif


#if ((CFE_MISSION_MAX_API_LEN % 4) != 0)
#error CFE_MISSION_MAX_API_LEN must be a multiple of 4
#endif
#if ((CFE_MISSION_MAX_PATH_LEN % 4) != 0)
#error CFE_MISSION_MAX_PATH_LEN must be a multiple of 4
#endif
#if ((CFE_MISSION_MAX_FILE_LEN % 4) != 0)
#error CFE_MISSION_MAX_FILE_LEN must be a multiple of 4
#endif
#if ((CFE_MISSION_ES_MAX_SHELL_CMD % 4) != 0)
#error CFE_MISSION_ES_MAX_SHELL_CMD must be a multiple of 4
#endif
#if ((CFE_MISSION_ES_MAX_SHELL_PKT % 4) != 0)
#error CFE_MISSION_ES_MAX_SHELL_PKT must be a multiple of 4
#endif
#if ((CFE_MISSION_ES_CDS_MAX_NAME_LENGTH % 4) != 0)
#error CFE_MISSION_ES_CDS_MAX_NAME_LENGTH must be a multiple of 4
#endif
#if ((CFE_MISSION_ES_CDS_MAX_NAME_LEN % 4) != 0)
#error CFE_MISSION_ES_CDS_MAX_NAME_LEN must be a multiple of 4
#endif


#endif /* _cfe_es_verify_ */
/*****************************************************************************/
29 changes: 0 additions & 29 deletions fsw/cfe-core/src/inc/cfe_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@



/******************* Macro Definitions ***********************/
#define CFE_FS_HDR_DESC_MAX_LEN 32 /**< \brief Max length of description field in a standard cFE File Header */

#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE compliant files (= 'cFE1') */


/*
* To preserve source-code compatibility with existing code,
* this allows the old enum names to still work. This should
Expand Down Expand Up @@ -77,29 +71,6 @@

#endif /* CFE_OMIT_DEPRECATED_6_6 */


/**
** \brief Standard cFE File header structure definition
*/
typedef struct
{
uint32 ContentType; /**< \brief Identifies the content type (='cFE1'=0x63464531)*/
uint32 SubType; /**< \brief Type of \c ContentType, if necessary */
/**< Standard SubType definitions can be found
\link #CFE_FS_SubType_ES_ERLOG here \endlink */
uint32 Length; /**< \brief Length of primary header */
uint32 SpacecraftID; /**< \brief Spacecraft that generated the file */
uint32 ProcessorID; /**< \brief Processor that generated the file */
uint32 ApplicationID; /**< \brief Application that generated the file */

uint32 TimeSeconds; /**< \brief File creation timestamp (seconds) */
uint32 TimeSubSeconds; /**< \brief File creation timestamp (sub-seconds) */

char Description[CFE_FS_HDR_DESC_MAX_LEN]; /**< \brief File description */

} CFE_FS_Header_t;


/*
** File header access functions...
*/
Expand Down
38 changes: 38 additions & 0 deletions fsw/cfe-core/src/inc/cfe_fs_extern_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@

#include "common_types.h"

/******************* Macro Definitions ***********************/

/*
* NOTE: the value of CFE_FS_HDR_DESC_MAX_LEN, if modified, should
* be constrained to multiples of 4, as it is used within a structure that
* also contains uint32 types. This ensures that the entire structure
* remains 32-bit aligned without the need for implicit padding bytes.
*/

#define CFE_FS_HDR_DESC_MAX_LEN 32 /**< \brief Max length of description field in a standard cFE File Header */

#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE compliant files (= 'cFE1') */



/**
* @brief Label definitions associated with CFE_FS_SubType_Enum_t
*/
Expand Down Expand Up @@ -202,6 +217,29 @@ enum CFE_FS_SubType
typedef uint32 CFE_FS_SubType_Enum_t;


/**
** \brief Standard cFE File header structure definition
*/
typedef struct
{
uint32 ContentType; /**< \brief Identifies the content type (='cFE1'=0x63464531)*/
uint32 SubType; /**< \brief Type of \c ContentType, if necessary */
/**< Standard SubType definitions can be found
\link #CFE_FS_SubType_ES_ERLOG here \endlink */
uint32 Length; /**< \brief Length of primary header */
uint32 SpacecraftID; /**< \brief Spacecraft that generated the file */
uint32 ProcessorID; /**< \brief Processor that generated the file */
uint32 ApplicationID; /**< \brief Application that generated the file */

uint32 TimeSeconds; /**< \brief File creation timestamp (seconds) */
uint32 TimeSubSeconds; /**< \brief File creation timestamp (sub-seconds) */

char Description[CFE_FS_HDR_DESC_MAX_LEN]; /**< \brief File description */

} CFE_FS_Header_t;




#endif /* CFE_EDS_ENABLED_BUILD */

Expand Down
11 changes: 6 additions & 5 deletions fsw/cfe-core/src/inc/cfe_tbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@

#define CFE_TBL_OPT_DEFAULT (CFE_TBL_OPT_SNGL_BUFFER | CFE_TBL_OPT_LOAD_DUMP)

/** Computation for maximum length allowed for a table name. <BR>
** NOTE: "+2" is for NULL Character and "." (i.e. - "AppName.TblName") */
#define CFE_TBL_MAX_FULL_NAME_LEN_COMP (CFE_MISSION_TBL_MAX_NAME_LENGTH + OS_MAX_API_NAME + 2)
/* Ensure the table name falls on a 4-byte boundary */
#define CFE_TBL_MAX_FULL_NAME_LEN (((CFE_TBL_MAX_FULL_NAME_LEN_COMP + 3)/4)*4)
/*
* 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)

#define CFE_TBL_BAD_TABLE_HANDLE (CFE_TBL_Handle_t) 0xFFFF

Expand Down
18 changes: 18 additions & 0 deletions fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
/* Use the local definitions of these types */

#include "common_types.h"
#include <cfe_mission_cfg.h> /* for CFE_MISSION_TBL_MAX_FULL_NAME_LEN */

/**
* @brief Label definitions associated with CFE_TBL_BufferSelect_Enum_t
Expand Down Expand Up @@ -59,6 +60,23 @@ enum CFE_TBL_BufferSelect
typedef uint16 CFE_TBL_BufferSelect_Enum_t;



/**
* @brief The definition of the header fields that are included in CFE Table Data files.
*
* This header follows the CFE_FS header and precedes the the actual table data.
*/
typedef struct
{
uint32 Reserved; /**< Future Use: NumTblSegments in File? */
uint32 Offset; /**< Byte Offset at which load should commence */
uint32 NumBytes; /**< Number of bytes to load into table */
char TableName[CFE_MISSION_TBL_MAX_FULL_NAME_LEN]; /**< Fully qualified name of table to load */
} CFE_TBL_File_Hdr_t;




#endif /* CFE_EDS_ENABLED_BUILD */

#endif /* _CFE_TBL_EXTERN_TYPEDEFS_H_ */
Expand Down
Loading