From 4b3a2e7c11b0d1592f670e35d597b195df69a5a9 Mon Sep 17 00:00:00 2001 From: Michael Rupp <95718139+mykrupp@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:53:23 -0400 Subject: [PATCH] [SILABS] Minor fixes for LWIP usage (#34393) * Changes necessary for WiFi SDK lwip component usage vs. source/header file reference * Restyled by clang-format * Update src/platform/silabs/PlatformManagerImpl.cpp Co-authored-by: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> * remove extraneous FreeRTOS includes --------- Co-authored-by: Curtis Rahman Co-authored-by: Restyled.io Co-authored-by: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> --- src/platform/silabs/PlatformManagerImpl.cpp | 9 +++++---- src/platform/silabs/PlatformManagerImpl.h | 3 ++- src/platform/silabs/SiWx917/wifi/wfx_host_events.h | 1 - src/platform/silabs/efr32/wifi/wfx_host_events.h | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/platform/silabs/PlatformManagerImpl.cpp b/src/platform/silabs/PlatformManagerImpl.cpp index 741a0b6b8676e1..14dd4f78f2487e 100644 --- a/src/platform/silabs/PlatformManagerImpl.cpp +++ b/src/platform/silabs/PlatformManagerImpl.cpp @@ -47,13 +47,13 @@ namespace DeviceLayer { PlatformManagerImpl PlatformManagerImpl::sInstance; #if defined(SL_MBEDTLS_USE_TINYCRYPT) -sys_mutex_t PlatformManagerImpl::rngMutexHandle = NULL; +osMutexId_t PlatformManagerImpl::rngMutexHandle = nullptr; int PlatformManagerImpl::uECC_RNG_Function(uint8_t * dest, unsigned int size) { - sys_mutex_lock(&rngMutexHandle); + osMutexAcquire(rngMutexHandle, osWaitForever); int res = (chip::Crypto::DRBG_get_bytes(dest, size) == CHIP_NO_ERROR) ? size : 0; - sys_mutex_unlock(&rngMutexHandle); + osMutexRelease(rngMutexHandle); return res; } @@ -97,7 +97,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16)); #endif // !SLI_SI91X_MCU_INTERFACE /* Set RNG function for tinycrypt operations. */ - VerifyOrExit(sys_mutex_new(&rngMutexHandle) == ERR_OK, err = CHIP_ERROR_NO_MEMORY); + rngMutexHandle = osMutexNew(nullptr); + VerifyOrExit((&rngMutexHandle != nullptr), err = CHIP_ERROR_NO_MEMORY); uECC_set_rng(PlatformManagerImpl::uECC_RNG_Function); #endif // SL_MBEDTLS_USE_TINYCRYPT diff --git a/src/platform/silabs/PlatformManagerImpl.h b/src/platform/silabs/PlatformManagerImpl.h index b44fbadbfa3308..25813afb4839f9 100644 --- a/src/platform/silabs/PlatformManagerImpl.h +++ b/src/platform/silabs/PlatformManagerImpl.h @@ -28,6 +28,7 @@ #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION #include "wfx_host_events.h" #endif +#include namespace chip { namespace DeviceLayer { @@ -45,7 +46,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener // Since the RNG callback will be called from multiple threads, // use this mutex to lock/unlock the call to Matter RNG API, which // uses some global variables. - static sys_mutex_t rngMutexHandle; + static osMutexId_t rngMutexHandle; // Callback used by tinycrypt to generate random numbers. // It must be set before calling any sign operations, diff --git a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h index 745de9b38410ba..beee667f58f261 100644 --- a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h +++ b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h @@ -23,7 +23,6 @@ #include "wfx_msgs.h" /* LwIP includes. */ -#include "lwip/apps/httpd.h" #include "lwip/ip_addr.h" #include "lwip/netif.h" #include "lwip/netifapi.h" diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 3e83f3b07d46c5..24e5b6ea707a7a 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -117,7 +117,6 @@ typedef struct __attribute__((__packed__)) sl_wfx_mib_req_s #endif /* WF200 */ /* LwIP includes. */ -#include "lwip/apps/httpd.h" #include "lwip/ip_addr.h" #include "lwip/netif.h" #include "lwip/netifapi.h"