mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-09 19:47:56 +00:00
Merge pull request #113 from andrzej-kaczmarek/npl-dev
porting: Fix multiple build errors on non-Mynewt builds
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
#include "ble_ll_conn_priv.h"
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_DIRECT_TEST_MODE) == 1
|
||||
#include <ble_ll_dtm_priv.h>
|
||||
#include "ble_ll_dtm_priv.h"
|
||||
#endif
|
||||
|
||||
/* XXX:
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "syscfg/syscfg.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "ble_ll_conn_priv.h"
|
||||
|
||||
#if MYNEWT_VAL(BLE_LL_DIRECT_TEST_MODE) == 1
|
||||
#include <ble_ll_dtm_priv.h>
|
||||
#include "ble_ll_dtm_priv.h"
|
||||
#endif
|
||||
|
||||
static void ble_ll_hci_cmd_proc(struct ble_npl_event *ev);
|
||||
|
||||
@@ -3528,7 +3528,7 @@ ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
|
||||
return BLE_HS_ENOTSUP;
|
||||
#endif
|
||||
|
||||
uint32_t duration_ticks;
|
||||
ble_npl_time_t duration_ticks;
|
||||
int rc;
|
||||
|
||||
STATS_INC(ble_gap_stats, initiate);
|
||||
@@ -3584,7 +3584,7 @@ ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
|
||||
}
|
||||
|
||||
if (duration_ms != BLE_HS_FOREVER) {
|
||||
rc = os_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
rc = ble_npl_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
if (rc != 0) {
|
||||
/* Duration too great. */
|
||||
rc = BLE_HS_EINVAL;
|
||||
|
||||
@@ -117,14 +117,18 @@ ble_hs_evq_set(struct ble_npl_eventq *evq)
|
||||
int
|
||||
ble_hs_locked_by_cur_task(void)
|
||||
{
|
||||
#if MYNEWT
|
||||
struct os_task *owner;
|
||||
|
||||
if (!os_started()) {
|
||||
if (!ble_npl_os_started()) {
|
||||
return ble_hs_dbg_mutex_locked;
|
||||
}
|
||||
|
||||
owner = ble_hs_mutex.mu.mu_owner;
|
||||
return owner != NULL && owner == os_sched_get_current_task();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -147,7 +151,7 @@ ble_hs_lock_nested(void)
|
||||
int rc;
|
||||
|
||||
#if MYNEWT_VAL(BLE_HS_DEBUG)
|
||||
if (!os_started()) {
|
||||
if (!ble_npl_os_started()) {
|
||||
ble_hs_dbg_mutex_locked = 1;
|
||||
return;
|
||||
}
|
||||
@@ -166,7 +170,7 @@ ble_hs_unlock_nested(void)
|
||||
int rc;
|
||||
|
||||
#if MYNEWT_VAL(BLE_HS_DEBUG)
|
||||
if (!os_started()) {
|
||||
if (!ble_npl_os_started()) {
|
||||
ble_hs_dbg_mutex_locked = 0;
|
||||
return;
|
||||
}
|
||||
@@ -184,7 +188,7 @@ ble_hs_lock(void)
|
||||
{
|
||||
BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task());
|
||||
#if MYNEWT_VAL(BLE_HS_DEBUG)
|
||||
if (!os_started()) {
|
||||
if (!ble_npl_os_started()) {
|
||||
BLE_HS_DBG_ASSERT(!ble_hs_dbg_mutex_locked);
|
||||
}
|
||||
#endif
|
||||
@@ -199,7 +203,7 @@ void
|
||||
ble_hs_unlock(void)
|
||||
{
|
||||
#if MYNEWT_VAL(BLE_HS_DEBUG)
|
||||
if (!os_started()) {
|
||||
if (!ble_npl_os_started()) {
|
||||
BLE_HS_DBG_ASSERT(ble_hs_dbg_mutex_locked);
|
||||
}
|
||||
#endif
|
||||
@@ -517,7 +521,7 @@ void
|
||||
ble_hs_notifications_sched(void)
|
||||
{
|
||||
#if !MYNEWT_VAL(BLE_HS_REQUIRE_OS)
|
||||
if (!os_started()) {
|
||||
if (!ble_npl_os_started()) {
|
||||
ble_gatts_tx_notifications();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#if MYNEWT_VAL(BLE_HS_FLOW_CTRL)
|
||||
|
||||
#define BLE_HS_FLOW_ITVL_TICKS \
|
||||
(MYNEWT_VAL(BLE_HS_FLOW_CTRL_ITVL) * OS_TICKS_PER_SEC / 1000)
|
||||
ble_npl_time_ms_to_ticks32(MYNEWT_VAL(BLE_HS_FLOW_CTRL_ITVL))
|
||||
|
||||
/**
|
||||
* The number of freed buffers since the most-recent
|
||||
@@ -34,13 +34,11 @@
|
||||
static uint16_t ble_hs_flow_num_completed_pkts;
|
||||
|
||||
/** Periodically sends number-of-completed-packets events. */
|
||||
static struct os_callout ble_hs_flow_timer;
|
||||
static struct ble_npl_callout ble_hs_flow_timer;
|
||||
|
||||
static os_event_fn ble_hs_flow_event_cb;
|
||||
static ble_npl_event_fn ble_hs_flow_event_cb;
|
||||
|
||||
static struct os_event ble_hs_flow_ev = {
|
||||
.ev_cb = ble_hs_flow_event_cb,
|
||||
};
|
||||
static struct ble_npl_event ble_hs_flow_ev;
|
||||
|
||||
static int
|
||||
ble_hs_flow_tx_num_comp_pkts(void)
|
||||
@@ -84,7 +82,7 @@ ble_hs_flow_tx_num_comp_pkts(void)
|
||||
rc = ble_hs_hci_cmd_send_buf(
|
||||
BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND,
|
||||
BLE_HCI_OCF_CB_HOST_NUM_COMP_PKTS),
|
||||
buf, off);
|
||||
buf, sizeof(buf));
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
@@ -95,7 +93,7 @@ ble_hs_flow_tx_num_comp_pkts(void)
|
||||
}
|
||||
|
||||
static void
|
||||
ble_hs_flow_event_cb(struct os_event *ev)
|
||||
ble_hs_flow_event_cb(struct ble_npl_event *ev)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -135,10 +133,10 @@ ble_hs_flow_inc_completed_pkts(struct ble_hs_conn *conn)
|
||||
*/
|
||||
num_free = MYNEWT_VAL(BLE_ACL_BUF_COUNT) - ble_hs_flow_num_completed_pkts;
|
||||
if (num_free <= MYNEWT_VAL(BLE_HS_FLOW_CTRL_THRESH)) {
|
||||
os_eventq_put(ble_hs_evq_get(), &ble_hs_flow_ev);
|
||||
os_callout_stop(&ble_hs_flow_timer);
|
||||
ble_npl_eventq_put(ble_hs_evq_get(), &ble_hs_flow_ev);
|
||||
ble_npl_callout_stop(&ble_hs_flow_timer);
|
||||
} else if (ble_hs_flow_num_completed_pkts == 1) {
|
||||
rc = os_callout_reset(&ble_hs_flow_timer, BLE_HS_FLOW_ITVL_TICKS);
|
||||
rc = ble_npl_callout_reset(&ble_hs_flow_timer, BLE_HS_FLOW_ITVL_TICKS);
|
||||
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
|
||||
}
|
||||
}
|
||||
@@ -229,9 +227,11 @@ ble_hs_flow_startup(void)
|
||||
struct hci_host_buf_size buf_size_cmd;
|
||||
int rc;
|
||||
|
||||
ble_npl_event_init(&ble_hs_flow_ev, ble_hs_flow_event_cb, NULL);
|
||||
|
||||
/* Assume failure. */
|
||||
ble_hci_trans_set_acl_free_cb(NULL, NULL);
|
||||
os_callout_stop(&ble_hs_flow_timer);
|
||||
ble_npl_callout_stop(&ble_hs_flow_timer);
|
||||
|
||||
rc = ble_hs_hci_cmd_tx_set_ctlr_to_host_fc(BLE_HCI_CTLR_TO_HOST_FC_ACL);
|
||||
if (rc != 0) {
|
||||
@@ -251,8 +251,8 @@ ble_hs_flow_startup(void)
|
||||
/* Flow control successfully enabled. */
|
||||
ble_hs_flow_num_completed_pkts = 0;
|
||||
ble_hci_trans_set_acl_free_cb(ble_hs_flow_acl_free, NULL);
|
||||
os_callout_init(&ble_hs_flow_timer, ble_hs_evq_get(),
|
||||
ble_hs_flow_event_cb, NULL);
|
||||
ble_npl_callout_init(&ble_hs_flow_timer, ble_hs_evq_get(),
|
||||
ble_hs_flow_event_cb, NULL);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -27,6 +27,7 @@ extern "C" {
|
||||
static inline void
|
||||
log_dummy(void *log, ...)
|
||||
{
|
||||
(void)log;
|
||||
}
|
||||
|
||||
#define LOG_DEBUG(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "os/os.h"
|
||||
#include "os/queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -188,6 +189,15 @@ 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, char *name);
|
||||
|
||||
/**
|
||||
* Clears a memory pool.
|
||||
*
|
||||
* @param mp The mempool to clear.
|
||||
*
|
||||
* @return os_error_t
|
||||
*/
|
||||
os_error_t os_mempool_clear(struct os_mempool *mp);
|
||||
|
||||
/**
|
||||
* Performs an integrity check of the specified mempool. This function
|
||||
* attempts to detect memory corruption in the specified memory pool.
|
||||
|
||||
@@ -136,6 +136,45 @@ os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
|
||||
return 0;
|
||||
}
|
||||
|
||||
os_error_t
|
||||
os_mempool_clear(struct os_mempool *mp)
|
||||
{
|
||||
struct os_memblock *block_ptr;
|
||||
int true_block_size;
|
||||
uint8_t *block_addr;
|
||||
uint16_t blocks;
|
||||
|
||||
if (!mp) {
|
||||
return OS_INVALID_PARM;
|
||||
}
|
||||
|
||||
true_block_size = OS_MEM_TRUE_BLOCK_SIZE(mp->mp_block_size);
|
||||
|
||||
/* cleanup the memory pool structure */
|
||||
mp->mp_num_free = mp->mp_num_blocks;
|
||||
mp->mp_min_free = mp->mp_num_blocks;
|
||||
os_mempool_poison((void *)mp->mp_membuf_addr, true_block_size);
|
||||
SLIST_FIRST(mp) = (void *)mp->mp_membuf_addr;
|
||||
|
||||
/* Chain the memory blocks to the free list */
|
||||
block_addr = (uint8_t *)mp->mp_membuf_addr;
|
||||
block_ptr = (struct os_memblock *)block_addr;
|
||||
blocks = mp->mp_num_blocks;
|
||||
|
||||
while (blocks > 1) {
|
||||
block_addr += true_block_size;
|
||||
os_mempool_poison(block_addr, true_block_size);
|
||||
SLIST_NEXT(block_ptr, mb_next) = (struct os_memblock *)block_addr;
|
||||
block_ptr = (struct os_memblock *)block_addr;
|
||||
--blocks;
|
||||
}
|
||||
|
||||
/* Last one in the list should be NULL */
|
||||
SLIST_NEXT(block_ptr, mb_next) = NULL;
|
||||
|
||||
return OS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
os_mempool_is_sane(const struct os_mempool *mp)
|
||||
{
|
||||
@@ -194,8 +233,6 @@ os_memblock_get(struct os_mempool *mp)
|
||||
/* Get a free block */
|
||||
block = SLIST_FIRST(mp);
|
||||
|
||||
os_mempool_poison_check(block, OS_MEMPOOL_TRUE_BLOCK_SIZE(mp));
|
||||
|
||||
/* Set new free list head */
|
||||
SLIST_FIRST(mp) = SLIST_NEXT(block, mb_next);
|
||||
|
||||
@@ -206,6 +243,10 @@ os_memblock_get(struct os_mempool *mp)
|
||||
}
|
||||
}
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
|
||||
if (block) {
|
||||
os_mempool_poison_check(block, OS_MEMPOOL_TRUE_BLOCK_SIZE(mp));
|
||||
}
|
||||
}
|
||||
|
||||
return (void *)block;
|
||||
|
||||
Reference in New Issue
Block a user