Skip to content

Commit

Permalink
check static buffer size and fix caching defines
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Feb 1, 2024
1 parent 05af791 commit 2c4cb01
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions source/portable/NetworkInterface/STM32/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@
/*===========================================================================*/
/*---------------------------------------------------------------------------*/

#define niEMAC_MPU ( defined( __MPU_PRESENT ) && ( __MPU_PRESENT == 1U ) )
#if ( niEMAC_MPU != 0 )
#if ( defined( __MPU_PRESENT ) && ( __MPU_PRESENT == 1U ) )
#define niEMAC_MPU
#define niEMAC_MPU_ENABLED ( _FLD2VAL( MPU_CTRL_ENABLE, MPU->CTRL ) != 0 )
#endif

#define niEMAC_CACHEABLE ( defined( __DCACHE_PRESENT ) && ( __DCACHE_PRESENT == 1U ) )
#if ( niEMAC_CACHEABLE != 0 )
#if ( defined( __DCACHE_PRESENT ) && ( __DCACHE_PRESENT == 1U ) )
#define niEMAC_CACHEABLE
#define niEMAC_CACHE_ENABLED ( _FLD2VAL( SCB_CCR_DC, SCB->CCR ) != 0 )
#define niEMAC_CACHE_MAINTENANCE ( ipconfigIS_DISABLED( niEMAC_USE_MPU ) && niEMAC_CACHE_ENABLED )
#ifdef __SCB_DCACHE_LINE_SIZE
Expand All @@ -194,7 +194,7 @@
#define niEMAC_DATA_ALIGNMENT 32U
#endif
#else
#define niEMAC_DATA_ALIGNMENT 4U
#define niEMAC_DATA_ALIGNMENT portBYTE_ALIGNMENT
#endif

#define niEMAC_DATA_ALIGNMENT_MASK ( niEMAC_DATA_ALIGNMENT - 1U )
Expand Down Expand Up @@ -698,7 +698,7 @@ static BaseType_t prvNetworkInterfaceOutput( NetworkInterface_t * pxInterface, N
break;
}

#if ( niEMAC_CACHEABLE != 0 )
#ifdef niEMAC_CACHEABLE
if( niEMAC_CACHE_MAINTENANCE != 0 )
{
const uintptr_t uxDataStart = ( uintptr_t ) xTxBuffer.buffer;
Expand Down Expand Up @@ -1060,11 +1060,11 @@ static BaseType_t prvEthConfigInit( ETH_HandleTypeDef * pxEthHandle, NetworkInte

if( xResult == pdTRUE )
{
#if defined( __DCACHE_PRESENT ) && ( __DCACHE_PRESENT == 1U )
#ifdef niEMAC_CACHEABLE
if( niEMAC_CACHE_ENABLED )
{
#if defined( __MPU_PRESENT ) && ( __MPU_PRESENT == 1U )
configASSERT( _FLD2VAL( MPU_CTRL_ENABLE, MPU->CTRL ) != 0 );
#ifdef niEMAC_MPU
configASSERT( niEMAC_MPU_ENABLED != 0 );
#else
configASSERT( pdFALSE );
#endif
Expand Down Expand Up @@ -1877,7 +1877,7 @@ void HAL_ETH_RxAllocateCallback( uint8_t ** ppucBuff )
const NetworkBufferDescriptor_t * pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( niEMAC_DATA_BUFFER_SIZE, pdMS_TO_TICKS( niEMAC_DESCRIPTOR_WAIT_TIME_MS ) );
if( pxBufferDescriptor != NULL )
{
#if ( niEMAC_CACHEABLE != 0 )
#ifdef niEMAC_CACHEABLE
if( niEMAC_CACHE_MAINTENANCE != 0 )
{
SCB_InvalidateDCache_by_Addr( ( uint32_t * ) pxBufferDescriptor->pucEthernetBuffer, pxBufferDescriptor->xDataLength );
Expand Down Expand Up @@ -1917,7 +1917,7 @@ void HAL_ETH_RxLinkCallback( void ** ppvStart, void ** ppvEnd, uint8_t * pucBuff
*ppxEndDescriptor = pxCurDescriptor;
/* Only single buffer packets are supported */
configASSERT( *ppxStartDescriptor == *ppxEndDescriptor );
#if ( niEMAC_CACHEABLE != 0 )
#ifdef niEMAC_CACHEABLE
if( niEMAC_CACHE_MAINTENANCE != 0 )
{
SCB_InvalidateDCache_by_Addr( ( uint32_t * ) pucBuff, usLength );
Expand Down Expand Up @@ -1950,6 +1950,7 @@ void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkB
{
static uint8_t ucNetworkPackets[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ][ niEMAC_TOTAL_BUFFER_SIZE ] __ALIGNED( niEMAC_BUF_ALIGNMENT ) __attribute__( ( section( niEMAC_BUFFERS_SECTION ) ) );

configASSERT( niEMAC_TOTAL_BUFFER_SIZE >= ipconfigETHERNET_MINIMUM_PACKET_BYTES );
configASSERT( xBufferAllocFixedSize == pdTRUE );

size_t uxIndex;
Expand Down

0 comments on commit 2c4cb01

Please sign in to comment.