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

Revisions to System::Layer #8267

Merged
merged 4 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 9 additions & 22 deletions src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,9 @@

#include <platform/CHIPDeviceBuildConfig.h>
#include <platform/CHIPDeviceEvent.h>
#include <system/SystemLayer.h>

namespace chip {
namespace System {
namespace Platform {
namespace Layer {

CHIP_ERROR PostEvent(System::Layer & aLayer, void * aContext, System::Object & aTarget, System::EventType aType,
uintptr_t aArgument);
CHIP_ERROR DispatchEvents(System::Layer & aLayer, void * aContext);
CHIP_ERROR DispatchEvent(System::Layer & aLayer, void * aContext, System::Event aEvent);
CHIP_ERROR StartTimer(System::Layer & aLayer, void * aContext, uint32_t aMilliseconds);

} // namespace Layer
} // namespace Platform
} // namespace System

namespace DeviceLayer {

class PlatformManagerImpl;
Expand Down Expand Up @@ -183,14 +170,14 @@ class PlatformManager
template <class>
friend class Internal::GenericConfigurationManagerImpl;
// Parentheses used to fix clang parsing issue with these declarations
friend ::CHIP_ERROR(::chip::System::Platform::Layer::PostEvent)(::chip::System::Layer & aLayer, void * aContext,
::chip::System::Object & aTarget,
::chip::System::EventType aType, uintptr_t aArgument);
friend ::CHIP_ERROR(::chip::System::Platform::Layer::DispatchEvents)(::chip::System::Layer & aLayer, void * aContext);
friend ::CHIP_ERROR(::chip::System::Platform::Layer::DispatchEvent)(::chip::System::Layer & aLayer, void * aContext,
::chip::System::Event aEvent);
friend ::CHIP_ERROR(::chip::System::Platform::Layer::StartTimer)(::chip::System::Layer & aLayer, void * aContext,
uint32_t aMilliseconds);
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::PostEvent)(::chip::System::Layer & aLayer, void * aContext,
::chip::System::Object & aTarget,
::chip::System::EventType aType, uintptr_t aArgument);
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::DispatchEvents)(::chip::System::Layer & aLayer, void * aContext);
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::DispatchEvent)(::chip::System::Layer & aLayer, void * aContext,
::chip::System::Event aEvent);
friend ::CHIP_ERROR(::chip::System::Platform::EventSupport::StartTimer)(::chip::System::Layer & aLayer, void * aContext,
uint32_t aMilliseconds);

void PostEvent(const ChipDeviceEvent * event);
void DispatchEvent(const ChipDeviceEvent * event);
Expand Down
3 changes: 1 addition & 2 deletions src/platform/EFR32/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ struct ChipDeviceEvent;

// ==================== Platform Adaptations ====================
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE int
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *

// ========== Platform-specific Configuration Overrides =========

Expand Down
3 changes: 1 addition & 2 deletions src/platform/ESP32/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ struct ChipDeviceEvent;

// ==================== Platform Adaptations ====================
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE int
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *

// ==================== General Configuration Overrides ====================

Expand Down
3 changes: 1 addition & 2 deletions src/platform/K32W/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ struct ChipDeviceEvent;

// ==================== Platform Adaptations ====================
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE int
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *

// ========== Platform-specific Configuration Overrides =========

Expand Down
4 changes: 2 additions & 2 deletions src/platform/SystemEventSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace chip {
namespace System {
namespace Platform {
namespace Layer {
namespace EventSupport {

using namespace ::chip::DeviceLayer;

Expand Down Expand Up @@ -62,7 +62,7 @@ CHIP_ERROR DispatchEvent(System::Layer & aLayer, void * aContext, const ChipDevi
return CHIP_NO_ERROR;
}

} // namespace Layer
} // namespace EventSupport
} // namespace Platform
} // namespace System
} // namespace chip
4 changes: 2 additions & 2 deletions src/platform/SystemTimerSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace chip {
namespace System {
namespace Platform {
namespace Layer {
namespace EventSupport {

using namespace ::chip::DeviceLayer;

Expand All @@ -39,7 +39,7 @@ CHIP_ERROR StartTimer(System::Layer & aLayer, void * aContext, uint32_t aMillise
return PlatformMgr().StartChipTimer(aMilliseconds);
}

} // namespace Layer
} // namespace EventSupport
} // namespace Platform
} // namespace System
} // namespace chip
3 changes: 1 addition & 2 deletions src/platform/cc13x2_26x2/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ struct ChipDeviceEvent;

// ==================== Platform Adaptations ====================
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE int
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *

// ========== Platform-specific Configuration Overrides =========

Expand Down
3 changes: 1 addition & 2 deletions src/platform/mbed/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ struct ChipDeviceEvent;
#define CHIP_SYSTEM_CONFIG_MBED_LOCKING 1
#define CHIP_SYSTEM_CONFIG_NO_LOCKING 0
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE int
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *

// ========== Platform-specific Configuration Overrides =========

Expand Down
3 changes: 1 addition & 2 deletions src/platform/qpg/SystemPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ struct ChipDeviceEvent;

// ==================== Platform Adaptations ====================
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE int
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *

// ========== Platform-specific Configuration Overrides =========

Expand Down
77 changes: 44 additions & 33 deletions src/system/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,30 +359,6 @@
#ifndef CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX
#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX 1583
#endif /* CHIP_SYSTEM_CONFIG_PACKETBUFFER_CAPACITY_MAX */
#endif /* !CHIP_SYSTEM_CONFIG_USE_LWIP */

#if CHIP_SYSTEM_CONFIG_USE_LWIP

/**
* @def CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE
*
* @brief
* This defines the type for CHIP System Layer event types, typically an integral type.
*/
#ifndef CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE int
#endif /* CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE */

/**
* @def CHIP_SYSTEM_CONFIG_LWIP_EVENT_UNRESERVED_CODE
*
* @brief
* This defines the first number in the default event code space not reserved for use by the CHIP System Layer.
* Event codes used by each layer must not overlap.
*/
#ifndef CHIP_SYSTEM_CONFIG_LWIP_EVENT_UNRESERVED_CODE
#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_UNRESERVED_CODE 32
#endif /* CHIP_SYSTEM_CONFIG_LWIP_EVENT_UNRESERVED_CODE */

/**
* @def _CHIP_SYSTEM_CONFIG_LWIP_EVENT
Expand All @@ -395,16 +371,30 @@
#define _CHIP_SYSTEM_CONFIG_LWIP_EVENT(e) (e)
#endif /* _CHIP_SYSTEM_CONFIG_LWIP_EVENT */

#endif /* !CHIP_SYSTEM_CONFIG_USE_LWIP */

/**
* @def CHIP_SYSTEM_CONFIG_EVENT_TYPE
*
* @brief
* This defines the type for CHIP System Layer event types, typically an integral type.
*/
#ifndef CHIP_SYSTEM_CONFIG_EVENT_TYPE
#define CHIP_SYSTEM_CONFIG_EVENT_TYPE int
#endif /* CHIP_SYSTEM_CONFIG_EVENT_TYPE */

/**
* @def CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE
* @def CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE
*
* @brief
* This defines the type of CHIP System Layer event objects or "messages" for the LwIP dispatcher.
* This defines the type of CHIP System Layer event objects or "messages".
*
* Such types are not directly used by the CHIP System Layer but are "passed through". Consequently a forward declaration and
* a const pointer or reference are appropriate.
*/
#ifndef CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE
#ifndef CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE

#if CHIP_SYSTEM_CONFIG_USE_LWIP
namespace chip {
namespace System {

Expand All @@ -413,20 +403,41 @@ struct LwIPEvent;
} // namespace System
} // namespace chip

#define CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE const struct chip::System::LwIPEvent*
#endif /* CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE */
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct chip::System::LwIPEvent*

#else /* CHIP_SYSTEM_CONFIG_USE_LWIP */

#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *

#endif /* CHIP_SYSTEM_CONFIG_USE_LWIP */

#endif /* CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE */

#if CHIP_SYSTEM_CONFIG_USE_LWIP

/**
* @def _CHIP_SYSTEM_CONFIG_LWIP_EVENT
*
* @brief
* This defines a mapping function for CHIP System Layer codes for describing the types of events for the LwIP dispatcher,
* which allows mapping such event types into a platform- or system-specific range.
*/
#ifndef _CHIP_SYSTEM_CONFIG_LWIP_EVENT
#define _CHIP_SYSTEM_CONFIG_LWIP_EVENT(e) (e)
#endif /* _CHIP_SYSTEM_CONFIG_LWIP_EVENT */

#endif /* CHIP_SYSTEM_CONFIG_USE_LWIP */


/**
* @def CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_XTOR_FUNCTIONS
*
* @brief
* This defines whether (1) or not (0) your platform will provide the following platform-specific functions:
* - chip::System::Platform::Layer::WillInit
* - chip::System::Platform::Layer::WillShutdown
* - chip::System::Platform::Layer::DidInit
* - chip::System::Platform::Layer::DidShutdown
* - chip::System::Platform::WillInit
* - chip::System::Platform::WillShutdown
* - chip::System::Platform::DidInit
* - chip::System::Platform::DidShutdown
*/
#ifndef CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_XTOR_FUNCTIONS
#define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_XTOR_FUNCTIONS 0
Expand Down
48 changes: 4 additions & 44 deletions src/system/SystemEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ struct ChipDeviceEvent;
namespace chip {
namespace System {

#if CHIP_SYSTEM_CONFIG_USE_LWIP

/**
* @typedef EventType
* The basic type for all InetLayer events.
*
* This is defined to a platform- or system-specific type.
*
*/
typedef CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE EventType;
typedef CHIP_SYSTEM_CONFIG_EVENT_TYPE EventType;

/**
* @typedef Event
Expand All @@ -54,7 +52,9 @@ typedef CHIP_SYSTEM_CONFIG_LWIP_EVENT_TYPE EventType;
* This is defined to a platform- or system-specific type.
*
*/
typedef CHIP_SYSTEM_CONFIG_LWIP_EVENT_OBJECT_TYPE Event;
typedef CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE Event;

#if CHIP_SYSTEM_CONFIG_USE_LWIP

/**
* The Inet layer event type definitions.
Expand All @@ -66,46 +66,6 @@ enum
kEvent_ScheduleWork = _CHIP_SYSTEM_CONFIG_LWIP_EVENT(1), /**< The event for scheduling work on the System Layer's thread. */
};

/**
* Check to verify if an EventType is a valid one.
*
* @param[in] aEventType CHIP System Layer event type.
*
* @return true if it falls within the enumerated range; otherwise, false.
*/
static inline bool IsEventOfType(EventType aEventType)
{
return (aEventType >= kEvent_ReleaseObj && aEventType <= kEvent_ScheduleWork);
}

#else

#ifndef CHIP_SYSTEM_CONFIG_EVENT_TYPE
#define CHIP_SYSTEM_CONFIG_EVENT_TYPE int
#endif

#ifndef CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE
#define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent *
#endif

/**
* @typedef EventType
* The basic type for all InetLayer events.
*
* This is defined to a platform- or system-specific type.
*
*/
typedef CHIP_SYSTEM_CONFIG_EVENT_TYPE EventType;

/**
* @typedef Event
* The basic object for all InetLayer events.
*
* This is defined to a platform- or system-specific type.
*
*/
typedef CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE Event;

#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

} // namespace System
Expand Down
Loading