Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] Merge PlatformManagerImpl.cpp for efr32 and si917 platforms #33274

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <platform/PlatformManager.h>
#include <platform/internal/GenericPlatformManagerImpl_FreeRTOS.ipp>
#include <platform/silabs/DiagnosticDataProviderImpl.h>

#if defined(TINYCRYPT_PRIMITIVES)
#include "tinycrypt/ecc.h"
#endif
Expand All @@ -39,30 +40,27 @@
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

#include "AppConfig.h"
#include "FreeRTOS.h"

using namespace chip::DeviceLayer::Internal;

namespace chip {
namespace DeviceLayer {

PlatformManagerImpl PlatformManagerImpl::sInstance;

#if SLI_SI91X_MCU_INTERFACE
#if defined(TINYCRYPT_PRIMITIVES)
sys_mutex_t PlatformManagerImpl::rngMutexHandle = NULL;
#endif

#if defined(TINYCRYPT_PRIMITIVES)
int PlatformManagerImpl::uECC_RNG_Function(uint8_t * dest, unsigned int size)
{
int res;

sys_mutex_lock(&rngMutexHandle);
res = (chip::Crypto::DRBG_get_bytes(dest, size) == CHIP_NO_ERROR) ? size : 0;
int res = (chip::Crypto::DRBG_get_bytes(dest, size) == CHIP_NO_ERROR) ? size : 0;
sys_mutex_unlock(&rngMutexHandle);

return res;
}
#endif
#endif // TINYCRYPT_PRIMITIVES
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved

static void app_get_random(uint8_t * aOutput, size_t aLen)
{
Expand All @@ -81,6 +79,7 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s

return 0;
}
#endif // SLI_SI91X_MCU_INTERFACE

CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
{
Expand All @@ -97,16 +96,15 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)

ReturnErrorOnFailure(System::Clock::InitClock_RealTime());

// 16 : Threshold value
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16));
#if SLI_SI91X_MCU_INTERFACE
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16 /*Threshold value*/));

#if defined(TINYCRYPT_PRIMITIVES)
/* Set RNG function for tinycrypt operations. */
err_t ret;
ret = sys_mutex_new(&rngMutexHandle);
VerifyOrExit((ERR_OK == ret), err = CHIP_ERROR_NO_MEMORY);
VerifyOrExit(sys_mutex_new(&rngMutexHandle) == ERR_OK, err = CHIP_ERROR_NO_MEMORY);
uECC_set_rng(PlatformManagerImpl::uECC_RNG_Function);
#endif
#endif // TINYCRYPT_PRIMITIVES
#endif // SLI_SI91X_MCU_INTERFACE

// Call _InitChipStack() on the generic implementation base class
// to finish the initialization process.
Expand Down Expand Up @@ -139,6 +137,7 @@ void PlatformManagerImpl::_Shutdown()
{
Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>::_Shutdown();
}

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
void PlatformManagerImpl::HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData)
{
Expand Down Expand Up @@ -206,7 +205,7 @@ void PlatformManagerImpl::HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wf

(void) sInstance.PostEvent(&event);
}
#endif
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION

} // namespace DeviceLayer
} // namespace chip
2 changes: 1 addition & 1 deletion src/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static_library("SiWx917") {
"${silabs_platform_dir}/Logging.cpp",
"${silabs_platform_dir}/MigrationManager.cpp",
"${silabs_platform_dir}/MigrationManager.h",
"${silabs_platform_dir}/PlatformManagerImpl.cpp",
"${silabs_platform_dir}/PlatformManagerImpl.h",
"${silabs_platform_dir}/SilabsConfig.cpp",
"${silabs_platform_dir}/SilabsConfig.h",
Expand All @@ -63,7 +64,6 @@ static_library("SiWx917") {
"../rs911x/rsi_ble_config.h",
"../rs911x/wfx_sl_ble_init.c",
"../rs911x/wfx_sl_ble_init.h",
"PlatformManagerImpl.cpp",
]

if (chip_enable_ota_requestor) {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static_library("efr32") {
"${silabs_platform_dir}/KeyValueStoreManagerImpl.h",
"${silabs_platform_dir}/Logging.cpp",
"${silabs_platform_dir}/MigrationManager.cpp",
"${silabs_platform_dir}/PlatformManagerImpl.cpp",
"${silabs_platform_dir}/PlatformManagerImpl.h",
"${silabs_platform_dir}/SilabsConfig.cpp",
"${silabs_platform_dir}/SilabsConfig.h",
Expand All @@ -64,7 +65,6 @@ static_library("efr32") {
"${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h",
"../../FreeRTOS/SystemTimeSupport.cpp",
"../../SingletonConfigurationManager.cpp",
"PlatformManagerImpl.cpp",
]

if (chip_enable_ble_rs911x) {
Expand Down
163 changes: 0 additions & 163 deletions src/platform/silabs/efr32/PlatformManagerImpl.cpp

This file was deleted.

Loading