Skip to content

Commit

Permalink
[slc][platform] add OpenThread vendor extension and ot_crash_handler …
Browse files Browse the repository at this point in the history
…to platform projects

The new `ot_vendor_extension` component implements the `ot::Extension::Extension` class.
This will print the efr32 on NCP/RCP initialization. The rest of the class is stubbed out.
  • Loading branch information
lmnotran committed Feb 29, 2024
1 parent ce1b303 commit 4a0b4d6
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 0 deletions.
17 changes: 17 additions & 0 deletions slc/component/ot_vendor_extension.slcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
id: ot_vendor_extension
label: Silicon Labs OpenThread Vendor Extension
package: OpenThread
category: OpenThread
quality: production
description: This component implements ot::Extension::ExtensionBase for EFR32
provides:
- name: ot_vendor_extension
include:
- path: openthread/src/
file_list:
- path: ncp/ncp_base.hpp
source:
- path: src/openthread/core/vendor_extension.cpp
define:
- name: OPENTHREAD_ENABLE_VENDOR_EXTENSION
value: 1
3 changes: 3 additions & 0 deletions slc/platform_projects/openthread-efr32-rcp-spi.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
- id: ot_platform_abstraction_core
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_vendor_extension
from: ot-efr32
- id: ot_ncp_spidrv
- id: rail_util_pti

Expand Down
3 changes: 3 additions & 0 deletions slc/platform_projects/openthread-efr32-rcp-uart.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
- id: ot_platform_abstraction_core
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
3 changes: 3 additions & 0 deletions slc/platform_projects/openthread-efr32-soc-with-buttons.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
3 changes: 3 additions & 0 deletions slc/platform_projects/openthread-efr32-soc.slcp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ category: OpenThread Examples
quality: production

component:
- id: ot_crash_handler
- id: ot_platform_abstraction_core
- id: ot_psa_crypto
- id: ot_mbedtls
- id: ot_stack_features_config
from: ot-efr32
- id: ot_vendor_extension
from: ot-efr32
- id: uartdrv_usart
instance:
- vcom
Expand Down
109 changes: 109 additions & 0 deletions src/openthread/core/vendor_extension.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2024, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/**
* @file
* This file implements a OpenThread vendor extension for EFR32
*/

#include "openthread-core-config.h"

#include <stdbool.h>
#include <stdint.h>

#include "common/code_utils.hpp"
#include "common/new.hpp"

#include "instance/extension.hpp"

#if defined(SL_COMPONENT_CATALOG_PRESENT)
#include "sl_component_catalog.h"
#endif

extern "C" void efr32PrintResetInfo(void);

namespace ot {
namespace Extension {

/**
* Defines the vendor extension object.
*
*/
class Extension : public ExtensionBase
{
public:
explicit Extension(Instance &aInstance)
: ExtensionBase(aInstance)
{
}
};

// ----------------------------------------------------------------------------
// `ExtensionBase` API
// ----------------------------------------------------------------------------

static OT_DEFINE_ALIGNED_VAR(sExtensionRaw, sizeof(Extension), uint64_t);

ExtensionBase &ExtensionBase::Init(Instance &aInstance)
{
ExtensionBase *ext = reinterpret_cast<ExtensionBase *>(&sExtensionRaw);

VerifyOrExit(!ext->mIsInitialized);

ext = new (&sExtensionRaw) Extension(aInstance);

exit:
return *ext;
}

void ExtensionBase::SignalInstanceInit(void)
{
// OpenThread instance is initialized and ready.

#if defined(SL_CATALOG_OT_CRASH_HANDLER_PRESENT)
efr32PrintResetInfo();
#endif
}

void ExtensionBase::SignalNcpInit(Ncp::NcpBase &aNcpBase)
{
// NCP instance is initialized and ready.
OT_UNUSED_VARIABLE(aNcpBase);

#if defined(SL_CATALOG_OT_CRASH_HANDLER_PRESENT)
efr32PrintResetInfo();
#endif
}

void ExtensionBase::HandleNotifierEvents(Events aEvents)
{
OT_UNUSED_VARIABLE(aEvents);
}

} // namespace Extension
} // namespace ot

0 comments on commit 4a0b4d6

Please sign in to comment.