feat(bt): refactor bt sdk with broker for esp32h4 and esp32s31

This commit is contained in:
ShenWeilong
2026-08-13 11:07:06 +08:00
parent b418d72bb0
commit c48a8567a1
42 changed files with 7360 additions and 3938 deletions
@@ -1,3 +1,112 @@
menu "Connection vendor/Optimization Options"
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
bool "Enable enhanced Access Address check in CONNECT_IND"
default n
help
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
If disabled, only basic checks are applied, improving compatibility.
config BT_LE_CTRL_CHAN_ASS_EN
bool "Enable channel assessment(Experimental)"
default n
help
If this option is enabled, The Controller will records the communication quality
for each channel and then start a timer to check and update the channel map every 4 seconds.
menu "BLE disconnects when Instant Passed (0x28) occurs"
config BT_LE_CTRL_LLCP_CONN_UPDATE
bool "BLE ACL connection update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs during connection update procedure.
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
bool "BLE ACL channel map update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs in channel map update procedure.
config BT_LE_CTRL_LLCP_PHY_UPDATE
bool "BLE ACL PHY update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs in PHY update procedure.
endmenu # "BLE disconnects when Instant Passed (0x28) occurs"
endmenu # "Connection vendor/Optimization Options"
menu "Scanning vendor/Optimization Options"
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
int "The value of upperlimitmax during scan backoff procedure"
range 1 256
default 32
help
The value of upperlimitmax needs to be a power of 2.
endmenu # "Scanning vendor/Optimization Options"
menu "Advertising vendor/Optimization Options"
config BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
bool "Enable aux packet when ext adv data length is zero(Experimental)"
default y
help
When this option is enabled, auxiliary packets will be present in the events of
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
config BT_LE_CTRL_ADV_EVENT_INC_ON_FULL_TX_EN
bool "Increment advertising event count only on full PDU TX success"
default n
help
When enabled, the advertising event count is incremented only
if all PDUs in an advertising event are transmitted successfully.
If disabled, the event count is incremented regardless of transmission success.
config BT_LE_CTRL_ADV_CH38_39_TX_AVOID_CONFLICT_EN
bool "Delay advertising TX on channels 38/39 to avoid scheduling conflicts"
default n
help
When enabled, advertising transmissions on channels 38 and 39
are delayed if a scheduling conflict occurs.
config BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN
bool "(Unsupported !!) Enable separate TX power for advertising on channel 39"
default n
help
When enabled, the TX power for advertising transmissions
on channel 39 can be configured independently of other channels.
config BT_LE_DFT_CH39_TX_POWER_LEVEL_DBM_EFF
int "Tx power for advertising on channel 39 (dBm)"
depends on BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN
range -15 20
default 0
config BT_LE_CTRL_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN
bool "Allow advertising TX to continue if data TX exceeds interval"
default n
help
When enabled, advertising transmission continues even if the
TX duration for advertising data exceeds the configured advertising interval.
config BT_LE_CTRL_ADV_RAND_CH_IDX_EN
bool "Enable Randomized Advertising Channel Indexing"
default n
help
When enabled, the advertising channel sequence is randomized
according to the Randomized Advertising Channel Indexing feature.
If disabled, the standard channel sequence is used.
config BT_LE_CTRL_FAST_CONN_DATA_TX_EN
bool "Enable fast sending of connection data"
default y
help
If this option is enabled, The Controller will continue to
Send an empty PDU after sending valid connection data within an interval.
endmenu # "Advertising vendor/Optimization Options"
menuconfig BT_LE_50_FEATURE_SUPPORT
bool "Enable BLE 5 feature"
@@ -64,6 +173,19 @@ if BT_LE_EXT_ADV
help
This enables controller transfer periodic sync events to host
config BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED
bool "Enable BLE periodic advertising with response"
depends on BT_LE_ENABLE_PERIODIC_ADV && SOC_BLE_PERIODIC_ADV_WITH_RESPONSE
default n
help
This enables BLE periodic advertising with response feature
config BT_LE_PERIODIC_SYNC_WITH_RESPONSE_ENABLED
bool "Enable BLE periodic sync with response"
depends on BT_LE_ENABLE_PERIODIC_ADV && SOC_BLE_PERIODIC_ADV_WITH_RESPONSE
default n
help
This enables BLE periodic sync with response feature
endif
config BT_LE_MAX_PERIODIC_SYNCS
@@ -110,13 +232,6 @@ config BT_LE_CTE_FEATURE_ENABLED
This feature allows devices to determine the direction of a Bluetooth CTE signal,
enabling Angle of Arrival (AoA) and Angle of Departure (AoD) functionality.
config BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED
bool "Enable BLE periodic advertising with response"
depends on BT_LE_50_FEATURE_SUPPORT && SOC_BLE_PERIODIC_ADV_WITH_RESPONSE
default n
help
This enables BLE periodic advertising with response feature
menuconfig BT_LE_ISO_SUPPORT
bool "Enable BLE ISO feature"
default n
@@ -616,3 +731,23 @@ config BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF
config BT_LE_DTM_ENABLED
bool "Enable Direct Test Mode (DTM) feature"
default n
menuconfig BT_CTRL_LE_VS_CMD_EVT_ENABLED
bool "Enable vendor-specific HCI commands"
default n if BT_CONTROLLER_ONLY
default y
help
Enable controller's vendor-specific HCI commands
config BT_CTRL_LE_VS_ADI_FILTER_ENABLED
depends on BT_CTRL_LE_VS_CMD_EVT_ENABLED && !BT_NIMBLE_ENABLED
bool "Use ADI to failter adv reports"
default n
help
ADI can be utilized to filter advertisement reports,
which will help to reduce time consumption on the secondary channel.
config BT_CTRL_LE_VS_CONST_EXT_ADV_DID
default n
depends on BT_CTRL_LE_VS_CMD_EVT_ENABLED && !BT_NIMBLE_ENABLED
bool "Allow setting constant extended advertisement DID"
@@ -16,6 +16,8 @@ int ble_stack_enable(void);
void ble_stack_disable(void);
void ble_stack_reset(void);
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
esp_err_t sleep_modem_ble_mac_modem_state_init(void);
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
@@ -7,8 +7,9 @@
#ifndef __BLE_USER_CFG_H__
#define __BLE_USER_CFG_H__
#include <stdint.h>
#include <sdkconfig.h>
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -20,156 +21,339 @@ extern "C" {
#if CONFIG_BT_NIMBLE_ENABLED
#if CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED MYNEWT_VAL(BLE_POWER_CONTROL)
#if CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#else
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
#endif
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS (CONFIG_BT_LE_MAX_CONNECTIONS)
#else
#define DEFAULT_BT_LE_MAX_CONNECTIONS (2)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_SIZE (CONFIG_BT_LE_ACL_BUF_SIZE)
#else
#define DEFAULT_BT_LE_ACL_BUF_SIZE (255)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_COUNT)
#define DEFAULT_BT_LE_ACL_BUF_COUNT (CONFIG_BT_LE_ACL_BUF_COUNT)
#else
#define DEFAULT_BT_LE_ACL_BUF_COUNT (24)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#else
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (70)
#endif
#if defined(CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#else
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (31)
#endif
#if defined(CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#else
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (1)
#endif
#if defined(CONFIG_BT_LE_WHITELIST_SIZE)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (CONFIG_BT_LE_WHITELIST_SIZE)
#else
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (12)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (30)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8)
#endif
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#if defined(CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED (CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#else
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED (0)
#endif
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
#else
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
#endif
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
#else
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
#endif
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
#define DEFAULT_BT_LE_MAX_CONNECTIONS (CONFIG_BT_LE_MAX_CONNECTIONS)
#else
#define DEFAULT_BT_LE_MAX_CONNECTIONS (2)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_SIZE)
#define DEFAULT_BT_LE_ACL_BUF_SIZE (CONFIG_BT_LE_ACL_BUF_SIZE)
#else
#define DEFAULT_BT_LE_ACL_BUF_SIZE (255)
#endif
#if defined(CONFIG_BT_LE_ACL_BUF_COUNT)
#define DEFAULT_BT_LE_ACL_BUF_COUNT (CONFIG_BT_LE_ACL_BUF_COUNT)
#else
#define DEFAULT_BT_LE_ACL_BUF_COUNT (24)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
#else
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (70)
#endif
#if defined(CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
#else
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (31)
#endif
#if defined(CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
#else
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (1)
#endif
#if defined(CONFIG_BT_LE_WHITELIST_SIZE)
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (CONFIG_BT_LE_WHITELIST_SIZE)
#else
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (12)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (30)
#endif
#if defined(CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
#else
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8)
#endif
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
#endif // CONFIG_BT_NIMBLE_ENABLED
#ifdef CONFIG_BT_LE_TX_CCA_ENABLED
#define DEFAULT_BT_LE_TX_CCA_ENABLED (CONFIG_BT_LE_TX_CCA_ENABLED)
#define DEFAULT_BT_LE_TX_CCA_ENABLED (CONFIG_BT_LE_TX_CCA_ENABLED)
#else
#define DEFAULT_BT_LE_TX_CCA_ENABLED (0)
#define DEFAULT_BT_LE_TX_CCA_ENABLED (0)
#endif
#ifdef CONFIG_BT_LE_CCA_RSSI_THRESH
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (CONFIG_BT_LE_CCA_RSSI_THRESH)
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (CONFIG_BT_LE_CCA_RSSI_THRESH)
#else
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (50)
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (50)
#endif
#define DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N DEFAULT_BT_LE_EXT_ADV_MAX_SIZE
#define UC_BLE_CTRL_CONN_ENABLED (1)
#if defined(CONFIG_BT_NIMBLE_AOA_AOD)
#define UC_BT_CTRL_LE_CTE_ENABLED (CONFIG_BT_NIMBLE_AOA_AOD)
#elif defined(CONFIG_BT_LE_CTE_ENABLED)
#define UC_BT_CTRL_LE_CTE_ENABLED (CONFIG_BT_LE_CTE_ENABLED)
#elif defined(CONFIG_BT_LE_CTE_FEATURE_ENABLED)
#define UC_BT_CTRL_LE_CTE_ENABLED (CONFIG_BT_LE_CTE_FEATURE_ENABLED)
#else
#define UC_BT_CTRL_LE_CTE_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_AOA_AOD
#define UC_BT_CTRL_LE_CTE_CAL_ENABLED (0)
#if CONFIG_BT_LE_DTM_ENABLED
#define UC_BT_CTRL_LE_DTM_ENABLED (CONFIG_BT_LE_DTM_ENABLED)
#else
#define UC_BT_CTRL_LE_DTM_ENABLED (0)
#endif
#if defined(CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#elif defined(CONFIG_BT_BLE_FEAT_PAWR_EN)
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (CONFIG_BT_BLE_FEAT_PAWR_EN)
#elif defined(CONFIG_BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED)
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (CONFIG_BT_LE_PERIODIC_ADV_WITH_RESPONSE_ENABLED)
#else
#define UC_BLE_CTRL_PAWR_BCAST_SUPPORTED (0)
#endif // CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES
#if defined(CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES)
#elif defined(CONFIG_BT_BLE_FEAT_PAWR_EN)
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (CONFIG_BT_BLE_FEAT_PAWR_EN)
#elif defined(CONFIG_BT_LE_PERIODIC_SYNC_WITH_RESPONSE_ENABLED)
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (CONFIG_BT_LE_PERIODIC_SYNC_WITH_RESPONSE_ENABLED)
#else
#define UC_BLE_CTRL_PAWR_SYNC_SUPPORTED (0)
#endif // CONFIG_BT_NIMBLE_PERIODIC_ADV_WITH_RESPONSES
#define UC_BT_CTRL_LE_BIS_BCAST_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_BIS_SYNC_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_CIS_CENT_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_CIS_PRPH_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_CIS_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_ISO_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#define UC_BT_CTRL_LE_ISO_TEST_ENABLED (CONFIG_BT_LE_ISO_SUPPORT)
#if defined(CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
#define UC_BT_CTRL_LE_50_FEATURE_SUPPORT (CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
#elif defined(CONFIG_BT_LE_50_FEATURE_SUPPORT)
#define UC_BT_CTRL_LE_50_FEATURE_SUPPORT (CONFIG_BT_LE_50_FEATURE_SUPPORT)
#else
#define UC_BT_CTRL_LE_50_FEATURE_SUPPORT (0)
#endif // CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT
#if defined(CONFIG_BT_NIMBLE_SUBRATE)
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (CONFIG_BT_NIMBLE_SUBRATE)
#elif defined(CONFIG_BT_BLE_FEAT_CONN_SUBRATING)
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (CONFIG_BT_BLE_FEAT_CONN_SUBRATING)
#elif defined(CONFIG_BT_LE_SUBRATE_ENABLED)
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (CONFIG_BT_LE_SUBRATE_ENABLED)
#else
#define UC_BT_CTRL_LE_SUBRATE_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_SUBRATE
#if defined(CONFIG_BT_NIMBLE_BLE_POWER_CONTROL)
#define UC_BT_CTRL_LE_POWER_CONTROL_ENABLED (CONFIG_BT_NIMBLE_BLE_POWER_CONTROL)
#elif defined(CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#define UC_BT_CTRL_LE_POWER_CONTROL_ENABLED (CONFIG_BT_LE_POWER_CONTROL_ENABLED)
#else
#define UC_BT_CTRL_LE_POWER_CONTROL_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_BLE_POWER_CONTROL
#if defined(CONFIG_BT_CTRL_LE_VS_CMD_EVT_ENABLED)
#define UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED (CONFIG_BT_CTRL_LE_VS_CMD_EVT_ENABLED)
#else
#define UC_BT_CTRL_LE_VS_CMD_EVT_ENABLED (0)
#endif // CONFIG_BT_CTRL_LE_VS_CMD_EVT_ENABLED
#if defined(CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID)
#define UC_BT_CTRL_LE_VS_CONST_EXT_ADV_DID (CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID)
#elif defined(CONFIG_BT_CTRL_LE_VS_CONST_EXT_ADV_DID)
#define UC_BT_CTRL_LE_VS_CONST_EXT_ADV_DID (CONFIG_BT_CTRL_LE_VS_CONST_EXT_ADV_DID)
#else
#define UC_BT_CTRL_LE_VS_CONST_EXT_ADV_DID (0)
#endif // CONFIG_BT_NIMBLE_ADV_SEND_CONSTANT_DID
#if defined(CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER)
#define UC_BT_CTRL_LE_VS_ADI_FILTER_ENABLED (CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER)
#elif defined(CONFIG_BT_CTRL_LE_VS_ADI_FILTER_ENABLED)
#define UC_BT_CTRL_LE_VS_ADI_FILTER_ENABLED (CONFIG_BT_CTRL_LE_VS_ADI_FILTER_ENABLED)
#else
#define UC_BT_CTRL_LE_VS_ADI_FILTER_ENABLED (0)
#endif // CONFIG_BT_NIMBLE_SCAN_ALLOW_ENH_ADI_FILTER
#if defined(CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
#define UC_BT_CTRL_LE_CHECK_CONNECT_IND_ACCESS_ADDRESS (CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS)
#else
#define UC_BT_CTRL_LE_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
#endif // CONFIG_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
#if defined(CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE)
#define UC_BT_CTRL_LE_CONN_UPDATE_PASSED_DISC_FLAG (1 << 0)
#else
#define UC_BT_CTRL_LE_CONN_UPDATE_PASSED_DISC_FLAG (0 << 0)
#endif // CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
#if defined(CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE)
#define UC_BT_CTRL_LE_CHAN_UPDATE_PASSED_DISC_FLAG (1 << 1)
#else
#define UC_BT_CTRL_LE_CHAN_UPDATE_PASSED_DISC_FLAG (0 << 1)
#endif // CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
#if defined(CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE)
#define UC_BT_CTRL_LE_PHY_UPDATE_PASSED_DISC_FLAG (1 << 2)
#else
#define UC_BT_CTRL_LE_PHY_UPDATE_PASSED_DISC_FLAG (0 << 2)
#endif // CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
#define UC_BT_CTRL_LLCP_INSTANT_PASSED_DISC_FLAGS \
(UC_BT_CTRL_LE_CONN_UPDATE_PASSED_DISC_FLAG | UC_BT_CTRL_LE_CHAN_UPDATE_PASSED_DISC_FLAG | \
UC_BT_CTRL_LE_PHY_UPDATE_PASSED_DISC_FLAG)
#if defined(CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
#define UC_BT_CTRL_LE_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
#else
#define UC_BT_CTRL_LE_SCAN_BACKOFF_UPPERLIMITMAX (256)
#endif // CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
#if defined(CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
#define UC_BT_CTRL_LE_CHAN_ASS_ENABLED (CONFIG_BT_LE_CTRL_CHAN_ASS_EN)
#else
#define UC_BT_CTRL_LE_CHAN_ASS_ENABLED (0)
#endif // CONFIG_BT_LE_CTRL_CHAN_ASS_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
#define UC_BT_CTRL_LE_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX)
#else
#define UC_BT_CTRL_LE_ADV_DATA_LENGTH_ZERO_AUX (1)
#endif // CONFIG_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX
#if defined(CONFIG_BT_LE_PTR_CHECK_ENABLED)
#define UC_BT_CTRL_LE_PTR_CHECK_ENABLED (CONFIG_BT_LE_PTR_CHECK_ENABLED)
#else
#define UC_BT_CTRL_LE_PTR_CHECK_ENABLED (0)
#endif // CONFIG_BT_LE_PTR_CHECK_ENABLED
#if defined(CONFIG_BT_LE_CTRL_ADV_EVENT_INC_ON_FULL_TX_EN)
#define UC_BT_CTRL_LE_ADV_EVENT_INC_ON_FULL_TX_EN (1 << 0)
#else
#define UC_BT_CTRL_LE_ADV_EVENT_INC_ON_FULL_TX_EN (0)
#endif // BT_LE_CTRL_ADV_EVENT_INC_ON_FULL_TX_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_CH38_39_TX_AVOID_CONFLICT_EN)
#define UC_BT_CTRL_LE_ADV_CH38_39_TX_AVOID_CONFLICT_EN (1 << 1)
#else
#define UC_BT_CTRL_LE_ADV_CH38_39_TX_AVOID_CONFLICT_EN (0)
#endif // BT_LE_CTRL_ADV_CH38_39_TX_AVOID_CONFLICT_EN
#if defined(CONFIG_BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN)
#define UC_BT_ADV__LECH39_TXPWR_CONFIG_SEPARATELY_EN (1 << 2)
#define UC_BT_CTRL_LE_CH39_TX_PWR_DBM (CONFIG_BT_LE_DFT_CH39_TX_POWER_LEVEL_DBM_EFF)
#else
#define UC_BT_ADV__LECH39_TXPWR_CONFIG_SEPARATELY_EN (0)
#define UC_BT_CTRL_LE_CH39_TX_PWR_DBM (CONFIG_BT_LE_DFT_TX_POWER_LEVEL_DBM_EFF)
#endif // BT_LE_ADV_CH39_TXPWR_CONFIG_SEPARATELY_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN)
#define UC_BT_CTRL_LE_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN (1 << 3)
#else
#define UC_BT_CTRL_LE_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN (0)
#endif // BT_LE_CTRL_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN
#if defined(CONFIG_BT_LE_CTRL_ADV_RAND_CH_IDX_EN)
#define UC_BT_CTRL_LE_ADV_RAND_CH_IDX_EN (1 << 4)
#else
#define UC_BT_CTRL_LE_ADV_RAND_CH_IDX_EN (0)
#endif // BT_LE_CTRL_ADV_RAND_CH_IDX_EN
#define UC_BT_CTRL_LE_ADV_TX_OPTIONS \
(UC_BT_CTRL_LE_ADV_EVENT_INC_ON_FULL_TX_EN | UC_BT_CTRL_LE_ADV_CH38_39_TX_AVOID_CONFLICT_EN | \
UC_BT_ADV__LECH39_TXPWR_CONFIG_SEPARATELY_EN | \
UC_BT_CTRL_LE_ADV_TX_CONTINUE_WHEN_EXCEED_ITVL_EN | UC_BT_CTRL_LE_ADV_RAND_CH_IDX_EN)
#if defined(CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
#define UC_BT_CTRL_LE_FAST_CONN_DATA_TX_EN (CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN)
#else
#define UC_BT_CTRL_LE_FAST_CONN_DATA_TX_EN (0)
#endif // CONFIG_BT_LE_CTRL_FAST_CONN_DATA_TX_EN
/* Unchanged configuration */
#define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */
#define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */
#define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1)
#define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1)
#define BLE_LL_SCHED_ADV_MAX_USECS_N (852)
#define BLE_LL_SCHED_ADV_MAX_USECS_N (852)
#define BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N (502)
#define BLE_LL_SCHED_MAX_ADV_PDU_USECS_N (376)
#define BLE_LL_SCHED_MAX_ADV_PDU_USECS_N (376)
#define BLE_LL_SUB_VERS_NR_N (0x0000)
#define BLE_LL_SUB_VERS_NR_N (0x0000)
#define BLE_LL_JITTER_USECS_N (16)
#define BLE_LL_JITTER_USECS_N (16)
#define BLE_PHY_MAX_PWR_DBM_N (10)
#define BLE_PHY_MAX_PWR_DBM_N (10)
#define BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N (3000)
#define BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N (3000)
#define RTC_FREQ_N (32768) /* in Hz */
#define RTC_FREQ_N (32768) /* in Hz */
#define BLE_LL_TX_PWR_DBM_N (9)
#define BLE_LL_TX_PWR_DBM_N (9)
#ifdef CONFIG_BT_LE_BQB_TEST_EN
#define RUN_BQB_TEST (CONFIG_BT_LE_BQB_TEST_EN)
#define RUN_BQB_TEST (CONFIG_BT_LE_BQB_TEST_EN)
#else
#define RUN_BQB_TEST (0)
#define RUN_BQB_TEST (0)
#endif // CONFIG_BT_LE_BQB_TEST_EN
#define RUN_QA_TEST (0)
#define NIMBLE_DISABLE_SCAN_BACKOFF (0)
#define RUN_QA_TEST (0)
#define NIMBLE_DISABLE_SCAN_BACKOFF (0)
#ifdef __cplusplus
}
@@ -1,7 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2022 The Apache Software Foundation (ASF)
*
* SPDX-License-Identifier: Apache-2.0
*
* SPDX-FileContributor: 2019-2026 Espressif Systems (Shanghai) CO LTD
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -34,10 +36,9 @@
#define _OS_MEMPOOL_H_
#include <stdbool.h>
#include "os/os.h"
#include "os/os_error.h"
#include "os/queue.h"
#include "btdm_mempool.h"
#include "syscfg/syscfg.h"
#ifdef __cplusplus
extern "C" {
@@ -78,20 +79,28 @@ struct os_mempool {
SLIST_HEAD(,os_memblock);
/** Name for memory block */
const char *name;
#if MYNEWT_VAL(MP_BLOCK_REUSED)
/** The number of allocated blocks. */
uint16_t mp_alloc_blocks;
#endif // MYNEWT_VAL(MP_BLOCK_REUSED)
};
static_assert(sizeof(struct os_mempool) == sizeof(struct btdm_mempool),
"Error: size of os_mempool");
/**
* Indicates an extended mempool. Address can be safely cast to
* (struct os_mempool_ext *).
*/
#define OS_MEMPOOL_F_EXT 0x01
#define OS_MEMPOOL_F_EXT BIT(0)
/* Flag to indicate runtime allocation mode */
#define OS_MEMPOOL_F_RUNTIME 0x02
#define OS_MEMPOOL_F_RUNTIME BIT(1)
/* Flag to indicate reuse block for runtime allocation mode */
#define OS_MEMPOOL_F_REUSED 0x04
#define OS_MEMPOOL_F_REUSED BIT(2)
/* Flag to indicate no address range comparison */
#define OS_MEMPOOL_F_FRAG BIT(3)
/* Flag to indicate mempool source */
#define OS_MEMPOOL_F_CONTROLLER BIT(4)
#define OS_MEMPOOL_F_LOW_PRIO BIT(5)
#define OS_MEMPOOL_F_FORBID BIT(6)
#define OS_MEMPOOL_F_COMBINATION BIT(7)
struct os_mempool_ext;
@@ -116,12 +125,27 @@ struct os_mempool_ext;
typedef os_error_t os_mempool_put_fn(struct os_mempool_ext *ome, void *data,
void *arg);
/**
* Block get callback function. If configured, this callback gets executed
* whenever a block is fetched from the corresponding extended mempool.
*
* @param ome The extended mempool that a block is being
* fetched.
* @param arg Optional argument configured along with the
* callback.
*
* @return void * pointer of block, return NULL if get failed
*/
typedef void *os_mempool_get_fn(struct os_mempool_ext *ome, void *arg);
struct os_mempool_ext {
struct os_mempool mpe_mp;
/* Callback that is executed immediately when a block is freed. */
os_mempool_put_fn *mpe_put_cb;
void *mpe_put_arg;
os_mempool_get_fn *mpe_get_cb;
void *mpe_get_arg;
};
#define OS_MEMPOOL_INFO_NAME_LEN (32)
@@ -156,19 +180,6 @@ struct os_mempool_info {
struct os_mempool *os_mempool_info_get_next(struct os_mempool *,
struct os_mempool_info *);
/*
* To calculate size of the memory buffer needed for the pool. NOTE: This size
* is NOT in bytes! The size is the number of os_membuf_t elements required for
* the memory pool.
*/
#if MYNEWT_VAL(OS_MEMPOOL_GUARD)
/*
* Leave extra 4 bytes of guard area at the end.
*/
#define OS_MEMPOOL_BLOCK_SZ(sz) ((sz) + sizeof(os_membuf_t))
#else
#define OS_MEMPOOL_BLOCK_SZ(sz) (sz)
#endif
#if (OS_ALIGNMENT == 4)
typedef uint32_t os_membuf_t;
#elif (OS_ALIGNMENT == 8)
@@ -180,142 +191,11 @@ typedef __uint128_t os_membuf_t;
#endif /* OS_ALIGNMENT == * */
#define OS_MEMPOOL_SIZE(n,blksize) ((((blksize) + ((OS_ALIGNMENT)-1)) / (OS_ALIGNMENT)) * (n))
/**
* Calculates the number of bytes required to initialize a memory pool.
* When OS_MEMPOOL_GUARD is enabled, one extra os_membuf_t word per block is
* included for the guard pattern written by os_mempool_init; the buffer passed
* to os_mempool_init must be at least this size.
*/
#if CONFIG_BT_NIMBLE_ENABLED
#if MYNEWT_VAL(OS_MEMPOOL_GUARD)
#define OS_MEMPOOL_BYTES(n,blksize) \
(sizeof (os_membuf_t) * (OS_MEMPOOL_SIZE((n), (blksize)) + (n)))
#else
/** Calculates the number of bytes required to initialize a memory pool. */
#define OS_MEMPOOL_BYTES(n,blksize) \
(sizeof (os_membuf_t) * OS_MEMPOOL_SIZE((n), (blksize)))
#endif
#else
#define OS_MEMPOOL_BYTES(n,blksize) \
(sizeof (os_membuf_t) * OS_MEMPOOL_SIZE((n), (blksize)))
#endif
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
/**
* Initialize a memory pool.
*
* @param mp Pointer to a pointer to a mempool
* @param blocks The number of blocks in the pool
* @param blocks_size The size of the block, in bytes.
* @param membuf Pointer to memory to contain blocks.
* @param name Name of the pool.
*
* @return os_error_t
*/
os_error_t r_os_mempool_init(struct os_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
#define os_mempool_init r_os_mempool_init
/**
* Initializes an extended memory pool. Extended attributes (e.g., callbacks)
* are not specified when this function is called; they are assigned manually
* after initialization.
*
* @param mpe The extended memory pool to initialize.
* @param blocks The number of blocks in the pool.
* @param block_size The size of each block, in bytes.
* @param membuf Pointer to memory to contain blocks.
* @param name Name of the pool.
*
* @return os_error_t
*/
os_error_t r_os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
#define os_mempool_ext_init r_os_mempool_ext_init
/**
* Removes the specified mempool from the list of initialized mempools.
*
* @param mp The mempool to unregister.
*
* @return 0 on success;
* OS_INVALID_PARM if the mempool is not
* registered.
*/
// os_error_t r_os_mempool_unregister(struct os_mempool *mp);
#define os_mempool_unregister(mp)
/**
* Clears a memory pool.
*
* @param mp The mempool to clear.
*
* @return os_error_t
*/
os_error_t r_os_mempool_clear(struct os_mempool *mp);
#define os_mempool_clear r_os_mempool_clear
/**
* Performs an integrity check of the specified mempool. This function
* attempts to detect memory corruption in the specified memory pool.
*
* @param mp The mempool to check.
*
* @return true if the memory pool passes the integrity
* check;
* false if the memory pool is corrupt.
*/
bool r_os_mempool_is_sane(const struct os_mempool *mp);
#define os_mempool_is_sane r_os_mempool_is_sane
/**
* Checks if a memory block was allocated from the specified mempool.
*
* @param mp The mempool to check as parent.
* @param block_addr The memory block to check as child.
*
* @return 0 if the block does not belong to the mempool;
* 1 if the block does belong to the mempool.
*/
int r_os_memblock_from(const struct os_mempool *mp, const void *block_addr);
#define os_memblock_from r_os_memblock_from
/**
* Get a memory block from a memory pool
*
* @param mp Pointer to the memory pool
*
* @return void* Pointer to block if available; NULL otherwise
*/
void *r_os_memblock_get(struct os_mempool *mp);
#define os_memblock_get r_os_memblock_get
/**
* Puts the memory block back into the pool, ignoring the put callback, if any.
* This function should only be called from a put callback to free a block
* without causing infinite recursion.
*
* @param mp Pointer to memory pool
* @param block_addr Pointer to memory block
*
* @return os_error_t
*/
os_error_t r_os_memblock_put_from_cb(struct os_mempool *mp, void *block_addr);
#define os_memblock_put_from_cb r_os_memblock_put_from_cb
/**
* Puts the memory block back into the pool
*
* @param mp Pointer to memory pool
* @param block_addr Pointer to memory block
*
* @return os_error_t
*/
os_error_t r_os_memblock_put(struct os_mempool *mp, void *block_addr);
#define os_memblock_put r_os_memblock_put
#else
#if !CONFIG_BT_DUAL_MODE_ARCH
/**
* Initialize a memory pool.
*
@@ -330,6 +210,24 @@ os_error_t r_os_memblock_put(struct os_mempool *mp, void *block_addr);
os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
/**
* @brief Initialize a memory pool.
* INTERNAL USE ONLY
*
* @param mp Pointer to a pointer to a mempool
* @param blocks The number of blocks in the pool
* @param blocks_size The size of the block, in bytes.
* @param membuf Pointer to memory to contain blocks.
* @param name Name of the pool.
* @param flags Mempool flags
*
* @return os_error_t
*/
os_error_t
os_mempool_init_internal(struct os_mempool *mp, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name,
uint8_t flags);
/**
* Initializes an extended memory pool. Extended attributes (e.g., callbacks)
* are not specified when this function is called; they are assigned manually
@@ -346,6 +244,18 @@ os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks,
os_error_t os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name);
/**
* Assign the put and get callback for an extended memory pool.
*
* @param mpe The extended memory pool
* @param put_cb Block put callback function
* @param put_arg Argument for put callback
* @param get_cb Block put callback function
* @param get_arg Argument for get callback
*/
void os_ext_mempool_register_cb(struct os_mempool_ext *mpe, void *put_cb, void *put_arg,
void *get_cb, void *get_arg);
/**
* Removes the specified mempool from the list of initialized mempools.
*
@@ -428,7 +338,116 @@ os_error_t os_memblock_put_from_cb(struct os_mempool *mp, void *block_addr);
* @return os_error_t
*/
os_error_t os_memblock_put(struct os_mempool *mp, void *block_addr);
#endif
/**
* @brief Set the mp_flags of memory pool
*
* @param mp Pointer to memory pool
* @param flags Flags value
*/
void os_mempool_flags_set(struct os_mempool *mp, uint8_t flags);
/**
* @brief Clear the mp_flags of memory pool
*
* @param mp Pointer to memory pool
* @param flags Flags value
*/
void os_mempool_flags_clear(struct os_mempool *mp, uint8_t flags);
#else /* !CONFIG_BT_DUAL_MODE_ARCH */
#include "btdm_mempool.h"
static_assert(sizeof(struct os_mempool) == sizeof(struct btdm_mempool), "Error: size of os_mempool");
static_assert(sizeof(struct os_mempool_ext) == sizeof(struct btdm_mempool_ext), "Error: size of os_mempool_ext");
static_assert(sizeof(struct os_memblock) == sizeof(struct btdm_memblock), "Error: size of os_memblock");
static inline os_error_t
os_mempool_init(struct os_mempool *mp, uint16_t blocks, uint32_t block_size,
void *membuf, const char *name)
{
return btdm_mempool_init((struct btdm_mempool *)mp, blocks, block_size,
membuf, name);
}
static inline os_error_t
os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, const char *name)
{
return btdm_mempool_ext_init((struct btdm_mempool_ext *)mpe, blocks,
block_size, membuf, name);
}
static inline void
os_ext_mempool_register_cb(struct os_mempool_ext *mpe, void *put_cb,
void *put_arg, void *get_cb, void *get_arg)
{
btdm_mempool_ext_register_cb((struct btdm_mempool_ext *)mpe, put_cb,
put_arg, get_cb, get_arg);
}
static inline os_error_t
os_mempool_unregister(struct os_mempool *mp)
{
return btdm_mempool_unregister((struct btdm_mempool *)mp);
}
static inline os_error_t
os_mempool_clear(struct os_mempool *mp)
{
return btdm_mempool_clear((struct btdm_mempool *)mp);
}
static inline os_error_t
os_mempool_ext_clear(struct os_mempool_ext *mpe)
{
return btdm_mempool_ext_clear((struct btdm_mempool_ext *)mpe);
}
static inline bool
os_mempool_is_sane(const struct os_mempool *mp)
{
return btdm_mempool_is_sane((const struct btdm_mempool *)mp);
}
static inline int
os_memblock_from(const struct os_mempool *mp, const void *block_addr)
{
return btdm_memblock_from((const struct btdm_mempool *)mp, block_addr);
}
static inline void *
os_memblock_get(struct os_mempool *mp)
{
return btdm_memblock_get((struct btdm_mempool *)mp);
}
static inline os_error_t
os_memblock_put_from_cb(struct os_mempool *mp, void *block_addr)
{
return btdm_memblock_put_from_cb((struct btdm_mempool *)mp, block_addr);
}
static inline os_error_t
os_memblock_put(struct os_mempool *mp, void *block_addr)
{
return btdm_memblock_put((struct btdm_mempool *)mp, block_addr);
}
static inline void
os_mempool_flags_set(struct os_mempool *mp, uint8_t flags)
{
btdm_mempool_flags_set((struct btdm_mempool *)mp, flags);
}
static inline void
os_mempool_flags_clear(struct os_mempool *mp, uint8_t flags)
{
btdm_mempool_flags_clear((struct btdm_mempool *)mp, flags);
}
#endif /* !CONFIG_BT_DUAL_MODE_ARCH */
#ifdef __cplusplus
}
File diff suppressed because it is too large Load Diff