From b32cb443e99655da529910bf2e6453e7c304de27 Mon Sep 17 00:00:00 2001 From: "daniel.m.knutsen" Date: Tue, 26 Apr 2022 10:27:19 -0400 Subject: [PATCH] Fix #6, remove padding in table definitions 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. --- fsw/src/cs_tbldefs.h | 10 ++++---- fsw/tables/cs_apptbl.c | 49 +++++++++++++++++++-------------------- fsw/tables/cs_eepromtbl.c | 33 +++++++++++++------------- fsw/tables/cs_memorytbl.c | 33 +++++++++++++------------- fsw/tables/cs_tablestbl.c | 49 +++++++++++++++++++-------------------- 5 files changed, 86 insertions(+), 88 deletions(-) diff --git a/fsw/src/cs_tbldefs.h b/fsw/src/cs_tbldefs.h index 4733736..7660bb0 100644 --- a/fsw/src/cs_tbldefs.h +++ b/fsw/src/cs_tbldefs.h @@ -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; @@ -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; /** @@ -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; @@ -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 */ diff --git a/fsw/tables/cs_apptbl.c b/fsw/tables/cs_apptbl.c index 3bb78d0..51c719d 100644 --- a/fsw/tables/cs_apptbl.c +++ b/fsw/tables/cs_apptbl.c @@ -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 = ""} }; /* diff --git a/fsw/tables/cs_eepromtbl.c b/fsw/tables/cs_eepromtbl.c index 2380b1d..ba0bcfb 100644 --- a/fsw/tables/cs_eepromtbl.c +++ b/fsw/tables/cs_eepromtbl.c @@ -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} }; /* diff --git a/fsw/tables/cs_memorytbl.c b/fsw/tables/cs_memorytbl.c index 8b023d8..0569287 100644 --- a/fsw/tables/cs_memorytbl.c +++ b/fsw/tables/cs_memorytbl.c @@ -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} }; /* diff --git a/fsw/tables/cs_tablestbl.c b/fsw/tables/cs_tablestbl.c index 358a0c2..0bee2c9 100644 --- a/fsw/tables/cs_tablestbl.c +++ b/fsw/tables/cs_tablestbl.c @@ -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 = ""} }; /*