diff --git a/fsw/cfe-core/src/inc/cfe_tbl.h b/fsw/cfe-core/src/inc/cfe_tbl.h index 4e29481d2..0229ba4ab 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl.h +++ b/fsw/cfe-core/src/inc/cfe_tbl.h @@ -116,7 +116,7 @@ typedef enum CFE_TBL_SrcEnum /** \brief Table Info */ typedef struct CFE_TBL_Info { - uint32 Size; /**< \brief Size, in bytes, of Table */ + 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 */ @@ -265,7 +265,7 @@ typedef struct CFE_TBL_Info **/ CFE_Status_t CFE_TBL_Register(CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ const char *Name, /* Application specific name */ - uint32 Size, /* Size, in bytes, of table */ + size_t Size, /* Size, in bytes, of table */ uint16 TblOptionFlags, /* Tbl Options Settings */ CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr); /* Ptr to func that validates tbl */ diff --git a/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h b/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h index 64c80b6de..10c05fa7b 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h +++ b/fsw/cfe-core/src/inc/cfe_tbl_extern_typedefs.h @@ -32,6 +32,7 @@ /* 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 */ /** @@ -69,8 +70,8 @@ typedef uint16 CFE_TBL_BufferSelect_En typedef struct CFE_TBL_File_Hdr { 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 */ + CFE_ES_MemOffset_t Offset; /**< Byte Offset at which load should commence */ + CFE_ES_MemOffset_t 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; diff --git a/fsw/cfe-core/src/inc/cfe_tbl_msg.h b/fsw/cfe-core/src/inc/cfe_tbl_msg.h index b93445fea..13788037d 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl_msg.h +++ b/fsw/cfe-core/src/inc/cfe_tbl_msg.h @@ -772,15 +772,15 @@ typedef struct CFE_TBL_HousekeepingTlm **/ typedef struct CFE_TBL_TblRegPacket_Payload { - uint32 Size; /**< \cfetlmmnemonic \TBL_SIZE + CFE_ES_MemOffset_t Size; /**< \cfetlmmnemonic \TBL_SIZE \brief Size, in bytes, of Table */ uint32 Crc; /**< \cfetlmmnemonic \TBL_CRC \brief Most recently calculated CRC of Table */ - cpuaddr ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD + CFE_ES_MemAddress_t ActiveBufferAddr; /**< \cfetlmmnemonic \TBL_ACTBUFADD \brief Address of Active Buffer */ - cpuaddr InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD + CFE_ES_MemAddress_t InactiveBufferAddr; /**< \cfetlmmnemonic \TBL_IACTBUFADD \brief Address of Inactive Buffer */ - cpuaddr ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR + CFE_ES_MemAddress_t ValidationFuncPtr; /**< \cfetlmmnemonic \TBL_VALFUNCPTR \brief Ptr to Owner App's function that validates tbl contents */ CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \cfetlmmnemonic \TBL_TIMELASTUPD \brief Time when Table was last updated */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index 22765e8d5..c032c938b 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_api.c @@ -50,7 +50,7 @@ */ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, const char *Name, - uint32 Size, + size_t Size, uint16 TblOptionFlags, CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ) { diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.c b/fsw/cfe-core/src/tbl/cfe_tbl_task.c index d1b4ffa59..8e44405a3 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.c @@ -265,7 +265,7 @@ void CFE_TBL_TaskPipe(CFE_SB_Msg_t *MessagePtr) CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(MessagePtr); uint16 CommandCode = CFE_SB_GetCmdCode(MessagePtr); int16 CmdIndx; - uint32 ActualLength; + size_t ActualLength; CFE_TBL_CmdProcRet_t CmdStatus = CFE_TBL_INC_ERR_CTR; /* Assume a failed command */ /* Search the Command Handler Table for a matching message */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task.h b/fsw/cfe-core/src/tbl/cfe_tbl_task.h index 96af49979..ae1c794c2 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task.h @@ -185,7 +185,7 @@ typedef struct typedef struct { CFE_ES_ResourceID_t OwnerAppId; /**< \brief Application ID of App that Registered Table */ - uint32 Size; /**< \brief Size, in bytes, of Table */ + size_t Size; /**< \brief Size, in bytes, of Table */ CFE_SB_MsgId_t NotificationMsgId; /**< \brief Message ID of an associated management notification message */ uint32 NotificationParam; /**< \brief Parameter of an associated management notification message */ CFE_TBL_LoadBuff_t Buffers[2]; /**< \brief Active and Inactive Buffer Pointers */ @@ -238,7 +238,7 @@ typedef struct typedef struct { CFE_TBL_DumpState_t State; /**< \brief Current state of this block of data */ - uint32 Size; /**< \brief Number of bytes to be dumped */ + size_t Size; /**< \brief Number of bytes to be dumped */ CFE_TBL_LoadBuff_t *DumpBufferPtr; /**< \brief Address where dumped data is to be stored temporarily */ CFE_TBL_RegistryRec_t *RegRecPtr; /**< \brief Ptr to dumped table's registry record */ char TableName[CFE_TBL_MAX_FULL_NAME_LEN]; /**< \brief Name of Table being Dumped */ @@ -253,7 +253,7 @@ typedef struct */ typedef struct { - uint32 Size; /**< \brief Size, in bytes, of Table */ + CFE_ES_MemOffset_t Size; /**< \brief Size, in bytes, of Table */ CFE_TIME_SysTime_t TimeOfLastUpdate; /**< \brief Time when Table was last updated */ uint32 NumUsers; /**< \brief Number of applications that are sharing the table */ int32 LoadInProgress; /**< \brief Flag identifies inactive buffer and whether load in progress */ diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c index b9a0b5104..2dd688b47 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.c @@ -274,31 +274,31 @@ void CFE_TBL_GetTblRegData(void) RegRecPtr = &CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex]; - CFE_TBL_TaskData.TblRegPacket.Payload.Size = RegRecPtr->Size; - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.ActiveBufferAddr, - RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size); + CFE_TBL_TaskData.TblRegPacket.Payload.ActiveBufferAddr = + CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[RegRecPtr->ActiveBufferIndex].BufferPtr); if (RegRecPtr->DoubleBuffered) { /* For a double buffered table, the inactive is the other allocated buffer */ - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr, - RegRecPtr->Buffers[(1U-RegRecPtr->ActiveBufferIndex)].BufferPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = + CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[(1U-RegRecPtr->ActiveBufferIndex)].BufferPtr); } else { /* Check to see if an inactive buffer has currently been allocated to the single buffered table */ if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) { - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr, - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = + CFE_ES_MEMADDRESS_C(CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].BufferPtr); } else { - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = 0; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); } } - CFE_SB_SET_MEMADDR(CFE_TBL_TaskData.TblRegPacket.Payload.ValidationFuncPtr, RegRecPtr->ValidationFuncPtr); + CFE_TBL_TaskData.TblRegPacket.Payload.ValidationFuncPtr = CFE_ES_MEMADDRESS_C(RegRecPtr->ValidationFuncPtr); CFE_TBL_TaskData.TblRegPacket.Payload.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate; CFE_TBL_TaskData.TblRegPacket.Payload.TableLoadedOnce = RegRecPtr->TableLoadedOnce; CFE_TBL_TaskData.TblRegPacket.Payload.LoadPending = RegRecPtr->LoadPending; @@ -730,7 +730,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_Dump_t *data) ** NOTE: For complete prolog information, see prototype above ********************************************************************/ -CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, const void *DumpDataAddr, uint32 TblSizeInBytes) +CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, const void *DumpDataAddr, size_t TblSizeInBytes) { CFE_TBL_CmdProcRet_t ReturnCode = CFE_TBL_INC_ERR_CTR; /* Assume failure */ bool FileExistedPrev = false; @@ -769,8 +769,8 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T /* Initialize the Table Image Header for the Dump File */ strncpy(TblFileHeader.TableName, TableName, sizeof(TblFileHeader.TableName)-1); TblFileHeader.TableName[sizeof(TblFileHeader.TableName)-1] = 0; - TblFileHeader.Offset = 0; - TblFileHeader.NumBytes = TblSizeInBytes; + TblFileHeader.Offset = CFE_ES_MEMOFFSET_C(0); + TblFileHeader.NumBytes = CFE_ES_MEMOFFSET_C(TblSizeInBytes); TblFileHeader.Reserved = 0; /* Determine if this is a little endian processor */ @@ -795,7 +795,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T DumpDataAddr, TblSizeInBytes); - if (Status == (int32)TblSizeInBytes) + if (Status == TblSizeInBytes) { if (FileExistedPrev) { @@ -1172,7 +1172,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) (RegRecPtr->HeadOfAccessList != CFE_TBL_END_OF_LIST)) { /* Fill Registry Dump Record with relevant information */ - DumpRecord.Size = RegRecPtr->Size; + DumpRecord.Size = CFE_ES_MEMOFFSET_C(RegRecPtr->Size); DumpRecord.TimeOfLastUpdate = RegRecPtr->TimeOfLastUpdate; DumpRecord.LoadInProgress = RegRecPtr->LoadInProgress; DumpRecord.ValidationFunc = (RegRecPtr->ValidationFuncPtr != NULL); diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h index c2f4f1aeb..f95fa43c5 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h +++ b/fsw/cfe-core/src/tbl/cfe_tbl_task_cmds.h @@ -73,7 +73,7 @@ typedef enum typedef struct { CFE_SB_MsgId_t MsgId; /**< \brief Acceptable Message ID */ uint32 CmdCode; /**< \brief Acceptable Command Code (if necessary) */ - uint32 ExpectedLength; /**< \brief Expected Message Length (in bytes) including message header */ + size_t ExpectedLength; /**< \brief Expected Message Length (in bytes) including message header */ CFE_TBL_MsgProcFuncPtr_t MsgProcFuncPtr; /**< \brief Pointer to function to handle message */ CFE_TBL_MsgType_t MsgTypes; /**< \brief Message Type (i.e. - with/without Cmd Code) */ } CFE_TBL_CmdHandlerTblRec_t; @@ -329,7 +329,7 @@ int32 CFE_TBL_AbortLoadCmd(const CFE_TBL_AbortLoad_t *data); ** \retval #CFE_TBL_INC_CMD_CTR \copydoc CFE_TBL_INC_CMD_CTR ******************************************************************************/ extern CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *TableName, - const void *DumpDataAddr, uint32 TblSizeInBytes); + const void *DumpDataAddr, size_t TblSizeInBytes); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/fsw/cfe-core/unit-test/tbl_UT.c index e395262f4..8c332b694 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/fsw/cfe-core/unit-test/tbl_UT.c @@ -89,6 +89,21 @@ static const UT_TaskPipeDispatchId_t UT_TPID_CFE_TBL_CMD_INVALID_CC = CFE_TBL_RegistryRec_t Original[CFE_PLATFORM_TBL_MAX_NUM_TABLES]; +/* + * UT helper routines + */ +void UT_TBL_SetupHeader(CFE_TBL_File_Hdr_t *TblFileHeader, size_t Offset, size_t NumBytes) +{ + TblFileHeader->Offset = CFE_ES_MEMOFFSET_C(Offset); + TblFileHeader->NumBytes = CFE_ES_MEMOFFSET_C(NumBytes); + + if (UT_Endianess == UT_LITTLE_ENDIAN) + { + CFE_TBL_ByteSwapUint32(&TblFileHeader->Offset); + CFE_TBL_ByteSwapUint32(&TblFileHeader->NumBytes); + } +} + /* ** Functions */ @@ -984,36 +999,36 @@ void Test_CFE_TBL_GetTblRegData(void) /* Test using a double buffered table */ UT_InitData(); - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = '\0'; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].DoubleBuffered = true; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != '\0', + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != 0, "CFE_TBL_GetTblRegData", "Double buffered table"); /* Test using a single buffered table and the buffer is inactive */ UT_InitData(); - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = '\0'; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); CFE_TBL_TaskData.Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].DoubleBuffered = false; CFE_TBL_TaskData. Registry[CFE_TBL_TaskData.HkTlmTblRegIndex]. LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS + 1; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != '\0', + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr != 0, "CFE_TBL_GetTblRegData", "Single buffered table - inactive buffer"); /* Test with no inactive buffer */ UT_InitData(); - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = '\0'; + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr = CFE_ES_MEMADDRESS_C(0); CFE_TBL_TaskData. Registry[CFE_TBL_TaskData.HkTlmTblRegIndex].LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; CFE_TBL_GetTblRegData(); UT_Report(__FILE__, __LINE__, - CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr == '\0', + CFE_TBL_TaskData.TblRegPacket.Payload.InactiveBufferAddr == 0, "CFE_TBL_GetTblRegData", "No inactive buffer"); } @@ -1474,14 +1489,8 @@ void Test_CFE_TBL_LoadCmd(void) * indicates) */ UT_InitData(); - TblFileHeader.Offset = 0; + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); CFE_TBL_TaskData.Registry[0].TableLoadedOnce = true; - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t); CFE_TBL_TaskData.Registry[0].LoadInProgress = @@ -1499,12 +1508,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with no extra byte => successful load */ UT_InitData(); - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); strncpy((char *)TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, @@ -1519,7 +1523,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with differing amount of data from header's claim */ UT_InitData(); - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); + TblFileHeader.NumBytes = CFE_ES_MEMOFFSET_C(sizeof(CFE_TBL_File_Hdr_t)); if (UT_Endianess == UT_LITTLE_ENDIAN) { @@ -1561,12 +1565,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with table header indicating data beyond size of the table */ UT_InitData(); - TblFileHeader.NumBytes = sizeof(CFE_TBL_File_Hdr_t); - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); CFE_TBL_TaskData.Registry[0].Size = sizeof(CFE_TBL_File_Hdr_t) - 1; strncpy((char *)TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, @@ -1581,12 +1580,7 @@ void Test_CFE_TBL_LoadCmd(void) /* Test with table header indicating no data in the file */ UT_InitData(); - TblFileHeader.NumBytes = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, 0); strncpy((char *)TblFileHeader.TableName, CFE_TBL_TaskData.Registry[0].Name, sizeof(TblFileHeader.TableName)); @@ -1602,14 +1596,7 @@ void Test_CFE_TBL_LoadCmd(void) * is non-zero */ UT_InitData(); - TblFileHeader.NumBytes = 1; - TblFileHeader.Offset = 1; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 1, 1); CFE_TBL_TaskData.Registry[0].TableLoadedOnce = false; @@ -1629,14 +1616,7 @@ void Test_CFE_TBL_LoadCmd(void) * is zero */ UT_InitData(); - TblFileHeader.NumBytes = 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, 1); CFE_TBL_TaskData.Registry[0].TableLoadedOnce = false; @@ -2547,14 +2527,8 @@ void Test_CFE_TBL_Share(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table4", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -2735,14 +2709,7 @@ void Test_CFE_TBL_Load(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 1; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 1, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -2788,14 +2755,7 @@ void Test_CFE_TBL_Load(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.NotUT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -2836,14 +2796,7 @@ void Test_CFE_TBL_Load(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy(TblFileHeader.TableName, "ut_cfe_tbl.NotUT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -3849,13 +3802,10 @@ void Test_CFE_TBL_TblMod(void) FileHeader.TimeSubSeconds = 104; strncpy((char *)File.TblHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(File.TblHeader.TableName)); - File.TblHeader.NumBytes = sizeof(UT_Table1_t); - File.TblHeader.Offset = 0; + UT_TBL_SetupHeader(&File.TblHeader, 0, sizeof(UT_Table1_t)); if (UT_Endianess == UT_LITTLE_ENDIAN) { - CFE_TBL_ByteSwapUint32(&File.TblHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&File.TblHeader.Offset); File.TblData.TblElement1 = 0x04030201; File.TblData.TblElement2 = 0x08070605; } @@ -3936,14 +3886,7 @@ void Test_CFE_TBL_TblMod(void) FileHeader.TimeSubSeconds = 104; strncpy((char *)File.TblHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(File.TblHeader.TableName)); - File.TblHeader.NumBytes = sizeof(UT_Table1_t); - File.TblHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&File.TblHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&File.TblHeader.Offset); - } + UT_TBL_SetupHeader(&File.TblHeader, 0, sizeof(UT_Table1_t)); File.TblData.TblElement1 = 0x04030201; File.TblData.TblElement2 = 0x08070605; @@ -4087,14 +4030,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 1; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 1, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4115,14 +4051,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4144,15 +4073,8 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } - + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); +// UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 2, sizeof(UT_Table1_t) - 1); @@ -4174,14 +4096,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.NotUT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4201,14 +4116,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4228,14 +4136,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4256,14 +4157,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4316,14 +4210,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG - 1; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4346,14 +4233,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t) - 1; - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)-1); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4493,14 +4373,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4521,14 +4394,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table1", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4549,14 +4415,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4577,14 +4436,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4608,14 +4460,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4655,14 +4500,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4703,14 +4541,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4753,14 +4584,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); @@ -4834,14 +4658,7 @@ void Test_CFE_TBL_Internal(void) StdFileHeader.SubType = CFE_FS_SubType_TBL_IMG; strncpy((char *)TblFileHeader.TableName, "ut_cfe_tbl.UT_Table2", sizeof(TblFileHeader.TableName)); - TblFileHeader.NumBytes = sizeof(UT_Table1_t); - TblFileHeader.Offset = 0; - - if (UT_Endianess == UT_LITTLE_ENDIAN) - { - CFE_TBL_ByteSwapUint32(&TblFileHeader.NumBytes); - CFE_TBL_ByteSwapUint32(&TblFileHeader.Offset); - } + UT_TBL_SetupHeader(&TblFileHeader, 0, sizeof(UT_Table1_t)); UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); diff --git a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c index b0befc23c..582f29e01 100644 --- a/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_tbl_stubs.c @@ -102,7 +102,7 @@ int32 CFE_TBL_CleanUpApp(uint32 AppId) int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr, /* Returned Handle */ const char *Name, /* Application specific name */ - uint32 Size, /* Size, in bytes, of table */ + size_t Size, /* Size, in bytes, of table */ uint16 TblOptionFlags, /* Tbl Options Settings */ CFE_TBL_CallbackFuncPtr_t TblValidationFuncPtr ) /* Ptr to func that validates tbl */ {