Skip to content

Commit

Permalink
Fix #6, remove padding in table definitions
Browse files Browse the repository at this point in the history
Correct structure definitions to minimize implicit padding added when
running on 64-bit systems.

Update default tables provided to remove positional dependency on table elements.
  • Loading branch information
dmknutsen authored and astrogeco committed May 3, 2022
1 parent 050a7ee commit b32cb44
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 88 deletions.
10 changes: 6 additions & 4 deletions fsw/src/cs_tbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
*/
typedef struct
{
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint16 State; /**< \brief Uses the CS_STATE_... defines from above */
uint16 Filler16; /** <\brief Padding */
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint32 NumBytesToChecksum; /**< \brief The number of Bytes to Checksum */
} CS_Def_EepromMemory_Table_Entry_t;

Expand All @@ -79,13 +79,14 @@ typedef struct
*/
typedef struct
{
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint16 State; /**< \brief Uses the CS_STATE_... defines from above */
uint16 ComputedYet; /**< \brief Have we computed an Integrity value yet */
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint32 NumBytesToChecksum; /**< \brief The number of Bytes to Checksum */
uint32 ComparisonValue; /**< \brief The Memory Integrity Value */
uint32 ByteOffset; /**< \brief Where a previous unfinished calculation left off */
uint32 TempChecksumValue; /**< \brief The unfinished caluculation */
uint32 Filler32; /**< \brief Padding */
} CS_Res_EepromMemory_Table_Entry_t;

/**
Expand All @@ -111,15 +112,16 @@ typedef struct
*/
typedef struct
{
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint16 State; /**< \brief Uses the CS_STATE_... defines from above */
uint16 ComputedYet; /**< \brief Have we computed an Integrity value yet */
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint32 NumBytesToChecksum; /**< \brief The number of Bytes to Checksum */
uint32 ComparisonValue; /**< \brief The Memory Integrity Value */
uint32 ByteOffset; /**< \brief Where a previous unfinished calculation left off */
uint32 TempChecksumValue; /**< \brief The unfinished caluculation */
CFE_TBL_Handle_t TblHandle; /**< \brief handle recieved from table services */
bool IsCSOwner; /**< \brief Is CS the original owner of this table */
bool Filler8; /**< \brief Padding */
char Name[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief name of the table */
} CS_Res_Tables_Table_Entry_t;

Expand All @@ -128,9 +130,9 @@ typedef struct
*/
typedef struct
{
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint16 State; /**< \brief Uses the CS_STATE_... defines from above */
uint16 ComputedYet; /**< \brief Have we computed an Integrity value yet */
cpuaddr StartAddress; /**< \brief The Start address to Checksum */
uint32 NumBytesToChecksum; /**< \brief The number of Bytes to Checksum */
uint32 ComparisonValue; /**< \brief The Memory Integrity Value */
uint32 ByteOffset; /**< \brief Where a previous unfinished calculation left off */
Expand Down
49 changes: 24 additions & 25 deletions fsw/tables/cs_apptbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,30 @@

CS_Def_App_Table_Entry_t CS_AppTable[CS_MAX_NUM_APP_TABLE_ENTRIES] = {
/* State Name */
/* 0 */ {CS_STATE_EMPTY, ""},
/* 1 */ {CS_STATE_EMPTY, ""},
/* 2 */ {CS_STATE_EMPTY, ""},
/* 3 */ {CS_STATE_EMPTY, ""},
/* 4 */ {CS_STATE_EMPTY, ""},
/* 5 */ {CS_STATE_EMPTY, ""},
/* 6 */ {CS_STATE_EMPTY, ""},
/* 7 */ {CS_STATE_EMPTY, ""},
/* 8 */ {CS_STATE_EMPTY, ""},
/* 9 */ {CS_STATE_EMPTY, ""},
/* 10 */ {CS_STATE_EMPTY, ""},
/* 11 */ {CS_STATE_EMPTY, ""},
/* 12 */ {CS_STATE_EMPTY, ""},
/* 13 */ {CS_STATE_EMPTY, ""},
/* 14 */ {CS_STATE_EMPTY, ""},
/* 15 */ {CS_STATE_EMPTY, ""},
/* 16 */ {CS_STATE_EMPTY, ""},
/* 17 */ {CS_STATE_EMPTY, ""},
/* 18 */ {CS_STATE_EMPTY, ""},
/* 19 */ {CS_STATE_EMPTY, ""},
/* 20 */ {CS_STATE_EMPTY, ""},
/* 21 */ {CS_STATE_EMPTY, ""},
/* 22 */ {CS_STATE_EMPTY, ""},
/* 23 */ {CS_STATE_EMPTY, ""}

/* 0 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 1 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 2 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 3 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 4 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 5 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 6 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 7 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 8 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 9 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 10 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 11 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 12 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 13 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 14 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 15 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 16 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 17 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 18 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 19 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 20 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 21 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 22 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 23 */ {.State = CS_STATE_EMPTY, .Name = ""}
};

/*
Expand Down
33 changes: 16 additions & 17 deletions fsw/tables/cs_eepromtbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@

CS_Def_EepromMemory_Table_Entry_t CS_EepromTable[CS_MAX_NUM_EEPROM_TABLE_ENTRIES] = {
/* State Filler StartAddress NumBytes */
/* 0 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 1 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 2 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 3 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 4 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 5 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 6 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 7 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 8 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 9 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 10 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 11 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 12 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 13 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 14 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 15 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000}

/* 0 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 1 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 2 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 3 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 4 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 5 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 6 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 7 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 8 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 9 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 10 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 11 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 12 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 13 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 14 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 15 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000}
};

/*
Expand Down
33 changes: 16 additions & 17 deletions fsw/tables/cs_memorytbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@

CS_Def_EepromMemory_Table_Entry_t CS_MemoryTable[CS_MAX_NUM_MEMORY_TABLE_ENTRIES] = {
/* State Filler StartAddress NumBytes */
/* 0 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 1 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 2 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 3 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 4 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 5 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 6 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 7 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 8 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 9 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 10 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 11 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 12 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 13 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 14 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000},
/* 15 */ {CS_STATE_EMPTY, 0x1234, 0x00000000, 0x00000000}

/* 0 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 1 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 2 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 3 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 4 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 5 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 6 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 7 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 8 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 9 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 10 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 11 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 12 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 13 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 14 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000},
/* 15 */ {.State = CS_STATE_EMPTY, .Filler16 = 0x1234, .StartAddress = 0x00000000, .NumBytesToChecksum = 0x00000000}
};

/*
Expand Down
49 changes: 24 additions & 25 deletions fsw/tables/cs_tablestbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,30 @@
CS_Def_Tables_Table_Entry_t CS_TablesTable[CS_MAX_NUM_TABLES_TABLE_ENTRIES] = {
/* State Name */

/* 0 */ {CS_STATE_EMPTY, ""},
/* 1 */ {CS_STATE_EMPTY, ""},
/* 2 */ {CS_STATE_EMPTY, ""},
/* 3 */ {CS_STATE_EMPTY, ""},
/* 4 */ {CS_STATE_EMPTY, ""},
/* 5 */ {CS_STATE_EMPTY, ""},
/* 6 */ {CS_STATE_EMPTY, ""},
/* 7 */ {CS_STATE_EMPTY, ""},
/* 8 */ {CS_STATE_EMPTY, ""},
/* 9 */ {CS_STATE_EMPTY, ""},
/* 10 */ {CS_STATE_EMPTY, ""},
/* 11 */ {CS_STATE_EMPTY, ""},
/* 12 */ {CS_STATE_EMPTY, ""},
/* 13 */ {CS_STATE_EMPTY, ""},
/* 14 */ {CS_STATE_EMPTY, ""},
/* 15 */ {CS_STATE_EMPTY, ""},
/* 16 */ {CS_STATE_EMPTY, ""},
/* 17 */ {CS_STATE_EMPTY, ""},
/* 18 */ {CS_STATE_EMPTY, ""},
/* 19 */ {CS_STATE_EMPTY, ""},
/* 20 */ {CS_STATE_EMPTY, ""},
/* 21 */ {CS_STATE_EMPTY, ""},
/* 22 */ {CS_STATE_EMPTY, ""},
/* 23 */ {CS_STATE_EMPTY, ""}

/* 0 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 1 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 2 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 3 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 4 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 5 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 6 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 7 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 8 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 9 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 10 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 11 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 12 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 13 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 14 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 15 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 16 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 17 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 18 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 19 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 20 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 21 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 22 */ {.State = CS_STATE_EMPTY, .Name = ""},
/* 23 */ {.State = CS_STATE_EMPTY, .Name = ""}
};

/*
Expand Down

0 comments on commit b32cb44

Please sign in to comment.