From 6cfc7585ec51906391c3e6b98aa0ed336d5c2254 Mon Sep 17 00:00:00 2001 From: Christos Zosimidis Date: Thu, 24 Nov 2022 11:22:12 +0100 Subject: [PATCH 1/8] Eliminate compiler unused parameter warning --- source/FreeRTOS_ICMP.c | 3 +++ .../NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/source/FreeRTOS_ICMP.c b/source/FreeRTOS_ICMP.c index d507d629c5..660786dda7 100644 --- a/source/FreeRTOS_ICMP.c +++ b/source/FreeRTOS_ICMP.c @@ -177,6 +177,9 @@ } #else { + /* Just to prevent compiler warnings about unused parameters. */ + ( void ) pxNetworkBuffer; + /* Many EMAC peripherals will only calculate the ICMP checksum * correctly if the field is nulled beforehand. */ pxICMPHeader->usChecksum = 0U; diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c index 3b38fa90c5..cbcc2c3a9d 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c @@ -126,6 +126,9 @@ int is_tx_space_available( xemacpsif_s * xemacpsif ) { size_t uxCount; + /* Just to prevent compiler warnings about unused parameters. */ + ( void ) xemacpsif; + if( xTXDescriptorSemaphore != NULL ) { uxCount = ( ( UBaseType_t ) ipconfigNIC_N_TX_DESC ) - uxSemaphoreGetCount( xTXDescriptorSemaphore ); From 43ab28bc208d3c30e8371ab0f7c7826770c1098e Mon Sep 17 00:00:00 2001 From: Christos Zosimidis Date: Thu, 24 Nov 2022 12:22:00 +0100 Subject: [PATCH 2/8] Eliminate compiler unused variable warnings --- .../xilinx_ultrascale/x_emacpsif_physpeed.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index 658a46d86d..1da34d47e2 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -842,6 +842,9 @@ static void ar8035Tick( XEmacPs * xemacpsp, value = XEmacPs_PhyRead2( xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET ); /*Retrieve current link state */ linkState = ( value & IEEE_STAT_LINK_STATUS ) ? TRUE : FALSE; + + /* Just to prevent compiler warnings about unused variable. */ + ( void ) linkState; } #define AR803X_DEBUG_ADDR 0x1D @@ -970,6 +973,9 @@ static uint32_t ar8035CheckStatus( XEmacPs * xemacpsp, /* nicNotifyLinkChange(interface); */ } + /* Just to prevent compiler warnings about unused variable. */ + ( void ) linkState; + return linkSpeed; } From 5665b9d30a1ccd147147425ff363b01b02df7078 Mon Sep 17 00:00:00 2001 From: Christos Zosimidis Date: Thu, 24 Nov 2022 15:10:41 +0100 Subject: [PATCH 3/8] Eliminate compiler unused function warning The function pcGetPHIName(...) would be called only in the FreeRTOS_printf message, however FreeRTOS_printf maybe be defined to nothing e.g. release builds, which then the warning would come up --- .../xilinx_ultrascale/x_emacpsif_physpeed.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index 1da34d47e2..20e425a3ef 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -1021,7 +1021,11 @@ static uint32_t get_IEEE_phy_speed_US( XEmacPs * xemacpsp, XEmacPs_PhyRead( xemacpsp, phy_addr, PHY_IDENTIFIER_1_REG, &phy_identity ); - FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcGetPHIName( phy_identity ), phy_identity ) ); + const char * pcPHINAme = pcGetPHIName( phy_identity ); + FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcPHINAme, phy_identity ) ); + + /* Just to prevent compiler warnings about unused variablies. */ + ( void ) pcPHINAme; switch( phy_identity ) { From 9829705528a353d340b68fe901074105a3d3c257 Mon Sep 17 00:00:00 2001 From: Christos Zosimidis Date: Thu, 24 Nov 2022 14:50:40 +0100 Subject: [PATCH 4/8] Rework callback setups in the EMAC-driver of the Xilinx UltraScale port The calls to the function XEmacPs_SetHandler would trigger the pedantic warning: "ISO C forbids conversion of object pointer to function pointer type" The reason for this, is that the second parameter of the function XEmacPS_SetHandler is declared as pointer to a void type, but the function "expects" a function pointer, which in setup_isr rightly happens. However IMHO, this is just bad code from the side of Xilinx, as not on all architectures the size of a data pointer is identical to the size of a function pointer, which also is correctly recognised by the compiler. Instead of using the "bad" function XEmacPs_SetHandler, we can set the handlers manually to the EmacPS-instance. --- .../xilinx_ultrascale/x_emacpsif_hw.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c index 183f82810b..9662e37935 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c @@ -47,17 +47,16 @@ void setup_isr( xemacpsif_s * xemacpsif ) /* * Setup callbacks */ - XEmacPs_SetHandler( &xemacpsif->emacps, XEMACPS_HANDLER_DMASEND, - ( void * ) emacps_send_handler, - ( void * ) xemacpsif ); + XEmacPs *xInstancePtr = &xemacpsif->emacps; - XEmacPs_SetHandler( &xemacpsif->emacps, XEMACPS_HANDLER_DMARECV, - ( void * ) emacps_recv_handler, - ( void * ) xemacpsif ); + xInstancePtr->SendHandler = ( XEmacPs_Handler ) emacps_send_handler; + xInstancePtr->SendRef = ( void * ) xemacpsif; - XEmacPs_SetHandler( &xemacpsif->emacps, XEMACPS_HANDLER_ERROR, - ( void * ) emacps_error_handler, - ( void * ) xemacpsif ); + xInstancePtr->RecvHandler = ( XEmacPs_Handler ) emacps_recv_handler; + xInstancePtr->RecvRef = ( void * ) xemacpsif; + + xInstancePtr->ErrorHandler = ( XEmacPs_ErrHandler ) emacps_error_handler; + xInstancePtr->ErrorRef = ( void * ) xemacpsif; } void start_emacps( xemacpsif_s * xemacps ) From bf1b30b7134df7824c393ad22f4cdcac6dfea46b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 24 Nov 2022 16:44:51 +0000 Subject: [PATCH 5/8] Uncrustify: triggered by comment. --- .../portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c | 2 +- .../NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c index 9662e37935..c26bdfda53 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c @@ -47,7 +47,7 @@ void setup_isr( xemacpsif_s * xemacpsif ) /* * Setup callbacks */ - XEmacPs *xInstancePtr = &xemacpsif->emacps; + XEmacPs * xInstancePtr = &xemacpsif->emacps; xInstancePtr->SendHandler = ( XEmacPs_Handler ) emacps_send_handler; xInstancePtr->SendRef = ( void * ) xemacpsif; diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index 20e425a3ef..3cf3e6aade 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -1021,7 +1021,7 @@ static uint32_t get_IEEE_phy_speed_US( XEmacPs * xemacpsp, XEmacPs_PhyRead( xemacpsp, phy_addr, PHY_IDENTIFIER_1_REG, &phy_identity ); - const char * pcPHINAme = pcGetPHIName( phy_identity ); + const char * pcPHINAme = pcGetPHIName( phy_identity ); FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcPHINAme, phy_identity ) ); /* Just to prevent compiler warnings about unused variablies. */ From 24d6a766dd5a7e67284aaf550a99b85349feb21f Mon Sep 17 00:00:00 2001 From: ChristosZosi <76208460+ChristosZosi@users.noreply.github.com> Date: Mon, 28 Nov 2022 07:54:10 +0100 Subject: [PATCH 6/8] Update source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c Co-authored-by: Paul Bartell --- .../portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c index c26bdfda53..c6362280f6 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c @@ -47,7 +47,7 @@ void setup_isr( xemacpsif_s * xemacpsif ) /* * Setup callbacks */ - XEmacPs * xInstancePtr = &xemacpsif->emacps; + XEmacPs * xInstancePtr = &( xemacpsif->emacps ); xInstancePtr->SendHandler = ( XEmacPs_Handler ) emacps_send_handler; xInstancePtr->SendRef = ( void * ) xemacpsif; From ba1f887b477ef72685a13485b6418d664eaedf79 Mon Sep 17 00:00:00 2001 From: ChristosZosi <76208460+ChristosZosi@users.noreply.github.com> Date: Mon, 28 Nov 2022 07:55:51 +0100 Subject: [PATCH 7/8] Apply suggestions from code review Co-authored-by: Paul Bartell --- .../xilinx_ultrascale/x_emacpsif_physpeed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index 3cf3e6aade..3c26cffc3e 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -1021,11 +1021,11 @@ static uint32_t get_IEEE_phy_speed_US( XEmacPs * xemacpsp, XEmacPs_PhyRead( xemacpsp, phy_addr, PHY_IDENTIFIER_1_REG, &phy_identity ); - const char * pcPHINAme = pcGetPHIName( phy_identity ); - FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcPHINAme, phy_identity ) ); + const char * pcPHYName = pcGetPHIName( phy_identity ); + FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcPHYName, phy_identity ) ); /* Just to prevent compiler warnings about unused variablies. */ - ( void ) pcPHINAme; + ( void ) pcPHYName; switch( phy_identity ) { From bd4c4e96c72ca41eee623ae0462c2c75e0d4aebe Mon Sep 17 00:00:00 2001 From: Christos Zosimidis Date: Thu, 29 Dec 2022 21:36:18 +0100 Subject: [PATCH 8/8] Address comments from reviews --- .../xilinx_ultrascale/x_emacpsif_hw.c | 6 +- .../xilinx_ultrascale/x_emacpsif_physpeed.c | 55 ------------------- 2 files changed, 3 insertions(+), 58 deletions(-) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c index c6362280f6..80b9386735 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c @@ -49,13 +49,13 @@ void setup_isr( xemacpsif_s * xemacpsif ) */ XEmacPs * xInstancePtr = &( xemacpsif->emacps ); - xInstancePtr->SendHandler = ( XEmacPs_Handler ) emacps_send_handler; + xInstancePtr->SendHandler = emacps_send_handler; xInstancePtr->SendRef = ( void * ) xemacpsif; - xInstancePtr->RecvHandler = ( XEmacPs_Handler ) emacps_recv_handler; + xInstancePtr->RecvHandler = emacps_recv_handler; xInstancePtr->RecvRef = ( void * ) xemacpsif; - xInstancePtr->ErrorHandler = ( XEmacPs_ErrHandler ) emacps_error_handler; + xInstancePtr->ErrorHandler = emacps_error_handler; xInstancePtr->ErrorRef = ( void * ) xemacpsif; } diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index 3c26cffc3e..039cef5dfc 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -245,18 +245,10 @@ void my_sleep( uint32_t uxTicks ) u32 phymapemac0[ 32 ]; u32 phymapemac1[ 32 ]; -static uint16_t prvAR803x_debug_reg_read( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg ); static uint16_t prvAR803x_debug_reg_write( XEmacPs * xemacpsp, uint32_t phy_addr, u16 reg, u16 value ); -static int prvAR803x_debug_reg_mask( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg, - u16 clear, - u16 set ); static void prvSET_AR803x_TX_Timing( XEmacPs * xemacpsp, uint32_t phy_addr ); @@ -832,32 +824,8 @@ static uint32_t get_AR8035_phy_speed( XEmacPs * xemacpsp, } } -static void ar8035Tick( XEmacPs * xemacpsp, - uint32_t phy_addr ) -{ - uint16_t value; - BaseType_t linkState; - - /*Read basic status register */ - value = XEmacPs_PhyRead2( xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET ); - /*Retrieve current link state */ - linkState = ( value & IEEE_STAT_LINK_STATUS ) ? TRUE : FALSE; - - /* Just to prevent compiler warnings about unused variable. */ - ( void ) linkState; -} - #define AR803X_DEBUG_ADDR 0x1D #define AR803X_DEBUG_DATA 0x1E -static uint16_t prvAR803x_debug_reg_read( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg ) -{ - XEmacPs_PhyWrite( xemacpsp, phy_addr, AR803X_DEBUG_ADDR, reg ); - - return XEmacPs_PhyRead2( xemacpsp, phy_addr, AR803X_DEBUG_DATA ); -} - static uint16_t prvAR803x_debug_reg_write( XEmacPs * xemacpsp, uint32_t phy_addr, u16 reg, @@ -868,29 +836,6 @@ static uint16_t prvAR803x_debug_reg_write( XEmacPs * xemacpsp, return XEmacPs_PhyWrite( xemacpsp, phy_addr, AR803X_DEBUG_DATA, value ); } -static int prvAR803x_debug_reg_mask( XEmacPs * xemacpsp, - uint32_t phy_addr, - u16 reg, - u16 clear, - u16 set ) -{ - u16 val; - int ret; - - ret = prvAR803x_debug_reg_read( xemacpsp, phy_addr, reg ); - - if( ret < 0 ) - { - return ret; - } - - val = ret & 0xffff; - val &= ~clear; - val |= set; - - return XEmacPs_PhyWrite( xemacpsp, phy_addr, AR803X_DEBUG_DATA, val ); -} - static uint32_t ar8035CheckStatus( XEmacPs * xemacpsp, uint32_t phy_addr ) {