Skip to content

Commit

Permalink
Fix nasa#61, remove dependence on ENDIAN macro for checksum
Browse files Browse the repository at this point in the history
Removes the "optimization" for big endian, unlikely to be useful.
  • Loading branch information
jphickey committed Jan 11, 2022
1 parent b6de205 commit 9b838e8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 65 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ add_cfe_app(cf ${APP_SRC_FILES})
# configuration table
add_cfe_tables(cf fsw/tables/cf_def_config.c)

add_definitions("-D_DEFAULT_SOURCE")

add_definitions(-D_DEFAULT_SOURCE=1)
add_definitions(-D_EL -DENDIAN=_EL -DSOFTWARE_BIG_BIT_ORDER)
if (ENABLE_UNIT_TESTS)
add_subdirectory(unit-test)
endif (ENABLE_UNIT_TESTS)
12 changes: 0 additions & 12 deletions fsw/platform_inc/cf_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,6 @@ typedef uint8 CF_EntityId_t;
*/
typedef uint32 CF_TransactionSeq_t;

/**
** \cfcfg CF_HW_ALIGNMENT and CF_SW_ALIGNMENT
**
** \par Description:
** ONE AND ONLY ONE must be #define.
**
** CF_HW_ALIGNMENT is set for platforms that can handle alignment in hardware (load/store used)
** CF_SW_ALIGNMENT is for platforms that can't handle alignment natively (memcpy used)
*/
#define CF_HW_ALIGNMENT
#undef CF_SW_ALIGNMENT

/**
** \cfcfg Application Pipe Depth
**
Expand Down
33 changes: 0 additions & 33 deletions fsw/src/cf_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, int len)
{
int i = 0;

/* can't use big-endian optimization with CF_SW_ALIGNMENT */
#if (ENDIAN == _EL) || defined(CF_SW_ALIGNMENT)
for (; i < len; ++i)
{
c->working <<= 8;
Expand All @@ -74,37 +72,6 @@ void CF_CRC_Digest(CF_Crc_t *c, const uint8 *data, int len)
c->index = 0;
}
}
#elif (ENDIAN == _EB) && defined(CF_HW_ALIGNMENT)
/* first get index to 0 byte-by-byte */
if (c->index)
{
for (; (c->index < 4) && (i < len); ++i, ++c->index)
{
c->working <<= 8;
c->working |= data[i];
}

c->result += c->working;
c->index = 0;
}

/* next, process data 4 bytes at a time like a boss */
for (/* keep previous i value */; (i + 4) <= len; i += 4)
{
c->result += (*(uint32 *)(void *)(data + i));
}

/* anything left over has to go back into the shift register */
for (/* keep previous i value */; i < len; ++i)
{
c->working <<= 8;
c->working |= data[i];

++c->index;
}
#else
#error well this is odd
#endif
}

/************************************************************************/
Expand Down
16 changes: 0 additions & 16 deletions fsw/src/cf_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@
#error refactor code for 32 bit CF_NUM_HISTORIES
#endif

#if !defined(CF_HW_ALIGNMENT) && !defined(CF_SW_ALIGNMENT)
#error Must define one of CF_HW_ALIGNMENT or CF_SW_ALIGNMENT
#endif

#if defined(CF_HW_ALIGNMENT) && defined(CF_SW_ALIGNMENT)
#error Must define ONLY ONE of CF_HW_ALIGNMENT or CF_SW_ALIGNMENT
#endif

#if !defined(ENDIAN)
#error Must define ENDIAN as _EL or _EB for little or big endian
#endif

#if (ENDIAN != _EL) && (ENDIAN != _EB)
#error Must define ENDIAN as either _EL or _EB for little or big endian
#endif

#if (CF_PERF_ID_PDURCVD(CF_NUM_CHANNELS - 1) >= CF_PERF_ID_PDUSENT(0))
#error Collision between CF_PERF_ID_PDURCVD and CF_PERF_ID_PDUSENT given number of channels
#endif
Expand Down

0 comments on commit 9b838e8

Please sign in to comment.